UNPKG

qn-im-sdk

Version:

QnzsIM SDK

3 lines (2 loc) 50.5 kB
var e,n,t,r=/*#__PURE__*/function(){function e(){this.events=void 0,this.events={}}var n=e.prototype;return n.emit=function(e,n){return this.events[e]&&this.events[e].forEach(function(e){return e(n)}),this},n.on=function(e,n){return this.events[e]?this.events[e].push(n):this.events[e]=[n],this},n.off=function(e,n){if(e&&"function"==typeof n){var t=this.events[e],r=t.findIndex(function(e){return e===n});t.splice(r,1)}else this.events[e]=[];return this},e}();function o(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function s(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return o(e,n);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},i.apply(null,arguments)}function u(e,n){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,n){return e.__proto__=n,e},u(e,n)}exports.RequestFunc=void 0,(e=exports.RequestFunc||(exports.RequestFunc={})).INITSDK="InitSDK",e.LOGIN="Login",e.LOGOUT="Logout",e.GETLOGINSTATUS="GetLoginStatus",e.GETLOGINUSER="GetLoginUser",e.GETSELFUSERINFO="GetSelfUserInfo",e.CREATETEXTMESSAGE="CreateTextMessage",e.CREATETEXTATMESSAGE="CreateTextAtMessage",e.CREATEADVANCEDTEXTMESSAGE="CreateAdvancedTextMessage",e.CREATEIMAGEMESSAGEFROMBYURL="CreateImageMessageByURL",e.CREATESOUNDMESSAGEBYURL="CreateSoundMessageByURL",e.CREATEVIDEOMESSAGEBYURL="CreateVideoMessageByURL",e.CREATEFILEMESSAGEBYURL="CreateFileMessageByURL",e.CREATEIMAGEMESSAGEFROMFULLPATH="CreateImageMessageFromFullPath",e.CREATESOUNDMESSAGEFROMFULLPATH="CreateSoundMessageFromFullPath",e.CREATEVIDEOMESSAGEFROMFULLPATH="CreateVideoMessageFromFullPath",e.CREATEFILEMESSAGEFROMFULLPATH="CreateFileMessageFromFullPath",e.CREATELOCATIONMESSAGE="CreateLocationMessage",e.CREATECUSTOMMESSAGE="CreateCustomMessage",e.CREATEMERGERMESSAGE="CreateMergerMessage",e.CREATEFORWARDMESSAGE="CreateForwardMessage",e.CREATEQUOTEMESSAGE="CreateQuoteMessage",e.CREATEADVANCEDQUOTEMESSAGE="CreateAdvancedQuoteMessage",e.CREATECARDMESSAGE="CreateCardMessage",e.CREATEFACEMESSAGE="CreateFaceMessage",e.SENDMESSAGE="SendMessage",e.SENDMESSAGENOTOSS="SendMessageNotOss",e.GETHISTORYMESSAGELIST="GetHistoryMessageList",e.GETADVANCEDHISTORYMESSAGELIST="GetAdvancedHistoryMessageList",e.GETHISTORYMESSAGELISTREVERSE="GetHistoryMessageListReverse",e.REVOKEMESSAGE="RevokeMessage",e.SETONECONVERSATIONPRIVATECHAT="SetOneConversationPrivateChat",e.DELETEMESSAGEFROMLOCALSTORAGE="DeleteMessageFromLocalStorage",e.DELETEMESSAGEFROMLOCALANDSVR="DeleteMessageFromLocalAndSvr",e.DELETECONVERSATIONFROMLOCALANDSVR="DeleteConversationFromLocalAndSvr",e.DELETEALLCONVERSATIONFROMLOCAL="DeleteAllConversationFromLocal",e.DELETEALLMSGFROMLOCALANDSVR="DeleteAllMsgFromLocalAndSvr",e.DELETEALLMSGFROMLOCAL="DeleteAllMsgFromLocal",e.MARKSINGLEMESSAGEHASREAD="MarkSingleMessageHasRead",e.INSERTSINGLEMESSAGETOLOCALSTORAGE="InsertSingleMessageToLocalStorage",e.INSERTGROUPMESSAGETOLOCALSTORAGE="InsertGroupMessageToLocalStorage",e.TYPINGSTATUSUPDATE="TypingStatusUpdate",e.MARKC2CMESSAGEASREAD="MarkC2CMessageAsRead",e.MARKMESSAGEASREADBYCONID="MarkMessageAsReadByConID",e.CLEARC2CHISTORYMESSAGE="ClearC2CHistoryMessage",e.CLEARC2CHISTORYMESSAGEFROMLOCALANDSVR="ClearC2CHistoryMessageFromLocalAndSvr",e.CLEARGROUPHISTORYMESSAGE="ClearGroupHistoryMessage",e.CLEARGROUPHISTORYMESSAGEFROMLOCALANDSVR="ClearGroupHistoryMessageFromLocalAndSvr",e.ADDFRIEND="AddFriend",e.SEARCHFRIENDS="SearchFriends",e.GETDESIGNATEDFRIENDSINFO="GetDesignatedFriendsInfo",e.GETRECVFRIENDAPPLICATIONLIST="GetRecvFriendApplicationList",e.GETSENDFRIENDAPPLICATIONLIST="GetSendFriendApplicationList",e.GETFRIENDLIST="GetFriendList",e.SETFRIENDREMARK="SetFriendRemark",e.ADDBLACK="AddBlack",e.GETBLACKLIST="GetBlackList",e.REMOVEBLACK="RemoveBlack",e.CHECKFRIEND="CheckFriend",e.ACCEPTFRIENDAPPLICATION="AcceptFriendApplication",e.REFUSEFRIENDAPPLICATION="RefuseFriendApplication",e.DELETEFRIEND="DeleteFriend",e.GETUSERSINFO="GetUsersInfo",e.SETSELFINFO="SetSelfInfo",e.GETALLCONVERSATIONLIST="GetAllConversationList",e.GETCONVERSATIONLISTSPLIT="GetConversationListSplit",e.GETONECONVERSATION="GetOneConversation",e.GETCONVERSATIONIDBYSESSIONTYPE="GetConversationIDBySessionType",e.GETMULTIPLECONVERSATION="GetMultipleConversation",e.DELETECONVERSATION="DeleteConversation",e.SETCONVERSATIONDRAFT="SetConversationDraft",e.PINCONVERSATION="PinConversation",e.GETTOTALUNREADMSGCOUNT="GetTotalUnreadMsgCount",e.GETCONVERSATIONRECVMESSAGEOPT="GetConversationRecvMessageOpt",e.SETCONVERSATIONRECVMESSAGEOPT="SetConversationRecvMessageOpt",e.SEARCHLOCALMESSAGES="SearchLocalMessages",e.MARKGROUPMESSAGEHASREAD="MarkGroupMessageHasRead",e.MARKGROUPMESSAGEASREAD="MarkGroupMessageAsRead",e.INVITEUSERTOGROUP="InviteUserToGroup",e.KICKGROUPMEMBER="KickGroupMember",e.GETGROUPMEMBERSINFO="GetGroupMembersInfo",e.GETGROUPMEMBERLIST="GetGroupMemberList",e.GETGROUPMEMBERLISTBYJOINTIMEFILTER="GetGroupMemberListByJoinTimeFilter",e.SEARCHGROUPMEMBERS="SearchGroupMembers",e.SETGROUPAPPLYMEMBERFRIEND="SetGroupApplyMemberFriend",e.SETGROUPLOOKMEMBERINFO="SetGroupLookMemberInfo",e.GETJOINEDGROUPLIST="GetJoinedGroupList",e.CREATEGROUP="CreateGroup",e.SETGROUPINFO="SetGroupInfo",e.SETGROUPMEMBERNICKNAME="SetGroupMemberNickname",e.GETGROUPSINFO="GetGroupsInfo",e.JOINGROUP="JoinGroup",e.SEARCHGROUPS="SearchGroups",e.QUITGROUP="QuitGroup",e.DISMISSGROUP="DismissGroup",e.CHANGEGROUPMUTE="ChangeGroupMute",e.CHANGEGROUPMEMBERMUTE="ChangeGroupMemberMute",e.TRANSFERGROUPOWNER="TransferGroupOwner",e.GETSENDGROUPAPPLICATIONLIST="GetSendGroupApplicationList",e.GETRECVGROUPAPPLICATIONLIST="GetRecvGroupApplicationList",e.ACCEPTGROUPAPPLICATION="AcceptGroupApplication",e.REFUSEGROUPAPPLICATION="RefuseGroupApplication",e.SIGNAL_INGINVITE="SignalingInvite",e.SIGNALINGINVITEINGROUP="SignalingInviteInGroup",e.SIGNALINGACCEPT="SignalingAccept",e.SIGNALINGREJECT="SignalingReject",e.SIGNALINGCANCEL="SignalingCancel",e.SIGNALINGHUNGUP="SignalingHungUp",e.GETSUBDEPARTMENT="GetSubDepartment",e.GETDEPARTMENTMEMBER="GetDepartmentMember",e.GETUSERINDEPARTMENT="GetUserInDepartment",e.GETDEPARTMENTMEMBERANDSUBDEPARTMENT="GetDepartmentMemberAndSubDepartment",e.GETDEPARTMENTINFO="GetDepartmentInfo",e.SEARCHORGANIZATION="SearchOrganization",e.RESETCONVERSATIONGROUPATTYPE="ResetConversationGroupAtType",e.SETGROUPMEMBERROLELEVEL="SetGroupMemberRoleLevel",e.SETGROUPVERIFICATION="SetGroupVerification",e.SETGLOBALRECVMESSAGEOPT="SetGlobalRecvMessageOpt",e.NEWREVOKEMESSAGE="NewRevokeMessage",e.FINDMESSAGELIST="FindMessageList",exports.CbEvents=void 0,(n=exports.CbEvents||(exports.CbEvents={})).ONCONNECTFAILED="OnConnectFailed",n.ONCONNECTSUCCESS="OnConnectSuccess",n.ONCONNECTING="OnConnecting",n.ONKICKEDOFFLINE="OnKickedOffline",n.ONSELFINFOUPDATED="OnSelfInfoUpdated",n.ONUSERTOKENEXPIRED="OnUserTokenExpired",n.ONPROGRESS="OnProgress",n.ONRECVNEWMESSAGE="OnRecvNewMessage",n.ONRECVNEWMESSAGES="OnRecvNewMessages",n.ONRECVMESSAGEREVOKED="OnRecvMessageRevoked",n.ONRECVC2CREADRECEIPT="OnRecvC2CReadReceipt",n.ONRECVGROUPREADRECEIPT="OnRecvGroupReadReceipt",n.ONCONVERSATIONCHANGED="OnConversationChanged",n.ONNEWCONVERSATION="OnNewConversation",n.ONSYNCSERVERFAILED="OnSyncServerFailed",n.ONSYNCSERVERFINISH="OnSyncServerFinish",n.ONSYNCSERVERSTART="OnSyncServerStart",n.ONTOTALUNREADMESSAGECOUNTCHANGED="OnTotalUnreadMessageCountChanged",n.ONBLACKADDED="OnBlackAdded",n.ONBLACKDELETED="OnBlackDeleted",n.ONFRIENDAPPLICATIONACCEPTED="OnFriendApplicationAccepted",n.ONFRIENDAPPLICATIONADDED="OnFriendApplicationAdded",n.ONFRIENDAPPLICATIONDELETED="OnFriendApplicationDeleted",n.ONFRIENDAPPLICATIONREJECTED="OnFriendApplicationRejected",n.ONFRIENDINFOCHANGED="OnFriendInfoChanged",n.ONFRIENDADDED="OnFriendAdded",n.ONFRIENDDELETED="OnFriendDeleted",n.ONJOINEDGROUPADDED="OnJoinedGroupAdded",n.ONJOINEDGROUPDELETED="OnJoinedGroupDeleted",n.ONGROUPMEMBERADDED="OnGroupMemberAdded",n.ONGROUPMEMBERDELETED="OnGroupMemberDeleted",n.ONGROUPAPPLICATIONADDED="OnGroupApplicationAdded",n.ONGROUPAPPLICATIONDELETED="OnGroupApplicationDeleted",n.ONGROUPINFOCHANGED="OnGroupInfoChanged",n.ONGROUPMEMBERINFOCHANGED="OnGroupMemberInfoChanged",n.ONGROUPAPPLICATIONACCEPTED="OnGroupApplicationAccepted",n.ONGROUPAPPLICATIONREJECTED="OnGroupApplicationRejected",n.ONRECEIVENEWINVITATION="OnReceiveNewInvitation",n.ONINVITEEACCEPTED="OnInviteeAccepted",n.ONINVITEEREJECTED="OnInviteeRejected",n.ONINVITATIONCANCELLED="OnInvitationCancelled",n.ONHANGUP="OnHangUp",n.ONINVITATIONTIMEOUT="OnInvitationTimeout",n.ONINVITEEACCEPTEDBYOTHERDEVICE="OnInviteeAcceptedByOtherDevice",n.ONINVITEEREJECTEDBYOTHERDEVICE="OnInviteeRejectedByOtherDevice",n.ONORGANIZATIONUPDATED="OnOrganizationUpdated",n.ONRECVNEWMESSAGEFROMOTHERWEB="OnRecvNewMessageFromOtherWeb",n.ONNEWRECVMESSAGEREVOKED="OnNewRecvMessageRevoked",n.ONSENSITIVEWORDBLOCKED="OnSensitiveWordBlocked",function(e){e[e.UPLOAD_RATE_LIMIT=10001]="UPLOAD_RATE_LIMIT",e[e.SENSITIVE_WORD_BLOCKED=10002]="SENSITIVE_WORD_BLOCKED"}(t||(t={}));var a=function(e){try{e&&e.terminate()}catch(e){console.log(e)}},c=function(e){return(36*Math.random()).toString(36).slice(2)+(new Date).getTime().toString()+e},E=/*#__PURE__*/function(){function e(){this.userUploadRecords=new Map,this.UPLOAD_LIMIT=6,this.TIME_WINDOW=6e4,this.PENDING_EXPIRE_TIME=6e4}e.getInstance=function(){return e.instance||(e.instance=new e),e.instance};var n=e.prototype;return n.checkUploadLimit=function(e){var n=this,t=Date.now(),r=this.userUploadRecords.get(e);return r||(r={timestamps:[],pendingUploads:new Map},this.userUploadRecords.set(e,r)),r.timestamps=r.timestamps.filter(function(e){return t-e<n.TIME_WINDOW}),r.timestamps.length>=this.UPLOAD_LIMIT?(console.log("[UploadRateLimit] 用户 "+e+" 上传次数已达限制: "+r.timestamps.length+"/"+this.UPLOAD_LIMIT),!1):(r.timestamps.push(t),console.log("[UploadRateLimit] 用户 "+e+" 上传记录: "+r.timestamps.length+"/"+this.UPLOAD_LIMIT),!0)},n.checkLimit=function(e){var n=this,t=Date.now(),r=this.userUploadRecords.get(e);r||(r={timestamps:[],pendingUploads:new Map},this.userUploadRecords.set(e,r)),r.timestamps=r.timestamps.filter(function(e){return t-e<n.TIME_WINDOW});for(var o,i=s(r.pendingUploads.entries());!(o=i()).done;){var u=o.value;t-u[1]>this.TIME_WINDOW&&r.pendingUploads.delete(u[0])}var a=r.timestamps.length+r.pendingUploads.size;return!(a>=this.UPLOAD_LIMIT&&(console.log("[UploadRateLimit] 用户 "+e+" 达到限制: 实际"+r.timestamps.length+" + 预占"+r.pendingUploads.size+" = "+a+"/"+this.UPLOAD_LIMIT),1))},n.recordUpload=function(e,n){var t=Date.now(),r=this.userUploadRecords.get(e);r||(r={timestamps:[],pendingUploads:new Map},this.userUploadRecords.set(e,r)),n?(r.pendingUploads.set(n,t),console.log("[UploadRateLimit] 用户 "+e+" 预占用配额,token: "+n)):r.timestamps.push(t)},n.releaseQuota=function(e,n){var t=this.userUploadRecords.get(e);t&&t.pendingUploads.has(n)&&(t.pendingUploads.delete(n),console.log("[UploadRateLimit] 用户 "+e+" 释放配额,token: "+n))},n.getRemainingTime=function(e){var n=this,t=Date.now(),r=this.userUploadRecords.get(e);if(!r)return 0;for(var o,i=[].concat(r.timestamps),u=s(r.pendingUploads.entries());!(o=u()).done;)i.push(o.value[1]);var a=i.filter(function(e){return t-e<n.TIME_WINDOW});return a.length<this.UPLOAD_LIMIT?0:(a.sort(function(e,n){return e-n}),Math.max(0,this.TIME_WINDOW-(t-a[a.length-this.UPLOAD_LIMIT])))},n.clearUserRecord=function(e){this.userUploadRecords.delete(e)},n.clearAllRecords=function(){this.userUploadRecords.clear()},e}();E.instance=void 0;var d=E.getInstance(),I=["乱伦","春药","疆独","藏独","暴动","毛片","军火","针孔","女优","肉棍","反华","反共","换妻","偷拍","露点","走光","共奴","乱交","鸡巴","露毛","肉棒","龟头","冰毒","迷药","性奴","暴政","婊子","法+輪+功","干 你 妈","草你妈","老 婊 子","蒙-汗-药","迷-魂-药","迷魂药","迷昏药","江泽民","胡锦涛","习近平","毛泽东","李克强"],S=new(/*#__PURE__*/function(){function e(){this.words=[],this.mode=2,this.loadWords(I)}var n=e.prototype;return n.loadWords=function(e){this.words=e},n.setMode=function(e){this.mode=e},n.getMode=function(){return this.mode},n.detect=function(e){for(var n,t=[],r=s(this.words);!(n=r()).done;){var o=n.value;e.includes(o)&&t.push(o)}return{hasSensitive:t.length>0,words:t}},n.replace=function(e){for(var n,t=e,r=s(this.words);!(n=r()).done;){var o=n.value,i="*".repeat(o.length),u=new RegExp(o,"g");t=t.replace(u,i)}return t},n.filter=function(e){return this.detect(e).hasSensitive?1===this.mode?{success:!0,content:this.replace(e)}:{success:!1,content:e,message:"该消息有敏感词被屏蔽"}:{success:!0,content:e}},e}());function R(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}exports.QnzsIMSDK=/*#__PURE__*/function(e){function n(){var n;return(n=e.call(this)||this).ws=void 0,n.uid=void 0,n.token=void 0,n.platform="web",n.wsUrl="",n.lock=!1,n.logoutFlag=!1,n.ws2promise={},n.onceFlag=!0,n.timer=void 0,n.lastTime=0,n.heartbeatCount=0,n.heartbeatStartTime=0,n.platformID=0,n.isBatch=!1,n.worker=null,n.checkUploadPermission=function(e){return new Promise(function(r,o){var s=e||c(n.uid);if(!d.checkLimit(n.uid||""))return n.emitUploadLimitMessage(s),void o({event:"checkUploadPermission",errCode:t.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:{allowed:!1,reason:"rate_limit",remainingTime:d.getRemainingTime(n.uid||"")},operationID:s});var i=s;d.recordUpload(n.uid||"",i),r({event:"checkUploadPermission",errCode:0,errMsg:"",data:{allowed:!0,uploadToken:i,expiresIn:6e4},operationID:s})})},n.releaseUploadQuota=function(e){d.releaseQuota(n.uid||"",e)},n.getLoginStatus=function(e){return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.GETLOGINSTATUS,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},n.getLoginUser=function(e){return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.GETLOGINUSER,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},n.getSelfUserInfo=function(e){return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.GETSELFUSERINFO,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},n.getUsersInfo=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETUSERSINFO,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.setSelfInfo=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SETSELFINFO,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.createTextMessage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.CREATETEXTMESSAGE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.createTextAtMessage=function(e,t){return new Promise(function(r,o){var s=i({},e);s.atUserIDList=JSON.stringify(s.atUserIDList),s.atUsersInfo=JSON.stringify(s.atUsersInfo);var u=t||c(n.uid),a={reqFuncName:exports.RequestFunc.CREATETEXTATMESSAGE,operationID:u,userID:n.uid,data:s};n.wsSend(a,r,o)})},n.createAdvancedTextMessage=function(e,t){return new Promise(function(r,o){var s=i({},e);s.messageEntityList=JSON.stringify(s.messageEntityList);var u=t||c(n.uid),a={reqFuncName:exports.RequestFunc.CREATEADVANCEDTEXTMESSAGE,operationID:u,userID:n.uid,data:s};n.wsSend(a,r,o)})},n.createImageMessage=function(e,r){return new Promise(function(o,s){var u=r||c(n.uid);if(!d.checkUploadLimit(n.uid||"unknown"))return n.emitUploadLimitMessage(u),void s({event:exports.RequestFunc.CREATEIMAGEMESSAGEFROMBYURL,errCode:t.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:u});var a=i({},e);a.bigPicture=JSON.stringify(a.bigPicture),a.snapshotPicture=JSON.stringify(a.snapshotPicture),a.sourcePicture=JSON.stringify(a.sourcePicture);var E={reqFuncName:exports.RequestFunc.CREATEIMAGEMESSAGEFROMBYURL,operationID:u,userID:n.uid,data:JSON.stringify(a)};n.wsSend(E,o,s)})},n.createSoundMessage=function(e,r){return new Promise(function(o,s){var i=r||c(n.uid);if(!d.checkUploadLimit(n.uid||"unknown"))return n.emitUploadLimitMessage(i),void s({event:exports.RequestFunc.CREATESOUNDMESSAGEBYURL,errCode:t.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:i});var u={soundBaseInfo:JSON.stringify(e)},a={reqFuncName:exports.RequestFunc.CREATESOUNDMESSAGEBYURL,operationID:i,userID:n.uid,data:JSON.stringify(u)};n.wsSend(a,o,s)})},n.createVideoMessage=function(e,r){return new Promise(function(o,s){var i=r||c(n.uid);if(!d.checkUploadLimit(n.uid||"unknown"))return n.emitUploadLimitMessage(i),void s({event:exports.RequestFunc.CREATEVIDEOMESSAGEBYURL,errCode:t.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:i});var u={videoBaseInfo:JSON.stringify(e)},a={reqFuncName:exports.RequestFunc.CREATEVIDEOMESSAGEBYURL,operationID:i,userID:n.uid,data:JSON.stringify(u)};n.wsSend(a,o,s)})},n.createFileMessage=function(e,r){return new Promise(function(o,s){var i=r||c(n.uid);if(!d.checkUploadLimit(n.uid||"unknown"))return n.emitUploadLimitMessage(i),void s({event:exports.RequestFunc.CREATEFILEMESSAGEBYURL,errCode:t.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:i});var u={fileBaseInfo:JSON.stringify(e)},a={reqFuncName:exports.RequestFunc.CREATEFILEMESSAGEBYURL,operationID:i,userID:n.uid,data:JSON.stringify(u)};n.wsSend(a,o,s)})},n.createFileMessageFromFullPath=function(e,r){return new Promise(function(o,s){var i=r||c(n.uid);if(!d.checkUploadLimit(n.uid||"unknown"))return n.emitUploadLimitMessage(i),void s({event:exports.RequestFunc.CREATEFILEMESSAGEFROMFULLPATH,errCode:t.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:i});var u={reqFuncName:exports.RequestFunc.CREATEFILEMESSAGEFROMFULLPATH,operationID:i,userID:n.uid,data:e};n.wsSend(u,o,s)})},n.createImageMessageFromFullPath=function(e,r){return new Promise(function(o,s){var i=r||c(n.uid);if(!d.checkUploadLimit(n.uid||"unknown"))return n.emitUploadLimitMessage(i),void s({event:exports.RequestFunc.CREATEIMAGEMESSAGEFROMFULLPATH,errCode:t.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:i});var u={reqFuncName:exports.RequestFunc.CREATEIMAGEMESSAGEFROMFULLPATH,operationID:i,userID:n.uid,data:e};n.wsSend(u,o,s)})},n.createSoundMessageFromFullPath=function(e,r){return new Promise(function(o,s){var i=r||c(n.uid);if(!d.checkUploadLimit(n.uid||"unknown"))return n.emitUploadLimitMessage(i),void s({event:exports.RequestFunc.CREATESOUNDMESSAGEFROMFULLPATH,errCode:t.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:i});var u={reqFuncName:exports.RequestFunc.CREATESOUNDMESSAGEFROMFULLPATH,operationID:i,userID:n.uid,data:e};n.wsSend(u,o,s)})},n.createVideoMessageFromFullPath=function(e,r){return new Promise(function(o,s){var i=r||c(n.uid);if(!d.checkUploadLimit(n.uid||"unknown"))return n.emitUploadLimitMessage(i),void s({event:exports.RequestFunc.CREATEVIDEOMESSAGEFROMFULLPATH,errCode:t.UPLOAD_RATE_LIMIT,errMsg:"上传超过时间限制次数",data:"",operationID:i});var u={reqFuncName:exports.RequestFunc.CREATEVIDEOMESSAGEFROMFULLPATH,operationID:i,userID:n.uid,data:e};n.wsSend(u,o,s)})},n.createMergerMessage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),u=i({},e);u.messageList=JSON.stringify(e.messageList),u.summaryList=JSON.stringify(e.summaryList);var a={reqFuncName:exports.RequestFunc.CREATEMERGERMESSAGE,operationID:s,userID:n.uid,data:u};n.wsSend(a,r,o)})},n.createForwardMessage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.CREATEFORWARDMESSAGE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.createFaceMessage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.CREATEFACEMESSAGE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.createLocationMessage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.CREATELOCATIONMESSAGE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.createCustomMessage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.CREATECUSTOMMESSAGE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.createQuoteMessage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.CREATEQUOTEMESSAGE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.createAdvancedQuoteMessage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),u=i({},e);u.messageEntityList=JSON.stringify(u.messageEntityList);var a={reqFuncName:exports.RequestFunc.CREATEADVANCEDQUOTEMESSAGE,operationID:s,userID:n.uid,data:u};n.wsSend(a,r,o)})},n.createCardMessage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.CREATECARDMESSAGE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.sendMessage=function(e,r){return new Promise(function(o,s){var u=r||c(n.uid),a=i({},e);try{var E=JSON.parse(e.message);if([101,106,114,117].includes(E.contentType)&&E.content){var d=S.filter(E.content);if(!d.success){var I=S.detect(E.content);console.log("[IM SDK] 检测到敏感词,阻止发送:",I.words);var R={clientMsgID:"system_"+Date.now()+"_"+Math.random().toString(36).substr(2,9),serverMsgID:"",createTime:Date.now(),sendTime:Date.now(),contentType:101,content:"[系统提示] 该消息有敏感词被屏蔽",senderUserID:"system",senderNickname:"系统提示",recvID:e.recvID,groupID:e.groupID,status:1,isRead:!0,msgFrom:100,attachedInfo:"",ex:"",localEx:JSON.stringify({isSensitiveWordBlocked:!0,blockedWords:I.words,originalContent:E.content})};setTimeout(function(){n.emit(exports.CbEvents.ONRECVNEWMESSAGE,{event:exports.CbEvents.ONRECVNEWMESSAGE,errCode:0,errMsg:"",data:R,operationID:u})},0),n.emit(exports.CbEvents.ONSENSITIVEWORDBLOCKED,{originalMessage:E,blockedWords:I.words,recvID:e.recvID,groupID:e.groupID});var p={event:exports.RequestFunc.SENDMESSAGE,errCode:t.SENSITIVE_WORD_BLOCKED,errMsg:d.message||"该消息有敏感词被屏蔽",data:"",operationID:u};return console.log("[IM SDK] 返回敏感词错误:",p),void s(p)}d.content!==E.content&&(console.log("[IM SDK] 敏感词已替换"),E.content=d.content,a.message=JSON.stringify(E))}}catch(e){console.error("[IM SDK] 解析消息内容失败:",e)}a.offlinePushInfo=a.offlinePushInfo?JSON.stringify(e.offlinePushInfo):"";var D={reqFuncName:exports.RequestFunc.SENDMESSAGE,operationID:u,userID:n.uid,data:a};n.wsSend(D,o,s)})},n.sendMessageNotOss=function(e,r){return new Promise(function(o,s){var u=r||c(n.uid),a=i({},e);try{var E=JSON.parse(e.message);if([101,106,114,117].includes(E.contentType)&&E.content){var d=S.filter(E.content);if(!d.success){var I=S.detect(E.content);console.log("[IM SDK] 检测到敏感词,阻止发送:",I.words);var R={clientMsgID:"system_"+Date.now()+"_"+Math.random().toString(36).substr(2,9),serverMsgID:"",createTime:Date.now(),sendTime:Date.now(),contentType:101,content:"[系统提示] 该消息有敏感词被屏蔽",senderUserID:"system",senderNickname:"系统提示",recvID:e.recvID,groupID:e.groupID,status:1,isRead:!0,msgFrom:100,attachedInfo:"",ex:"",localEx:JSON.stringify({isSensitiveWordBlocked:!0,blockedWords:I.words,originalContent:E.content})};setTimeout(function(){n.emit(exports.CbEvents.ONRECVNEWMESSAGE,{event:exports.CbEvents.ONRECVNEWMESSAGE,errCode:0,errMsg:"",data:R,operationID:u})},0),n.emit(exports.CbEvents.ONSENSITIVEWORDBLOCKED,{originalMessage:E,blockedWords:I.words,recvID:e.recvID,groupID:e.groupID});var p={event:exports.RequestFunc.SENDMESSAGENOTOSS,errCode:t.SENSITIVE_WORD_BLOCKED,errMsg:d.message||"该消息有敏感词被屏蔽",data:"",operationID:u};return console.log("[IM SDK] 返回敏感词错误:",p),void s(p)}d.content!==E.content&&(console.log("[IM SDK] 敏感词已替换"),E.content=d.content,a.message=JSON.stringify(E))}}catch(e){console.error("[IM SDK] 解析消息内容失败:",e)}a.offlinePushInfo=a.offlinePushInfo?JSON.stringify(e.offlinePushInfo):"";var D={reqFuncName:exports.RequestFunc.SENDMESSAGENOTOSS,operationID:u,userID:n.uid,data:a};n.wsSend(D,o,s)})},n.getHistoryMessageList=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETHISTORYMESSAGELIST,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getAdvancedHistoryMessageList=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETADVANCEDHISTORYMESSAGELIST,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getHistoryMessageListReverse=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETHISTORYMESSAGELISTREVERSE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.revokeMessage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.REVOKEMESSAGE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.setOneConversationPrivateChat=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SETONECONVERSATIONPRIVATECHAT,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.deleteMessageFromLocalStorage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.DELETEMESSAGEFROMLOCALSTORAGE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.deleteMessageFromLocalAndSvr=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.DELETEMESSAGEFROMLOCALANDSVR,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.deleteConversationFromLocalAndSvr=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.DELETECONVERSATIONFROMLOCALANDSVR,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.deleteAllConversationFromLocal=function(e){return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.DELETEALLCONVERSATIONFROMLOCAL,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},n.deleteAllMsgFromLocal=function(e){return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.DELETEALLMSGFROMLOCAL,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},n.deleteAllMsgFromLocalAndSvr=function(e){return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.DELETEALLMSGFROMLOCALANDSVR,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},n.markGroupMessageHasRead=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.MARKGROUPMESSAGEHASREAD,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.markGroupMessageAsRead=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),u=i({},e);u.msgIDList=JSON.stringify(u.msgIDList);var a={reqFuncName:exports.RequestFunc.MARKGROUPMESSAGEASREAD,operationID:s,userID:n.uid,data:u};n.wsSend(a,r,o)})},n.insertSingleMessageToLocalStorage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.INSERTSINGLEMESSAGETOLOCALSTORAGE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.insertGroupMessageToLocalStorage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.INSERTGROUPMESSAGETOLOCALSTORAGE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.typingStatusUpdate=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.TYPINGSTATUSUPDATE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.markC2CMessageAsRead=function(e,t){return new Promise(function(r,o){var s=i({},e);s.msgIDList=JSON.stringify(s.msgIDList);var u=t||c(n.uid),a={reqFuncName:exports.RequestFunc.MARKC2CMESSAGEASREAD,operationID:u,userID:n.uid,data:s};n.wsSend(a,r,o)})},n.markNotifyMessageHasRead=function(e,t){n.markMessageAsReadByConID({conversationID:e,msgIDList:[]})},n.markMessageAsReadByConID=function(e,t){return new Promise(function(r,o){var s=i({},e);s.msgIDList=JSON.stringify(s.msgIDList);var u=t||c(n.uid),a={reqFuncName:exports.RequestFunc.MARKMESSAGEASREADBYCONID,operationID:u,userID:n.uid,data:s};n.wsSend(a,r,o)})},n.clearC2CHistoryMessage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.CLEARC2CHISTORYMESSAGE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.clearC2CHistoryMessageFromLocalAndSvr=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.CLEARC2CHISTORYMESSAGEFROMLOCALANDSVR,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.clearGroupHistoryMessage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.CLEARGROUPHISTORYMESSAGE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.clearGroupHistoryMessageFromLocalAndSvr=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.CLEARGROUPHISTORYMESSAGEFROMLOCALANDSVR,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getAllConversationList=function(e){return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.GETALLCONVERSATIONLIST,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},n.getConversationListSplit=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETCONVERSATIONLISTSPLIT,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getOneConversation=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETONECONVERSATION,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getConversationIDBySessionType=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETCONVERSATIONIDBYSESSIONTYPE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getMultipleConversation=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETMULTIPLECONVERSATION,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.deleteConversation=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.DELETECONVERSATION,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.setConversationDraft=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SETCONVERSATIONDRAFT,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.pinConversation=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.PINCONVERSATION,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getTotalUnreadMsgCount=function(e){return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.GETTOTALUNREADMSGCOUNT,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},n.getConversationRecvMessageOpt=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETCONVERSATIONRECVMESSAGEOPT,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.setConversationRecvMessageOpt=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),u=i({},e);u.conversationIDList=JSON.stringify(e.conversationIDList);var a={reqFuncName:exports.RequestFunc.SETCONVERSATIONRECVMESSAGEOPT,operationID:s,userID:n.uid,data:u};n.wsSend(a,r,o)})},n.searchLocalMessages=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SEARCHLOCALMESSAGES,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.addFriend=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.ADDFRIEND,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.searchFriends=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SEARCHFRIENDS,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getDesignatedFriendsInfo=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETDESIGNATEDFRIENDSINFO,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getRecvFriendApplicationList=function(e){return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.GETRECVFRIENDAPPLICATIONLIST,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},n.getSendFriendApplicationList=function(e){return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.GETSENDFRIENDAPPLICATIONLIST,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},n.getFriendList=function(e){return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.GETFRIENDLIST,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},n.setFriendRemark=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SETFRIENDREMARK,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.checkFriend=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.CHECKFRIEND,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.acceptFriendApplication=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.ACCEPTFRIENDAPPLICATION,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.refuseFriendApplication=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.REFUSEFRIENDAPPLICATION,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.deleteFriend=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.DELETEFRIEND,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.addBlack=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.ADDBLACK,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.removeBlack=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.REMOVEBLACK,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getBlackList=function(e){return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.GETBLACKLIST,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},n.inviteUserToGroup=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),u=i({},e);u.userIDList=JSON.stringify(u.userIDList);var a={reqFuncName:exports.RequestFunc.INVITEUSERTOGROUP,operationID:s,userID:n.uid,data:u};n.wsSend(a,r,o)})},n.kickGroupMember=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),u=i({},e);u.userIDList=JSON.stringify(u.userIDList);var a={reqFuncName:exports.RequestFunc.KICKGROUPMEMBER,operationID:s,userID:n.uid,data:u};n.wsSend(a,r,o)})},n.getGroupMembersInfo=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),u=i({},e);u.userIDList=JSON.stringify(u.userIDList);var a={reqFuncName:exports.RequestFunc.GETGROUPMEMBERSINFO,operationID:s,userID:n.uid,data:u};n.wsSend(a,r,o)})},n.getGroupMemberList=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETGROUPMEMBERLIST,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getGroupMemberListByJoinTimeFilter=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),u=i({},e);u.filterUserIDList=JSON.stringify(u.filterUserIDList);var a={reqFuncName:exports.RequestFunc.GETGROUPMEMBERLISTBYJOINTIMEFILTER,operationID:s,userID:n.uid,data:u};n.wsSend(a,r,o)})},n.searchGroupMembers=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SEARCHGROUPMEMBERS,operationID:s,userID:n.uid,data:{searchParam:JSON.stringify(e)}};n.wsSend(i,r,o)})},n.setGroupApplyMemberFriend=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SETGROUPAPPLYMEMBERFRIEND,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.setGroupLookMemberInfo=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SETGROUPLOOKMEMBERINFO,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getJoinedGroupList=function(e){return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.GETJOINEDGROUPLIST,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},n.createGroup=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),u=i({},e);u.groupBaseInfo=JSON.stringify(u.groupBaseInfo),u.memberList=JSON.stringify(u.memberList);var a={reqFuncName:exports.RequestFunc.CREATEGROUP,operationID:s,userID:n.uid,data:u};n.wsSend(a,r,o)})},n.setGroupInfo=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),u=i({},e);u.groupInfo=JSON.stringify(u.groupInfo);var a={reqFuncName:exports.RequestFunc.SETGROUPINFO,operationID:s,userID:n.uid,data:u};n.wsSend(a,r,o)})},n.setGroupMemberNickname=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SETGROUPMEMBERNICKNAME,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getGroupsInfo=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETGROUPSINFO,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.joinGroup=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.JOINGROUP,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.searchGroups=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SEARCHGROUPS,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.quitGroup=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.QUITGROUP,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.dismissGroup=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.DISMISSGROUP,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.changeGroupMute=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.CHANGEGROUPMUTE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.changeGroupMemberMute=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.CHANGEGROUPMEMBERMUTE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.transferGroupOwner=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.TRANSFERGROUPOWNER,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getSendGroupApplicationList=function(e){return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.GETSENDGROUPAPPLICATIONLIST,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},n.getRecvGroupApplicationList=function(e){return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.GETRECVGROUPAPPLICATIONLIST,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},n.acceptGroupApplication=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.ACCEPTGROUPAPPLICATION,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.refuseGroupApplication=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.REFUSEGROUPAPPLICATION,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.signalingInvite=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={};i.invitation=e;var u={reqFuncName:exports.RequestFunc.SIGNAL_INGINVITE,operationID:s,userID:n.uid,data:i};n.wsSend(u,r,o)})},n.signalingInviteInGroup=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={};i.invitation=e;var u={reqFuncName:exports.RequestFunc.SIGNALINGINVITEINGROUP,operationID:s,userID:n.uid,data:i};n.wsSend(u,r,o)})},n.signalingAccept=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SIGNALINGACCEPT,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.signalingReject=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SIGNALINGREJECT,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.signalingCancel=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SIGNALINGCANCEL,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.signalingHungUp=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SIGNALINGHUNGUP,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getSubDepartment=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETSUBDEPARTMENT,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getDepartmentMember=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETDEPARTMENTMEMBER,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getUserInDepartment=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETUSERINDEPARTMENT,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getDepartmentMemberAndSubDepartment=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETDEPARTMENTMEMBERANDSUBDEPARTMENT,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.getDepartmentInfo=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.GETDEPARTMENTINFO,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.searchOrganization=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i=e;i.input=JSON.stringify(i.input);var u={reqFuncName:exports.RequestFunc.SEARCHORGANIZATION,operationID:s,userID:n.uid,data:i};n.wsSend(u,r,o)})},n.resetConversationGroupAtType=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.RESETCONVERSATIONGROUPATTYPE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.setGroupMemberRoleLevel=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SETGROUPMEMBERROLELEVEL,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.setGroupVerification=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SETGROUPVERIFICATION,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.setGlobalRecvMessageOpt=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.SETGLOBALRECVMESSAGEOPT,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.newRevokeMessage=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.NEWREVOKEMESSAGE,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.findMessageList=function(e,t){return new Promise(function(r,o){var s=t||c(n.uid),i={reqFuncName:exports.RequestFunc.FINDMESSAGELIST,operationID:s,userID:n.uid,data:e};n.wsSend(i,r,o)})},n.wsSend=function(e,t,r){var o,s,i;if(null==(o=window)||!o.navigator||window.navigator.onLine)if((null==(s=n.ws)?void 0:s.readyState)===(null==(i=n.ws)?void 0:i.OPEN)){"object"==typeof e.data&&(e.data=JSON.stringify(e.data));var u={oid:e.operationID||c(n.uid),mname:e.reqFuncName,mrsve:t,mrjet:r,flag:!1};n.ws2promise[u.oid]=u;var a=function(t){n.lastTime=(new Date).getTime();var r=JSON.parse(t.data);if(exports.CbEvents[r.event.toUpperCase()])n.emit(r.event,r);else{e.reqFuncName===exports.RequestFunc.LOGOUT&&(n.logoutFlag=!0,n.ws.close(),n.ws=void 0);var o=n.ws2promise[r.operationID];o?(0===r.errCode?o.mrsve(r):o.mrjet(r),delete n.ws2promise[r.operationID]):r.event!==exports.RequestFunc.SENDMESSAGE&&r.event!==exports.RequestFunc.SENDMESSAGENOTOSS||n.emit(exports.CbEvents.ONRECVNEWMESSAGEFROMOTHERWEB,r)}};try{"web"==n.platform?(n.ws.send(JSON.stringify(e)),n.ws.onmessage=a):(n.ws.send({data:JSON.stringify(e),success:function(e){"uni"===n.platform&&void 0!==n.ws._callbacks&&void 0!==n.ws._callbacks.message&&(n.ws._callbacks.message=[])}}),n.onceFlag&&(n.ws.onMessage(a),n.onceFlag=!1))}catch(n){return void r({event:e.reqFuncName,errCode:112,errMsg:"no ws conect...",data:"",operationID:e.operationID||""})}e.reqFuncName===exports.RequestFunc.LOGOUT&&(n.onceFlag=!0)}else r({event:e.reqFuncName,errCode:112,errMsg:"ws conecting...",data:"",operationID:e.operationID||""});else r({event:e.reqFuncName,errCode:113,errMsg:"net work error",data:"",operationID:e.operationID||""})},n.getPlatform(),n}var r,o;o=e,(r=n).prototype=Object.create(o.prototype),r.prototype.constructor=r,u(r,o);var s=n.prototype;return s.emitUploadLimitMessage=function(e){var n=this,t={clientMsgID:"system_"+Date.now()+"_"+Math.random().toString(36).substr(2,9),serverMsgID:"",createTime:Date.now(),sendTime:Date.now(),contentType:101,content:"[系统提示] 上传太频繁,每分钟最多上传6次文件",senderUserID:"system",senderNickname:"系统提示",recvID:this.uid||"",groupID:"",status:1,isRead:!0,msgFrom:100,attachedInfo:"",ex:"",localEx:JSON.stringify({isUploadLimitExceeded:!0,limitType:"file_upload",limit:6,timeWindow:60})};setTimeout(function(){n.emit(exports.CbEvents.ONRECVNEWMESSAGE,{event:exports.CbEvents.ONRECVNEWMESSAGE,errCode:0,errMsg:"",data:t,operationID:e})},0)},s.login=function(e){var n=this;return new Promise(function(t,r){var o=e.userID,s=e.token,i=e.platformID,u=e.isBatch,a=void 0!==u&&u,c=e.operationID,E=e.censorWordsUrl;n.wsUrl=e.url+"?sendID="+o+"&token="+s+"&platformID="+i,n.platformID=i;var d={userID:o,token:s},I={event:exports.RequestFunc.LOGIN,errCode:0,errMsg:"",data:"",operationID:c||""};n.createWs(function(){n.uid=o,n.token=s,n.isBatch=a,n.iLogin(d,c).then(function(e){try{var r=function(){t(e)};n.logoutFlag=!1,n.heartbeat();var o=function(){if(E){var e=R(function(){return Promise.resolve(n.loadRemoteCensorWords(E)).then(function(){})},function(e){console.warn("Failed to load remote censor words:",e)});if(e&&e.then)return e.then(function(){})}}();return Promise.resolve(o&&o.then?o.then(r):r())}catch(e){return Promise.reject(e)}}).catch(function(e){I.errCode=e.errCode,I.errMsg=e.errMsg,r(I)})},function(){I.errCode=111,I.errMsg="ws connect close...",n.logoutFlag||Object.values(n.ws2promise).forEach(function(e){return e.mrjet({event:e.mname,errCode:111,errMsg:"ws connect close...",data:"",operationID:e.oid})}),r(I)},function(e){console.log(e),I.errCode=112,I.errMsg="ws connect error...",r(I)}),n.ws||(I.errCode=112,I.errMsg="The current platform is not supported...",r(I))})},s.iLogin=function(e,n){var t=this;return new Promise(function(r,o){var s=n||c(t.uid),i={reqFuncName:exports.RequestFunc.LOGIN,operationID:s,userID:t.uid,data:e,batchMsg:t.isBatch?1:0};t.wsSend(i,r,o)})},s.logout=function(e){var n=this;return new Promise(function(t,r){var o=e||c(n.uid),s={reqFuncName:exports.RequestFunc.LOGOUT,operationID:o,userID:n.uid,data:""};n.wsSend(s,t,r)})},s.loadRemoteCensorWords=function(e){try{var n=this;return Promise.resolve(R(function(){function t(e){Array.isArray(r)&&r.length>0&&(S.loadWords(r),console.log("Loaded "+r.length+" censor words from remote"))}var r=[],o="web"===n.platform?Promise.resolve(fetch(e)).then(function(e){if(!e.ok)throw new Error("HTTP error! status: "+e.status);return Promise.resolve(e.json()).then(function(e){r=e.words||e})}):function(){if("uni"===n.platform)return Promise.resolve(uni.request({url:e,method:"GET"})).then(function(e){var n=e[0];if(n)throw n;var t=e[1].data;r=t.words||t});var t=function(){if("wx"===n.platform)return Promise.resolve(new Promise(function(n,t){wx.request({url:e,method:"GET",success:function(e){var t=e.data;n(t.words||t)},fail:t})})).then(function(e){r=e})}();return t&&t.then?t.then(function(){}):void 0}();return o&&o.then?o.then(t):t()},function(e){throw console.error("Error loading remote censor words:",e),e}))}catch(e){return Promise.reject(e)}},s.getPlatform=function(){var e=typeof WebSocket,n=typeof uni,t=typeof wx;this.platform="undefined"===e?"object"===n&&"object"!==t?"uni":"object"!==n&&"object"===t?"wx":"unknow":"web"},s.createWs=function(e,n,t){var r=this;return console.log("start createWs..."),new Promise(function(o,s){var i;null==(i=r.ws)||i.close(),r.ws=void 0;var u=function(){r.iLogin({userID:r.uid,token:r.token}).then(function(e){r.logoutFlag=!1,console.log("iLogin suc..."),r.heartbeat(),o()})};e&&(u=e);var a=function(){console.log("ws close agin:::"),r.logoutFlag||Object.values(r.ws2promise).forEach(function(e){return e.mrjet({event:e.mname,errCode:111,errMsg:"ws connect close...",data:"",operationID:e.oid})})};n&&(a=n);var c=function(){};if(t&&(c=t),"web"===r.platform)return r.ws=new WebSocket(r.wsUrl),r.ws.onclose=a,r.ws.onopen=u,void(r.ws.onerror=c);var E="uni"===r.platform?uni:wx;r.ws=E.connectSocket({url:r.wsUrl,complete:function(){}}),r.ws.onClose(a),r.ws.onOpen(u),r.ws.onError(c)})},s.reconnect=function(){var e=this;this.onceFlag||(this.onceFlag=!0),this.lock||(this.lock=!0,this.clearTimer(),this.timer=setTimeout(function(){e.createWs(),e.lock=!1},500))},s.clearTimer=function(){this.timer&&clearTimeout(this.timer)},s.heartbeat=function(){var e,n,t,r,o=this;console.log("start heartbeat..."),this.clearTimer(),this.worker&&a(this.worker);try{this.worker=(e=function(){var e,n,t,r;o.logoutFlag?o.worker&&a(o.worker):(null==(e=o.ws)?void 0:e.readyState)===(null==(n=o.ws)?void 0:n.CONNECTING)||(null==(t=o.ws)?void 0:t.readyState)===(null==(r=o.ws)?void 0:r.OPEN)?(new Date).getTime()-o.lastTime<9e3||o.getLoginStatus().catch(function(e){return o.reconnect()}):o.reconnect()},n=new Blob(["(function (e) {\n setInterval(function () {\n this.postMessage(null)\n }, 10000)\n })()"]),t=window.URL.createObjectURL(n),(r=new Worker(t)).onmessage=e,r)}catch(e){}},n}(r),exports.emitter=r,exports.uuid=c; //# sourceMappingURL=index.js.map