diff --git a/CometChat.d.ts b/CometChat.d.ts index a6dbcd6..4eec5ce 100644 --- a/CometChat.d.ts +++ b/CometChat.d.ts @@ -299,6 +299,25 @@ export namespace CometChat { /**-------------------------------------------------------------------* * User related functions provided by CometChat class * *--------------------------------------------------------------------**/ + /** + * function to create user. + * + * @static + * @param {User} user, authOnly apiKey + * @returns Promise + * @memberof CometChat + */ + export function createUser(user: User | any, apiKey: string): Promise; + + /** + * + * function to update the already existing user and returns the result with updated user + * @param {User} user, authOnly apiKey + * @returns Promise + * @memberof CometChat + */ + export function updateUser(user: User | any, apiKey: string): Promise; + /** * function to get the information for the uid provided as an argument * @static @@ -535,13 +554,7 @@ export namespace CometChat { /**-------------------------------------------------------------------------------------------------------* * Events listeners setting and removing . * *--------------------------------------------------------------------------------------------------------**/ - /** - * It will add the MessgeEventListener to list of the MessageEventListeners. - * - * @param {string} name - * @param {Function} callback - * @memberof CometChat - */ + export function addMessageListener(name: string, messageEventListener: MessageListener): void; /** * It will remove the MessgeEventListener from the list of the MessageEventListeners. @@ -689,12 +702,12 @@ export namespace CometChat { setConversationType(conversationType: string): void; setLastMessage(lastMessage: TextMessage | MediaMessage | CustomMessage | any): void; setConversationWith(conversationWith: User | Group): void; - setUnreadMessageCount(unreadMessageCount: number | any): void; + setUnreadMessageCount(unreadMessageCount: number): void; getConversationId(): string; getConversationType(): string; getLastMessage(): TextMessage | MediaMessage | CustomMessage | any; getConversationWith(): User | Group; - getUnreadMessageCount(): number | any; + getUnreadMessageCount(): number; constructor(conversationId: string, conversationType: string, lastMessage: TextMessage | MediaMessage | CustomMessage | any, conversationWith: User | Group, unreadMessageCount: number | any) } @@ -1431,7 +1444,12 @@ export namespace CometChat { getJoinedAt(): string; setJoinedAt(joinedAt: string): void; } - + export class ConnectionListener { + onConnected?: Function; + inConnecting?: Function; + onDisconnected?: Function; + constructor(...args: any[]); + } export class MessageListener { onAction?: Function; onTextMessageReceived?: Function; diff --git a/CometChat.js b/CometChat.js index 97b27a3..4acf17c 100644 --- a/CometChat.js +++ b/CometChat.js @@ -1 +1 @@ -!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,function(){return function(n){var r={};function o(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}return o.m=n,o.c=r,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=39)}([function(e,t,n){"use strict";t.__esModule=!0;var r,o,s,i=n(2);t.constants={DEFAULT_STORE:"cometchat",MSG_VER_PRE:"store-ver-pre",MSG_VER_POST:"store-ver-post"},t.DEFAULT_VALUES={ZERO:0,MSGS_LIMIT:30,MSGS_MAX_LIMIT:100,USERS_LIMIT:30,USERS_MAX_LIMIT:100,GROUPS_LIMIT:30,GROUPS_MAX_LIMIT:100,CONVERSATION_MAX_LIMIT:50,CALL_TIMEOUT:45,DEFAULT_MSG_ID:0,DEFAULT_MAX_TYPING_INDICATOR_LIMIT:5,REGION_DEFAULT:"eu",REGION_DEFAULT_EU:"eu",REGION_DEFAULT_US:"us",REGION_DEFAULT_IN:"in",REGION_DEFAULT_PRIVATE:"private"},(r=t.GroupType||(t.GroupType={})).Public="public",r.Private="private",r.Protected="protected",r.Password="password",t.GROUP_TYPE={PUBLIC:"public",PRIVATE:"private",PROTECTED:"password",PASSWORD:"password"},(o=t.GroupMemberScope||(t.GroupMemberScope={})).Admin="admin",o.Moderator="moderator",o.Member="member",t.GROUP_MEMBER_SCOPE={ADMIN:"admin",MODERATOR:"moderator",PARTICIPANT:"participant"},t.APPINFO={platform:"IONIC_CORDOVA",sdkVersion:"v2.0.6",apiVersion:"v2.0"},t.XMPP={host:"encke.cometchat.com",port:7443,ws_url:"/ws/",bind_url:"/http-bind/",deafult_password:"CometChat",PUBSUB_CHANNEL:"pubsub",jid_string:"[%s]%s@%s/%s",bare_jid_string:"[%s]%s@%s",username_string:"[%s]%s",muc_jid_string:"[%s]%s@%s.%s",pubsub_global_string:"[%s]global_presence",pubsub_default_string:"[%s]default",pubsub_role_string:"[%s]%s",xmpp_resource:"javascripts_"+(new Date).getTime(),CONVERSATION:{TYPE:{CHAT:"chat",GROUP_CHAT:"groupchat"}}},t.LOCAL_STORE={COMMON_STORE:"common_store",MESSAGE_LISTENERS_LIST:"message_listeners_list",USERS_STORE:"users_store",MESSAGES_STORE:"messages_store",KEYS_STORE:"keys_store",STORE_STRING:"%s:%s"},t.ResponseConstants={RESPONSE_KEYS:{KEY_DATA:"data",KEY_META:"meta",KEY_CURSOR:"cursor",KEY_ACTION:"action",KEY_MESSAGE:"message",KEY_ERROR:"error",KEY_ERROR_DETAILS:"details",KEY_ERROR_CODE:"code",KEY_ERROR_MESSAGE:"message",KEY_AUTH_TOKEN:"authToken",KEY_WS_CHANNEL:"wsChannel",KEY_IDENTITY:"identity",KEY_SERVICE:"identity",KEY_ENTITIES:"entities",KEY_ENTITITY:"entity",KEY_ENTITYTYPE:"entityType",KEY_ATTACHMENTS:"attachments",CODE_REQUEST_OK:200,CODE_BAD_REQUEST:401,UNREAD_UNDELIVERED_KEYS:{ENTITY:"entity",ENTITY_TYPE:"entityType",ENTITY_Id:"entityId",COUNT:"count"},GROUP_MEMBERS_RESPONSE:{SUCCESS:"success",ERROR:"error",MESSAGE:"message"},KEY_ENTITY_TYPE:{USER:"user",GROUP:"group"}}},t.DELIVERY_RECEIPTS={RECEIVER_ID:"receiverId",RECEIVER_TYPE:"type",RECIPIENT:"recipient",MESSAGE_ID:"messageId",RECEIVED:"delivered",DELIVERED_AT:"deliveredAt",ID:"id",TIME:"time",DELIVERED_TO_ME_AT:"deliveredToMeAt"},t.READ_RECEIPTS={RECEIVER_ID:"receiverId",RECEIVER_TYPE:"type",RECIPIENT:"recipient",MESSAGE_ID:"messageId",READ:"read",READ_AT:"readAt",ID:"id",TIME:"time",READ_BY_ME_AT:"readByMeAt"},t.MessageConstatnts={XMPP_KEYS:{FROM:"from",TO:"to",TYPE:"type",TYPE_USER:"chat",TYPE_GROUP:"groupchat"},TYPE:{TEXT:"text",MEDIA:"media",IMAGE:"image",VIDEO:"video",AUDIO:"audio",FILE:"file",CUSTOM:"custom"},CATEGORY:{MESSAGE:"message",ACTION:"action",CALL:"call",CUSTOM:"custom"},RECEIVER_TYPE:{USER:"user",GROUP:"group"},KEYS:{ATTATCHMENT:"attatchment",ATTATCHMENTS:"attachments",ACTION:"action",TYPE:"type",DATA:"data",ID:"id",MUID:"muid",SENDER:"sender",RECEIVER:"receiver",RECEIVER_ID:"receiverId",CATEGORY:"category",RECEIVER_TYPE:"receiverType",SENT_AT:"sentAt",STATUS:"status",TEXT:"text",URL:"url",METADATA:"metadata",RECEIPTS:"receipts",MY_RECEIPTS:"myReceipt",CUSTOM_DATA:"customData",CUSTOM_SUB_TYPE:"subType"},KNOWN_MEDIA_TYPE:{IMAGE:[],VIDEO:[],AUDIO:[],FILE:[]},PAGINATION:{AFFIX:{APPEND:"append",PREPEND:"prepend"},CURSOR_FILEDS:{ID:"id",SENT_AT:"sentAt"},CURSOR_AFFIX_DEFAULT:"prepend",CURSOR_FIELD_DEFAULT:"sentAt",KEYS:{PER_PAGE:"per_page",CURSOR_AFFIX:"cursorAffix",AFFIX:"affix",CURSOR_FIELD:"cursorField",CURSOR_VALUE:"cursorValue",UID:"uid",SENT_AT:"sentAt",ID:"id",CURRENT_PAGE:"page",UNREAD:"unread",UNDELIVERED:"undelivered",HIDE_MESSAGES_FROM_BLOCKED_USER:"hideMessagesFromBlockedUsers",SEARCH_KEY:"searchKey",ONLY_UPDATES:"onlyUpdates",UPDATED_AT:"updatedAt",CATEGORY:"category",TYPE:"type"}}},t.ATTACHMENTS_CONSTANTS={KEYS:{EXTENSION:"extension",MIME_TYPE:"mimeType",NAME:"name",SIZE:"size",URL:"url"}},(s=t.MessageCategory||(t.MessageCategory={})).ACTION="action",s.MESSAGE="message",s.CALL="call",s.CUSTOM="custom",t.TYPING_NOTIFICATION={RECEIVER_ID:"receiverId",RECEIVER_TYPE:"receiverType",META:"metadata",KEYS:{TYPING_NOTIFICATION:"typingNotification",TIMESTAMP:"timestamp"},ACTIONS:{STARTED:"started",ENDED:"ended"}},t.ActionConstatnts={ACTION_SUBJECTS:{ACTION_ON:"on",ACTION_BY:"by",ACTION_FOR:"for"},ACTION_ENTITY_TYPE:{GROUP_USER:"groupuser",USER:"user",GROUP:"group",MESSAGE:"message"},ACTION_KEYS:{ACTION_CREATED:"created",ACTION_UPDATED:"updated",ACTION_DELETED:"deleted",ENTITIES:"entities",ENTITY:"entity",ENTITY_TYPE:"entityType",TYPE_MEMBER_JOINED:"joined",TYPE_MEMBER_LEFT:"left",TYPE_MEMBER_KICKED:"kicked",TYPE_MEMBER_BANNED:"banned",TYPE_MEMBER_UNBANNED:"unbanned",TYPE_MEMBER_INVITED:"invited",TYPE_MEMBER_ADDED:"added",ACTION_SCOPE_CHANGED:"scopeChanged",ACTION_TYPE_USER:"user",ACTION_TYPE_GROUP:"group",ACTION_TYPE_GROUP_MEMBER:"groupMember",TYPE_MESSAGE_EDITED:"edited",TYPE_MESSAGE_DELETED:"deleted",ACTION_TYPE_CALL:"call",EXTRAS:"extras",SCOPE:"scope",NEW:"new",OLD:"old"},ActionMessages:{ACTION_GROUP_JOINED_MESSAGE:"%s joined",ACTION_GROUP_LEFT_MESSAGE:"%s left",ACTION_MEMBER_KICKED_MESSAGE:"%s kicked %s",ACTION_MEMBER_BANNED_MESSAGE:"%s banned %s",ACTION_MEMBER_UNBANNED_MESSAGE:"%s unbanned %s",ACTION_MEMBER_INVITED_MESSAGE:"%s banned %s",ACTION_MESSAGE_EDITED_MESSAGE:" Message Edited",ACTION_MESSAGE_DELETED_MESSAGE:"Message Deleted",ACTION_MEMBER_SCOPE_CHANGED:"%s made %s %s",ACTION_MEMBER_ADDED_TO_GROUP:"%s added %s"},ACTION_TYPE:{TYPE_MEMBER_JOINED:"joined",TYPE_MEMBER_LEFT:"left",TYPE_MEMBER_KICKED:"kicked",TYPE_MEMBER_BANNED:"banned",TYPE_MEMBER_UNBANNED:"unbanned",TYPE_MEMBER_INVITED:"invited",TYPE_MEMBER_SCOPE_CHANGED:"scopeChanged",TYPE_MESSAGE:"message",TYPE_MESSAGE_EDITED:"edited",TYPE_MESSAGE_DELETED:"deleted",TYPE_MEMBER_ADDED:"added"},ACTIONS:{MEMBER_JOINED:"joined",MEMBER_LEFT:"left",MEMBER_KICKED:"kicked",MEMBER_BANNED:"banned",MEMBER_UNBANNED:"unbanned",MEMBER_INVITED:"invited",MEMBER_SCOPE_CHANGED:"scopeChanged"}},t.BlockedUsersConstants={REQUEST_KEYS:{DIRECTIONS:{BOTH:"both",HAS_BLOCKED_ME:"hasBlockedMe",BLOCKED_BY_ME:"blockedByMe"}}},t.CallConstants={CALL_TYPE_AUDIO:"audio",CALL_TYPE_VIDEO:"video",CALL_TYPE:{AUDIO:"audio",VIDEO:"video"},RECEIVER_TYPE_GROUP:"group",RECEIVER_TYPE_USER:"user",CALL_KEYS:{CALL_DATA:"data",CALL_ID:"id",CALL_SESSION_ID:"sessionid",CALL_RECEIVER:"receiver",CALL_SENDER:"sender",CALL_RECEIVER_TYPE:"receiverType",CALL_STATUS:"status",CALL_TYPE:"type",CALL_INITIATED_AT:"initiatedAt",CALL_JOINED_AT:"joinedAt",CALL_LEFT_AT:"leftAt",CALL_METADATA:"metadata",CALL_ENTITIES:"entities",CALL_ENTITY_TYPE:"entityType",CALL_ENTITY:"entity",CALL_ENTITY_USER:"user",CALL_ENTITY_GROUP:"group"},CALL_STATUS:{INITIATED:"initiated",ONGOING:"ongoing",UNANSWERED:"unanswered",REJECTED:"rejected",BUSY:"busy",CANCELLED:"cancelled",ENDED:"ended"}},t.GroupConstants={KEYS:{NAME:"name",GUID:"guid",TYPE:"type",PASSWORD:"password",ICON:"icon",DESCRIPTION:"description",OWNER:"owner",METADATA:"metadata",CREATED_AT:"createdAt",UPDATED_AT:"updatedAt",HAS_JOINED:"hasJoined",WS_CHANNEL:"wsChannel"}},t.GroupMemersConstans={KEYS:{SCOPE:"scope",UID:"uid",GUID:"guid",USER:"user",NAME:"name"}},t.UserConstants={UID:"uid",NAME:"name",AUTH_TOKEN:"authToken",AVATAR:"avatar",CREDITS:"credits",LAST_ACTIVE_AT:"lastActiveAt",LINK:"link",META_DATA:"metaData",ROLE:"role",STATUS:"status",STATUS_MESSAGE:"statusMessage",USER_NAME:"user_name"},t.Errors={ERROR_IO_EXCEPTION:"ERROR_IO_EXCEPTION",ERROR_JSON_EXCEPTION:"ERROR_JSON_EXCEPTION",ERROR_PASSWORD_MISSING:"ERROR_PASSWORD_MISSING",ERROR_LIMIT_EXCEEDED:"ERROR_LIMIT_EXCEEDED",ERROR_USER_NOT_LOGGED_IN:"ERROR_USER_NOT_LOGGED_IN",ERROR_INVALID_GUID:"ERROR_INVALID_GUID",ERROR_PASSWORD_MISSING_MESSAGE:"Password is mandatory for a password group",ERROR_LIMIT_EXCEEDED_MESSAGE:"Limit Exceeded Max limit of %s",ERROR_USER_NOT_LOGGED_IN_MESSAGE:"Please log in to CometChat before calling this method",ERROR_INVALID_GUID_MESSAGE:"Please provide a valid GUID",ERROR_DEFAULT_MESSAGE:"Something went wrong"},t.CALL_ERROR={CALL_ALREADY_INITIATED:{code:"CALL_ALREADY_INITIATED",name:"CALL_ALREADY_INITIATED",message:"There is already call in progress",details:{}},ERROR_IN_CALLING:{code:"CALL_IN_PROGRESS",name:"CALL_ALREADY_INITIATED",message:"There is already call in progress",details:{}}},t.PARAMETER_ERROR={PARAMETER_REQUIRED:{code:"%s_NOT_PROVIDED",name:"%s_NOT_PROVIDED",message:"please provide the %s",details:{}}},t.GENERAL_ERROR={MUST_BE_A_STRING:{code:"INVALID_%s",name:"INVALID_%s",message:"%s should be a string",details:{}},MUST_BE_A_NUMBER:{code:"INVALID_%s",name:"INVALID_%s",message:"%s should be a number",details:{}},MUST_BE_A_OBJECT:{code:"INVALID_%s",name:"INVALID_%s",message:"%s should be a object",details:{}},MUST_BE_AN_ARRAY:{code:"INVALID_%s",name:"INVALID_%s",message:"%s should be an array",details:{}},MUST_BE_A_BOOLEAN:{code:"INVALID_%s",name:"INVALID_%s",message:"%s should be a boolean",details:{}},MUST_BE_A_BLOB:{code:"INVALID_%s",name:"INVALID_%s",message:"%s should be a blob",details:{}},INVALID:{code:"INVALID_%s",name:"INVALID_%s",message:"%s is invalid",details:{}},COMPULSORY:{code:"%s_IS_COMPULSORY",name:"%s_IS_COMPULSORY",message:"%s is required",details:{}},LIMIT_EXCEEDED:{code:"ERROR_%s_EXCEEDED",name:"ERROR_%s_EXCEEDED",message:"%s exceeded max limit of %s",details:{}},MUST_BE_A_POSITIVE_NUMBER:{code:"INVALID_%s",name:"INVALID_%s",message:"%s should be a postive integer greater than 0",details:{}},INVALID_MEDIA_FILE:{code:"INVALID_%s",name:"INVALID_%s",message:"The message type does not match the file's mime type.",details:{}},EMPTY_STRING:{code:"INVALID_%s",name:"INVALID_%s",message:"The parameter %s is required and it cannot be empty",details:{}}},t.UserErrors={INVALID_STATUS:new i.CometChatException({code:"INVALID_STATUS_VALUE",name:"INVALID_STATUS_VALUE",message:"status accepts only two values: online and offline",details:""}),INVALID_DIRECTION:new i.CometChatException({code:"INVALID_DIRECTION_VALUE",name:"INVALID_DIRECTION_VALUE",message:"direction accepts only three values: both, blockedByMe and hasBlockedMe",details:""}),USER_NOT_LOGGED_IN:new i.CometChatException({code:"USER_NOT_LOGGED_IN",name:"USER_NOT_LOGGED_IN",message:"please login before using any other method of cometchat",details:""})},t.GroupErrors={NOT_A_GROUP:new i.CometChatException({code:"NOT_A_GROUP",message:"Please use group class to construct a new group"}),INVALID_SCOPE:new i.CometChatException({code:"INVALID_SCOPE_VALUE",name:"INVALID_SCOPE_VALUE",message:"Scope can be admin, moderator or participant",details:""}),INVALID_GROUP_TYPE:new i.CometChatException({code:"INVALID_GROUP_TYPE",name:"INVALID_GROUP_TYPE",message:"Group Type can be public, private, protected or password",details:""})},t.PresenceConstatnts={XMPP_KEYS:{FROM:"from",STATUS:"status",LAST_ACTIVE_AT:"lastActiveAt",TYPE:"type"},STATUS:{ONLINE:"online",AVAILABLE:"available",OFFLINE:"offline",JOINED:"JOINED",LEFT:"LEFT"}},t.APP_SETTINGS={APP_SETTINGS:"app_settings",KEYS:{CHAT_HOST:"CHAT_HOST",CHAT_USE_SSL:"CHAT_USE_SSL",GROUP_SERVICE:"GROUP_SERVICE",CALL_SERVICE:"CALL_SERVICE",CHAT_WS_PORT:"CHAT_WS_PORT",CHAT_WSS_PORT:"CHAT_WSS_PORT",CHAT_HTTP_BIND_PORT:"CHAT_HTTP_BIND_PORT",CHAT_HTTPS_BIND_PORT:"CHAT_HTTPS_BIND_PORT",ADMIN_API_HOST:"ADMIN_API_HOST",CLIENT_API_HOST:"CLIENT_API_HOST",WEBRTC_HOST:"WEBRTC_HOST",WEBRTC_USE_SSL:"WEBRTC_USE_SSL",WEBRTC_WS_PORT:"WEBRTC_WS_PORT",WEBRTC_WSS_PORT:"WEBRTC_WSS_PORT",WEBRTC_HTTP_BIND_PORT:"WEBRTC_HTTP_BIND_PORT",WEBRTC_HTTPS_BIND_PORT:"WEBRTC_HTTPS_BIND_PORT",EXTENSION_LIST:"extensions",EXTENSION_KEYS:{ID:"id",NAME:"name"}}},t.COMMON_UTILITY_CONSTANTS={TYPE_CONSTANTS:{BOOLEAN:"boolean",STRING:"string",OBJECT:"object",NUMBER:"number"}}},function(e,r,t){"use strict";r.__esModule=!0;var o=t(9),s=t(0),i=t(4),a=t(2),c=t(17),u=t(18),l=t(19),d=t(3),n=t(14);function E(e){return null!=e&&("string"==typeof e&&(e=e.trim()),"object"==typeof e&&0===Object.keys(e).length&&(e=void 0)),["",0,"0",!1,null,"null",void 0,"undefined"].includes(e)}function h(e){for(var r=[],t=1;t>>32-t}function S(e){var t,n="";for(t=7;0<=t;t--)n+=(e>>>4*t&15).toString(16);return n}r.Logger=p,r.getCurrentTime=function(){return(new Date).getTime()},r.getAppSettings=function(){return new Promise(function(t,n){o.LocalStorage.getInstance().get(s.APP_SETTINGS.APP_SETTINGS).then(function(e){E(e)?f().then(function(e){t(e)},function(e){n(e)}):t(e)},function(e){n(e)})})},r.getUpdatedSettings=f,r.isImage=function(e){var t;return e.type&&e.type.toLowerCase().includes("image")&&(t=!0),t},r.isVideo=function(e){var t;return e.type&&e.type.toLowerCase().includes("video")&&(t=!0),t},r.isAudio=function(e){var t;return e.type&&e.type.toLowerCase().includes("audio")&&(t=!0),t},r.validateScope=function(e){return typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"SCOPE","SCOPE","scope"))):E(e)?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"SCOPE","SCOPE","scope"))):e!=d.CometChat.GROUP_MEMBER_SCOPE.ADMIN&&e!=d.CometChat.GROUP_MEMBER_SCOPE.MODERATOR&&e!=d.CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT?new a.CometChatException(s.GroupErrors.INVALID_SCOPE):void 0},r.validateUpdateGroup=function(e){return e.hasOwnProperty(s.GroupConstants.KEYS.GUID)?typeof e[s.GroupConstants.KEYS.GUID]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GUID","GUID","guid"))):E(e[s.GroupConstants.KEYS.GUID])?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"GUID","GUID","guid"))):e.hasOwnProperty(s.GroupConstants.KEYS.NAME)&&""===e[s.GroupConstants.KEYS.NAME]?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.EMPTY_STRING),"GROUP_NAME","GROUP_NAME","group name"))):void 0:new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"GUID","GUID","guid")))},r.validateJoinGroup=function(e,t,n){if(typeof e==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.OBJECT){if(!e.hasOwnProperty(s.GroupConstants.KEYS.GUID))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"GUID","GUID","guid")));if(typeof e[s.GroupConstants.KEYS.GUID]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GUID","GUID","guid")));if(E(e[s.GroupConstants.KEYS.GUID]))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"GUID","GUID","guid")));if(!e.hasOwnProperty(s.GroupConstants.KEYS.TYPE))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"GROUP_TYPE","GROUP_TYPE","group type")));if(typeof e[s.GroupConstants.KEYS.TYPE]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GROUP_TYPE","GROUP_TYPE","group type")));if(E(e[s.GroupConstants.KEYS.TYPE]))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"GROUP_TYPE","GROUP_TYPE","group type")));if(e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PUBLIC&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PASSWORD&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PROTECTED&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PRIVATE)return new a.CometChatException(s.GroupErrors.INVALID_GROUP_TYPE);if(e[s.GroupConstants.KEYS.TYPE].toLowerCase()==d.CometChat.GROUP_TYPE.PASSWORD){if(!e.hasOwnProperty(s.GroupConstants.KEYS.PASSWORD))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"PASSWORD","PASSWORD","password")));if(typeof e[s.GroupConstants.KEYS.PASSWORD]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"PASSWORD","PASSWORD","password")));if(E(e[s.GroupConstants.KEYS.PASSWORD]))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"PASSWORD","PASSWORD","password")))}}else{if(void 0!==e){if(typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GUID","GUID","guid")));if(E(e))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"GUID","GUID","guid")))}if(void 0!==t){if(typeof t!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GROUP_TYPE","GROUP_TYPE","group type")));if(E(t))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"GROUP_TYPE","GROUP_TYPE","group type")));if(t.toLowerCase()!=d.CometChat.GROUP_TYPE.PUBLIC&&t.toLowerCase()!=d.CometChat.GROUP_TYPE.PASSWORD&&t.toLowerCase()!=d.CometChat.GROUP_TYPE.PROTECTED&&t.toLowerCase()!=d.CometChat.GROUP_TYPE.PRIVATE)return new a.CometChatException(s.GroupErrors.INVALID_GROUP_TYPE);if(t.toLowerCase()==d.CometChat.GROUP_TYPE.PASSWORD){if(typeof n!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"PASSWORD","PASSWORD","password")));if(E(n))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"PASSWORD","PASSWORD","password")))}}}},r.validateCreateGroup=function(e){if(!e.hasOwnProperty(s.GroupConstants.KEYS.GUID))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"GUID","GUID","guid")));if(typeof e[s.GroupConstants.KEYS.GUID]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GUID","GUID","guid")));if(E(e[s.GroupConstants.KEYS.GUID]))return new a.CometChatException({code:"Empty GUID"});if(!e.hasOwnProperty(s.GroupConstants.KEYS.NAME))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"GROUP_NAME","GROUP_NAME","group name")));if(typeof e[s.GroupConstants.KEYS.NAME]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GROUP_NAME","GROUP_NAME","group name")));if(E(e[s.GroupConstants.KEYS.NAME]))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"GROUP_NAME","GROUP_NAME","group name")));if(!e.hasOwnProperty(s.GroupConstants.KEYS.TYPE))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"GROUP_TYPE","GROUP_TYPE","group type")));if(typeof e[s.GroupConstants.KEYS.TYPE]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GROUP_TYPE","GROUP_TYPE","group type")));if(E(e[s.GroupConstants.KEYS.TYPE]))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"GROUP_TYPE","GROUP_TYPE","group type")));if(e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PUBLIC&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PASSWORD&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PROTECTED&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PRIVATE)return new a.CometChatException(s.GroupErrors.INVALID_GROUP_TYPE);if(e[s.GroupConstants.KEYS.TYPE].toLowerCase()==d.CometChat.GROUP_TYPE.PASSWORD){if(!e.hasOwnProperty(s.GroupConstants.KEYS.PASSWORD))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"PASSWORD","PASSWORD","password")));if(typeof e[s.GroupConstants.KEYS.PASSWORD]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"PASSWORD","PASSWORD","password")));if(E(e[s.GroupConstants.KEYS.PASSWORD]))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"PASSWORD","PASSWORD","password")))}},r.validateId=function(e){return typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"UID/GUID","UID/GUID","uid/guid"))):E(e)?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"UID/GUID","UID/GUID","uid/guid"))):void 0},r.validateHideMessagesFromBlockedUsers=function(e){if(typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.BOOLEAN)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_BOOLEAN),"HIDE_MESSAGES_FROM_BLOCKED_USERS","HIDE_MESSAGES_FROM_BLOCKED_USERS","hideMessagesFromBlockedUsers")))},r.validateArray=function(e){return typeof e!=s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.OBJECT?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_OBJECT),"LIST","LIST","list"))):Array.isArray(e)?void 0:new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_AN_ARRAY),"LIST","LIST","list")))},r.validateMsgId=function(e){return isNaN(e)?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_NUMBER),"MESSAGE_ID","MESSAGE_ID","Message Id"))):E(e)?new a.CometChatException(n.ERRORS.PARAMETER_MISSING):void 0},r.validateChatType=function(e){return typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"RECEIVER_TYPE","RECEIVER_TYPE","receiver type"))):E(e)?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"RECEIVER_TYPE","RECEIVER_TYPE","receiver type"))):e!=s.MessageConstatnts.RECEIVER_TYPE.GROUP&&e!=s.MessageConstatnts.RECEIVER_TYPE.USER?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"RECEIVER_TYPE","RECEIVER_TYPE","Receiver Type"))):void 0},r.validateMessage=function(e){var t=e;if(typeof t.getReceiverId()!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"RECEIVER_ID","RECEIVER_ID","Receiver Id")));if(E(t.getReceiverId()))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"RECEIVER_ID","RECEIVER_ID","Receiver Id")));if(typeof t.getReceiverType()!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"RECEIVER_TYPE","RECEIVER_TYPE","Receiver Type")));if(E(t.getReceiverType()))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"RECEIVER_TYPE","RECEIVER_TYPE","Receiver Type")));if(t.getReceiverType()!=s.MessageConstatnts.RECEIVER_TYPE.GROUP&&t.getReceiverType()!=s.MessageConstatnts.RECEIVER_TYPE.USER)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"RECEIVER_TYPE","RECEIVER_TYPE","Receiver Type")));if(e instanceof c.TextMessage&&E(e.getText()))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"MESSAGE_TEXT","MESSAGE_TEXT","Message Text")));if(e instanceof u.MediaMessage){var n=e;if(!(n.file instanceof Blob))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_BLOB),"MEDIA_OBJECT","MEDIA_OBJECT","Media Object")));if(typeof n.getData()!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.OBJECT)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_OBJECT),"MEDIA_OBJECT","MEDIA_OBJECT","Media Object")));if(E(n.getData()))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"MEDIA_OBJECT","MEDIA_OBJECT","Media Object")));if("image"==n.getType()){if(!r.isImage(n.file))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_MEDIA_FILE),"IMAGE_FILE","IMAGE_FILE")))}else if("video"==n.getType()){if(!r.isVideo(n.file))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_MEDIA_FILE),"VIDEO_FILE","VIDEO_FILE")))}else if("audio"==n.getType()&&!r.isAudio(n.file))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_MEDIA_FILE),"AUDIO_FILE","AUDIO_FILE")))}if(e instanceof l.CustomMessage&&E(e.getCustomData()))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"CUSTOM_DATA","CUSTOM_DATA","Custom Data")))},r.validateCreateUser=function(e){return e.hasOwnProperty(s.UserConstants.UID)?typeof e[s.UserConstants.UID]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"UID","UID","uid"))):E(e[s.UserConstants.UID])?new a.CometChatException({code:"Empty UID"}):e.hasOwnProperty(s.UserConstants.NAME)?typeof e[s.UserConstants.NAME]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"USER_NAME","USER_NAME","user name"))):E(e[s.UserConstants.NAME])?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"USER_NAME","USER_NAME","user name"))):void 0:new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"USER_NAME","USER_NAME","user name"))):new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"UID","UID","uid")))},r.validateUpdateUser=function(e){return e.hasOwnProperty(s.UserConstants.UID)?typeof e[s.UserConstants.UID]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"UID","UID","uid"))):E(e[s.UserConstants.UID])?new a.CometChatException({code:"Empty UID"}):e.hasOwnProperty(s.UserConstants.NAME)&&""===e[s.UserConstants.NAME]?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"USER_NAME","USER_NAME","user name"))):void 0:new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"UID","UID","uid")))},r.SHA1=function(e){var t,n,r,o,s,i,a,c,u,l=new Array(80),d=1732584193,E=4023233417,h=2562383102,p=271733878,f=3285377520,g=(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n>6|192):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128)),t+=String.fromCharCode(63&r|128))}return t}(e)).length,_=new Array;for(n=0;n>>29),_.push(g<<3&4294967295),t=0;t<_.length;t+=16){for(n=0;n<16;n++)l[n]=_[t+n];for(n=16;n<=79;n++)l[n]=C(l[n-3]^l[n-8]^l[n-14]^l[n-16],1);for(o=d,s=E,i=h,a=p,c=f,n=0;n<=19;n++)u=C(o,5)+(s&i|~s&a)+c+l[n]+1518500249&4294967295,c=a,a=i,i=C(s,30),s=o,o=u;for(n=20;n<=39;n++)u=C(o,5)+(s^i^a)+c+l[n]+1859775393&4294967295,c=a,a=i,i=C(s,30),s=o,o=u;for(n=40;n<=59;n++)u=C(o,5)+(s&i|s&a|i&a)+c+l[n]+2400959708&4294967295,c=a,a=i,i=C(s,30),s=o,o=u;for(n=60;n<=79;n++)u=C(o,5)+(s^i^a)+c+l[n]+3395469782&4294967295,c=a,a=i,i=C(s,30),s=o,o=u;d=d+o&4294967295,E=E+s&4294967295,h=h+i&4294967295,p=p+a&4294967295,f=f+c&4294967295}return(S(d)+S(E)+S(h)+S(p)+S(f)).toLowerCase()}},function(e,t,n){"use strict";t.__esModule=!0;var r=function(e){null!==e.code&&void 0!==e.code&&""!==e.code&&(this.code=e.code),null!==e.name&&void 0!==e.name&&""!==e.name&&(this.name=e.name),null!==e.message&&void 0!==e.message&&""!==e.message&&(this.message=e.message),null!==e.details&&void 0!==e.details&&""!==e.details&&(this.details=e.details)};t.CometChatException=r},function(e,X,q){"use strict";(function(t){var p=this&&this.__assign||function(){return(p=Object.assign||function(e){for(var t,n=1,r=arguments.length;ni[0]&&t[1]","text/xml"),h.isNative=!0):f.Logger.info("This is node","we do not have anything"),h.typingTimer(),h.appId=e,h.messagesStore=n.MessagesStore.getInstance(),h.localStorage=r.LocalStorage.getInstance(),h.userStore=o.UserStore.getInstance(),h.keyStore=s.KeyStore.getInstance(),h.messageListnerMaping=D.MessageListnerMaping.getInstance()}catch(e){f.Logger.error("CometChat: constructor",e)}}return h.setAuthToken=function(e){try{h.authToken=e}catch(e){f.Logger.error("CometChat: setAuthToken",e)}},h.prototype.getAuthToken=function(){try{return h.authToken}catch(e){f.Logger.error("CometChat: getAuthToken",e)}},h.getAppId=function(){try{return h.appId}catch(e){f.Logger.error("CometChat: getAppId",e)}},h.prototype.getApiKey=function(){try{return h.apiKey}catch(e){f.Logger.error("CometChat: getApiKey",e)}},h.init=function(r,e){var o=this;return void 0===r&&(r=""),void 0===e&&(e={}),new Promise(function(t,n){try{"object"==typeof r&&(r.hasOwnProperty("appId")&&(r=r.appId),r.hasOwnProperty("appSettings")&&(e=r.appSettings)),f.isFalsy(e)?e=(new H.AppSettingsBuilder).setRegion(H.AppSettings.REGION_EU).build():e.getRegion()==H.AppSettings.REGION_PRIVATE&&(e.region=r),o.appSettings=e,f.isFalsy(r)?n(new g.CometChatException(y.INIT_ERROR.NO_APP_ID)):(o.initialzed=!0,o.getInstance(r)),t(!0),h.keyStore.get("deviceId").then(function(e){if(null==e){var t=r.substr(0,r.length-10)+"_"+V()+"_"+(new Date).getTime(),n=f.SHA1(t);h.keyStore.set("deviceId",n)}}),h.localStorage.get("user").then(function(e){e?(h.user=new d.Me(e),h.setAuthToken(h.user.getAuthToken()),h.XMPPLogin(h.user,function(){t(!0)},function(){n("error in connecting to xmpp server")})):t(!0)})}catch(e){n(new g.CometChatException(e))}})},h.isInitialized=function(){try{return this.initialzed}catch(e){f.Logger.error("CometChat: isInitialized",e)}},h.getInstance=function(e){try{return this.cometChat||(this.cometChat=new h(e)),this.cometChat}catch(e){f.Logger.error("CometChat: getInstance",e)}},h.registerTokenForPushNotification=function(l,d){var E=this;return new Promise(function(c,u){try{h.keyStore.get("deviceId").then(function(e){var t="",n=e,r=m.APPINFO.platform,o=m.APPINFO.sdkVersion,s=m.APPINFO.apiVersion;if(navigator&&(t=navigator.userAgent),null==n){var i=E.appId.substr(0,E.appId.length-10)+"_"+V()+"_"+(new Date).getTime();n=f.SHA1(i),h.keyStore.set("deviceId",n)}var a={platform:r,userAgent:t,deviceId:n,appInfo:{version:o,apiVersion:s,pushNotification:{fcmDeviceToken:l,settings:d}}};_.makeApiCall("updateMyDetails",{},a,!1).then(function(e){c("Token Registration successful")},function(e){u(new g.CometChatException(e.error))}).catch(function(e){u(new g.CometChatException(e))})})}catch(e){u(new g.CometChatException(e))}})},h.login=function(){for(var s=this,i=[],e=0;e=1e3*m.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT||null==w.TypingNotificationController.getTypingStartedMap(t))&&f.getAppSettings().then(function(e){switch(n){case m.XMPP.CONVERSATION.TYPE.CHAT:j.sendTypingStarted(f.format(m.XMPP.bare_jid_string,h.getAppId(),t,e[m.APP_SETTINGS.KEYS.CHAT_HOST]),n,r);break;case m.XMPP.CONVERSATION.TYPE.GROUP_CHAT:j.sendTypingStarted(f.format(m.XMPP.muc_jid_string,h.getAppId(),t,e[m.APP_SETTINGS.KEYS.GROUP_SERVICE],e[m.APP_SETTINGS.KEYS.CHAT_HOST]),n,r)}w.TypingNotificationController.addTypingStarted(t)},function(e){})}catch(e){f.Logger.error("CometChat: startTyping",e)}},h.endTyping=function(e){try{if(!f.isFalsy(e)){var t,n=this.RECEIVER_TYPE.USER,r={};if(e instanceof b.TypingIndicator)t=e.getReceiverId(),n=e.getReceiverType(),r=e.getMetadata();else{if(!e.hasOwnProperty(m.TYPING_NOTIFICATION.RECEIVER_ID))return;t=e[m.TYPING_NOTIFICATION.RECEIVER_ID],e.hasOwnProperty(m.TYPING_NOTIFICATION.RECEIVER_TYPE)&&(n=e[m.TYPING_NOTIFICATION.RECEIVER_TYPE]),n=n==this.RECEIVER_TYPE.USER?m.XMPP.CONVERSATION.TYPE.CHAT:m.XMPP.CONVERSATION.TYPE.GROUP_CHAT,e.hasOwnProperty(m.TYPING_NOTIFICATION.META)&&(r=e[m.TYPING_NOTIFICATION.META])}if(f.isFalsy(t))return;n=n==this.RECEIVER_TYPE.USER?m.XMPP.CONVERSATION.TYPE.CHAT:m.XMPP.CONVERSATION.TYPE.GROUP_CHAT,w.TypingNotificationController.getTypingStartedMap(t)&&f.getCurrentTime()-w.TypingNotificationController.getTypingStartedMap(t)<1e3*m.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT&&(w.TypingNotificationController.getTypingEndedMap(t)&&f.getCurrentTime()-w.TypingNotificationController.getTypingEndedMap(t)>=1e3*m.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT||null==w.TypingNotificationController.getTypingEndedMap(t))&&f.getAppSettings().then(function(e){switch(n){case m.XMPP.CONVERSATION.TYPE.CHAT:j.sendTypingPaused(f.format(m.XMPP.bare_jid_string,h.getAppId(),t,e[m.APP_SETTINGS.KEYS.CHAT_HOST]),n,r);break;case m.XMPP.CONVERSATION.TYPE.GROUP_CHAT:j.sendTypingPaused(f.format(m.XMPP.muc_jid_string,h.getAppId(),t,e[m.APP_SETTINGS.KEYS.GROUP_SERVICE],e[m.APP_SETTINGS.KEYS.CHAT_HOST]),n,r)}w.TypingNotificationController.addTypingEnded(t)},function(e){})}}catch(e){f.Logger.error("CometChat: endTyping",e)}},h.markAsRead=function(e,t,n){try{a.XMPPConnectionHelper.getInstance().markAsRead(t,n,e)}catch(e){f.Logger.error("CometChat: markAsRead",e)}},h.markAsDelivered=function(e,t,n){try{a.XMPPConnectionHelper.getInstance().markAsDelivered(t,n,e)}catch(e){f.Logger.error("CometChat: markAsDelivered",e)}},h.getMessageDetails=function(e){return new Promise(function(t,n){try{f.isFalsy(e)?n(new g.CometChatException(y.ERRORS.PARAMETER_MISSING)):_.makeApiCall("getMessageDetails",{messageId:e}).then(function(e){t(S.MessageController.trasformJSONMessge(e.data))},function(e){f.Logger.error("CometChat:GetMessageDetails:",e),n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.getMessageReceipts=function(r){return new Promise(function(t,n){try{var e=f.validateMsgId(r);if(e instanceof g.CometChatException)return void n(e);f.isFalsy(r)?n(new g.CometChatException(y.ERRORS.PARAMETER_MISSING)):_.makeApiCall("getMessageDetails",{messageId:r}).then(function(e){S.MessageController.getReceiptsFromJSON(e.data).then(function(e){t(e)},function(e){n(new g.CometChatException(e))})},function(e){f.Logger.error("CometChat:GetMessageDetails:",e),n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.getUnreadMessageCount=function(n){void 0===n&&(n=!1);var o=0;return new Promise(function(r,t){try{var e=f.validateHideMessagesFromBlockedUsers(n);if(e instanceof g.CometChatException)return void t(e);n&&(o=1),_.makeApiCall("getMessages",{},{unread:1,count:1,hideMessagesFromBlockedUsers:o}).then(function(e){var t={},n={};e.data.map(function(e){e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_TYPE]==m.MessageConstatnts.RECEIVER_TYPE.GROUP?n[e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]:t[e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),r({users:t,groups:n})},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.getUnreadMessageCountForAllUsers=function(r){void 0===r&&(r=!1);var o=0;return new Promise(function(n,t){try{var e=f.validateHideMessagesFromBlockedUsers(r);if(e instanceof g.CometChatException)return void t(e);r&&(o=1),_.makeApiCall("getMessages",{},{hideMessagesFromBlockedUsers:o,receiverType:m.MessageConstatnts.RECEIVER_TYPE.USER,unread:1,count:1}).then(function(e){var t={};e.data.map(function(e){t[e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),n(p({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.getUnreadMessageCountForAllGroups=function(r){void 0===r&&(r=!1);var o=0;return new Promise(function(n,t){try{var e=f.validateHideMessagesFromBlockedUsers(r);if(e instanceof g.CometChatException)return void t(e);r&&(o=1),_.makeApiCall("getMessages",{},{hideMessagesFromBlockedUsers:o,receiverType:m.MessageConstatnts.RECEIVER_TYPE.GROUP,unread:1,count:1}).then(function(e){var t={};e.data.map(function(e){e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_TYPE]==m.MessageConstatnts.RECEIVER_TYPE.GROUP&&(t[e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT])}),n(p({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.getUnreadMessageCountForUser=function(o,s){void 0===s&&(s=!1);var i=0;return new Promise(function(n,t){try{var e=f.validateId(o);if(e instanceof g.CometChatException)return void t(e);var r=f.validateHideMessagesFromBlockedUsers(s);if(r instanceof g.CometChatException)return void t(r);s&&(i=1),_.makeApiCall("getUserMessages",{listId:o},{hideMessagesFromBlockedUsers:i,unread:1,count:1,uid:o}).then(function(e){var t={};e.data.map(function(e){t[e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),n(p({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.getUnreadMessageCountForGroup=function(o,s){void 0===s&&(s=!1);var i=0;return new Promise(function(n,t){try{var e=f.validateId(o);if(e instanceof g.CometChatException)return void t(e);var r=f.validateHideMessagesFromBlockedUsers(s);if(r instanceof g.CometChatException)return void t(r);s&&(i=1),_.makeApiCall("getGroupMessages",{listId:o},{hideMessagesFromBlockedUsers:i,unread:1,count:1,guid:o}).then(function(e){var t={};e.data.map(function(e){e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_TYPE]==m.MessageConstatnts.RECEIVER_TYPE.GROUP&&(t[e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT])}),n(p({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.getUndeliveredMessageCount=function(n){void 0===n&&(n=!1);var o=0;return new Promise(function(r,t){try{var e=f.validateHideMessagesFromBlockedUsers(n);if(e instanceof g.CometChatException)return void t(e);n&&(o=1),_.makeApiCall("getMessages",{},{hideMessagesFromBlockedUsers:o,undelivered:1,count:1}).then(function(e){var t={},n={};e.data.map(function(e){e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_TYPE]==m.MessageConstatnts.RECEIVER_TYPE.GROUP?n[e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]:t[e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),r({users:t,groups:n})},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.getUndeliveredMessageCountForAllUsers=function(r){void 0===r&&(r=!1);var o=0;return new Promise(function(n,t){try{var e=f.validateHideMessagesFromBlockedUsers(r);if(e instanceof g.CometChatException)return void t(e);r&&(o=1),_.makeApiCall("getMessages",{},{hideMessagesFromBlockedUsers:o,unread:1,count:1}).then(function(e){var t={};e.data.map(function(e){t[e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),n(p({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.getUndeliveredMessageCountForAllGroups=function(r){void 0===r&&(r=!1);var o=0;return new Promise(function(n,t){try{var e=f.validateHideMessagesFromBlockedUsers(r);if(e instanceof g.CometChatException)return void t(e);r&&(o=1),_.makeApiCall("getMessages",{},{hideMessagesFromBlockedUsers:o,unread:1,count:1}).then(function(e){var t={};e.data.map(function(e){t[e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),n(p({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.getUndeliveredMessageCountForUser=function(o,s){void 0===s&&(s=!1);var i=0;return new Promise(function(n,t){try{var e=f.validateId(o);if(e instanceof g.CometChatException)return void t(e);var r=f.validateHideMessagesFromBlockedUsers(s);if(r instanceof g.CometChatException)return void t(r);s&&(i=1),_.makeApiCall("getUserMessages",{listId:o},{hideMessagesFromBlockedUsers:i,undelivered:1,count:1,uid:o}).then(function(e){var t={};e.data.map(function(e){t[e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),n(p({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.getUndeliveredMessageCountForGroup=function(o,s){void 0===s&&(s=!1);var i=0;return new Promise(function(n,t){try{var e=f.validateId(o);if(e instanceof g.CometChatException)return void t(e);var r=f.validateHideMessagesFromBlockedUsers(s);if(r instanceof g.CometChatException)return void t(r);s&&(i=1),_.makeApiCall("getGroupMessages",{listId:o},{hideMessagesFromBlockedUsers:i,undelivered:1,count:1,uid:o}).then(function(e){var t={};e.data.map(function(e){t[e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[m.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),n(p({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.editMessage=function(r){return new Promise(function(t,n){try{var e=f.validateMsgId(r.getId());if(e instanceof g.CometChatException)return void n(e);_.makeApiCall("updateMessage",{messageId:r.getId()},r).then(function(e){t(S.MessageController.trasformJSONMessge(e.data).getActionOn())},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.deleteMessage=function(r){return new Promise(function(t,n){try{var e=f.validateMsgId(r);if(e instanceof g.CometChatException)return void n(e);_.makeApiCall("deleteMessage",{messageId:r},{id:r}).then(function(e){t(S.MessageController.trasformJSONMessge(e.data).getActionOn())},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.getPreviousMessagesByTimestamp=function(e,r){return new Promise(function(t,n){try{f.isFalsy(r)?n(new g.CometChatException(JSON.parse(f.format(JSON.stringify(m.PARAMETER_ERROR.PARAMETER_REQUIRED),"TIMESTAMP","TIMESTAMP","timestamp")))):S.MessageController.getAllMessage(e,r,m.MessageConstatnts.PAGINATION.CURSOR_FILEDS.SENT_AT,m.MessageConstatnts.PAGINATION.AFFIX.PREPEND).then(function(e){return t(e)},function(e){return n(new g.CometChatException(e))})}catch(e){n(new g.CometChatException(e))}})},h.getPreviousMessagesById=function(e,r){return new Promise(function(t,n){try{f.isFalsy(r)?n(new g.CometChatException(JSON.parse(f.format(JSON.stringify(m.PARAMETER_ERROR.PARAMETER_REQUIRED),"ID","ID","id")))):S.MessageController.getAllMessage(e,r,m.MessageConstatnts.PAGINATION.CURSOR_FILEDS.ID,m.MessageConstatnts.PAGINATION.AFFIX.PREPEND).then(function(e){return t(e)},function(e){return n(new g.CometChatException(e))})}catch(e){n(new g.CometChatException(e))}})},h.getNextMessagesByTimestamp=function(e,r){return new Promise(function(t,n){try{f.isFalsy(r)?n(new g.CometChatException(JSON.parse(f.format(JSON.stringify(m.PARAMETER_ERROR.PARAMETER_REQUIRED),"TIMESTAMP","TIMESTAMP","timestamp")))):S.MessageController.getAllMessage(e,r,m.MessageConstatnts.PAGINATION.CURSOR_FILEDS.SENT_AT,m.MessageConstatnts.PAGINATION.AFFIX.APPEND).then(function(e){return t(e)},function(e){return n(new g.CometChatException(e))})}catch(e){n(new g.CometChatException(e))}})},h.getNextMessagesById=function(e,r){return new Promise(function(t,n){try{f.isFalsy(r)?n(new g.CometChatException(JSON.parse(f.format(JSON.stringify(m.PARAMETER_ERROR.PARAMETER_REQUIRED),"ID","ID","id")))):S.MessageController.getAllMessage(e,r,m.MessageConstatnts.PAGINATION.CURSOR_FILEDS.ID,m.MessageConstatnts.PAGINATION.AFFIX.APPEND).then(function(e){return t(e)},function(e){return n(new g.CometChatException(e))})}catch(e){n(new g.CometChatException(e))}})},h.createUser=function(o,s){return new Promise(function(n,t){try{if(f.isFalsy(s))return void t(new g.CometChatException(JSON.parse(f.format(JSON.stringify(m.GENERAL_ERROR.INVALID),"API_KEY","API_KEY","API_KEY"))));h.apiKey=s;var e=f.validateCreateUser(o);if(e instanceof g.CometChatException)return void t(e);if(!(o instanceof d.User)){var r=void 0;if(!o.hasOwnProperty(m.UserConstants.UID))return void t(new g.CometChatException(y.ERRORS.PARAMETER_MISSING));if(!o.hasOwnProperty(m.UserConstants.NAME))return void t(new g.CometChatException(y.ERRORS.PARAMETER_MISSING));r=new d.User(o[m.UserConstants.UID],o[m.UserConstants.NAME]),o.hasOwnProperty(m.UserConstants.AVATAR)&&r.setAvatar(o[m.UserConstants.AVATAR]),o.hasOwnProperty(m.UserConstants.ROLE)&&r.setRole(o[m.UserConstants.ROLE]),o.hasOwnProperty(m.UserConstants.META_DATA)&&r.setMetadata(o[m.UserConstants.META_DATA]),o.hasOwnProperty(m.UserConstants.LINK)&&r.setLink(o[m.UserConstants.LINK]),o.hasOwnProperty(m.UserConstants.CREDITS)&&r.setCredits(o[m.UserConstants.CREDITS]),o.hasOwnProperty(m.UserConstants.STATUS_MESSAGE)&&r.setStatusMessage(o[m.UserConstants.STATUS_MESSAGE]),o=r}_.makeApiCall("createUser",{},o).then(function(e){var t=T.UsersController.trasformJSONUser(e.data);n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.updateUser=function(s,i){return new Promise(function(n,t){try{if(f.isFalsy(i))return void t(new g.CometChatException(JSON.parse(f.format(JSON.stringify(m.GENERAL_ERROR.INVALID),"API_KEY","API_KEY","API_KEY"))));h.apiKey=i;var e=f.validateUpdateUser(s);if(e instanceof g.CometChatException)return void t(e);if(!(s instanceof d.User)){var r=void 0;if(!s.hasOwnProperty(m.UserConstants.UID))return void t(new g.CometChatException(y.ERRORS.PARAMETER_MISSING));r=new d.User(s[m.UserConstants.UID]),s.hasOwnProperty(m.UserConstants.NAME)&&r.setName(s[m.UserConstants.NAME]),s.hasOwnProperty(m.UserConstants.AVATAR)&&r.setAvatar(s[m.UserConstants.AVATAR]),s.hasOwnProperty(m.UserConstants.ROLE)&&r.setRole(s[m.UserConstants.ROLE]),s.hasOwnProperty(m.UserConstants.META_DATA)&&r.setMetadata(s[m.UserConstants.META_DATA]),s.hasOwnProperty(m.UserConstants.LINK)&&r.setLink(s[m.UserConstants.LINK]),s.hasOwnProperty(m.UserConstants.CREDITS)&&r.setCredits(s[m.UserConstants.CREDITS]),s.hasOwnProperty(m.UserConstants.STATUS_MESSAGE)&&r.setStatusMessage(s[m.UserConstants.STATUS_MESSAGE]),s=r}var o=s.uid;_.makeApiCall("updateUser",{uid:o},s).then(function(e){var t=T.UsersController.trasformJSONUser(e.data);n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.getUser=function(r){return new Promise(function(n,t){try{"object"==typeof r&&r.hasOwnProperty("uid")&&(r=r.uid);var e=f.validateId(r);if(e instanceof g.CometChatException)return void t(e);_.makeApiCall("user",{uid:r}).then(function(e){var t=T.UsersController.trasformJSONUser(e.data);n(t)}).catch(function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.getLoggedInUser=function(){var l=this;return new Promise(function(c,u){try{h.localStorage.get("user").then(function(e){if(e)c(h.user=new d.Me(e));else{var r="",o="",s=m.APPINFO.platform,i=m.APPINFO.sdkVersion,a=m.APPINFO.apiVersion;h.keyStore.get("deviceId").then(function(e){if(o=e,navigator&&(r=navigator.userAgent),null==o){var t=l.appId.substr(0,l.appId.length-10)+"_"+V()+"_"+(new Date).getTime();o=f.SHA1(t),h.keyStore.set("deviceId",o)}var n={platform:s,userAgent:r,deviceId:o,appInfo:{version:i,apiVersion:a}};_.makeApiCall("updateMyDetails",{},n,!1).then(function(e){c(new d.Me(e.data))},function(e){u(new g.CometChatException(e.error))}).catch(function(e){u(new g.CometChatException(e))})})}})}catch(e){u(new g.CometChatException(e))}})},h.getLoggedinUser=function(){return new Promise(function(t,n){try{h.localStorage.get("user").then(function(e){t(e?h.user=new d.Me(e):null)},function(e){t(null)})}catch(e){n(new g.CometChatException(e))}})},h.blockUsers=function(r){return new Promise(function(t,n){try{var e=f.validateArray(r);if(e instanceof g.CometChatException)return void n(e);f.isFalsy(r)?n(new g.CometChatException(y.USERS_REQUEST_ERRORS.EMPTY_USERS_LIST)):_.makeApiCall("blockUsers",{},{blockedUids:r}).then(function(e){t(e.data)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.unblockUsers=function(r){return new Promise(function(t,n){try{var e=f.validateArray(r);if(e instanceof g.CometChatException)return void n(e);f.isFalsy(r)?n(new g.CometChatException(y.USERS_REQUEST_ERRORS.EMPTY_USERS_LIST)):_.makeApiCall("unblockUsers",{},{blockedUids:r}).then(function(e){t(e.data)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.createGroup=function(o){return new Promise(function(t,n){try{var e=f.validateCreateGroup(o);if(e instanceof g.CometChatException)return void n(e);if(!(o instanceof A.Group)){var r=void 0;if(!o.hasOwnProperty(m.GroupConstants.KEYS.GUID))return void n(new g.CometChatException(y.ERRORS.PARAMETER_MISSING));if(!o.hasOwnProperty(m.GroupConstants.KEYS.NAME))return void n(new g.CometChatException(y.ERRORS.PARAMETER_MISSING));if(r=new A.Group(o[m.GroupConstants.KEYS.GUID],o[m.GroupConstants.KEYS.NAME],""),o.hasOwnProperty(m.GroupConstants.KEYS.TYPE))if(o[m.GroupConstants.KEYS.TYPE].toLocaleLowerCase()==m.GroupType.Password){if(!o.hasOwnProperty(m.GroupConstants.KEYS.PASSWORD))return void n(new g.CometChatException(y.GROUP_CREATION_ERRORS.EMPTY_PASSWORD));r.setType(m.GROUP_TYPE.PASSWORD),r.setPassword(o[m.GroupConstants.KEYS.PASSWORD])}else r.setType(o[m.GroupConstants.KEYS.TYPE]);else r.setType(m.GROUP_TYPE.PUBLIC);o.hasOwnProperty(m.GroupConstants.KEYS.ICON)&&r.setIcon(o[m.GroupConstants.KEYS.ICON]),o.hasOwnProperty(m.GroupConstants.KEYS.DESCRIPTION)&&r.setDescription(o[m.GroupConstants.KEYS.DESCRIPTION]),o=r}_.makeApiCall("createGroup",{},o).then(function(e){j.joinMuc(o),I.GroupsController.trasformJSONGroup(e.data).setHasJoined(!0),t(I.GroupsController.trasformJSONGroup(e.data))},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.getGroup=function(r){return new Promise(function(t,n){try{"object"==typeof r&&r.hasOwnProperty("guid")&&(r=r.guid);var e=f.validateId(r);if(e instanceof g.CometChatException)return void n(e);_.makeApiCall("getGroup",{guid:r}).then(function(e){t(I.GroupsController.trasformJSONGroup(e.data))},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.getJoinedGroups=function(){return new Promise(function(t,n){try{j.getRooms().then(function(e){t(e)},function(e){n(e)})}catch(e){n(new g.CometChatException(e))}})},h.joinGroup=function(o,s,i){return void 0===s&&(s=m.GroupType.Public),void 0===i&&(i=""),new Promise(function(n,t){try{var r,e=f.validateJoinGroup(o,s,i);if(e instanceof g.CometChatException)return void t(e);"object"==typeof o&&(o.hasOwnProperty(m.GroupConstants.KEYS.GUID)?(o.hasOwnProperty(m.GroupConstants.KEYS.TYPE)&&(s=o[m.GroupConstants.KEYS.TYPE],o[m.GroupConstants.KEYS.TYPE].toLocaleLowerCase()===m.GroupType.Password&&o.hasOwnProperty(m.GroupConstants.KEYS.PASSWORD)&&(i=o[m.GroupConstants.KEYS.PASSWORD])),o=o[m.GroupConstants.KEYS.GUID]):t(new g.CometChatException(y.ERRORS.PARAMETER_MISSING))),r=f.isFalsy(i)?new A.Group(o,"name",s):new A.Group(o,"name",s,i),_.makeApiCall("joinGroup",r,r).then(function(e){j.joinMuc(r);var t=I.GroupsController.trasformJSONGroup(e.data[m.ResponseConstants.RESPONSE_KEYS.KEY_DATA][m.ActionConstatnts.ACTION_KEYS.ENTITIES][m.ActionConstatnts.ACTION_SUBJECTS.ACTION_FOR][m.ActionConstatnts.ACTION_KEYS.ENTITY]);t.setHasJoined(!0),n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.updateGroup=function(o){return new Promise(function(t,n){try{var e=f.validateUpdateGroup(o);if(e instanceof g.CometChatException)return void n(e);if(!(o instanceof A.Group)){var r=void 0;if(!o.hasOwnProperty(m.GroupConstants.KEYS.GUID))return void n(new g.CometChatException(y.ERRORS.PARAMETER_MISSING));r=new A.Group(m.GroupConstants.KEYS.GUID,"",""),o.hasOwnProperty(m.GroupConstants.KEYS.TYPE)?r.setType(o[m.GroupConstants.KEYS.TYPE]):(o[m.GroupConstants.KEYS.TYPE]=m.GROUP_TYPE.PUBLIC,r.setType[m.GROUP_TYPE.PUBLIC]),o.hasOwnProperty(m.GroupConstants.KEYS.NAME)&&r.setName(o[m.GroupConstants.KEYS.NAME]),o.hasOwnProperty(m.GroupConstants.KEYS.ICON)&&r.setIcon(o[m.GroupConstants.KEYS.ICON]),o.hasOwnProperty(m.GroupConstants.KEYS.DESCRIPTION)&&r.setDescription(o[m.GroupConstants.KEYS.DESCRIPTION]),o=r}_.makeApiCall("updateGroup",o,o).then(function(e){t(I.GroupsController.trasformJSONGroup(e.data))},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.deleteGroup=function(r){return new Promise(function(t,n){try{var e=f.validateId(r);if(e instanceof g.CometChatException)return void n(e);_.makeApiCall("deleteGroup",{guid:r}).then(function(e){t(!0)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.leaveGroup=function(r){return new Promise(function(t,n){try{var e=f.validateId(r);if(e instanceof g.CometChatException)return void n(e);_.makeApiCall("leaveGroup",{guid:r}).then(function(e){j.leaveMuc(r),t(!0)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.kickGroupMember=function(o,s){return new Promise(function(t,n){try{var e=f.validateId(o);if(e instanceof g.CometChatException)return void n(e);var r=f.validateId(s);if(r instanceof g.CometChatException)return void n(r);_.makeApiCall("kickGroupMembers",{guid:o,uid:s}).then(function(e){t(!0)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.updateGroupMemberScope=function(s,i,a){return new Promise(function(t,n){try{var e=f.validateId(s);if(e instanceof g.CometChatException)return void n(e);var r=f.validateId(i);if(r instanceof g.CometChatException)return void n(r);var o=f.validateScope(a);if(o instanceof g.CometChatException)return void n(o);_.makeApiCall("changeScopeOfMember",{guid:s,uid:i},{scope:a}).then(function(e){t(!0)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.banGroupMember=function(o,s){return new Promise(function(t,n){try{var e=f.validateId(o);if(e instanceof g.CometChatException)return void n(e);var r=f.validateId(s);if(r instanceof g.CometChatException)return void n(r);_.makeApiCall("banGroupMember",{guid:o,uid:s}).then(function(e){t(!0)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.unbanGroupMember=function(o,s){return new Promise(function(t,n){try{var e=f.validateId(o);if(e instanceof g.CometChatException)return void n(e);var r=f.validateId(s);if(r instanceof g.CometChatException)return void n(r);_.makeApiCall("unbanGroupMember",{guid:o,uid:s}).then(function(e){t(!0)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.addMembersToGroup=function(i,a,c){var u=[],l=[],d=[],E=[];return new Promise(function(e,t){try{var n=f.validateId(i);if(n instanceof g.CometChatException)return void t(n);var r=f.validateArray(a);if(r instanceof g.CometChatException)return void t(r);var o=f.validateArray(c);if(o instanceof g.CometChatException)return void t(o);f.isFalsy(a)&&f.isFalsy(c)?t(new g.CometChatException({})):f.isFalsy(a)||f.isFalsy(c)?f.isFalsy(a)?c.map(function(e){E.push(e)}):(a.filter(function(e){if(e.getScope()==m.GROUP_MEMBER_SCOPE.ADMIN)return!0}).map(function(e){u.push(e.getUid())}),a.filter(function(e){if(e.getScope()==m.GROUP_MEMBER_SCOPE.MODERATOR)return!0}).map(function(e){l.push(e.getUid())}),a.filter(function(e){if(e.getScope()==m.GROUP_MEMBER_SCOPE.PARTICIPANT)return!0}).map(function(e){d.push(e.getUid())})):(a.filter(function(e){if(e.getScope()==m.GROUP_MEMBER_SCOPE.ADMIN)return!0}).map(function(e){u.push(e.getUid())}),a.filter(function(e){if(e.getScope()==m.GROUP_MEMBER_SCOPE.MODERATOR)return!0}).map(function(e){l.push(e.getUid())}),a.filter(function(e){if(e.getScope()==m.GROUP_MEMBER_SCOPE.PARTICIPANT)return!0}).map(function(e){d.push(e.getUid())}),c.map(function(e){E.push(e)}));var s={};f.isFalsy(u)||(s=p({},s,{admins:u})),f.isFalsy(d)||(s=p({},s,{participants:d})),f.isFalsy(l)||(s=p({},s,{moderators:l})),f.isFalsy(E)||(s=p({},s,{usersToBan:E})),_.makeApiCall("addMemebersToGroup",{guid:i},s).then(function(t){var n={};Object.keys(t.data.admins).map(function(e){t.data.admins[e][m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS]?n[e]=m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS:n[e]=t.data.admins[e][m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.ERROR][m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.MESSAGE]}),Object.keys(t.data.participants).map(function(e){t.data.participants[e][m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS]?n[e]=m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS:n[e]=t.data.participants[e][m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.ERROR][m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.MESSAGE]}),Object.keys(t.data.moderators).map(function(e){t.data.moderators[e][m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS]?n[e]=m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS:n[e]=t.data.moderators[e][m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.ERROR][m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.MESSAGE]}),Object.keys(t.data.usersToBan).map(function(e){t.data.usersToBan[e][m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS]?n[e]=m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS:n[e]=t.data.usersToBan[e][m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.ERROR][m.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.MESSAGE]}),e(n)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.initiateCall=function(t){return new Promise(function(n,r){try{f.isFalsy(JSON.parse(JSON.stringify(t)).sender)?f.isFalsy(R.CallController.getInstance().getActiveCall())?(t.setStatus(m.CallConstants.CALL_STATUS.INITIATED),t.receiver=t.receiverId.toString(),delete t.receiverId,_.makeApiCall("createCallSession",{},t).then(function(e){var t=S.MessageController.trasformJSONMessge(e[m.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);R.CallController.getInstance().initiateCall(t).then(function(e){n(t)}).catch(function(e){r(new g.CometChatException(e))})},function(e){r(new g.CometChatException(e.error))})):r(new g.CometChatException(m.CALL_ERROR.ERROR_IN_CALLING)):R.CallController.getInstance().initiateCall(t).then(function(e){n(Object.assign(t))}).catch(function(e){r(new g.CometChatException(e))})}catch(e){r(new g.CometChatException(e))}})},h.acceptCall=function(r){return new Promise(function(n,t){try{var e={};e[m.CallConstants.CALL_KEYS.CALL_STATUS]=m.CallConstants.CALL_STATUS.ONGOING,_.makeApiCall("updateCallSession",{sessionid:r},e).then(function(e){var t=S.MessageController.trasformJSONMessge(e[m.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);R.CallController.getInstance().onCallStarted(t),n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.rejectCall=function(e,t){try{switch(t){case m.CallConstants.CALL_STATUS.REJECTED:return this.rejectIncomingCall(e);case m.CallConstants.CALL_STATUS.CANCELLED:return this.cancelCall(e);case m.CallConstants.CALL_STATUS.BUSY:return this.sendBusyResponse(e);default:return this.endCall(e)}}catch(e){f.Logger.error("CometChat: rejectCall",e)}},h.endCall=function(r){return new Promise(function(n,t){try{var e={};e[m.CallConstants.CALL_KEYS.CALL_STATUS]=m.CallConstants.CALL_STATUS.ENDED,R.CallController.getInstance().getActiveCall().getJoinedAt()&&(e[m.CallConstants.CALL_KEYS.CALL_JOINED_AT]=R.CallController.getInstance().getActiveCall().getJoinedAt()),_.makeApiCall("updateCallSession",{sessionid:r},e).then(function(e){var t=S.MessageController.trasformJSONMessge(e[m.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);n(t)},function(e){f.Logger.log("calling Log",{error:e});var t=R.CallController.getInstance().getActiveCall();t.setStatus(m.CallConstants.CALL_STATUS.ENDED),n(t),R.CallController.getInstance().endCall()})}catch(e){t(new g.CometChatException(e))}})},h.getActiveCall=function(){try{return R.CallController.getInstance().getActiveCall()}catch(e){f.Logger.error("CometChat: getActiveCall",e)}},h.startCall=function(e,t,n,r){try{R.CallController.getInstance().startCall(t,n,r)}catch(e){f.Logger.error("CometChat: startCall",e)}},h.toggleAudio=function(){try{R.CallController.toggleAudio()}catch(e){f.Logger.error("CometChat: toggleAudio",e)}},h.toggleVideo=function(){try{R.CallController.toggleVideo()}catch(e){f.Logger.error("CometChat: toggleVideo",e)}},h.leaveCall=function(){try{R.CallController.leave()}catch(e){f.Logger.error("CometChat: leaveCall",e)}},h.createCallView=function(e){try{return{prop1:this.makeCall,onMessage:function(e){R.CallController.getInstance().getCallListner()._eventListener.onCallEnded(R.CallController.getInstance().getActiveCall()),h.endCall(R.CallController.getInstance().getActiveCall().getSessionId()).then(function(e){f.Logger.info("CometChat: createCallView",e)}).catch(function(e){f.Logger.error("CometChat: createCallView",e)})}}}catch(e){f.Logger.error("CometChat: createCallView",e)}},h.makeCall=function(e,t){try{e.setState(function(e){return p({},e,{uri:t})})}catch(e){f.Logger.error("CometChat: makeCall",e)}},h.rejectIncomingCall=function(r){return new Promise(function(n,t){try{var e={};e[m.CallConstants.CALL_KEYS.CALL_STATUS]=m.CallConstants.CALL_STATUS.REJECTED,_.makeApiCall("updateCallSession",{sessionid:r},e).then(function(e){var t=S.MessageController.trasformJSONMessge(e[m.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.cancelCall=function(r){return new Promise(function(n,t){try{var e={};e[m.CallConstants.CALL_KEYS.CALL_STATUS]=m.CallConstants.CALL_STATUS.CANCELLED,_.makeApiCall("updateCallSession",{sessionid:r},e).then(function(e){var t=S.MessageController.trasformJSONMessge(e[m.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);R.CallController.getInstance().endCallSession(),n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.sendBusyResponse=function(r){return new Promise(function(n,t){try{var e={};e[m.CallConstants.CALL_KEYS.CALL_STATUS]=m.CallConstants.CALL_STATUS.BUSY,_.makeApiCall("updateCallSession",{sessionid:r},e).then(function(e){var t=S.MessageController.trasformJSONMessge(e[m.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.sendUnansweredResponse=function(r){return new Promise(function(n,t){try{var e={};e[m.CallConstants.CALL_KEYS.CALL_STATUS]=m.CallConstants.CALL_STATUS.UNANSWERED,_.makeApiCall("updateCallSession",{sessionid:r},e).then(function(e){var t=S.MessageController.trasformJSONMessge(e[m.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);a.XMPPConnectionHelper.getInstance().trigerMessageHandler(Object.assign(t,e[m.ResponseConstants.RESPONSE_KEYS.KEY_DATA])),n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},h.addMessageListener=function(e,t){try{j.addMessageEventListener(e,t)}catch(e){f.Logger.error("CometChat: addMessageListener",e)}},h.removeMessageListener=function(e){try{j.removeMessageEventListener(e)}catch(e){f.Logger.error("CometChat: removeMessageListener",e)}},h.addCallListener=function(e,t){try{j.addCallEventListener(e,t)}catch(e){f.Logger.error("CometChat: addCallListener",e)}},h.removeCallListener=function(e){try{j.removeCallEventListener(e)}catch(e){f.Logger.error("CometChat: removeCallListener",e)}},h.addUserListener=function(e,t){try{j.addUserEventListener(e,t)}catch(e){f.Logger.error("CometChat: addUserListener",e)}},h.removeUserListener=function(e){try{j.removeUserEventListener(e)}catch(e){f.Logger.error("CometChat: removeUserListener",e)}},h.addGroupListener=function(e,t){try{j.addGroupEventListener(e,t)}catch(e){f.Logger.error("CometChat: addGroupListener",e)}},h.removeGroupListener=function(e){try{j.removeGroupEventListener(e)}catch(e){f.Logger.error("CometChat: removeGroupListener",e)}},h.generateAuthToken=function(l){var d=this;return new Promise(function(n,r){try{var o={},s="",i="",a=m.APPINFO.platform,c=m.APPINFO.sdkVersion,u=m.APPINFO.apiVersion;navigator&&(i=navigator.userAgent),h.keyStore.get("deviceId").then(function(e){if(null==(s=e)){var t=d.appId.substr(0,d.appId.length-10)+"_"+V()+"_"+(new Date).getTime();s=f.SHA1(t),h.keyStore.set("deviceId",s)}o={platform:a,userAgent:i,deviceId:s,appInfo:{version:c,apiVersion:u}},_.makeApiCall("authToken",{uid:l},o).then(function(e){n(e.data)}).catch(function(e){r(new g.CometChatException(e.error))})},function(e){f.Logger.error("Got error while fetching data from key store",e)})}catch(e){r(new g.CometChatException(e))}})},h.XMPPLogin=function(t,n,r){var o=this;try{var s=!1;this.timeOut+this.timeIncrements<3e4&&(this.timeOut=this.timeOut+this.timeIncrements,this.timeIncrements=this.timeIncrements+2e3);var i=!0;j.XMMPLogin(t.getUid(),t.getWsChannel().secret,this.fallback,function(e){switch(e){case c.Strophe.Status.CONNFAIL:f.Logger.info("CometChat: XMPPLogin","In connection fail state"),s=!0,i&&setTimeout(function(){o.fallback=!o.fallback,o.XMPPLogin(t,n,r)},o.timeOut);break;case c.Strophe.Status.CONNECTING:f.Logger.info("CometChat: XMPPLogin","In connecting state");break;case c.Strophe.Status.CONNECTED:f.Logger.info("CometChat: XMPPLogin","In connected state"),o.timeOut=0,o.timeIncrements=1e3,s=!1,o.localStorage.set("user",t),n(new d.User(t));break;case c.Strophe.Status.DISCONNECTED:f.Logger.info("CometChat: XMPPLogin","In disconnected state"),i&&!s&&setTimeout(function(){o.fallback=!o.fallback,o.XMPPLogin(t,n,r)},o.timeOut);break;case c.Strophe.Status.DISCONNECTING:i=!1,f.Logger.info("CometChat: XMPPLogin","In disconnecting state");break;case c.Strophe.Status.AUTHFAIL:o.timeOut=0,o.timeIncrements=1e3,s=!1,r(new g.CometChatException(y.LOGIN_ERROR.XMPP_AUTH_FAIL))}})}catch(e){return void r(new g.CometChatException(e))}},h.getAppSettings=function(){return new Promise(function(t,n){try{_.makeApiCall("appSettings").then(function(e){r.LocalStorage.getInstance().set("app_settings",e.data),t(e.data)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.logout=function(){var r=this;return new Promise(function(t,n){try{_.makeApiCall("userLogout").then(function(e){r.clearCache(),r.apiKey=void 0,r.user=void 0,r.authToken=void 0,r.cometChat=void 0,a.XMPPConnectionHelper.getInstance().XMPPDisconnect(),t(e.data)},function(e){r.clearCache(),r.apiKey=void 0,r.user=void 0,r.authToken=void 0,r.cometChat=void 0,a.XMPPConnectionHelper.getInstance().XMPPDisconnect(),new g.CometChatException(e.error).code==y.SERVER_ERRORS.AUTH_ERR.code?t({}):n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},h.isExtensionEnabled=function(r){return new Promise(function(t,n){try{F.ExtensionController.getExtensionList().then(function(e){Object.keys(e).map(function(e){e==r&&t(!0)}),t(!1)},function(e){f.Logger.log("error while fetching exntension list",e),t(!1)})}catch(e){n(new g.CometChatException(e))}})},h.clearCache=function(){try{this.messagesStore.clearStore(),this.userStore.clearStore(),this.localStorage.clearStore()}catch(e){f.Logger.error("CometChat: clearCache",e)}},h.typingTimer=function(){try{setInterval(function(){w.TypingNotificationController.clearTimer()},500)}catch(e){f.Logger.error("CometChat: typingTimer",e)}},h.initialzed=!1,h.isNative=!1,h.CometChatException=g.CometChatException,h.TextMessage=C.TextMessage,h.MediaMessage=E.MediaMessage,h.CustomMessage=Y.CustomMessage,h.Action=O.Action,h.Call=N.Call,h.TypingIndicator=b.TypingIndicator,h.Group=A.Group,h.AppUser=d.User,h.User=d.User,h.GroupMember=x.GroupMember,h.Conversation=J.Conversation,h.USER_STATUS={ONLINE:m.PresenceConstatnts.STATUS.ONLINE,OFFLINE:m.PresenceConstatnts.STATUS.OFFLINE},h.MessagesRequest=U.DefaultMessagesRequest,h.MessagesRequestBuilder=U.DefaultMessagesRequestBuilder,h.UsersRequest=P.UsersRequest,h.UsersRequestBuilder=P.UsersRequestBuilder,h.ConversationsRequest=L.ConversationsRequest,h.ConversationsRequestBuilder=L.ConversationsRequestBuilder,h.BlockedUsersRequest=K.BlockedUsersRequest,h.BlockedUsersRequestBuilder=K.BlockedUsersRequestBuilder,h.GroupsRequest=v.GroupsRequest,h.GroupsRequestBuilder=v.GroupsRequestBuilder,h.GroupMembersRequest=M.GroupMembersRequest,h.GroupMembersRequestBuilder=M.GroupMembersRequestBuilder,h.BannedMembersRequest=M.GroupMembersRequest,h.BannedMembersRequestBuilder=M.GroupOutCastMembersRequestBuilder,h.AppSettings=H.AppSettings,h.AppSettingsBuilder=H.AppSettingsBuilder,h.MessageListener=i.MessageEventListener,h.UserListener=i.UserEventListener,h.GroupListener=i.GroupEventListener,h.OngoingCallListener=i.UserCallEventListener,h.CallListener=i.CallEventListener,h.MESSAGE_TYPE=m.MessageConstatnts.TYPE,h.CATEGORY_MESSAGE=m.MessageConstatnts.CATEGORY.MESSAGE,h.CATEGORY_ACTION=m.MessageConstatnts.CATEGORY.ACTION,h.CATEGORY_CALL=m.MessageConstatnts.CATEGORY.CALL,h.ACTION_TYPE=m.ActionConstatnts.ACTIONS,h.CALL_TYPE=m.CallConstants.CALL_TYPE,h.RECEIVER_TYPE=m.MessageConstatnts.RECEIVER_TYPE,h.CALL_STATUS=m.CallConstants.CALL_STATUS,h.CallController=R.CallController,h.GROUP_MEMBER_SCOPE=m.GROUP_MEMBER_SCOPE,h.GROUP_TYPE=m.GROUP_TYPE,h.MESSAGE_REQUEST=m.MessageConstatnts.PAGINATION.CURSOR_FILEDS,h.CometChatExtension=G.CometChatExtension,h.ExtensionManager=B.ExtensionManager,h.isCall=!1,h.endpointFactory=new e.EndpointFactory,h.startTypingCount=0,h.endTypingCount=0,h.CometChatHelper=k.CometChatHelper,h.fallback=!1,h.timeOut=0,h.timeIncrements=1e3,h}();X.CometChat=h}).call(this,q(26))},function(e,t,n){"use strict";t.__esModule=!0;var c=n(40),u=n(3),i=n(1),l=n(2);function d(t,e,n,r,o){var s;return void 0===t&&(t=""),void 0===e&&(e="GET"),void 0===n&&(n={}),void 0===r&&(r={}),n=i.isFalsy(n)?void 0:("GET"==e&&(t+="?",Object.keys(n).map(function(e){t=t+e+"="+n[e]+"&"}),n=void 0),o&&(s=new FormData,Object.keys(n).map(function(e){"data"!=e?"metadata"!=e&&s.append(e,n[e]):s.append(e,JSON.stringify(n[e]))})),JSON.stringify(n)),fetch(t,{method:e,mode:"cors",cache:"no-cache",headers:r,redirect:"follow",referrer:"no-referrer",body:o?s:n})}t.makeApiCall=function(o,e,s,i){void 0===o&&(o=""),void 0===e&&(e={}),void 0===s&&(s={});var a=u.CometChat.getInstance();return new Promise(function(n,r){try{c.getEndPoint(o,e).then(function(e){var t={appId:u.CometChat.getAppId(),Accept:"application/json"};i||(t["Content-Type"]="application/json"),e.hasOwnProperty("isAdminApi")&&e.isAdminApi?a.getApiKey()?t.apiKey=a.getApiKey():r({error:{code:"API_KEY_NOT_SET",message:"An apiKey is needed to use the "+o+" api.",name:"API_KEY_NOT_SET"}}):a.getAuthToken()?t.authToken=a.getAuthToken():r({error:{code:"USER_NOT_LOGED_IN",message:"An authToken is need to use the "+o+" api.",name:"user not logged in"}}),d(e.endpoint,e.method,s,t,i).then(function(e){return e.json()}).then(function(e){e.hasOwnProperty("data")?(e.data.hasOwnProperty("authToken")&&u.CometChat.setAuthToken(e.data.authToken),n(e)):r(e)}).catch(function(e){return r})}).catch(function(e){return r})}catch(e){r(new l.CometChatException(e))}})},t.makeAdminApiCall=function(o,e,s,i){void 0===o&&(o=""),void 0===e&&(e={}),void 0===s&&(s={});var a=u.CometChat.getInstance();return new Promise(function(n,r){c.getEndPoint(o,e).then(function(e){var t={appId:u.CometChat.getAppId(),Accept:"application/json"};i||(t["Content-Type"]="application/json"),e.hasOwnProperty("isAdminApi")&&e.isAdminApi?a.getApiKey()?t.apiKey=a.getApiKey():r({error:"An apiKey is need to use the "+o+" api."}):a.getAuthToken()?t.authToken=a.getAuthToken():r({error:"An authToken is need to use the "+o+" api."}),d(e.endpoint,e.method,s,t,i).then(function(e){return e.json()}).then(function(e){e.hasOwnProperty("data")?(e.data.hasOwnProperty("authToken")&&u.CometChat.setAuthToken(e.data.authToken),n(e)):r(e)}).catch(function(e){return r})}).catch(function(e){return r})})},t.postData=d},function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0;var s=n(2),i=n(14),a=n(0),c=function(){function e(){for(var e=[],t=0;te.db.version;if(r&&(e.version,e.version=e.db.version),o||n){if(n){var s=e.db.version+1;s>e.version&&(e.version=s)}return!0}return!1}function R(e){var t=function(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o>4,l[c++]=(15&r)<<4|o>>2,l[c++]=(3&o)<<6|63&s;return u}function B(e){var t,n=new Uint8Array(e),r="";for(t=0;t>2],r+=P[(3&n[t])<<4|n[t+1]>>4],r+=P[(15&n[t+1])<<2|n[t+2]>>6],r+=P[63&n[t+2]];return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}var F={serialize:function(t,n){var e="";if(t&&(e=x.call(t)),t&&("[object ArrayBuffer]"===e||t.buffer&&"[object ArrayBuffer]"===x.call(t.buffer))){var r,o=U;t instanceof ArrayBuffer?(r=t,o+=b):(r=t.buffer,"[object Int8Array]"===e?o+="si08":"[object Uint8Array]"===e?o+="ui08":"[object Uint8ClampedArray]"===e?o+="uic8":"[object Int16Array]"===e?o+="si16":"[object Uint16Array]"===e?o+="ur16":"[object Int32Array]"===e?o+="si32":"[object Uint32Array]"===e?o+="ui32":"[object Float32Array]"===e?o+="fl32":"[object Float64Array]"===e?o+="fl64":n(new Error("Failed to get type for BinaryArray"))),n(o+B(r))}else if("[object Blob]"===e){var s=new FileReader;s.onload=function(){var e="~~local_forage_type~"+t.type+"~"+B(this.result);n(U+w+e)},s.readAsArrayBuffer(t)}else try{n(JSON.stringify(t))}catch(e){n(null,e)}},deserialize:function(e){if(e.substring(0,D)!==U)return JSON.parse(e);var t,n=e.substring(Y),r=e.substring(D,Y);if(r===w&&L.test(n)){var o=n.match(L);t=o[1],n=n.substring(o[0].length)}var s=G(n);switch(r){case b:return s;case w:return i([s],{type:t});case"si08":return new Int8Array(s);case"ui08":return new Uint8Array(s);case"uic8":return new Uint8ClampedArray(s);case"si16":return new Int16Array(s);case"ur16":return new Uint16Array(s);case"si32":return new Int32Array(s);case"ui32":return new Uint32Array(s);case"fl32":return new Float32Array(s);case"fl64":return new Float64Array(s);default:throw new Error("Unkown type: "+r)}},stringToBuffer:G,bufferToString:B};function K(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function H(e,r,o,s,i,a){e.executeSql(o,s,i,function(e,n){n.code===n.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[r.storeName],function(e,t){t.rows.length?a(e,n):K(e,r,function(){e.executeSql(o,s,i,a)},a)},a):a(e,n)},a)}function k(i,e,a,c){var u=this;i=l(i);var t=new d(function(o,s){u.ready().then(function(){void 0===e&&(e=null);var n=e,r=u._dbInfo;r.serializer.serialize(e,function(t,e){e?s(e):r.db.transaction(function(e){H(e,r,"INSERT OR REPLACE INTO "+r.storeName+" (key, value) VALUES (?, ?)",[i,t],function(){o(n)},function(e,t){s(t)})},function(e){if(e.code===e.QUOTA_ERR){if(0 '__WebKitDatabaseInfoTable__'",[],function(e,t){for(var n=[],r=0;ri[0]&&t[1]Math.floor(d.SECONDARY_TIMEOUT*this.wait)&&this._throttledRequestHandler(),r>Math.floor(d.TIMEOUT*this.wait)&&(d.warn("Request "+this._requests[0].id+" timed out, over "+Math.floor(d.TIMEOUT*this.wait)+" seconds since last activity"),this._throttledRequestHandler())}}},_getRequestStatus:function(e,t){var n;if(4===e.xhr.readyState)try{n=e.xhr.status}catch(e){d.error("Caught an error while retrieving a request's status, reqStatus: "+n)}return void 0===n&&(n="number"==typeof t?t:0),n},_onRequestStateChange:function(e,t){if(d.debug("request id "+t.id+"."+t.sends+" state changed to "+t.xhr.readyState),t.abort)t.abort=!1;else if(4===t.xhr.readyState){var n=this._getRequestStatus(t);if(this.lastResponseHeaders=t.xhr.getAllResponseHeaders(),this.disconnecting&&400<=n)return this._hitError(n),void this._callProtocolErrorHandlers(t);var r=0this._conn.maxRetries;if((r||o)&&(this._removeRequest(t),d.debug("request id "+t.id+" should now be removed")),200===n){var s=this._requests[0]===t;(this._requests[1]===t||s&&0Math.floor(d.SECONDARY_TIMEOUT*this.wait))&&this._restartRequest(0),this._conn.nextValidRid(Number(t.rid)+1),d.debug("request id "+t.id+"."+t.sends+" got 200"),e(t),this.errors=0}else 0===n||400<=n&&n<600||12e3<=n?(d.error("request id "+t.id+"."+t.sends+" error "+n+" happened"),this._hitError(n),this._callProtocolErrorHandlers(t),400<=n&&n<500&&(this._conn._changeConnectStatus(d.Status.DISCONNECTING,null),this._conn._doDisconnect())):d.error("request id "+t.id+"."+t.sends+" error "+n+" happened");r||o?o&&!this._conn.connected&&this._conn._changeConnectStatus(d.Status.CONNFAIL,"giving-up"):this._throttledRequestHandler()}},_processRequest:function(e){var n=this,r=this._requests[e],t=this._getRequestStatus(r,-1);if(r.sends>this._conn.maxRetries)this._conn._onDisconnectTimeout();else{var o=r.age(),s=!isNaN(o)&&o>Math.floor(d.TIMEOUT*this.wait),i=null!==r.dead&&r.timeDead()>Math.floor(d.SECONDARY_TIMEOUT*this.wait),a=4===r.xhr.readyState&&(t<1||500<=t);if((s||i||a)&&(i&&d.error("Request ".concat(this._requests[e].id," timed out (secondary), restarting")),r.abort=!0,r.xhr.abort(),r.xhr.onreadystatechange=function(){},this._requests[e]=new d.Request(r.xmlData,r.origFunc,r.rid,r.sends),r=this._requests[e]),0===r.xhr.readyState){d.debug("request id "+r.id+"."+r.sends+" posting");try{var c=this._conn.options.contentType||"text/xml; charset=utf-8";r.xhr.open("POST",this._conn.service,!this._conn.options.sync),void 0!==r.xhr.setRequestHeader&&r.xhr.setRequestHeader("Content-Type",c),this._conn.options.withCredentials&&(r.xhr.withCredentials=!0)}catch(e){return d.error("XHR open failed: "+e.toString()),this._conn.connected||this._conn._changeConnectStatus(d.Status.CONNFAIL,"bad-service"),void this._conn.disconnect()}var u=function(){if(r.date=new Date,n._conn.options.customHeaders){var e=n._conn.options.customHeaders;for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.xhr.setRequestHeader(t,e[t])}r.xhr.send(r.data)};if(1/g,">")).replace(/'/g,"'")).replace(/"/g,""")},xmlunescape:function(e){return e=(e=(e=(e=(e=e.replace(/\&/g,"&")).replace(/</g,"<")).replace(/>/g,">")).replace(/'/g,"'")).replace(/"/g,'"')},xmlTextNode:function(e){return g.xmlGenerator().createTextNode(e)},xmlHtmlNode:function(e){var t;DOMParser?t=(new DOMParser).parseFromString(e,"text/xml"):((t=new ActiveXObject("Microsoft.XMLDOM")).async="false",t.loadXML(e));return t},getText:function(e){if(!e)return null;var t="";0===e.childNodes.length&&e.nodeType===g.ElementType.TEXT&&(t+=e.nodeValue);for(var n=0;n/g,"\\3e").replace(/@/g,"\\40")},unescapeNode:function(e){return"string"!=typeof e?e:e.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\")},getNodeFromJid:function(e){return e.indexOf("@")<0?null:e.split("@")[0]},getDomainFromJid:function(e){var t=g.getBareJidFromJid(e);if(t.indexOf("@")<0)return t;var n=t.split("@");return n.splice(0,1),n.join("@")},getResourceFromJid:function(e){var t=e.split("/");return t.length<2?null:(t.splice(0,1),t.join("/"))},getBareJidFromJid:function(e){return e?e.split("/")[0]:null},_handleError:function(e){void 0!==e.stack&&g.fatal(e.stack),e.sourceURL?g.fatal("error: "+this.handler+" "+e.sourceURL+":"+e.line+" - "+e.name+": "+e.message):e.fileName?g.fatal("error: "+this.handler+" "+e.fileName+":"+e.lineNumber+" - "+e.name+": "+e.message):g.fatal("error: "+e.message)},log:function(e,t){e===this.LogLevel.FATAL&&"object"===f(window.console)&&"function"==typeof window.console.error&&window.console.error(t)},debug:function(e){this.log(this.LogLevel.DEBUG,e)},info:function(e){this.log(this.LogLevel.INFO,e)},warn:function(e){this.log(this.LogLevel.WARN,e)},error:function(e){this.log(this.LogLevel.ERROR,e)},fatal:function(e){this.log(this.LogLevel.FATAL,e)},serialize:function(n){if(!n)return null;"function"==typeof n.tree&&(n=n.tree());var e=s(Array(n.attributes.length).keys()).map(function(e){return n.attributes[e].nodeName});e.sort();var t=e.reduce(function(e,t){return"".concat(e," ").concat(t,'="').concat(g.xmlescape(n.attributes.getNamedItem(t).value),'"')},"<".concat(n.nodeName));if(0";for(var r=0;r"}}t+=""}else t+="/>";return t},_requestId:0,_connectionPlugins:{},addConnectionPlugin:function(e,t){g._connectionPlugins[e]=t},Builder:function(e,t){"presence"!==e&&"message"!==e&&"iq"!==e||(t&&!t.xmlns?t.xmlns=g.NS.CLIENT:t||(t={xmlns:g.NS.CLIENT})),this.nodeTree=g.xmlElement(e,t),this.node=this.nodeTree}};g.Builder.prototype={tree:function(){return this.nodeTree},toString:function(){return g.serialize(this.nodeTree)},up:function(){return this.node=this.node.parentNode,this},root:function(){return this.node=this.nodeTree,this},attrs:function(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(void 0===e[t]?this.node.removeAttribute(t):this.node.setAttribute(t,e[t]));return this},c:function(e,t,n){var r=g.xmlElement(e,t,n);return this.node.appendChild(r),"string"!=typeof n&&"number"!=typeof n&&(this.node=r),this},cnode:function(e){var t,n=g.xmlGenerator();try{t=void 0!==n.importNode}catch(e){t=!1}var r=t?n.importNode(e,!0):g.copyElement(e);return this.node.appendChild(r),this.node=r,this},t:function(e){var t=g.xmlTextNode(e);return this.node.appendChild(t),this},h:function(e){var t=document.createElement("body");t.innerHTML=e;for(var n=g.createHtml(t);0e[n].prototype.priority&&(n=r);if(n!==t){var o=e[t];e[t]=e[n],e[n]=o}}return e},_attemptSASLAuth:function(e){e=this.sortMechanismsByPriority(e||[]);for(var t=!1,n=0;n>16)+(t>>16)+(n>>16)<<16|65535&n},r=function(e){for(var t=[],n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<>>32-a,n);var i,a},E=function(e,t,n,r,o,s,i){return a(t&n|~t&r,e,t,o,s,i)},h=function(e,t,n,r,o,s,i){return a(t&r|n&~r,e,t,o,s,i)},p=function(e,t,n,r,o,s,i){return a(t^n^r,e,t,o,s,i)},f=function(e,t,n,r,o,s,i){return a(n^(t|~r),e,t,o,s,i)},o=function(e,t){e[t>>5]|=128<>>9<<4)]=t;for(var n,r,o,s,i=1732584193,a=-271733879,c=-1732584194,u=271733878,l=0;l>2]>>r%4*8+4&15)+t.charAt(e[r>>2]>>r%4*8&15);return n}(o(r(e),8*e.length))},hash:function(e){return function(e){for(var t="",n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>n%32&255);return t}(o(r(e),8*e.length))}}},"./src/sha1.js":function(e,t,n){"use strict";function a(e,t){e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;var n,r,o,s,i,a,c,u,l,d=new Array(80),E=1732584193,h=-271733879,p=-1732584194,f=271733878,g=-1009589776;for(n=0;n>16)+(t>>16)+(n>>16)<<16|65535&n}function S(e,t){return e<>>32-t}function c(e){for(var t=[],n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<<24-n%32;return t}function o(e){for(var t,n,r="",o=0;o<4*e.length;o+=3)for(t=(e[o>>2]>>8*(3-o%4)&255)<<16|(e[o+1>>2]>>8*(3-(o+1)%4)&255)<<8|e[o+2>>2]>>8*(3-(o+2)%4)&255,n=0;n<4;n++)8*o+6*n>32*e.length?r+="=":r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t>>6*(3-n)&63);return r}function s(e){for(var t="",n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>24-n%32&255);return t}n.r(t),n.d(t,"default",function(){return i});var i={b64_hmac_sha1:function(e,t){return o(r(e,t))},b64_sha1:function(e){return o(a(c(e),8*e.length))},binb2str:s,core_hmac_sha1:r,str_hmac_sha1:function(e,t){return s(r(e,t))},str_sha1:function(e){return s(a(c(e),8*e.length))}}},"./src/strophe.js":function(e,t,n){"use strict";n.r(t);n("./src/bosh.js"),n("./src/websocket.js");var r=n("./src/core.js");n.d(t,"default",function(){return r.default})},"./src/utils.js":function(e,t,n){"use strict";function c(e){return(c="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})(e)}n.r(t),n.d(t,"default",function(){return r});var r={utf16to8:function(e){var t,n,r="",o=e.length;for(t=0;t>12&15),r+=String.fromCharCode(128|n>>6&63)):r+=String.fromCharCode(192|n>>6&31),r+=String.fromCharCode(128|n>>0&63));return r},addCookies:function(e){for(var t in e=e||{})if(Object.prototype.hasOwnProperty.call(e,t)){var n="",r="",o="",s=e[t],i="object"===c(s),a=escape(unescape(i?s.value:s));i&&(n=s.expires?";expires="+s.expires:"",r=s.domain?";domain="+s.domain:"",o=s.path?";path="+s.path:""),document.cookie=t+"="+a+n+r+o}}}},"./src/websocket.js":function(e,t,n){"use strict";n.r(t);var r=n("./src/core.js"),u=r.default.Strophe,o=r.default.$build;u.Websocket=function(e){this._conn=e,this.strip="wrapper";var t=e.service;if(0!==t.indexOf("ws:")&&0!==t.indexOf("wss:")){var n="";"ws"===e.options.protocol&&"https:"!==window.location.protocol?n+="ws":n+="wss",n+="://"+window.location.host,0!==t.indexOf("/")?n+=window.location.pathname+t:n+=t,e.service=n}},u.Websocket.prototype={_buildStream:function(){return o("open",{xmlns:u.NS.FRAMING,to:this._conn.domain,version:"1.0"})},_check_streamerror:function(e,t){var n;if(0===(n=e.getElementsByTagNameNS?e.getElementsByTagNameNS(u.NS.STREAM,"error"):e.getElementsByTagName("stream:error")).length)return!1;for(var r=n[0],o="",s="",i=0;i: "+n);var r=e.getAttribute("version");return"string"!=typeof r?t="Missing version in ":"1.0"!==r&&(t="Wrong version in : "+r),!t||(this._conn._changeConnectStatus(u.Status.CONNFAIL,t),this._conn._doDisconnect(),!1)},_connect_cb_wrapper:function(e){if(0===e.data.indexOf("\s*)*/,"");if(""===t)return;var n=(new DOMParser).parseFromString(t,"text/xml").documentElement;this._conn.xmlInput(n),this._conn.rawInput(e.data),this._handleStreamStart(n)&&this._connect_cb(n)}else if(0===e.data.indexOf(" tag.")}}this._conn._doDisconnect()},_doDisconnect:function(){u.info("WebSockets _doDisconnect was called"),this._closeSocket()},_streamWrap:function(e){return""+e+""},_closeSocket:function(){if(this.socket)try{this.socket.onerror=null,this.socket.close()}catch(e){u.debug(e.message)}this.socket=null},_emptyQueue:function(){return!0},_onClose:function(e){this._conn.connected&&!this._conn.disconnecting?(u.error("Websocket closed unexpectedly"),this._conn._doDisconnect()):e&&1006===e.code&&!this._conn.connected&&this.socket?(u.error("Websocket closed unexcectedly"),this._conn._changeConnectStatus(u.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._conn._doDisconnect()):u.info("Websocket closed")},_no_auth_received:function(e){u.error("Server did not offer a supported authentication mechanism"),this._changeConnectStatus(u.Status.CONNFAIL,u.ErrorCondition.NO_AUTH_MECH),e&&e.call(this._conn),this._conn._doDisconnect()},_onDisconnectTimeout:function(){},_abortAllRequests:function(){},_onError:function(e){u.error("Websocket error "+e),this._conn._changeConnectStatus(u.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._disconnect()},_onIdle:function(){var e=this._conn._data;if(0e.getId()&&(i=parseInt(e.getId().toString())),ri[0]&&t[1]"}},getFriends:{endpoint:"user/friends",method:"GET"},unfriend:{endpoint:"user/friends/{{uid}}/{{gid}}",method:"DELETE",data:{uids:"array"}},acceptFriendRequest:{endpoint:"user/friends/{{uid}}/accept",method:"PUT",data:{uids:"array"}},rejectFriendRequest:{endpoint:"user/friends/{{uid}}/reject",method:"DELETE",data:{uids:"array"}},createGroup:{endpoint:"groups",method:"POST",data:{guid:"required|string|max:100",name:"required|string|max:100",type:"enum|public,protected,password",password:"filled|string|max:100"}},getGroups:{endpoint:"groups",method:"GET"},getGroup:{endpoint:"groups/{{guid}}",method:"GET"},updateGroup:{endpoint:"groups/{{guid}}",method:"PUT"},deleteGroup:{endpoint:"groups/{{guid}}",method:"DELETE"},addGroupMembers:{endpoint:"groups/{{guid}}/members",method:"POST",data:{uids:"array"}},getGroupMembers:{endpoint:"groups/{{guid}}/members",method:"GET"},joinGroup:{endpoint:"groups/{{guid}}/members",method:"POST"},leaveGroup:{endpoint:"groups/{{guid}}/members",method:"DELETE"},kickGroupMembers:{endpoint:"groups/{{guid}}/members/{{uid}}",method:"DELETE",data:{uids:"array"}},changeScopeOfMember:{endpoint:"groups/{{guid}}/members/{{uid}}",method:"PUT",data:{uids:"array"}},banGroupMember:{endpoint:"groups/{{guid}}/bannedusers/{{uid}}",method:"POST",data:{uids:"array"}},unbanGroupMember:{endpoint:"groups/{{guid}}/bannedusers/{{uid}}",method:"DELETE",data:{uids:"array"}},addMemebersToGroup:{endpoint:"groups/{{guid}}/members",method:"PUT"},getBannedGroupMembers:{endpoint:"groups/{{guid}}/bannedusers",method:"GET"},promotemoteGroupMember:{endpoint:"groups/{{guid}}/promote",method:"PUT",data:{uids:"array"}},demoteGroupMember:{endpoint:"groups/{{guid}}/demote",method:"DELETE",data:{uids:"array"}},sendMessage:{endpoint:"messages",method:"POST",data:{sender:"array:string:max:100>",isGroupMember:"filled|boolean|bail",data:"required|json"}},getMessages:{endpoint:"messages",method:"GET"},getMessageDetails:{endpoint:"messages/{{messageId}}",method:"GET"},getUserMessages:{endpoint:"users/{{listId}}/messages",method:"GET"},getGroupMessages:{endpoint:"groups/{{listId}}/messages",method:"GET"},getMessage:{endpoint:"user/messages/{{muid}}",method:"GET"},updateMessage:{endpoint:"messages/{{messageId}}",method:"PUT"},deleteMessage:{endpoint:"messages/{{messageId}}",method:"DELETE"},createCallSession:{endpoint:"calls",method:"POST",data:{}},updateCallSession:{endpoint:"calls/{{sessionid}}",method:"put",data:{}},getConversations:{endpoint:"conversations",method:"GET"}}}return s.prototype.getEndpointData=function(o){return new Promise(function(r,t){try{c.LocalStorage.getInstance().get(a.APP_SETTINGS.APP_SETTINGS).then(function(e){if(i.isFalsy(e)){var t={};if((new s).uriEndpoints.hasOwnProperty(o))if((t=(new s).uriEndpoints[o]).hasOwnProperty("isAdminApi")){var n=i.format((new s).adminApiUrl,u.CometChat.appSettings.getRegion())+(new s).adminApiVersion+"/"+t.endpoint;t.endpoint=n}else{n=i.format((new s).baseUrl,u.CometChat.appSettings.getRegion())+(new s).apiVersion+"/"+t.endpoint;t.endpoint=n}r(t)}else{t={};if((new s).uriEndpoints.hasOwnProperty(o))if((t=(new s).uriEndpoints[o]).hasOwnProperty("isAdminApi"))t.endpoint="https://"+e[a.APP_SETTINGS.KEYS.ADMIN_API_HOST]+"/"+(new s).adminApiVersion+"/"+t.endpoint;else{n="https://"+e[a.APP_SETTINGS.KEYS.CLIENT_API_HOST]+"/"+(new s).apiVersion+"/"+t.endpoint;t.endpoint=n}r(t)}},function(e){var t;(new s).uriEndpoints.hasOwnProperty(o)&&((t=(new s).uriEndpoints[o]).hasOwnProperty(["isAdminApi"])?t.endpoint=i.format((new s).adminApiUrl,u.CometChat.appSettings.getRegion())+(new s).adminApiVersion+"/"+t.endpoint:t.endpoint=i.format((new s).baseUrl,u.CometChat.appSettings.getRegion())+(new s).apiVersion+"/"+t.endpoint),r(t)})}catch(e){t(new l.CometChatException(e))}})},s}();t.EndpointFactory=r},function(e,t,n){"use strict";t.__esModule=!0;var r=n(44),o=n(0),s=n(1),i=function(){function e(){}return e.transformPresence=function(e){return e.getAttribute("type")?new r.UserPresence(e.getAttribute(o.PresenceConstatnts.XMPP_KEYS.FROM),o.PresenceConstatnts.STATUS.OFFLINE,(new Date).getTime()):new r.UserPresence(e.getAttribute(o.PresenceConstatnts.XMPP_KEYS.FROM),o.PresenceConstatnts.STATUS.ONLINE,(new Date).getTime())},e.transformPresences=function(e){var t=[];return e.map(function(e){try{t.push(new r.UserPresence(e.getAttribute(o.PresenceConstatnts.XMPP_KEYS.FROM),e.getAttribute(o.PresenceConstatnts.XMPP_KEYS.STATUS),e.getAttribute(o.PresenceConstatnts.XMPP_KEYS.LAST_ACTIVE_AT)))}catch(e){s.Logger.error("PresenceController:transformPresences",e)}}),t},e.transformMUCUserPresence=function(e){return e.getAttribute("type")?new r.UserPresence(e.getAttribute(o.PresenceConstatnts.XMPP_KEYS.FROM),o.PresenceConstatnts.STATUS.LEFT,(new Date).getTime()):new r.UserPresence(e.getAttribute(o.PresenceConstatnts.XMPP_KEYS.FROM),o.PresenceConstatnts.STATUS.JOINED,(new Date).getTime())},e.trandformMUCPresence=function(e){0=1e3*o.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT&&delete n.TYPING_STARTED_MAP[e]})}),new Promise(function(e,t){Object.keys(n.TYPING_ENDED_MAP).map(function(e){r.getCurrentTime()-n.TYPING_ENDED_MAP[e]>=1e3*o.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT&&delete n.TYPING_ENDED_MAP[e]})}),new Promise(function(e,t){Object.keys(n.INCOMING_TYPING_STARTED_MAP).map(function(e){r.getCurrentTime()-n.INCOMING_TYPING_STARTED_MAP[e][o.TYPING_NOTIFICATION.KEYS.TIMESTAMP]>=1e3*o.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT&&(s.XMPPConnectionHelper.getInstance().publishTypinStatusNotification(n.INCOMING_TYPING_STARTED_MAP[e][o.TYPING_NOTIFICATION.KEYS.TYPING_NOTIFICATION],o.TYPING_NOTIFICATION.ACTIONS.ENDED),delete n.INCOMING_TYPING_STARTED_MAP[e])})})},e.TYPING_STARTED_MAP={},e.TYPING_ENDED_MAP={},e.INCOMING_TYPING_STARTED_MAP={},e}();t.TypingNotificationController=i},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(s,i,a,c){return new(a||(a=Promise))(function(e,t){function n(e){try{o(c.next(e))}catch(e){t(e)}}function r(e){try{o(c.throw(e))}catch(e){t(e)}}function o(t){t.done?e(t.value):new a(function(e){e(t.value)}).then(n,r)}o((c=c.apply(s,i||[])).next())})},o=this&&this.__generator||function(n,r){var o,s,i,e,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,s&&(i=2&t[0]?s.return:t[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,t[1])).done)return i;switch(s=0,i&&(t=[2&t[0],i.value]),t[0]){case 0:case 1:i=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,s=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(i=0<(i=a.trys).length&&i[i.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!i||t[1]>i[0]&&t[1]"==e&&">")||"&"==e&&"&"||'"'==e&&"""||"&#"+e.charCodeAt()+";"}function b(e,t){if(t(e))return!0;if(e=e.firstChild)do{if(b(e,t))return!0}while(e=e.nextSibling)}function w(){}function Y(e,t,n,r){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==n.namespaceURI&&delete t._nsMap[n.prefix?n.localName:""]}function x(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n)r[r.length++]=n;else{for(var o=t.firstChild,s=0;o;)o=(r[s++]=o).nextSibling;r.length=s}}}function G(e,t){var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,x(e.ownerDocument,e),t}function B(e,t,n){var r=t.parentNode;if(r&&r.removeChild(t),t.nodeType===O){var o=t.firstChild;if(null==o)return t;var s=t.lastChild}else o=s=t;var i=n?n.previousSibling:e.lastChild;for(o.previousSibling=i,s.nextSibling=n,i?i.nextSibling=o:e.firstChild=o,null==n?e.lastChild=s:n.previousSibling=s;o.parentNode=e,o!==s&&(o=o.nextSibling););return x(e.ownerDocument||e,e),t.nodeType==O&&(t.firstChild=t.lastChild=null),t}function F(){this._nsMap={}}function K(){}function H(){}function k(){}function J(){}function V(){}function j(){}function X(){}function q(){}function W(){}function $(){}function Q(){}function z(){}function Z(e,t){var n=[],r=9==this.nodeType?this.documentElement:this,o=r.prefix,s=r.namespaceURI;if(s&&null==o&&null==(o=r.lookupPrefix(s)))var i=[{namespace:s,prefix:null}];return te(this,n,e,t,i),n.join("")}function ee(e,t,n){var r=e.prefix||"",o=e.namespaceURI;if(!r&&!o)return!1;if("xml"===r&&"http://www.w3.org/XML/1998/namespace"===o||"http://www.w3.org/2000/xmlns/"==o)return!1;for(var s=n.length;s--;){var i=n[s];if(i.prefix==r)return i.namespace!=o}return!0}function te(e,t,n,r,o){if(r){if(!(e=r(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case C:o||(o=[]);o.length;var s=e.attributes,i=s.length,a=e.firstChild,c=e.tagName;n=_===e.namespaceURI||n,t.push("<",c);for(var u=0;u"),n&&/^script$/i.test(c))for(;a;)a.data?t.push(a.data):te(a,t,n,r,o),a=a.nextSibling;else for(;a;)te(a,t,n,r,o),a=a.nextSibling;t.push("")}else t.push("/>");return;case R:case O:for(a=e.firstChild;a;)te(a,t,n,r,o),a=a.nextSibling;return;case S:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,D),'"');case T:return t.push(e.data.replace(/[<&]/g,D));case m:return t.push("");case N:return t.push("\x3c!--",e.data,"--\x3e");case y:var p=e.publicId,f=e.systemId;if(t.push("');else if(f&&"."!=f)t.push(' SYSTEM "',f,'">');else{var g=e.internalSubset;g&&t.push(" [",g,"]"),t.push(">")}return;case I:return t.push("");case A:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function ne(e,t,n){e[t]=n}E.prototype=Error.prototype,s(a,E),h.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var n=[],r=0;ri[0]&&t[1]t._resendCount)return;t._msgQueue[e].tree().setAttribute("from",t._conn.jid),t._conn.send(t._msgQueue[e]),t.resendMessage(e)}},this._resendTime)},addReceiptHandler:function(t,e,n,r){var o=this;this._conn.addHandler(function(e){return o._processReceipt(e),t(e)},p.Strophe.NS.RECEIPTS,"message",e,null,n,r)},_processReceipt:function(h,e){return void 0===e&&(e=0),n(this,void 0,void 0,function(){var t,n,r,o,s,i,a,c,u,l,d,E;return f(this,function(e){t=h.getAttribute(_.DELIVERY_RECEIPTS.ID),n=p.Strophe.getBareJidFromJid(h.getAttribute(_.MessageConstatnts.XMPP_KEYS.FROM)),r=g.getUidFromJid(n),o=_.MessageConstatnts.XMPP_KEYS.TYPE_USER,s=_.MessageConstatnts.RECEIVER_TYPE.USER,i=h.getElementsByTagName("request"),a=h.getElementsByTagName("received");try{c=h.getElementsByTagName("body")[0].innerHTML}catch(e){u=c=void 0}return void 0!==c&&(u=JSON.parse(c).receiverType),h.getAttribute(_.MessageConstatnts.XMPP_KEYS.TYPE)==_.MessageConstatnts.XMPP_KEYS.TYPE_GROUP||void 0!==u&&u==_.MessageConstatnts.RECEIVER_TYPE.GROUP?(s=_.MessageConstatnts.RECEIVER_TYPE.GROUP,n=g.getGroupJidFullGroupJid(h.getAttribute(_.MessageConstatnts.XMPP_KEYS.FROM)),o=_.MessageConstatnts.XMPP_KEYS.TYPE_GROUP,0a.DEFAULT_VALUES.GROUPS_MAX_LIMIT)return new s.CometChatException(JSON.parse(r.format(JSON.stringify(a.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT","group limit",a.DEFAULT_VALUES.GROUPS_MAX_LIMIT)));if(this.limitthis.total_pages)return e.page=this.next_page,e;e.page=this.next_page++}return e},e.prototype.getPreData=function(){var e={};return e.per_page=this.limit,0<=this.next_page&&0l.DEFAULT_VALUES.USERS_MAX_LIMIT)return new c.CometChatException(JSON.parse(i.format(JSON.stringify(l.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT","group member limit",l.DEFAULT_VALUES.USERS_MAX_LIMIT)));if(this.limitthis.total_pages)return e.page=this.next_page,e;e.page=++this.next_page}return e},e.prototype.getPreData=function(){var e={};return e.per_page=this.limit,0<=this.next_page&&0u.DEFAULT_VALUES.USERS_MAX_LIMIT)return new c.CometChatException(JSON.parse(i.format(JSON.stringify(u.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT","user limit",u.DEFAULT_VALUES.USERS_MAX_LIMIT)));if(this.limitthis.total_pages)return e.page=this.next_page,e;e.page=this.next_page++}return e},o.prototype.getPreData=function(){var e={};return e.per_page=this.limit,0<=this.next_page&&0a.DEFAULT_VALUES.CONVERSATION_MAX_LIMIT?new s.CometChatException(JSON.parse(r.format(JSON.stringify(a.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT","conversation limit",a.DEFAULT_VALUES.CONVERSATION_MAX_LIMIT))):this.limitthis.total_pages)return e.page=this.next_page,e;e.page=this.next_page++}return e},e}();t.ConversationsRequest=c;var u=function(){function e(){}return e.prototype.setLimit=function(e){return this.limit=e,this},e.prototype.setConversationType=function(e){return this.conversationType=e,this},e.prototype.build=function(){return new c(this)},e}();t.ConversationsRequestBuilder=u},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(s,i,a,c){return new(a||(a=Promise))(function(e,t){function n(e){try{o(c.next(e))}catch(e){t(e)}}function r(e){try{o(c.throw(e))}catch(e){t(e)}}function o(t){t.done?e(t.value):new a(function(e){e(t.value)}).then(n,r)}o((c=c.apply(s,i||[])).next())})},a=this&&this.__generator||function(n,r){var o,s,i,e,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,s&&(i=2&t[0]?s.return:t[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,t[1])).done)return i;switch(s=0,i&&(t=[2&t[0],i.value]),t[0]){case 0:case 1:i=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,s=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(i=0<(i=a.trys).length&&i[i.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!i||t[1]>i[0]&&t[1]C.DEFAULT_VALUES.MSGS_MAX_LIMIT)return void t(new p.CometChatException(JSON.parse(_.format(JSON.stringify(C.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT","message limit",C.DEFAULT_VALUES.MSGS_MAX_LIMIT))));if(re&&A.MessageListnerMaping.getInstance().set("all",t.id)},function(e){A.MessageListnerMaping.getInstance().set("all",t.id)}),h.affix==C.MessageConstatnts.PAGINATION.AFFIX.APPEND?(h.idt.id&&(h.id=t.id),h.timestamp>t.sentAt&&(h.timestamp=t.sentAt),h.updatedAt>t.updatedAt&&(h.updatedAt=t.updatedAt)),h.id&&(h.paginationMeta[C.MessageConstatnts.PAGINATION.KEYS.ID]=h.id),h.timestamp&&(h.paginationMeta[C.MessageConstatnts.PAGINATION.KEYS.SENT_AT]=h.timestamp),h.updatedAt&&(h.paginationMeta[C.MessageConstatnts.PAGINATION.KEYS.UPDATED_AT]=h.updatedAt),n.push(g.MessageController.trasformJSONMessge(t))})}else n=[];a(n)},function(e){t(new p.CometChatException(e))})}catch(e){t(new p.CometChatException(e))}})},e.prototype.createEndpoint=function(){(_.isFalsy(this.guid)||_.isFalsy(this.uid))&&_.isFalsy(this.guid)?(_.isFalsy(this.uid)?this.endpointName="getMessages":this.endpointName="getUserMessages",this.listId=this.uid):(this.endpointName="getGroupMessages",this.listId=this.guid)},e.prototype.makeData=function(){var e={};e[C.MessageConstatnts.PAGINATION.KEYS.PER_PAGE]=this.limit,e[C.MessageConstatnts.PAGINATION.KEYS.AFFIX]=this.affix,(_.isFalsy(this.guid)||_.isFalsy(this.uid))&&_.isFalsy(this.guid)&&_.isFalsy(this.uid)},e.prototype.getFilteredPreviousDataByReceiverId=function(t){return r(this,void 0,void 0,function(){var n,r=this;return a(this,function(e){switch(e.label){case 0:switch(n=[],t){case"user":return[3,1];case"group":return[3,3];case"both":return[3,5]}return[3,7];case 1:return[4,o.MessagesStore.getInstance().get(this.uid).then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).map(function(e){n=n.concat([t[e]])})})];case 2:return e.sent(),[3,9];case 3:return[4,o.MessagesStore.getInstance().get(this.guid).then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).map(function(e){n=n.concat([t[e]])})})];case 4:e.sent(),e.label=5;case 5:return[4,o.MessagesStore.getInstance().get(this.guid).then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).filter(function(e){return t[e].sender.uid==r.uid}).map(function(e){n=n.concat([t[e]])})})];case 6:return e.sent(),[3,9];case 7:return[4,o.MessagesStore.getInstance().getAllMessages().then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).map(function(e){n=n.concat([t[e]])})})];case 8:return e.sent(),[3,9];case 9:return[2,n]}})})},e.prototype.getFilteredNextDataByReceiverId=function(t){return r(this,void 0,void 0,function(){var n,r=this;return a(this,function(e){switch(e.label){case 0:switch(n=[],t){case"user":return[3,1];case"group":return[3,3];case"both":return[3,5]}return[3,7];case 1:return[4,o.MessagesStore.getInstance().get(this.uid).then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).map(function(e){n=n.concat([t[e]])})})];case 2:return e.sent(),[3,9];case 3:return[4,o.MessagesStore.getInstance().get(this.guid).then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).map(function(e){n=n.concat([t[e]])})})];case 4:e.sent(),e.label=5;case 5:return[4,o.MessagesStore.getInstance().get(this.guid).then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).filter(function(e){return t[e].sender.uid==r.uid}).map(function(e){n=n.concat([t[e]])})})];case 6:return e.sent(),[3,9];case 7:return[4,o.MessagesStore.getInstance().getAllMessages().then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).map(function(e){n=n.concat([t[e]])})})];case 8:return e.sent(),[3,9];case 9:return[2,n]}})})},e}();t.DefaultMessagesRequest=s;var i=function(){function e(){this.maxLimit=C.DEFAULT_VALUES.MSGS_MAX_LIMIT,this.timestamp=0,this.id=C.DEFAULT_VALUES.DEFAULT_MSG_ID,this.unread=!1,this.undelivered=!1,this.HideMessagesFromBlockedUsers=!1,this.onlyUpdate=0}return e.prototype.setLimit=function(e){return this.limit=e,this},e.prototype.setGUID=function(e){return this.guid=e,this},e.prototype.setUID=function(e){return this.uid=e,this},e.prototype.setTimestamp=function(e){return void 0===e&&(e=_.getCurrentTime()),this.timestamp=e,this},e.prototype.setMessageId=function(e){return void 0===e&&(e=C.DEFAULT_VALUES.DEFAULT_MSG_ID),this.id=e,this},e.prototype.setUnread=function(e){return void 0===e&&(e=!1),this.unread=e,this},e.prototype.setUndelivered=function(e){return void 0===e&&(e=!1),this.undelivered=e,this},e.prototype.hideMessagesFromBlockedUsers=function(e){return void 0===e&&(e=!1),this.HideMessagesFromBlockedUsers=e,this},e.prototype.setSearchKeyword=function(e){return this.searchKey=e,this},e.prototype.setUpdatedAfter=function(e){return this.updatedAt=e,this},e.prototype.updatesOnly=function(e){return e&&(this.onlyUpdate=1),this},e.prototype.setCategory=function(e){return this.category=e,this},e.prototype.setType=function(e){return this.type=e,this},e.prototype.build=function(){return new s(this)},e}();t.DefaultMessagesRequestBuilder=i},function(e,t,n){"use strict";t.__esModule=!0;var r=function(e){};t.CometChatExtension=r},function(e,t,n){"use strict";t.__esModule=!0;var o=n(4),r=n(1),s=n(8),i=n(2),a=n(0),c=function(){function e(e){this.next_page=1,this.current_page=1,this.total_pages=-1,this.fetchingInProgress=!1,this.pagination={total:0,count:0,per_page:0,current_page:0,total_pages:0,links:[]},r.isFalsy(e)||(this.limit=e.limit,r.isFalsy(e.searchKeyword)||(this.searchKeyword=e.searchKeyword),r.isFalsy(e.direction)||(this.direction=e.direction))}return e.prototype.validateBlockedUsersBuilder=function(){if(void 0===this.limit)return new i.CometChatException(JSON.parse(r.format(JSON.stringify(a.GENERAL_ERROR.COMPULSORY),"SET_LIMIT","SET_LIMIT","setLimit() method")));if(isNaN(this.limit))return new i.CometChatException(JSON.parse(r.format(JSON.stringify(a.GENERAL_ERROR.MUST_BE_A_NUMBER),"SET_LIMIT","SET_LIMIT","user limit")));if(this.limit>a.DEFAULT_VALUES.USERS_MAX_LIMIT)return new i.CometChatException(JSON.parse(r.format(JSON.stringify(a.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT","user limit",a.DEFAULT_VALUES.USERS_MAX_LIMIT)));if(this.limitthis.total_pages)return e.page=this.next_page,e;e.page=++this.next_page}return e},e.prototype.getPreData=function(){var e={};return e.per_page=this.limit,0<=this.next_page&&0>>((3&t)<<3)&255;return o}}},function(e,t){for(var o=[],n=0;n<256;++n)o[n]=(n+256).toString(16).substr(1);e.exports=function(e,t){var n=t||0,r=o;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")}},function(e,t,n){function r(e){this.options=e||{locator:{}}}function u(){this.cdata=!1}function l(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function d(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function o(e,t,n){return"string"==typeof e?e.substr(t,n):e.length>=t+n||t?new java.lang.String(e,t,n)+"":e}function E(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}r.prototype.parseFromString=function(e,t){var n=this.options,r=new h,o=n.domBuilder||new u,s=n.errorHandler,i=n.locator,a=n.xmlns||{},c={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return i&&o.setDocumentLocator(i),r.errorHandler=function(r,e,o){if(!r){if(e instanceof u)return e;r=e}var s={},i=r instanceof Function;function t(t){var n=r[t];!n&&i&&(n=2==r.length?function(e){r(t,e)}:r),s[t]=n&&function(e){n("[xmldom "+t+"]\t"+e+d(o))}||function(){}}return o=o||{},t("warning"),t("error"),t("fatalError"),s}(s,o,i),r.domBuilder=n.domBuilder||o,/\/x?html?$/.test(t)&&(c.nbsp=" ",c.copy="©",a[""]="http://www.w3.org/1999/xhtml"),a.xml=a.xml||"http://www.w3.org/XML/1998/namespace",e?r.parse(e,a,c):r.errorHandler.error("invalid doc source"),o.doc},u.prototype={startDocument:function(){this.doc=(new s).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,n,r){var o=this.doc,s=o.createElementNS(e,n||t),i=r.length;E(this,s),this.currentElement=s,this.locator&&l(this.locator,s);for(var a=0;a":switch(c){case d:n.setTagName(e.slice(t,a));case g:case _:case C:break;case f:case E:"/"===(l=e.slice(t,a)).slice(-1)&&(n.closed=!0,l=l.slice(0,-1));case h:c===h&&(l=i),c==f?(s.warning('attribute "'+l+'" missed quot(")!!'),n.add(i,l.replace(/&#?\w+;/g,o),t)):("http://www.w3.org/1999/xhtml"===r[""]&&l.match(/^(?:disabled|checked|selected)$/i)||s.warning('attribute "'+l+'" missed value!! "'+l+'" instead!!'),n.add(l,l,t));break;case p:throw new Error("attribute value missed!!")}return a;case"€":u=" ";default:if(u<=" ")switch(c){case d:n.setTagName(e.slice(t,a)),c=_;break;case E:i=e.slice(t,a),c=h;break;case f:var l=e.slice(t,a).replace(/&#?\w+;/g,o);s.warning('attribute "'+l+'" missed quot(")!!'),n.add(i,l,t);case g:c=_}else switch(c){case h:n.tagName;"http://www.w3.org/1999/xhtml"===r[""]&&i.match(/^(?:disabled|checked|selected)$/i)||s.warning('attribute "'+i+'" missed value!! "'+i+'" instead2!!'),n.add(i,i,t),t=a,c=E;break;case g:s.warning('attribute space is required"'+i+'"!!');case _:c=E,t=a;break;case p:c=f,t=a;break;case C:throw new Error("elements closed character '/' and '>' must be connected to")}}a++}}function D(e,t,n){for(var r=e.tagName,o=null,s=e.length;s--;){var i=e[s],a=i.qName,c=i.value;if(0<(E=a.indexOf(":")))var u=i.prefix=a.slice(0,E),l=a.slice(E+1),d="xmlns"===u&&l;else u=null,d="xmlns"===(l=a)&&"";i.localName=l,!1!==d&&(null==o&&(o={},S(n,n={})),n[d]=o[d]=c,i.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(d,c))}for(s=e.length;s--;){(u=(i=e[s]).prefix)&&("xml"===u&&(i.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==u&&(i.uri=n[u||""]))}var E=r.indexOf(":");l=e.localName=0",t),i=e.substring(t+1,s);if(/[&<]/.test(i))return/^script$/i.test(n)||(i=i.replace(/&#?\w+;/g,r)),o.characters(i,0,i.length),s}return t+1}function w(e,t,n,r){var o=r[n];return null==o&&((o=e.lastIndexOf(""))",t+9);return n.startCDATA(),n.characters(e,t+9,o-t-9),n.endCDATA(),o+3}var s=function(e,t){var n,r=[],o=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;o.lastIndex=t,o.exec(e);for(;n=o.exec(e);)if(r.push(n),n[1])return r}(e,t),i=s.length;if(1",t);if(r){var o=e.substring(t,r).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(o){o[0].length;return n.processingInstruction(o[1],o[2]),r+2}return-1}return-1}function G(e){}function i(e,t){return e.__proto__=t,e}s.prototype={parse:function(e,t,n){var r=this.domBuilder;r.startDocument(),S(t,t={}),function(n,e,r,o,s){function i(e){var t=e.slice(1,-1);return t in r?r[t]:"#"===t.charAt(0)?function(e){{if(65535>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}}(parseInt(t.substr(1).replace("x","0x"))):(s.error("entity not found:"+e),e)}function t(e){if(p",f+3),S=n.substring(f+2,C),T=E.pop();C<0?(S=n.substring(f+2).replace(/[\s<].*/,""),s.error("end tag name: "+S+" is not complete:"+T.tagName),C=f+1+S.length):S.match(/\s>>32-t}function S(e){var t,n="";for(t=7;0<=t;t--)n+=(e>>>4*t&15).toString(16);return n}r.Logger=p,r.getCurrentTime=function(){return(new Date).getTime()},r.getAppSettings=function(){return new Promise(function(t,n){o.LocalStorage.getInstance().get(s.APP_SETTINGS.APP_SETTINGS).then(function(e){E(e)?f().then(function(e){t(e)},function(e){n(e)}):t(e)},function(e){n(e)})})},r.getUpdatedSettings=f,r.isImage=function(e){var t;return e.type&&e.type.toLowerCase().includes("image")&&(t=!0),t},r.isVideo=function(e){var t;return e.type&&e.type.toLowerCase().includes("video")&&(t=!0),t},r.isAudio=function(e){var t;return e.type&&e.type.toLowerCase().includes("audio")&&(t=!0),t},r.validateScope=function(e){return typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"SCOPE","SCOPE","scope"))):E(e)?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"SCOPE","SCOPE","scope"))):e!=d.CometChat.GROUP_MEMBER_SCOPE.ADMIN&&e!=d.CometChat.GROUP_MEMBER_SCOPE.MODERATOR&&e!=d.CometChat.GROUP_MEMBER_SCOPE.PARTICIPANT?new a.CometChatException(s.GroupErrors.INVALID_SCOPE):void 0},r.validateUpdateGroup=function(e){return e.hasOwnProperty(s.GroupConstants.KEYS.GUID)?typeof e[s.GroupConstants.KEYS.GUID]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GUID","GUID","guid"))):E(e[s.GroupConstants.KEYS.GUID])?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"GUID","GUID","guid"))):e.hasOwnProperty(s.GroupConstants.KEYS.NAME)&&""===e[s.GroupConstants.KEYS.NAME]?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.EMPTY_STRING),"GROUP_NAME","GROUP_NAME","group name"))):void 0:new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"GUID","GUID","guid")))},r.validateJoinGroup=function(e,t,n){if(typeof e==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.OBJECT){if(!e.hasOwnProperty(s.GroupConstants.KEYS.GUID))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"GUID","GUID","guid")));if(typeof e[s.GroupConstants.KEYS.GUID]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GUID","GUID","guid")));if(E(e[s.GroupConstants.KEYS.GUID]))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"GUID","GUID","guid")));if(!e.hasOwnProperty(s.GroupConstants.KEYS.TYPE))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"GROUP_TYPE","GROUP_TYPE","group type")));if(typeof e[s.GroupConstants.KEYS.TYPE]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GROUP_TYPE","GROUP_TYPE","group type")));if(E(e[s.GroupConstants.KEYS.TYPE]))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"GROUP_TYPE","GROUP_TYPE","group type")));if(e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PUBLIC&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PASSWORD&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PROTECTED&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PRIVATE)return new a.CometChatException(s.GroupErrors.INVALID_GROUP_TYPE);if(e[s.GroupConstants.KEYS.TYPE].toLowerCase()==d.CometChat.GROUP_TYPE.PASSWORD){if(!e.hasOwnProperty(s.GroupConstants.KEYS.PASSWORD))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"PASSWORD","PASSWORD","password")));if(typeof e[s.GroupConstants.KEYS.PASSWORD]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"PASSWORD","PASSWORD","password")));if(E(e[s.GroupConstants.KEYS.PASSWORD]))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"PASSWORD","PASSWORD","password")))}}else{if(void 0!==e){if(typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GUID","GUID","guid")));if(E(e))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"GUID","GUID","guid")))}if(void 0!==t){if(typeof t!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GROUP_TYPE","GROUP_TYPE","group type")));if(E(t))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"GROUP_TYPE","GROUP_TYPE","group type")));if(t.toLowerCase()!=d.CometChat.GROUP_TYPE.PUBLIC&&t.toLowerCase()!=d.CometChat.GROUP_TYPE.PASSWORD&&t.toLowerCase()!=d.CometChat.GROUP_TYPE.PROTECTED&&t.toLowerCase()!=d.CometChat.GROUP_TYPE.PRIVATE)return new a.CometChatException(s.GroupErrors.INVALID_GROUP_TYPE);if(t.toLowerCase()==d.CometChat.GROUP_TYPE.PASSWORD){if(typeof n!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"PASSWORD","PASSWORD","password")));if(E(n))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"PASSWORD","PASSWORD","password")))}}}},r.validateCreateGroup=function(e){if(!e.hasOwnProperty(s.GroupConstants.KEYS.GUID))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"GUID","GUID","guid")));if(typeof e[s.GroupConstants.KEYS.GUID]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GUID","GUID","guid")));if(E(e[s.GroupConstants.KEYS.GUID]))return new a.CometChatException({code:"Empty GUID"});if(!e.hasOwnProperty(s.GroupConstants.KEYS.NAME))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"GROUP_NAME","GROUP_NAME","group name")));if(typeof e[s.GroupConstants.KEYS.NAME]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GROUP_NAME","GROUP_NAME","group name")));if(E(e[s.GroupConstants.KEYS.NAME]))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"GROUP_NAME","GROUP_NAME","group name")));if(!e.hasOwnProperty(s.GroupConstants.KEYS.TYPE))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"GROUP_TYPE","GROUP_TYPE","group type")));if(typeof e[s.GroupConstants.KEYS.TYPE]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"GROUP_TYPE","GROUP_TYPE","group type")));if(E(e[s.GroupConstants.KEYS.TYPE]))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"GROUP_TYPE","GROUP_TYPE","group type")));if(e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PUBLIC&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PASSWORD&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PROTECTED&&e[s.GroupConstants.KEYS.TYPE].toLowerCase()!=d.CometChat.GROUP_TYPE.PRIVATE)return new a.CometChatException(s.GroupErrors.INVALID_GROUP_TYPE);if(e[s.GroupConstants.KEYS.TYPE].toLowerCase()==d.CometChat.GROUP_TYPE.PASSWORD){if(!e.hasOwnProperty(s.GroupConstants.KEYS.PASSWORD))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"PASSWORD","PASSWORD","password")));if(typeof e[s.GroupConstants.KEYS.PASSWORD]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"PASSWORD","PASSWORD","password")));if(E(e[s.GroupConstants.KEYS.PASSWORD]))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"PASSWORD","PASSWORD","password")))}},r.validateId=function(e){return typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"UID/GUID","UID/GUID","uid/guid"))):E(e)?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"UID/GUID","UID/GUID","uid/guid"))):void 0},r.validateHideMessagesFromBlockedUsers=function(e){if(typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.BOOLEAN)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_BOOLEAN),"HIDE_MESSAGES_FROM_BLOCKED_USERS","HIDE_MESSAGES_FROM_BLOCKED_USERS","hideMessagesFromBlockedUsers")))},r.validateArray=function(e){return typeof e!=s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.OBJECT?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_OBJECT),"LIST","LIST","list"))):Array.isArray(e)?void 0:new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_AN_ARRAY),"LIST","LIST","list")))},r.validateMsgId=function(e){return isNaN(e)?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_NUMBER),"MESSAGE_ID","MESSAGE_ID","Message Id"))):E(e)?new a.CometChatException(n.ERRORS.PARAMETER_MISSING):void 0},r.validateChatType=function(e){return typeof e!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"RECEIVER_TYPE","RECEIVER_TYPE","receiver type"))):E(e)?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"RECEIVER_TYPE","RECEIVER_TYPE","receiver type"))):e!=s.MessageConstatnts.RECEIVER_TYPE.GROUP&&e!=s.MessageConstatnts.RECEIVER_TYPE.USER?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"RECEIVER_TYPE","RECEIVER_TYPE","Receiver Type"))):void 0},r.validateMessage=function(e){var t=e;if(typeof t.getReceiverId()!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"RECEIVER_ID","RECEIVER_ID","Receiver Id")));if(E(t.getReceiverId()))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"RECEIVER_ID","RECEIVER_ID","Receiver Id")));if(typeof t.getReceiverType()!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"RECEIVER_TYPE","RECEIVER_TYPE","Receiver Type")));if(E(t.getReceiverType()))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"RECEIVER_TYPE","RECEIVER_TYPE","Receiver Type")));if(t.getReceiverType()!=s.MessageConstatnts.RECEIVER_TYPE.GROUP&&t.getReceiverType()!=s.MessageConstatnts.RECEIVER_TYPE.USER)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"RECEIVER_TYPE","RECEIVER_TYPE","Receiver Type")));if(e instanceof c.TextMessage&&E(e.getText()))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"MESSAGE_TEXT","MESSAGE_TEXT","Message Text")));if(e instanceof u.MediaMessage){var n=e;if(!(n.file instanceof Blob))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_BLOB),"MEDIA_OBJECT","MEDIA_OBJECT","Media Object")));if(typeof n.getData()!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.OBJECT)return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_OBJECT),"MEDIA_OBJECT","MEDIA_OBJECT","Media Object")));if(E(n.getData()))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"MEDIA_OBJECT","MEDIA_OBJECT","Media Object")));if("image"==n.getType()){if(!r.isImage(n.file))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_MEDIA_FILE),"IMAGE_FILE","IMAGE_FILE")))}else if("video"==n.getType()){if(!r.isVideo(n.file))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_MEDIA_FILE),"VIDEO_FILE","VIDEO_FILE")))}else if("audio"==n.getType()&&!r.isAudio(n.file))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID_MEDIA_FILE),"AUDIO_FILE","AUDIO_FILE")))}if(e instanceof l.CustomMessage&&E(e.getCustomData()))return new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"CUSTOM_DATA","CUSTOM_DATA","Custom Data")))},r.validateCreateUser=function(e){return e.hasOwnProperty(s.UserConstants.UID)?typeof e[s.UserConstants.UID]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"UID","UID","uid"))):E(e[s.UserConstants.UID])?new a.CometChatException({code:"Empty UID"}):e.hasOwnProperty(s.UserConstants.NAME)?typeof e[s.UserConstants.NAME]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"USER_NAME","USER_NAME","user name"))):E(e[s.UserConstants.NAME])?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.INVALID),"USER_NAME","USER_NAME","user name"))):void 0:new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"USER_NAME","USER_NAME","user name"))):new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"UID","UID","uid")))},r.validateUpdateUser=function(e){return e.hasOwnProperty(s.UserConstants.UID)?typeof e[s.UserConstants.UID]!==s.COMMON_UTILITY_CONSTANTS.TYPE_CONSTANTS.STRING?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.MUST_BE_A_STRING),"UID","UID","uid"))):E(e[s.UserConstants.UID])?new a.CometChatException({code:"Empty UID"}):e.hasOwnProperty(s.UserConstants.NAME)&&""===e[s.UserConstants.NAME]?new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.EMPTY_STRING),"USER_NAME","USER_NAME","user name"))):void 0:new a.CometChatException(JSON.parse(h(JSON.stringify(s.GENERAL_ERROR.COMPULSORY),"UID","UID","uid")))},r.SHA1=function(e){var t,n,r,o,s,i,a,c,u,l=new Array(80),d=1732584193,E=4023233417,h=2562383102,p=271733878,f=3285377520,g=(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n>6|192):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128)),t+=String.fromCharCode(63&r|128))}return t}(e)).length,_=new Array;for(n=0;n>>29),_.push(g<<3&4294967295),t=0;t<_.length;t+=16){for(n=0;n<16;n++)l[n]=_[t+n];for(n=16;n<=79;n++)l[n]=C(l[n-3]^l[n-8]^l[n-14]^l[n-16],1);for(o=d,s=E,i=h,a=p,c=f,n=0;n<=19;n++)u=C(o,5)+(s&i|~s&a)+c+l[n]+1518500249&4294967295,c=a,a=i,i=C(s,30),s=o,o=u;for(n=20;n<=39;n++)u=C(o,5)+(s^i^a)+c+l[n]+1859775393&4294967295,c=a,a=i,i=C(s,30),s=o,o=u;for(n=40;n<=59;n++)u=C(o,5)+(s&i|s&a|i&a)+c+l[n]+2400959708&4294967295,c=a,a=i,i=C(s,30),s=o,o=u;for(n=60;n<=79;n++)u=C(o,5)+(s^i^a)+c+l[n]+3395469782&4294967295,c=a,a=i,i=C(s,30),s=o,o=u;d=d+o&4294967295,E=E+s&4294967295,h=h+i&4294967295,p=p+a&4294967295,f=f+c&4294967295}return(S(d)+S(E)+S(h)+S(p)+S(f)).toLowerCase()}},function(e,t,n){"use strict";t.__esModule=!0;var r=function(e){null!==e.code&&void 0!==e.code&&""!==e.code&&(this.code=e.code),null!==e.name&&void 0!==e.name&&""!==e.name&&(this.name=e.name),null!==e.message&&void 0!==e.message&&""!==e.message&&(this.message=e.message),null!==e.details&&void 0!==e.details&&""!==e.details&&(this.details=e.details)};t.CometChatException=r},function(e,X,q){"use strict";(function(t){var h=this&&this.__assign||function(){return(h=Object.assign||function(e){for(var t,n=1,r=arguments.length;ni[0]&&t[1]","text/xml"),p.isNative=!0):f.Logger.info("This is node","we do not have anything"),p.typingTimer(),p.appId=e,p.messagesStore=n.MessagesStore.getInstance(),p.localStorage=d.LocalStorage.getInstance(),p.userStore=r.UserStore.getInstance(),p.keyStore=i.KeyStore.getInstance(),p.messageListnerMaping=D.MessageListnerMaping.getInstance()}catch(e){f.Logger.error("CometChat: constructor",e)}}return p.setAuthToken=function(e){try{p.authToken=e}catch(e){f.Logger.error("CometChat: setAuthToken",e)}},p.prototype.getAuthToken=function(){try{return p.authToken}catch(e){f.Logger.error("CometChat: getAuthToken",e)}},p.getAppId=function(){try{return p.appId}catch(e){f.Logger.error("CometChat: getAppId",e)}},p.prototype.getApiKey=function(){try{return p.apiKey}catch(e){f.Logger.error("CometChat: getApiKey",e)}},p.init=function(o,e){var s=this;return void 0===o&&(o=""),void 0===e&&(e={}),new Promise(function(n,r){try{"object"==typeof o&&(o.hasOwnProperty("appId")&&(o=o.appId),o.hasOwnProperty("appSettings")&&(e=o.appSettings)),f.isFalsy(e)?e=(new H.AppSettingsBuilder).setRegion(H.AppSettings.REGION_EU).build():e.getRegion()==H.AppSettings.REGION_PRIVATE&&(e.region=o),s.appSettings=e,f.isFalsy(o)?r(new g.CometChatException(y.INIT_ERROR.NO_APP_ID)):(s.initialzed=!0,d.LocalStorage.getInstance().get("appId").then(function(e){if(null==e||null==e)p.appId=o,d.LocalStorage.getInstance().set("appId",o),p.getInstance(o),n(!0);else{var t=e.toLocaleString();t===o?(p.appId=t,p.getInstance(t),n(!0),d.LocalStorage.getInstance().get("user").then(function(e){e?(p.user=new E.Me(e),p.setAuthToken(p.user.getAuthToken()),p.XMPPLogin(p.user,function(){n(!0)},function(){r("error in connecting to xmpp server")})):n(!0)})):s.clearCache().then(function(){p.apiKey=void 0,p.user=void 0,p.authToken=void 0,p.cometChat=void 0,a.XMPPConnectionHelper.getInstance().XMPPDisconnect(),p.appId=o,d.LocalStorage.getInstance().set("appId",o),p.getInstance(o),n(!0)})}}),i.KeyStore.getInstance().get("deviceId").then(function(e){if(null==e){var t=V(),n=(new Date).getTime(),r=o+"_"+t+"_"+n;i.KeyStore.getInstance().set("deviceId",r)}}))}catch(e){r(new g.CometChatException(e))}})},p.isInitialized=function(){try{return this.initialzed}catch(e){f.Logger.error("CometChat: isInitialized",e)}},p.getInstance=function(e){try{return this.cometChat||(this.cometChat=new p(e)),this.cometChat}catch(e){f.Logger.error("CometChat: getInstance",e)}},p.registerTokenForPushNotification=function(d,E){var h=this;return new Promise(function(u,l){try{p.keyStore.get("deviceId").then(function(e){var t="",n=e,r=A.APPINFO.platform,o=A.APPINFO.sdkVersion,s=A.APPINFO.apiVersion;if(navigator&&(t=navigator.userAgent),null==n){var i=V(),a=(new Date).getTime();n=h.appId+"_"+i+"_"+a,p.keyStore.set("deviceId",n)}var c={platform:r,userAgent:t,deviceId:n,appInfo:{version:o,apiVersion:s,pushNotification:{fcmDeviceToken:d,settings:E}}};_.makeApiCall("updateMyDetails",{},c,!1).then(function(e){u("Token Registration successful")},function(e){l(new g.CometChatException(e.error))}).catch(function(e){l(new g.CometChatException(e))})})}catch(e){l(new g.CometChatException(e))}})},p.login=function(){for(var s=this,i=[],e=0;e=1e3*A.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT||null==b.TypingNotificationController.getTypingStartedMap(t))&&f.getAppSettings().then(function(e){switch(n){case A.XMPP.CONVERSATION.TYPE.CHAT:j.sendTypingStarted(f.format(A.XMPP.bare_jid_string,p.getAppId(),t,e[A.APP_SETTINGS.KEYS.CHAT_HOST]),n,r);break;case A.XMPP.CONVERSATION.TYPE.GROUP_CHAT:j.sendTypingStarted(f.format(A.XMPP.muc_jid_string,p.getAppId(),t,e[A.APP_SETTINGS.KEYS.GROUP_SERVICE],e[A.APP_SETTINGS.KEYS.CHAT_HOST]),n,r)}b.TypingNotificationController.addTypingStarted(t)},function(e){})}catch(e){f.Logger.error("CometChat: startTyping",e)}},p.endTyping=function(e){try{if(!f.isFalsy(e)){var t,n=this.RECEIVER_TYPE.USER,r={};if(e instanceof w.TypingIndicator)t=e.getReceiverId(),n=e.getReceiverType(),r=e.getMetadata();else{if(!e.hasOwnProperty(A.TYPING_NOTIFICATION.RECEIVER_ID))return;t=e[A.TYPING_NOTIFICATION.RECEIVER_ID],e.hasOwnProperty(A.TYPING_NOTIFICATION.RECEIVER_TYPE)&&(n=e[A.TYPING_NOTIFICATION.RECEIVER_TYPE]),n=n==this.RECEIVER_TYPE.USER?A.XMPP.CONVERSATION.TYPE.CHAT:A.XMPP.CONVERSATION.TYPE.GROUP_CHAT,e.hasOwnProperty(A.TYPING_NOTIFICATION.META)&&(r=e[A.TYPING_NOTIFICATION.META])}if(f.isFalsy(t))return;n=n==this.RECEIVER_TYPE.USER?A.XMPP.CONVERSATION.TYPE.CHAT:A.XMPP.CONVERSATION.TYPE.GROUP_CHAT,b.TypingNotificationController.getTypingStartedMap(t)&&f.getCurrentTime()-b.TypingNotificationController.getTypingStartedMap(t)<1e3*A.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT&&(b.TypingNotificationController.getTypingEndedMap(t)&&f.getCurrentTime()-b.TypingNotificationController.getTypingEndedMap(t)>=1e3*A.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT||null==b.TypingNotificationController.getTypingEndedMap(t))&&f.getAppSettings().then(function(e){switch(n){case A.XMPP.CONVERSATION.TYPE.CHAT:j.sendTypingPaused(f.format(A.XMPP.bare_jid_string,p.getAppId(),t,e[A.APP_SETTINGS.KEYS.CHAT_HOST]),n,r);break;case A.XMPP.CONVERSATION.TYPE.GROUP_CHAT:j.sendTypingPaused(f.format(A.XMPP.muc_jid_string,p.getAppId(),t,e[A.APP_SETTINGS.KEYS.GROUP_SERVICE],e[A.APP_SETTINGS.KEYS.CHAT_HOST]),n,r)}b.TypingNotificationController.addTypingEnded(t)},function(e){})}}catch(e){f.Logger.error("CometChat: endTyping",e)}},p.markAsRead=function(e,t,n){try{a.XMPPConnectionHelper.getInstance().markAsRead(t,n,e)}catch(e){f.Logger.error("CometChat: markAsRead",e)}},p.markAsDelivered=function(e,t,n){try{a.XMPPConnectionHelper.getInstance().markAsDelivered(t,n,e)}catch(e){f.Logger.error("CometChat: markAsDelivered",e)}},p.getMessageDetails=function(e){return new Promise(function(t,n){try{f.isFalsy(e)?n(new g.CometChatException(y.ERRORS.PARAMETER_MISSING)):_.makeApiCall("getMessageDetails",{messageId:e}).then(function(e){t(T.MessageController.trasformJSONMessge(e.data))},function(e){f.Logger.error("CometChat:GetMessageDetails:",e),n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.getMessageReceipts=function(r){return new Promise(function(t,n){try{var e=f.validateMsgId(r);if(e instanceof g.CometChatException)return void n(e);f.isFalsy(r)?n(new g.CometChatException(y.ERRORS.PARAMETER_MISSING)):_.makeApiCall("getMessageDetails",{messageId:r}).then(function(e){T.MessageController.getReceiptsFromJSON(e.data).then(function(e){t(e)},function(e){n(new g.CometChatException(e))})},function(e){f.Logger.error("CometChat:GetMessageDetails:",e),n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.getUnreadMessageCount=function(n){void 0===n&&(n=!1);var o=0;return new Promise(function(r,t){try{var e=f.validateHideMessagesFromBlockedUsers(n);if(e instanceof g.CometChatException)return void t(e);n&&(o=1),_.makeApiCall("getMessages",{},{unread:1,count:1,hideMessagesFromBlockedUsers:o}).then(function(e){var t={},n={};e.data.map(function(e){e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_TYPE]==A.MessageConstatnts.RECEIVER_TYPE.GROUP?n[e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]:t[e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),r({users:t,groups:n})},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.getUnreadMessageCountForAllUsers=function(r){void 0===r&&(r=!1);var o=0;return new Promise(function(n,t){try{var e=f.validateHideMessagesFromBlockedUsers(r);if(e instanceof g.CometChatException)return void t(e);r&&(o=1),_.makeApiCall("getMessages",{},{hideMessagesFromBlockedUsers:o,receiverType:A.MessageConstatnts.RECEIVER_TYPE.USER,unread:1,count:1}).then(function(e){var t={};e.data.map(function(e){t[e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),n(h({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.getUnreadMessageCountForAllGroups=function(r){void 0===r&&(r=!1);var o=0;return new Promise(function(n,t){try{var e=f.validateHideMessagesFromBlockedUsers(r);if(e instanceof g.CometChatException)return void t(e);r&&(o=1),_.makeApiCall("getMessages",{},{hideMessagesFromBlockedUsers:o,receiverType:A.MessageConstatnts.RECEIVER_TYPE.GROUP,unread:1,count:1}).then(function(e){var t={};e.data.map(function(e){e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_TYPE]==A.MessageConstatnts.RECEIVER_TYPE.GROUP&&(t[e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT])}),n(h({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.getUnreadMessageCountForUser=function(o,s){void 0===s&&(s=!1);var i=0;return new Promise(function(n,t){try{var e=f.validateId(o);if(e instanceof g.CometChatException)return void t(e);var r=f.validateHideMessagesFromBlockedUsers(s);if(r instanceof g.CometChatException)return void t(r);s&&(i=1),_.makeApiCall("getUserMessages",{listId:o},{hideMessagesFromBlockedUsers:i,unread:1,count:1,uid:o}).then(function(e){var t={};e.data.map(function(e){t[e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),n(h({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.getUnreadMessageCountForGroup=function(o,s){void 0===s&&(s=!1);var i=0;return new Promise(function(n,t){try{var e=f.validateId(o);if(e instanceof g.CometChatException)return void t(e);var r=f.validateHideMessagesFromBlockedUsers(s);if(r instanceof g.CometChatException)return void t(r);s&&(i=1),_.makeApiCall("getGroupMessages",{listId:o},{hideMessagesFromBlockedUsers:i,unread:1,count:1,guid:o}).then(function(e){var t={};e.data.map(function(e){e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_TYPE]==A.MessageConstatnts.RECEIVER_TYPE.GROUP&&(t[e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT])}),n(h({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.getUndeliveredMessageCount=function(n){void 0===n&&(n=!1);var o=0;return new Promise(function(r,t){try{var e=f.validateHideMessagesFromBlockedUsers(n);if(e instanceof g.CometChatException)return void t(e);n&&(o=1),_.makeApiCall("getMessages",{},{hideMessagesFromBlockedUsers:o,undelivered:1,count:1}).then(function(e){var t={},n={};e.data.map(function(e){e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_TYPE]==A.MessageConstatnts.RECEIVER_TYPE.GROUP?n[e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]:t[e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),r({users:t,groups:n})},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.getUndeliveredMessageCountForAllUsers=function(r){void 0===r&&(r=!1);var o=0;return new Promise(function(n,t){try{var e=f.validateHideMessagesFromBlockedUsers(r);if(e instanceof g.CometChatException)return void t(e);r&&(o=1),_.makeApiCall("getMessages",{},{hideMessagesFromBlockedUsers:o,unread:1,count:1}).then(function(e){var t={};e.data.map(function(e){t[e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),n(h({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.getUndeliveredMessageCountForAllGroups=function(r){void 0===r&&(r=!1);var o=0;return new Promise(function(n,t){try{var e=f.validateHideMessagesFromBlockedUsers(r);if(e instanceof g.CometChatException)return void t(e);r&&(o=1),_.makeApiCall("getMessages",{},{hideMessagesFromBlockedUsers:o,unread:1,count:1}).then(function(e){var t={};e.data.map(function(e){t[e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),n(h({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.getUndeliveredMessageCountForUser=function(o,s){void 0===s&&(s=!1);var i=0;return new Promise(function(n,t){try{var e=f.validateId(o);if(e instanceof g.CometChatException)return void t(e);var r=f.validateHideMessagesFromBlockedUsers(s);if(r instanceof g.CometChatException)return void t(r);s&&(i=1),_.makeApiCall("getUserMessages",{listId:o},{hideMessagesFromBlockedUsers:i,undelivered:1,count:1,uid:o}).then(function(e){var t={};e.data.map(function(e){t[e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),n(h({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.getUndeliveredMessageCountForGroup=function(o,s){void 0===s&&(s=!1);var i=0;return new Promise(function(n,t){try{var e=f.validateId(o);if(e instanceof g.CometChatException)return void t(e);var r=f.validateHideMessagesFromBlockedUsers(s);if(r instanceof g.CometChatException)return void t(r);s&&(i=1),_.makeApiCall("getGroupMessages",{listId:o},{hideMessagesFromBlockedUsers:i,undelivered:1,count:1,uid:o}).then(function(e){var t={};e.data.map(function(e){t[e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.ENTITY_Id]]=e[A.ResponseConstants.RESPONSE_KEYS.UNREAD_UNDELIVERED_KEYS.COUNT]}),n(h({},t))},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.editMessage=function(r){return new Promise(function(t,n){try{var e=f.validateMsgId(r.getId());if(e instanceof g.CometChatException)return void n(e);_.makeApiCall("updateMessage",{messageId:r.getId()},r).then(function(e){t(T.MessageController.trasformJSONMessge(e.data).getActionOn())},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.deleteMessage=function(r){return new Promise(function(t,n){try{var e=f.validateMsgId(r);if(e instanceof g.CometChatException)return void n(e);_.makeApiCall("deleteMessage",{messageId:r},{id:r}).then(function(e){t(T.MessageController.trasformJSONMessge(e.data).getActionOn())},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.getPreviousMessagesByTimestamp=function(e,r){return new Promise(function(t,n){try{f.isFalsy(r)?n(new g.CometChatException(JSON.parse(f.format(JSON.stringify(A.PARAMETER_ERROR.PARAMETER_REQUIRED),"TIMESTAMP","TIMESTAMP","timestamp")))):T.MessageController.getAllMessage(e,r,A.MessageConstatnts.PAGINATION.CURSOR_FILEDS.SENT_AT,A.MessageConstatnts.PAGINATION.AFFIX.PREPEND).then(function(e){return t(e)},function(e){return n(new g.CometChatException(e))})}catch(e){n(new g.CometChatException(e))}})},p.getPreviousMessagesById=function(e,r){return new Promise(function(t,n){try{f.isFalsy(r)?n(new g.CometChatException(JSON.parse(f.format(JSON.stringify(A.PARAMETER_ERROR.PARAMETER_REQUIRED),"ID","ID","id")))):T.MessageController.getAllMessage(e,r,A.MessageConstatnts.PAGINATION.CURSOR_FILEDS.ID,A.MessageConstatnts.PAGINATION.AFFIX.PREPEND).then(function(e){return t(e)},function(e){return n(new g.CometChatException(e))})}catch(e){n(new g.CometChatException(e))}})},p.getNextMessagesByTimestamp=function(e,r){return new Promise(function(t,n){try{f.isFalsy(r)?n(new g.CometChatException(JSON.parse(f.format(JSON.stringify(A.PARAMETER_ERROR.PARAMETER_REQUIRED),"TIMESTAMP","TIMESTAMP","timestamp")))):T.MessageController.getAllMessage(e,r,A.MessageConstatnts.PAGINATION.CURSOR_FILEDS.SENT_AT,A.MessageConstatnts.PAGINATION.AFFIX.APPEND).then(function(e){return t(e)},function(e){return n(new g.CometChatException(e))})}catch(e){n(new g.CometChatException(e))}})},p.getNextMessagesById=function(e,r){return new Promise(function(t,n){try{f.isFalsy(r)?n(new g.CometChatException(JSON.parse(f.format(JSON.stringify(A.PARAMETER_ERROR.PARAMETER_REQUIRED),"ID","ID","id")))):T.MessageController.getAllMessage(e,r,A.MessageConstatnts.PAGINATION.CURSOR_FILEDS.ID,A.MessageConstatnts.PAGINATION.AFFIX.APPEND).then(function(e){return t(e)},function(e){return n(new g.CometChatException(e))})}catch(e){n(new g.CometChatException(e))}})},p.createUser=function(o,s){return new Promise(function(n,t){try{if(f.isFalsy(s))return void t(new g.CometChatException(JSON.parse(f.format(JSON.stringify(A.GENERAL_ERROR.INVALID),"API_KEY","API_KEY","API_KEY"))));p.apiKey=s;var e=f.validateCreateUser(o);if(e instanceof g.CometChatException)return void t(e);if(!(o instanceof E.User)){var r=void 0;if(!o.hasOwnProperty(A.UserConstants.UID))return void t(new g.CometChatException(y.ERRORS.PARAMETER_MISSING));if(!o.hasOwnProperty(A.UserConstants.NAME))return void t(new g.CometChatException(y.ERRORS.PARAMETER_MISSING));r=new E.User(o[A.UserConstants.UID],o[A.UserConstants.NAME]),o.hasOwnProperty(A.UserConstants.AVATAR)&&r.setAvatar(o[A.UserConstants.AVATAR]),o.hasOwnProperty(A.UserConstants.ROLE)&&r.setRole(o[A.UserConstants.ROLE]),o.hasOwnProperty(A.UserConstants.META_DATA)&&r.setMetadata(o[A.UserConstants.META_DATA]),o.hasOwnProperty(A.UserConstants.LINK)&&r.setLink(o[A.UserConstants.LINK]),o.hasOwnProperty(A.UserConstants.CREDITS)&&r.setCredits(o[A.UserConstants.CREDITS]),o.hasOwnProperty(A.UserConstants.STATUS_MESSAGE)&&r.setStatusMessage(o[A.UserConstants.STATUS_MESSAGE]),o=r}_.makeApiCall("createUser",{},o).then(function(e){var t=m.UsersController.trasformJSONUser(e.data);n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.updateUser=function(s,i){return new Promise(function(n,t){try{if(f.isFalsy(i))return void t(new g.CometChatException(JSON.parse(f.format(JSON.stringify(A.GENERAL_ERROR.INVALID),"API_KEY","API_KEY","API_KEY"))));p.apiKey=i;var e=f.validateUpdateUser(s);if(e instanceof g.CometChatException)return void t(e);if(!(s instanceof E.User)){var r=void 0;if(!s.hasOwnProperty(A.UserConstants.UID))return void t(new g.CometChatException(y.ERRORS.PARAMETER_MISSING));r=new E.User(s[A.UserConstants.UID]),s.hasOwnProperty(A.UserConstants.NAME)&&r.setName(s[A.UserConstants.NAME]),s.hasOwnProperty(A.UserConstants.AVATAR)&&r.setAvatar(s[A.UserConstants.AVATAR]),s.hasOwnProperty(A.UserConstants.ROLE)&&r.setRole(s[A.UserConstants.ROLE]),s.hasOwnProperty(A.UserConstants.META_DATA)&&r.setMetadata(s[A.UserConstants.META_DATA]),s.hasOwnProperty(A.UserConstants.LINK)&&r.setLink(s[A.UserConstants.LINK]),s.hasOwnProperty(A.UserConstants.CREDITS)&&r.setCredits(s[A.UserConstants.CREDITS]),s.hasOwnProperty(A.UserConstants.STATUS_MESSAGE)&&r.setStatusMessage(s[A.UserConstants.STATUS_MESSAGE]),s=r}var o=s.uid;_.makeApiCall("updateUser",{uid:o},s).then(function(e){var t=m.UsersController.trasformJSONUser(e.data);n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.getUser=function(r){return new Promise(function(n,t){try{"object"==typeof r&&r.hasOwnProperty("uid")&&(r=r.uid);var e=f.validateId(r);if(e instanceof g.CometChatException)return void t(e);_.makeApiCall("user",{uid:r}).then(function(e){var t=m.UsersController.trasformJSONUser(e.data);n(t)}).catch(function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.getLoggedInUser=function(){var d=this;return new Promise(function(u,l){try{p.localStorage.get("user").then(function(e){if(e)u(p.user=new E.Me(e));else{var o="",s="",i=A.APPINFO.platform,a=A.APPINFO.sdkVersion,c=A.APPINFO.apiVersion;p.keyStore.get("deviceId").then(function(e){if(s=e,navigator&&(o=navigator.userAgent),null==s){var t=V(),n=(new Date).getTime();s=d.appId+"_"+t+"_"+n,p.keyStore.set("deviceId",s)}var r={platform:i,userAgent:o,deviceId:s,appInfo:{version:a,apiVersion:c}};_.makeApiCall("updateMyDetails",{},r,!1).then(function(e){u(new E.Me(e.data))},function(e){l(new g.CometChatException(e.error))}).catch(function(e){l(new g.CometChatException(e))})})}})}catch(e){l(new g.CometChatException(e))}})},p.getLoggedinUser=function(){return new Promise(function(t,n){try{p.localStorage.get("user").then(function(e){t(e?p.user=new E.Me(e):null)},function(e){t(null)})}catch(e){n(new g.CometChatException(e))}})},p.blockUsers=function(r){return new Promise(function(t,n){try{var e=f.validateArray(r);if(e instanceof g.CometChatException)return void n(e);f.isFalsy(r)?n(new g.CometChatException(y.USERS_REQUEST_ERRORS.EMPTY_USERS_LIST)):_.makeApiCall("blockUsers",{},{blockedUids:r}).then(function(e){t(e.data)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.unblockUsers=function(r){return new Promise(function(t,n){try{var e=f.validateArray(r);if(e instanceof g.CometChatException)return void n(e);f.isFalsy(r)?n(new g.CometChatException(y.USERS_REQUEST_ERRORS.EMPTY_USERS_LIST)):_.makeApiCall("unblockUsers",{},{blockedUids:r}).then(function(e){t(e.data)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.createGroup=function(o){return new Promise(function(t,n){try{var e=f.validateCreateGroup(o);if(e instanceof g.CometChatException)return void n(e);if(!(o instanceof I.Group)){var r=void 0;if(!o.hasOwnProperty(A.GroupConstants.KEYS.GUID))return void n(new g.CometChatException(y.ERRORS.PARAMETER_MISSING));if(!o.hasOwnProperty(A.GroupConstants.KEYS.NAME))return void n(new g.CometChatException(y.ERRORS.PARAMETER_MISSING));if(r=new I.Group(o[A.GroupConstants.KEYS.GUID],o[A.GroupConstants.KEYS.NAME],""),o.hasOwnProperty(A.GroupConstants.KEYS.TYPE))if(o[A.GroupConstants.KEYS.TYPE].toLocaleLowerCase()==A.GroupType.Password){if(!o.hasOwnProperty(A.GroupConstants.KEYS.PASSWORD))return void n(new g.CometChatException(y.GROUP_CREATION_ERRORS.EMPTY_PASSWORD));r.setType(A.GROUP_TYPE.PASSWORD),r.setPassword(o[A.GroupConstants.KEYS.PASSWORD])}else r.setType(o[A.GroupConstants.KEYS.TYPE]);else r.setType(A.GROUP_TYPE.PUBLIC);o.hasOwnProperty(A.GroupConstants.KEYS.ICON)&&r.setIcon(o[A.GroupConstants.KEYS.ICON]),o.hasOwnProperty(A.GroupConstants.KEYS.DESCRIPTION)&&r.setDescription(o[A.GroupConstants.KEYS.DESCRIPTION]),o=r}_.makeApiCall("createGroup",{},o).then(function(e){j.joinMuc(o),N.GroupsController.trasformJSONGroup(e.data).setHasJoined(!0),t(N.GroupsController.trasformJSONGroup(e.data))},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.getGroup=function(r){return new Promise(function(t,n){try{"object"==typeof r&&r.hasOwnProperty("guid")&&(r=r.guid);var e=f.validateId(r);if(e instanceof g.CometChatException)return void n(e);_.makeApiCall("getGroup",{guid:r}).then(function(e){t(N.GroupsController.trasformJSONGroup(e.data))},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.getJoinedGroups=function(){return new Promise(function(t,n){try{j.getRooms().then(function(e){t(e)},function(e){n(e)})}catch(e){n(new g.CometChatException(e))}})},p.joinGroup=function(o,s,i){return void 0===s&&(s=A.GroupType.Public),void 0===i&&(i=""),new Promise(function(n,t){try{var r,e=f.validateJoinGroup(o,s,i);if(e instanceof g.CometChatException)return void t(e);"object"==typeof o&&(o.hasOwnProperty(A.GroupConstants.KEYS.GUID)?(o.hasOwnProperty(A.GroupConstants.KEYS.TYPE)&&(s=o[A.GroupConstants.KEYS.TYPE],o[A.GroupConstants.KEYS.TYPE].toLocaleLowerCase()===A.GroupType.Password&&o.hasOwnProperty(A.GroupConstants.KEYS.PASSWORD)&&(i=o[A.GroupConstants.KEYS.PASSWORD])),o=o[A.GroupConstants.KEYS.GUID]):t(new g.CometChatException(y.ERRORS.PARAMETER_MISSING))),r=f.isFalsy(i)?new I.Group(o,"name",s):new I.Group(o,"name",s,i),_.makeApiCall("joinGroup",r,r).then(function(e){j.joinMuc(r);var t=N.GroupsController.trasformJSONGroup(e.data[A.ResponseConstants.RESPONSE_KEYS.KEY_DATA][A.ActionConstatnts.ACTION_KEYS.ENTITIES][A.ActionConstatnts.ACTION_SUBJECTS.ACTION_FOR][A.ActionConstatnts.ACTION_KEYS.ENTITY]);t.setHasJoined(!0),n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.updateGroup=function(o){return new Promise(function(t,n){try{var e=f.validateUpdateGroup(o);if(e instanceof g.CometChatException)return void n(e);if(!(o instanceof I.Group)){var r=void 0;if(!o.hasOwnProperty(A.GroupConstants.KEYS.GUID))return void n(new g.CometChatException(y.ERRORS.PARAMETER_MISSING));r=new I.Group(A.GroupConstants.KEYS.GUID,"",""),o.hasOwnProperty(A.GroupConstants.KEYS.TYPE)?r.setType(o[A.GroupConstants.KEYS.TYPE]):(o[A.GroupConstants.KEYS.TYPE]=A.GROUP_TYPE.PUBLIC,r.setType[A.GROUP_TYPE.PUBLIC]),o.hasOwnProperty(A.GroupConstants.KEYS.NAME)&&r.setName(o[A.GroupConstants.KEYS.NAME]),o.hasOwnProperty(A.GroupConstants.KEYS.ICON)&&r.setIcon(o[A.GroupConstants.KEYS.ICON]),o.hasOwnProperty(A.GroupConstants.KEYS.DESCRIPTION)&&r.setDescription(o[A.GroupConstants.KEYS.DESCRIPTION]),o=r}_.makeApiCall("updateGroup",o,o).then(function(e){t(N.GroupsController.trasformJSONGroup(e.data))},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.deleteGroup=function(r){return new Promise(function(t,n){try{var e=f.validateId(r);if(e instanceof g.CometChatException)return void n(e);_.makeApiCall("deleteGroup",{guid:r}).then(function(e){t(!0)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.leaveGroup=function(r){return new Promise(function(t,n){try{var e=f.validateId(r);if(e instanceof g.CometChatException)return void n(e);_.makeApiCall("leaveGroup",{guid:r}).then(function(e){j.leaveMuc(r),t(!0)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.kickGroupMember=function(o,s){return new Promise(function(t,n){try{var e=f.validateId(o);if(e instanceof g.CometChatException)return void n(e);var r=f.validateId(s);if(r instanceof g.CometChatException)return void n(r);_.makeApiCall("kickGroupMembers",{guid:o,uid:s}).then(function(e){t(!0)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.updateGroupMemberScope=function(s,i,a){return new Promise(function(t,n){try{var e=f.validateId(s);if(e instanceof g.CometChatException)return void n(e);var r=f.validateId(i);if(r instanceof g.CometChatException)return void n(r);var o=f.validateScope(a);if(o instanceof g.CometChatException)return void n(o);_.makeApiCall("changeScopeOfMember",{guid:s,uid:i},{scope:a}).then(function(e){t(!0)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.banGroupMember=function(o,s){return new Promise(function(t,n){try{var e=f.validateId(o);if(e instanceof g.CometChatException)return void n(e);var r=f.validateId(s);if(r instanceof g.CometChatException)return void n(r);_.makeApiCall("banGroupMember",{guid:o,uid:s}).then(function(e){t(!0)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.unbanGroupMember=function(o,s){return new Promise(function(t,n){try{var e=f.validateId(o);if(e instanceof g.CometChatException)return void n(e);var r=f.validateId(s);if(r instanceof g.CometChatException)return void n(r);_.makeApiCall("unbanGroupMember",{guid:o,uid:s}).then(function(e){t(!0)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.addMembersToGroup=function(i,a,c){var u=[],l=[],d=[],E=[];return new Promise(function(e,t){try{var n=f.validateId(i);if(n instanceof g.CometChatException)return void t(n);var r=f.validateArray(a);if(r instanceof g.CometChatException)return void t(r);var o=f.validateArray(c);if(o instanceof g.CometChatException)return void t(o);f.isFalsy(a)&&f.isFalsy(c)?t(new g.CometChatException({})):f.isFalsy(a)||f.isFalsy(c)?f.isFalsy(a)?c.map(function(e){E.push(e)}):(a.filter(function(e){if(e.getScope()==A.GROUP_MEMBER_SCOPE.ADMIN)return!0}).map(function(e){u.push(e.getUid())}),a.filter(function(e){if(e.getScope()==A.GROUP_MEMBER_SCOPE.MODERATOR)return!0}).map(function(e){l.push(e.getUid())}),a.filter(function(e){if(e.getScope()==A.GROUP_MEMBER_SCOPE.PARTICIPANT)return!0}).map(function(e){d.push(e.getUid())})):(a.filter(function(e){if(e.getScope()==A.GROUP_MEMBER_SCOPE.ADMIN)return!0}).map(function(e){u.push(e.getUid())}),a.filter(function(e){if(e.getScope()==A.GROUP_MEMBER_SCOPE.MODERATOR)return!0}).map(function(e){l.push(e.getUid())}),a.filter(function(e){if(e.getScope()==A.GROUP_MEMBER_SCOPE.PARTICIPANT)return!0}).map(function(e){d.push(e.getUid())}),c.map(function(e){E.push(e)}));var s={};f.isFalsy(u)||(s=h({},s,{admins:u})),f.isFalsy(d)||(s=h({},s,{participants:d})),f.isFalsy(l)||(s=h({},s,{moderators:l})),f.isFalsy(E)||(s=h({},s,{usersToBan:E})),_.makeApiCall("addMemebersToGroup",{guid:i},s).then(function(t){var n={};Object.keys(t.data.admins).map(function(e){t.data.admins[e][A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS]?n[e]=A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS:n[e]=t.data.admins[e][A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.ERROR][A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.MESSAGE]}),Object.keys(t.data.participants).map(function(e){t.data.participants[e][A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS]?n[e]=A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS:n[e]=t.data.participants[e][A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.ERROR][A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.MESSAGE]}),Object.keys(t.data.moderators).map(function(e){t.data.moderators[e][A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS]?n[e]=A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS:n[e]=t.data.moderators[e][A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.ERROR][A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.MESSAGE]}),Object.keys(t.data.usersToBan).map(function(e){t.data.usersToBan[e][A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS]?n[e]=A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.SUCCESS:n[e]=t.data.usersToBan[e][A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.ERROR][A.ResponseConstants.RESPONSE_KEYS.GROUP_MEMBERS_RESPONSE.MESSAGE]}),e(n)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.initiateCall=function(t){return new Promise(function(n,r){try{f.isFalsy(JSON.parse(JSON.stringify(t)).sender)?f.isFalsy(R.CallController.getInstance().getActiveCall())?(t.setStatus(A.CallConstants.CALL_STATUS.INITIATED),t.receiver=t.receiverId.toString(),delete t.receiverId,_.makeApiCall("createCallSession",{},t).then(function(e){var t=T.MessageController.trasformJSONMessge(e[A.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);R.CallController.getInstance().initiateCall(t).then(function(e){n(t)}).catch(function(e){r(new g.CometChatException(e))})},function(e){r(new g.CometChatException(e.error))})):r(new g.CometChatException(A.CALL_ERROR.ERROR_IN_CALLING)):R.CallController.getInstance().initiateCall(t).then(function(e){n(Object.assign(t))}).catch(function(e){r(new g.CometChatException(e))})}catch(e){r(new g.CometChatException(e))}})},p.acceptCall=function(r){return new Promise(function(n,t){try{var e={};e[A.CallConstants.CALL_KEYS.CALL_STATUS]=A.CallConstants.CALL_STATUS.ONGOING,_.makeApiCall("updateCallSession",{sessionid:r},e).then(function(e){var t=T.MessageController.trasformJSONMessge(e[A.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);R.CallController.getInstance().onCallStarted(t),n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.rejectCall=function(e,t){try{switch(t){case A.CallConstants.CALL_STATUS.REJECTED:return this.rejectIncomingCall(e);case A.CallConstants.CALL_STATUS.CANCELLED:return this.cancelCall(e);case A.CallConstants.CALL_STATUS.BUSY:return this.sendBusyResponse(e);default:return this.endCall(e)}}catch(e){f.Logger.error("CometChat: rejectCall",e)}},p.endCall=function(r){return new Promise(function(n,t){try{var e={};e[A.CallConstants.CALL_KEYS.CALL_STATUS]=A.CallConstants.CALL_STATUS.ENDED,R.CallController.getInstance().getActiveCall().getJoinedAt()&&(e[A.CallConstants.CALL_KEYS.CALL_JOINED_AT]=R.CallController.getInstance().getActiveCall().getJoinedAt()),_.makeApiCall("updateCallSession",{sessionid:r},e).then(function(e){var t=T.MessageController.trasformJSONMessge(e[A.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);n(t)},function(e){f.Logger.log("calling Log",{error:e});var t=R.CallController.getInstance().getActiveCall();t.setStatus(A.CallConstants.CALL_STATUS.ENDED),n(t),R.CallController.getInstance().endCall()})}catch(e){t(new g.CometChatException(e))}})},p.getActiveCall=function(){try{return R.CallController.getInstance().getActiveCall()}catch(e){f.Logger.error("CometChat: getActiveCall",e)}},p.startCall=function(e,t,n,r){try{R.CallController.getInstance().startCall(t,n,r)}catch(e){f.Logger.error("CometChat: startCall",e)}},p.toggleAudio=function(){try{R.CallController.toggleAudio()}catch(e){f.Logger.error("CometChat: toggleAudio",e)}},p.toggleVideo=function(){try{R.CallController.toggleVideo()}catch(e){f.Logger.error("CometChat: toggleVideo",e)}},p.leaveCall=function(){try{R.CallController.leave()}catch(e){f.Logger.error("CometChat: leaveCall",e)}},p.createCallView=function(e){try{return{prop1:this.makeCall,onMessage:function(e){R.CallController.getInstance().getCallListner()._eventListener.onCallEnded(R.CallController.getInstance().getActiveCall()),p.endCall(R.CallController.getInstance().getActiveCall().getSessionId()).then(function(e){f.Logger.info("CometChat: createCallView",e)}).catch(function(e){f.Logger.error("CometChat: createCallView",e)})}}}catch(e){f.Logger.error("CometChat: createCallView",e)}},p.makeCall=function(e,t){try{e.setState(function(e){return h({},e,{uri:t})})}catch(e){f.Logger.error("CometChat: makeCall",e)}},p.rejectIncomingCall=function(r){return new Promise(function(n,t){try{var e={};e[A.CallConstants.CALL_KEYS.CALL_STATUS]=A.CallConstants.CALL_STATUS.REJECTED,_.makeApiCall("updateCallSession",{sessionid:r},e).then(function(e){var t=T.MessageController.trasformJSONMessge(e[A.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.cancelCall=function(r){return new Promise(function(n,t){try{var e={};e[A.CallConstants.CALL_KEYS.CALL_STATUS]=A.CallConstants.CALL_STATUS.CANCELLED,_.makeApiCall("updateCallSession",{sessionid:r},e).then(function(e){var t=T.MessageController.trasformJSONMessge(e[A.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);R.CallController.getInstance().endCallSession(),n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.sendBusyResponse=function(r){return new Promise(function(n,t){try{var e={};e[A.CallConstants.CALL_KEYS.CALL_STATUS]=A.CallConstants.CALL_STATUS.BUSY,_.makeApiCall("updateCallSession",{sessionid:r},e).then(function(e){var t=T.MessageController.trasformJSONMessge(e[A.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.sendUnansweredResponse=function(r){return new Promise(function(n,t){try{var e={};e[A.CallConstants.CALL_KEYS.CALL_STATUS]=A.CallConstants.CALL_STATUS.UNANSWERED,_.makeApiCall("updateCallSession",{sessionid:r},e).then(function(e){var t=T.MessageController.trasformJSONMessge(e[A.ResponseConstants.RESPONSE_KEYS.KEY_DATA]);a.XMPPConnectionHelper.getInstance().trigerMessageHandler(Object.assign(t,e[A.ResponseConstants.RESPONSE_KEYS.KEY_DATA])),n(t)},function(e){t(new g.CometChatException(e.error))})}catch(e){t(new g.CometChatException(e))}})},p.addMessageListener=function(e,t){try{j.addMessageEventListener(e,t)}catch(e){f.Logger.error("CometChat: addMessageListener",e)}},p.removeMessageListener=function(e){try{j.removeMessageEventListener(e)}catch(e){f.Logger.error("CometChat: removeMessageListener",e)}},p.addCallListener=function(e,t){try{j.addCallEventListener(e,t)}catch(e){f.Logger.error("CometChat: addCallListener",e)}},p.removeCallListener=function(e){try{j.removeCallEventListener(e)}catch(e){f.Logger.error("CometChat: removeCallListener",e)}},p.addUserListener=function(e,t){try{j.addUserEventListener(e,t)}catch(e){f.Logger.error("CometChat: addUserListener",e)}},p.removeUserListener=function(e){try{j.removeUserEventListener(e)}catch(e){f.Logger.error("CometChat: removeUserListener",e)}},p.addGroupListener=function(e,t){try{j.addGroupEventListener(e,t)}catch(e){f.Logger.error("CometChat: addGroupListener",e)}},p.removeGroupListener=function(e){try{j.removeGroupEventListener(e)}catch(e){f.Logger.error("CometChat: removeGroupListener",e)}},p.generateAuthToken=function(d){var E=this;return new Promise(function(r,o){try{var s={},i="",a="",c=A.APPINFO.platform,u=A.APPINFO.sdkVersion,l=A.APPINFO.apiVersion;navigator&&(a=navigator.userAgent),p.keyStore.get("deviceId").then(function(e){if(null==(i=e)){var t=V(),n=(new Date).getTime();i=E.appId+"_"+t+"_"+n,p.keyStore.set("deviceId",i)}s={platform:c,userAgent:a,deviceId:i,appInfo:{version:u,apiVersion:l}},_.makeApiCall("authToken",{uid:d},s).then(function(e){r(e.data)}).catch(function(e){o(new g.CometChatException(e.error))})},function(e){f.Logger.error("Got error while fetching data from key store",e)})}catch(e){o(new g.CometChatException(e))}})},p.XMPPLogin=function(t,n,r){var o=this;try{var s=!1;this.timeOut+this.timeIncrements<3e4&&(this.timeOut=this.timeOut+this.timeIncrements,this.timeIncrements=this.timeIncrements+2e3);var i=!0;j.XMMPLogin(t.getUid(),t.getWsChannel().secret,this.fallback,function(e){switch(e){case c.Strophe.Status.CONNFAIL:f.Logger.info("CometChat: XMPPLogin","In connection fail state"),s=!0,i&&setTimeout(function(){o.fallback=!o.fallback,o.XMPPLogin(t,n,r)},o.timeOut);break;case c.Strophe.Status.CONNECTING:break;case c.Strophe.Status.CONNECTED:o.timeOut=0,o.timeIncrements=1e3,s=!1,o.localStorage.set("user",t),n(new E.User(t));break;case c.Strophe.Status.DISCONNECTED:i&&!s&&setTimeout(function(){o.fallback=!o.fallback,o.XMPPLogin(t,n,r)},o.timeOut);break;case c.Strophe.Status.DISCONNECTING:i=!1;break;case c.Strophe.Status.AUTHFAIL:o.timeOut=0,o.timeIncrements=1e3,s=!1,r(new g.CometChatException(y.LOGIN_ERROR.XMPP_AUTH_FAIL))}})}catch(e){return void r(new g.CometChatException(e))}},p.getAppSettings=function(){return new Promise(function(t,n){try{_.makeApiCall("appSettings").then(function(e){d.LocalStorage.getInstance().set("app_settings",e.data),t(e.data)},function(e){n(new g.CometChatException(e.error))})}catch(e){n(new g.CometChatException(e))}})},p.logout=function(){var r=this;return new Promise(function(t,n){try{_.makeApiCall("userLogout").then(function(e){r.clearCache().then(function(){p.apiKey=void 0,p.user=void 0,p.authToken=void 0,p.cometChat=void 0,a.XMPPConnectionHelper.getInstance().XMPPDisconnect(),t(e.data)})},function(e){r.clearCache().then(function(){p.apiKey=void 0,p.user=void 0,p.authToken=void 0,p.cometChat=void 0,a.XMPPConnectionHelper.getInstance().XMPPDisconnect(),new g.CometChatException(e.error).code==y.SERVER_ERRORS.AUTH_ERR.code?t({}):n(new g.CometChatException(e.error))})})}catch(e){n(new g.CometChatException(e))}})},p.isExtensionEnabled=function(r){return new Promise(function(t,n){try{F.ExtensionController.getExtensionList().then(function(e){Object.keys(e).map(function(e){e==r&&t(!0)}),t(!1)},function(e){f.Logger.log("error while fetching exntension list",e),t(!1)})}catch(e){n(new g.CometChatException(e))}})},p.clearCache=function(){return new Promise(function(e,t){try{d.LocalStorage.getInstance().clearStore().then(function(){r.UserStore.getInstance().clearStore().then(function(){n.MessagesStore.getInstance().clearStore().then(function(){f.Logger.info("CometChat: clearCache => All store cleared successfully","true"),e(!0)})})})}catch(e){f.Logger.error("CometChat: clearCache",e),t(e)}})},p.typingTimer=function(){try{setInterval(function(){b.TypingNotificationController.clearTimer()},500)}catch(e){f.Logger.error("CometChat: typingTimer",e)}},p.initialzed=!1,p.isNative=!1,p.CometChatException=g.CometChatException,p.TextMessage=S.TextMessage,p.MediaMessage=C.MediaMessage,p.CustomMessage=Y.CustomMessage,p.Action=O.Action,p.Call=s.Call,p.TypingIndicator=w.TypingIndicator,p.Group=I.Group,p.AppUser=E.User,p.User=E.User,p.GroupMember=x.GroupMember,p.Conversation=J.Conversation,p.USER_STATUS={ONLINE:A.PresenceConstatnts.STATUS.ONLINE,OFFLINE:A.PresenceConstatnts.STATUS.OFFLINE},p.MessagesRequest=U.DefaultMessagesRequest,p.MessagesRequestBuilder=U.DefaultMessagesRequestBuilder,p.UsersRequest=P.UsersRequest,p.UsersRequestBuilder=P.UsersRequestBuilder,p.ConversationsRequest=L.ConversationsRequest,p.ConversationsRequestBuilder=L.ConversationsRequestBuilder,p.BlockedUsersRequest=K.BlockedUsersRequest,p.BlockedUsersRequestBuilder=K.BlockedUsersRequestBuilder,p.GroupsRequest=v.GroupsRequest,p.GroupsRequestBuilder=v.GroupsRequestBuilder,p.GroupMembersRequest=M.GroupMembersRequest,p.GroupMembersRequestBuilder=M.GroupMembersRequestBuilder,p.BannedMembersRequest=M.GroupMembersRequest,p.BannedMembersRequestBuilder=M.GroupOutCastMembersRequestBuilder,p.AppSettings=H.AppSettings,p.AppSettingsBuilder=H.AppSettingsBuilder,p.MessageListener=o.MessageEventListener,p.UserListener=o.UserEventListener,p.GroupListener=o.GroupEventListener,p.OngoingCallListener=o.UserCallEventListener,p.CallListener=o.CallEventListener,p.MESSAGE_TYPE=A.MessageConstatnts.TYPE,p.CATEGORY_MESSAGE=A.MessageConstatnts.CATEGORY.MESSAGE,p.CATEGORY_ACTION=A.MessageConstatnts.CATEGORY.ACTION,p.CATEGORY_CALL=A.MessageConstatnts.CATEGORY.CALL,p.ACTION_TYPE=A.ActionConstatnts.ACTIONS,p.CALL_TYPE=A.CallConstants.CALL_TYPE,p.RECEIVER_TYPE=A.MessageConstatnts.RECEIVER_TYPE,p.CALL_STATUS=A.CallConstants.CALL_STATUS,p.CallController=R.CallController,p.GROUP_MEMBER_SCOPE=A.GROUP_MEMBER_SCOPE,p.GROUP_TYPE=A.GROUP_TYPE,p.MESSAGE_REQUEST=A.MessageConstatnts.PAGINATION.CURSOR_FILEDS,p.CometChatExtension=G.CometChatExtension,p.ExtensionManager=B.ExtensionManager,p.isCall=!1,p.endpointFactory=new e.EndpointFactory,p.startTypingCount=0,p.endTypingCount=0,p.CometChatHelper=k.CometChatHelper,p.fallback=!1,p.timeOut=0,p.timeIncrements=1e3,p}();X.CometChat=p}).call(this,q(26))},function(e,t,n){"use strict";t.__esModule=!0;var c=n(40),u=n(3),i=n(1),l=n(2);function d(t,e,n,r,o){var s;return void 0===t&&(t=""),void 0===e&&(e="GET"),void 0===n&&(n={}),void 0===r&&(r={}),n=i.isFalsy(n)?void 0:("GET"==e&&(t+="?",Object.keys(n).map(function(e){t=t+e+"="+n[e]+"&"}),n=void 0),o&&(s=new FormData,Object.keys(n).map(function(e){"data"!=e?"metadata"!=e&&s.append(e,n[e]):s.append(e,JSON.stringify(n[e]))})),JSON.stringify(n)),fetch(t,{method:e,mode:"cors",cache:"no-cache",headers:r,redirect:"follow",referrer:"no-referrer",body:o?s:n})}t.makeApiCall=function(o,e,s,i){void 0===o&&(o=""),void 0===e&&(e={}),void 0===s&&(s={});var a=u.CometChat.getInstance();return new Promise(function(n,r){try{c.getEndPoint(o,e).then(function(e){var t={appId:u.CometChat.getAppId(),Accept:"application/json"};i||(t["Content-Type"]="application/json"),e.hasOwnProperty("isAdminApi")&&e.isAdminApi?a.getApiKey()?t.apiKey=a.getApiKey():r({error:{code:"API_KEY_NOT_SET",message:"An apiKey is needed to use the "+o+" api.",name:"API_KEY_NOT_SET"}}):a.getAuthToken()?t.authToken=a.getAuthToken():r({error:{code:"USER_NOT_LOGED_IN",message:"An authToken is need to use the "+o+" api.",name:"user not logged in"}}),d(e.endpoint,e.method,s,t,i).then(function(e){return e.json()}).then(function(e){e.hasOwnProperty("data")?(e.data.hasOwnProperty("authToken")&&u.CometChat.setAuthToken(e.data.authToken),n(e)):r(e)}).catch(function(e){return r})}).catch(function(e){return r})}catch(e){r(new l.CometChatException(e))}})},t.makeAdminApiCall=function(o,e,s,i){void 0===o&&(o=""),void 0===e&&(e={}),void 0===s&&(s={});var a=u.CometChat.getInstance();return new Promise(function(n,r){c.getEndPoint(o,e).then(function(e){var t={appId:u.CometChat.getAppId(),Accept:"application/json"};i||(t["Content-Type"]="application/json"),e.hasOwnProperty("isAdminApi")&&e.isAdminApi?a.getApiKey()?t.apiKey=a.getApiKey():r({error:"An apiKey is need to use the "+o+" api."}):a.getAuthToken()?t.authToken=a.getAuthToken():r({error:"An authToken is need to use the "+o+" api."}),d(e.endpoint,e.method,s,t,i).then(function(e){return e.json()}).then(function(e){e.hasOwnProperty("data")?(e.data.hasOwnProperty("authToken")&&u.CometChat.setAuthToken(e.data.authToken),n(e)):r(e)}).catch(function(e){return r})}).catch(function(e){return r})})},t.postData=d},function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0;var s=n(2),i=n(14),a=n(0),c=function(){function e(){for(var e=[],t=0;te.db.version;if(r&&(e.version,e.version=e.db.version),o||n){if(n){var s=e.db.version+1;s>e.version&&(e.version=s)}return!0}return!1}function R(e){var t=function(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=0;o>4,l[c++]=(15&r)<<4|o>>2,l[c++]=(3&o)<<6|63&s;return u}function B(e){var t,n=new Uint8Array(e),r="";for(t=0;t>2],r+=P[(3&n[t])<<4|n[t+1]>>4],r+=P[(15&n[t+1])<<2|n[t+2]>>6],r+=P[63&n[t+2]];return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}var F={serialize:function(t,n){var e="";if(t&&(e=x.call(t)),t&&("[object ArrayBuffer]"===e||t.buffer&&"[object ArrayBuffer]"===x.call(t.buffer))){var r,o=U;t instanceof ArrayBuffer?(r=t,o+=w):(r=t.buffer,"[object Int8Array]"===e?o+="si08":"[object Uint8Array]"===e?o+="ui08":"[object Uint8ClampedArray]"===e?o+="uic8":"[object Int16Array]"===e?o+="si16":"[object Uint16Array]"===e?o+="ur16":"[object Int32Array]"===e?o+="si32":"[object Uint32Array]"===e?o+="ui32":"[object Float32Array]"===e?o+="fl32":"[object Float64Array]"===e?o+="fl64":n(new Error("Failed to get type for BinaryArray"))),n(o+B(r))}else if("[object Blob]"===e){var s=new FileReader;s.onload=function(){var e="~~local_forage_type~"+t.type+"~"+B(this.result);n(U+b+e)},s.readAsArrayBuffer(t)}else try{n(JSON.stringify(t))}catch(e){n(null,e)}},deserialize:function(e){if(e.substring(0,D)!==U)return JSON.parse(e);var t,n=e.substring(Y),r=e.substring(D,Y);if(r===b&&L.test(n)){var o=n.match(L);t=o[1],n=n.substring(o[0].length)}var s=G(n);switch(r){case w:return s;case b:return i([s],{type:t});case"si08":return new Int8Array(s);case"ui08":return new Uint8Array(s);case"uic8":return new Uint8ClampedArray(s);case"si16":return new Int16Array(s);case"ur16":return new Uint16Array(s);case"si32":return new Int32Array(s);case"ui32":return new Uint32Array(s);case"fl32":return new Float32Array(s);case"fl64":return new Float64Array(s);default:throw new Error("Unkown type: "+r)}},stringToBuffer:G,bufferToString:B};function K(e,t,n,r){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],n,r)}function H(e,r,o,s,i,a){e.executeSql(o,s,i,function(e,n){n.code===n.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[r.storeName],function(e,t){t.rows.length?a(e,n):K(e,r,function(){e.executeSql(o,s,i,a)},a)},a):a(e,n)},a)}function k(i,e,a,c){var u=this;i=l(i);var t=new d(function(o,s){u.ready().then(function(){void 0===e&&(e=null);var n=e,r=u._dbInfo;r.serializer.serialize(e,function(t,e){e?s(e):r.db.transaction(function(e){H(e,r,"INSERT OR REPLACE INTO "+r.storeName+" (key, value) VALUES (?, ?)",[i,t],function(){o(n)},function(e,t){s(t)})},function(e){if(e.code===e.QUOTA_ERR){if(0 '__WebKitDatabaseInfoTable__'",[],function(e,t){for(var n=[],r=0;ri[0]&&t[1]Math.floor(d.SECONDARY_TIMEOUT*this.wait)&&this._throttledRequestHandler(),r>Math.floor(d.TIMEOUT*this.wait)&&(d.warn("Request "+this._requests[0].id+" timed out, over "+Math.floor(d.TIMEOUT*this.wait)+" seconds since last activity"),this._throttledRequestHandler())}}},_getRequestStatus:function(e,t){var n;if(4===e.xhr.readyState)try{n=e.xhr.status}catch(e){d.error("Caught an error while retrieving a request's status, reqStatus: "+n)}return void 0===n&&(n="number"==typeof t?t:0),n},_onRequestStateChange:function(e,t){if(d.debug("request id "+t.id+"."+t.sends+" state changed to "+t.xhr.readyState),t.abort)t.abort=!1;else if(4===t.xhr.readyState){var n=this._getRequestStatus(t);if(this.lastResponseHeaders=t.xhr.getAllResponseHeaders(),this.disconnecting&&400<=n)return this._hitError(n),void this._callProtocolErrorHandlers(t);var r=0this._conn.maxRetries;if((r||o)&&(this._removeRequest(t),d.debug("request id "+t.id+" should now be removed")),200===n){var s=this._requests[0]===t;(this._requests[1]===t||s&&0Math.floor(d.SECONDARY_TIMEOUT*this.wait))&&this._restartRequest(0),this._conn.nextValidRid(Number(t.rid)+1),d.debug("request id "+t.id+"."+t.sends+" got 200"),e(t),this.errors=0}else 0===n||400<=n&&n<600||12e3<=n?(d.error("request id "+t.id+"."+t.sends+" error "+n+" happened"),this._hitError(n),this._callProtocolErrorHandlers(t),400<=n&&n<500&&(this._conn._changeConnectStatus(d.Status.DISCONNECTING,null),this._conn._doDisconnect())):d.error("request id "+t.id+"."+t.sends+" error "+n+" happened");r||o?o&&!this._conn.connected&&this._conn._changeConnectStatus(d.Status.CONNFAIL,"giving-up"):this._throttledRequestHandler()}},_processRequest:function(e){var n=this,r=this._requests[e],t=this._getRequestStatus(r,-1);if(r.sends>this._conn.maxRetries)this._conn._onDisconnectTimeout();else{var o=r.age(),s=!isNaN(o)&&o>Math.floor(d.TIMEOUT*this.wait),i=null!==r.dead&&r.timeDead()>Math.floor(d.SECONDARY_TIMEOUT*this.wait),a=4===r.xhr.readyState&&(t<1||500<=t);if((s||i||a)&&(i&&d.error("Request ".concat(this._requests[e].id," timed out (secondary), restarting")),r.abort=!0,r.xhr.abort(),r.xhr.onreadystatechange=function(){},this._requests[e]=new d.Request(r.xmlData,r.origFunc,r.rid,r.sends),r=this._requests[e]),0===r.xhr.readyState){d.debug("request id "+r.id+"."+r.sends+" posting");try{var c=this._conn.options.contentType||"text/xml; charset=utf-8";r.xhr.open("POST",this._conn.service,!this._conn.options.sync),void 0!==r.xhr.setRequestHeader&&r.xhr.setRequestHeader("Content-Type",c),this._conn.options.withCredentials&&(r.xhr.withCredentials=!0)}catch(e){return d.error("XHR open failed: "+e.toString()),this._conn.connected||this._conn._changeConnectStatus(d.Status.CONNFAIL,"bad-service"),void this._conn.disconnect()}var u=function(){if(r.date=new Date,n._conn.options.customHeaders){var e=n._conn.options.customHeaders;for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.xhr.setRequestHeader(t,e[t])}r.xhr.send(r.data)};if(1/g,">")).replace(/'/g,"'")).replace(/"/g,""")},xmlunescape:function(e){return e=(e=(e=(e=(e=e.replace(/\&/g,"&")).replace(/</g,"<")).replace(/>/g,">")).replace(/'/g,"'")).replace(/"/g,'"')},xmlTextNode:function(e){return g.xmlGenerator().createTextNode(e)},xmlHtmlNode:function(e){var t;DOMParser?t=(new DOMParser).parseFromString(e,"text/xml"):((t=new ActiveXObject("Microsoft.XMLDOM")).async="false",t.loadXML(e));return t},getText:function(e){if(!e)return null;var t="";0===e.childNodes.length&&e.nodeType===g.ElementType.TEXT&&(t+=e.nodeValue);for(var n=0;n/g,"\\3e").replace(/@/g,"\\40")},unescapeNode:function(e){return"string"!=typeof e?e:e.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\")},getNodeFromJid:function(e){return e.indexOf("@")<0?null:e.split("@")[0]},getDomainFromJid:function(e){var t=g.getBareJidFromJid(e);if(t.indexOf("@")<0)return t;var n=t.split("@");return n.splice(0,1),n.join("@")},getResourceFromJid:function(e){var t=e.split("/");return t.length<2?null:(t.splice(0,1),t.join("/"))},getBareJidFromJid:function(e){return e?e.split("/")[0]:null},_handleError:function(e){void 0!==e.stack&&g.fatal(e.stack),e.sourceURL?g.fatal("error: "+this.handler+" "+e.sourceURL+":"+e.line+" - "+e.name+": "+e.message):e.fileName?g.fatal("error: "+this.handler+" "+e.fileName+":"+e.lineNumber+" - "+e.name+": "+e.message):g.fatal("error: "+e.message)},log:function(e,t){e===this.LogLevel.FATAL&&"object"===f(window.console)&&"function"==typeof window.console.error&&window.console.error(t)},debug:function(e){this.log(this.LogLevel.DEBUG,e)},info:function(e){this.log(this.LogLevel.INFO,e)},warn:function(e){this.log(this.LogLevel.WARN,e)},error:function(e){this.log(this.LogLevel.ERROR,e)},fatal:function(e){this.log(this.LogLevel.FATAL,e)},serialize:function(n){if(!n)return null;"function"==typeof n.tree&&(n=n.tree());var e=s(Array(n.attributes.length).keys()).map(function(e){return n.attributes[e].nodeName});e.sort();var t=e.reduce(function(e,t){return"".concat(e," ").concat(t,'="').concat(g.xmlescape(n.attributes.getNamedItem(t).value),'"')},"<".concat(n.nodeName));if(0";for(var r=0;r"}}t+=""}else t+="/>";return t},_requestId:0,_connectionPlugins:{},addConnectionPlugin:function(e,t){g._connectionPlugins[e]=t},Builder:function(e,t){"presence"!==e&&"message"!==e&&"iq"!==e||(t&&!t.xmlns?t.xmlns=g.NS.CLIENT:t||(t={xmlns:g.NS.CLIENT})),this.nodeTree=g.xmlElement(e,t),this.node=this.nodeTree}};g.Builder.prototype={tree:function(){return this.nodeTree},toString:function(){return g.serialize(this.nodeTree)},up:function(){return this.node=this.node.parentNode,this},root:function(){return this.node=this.nodeTree,this},attrs:function(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(void 0===e[t]?this.node.removeAttribute(t):this.node.setAttribute(t,e[t]));return this},c:function(e,t,n){var r=g.xmlElement(e,t,n);return this.node.appendChild(r),"string"!=typeof n&&"number"!=typeof n&&(this.node=r),this},cnode:function(e){var t,n=g.xmlGenerator();try{t=void 0!==n.importNode}catch(e){t=!1}var r=t?n.importNode(e,!0):g.copyElement(e);return this.node.appendChild(r),this.node=r,this},t:function(e){var t=g.xmlTextNode(e);return this.node.appendChild(t),this},h:function(e){var t=document.createElement("body");t.innerHTML=e;for(var n=g.createHtml(t);0e[n].prototype.priority&&(n=r);if(n!==t){var o=e[t];e[t]=e[n],e[n]=o}}return e},_attemptSASLAuth:function(e){e=this.sortMechanismsByPriority(e||[]);for(var t=!1,n=0;n>16)+(t>>16)+(n>>16)<<16|65535&n},r=function(e){for(var t=[],n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<>>32-a,n);var i,a},E=function(e,t,n,r,o,s,i){return a(t&n|~t&r,e,t,o,s,i)},h=function(e,t,n,r,o,s,i){return a(t&r|n&~r,e,t,o,s,i)},p=function(e,t,n,r,o,s,i){return a(t^n^r,e,t,o,s,i)},f=function(e,t,n,r,o,s,i){return a(n^(t|~r),e,t,o,s,i)},o=function(e,t){e[t>>5]|=128<>>9<<4)]=t;for(var n,r,o,s,i=1732584193,a=-271733879,c=-1732584194,u=271733878,l=0;l>2]>>r%4*8+4&15)+t.charAt(e[r>>2]>>r%4*8&15);return n}(o(r(e),8*e.length))},hash:function(e){return function(e){for(var t="",n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>n%32&255);return t}(o(r(e),8*e.length))}}},"./src/sha1.js":function(e,t,n){"use strict";function a(e,t){e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;var n,r,o,s,i,a,c,u,l,d=new Array(80),E=1732584193,h=-271733879,p=-1732584194,f=271733878,g=-1009589776;for(n=0;n>16)+(t>>16)+(n>>16)<<16|65535&n}function S(e,t){return e<>>32-t}function c(e){for(var t=[],n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<<24-n%32;return t}function o(e){for(var t,n,r="",o=0;o<4*e.length;o+=3)for(t=(e[o>>2]>>8*(3-o%4)&255)<<16|(e[o+1>>2]>>8*(3-(o+1)%4)&255)<<8|e[o+2>>2]>>8*(3-(o+2)%4)&255,n=0;n<4;n++)8*o+6*n>32*e.length?r+="=":r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t>>6*(3-n)&63);return r}function s(e){for(var t="",n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>24-n%32&255);return t}n.r(t),n.d(t,"default",function(){return i});var i={b64_hmac_sha1:function(e,t){return o(r(e,t))},b64_sha1:function(e){return o(a(c(e),8*e.length))},binb2str:s,core_hmac_sha1:r,str_hmac_sha1:function(e,t){return s(r(e,t))},str_sha1:function(e){return s(a(c(e),8*e.length))}}},"./src/strophe.js":function(e,t,n){"use strict";n.r(t);n("./src/bosh.js"),n("./src/websocket.js");var r=n("./src/core.js");n.d(t,"default",function(){return r.default})},"./src/utils.js":function(e,t,n){"use strict";function c(e){return(c="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})(e)}n.r(t),n.d(t,"default",function(){return r});var r={utf16to8:function(e){var t,n,r="",o=e.length;for(t=0;t>12&15),r+=String.fromCharCode(128|n>>6&63)):r+=String.fromCharCode(192|n>>6&31),r+=String.fromCharCode(128|n>>0&63));return r},addCookies:function(e){for(var t in e=e||{})if(Object.prototype.hasOwnProperty.call(e,t)){var n="",r="",o="",s=e[t],i="object"===c(s),a=escape(unescape(i?s.value:s));i&&(n=s.expires?";expires="+s.expires:"",r=s.domain?";domain="+s.domain:"",o=s.path?";path="+s.path:""),document.cookie=t+"="+a+n+r+o}}}},"./src/websocket.js":function(e,t,n){"use strict";n.r(t);var r=n("./src/core.js"),u=r.default.Strophe,o=r.default.$build;u.Websocket=function(e){this._conn=e,this.strip="wrapper";var t=e.service;if(0!==t.indexOf("ws:")&&0!==t.indexOf("wss:")){var n="";"ws"===e.options.protocol&&"https:"!==window.location.protocol?n+="ws":n+="wss",n+="://"+window.location.host,0!==t.indexOf("/")?n+=window.location.pathname+t:n+=t,e.service=n}},u.Websocket.prototype={_buildStream:function(){return o("open",{xmlns:u.NS.FRAMING,to:this._conn.domain,version:"1.0"})},_check_streamerror:function(e,t){var n;if(0===(n=e.getElementsByTagNameNS?e.getElementsByTagNameNS(u.NS.STREAM,"error"):e.getElementsByTagName("stream:error")).length)return!1;for(var r=n[0],o="",s="",i=0;i: "+n);var r=e.getAttribute("version");return"string"!=typeof r?t="Missing version in ":"1.0"!==r&&(t="Wrong version in : "+r),!t||(this._conn._changeConnectStatus(u.Status.CONNFAIL,t),this._conn._doDisconnect(),!1)},_connect_cb_wrapper:function(e){if(0===e.data.indexOf("\s*)*/,"");if(""===t)return;var n=(new DOMParser).parseFromString(t,"text/xml").documentElement;this._conn.xmlInput(n),this._conn.rawInput(e.data),this._handleStreamStart(n)&&this._connect_cb(n)}else if(0===e.data.indexOf(" tag.")}}this._conn._doDisconnect()},_doDisconnect:function(){u.info("WebSockets _doDisconnect was called"),this._closeSocket()},_streamWrap:function(e){return""+e+""},_closeSocket:function(){if(this.socket)try{this.socket.onerror=null,this.socket.close()}catch(e){u.debug(e.message)}this.socket=null},_emptyQueue:function(){return!0},_onClose:function(e){this._conn.connected&&!this._conn.disconnecting?(u.error("Websocket closed unexpectedly"),this._conn._doDisconnect()):e&&1006===e.code&&!this._conn.connected&&this.socket?(u.error("Websocket closed unexcectedly"),this._conn._changeConnectStatus(u.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._conn._doDisconnect()):u.info("Websocket closed")},_no_auth_received:function(e){u.error("Server did not offer a supported authentication mechanism"),this._changeConnectStatus(u.Status.CONNFAIL,u.ErrorCondition.NO_AUTH_MECH),e&&e.call(this._conn),this._conn._doDisconnect()},_onDisconnectTimeout:function(){},_abortAllRequests:function(){},_onError:function(e){u.error("Websocket error "+e),this._conn._changeConnectStatus(u.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._disconnect()},_onIdle:function(){var e=this._conn._data;if(0e.getId()&&(i=parseInt(e.getId().toString())),ri[0]&&t[1]"}},getFriends:{endpoint:"user/friends",method:"GET"},unfriend:{endpoint:"user/friends/{{uid}}/{{gid}}",method:"DELETE",data:{uids:"array"}},acceptFriendRequest:{endpoint:"user/friends/{{uid}}/accept",method:"PUT",data:{uids:"array"}},rejectFriendRequest:{endpoint:"user/friends/{{uid}}/reject",method:"DELETE",data:{uids:"array"}},createGroup:{endpoint:"groups",method:"POST",data:{guid:"required|string|max:100",name:"required|string|max:100",type:"enum|public,protected,password",password:"filled|string|max:100"}},getGroups:{endpoint:"groups",method:"GET"},getGroup:{endpoint:"groups/{{guid}}",method:"GET"},updateGroup:{endpoint:"groups/{{guid}}",method:"PUT"},deleteGroup:{endpoint:"groups/{{guid}}",method:"DELETE"},addGroupMembers:{endpoint:"groups/{{guid}}/members",method:"POST",data:{uids:"array"}},getGroupMembers:{endpoint:"groups/{{guid}}/members",method:"GET"},joinGroup:{endpoint:"groups/{{guid}}/members",method:"POST"},leaveGroup:{endpoint:"groups/{{guid}}/members",method:"DELETE"},kickGroupMembers:{endpoint:"groups/{{guid}}/members/{{uid}}",method:"DELETE",data:{uids:"array"}},changeScopeOfMember:{endpoint:"groups/{{guid}}/members/{{uid}}",method:"PUT",data:{uids:"array"}},banGroupMember:{endpoint:"groups/{{guid}}/bannedusers/{{uid}}",method:"POST",data:{uids:"array"}},unbanGroupMember:{endpoint:"groups/{{guid}}/bannedusers/{{uid}}",method:"DELETE",data:{uids:"array"}},addMemebersToGroup:{endpoint:"groups/{{guid}}/members",method:"PUT"},getBannedGroupMembers:{endpoint:"groups/{{guid}}/bannedusers",method:"GET"},promotemoteGroupMember:{endpoint:"groups/{{guid}}/promote",method:"PUT",data:{uids:"array"}},demoteGroupMember:{endpoint:"groups/{{guid}}/demote",method:"DELETE",data:{uids:"array"}},sendMessage:{endpoint:"messages",method:"POST",data:{sender:"array:string:max:100>",isGroupMember:"filled|boolean|bail",data:"required|json"}},getMessages:{endpoint:"messages",method:"GET"},getMessageDetails:{endpoint:"messages/{{messageId}}",method:"GET"},getUserMessages:{endpoint:"users/{{listId}}/messages",method:"GET"},getGroupMessages:{endpoint:"groups/{{listId}}/messages",method:"GET"},getMessage:{endpoint:"user/messages/{{muid}}",method:"GET"},updateMessage:{endpoint:"messages/{{messageId}}",method:"PUT"},deleteMessage:{endpoint:"messages/{{messageId}}",method:"DELETE"},createCallSession:{endpoint:"calls",method:"POST",data:{}},updateCallSession:{endpoint:"calls/{{sessionid}}",method:"put",data:{}},getConversations:{endpoint:"conversations",method:"GET"}}}return s.prototype.getEndpointData=function(o){return new Promise(function(r,t){try{c.LocalStorage.getInstance().get(a.APP_SETTINGS.APP_SETTINGS).then(function(e){if(i.isFalsy(e)){var t={};if((new s).uriEndpoints.hasOwnProperty(o))if((t=(new s).uriEndpoints[o]).hasOwnProperty("isAdminApi")){var n=i.format((new s).adminApiUrl,u.CometChat.appSettings.getRegion())+(new s).adminApiVersion+"/"+t.endpoint;t.endpoint=n}else{n=i.format((new s).baseUrl,u.CometChat.appSettings.getRegion())+(new s).apiVersion+"/"+t.endpoint;t.endpoint=n}r(t)}else{t={};if((new s).uriEndpoints.hasOwnProperty(o))if((t=(new s).uriEndpoints[o]).hasOwnProperty("isAdminApi"))t.endpoint="https://"+e[a.APP_SETTINGS.KEYS.ADMIN_API_HOST]+"/"+(new s).adminApiVersion+"/"+t.endpoint;else{n="https://"+e[a.APP_SETTINGS.KEYS.CLIENT_API_HOST]+"/"+(new s).apiVersion+"/"+t.endpoint;t.endpoint=n}r(t)}},function(e){var t;(new s).uriEndpoints.hasOwnProperty(o)&&((t=(new s).uriEndpoints[o]).hasOwnProperty(["isAdminApi"])?t.endpoint=i.format((new s).adminApiUrl,u.CometChat.appSettings.getRegion())+(new s).adminApiVersion+"/"+t.endpoint:t.endpoint=i.format((new s).baseUrl,u.CometChat.appSettings.getRegion())+(new s).apiVersion+"/"+t.endpoint),r(t)})}catch(e){t(new l.CometChatException(e))}})},s}();t.EndpointFactory=r},function(e,t,n){"use strict";t.__esModule=!0;var r=n(44),o=n(0),s=n(1),i=function(){function e(){}return e.transformPresence=function(e){return e.getAttribute("type")?new r.UserPresence(e.getAttribute(o.PresenceConstatnts.XMPP_KEYS.FROM),o.PresenceConstatnts.STATUS.OFFLINE,(new Date).getTime()):new r.UserPresence(e.getAttribute(o.PresenceConstatnts.XMPP_KEYS.FROM),o.PresenceConstatnts.STATUS.ONLINE,(new Date).getTime())},e.transformPresences=function(e){var t=[];return e.map(function(e){try{t.push(new r.UserPresence(e.getAttribute(o.PresenceConstatnts.XMPP_KEYS.FROM),e.getAttribute(o.PresenceConstatnts.XMPP_KEYS.STATUS),e.getAttribute(o.PresenceConstatnts.XMPP_KEYS.LAST_ACTIVE_AT)))}catch(e){s.Logger.error("PresenceController:transformPresences",e)}}),t},e.transformMUCUserPresence=function(e){return e.getAttribute("type")?new r.UserPresence(e.getAttribute(o.PresenceConstatnts.XMPP_KEYS.FROM),o.PresenceConstatnts.STATUS.LEFT,(new Date).getTime()):new r.UserPresence(e.getAttribute(o.PresenceConstatnts.XMPP_KEYS.FROM),o.PresenceConstatnts.STATUS.JOINED,(new Date).getTime())},e.trandformMUCPresence=function(e){0=1e3*o.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT&&delete n.TYPING_STARTED_MAP[e]})}),new Promise(function(e,t){Object.keys(n.TYPING_ENDED_MAP).map(function(e){r.getCurrentTime()-n.TYPING_ENDED_MAP[e]>=1e3*o.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT&&delete n.TYPING_ENDED_MAP[e]})}),new Promise(function(e,t){Object.keys(n.INCOMING_TYPING_STARTED_MAP).map(function(e){r.getCurrentTime()-n.INCOMING_TYPING_STARTED_MAP[e][o.TYPING_NOTIFICATION.KEYS.TIMESTAMP]>=1e3*o.DEFAULT_VALUES.DEFAULT_MAX_TYPING_INDICATOR_LIMIT&&(s.XMPPConnectionHelper.getInstance().publishTypinStatusNotification(n.INCOMING_TYPING_STARTED_MAP[e][o.TYPING_NOTIFICATION.KEYS.TYPING_NOTIFICATION],o.TYPING_NOTIFICATION.ACTIONS.ENDED),delete n.INCOMING_TYPING_STARTED_MAP[e])})})},e.TYPING_STARTED_MAP={},e.TYPING_ENDED_MAP={},e.INCOMING_TYPING_STARTED_MAP={},e}();t.TypingNotificationController=i},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(s,i,a,c){return new(a||(a=Promise))(function(e,t){function n(e){try{o(c.next(e))}catch(e){t(e)}}function r(e){try{o(c.throw(e))}catch(e){t(e)}}function o(t){t.done?e(t.value):new a(function(e){e(t.value)}).then(n,r)}o((c=c.apply(s,i||[])).next())})},o=this&&this.__generator||function(n,r){var o,s,i,e,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,s&&(i=2&t[0]?s.return:t[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,t[1])).done)return i;switch(s=0,i&&(t=[2&t[0],i.value]),t[0]){case 0:case 1:i=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,s=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(i=0<(i=a.trys).length&&i[i.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!i||t[1]>i[0]&&t[1]"==e&&">")||"&"==e&&"&"||'"'==e&&"""||"&#"+e.charCodeAt()+";"}function w(e,t){if(t(e))return!0;if(e=e.firstChild)do{if(w(e,t))return!0}while(e=e.nextSibling)}function b(){}function Y(e,t,n,r){e&&e._inc++,"http://www.w3.org/2000/xmlns/"==n.namespaceURI&&delete t._nsMap[n.prefix?n.localName:""]}function x(e,t,n){if(e&&e._inc){e._inc++;var r=t.childNodes;if(n)r[r.length++]=n;else{for(var o=t.firstChild,s=0;o;)o=(r[s++]=o).nextSibling;r.length=s}}}function G(e,t){var n=t.previousSibling,r=t.nextSibling;return n?n.nextSibling=r:e.firstChild=r,r?r.previousSibling=n:e.lastChild=n,x(e.ownerDocument,e),t}function B(e,t,n){var r=t.parentNode;if(r&&r.removeChild(t),t.nodeType===O){var o=t.firstChild;if(null==o)return t;var s=t.lastChild}else o=s=t;var i=n?n.previousSibling:e.lastChild;for(o.previousSibling=i,s.nextSibling=n,i?i.nextSibling=o:e.firstChild=o,null==n?e.lastChild=s:n.previousSibling=s;o.parentNode=e,o!==s&&(o=o.nextSibling););return x(e.ownerDocument||e,e),t.nodeType==O&&(t.firstChild=t.lastChild=null),t}function F(){this._nsMap={}}function K(){}function H(){}function k(){}function J(){}function V(){}function j(){}function X(){}function q(){}function W(){}function $(){}function Q(){}function z(){}function Z(e,t){var n=[],r=9==this.nodeType?this.documentElement:this,o=r.prefix,s=r.namespaceURI;if(s&&null==o&&null==(o=r.lookupPrefix(s)))var i=[{namespace:s,prefix:null}];return te(this,n,e,t,i),n.join("")}function ee(e,t,n){var r=e.prefix||"",o=e.namespaceURI;if(!r&&!o)return!1;if("xml"===r&&"http://www.w3.org/XML/1998/namespace"===o||"http://www.w3.org/2000/xmlns/"==o)return!1;for(var s=n.length;s--;){var i=n[s];if(i.prefix==r)return i.namespace!=o}return!0}function te(e,t,n,r,o){if(r){if(!(e=r(e)))return;if("string"==typeof e)return void t.push(e)}switch(e.nodeType){case C:o||(o=[]);o.length;var s=e.attributes,i=s.length,a=e.firstChild,c=e.tagName;n=_===e.namespaceURI||n,t.push("<",c);for(var u=0;u"),n&&/^script$/i.test(c))for(;a;)a.data?t.push(a.data):te(a,t,n,r,o),a=a.nextSibling;else for(;a;)te(a,t,n,r,o),a=a.nextSibling;t.push("")}else t.push("/>");return;case R:case O:for(a=e.firstChild;a;)te(a,t,n,r,o),a=a.nextSibling;return;case S:return t.push(" ",e.name,'="',e.value.replace(/[<&"]/g,D),'"');case T:return t.push(e.data.replace(/[<&]/g,D));case m:return t.push("");case N:return t.push("\x3c!--",e.data,"--\x3e");case y:var p=e.publicId,f=e.systemId;if(t.push("');else if(f&&"."!=f)t.push(' SYSTEM "',f,'">');else{var g=e.internalSubset;g&&t.push(" [",g,"]"),t.push(">")}return;case I:return t.push("");case A:return t.push("&",e.nodeName,";");default:t.push("??",e.nodeName)}}function ne(e,t,n){e[t]=n}E.prototype=Error.prototype,s(a,E),h.prototype={length:0,item:function(e){return this[e]||null},toString:function(e,t){for(var n=[],r=0;ri[0]&&t[1]t._resendCount)return;t._msgQueue[e].tree().setAttribute("from",t._conn.jid),t._conn.send(t._msgQueue[e]),t.resendMessage(e)}},this._resendTime)},addReceiptHandler:function(t,e,n,r){var o=this;this._conn.addHandler(function(e){return o._processReceipt(e),t(e)},p.Strophe.NS.RECEIPTS,"message",e,null,n,r)},_processReceipt:function(h,e){return void 0===e&&(e=0),n(this,void 0,void 0,function(){var t,n,r,o,s,i,a,c,u,l,d,E;return f(this,function(e){t=h.getAttribute(_.DELIVERY_RECEIPTS.ID),n=p.Strophe.getBareJidFromJid(h.getAttribute(_.MessageConstatnts.XMPP_KEYS.FROM)),r=g.getUidFromJid(n),o=_.MessageConstatnts.XMPP_KEYS.TYPE_USER,s=_.MessageConstatnts.RECEIVER_TYPE.USER,i=h.getElementsByTagName("request"),a=h.getElementsByTagName("received");try{c=h.getElementsByTagName("body")[0].innerHTML}catch(e){u=c=void 0}return void 0!==c&&(u=JSON.parse(c).receiverType),h.getAttribute(_.MessageConstatnts.XMPP_KEYS.TYPE)==_.MessageConstatnts.XMPP_KEYS.TYPE_GROUP||void 0!==u&&u==_.MessageConstatnts.RECEIVER_TYPE.GROUP?(s=_.MessageConstatnts.RECEIVER_TYPE.GROUP,n=g.getGroupJidFullGroupJid(h.getAttribute(_.MessageConstatnts.XMPP_KEYS.FROM)),o=_.MessageConstatnts.XMPP_KEYS.TYPE_GROUP,0a.DEFAULT_VALUES.GROUPS_MAX_LIMIT)return new s.CometChatException(JSON.parse(r.format(JSON.stringify(a.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT","group limit",a.DEFAULT_VALUES.GROUPS_MAX_LIMIT)));if(this.limitthis.total_pages)return e.page=this.next_page,e;e.page=this.next_page++}return e},e.prototype.getPreData=function(){var e={};return e.per_page=this.limit,0<=this.next_page&&0l.DEFAULT_VALUES.USERS_MAX_LIMIT)return new c.CometChatException(JSON.parse(i.format(JSON.stringify(l.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT","group member limit",l.DEFAULT_VALUES.USERS_MAX_LIMIT)));if(this.limitthis.total_pages)return e.page=this.next_page,e;e.page=this.next_page++}return e},e.prototype.getPreData=function(){var e={};return e.per_page=this.limit,0<=this.next_page&&0u.DEFAULT_VALUES.USERS_MAX_LIMIT)return new c.CometChatException(JSON.parse(i.format(JSON.stringify(u.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT","user limit",u.DEFAULT_VALUES.USERS_MAX_LIMIT)));if(this.limitthis.total_pages)return e.page=this.next_page,e;e.page=this.next_page++}return e},o.prototype.getPreData=function(){var e={};return e.per_page=this.limit,0<=this.next_page&&0a.DEFAULT_VALUES.CONVERSATION_MAX_LIMIT?new s.CometChatException(JSON.parse(r.format(JSON.stringify(a.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT","conversation limit",a.DEFAULT_VALUES.CONVERSATION_MAX_LIMIT))):this.limitthis.total_pages)return e.page=this.next_page,e;e.page=this.next_page++}return e},e}();t.ConversationsRequest=c;var u=function(){function e(){}return e.prototype.setLimit=function(e){return this.limit=e,this},e.prototype.setConversationType=function(e){return this.conversationType=e,this},e.prototype.build=function(){return new c(this)},e}();t.ConversationsRequestBuilder=u},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(s,i,a,c){return new(a||(a=Promise))(function(e,t){function n(e){try{o(c.next(e))}catch(e){t(e)}}function r(e){try{o(c.throw(e))}catch(e){t(e)}}function o(t){t.done?e(t.value):new a(function(e){e(t.value)}).then(n,r)}o((c=c.apply(s,i||[])).next())})},a=this&&this.__generator||function(n,r){var o,s,i,e,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,s&&(i=2&t[0]?s.return:t[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,t[1])).done)return i;switch(s=0,i&&(t=[2&t[0],i.value]),t[0]){case 0:case 1:i=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,s=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(i=0<(i=a.trys).length&&i[i.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!i||t[1]>i[0]&&t[1]C.DEFAULT_VALUES.MSGS_MAX_LIMIT)return void t(new p.CometChatException(JSON.parse(_.format(JSON.stringify(C.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT","message limit",C.DEFAULT_VALUES.MSGS_MAX_LIMIT))));if(re&&A.MessageListnerMaping.getInstance().set("all",t.id)},function(e){A.MessageListnerMaping.getInstance().set("all",t.id)}),h.affix==C.MessageConstatnts.PAGINATION.AFFIX.APPEND?(h.idt.id&&(h.id=t.id),h.timestamp>t.sentAt&&(h.timestamp=t.sentAt),h.updatedAt>t.updatedAt&&(h.updatedAt=t.updatedAt)),h.id&&(h.paginationMeta[C.MessageConstatnts.PAGINATION.KEYS.ID]=h.id),h.timestamp&&(h.paginationMeta[C.MessageConstatnts.PAGINATION.KEYS.SENT_AT]=h.timestamp),h.updatedAt&&(h.paginationMeta[C.MessageConstatnts.PAGINATION.KEYS.UPDATED_AT]=h.updatedAt),n.push(g.MessageController.trasformJSONMessge(t))})}else n=[];a(n)},function(e){t(new p.CometChatException(e))})}catch(e){t(new p.CometChatException(e))}})},e.prototype.createEndpoint=function(){(_.isFalsy(this.guid)||_.isFalsy(this.uid))&&_.isFalsy(this.guid)?(_.isFalsy(this.uid)?this.endpointName="getMessages":this.endpointName="getUserMessages",this.listId=this.uid):(this.endpointName="getGroupMessages",this.listId=this.guid)},e.prototype.makeData=function(){var e={};e[C.MessageConstatnts.PAGINATION.KEYS.PER_PAGE]=this.limit,e[C.MessageConstatnts.PAGINATION.KEYS.AFFIX]=this.affix,(_.isFalsy(this.guid)||_.isFalsy(this.uid))&&_.isFalsy(this.guid)&&_.isFalsy(this.uid)},e.prototype.getFilteredPreviousDataByReceiverId=function(t){return r(this,void 0,void 0,function(){var n,r=this;return a(this,function(e){switch(e.label){case 0:switch(n=[],t){case"user":return[3,1];case"group":return[3,3];case"both":return[3,5]}return[3,7];case 1:return[4,o.MessagesStore.getInstance().get(this.uid).then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).map(function(e){n=n.concat([t[e]])})})];case 2:return e.sent(),[3,9];case 3:return[4,o.MessagesStore.getInstance().get(this.guid).then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).map(function(e){n=n.concat([t[e]])})})];case 4:e.sent(),e.label=5;case 5:return[4,o.MessagesStore.getInstance().get(this.guid).then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).filter(function(e){return t[e].sender.uid==r.uid}).map(function(e){n=n.concat([t[e]])})})];case 6:return e.sent(),[3,9];case 7:return[4,o.MessagesStore.getInstance().getAllMessages().then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).map(function(e){n=n.concat([t[e]])})})];case 8:return e.sent(),[3,9];case 9:return[2,n]}})})},e.prototype.getFilteredNextDataByReceiverId=function(t){return r(this,void 0,void 0,function(){var n,r=this;return a(this,function(e){switch(e.label){case 0:switch(n=[],t){case"user":return[3,1];case"group":return[3,3];case"both":return[3,5]}return[3,7];case 1:return[4,o.MessagesStore.getInstance().get(this.uid).then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).map(function(e){n=n.concat([t[e]])})})];case 2:return e.sent(),[3,9];case 3:return[4,o.MessagesStore.getInstance().get(this.guid).then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).map(function(e){n=n.concat([t[e]])})})];case 4:e.sent(),e.label=5;case 5:return[4,o.MessagesStore.getInstance().get(this.guid).then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).filter(function(e){return t[e].sender.uid==r.uid}).map(function(e){n=n.concat([t[e]])})})];case 6:return e.sent(),[3,9];case 7:return[4,o.MessagesStore.getInstance().getAllMessages().then(function(t){Object.keys(t).filter(function(e){return parseInt(e)>r.id}).map(function(e){n=n.concat([t[e]])})})];case 8:return e.sent(),[3,9];case 9:return[2,n]}})})},e}();t.DefaultMessagesRequest=s;var i=function(){function e(){this.maxLimit=C.DEFAULT_VALUES.MSGS_MAX_LIMIT,this.timestamp=0,this.id=C.DEFAULT_VALUES.DEFAULT_MSG_ID,this.unread=!1,this.undelivered=!1,this.HideMessagesFromBlockedUsers=!1,this.onlyUpdate=0}return e.prototype.setLimit=function(e){return this.limit=e,this},e.prototype.setGUID=function(e){return this.guid=e,this},e.prototype.setUID=function(e){return this.uid=e,this},e.prototype.setTimestamp=function(e){return void 0===e&&(e=_.getCurrentTime()),this.timestamp=e,this},e.prototype.setMessageId=function(e){return void 0===e&&(e=C.DEFAULT_VALUES.DEFAULT_MSG_ID),this.id=e,this},e.prototype.setUnread=function(e){return void 0===e&&(e=!1),this.unread=e,this},e.prototype.setUndelivered=function(e){return void 0===e&&(e=!1),this.undelivered=e,this},e.prototype.hideMessagesFromBlockedUsers=function(e){return void 0===e&&(e=!1),this.HideMessagesFromBlockedUsers=e,this},e.prototype.setSearchKeyword=function(e){return this.searchKey=e,this},e.prototype.setUpdatedAfter=function(e){return this.updatedAt=e,this},e.prototype.updatesOnly=function(e){return e&&(this.onlyUpdate=1),this},e.prototype.setCategory=function(e){return this.category=e,this},e.prototype.setType=function(e){return this.type=e,this},e.prototype.build=function(){return new s(this)},e}();t.DefaultMessagesRequestBuilder=i},function(e,t,n){"use strict";t.__esModule=!0;var r=function(e){};t.CometChatExtension=r},function(e,t,n){"use strict";t.__esModule=!0;var o=n(4),r=n(1),s=n(8),i=n(2),a=n(0),c=function(){function e(e){this.next_page=1,this.current_page=1,this.total_pages=-1,this.fetchingInProgress=!1,this.pagination={total:0,count:0,per_page:0,current_page:0,total_pages:0,links:[]},r.isFalsy(e)||(this.limit=e.limit,r.isFalsy(e.searchKeyword)||(this.searchKeyword=e.searchKeyword),r.isFalsy(e.direction)||(this.direction=e.direction))}return e.prototype.validateBlockedUsersBuilder=function(){if(void 0===this.limit)return new i.CometChatException(JSON.parse(r.format(JSON.stringify(a.GENERAL_ERROR.COMPULSORY),"SET_LIMIT","SET_LIMIT","setLimit() method")));if(isNaN(this.limit))return new i.CometChatException(JSON.parse(r.format(JSON.stringify(a.GENERAL_ERROR.MUST_BE_A_NUMBER),"SET_LIMIT","SET_LIMIT","user limit")));if(this.limit>a.DEFAULT_VALUES.USERS_MAX_LIMIT)return new i.CometChatException(JSON.parse(r.format(JSON.stringify(a.GENERAL_ERROR.LIMIT_EXCEEDED),"SET_LIMIT","SET_LIMIT","user limit",a.DEFAULT_VALUES.USERS_MAX_LIMIT)));if(this.limitthis.total_pages)return e.page=this.next_page,e;e.page=this.next_page++}return e},e.prototype.getPreData=function(){var e={};return e.per_page=this.limit,0<=this.next_page&&0>>((3&t)<<3)&255;return o}}},function(e,t){for(var o=[],n=0;n<256;++n)o[n]=(n+256).toString(16).substr(1);e.exports=function(e,t){var n=t||0,r=o;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")}},function(e,t,n){function r(e){this.options=e||{locator:{}}}function u(){this.cdata=!1}function l(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}function d(e){if(e)return"\n@"+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function o(e,t,n){return"string"==typeof e?e.substr(t,n):e.length>=t+n||t?new java.lang.String(e,t,n)+"":e}function E(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}r.prototype.parseFromString=function(e,t){var n=this.options,r=new h,o=n.domBuilder||new u,s=n.errorHandler,i=n.locator,a=n.xmlns||{},c={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"};return i&&o.setDocumentLocator(i),r.errorHandler=function(r,e,o){if(!r){if(e instanceof u)return e;r=e}var s={},i=r instanceof Function;function t(t){var n=r[t];!n&&i&&(n=2==r.length?function(e){r(t,e)}:r),s[t]=n&&function(e){n("[xmldom "+t+"]\t"+e+d(o))}||function(){}}return o=o||{},t("warning"),t("error"),t("fatalError"),s}(s,o,i),r.domBuilder=n.domBuilder||o,/\/x?html?$/.test(t)&&(c.nbsp=" ",c.copy="©",a[""]="http://www.w3.org/1999/xhtml"),a.xml=a.xml||"http://www.w3.org/XML/1998/namespace",e?r.parse(e,a,c):r.errorHandler.error("invalid doc source"),o.doc},u.prototype={startDocument:function(){this.doc=(new s).createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,n,r){var o=this.doc,s=o.createElementNS(e,n||t),i=r.length;E(this,s),this.currentElement=s,this.locator&&l(this.locator,s);for(var a=0;a":switch(c){case d:n.setTagName(e.slice(t,a));case g:case _:case C:break;case f:case E:"/"===(l=e.slice(t,a)).slice(-1)&&(n.closed=!0,l=l.slice(0,-1));case h:c===h&&(l=i),c==f?(s.warning('attribute "'+l+'" missed quot(")!!'),n.add(i,l.replace(/&#?\w+;/g,o),t)):("http://www.w3.org/1999/xhtml"===r[""]&&l.match(/^(?:disabled|checked|selected)$/i)||s.warning('attribute "'+l+'" missed value!! "'+l+'" instead!!'),n.add(l,l,t));break;case p:throw new Error("attribute value missed!!")}return a;case"€":u=" ";default:if(u<=" ")switch(c){case d:n.setTagName(e.slice(t,a)),c=_;break;case E:i=e.slice(t,a),c=h;break;case f:var l=e.slice(t,a).replace(/&#?\w+;/g,o);s.warning('attribute "'+l+'" missed quot(")!!'),n.add(i,l,t);case g:c=_}else switch(c){case h:n.tagName;"http://www.w3.org/1999/xhtml"===r[""]&&i.match(/^(?:disabled|checked|selected)$/i)||s.warning('attribute "'+i+'" missed value!! "'+i+'" instead2!!'),n.add(i,i,t),t=a,c=E;break;case g:s.warning('attribute space is required"'+i+'"!!');case _:c=E,t=a;break;case p:c=f,t=a;break;case C:throw new Error("elements closed character '/' and '>' must be connected to")}}a++}}function D(e,t,n){for(var r=e.tagName,o=null,s=e.length;s--;){var i=e[s],a=i.qName,c=i.value;if(0<(E=a.indexOf(":")))var u=i.prefix=a.slice(0,E),l=a.slice(E+1),d="xmlns"===u&&l;else u=null,d="xmlns"===(l=a)&&"";i.localName=l,!1!==d&&(null==o&&(o={},S(n,n={})),n[d]=o[d]=c,i.uri="http://www.w3.org/2000/xmlns/",t.startPrefixMapping(d,c))}for(s=e.length;s--;){(u=(i=e[s]).prefix)&&("xml"===u&&(i.uri="http://www.w3.org/XML/1998/namespace"),"xmlns"!==u&&(i.uri=n[u||""]))}var E=r.indexOf(":");l=e.localName=0",t),i=e.substring(t+1,s);if(/[&<]/.test(i))return/^script$/i.test(n)||(i=i.replace(/&#?\w+;/g,r)),o.characters(i,0,i.length),s}return t+1}function b(e,t,n,r){var o=r[n];return null==o&&((o=e.lastIndexOf(""))",t+9);return n.startCDATA(),n.characters(e,t+9,o-t-9),n.endCDATA(),o+3}var s=function(e,t){var n,r=[],o=/'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;o.lastIndex=t,o.exec(e);for(;n=o.exec(e);)if(r.push(n),n[1])return r}(e,t),i=s.length;if(1",t);if(r){var o=e.substring(t,r).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);if(o){o[0].length;return n.processingInstruction(o[1],o[2]),r+2}return-1}return-1}function G(e){}function i(e,t){return e.__proto__=t,e}s.prototype={parse:function(e,t,n){var r=this.domBuilder;r.startDocument(),S(t,t={}),function(n,e,r,o,s){function i(e){var t=e.slice(1,-1);return t in r?r[t]:"#"===t.charAt(0)?function(e){{if(65535>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}}(parseInt(t.substr(1).replace("x","0x"))):(s.error("entity not found:"+e),e)}function t(e){if(p",f+3),S=n.substring(f+2,C),T=E.pop();C<0?(S=n.substring(f+2).replace(/[\s<].*/,""),s.error("end tag name: "+S+" is not complete:"+T.tagName),C=f+1+S.length):S.match(/\s