module.exports=function(){"function"!=typeof Array.prototype.forEach&&(Array.prototype.forEach=function(e){for(var t=0;t")),t},this.formatHtml2Text=function(e){var t=e;return t&&(t=t.replace(/ /g," "),t=t.replace(/
/g,"\n")),t},this.getStrBytes=function(e){if(null==e||void 0===e)return 0;if("string"!=typeof e)return 0;var t,n,o,r=0;for(n=0,o=e.length;n]/g,">"),e=e.replace(/"/g,""")),e},this.trimStr=function(e){return e?(e=e.toString(),e.replace(/(^\s*)|(\s*$)/g,"")):""},this.validNumber=function(e){return e=e.toString(),e.match(/(^\d{1,8}$)/g)},this.getReturnError=function(e,t){return t||(t=-100),{ActionStatus:d.FAIL,ErrorCode:t,ErrorInfo:e+"["+t+"]"}},this.replaceObject=function(e,t){for(var n in t)if(e[n])if(t[e[n]]=t[n],delete t[n],t[e[n]]instanceof Array)for(var o=t[e[n]].length,r=0;r=20){var p={EvtItems:Z,MainVersion:n.VERSION,Version:"0"};yt(p,function(e){Z=[]},function(e){Z=[]})}}}}},he=function(e){At.apiCall(u.WEB_IM,"accesslayer",{},function(t){0===t.ErrorCode&&1===t.WebImAccessLayer&&(i.FORMAL.COMMON="https://events.tim.qq.com"),e()},function(){e()})},Te=function(e,t){At.apiCall(u.OPEN_IM,"login",{State:"Online"},function(n){if(n.TinyId)V.tinyid=n.TinyId;else if(t)return void t(oe.getReturnError("TinyId is empty",-10));if(n.A2Key)V.a2=n.A2Key;else if(t)return void t(oe.getReturnError("A2Key is empty",-11));var o=["Tag_Profile_IM_Nick","Tag_Profile_IM_Image"],r={From_Account:V.identifier,To_Account:[V.identifier],LastStandardSequence:0,TagList:o};ft(r,function(t){var n,o;if(t.UserProfileItem&&t.UserProfileItem.length>0)for(var r in t.UserProfileItem)for(var i in t.UserProfileItem[r].ProfileItem)switch(t.UserProfileItem[r].ProfileItem[i].Tag){case"Tag_Profile_IM_Nick":n=t.UserProfileItem[r].ProfileItem[i].Value,n&&(V.identifierNick=n);break;case"Tag_Profile_IM_Image":o=t.UserProfileItem[r].ProfileItem[i].Value,o&&(V.headurl=o)}e&&e(V.identifierNick,V.headurl)},t)},t)},Ae=function(e,t,n){if(!pe(n,!1))return Ee(),void(t&&t({ActionStatus:d.OK,ErrorCode:0,ErrorInfo:"logout success"}));"all"==e?At.apiCall(u.OPEN_IM,"logout",{},function(e){Ee(),t&&t(e)},n):At.apiCall(u.OPEN_IM,"longpollinglogout",{LongPollingId:B},function(e){Ee(),t&&t(e)},n)},Ce=function(e,t,n){if(pe(n,!0)){var o=null;switch(e.sess.type()){case l.C2C:o={From_Account:V.identifier,To_Account:e.sess.id().toString(),MsgTimeStamp:e.time,MsgSeq:e.seq,MsgRandom:e.random,MsgBody:[],OfflinePushInfo:e.offlinePushInfo};break;case l.GROUP:var r=e.getSubType();switch(o={GroupId:e.sess.id().toString(),From_Account:V.identifier,Random:e.random,MsgBody:[]},r){case S.COMMON:o.MsgPriority="COMMON";break;case S.REDPACKET:o.MsgPriority="REDPACKET";break;case S.LOVEMSG:o.MsgPriority="LOVEMSG";break;case S.TIP:re.error("不能主动发送群提示消息,subType="+r);break;default:return void re.error("发送群消息时,出现未知子消息类型:subType="+r)}}for(var i in e.elems){var s=e.elems[i],a=null,c=s.type;switch(c){case g.TEXT:a={Text:s.content.text};break;case g.FACE:a={Index:s.content.index,Data:s.content.data};break;case g.IMAGE:var p=[];for(var f in s.content.ImageInfoArray)p.push({Type:s.content.ImageInfoArray[f].type,Size:s.content.ImageInfoArray[f].size,Width:s.content.ImageInfoArray[f].width,Height:s.content.ImageInfoArray[f].height,URL:s.content.ImageInfoArray[f].url});a={ImageFormat:s.content.ImageFormat,UUID:s.content.UUID,ImageInfoArray:p};break;case g.SOUND:re.warn("web端暂不支持发送语音消息");continue;case g.LOCATION:re.warn("web端暂不支持发送地理位置消息");continue;case g.FILE:a={UUID:s.content.uuid,FileName:s.content.name,FileSize:s.content.size,DownloadFlag:s.content.downFlag};break;case g.CUSTOM:a={Data:s.content.data,Desc:s.content.desc,Ext:s.content.ext},c=g.CUSTOM;break;default:re.warn("web端暂不支持发送"+s.type+"消息");continue}e.PushInfoBoolean&&(o.OfflinePushInfo=e.PushInfo),o.MsgBody.push({MsgType:c,MsgContent:a})}e.sess.type()==l.C2C?At.apiCall(u.OPEN_IM,"sendmsg",o,t,n):e.sess.type()==l.GROUP&&At.apiCall(u.GROUP,"send_group_msg",o,t,n)}},Se=function(e,t,n){(o||"undefined"==typeof stopPolling||1!=stopPolling)&&pe(n,!0)&&At.apiCall(u.OPEN_IM,"longpolling",e,t,n,q,!0)},Ge=function(e,t,n,o){At.apiCall(u.BIG_GROUP_LONG_POLLING,"get_msg",e,t,n,o)},Fe=function(e,t,n,o){pe(o,!0)&&At.apiCall(u.OPEN_IM,"getmsg",{Cookie:e,SyncFlag:t},function(e){if(e.MsgList&&e.MsgList.length)for(var t in e.MsgList)Q.push(e.MsgList[t]);1==e.SyncFlag?Fe(e.Cookie,e.SyncFlag,n,o):(e.MsgList=Q,Q=[],n&&n(e))},o)},Oe=function(e,t,n,o){if(pe(o,!0)){var r=[];for(var i in t){var s={To_Account:t[i].toAccount,LastedMsgTime:t[i].lastedMsgTime};r.push(s)}At.apiCall(u.OPEN_IM,"msgreaded",{C2CMsgReaded:{Cookie:e,C2CMsgReadedItem:r}},n,o)}},Re=function(e,t,n){pe(n,!0)&&At.apiCall(u.OPEN_IM,"deletemsg",e,t,n)},Ne=function(e,t,n){pe(n,!0)&&At.apiCall(u.OPEN_IM,"getroammsg",e,function(o){var r=e.MaxCnt,i=o.Complete,s=o.MaxCnt,u=o.MsgKey,a=o.LastMsgTime;if(o.MsgList&&o.MsgList.length)for(var c in o.MsgList)$.push(o.MsgList[c]);var l=null;0==i&&s0&&(e.ActionStatus=d.FAIL,e.GroupInfo[o].ErrorInfo="["+r+"]"+e.GroupInfo[o].ErrorInfo,e.ErrorInfo+=e.GroupInfo[o].ErrorInfo+"\n")}e.ActionStatus==d.FAIL?n&&n(e):t&&t(e)},n)},ze=function(e,t,n){if(pe(n,!0)){var o={GroupIdList:e.GroupIdList,ResponseFilter:{GroupBaseInfoFilter:e.GroupBaseInfoFilter,MemberInfoFilter:e.MemberInfoFilter}};e.AppDefinedDataFilter_Group&&(o.ResponseFilter.AppDefinedDataFilter_Group=e.AppDefinedDataFilter_Group),e.AppDefinedDataFilter_GroupMember&&(o.ResponseFilter.AppDefinedDataFilter_GroupMember=e.AppDefinedDataFilter_GroupMember),At.apiCall(u.GROUP,"get_group_info",o,t,n)}},Je=function(e,t,n){pe(n,!0)&&At.apiCall(u.GROUP,"get_group_member_info",{GroupId:e.GroupId,Offset:e.Offset,Limit:e.Limit,MemberInfoFilter:e.MemberInfoFilter,MemberRoleFilter:e.MemberRoleFilter,AppDefinedDataFilter_GroupMember:e.AppDefinedDataFilter_GroupMember},t,n)},Ve=function(e,t,n){pe(n,!0)&&At.apiCall(u.GROUP,"add_group_member",{GroupId:e.GroupId,Silence:e.Silence,MemberList:e.MemberList},t,n)},Ye=function(e,t,n){if(pe(n,!0)){var o={};e.GroupId&&(o.GroupId=e.GroupId),e.Member_Account&&(o.Member_Account=e.Member_Account),e.Role&&(o.Role=e.Role),e.MsgFlag&&(o.MsgFlag=e.MsgFlag),e.ShutUpTime&&(o.ShutUpTime=e.ShutUpTime),e.NameCard&&(o.NameCard=e.NameCard),e.AppMemberDefinedData&&(o.AppMemberDefinedData=e.AppMemberDefinedData),At.apiCall(u.GROUP,"modify_group_member_info",o,t,n)}},Xe=function(e,t,n){pe(n,!0)&&At.apiCall(u.GROUP,"delete_group_member",{GroupId:e.GroupId,Silence:e.Silence,MemberToDel_Account:e.MemberToDel_Account,Reason:e.Reason},t,n)},je=function(e,t,n){pe(n,!0)&&At.apiCall(u.GROUP,"destroy_group",{GroupId:e.GroupId},t,n)},We=function(e,t,n){pe(n,!0)&&At.apiCall(u.GROUP,"change_group_owner",e,t,n)},Qe=function(e,t,n){pe(n,!0)&&At.apiCall(u.GROUP,"get_joined_group_list",{Member_Account:e.Member_Account,Limit:e.Limit,Offset:e.Offset,GroupType:e.GroupType,ResponseFilter:{GroupBaseInfoFilter:e.GroupBaseInfoFilter,SelfInfoFilter:e.SelfInfoFilter}},t,n)},$e=function(e,t,n){pe(n,!0)&&At.apiCall(u.GROUP,"get_role_in_group",{GroupId:e.GroupId,User_Account:e.User_Account},t,n)},Ze=function(e,t,n){pe(n,!0)&&At.apiCall(u.GROUP,"forbid_send_msg",{GroupId:e.GroupId,Members_Account:e.Members_Account,ShutUpTime:e.ShutUpTime},t,n)},et=function(e,t,n){pe(n,!0)&&At.apiCall(u.GROUP,"send_group_system_notification",e,t,n)},tt=function(e,t,n){pe(n,!0)&&At.apiCall(u.GROUP,"group_msg_get",{GroupId:e.GroupId,ReqMsgSeq:e.ReqMsgSeq,ReqMsgNumber:e.ReqMsgNumber},t,n)},nt=function(e,t,n){pe(n,!0)&&At.apiCall(u.GROUP,"msg_read_report",{GroupId:e.GroupId,MsgReadedSeq:e.MsgReadedSeq},t,n)},ot=function(e){var t=[];if(e.Fail_Account&&e.Fail_Account.length&&(t=e.Fail_Account),e.Invalid_Account&&e.Invalid_Account.length)for(var n in e.Invalid_Account)t.push(e.Invalid_Account[n]);if(t.length){e.ActionStatus=d.FAIL,e.ErrorCode=99999,e.ErrorInfo="";for(var o in t){var r=t[o];for(var i in e.ResultItem)if(e.ResultItem[i].To_Account==r){var s=e.ResultItem[i].ResultCode;e.ResultItem[i].ResultInfo="["+s+"]"+e.ResultItem[i].ResultInfo,e.ErrorInfo+=e.ResultItem[i].ResultInfo+"\n";break}}}return e},rt=function(e,t,n){pe(n,!0)&&At.apiCall(u.FRIEND,"friend_add",{From_Account:V.identifier,AddFriendItem:e.AddFriendItem},function(e){var o=ot(e);o.ActionStatus==d.FAIL?n&&n(o):t&&t(o)},n)},it=function(e,t,n){pe(n,!0)&&At.apiCall(u.FRIEND,"friend_delete",{From_Account:V.identifier,To_Account:e.To_Account,DeleteType:e.DeleteType},function(e){var o=ot(e);o.ActionStatus==d.FAIL?n&&n(o):t&&t(o)},n)},st=function(e,t,n){pe(n,!0)&&(1==e.chatType?At.apiCall(u.DEL_CHAT,"delete",{From_Account:V.identifier,Type:e.chatType,To_Account:e.To_Account},t,n):At.apiCall(u.DEL_CHAT,"delete",{From_Account:V.identifier,Type:e.chatType,ToGroupid:e.To_Account},t,n))},ut=function(e,t,n){pe(n,!0)&&At.apiCall(u.FRIEND,"pendency_get",{From_Account:V.identifier,PendencyType:e.PendencyType,StartTime:e.StartTime,MaxLimited:e.MaxLimited,LastSequence:e.LastSequence},t,n)},at=function(e,t,n){pe(n,!0)&&At.apiCall(u.FRIEND,"PendencyReport",{From_Account:V.identifier,LatestPendencyTimeStamp:e.LatestPendencyTimeStamp},t,n)},ct=function(e,t,n){pe(n,!0)&&At.apiCall(u.FRIEND,"pendency_delete",{From_Account:V.identifier,PendencyType:e.PendencyType,To_Account:e.To_Account},function(e){var o=ot(e);o.ActionStatus==d.FAIL?n&&n(o):t&&t(o)},n)},lt=function(e,t,n){pe(n,!0)&&At.apiCall(u.FRIEND,"friend_response",{From_Account:V.identifier,ResponseFriendItem:e.ResponseFriendItem},function(e){var o=ot(e);o.ActionStatus==d.FAIL?n&&n(o):t&&t(o)},n)},pt=function(e,t,n){pe(n,!0)&&At.apiCall(u.FRIEND,"friend_get_all",{From_Account:V.identifier,TimeStamp:e.TimeStamp,StartIndex:e.StartIndex,GetCount:e.GetCount,LastStandardSequence:e.LastStandardSequence,TagList:e.TagList},t,n)},ft=function(e,t,n){e.To_Account.length>100&&(e.To_Account.length=100,re.error("获取用户资料人数不能超过100人")),pe(n,!0)&&At.apiCall(u.PROFILE,"portrait_get",{From_Account:V.identifier,To_Account:e.To_Account,TagList:e.TagList},function(e){var o=[];if(e.Fail_Account&&e.Fail_Account.length&&(o=e.Fail_Account),e.Invalid_Account&&e.Invalid_Account.length)for(var r in e.Invalid_Account)o.push(e.Invalid_Account[r]);if(o.length){e.ActionStatus=d.FAIL,e.ErrorCode=99999,e.ErrorInfo="";for(var i in o){var s=o[i];for(var u in e.UserProfileItem)if(e.UserProfileItem[u].To_Account==s){var a=e.UserProfileItem[u].ResultCode;e.UserProfileItem[u].ResultInfo="["+a+"]"+e.UserProfileItem[u].ResultInfo,e.ErrorInfo+="账号:"+s+","+e.UserProfileItem[u].ResultInfo+"\n";break}}}e.ActionStatus==d.FAIL?n&&n(e):t&&t(e)},n)},dt=function(e,t,n){pe(n,!0)&&At.apiCall(u.PROFILE,"portrait_set",{From_Account:V.identifier,ProfileItem:e.ProfileItem},function(n){for(var o in e.ProfileItem){var r=e.ProfileItem[o];if("Tag_Profile_IM_Nick"==r.Tag){V.identifierNick=r.Value;break}}t&&t(n)},n)},gt=function(e,t,n){pe(n,!0)&&At.apiCall(u.FRIEND,"black_list_add",{From_Account:V.identifier,To_Account:e.To_Account},function(e){var o=ot(e);o.ActionStatus==d.FAIL?n&&n(o):t&&t(o)},n)},mt=function(e,t,n){pe(n,!0)&&At.apiCall(u.FRIEND,"black_list_delete",{From_Account:V.identifier,To_Account:e.To_Account},function(e){var o=ot(e);o.ActionStatus==d.FAIL?n&&n(o):t&&t(o)},n)},It=function(e,t,n){pe(n,!0)&&At.apiCall(u.FRIEND,"black_list_get",{From_Account:V.identifier,StartIndex:e.StartIndex,MaxLimited:e.MaxLimited,LastSequence:e.LastSequence},t,n)},Mt=function(e,t,n){pe(n,!0)&&At.apiCall(u.RECENT_CONTACT,"get",{From_Account:V.identifier,Count:e.Count},t,n)},Et=function(e,t,n){if(pe(n,!0)){var o;o=fe()?"pic_up":"pic_up_test",At.apiCall(u.PIC,o,{App_Version:h.APP_VERSION,From_Account:V.identifier,To_Account:e.To_Account,Seq:e.Seq,Timestamp:e.Timestamp,Random:e.Random,File_Str_Md5:e.File_Str_Md5,File_Size:e.File_Size,File_Type:e.File_Type,Server_Ver:h.SERVER_VERSION,Auth_Key:z,Busi_Id:e.Busi_Id,PkgFlag:e.PkgFlag,Slice_Offset:e.Slice_Offset,Slice_Size:e.Slice_Size,Slice_Data:e.Slice_Data},t,n)}},_t=function(e,t){pe(t,!0)&&At.apiCall(u.OPEN_IM,"authkey",{},e,t)},yt=function(e,t,n){pe(n,!0)&&At.apiCall(u.IM_OPEN_STAT,"web_report",e,t,n)},ht=function(e,t,n){pe(n,!0)&&At.apiCall(u.OPEN_IM,"getlongpollingid",{},function(e){t&&t(e)},n)},Tt=function(e,t,n){At.apiCall(u.PIC,"apply_download",e,t,n)};!function(){s="wechat"}();var At=new function(){var e=null;this.init=function(t,n,o){t&&(e=t)},this.callBack=function(t){e&&e(t)},this.clear=function(){e=null},this.apiCall=function(e,t,n,o,r,i,s){var u=de(e,t,0,r);0!=u&&ce("POST",u,n,0,0,function(i){var s=null,a="";"pic_up"==t&&(n.Slice_Data="");var c="\n request url: \n"+u+"\n request body: \n"+JSON.stringify(n)+"\n response: \n"+JSON.stringify(i);i.ActionStatus==d.OK?(re.info("["+e+"]["+t+"]success: "+c),o&&o(i),s=0,a=""):(s=i.ErrorCode,a=i.ErrorInfo,r&&(i.SrcErrorInfo=i.ErrorInfo,i.ErrorInfo="["+e+"]["+t+"]failed: "+c,"longpolling"==t&&60008==i.ErrorCode||re.error(i.ErrorInfo),r(i))),ye(t,s,a)},function(e){r&&r(e),ye(t,e.ErrorCode,e.ErrorInfo)})}},Ct=function(e,t,n,o,r,i){this._impl={skey:Ct.skey(e,t),type:e,id:t,name:n,icon:o,unread:0,isAutoRead:!1,time:r>=0?r:0,curMaxMsgSeq:i>=0?i:0,msgs:[],isFinished:1}};Ct.skey=function(e,t){return e+t},Ct.prototype.type=function(){return this._impl.type},Ct.prototype.id=function(){return this._impl.id},Ct.prototype.name=function(){return this._impl.name},Ct.prototype.icon=function(){return this._impl.icon},Ct.prototype.unread=function(e){if(void 0===e)return this._impl.unread;this._impl.unread=e},Ct.prototype.isFinished=function(e){if(void 0===e)return this._impl.isFinished;this._impl.isFinished=e},Ct.prototype.time=function(){return this._impl.time},Ct.prototype.curMaxMsgSeq=function(e){if(void 0===e)return this._impl.curMaxMsgSeq;this._impl.curMaxMsgSeq=e},Ct.prototype.msgCount=function(){return this._impl.msgs.length},Ct.prototype.msg=function(e){return this._impl.msgs[e]},Ct.prototype.msgs=function(){return this._impl.msgs},Ct.prototype._impl_addMsg=function(e,t){this._impl.msgs.push(e),e.time>this._impl.time&&(this._impl.time=e.time),e.seq>this._impl.curMaxMsgSeq&&(this._impl.curMaxMsgSeq=e.seq),e.isSend||this._impl.isAutoRead||!t||this._impl.unread++};var St=function(e,t){this.toAccount=e,this.lastedMsgTime=t},Gt=function(e,t,n,o,r,i,s,u,a){this.sess=e,this.subType=s>=0?s:0,this.fromAccount=i,this.fromAccountNick=u||i,this.fromAccountHeadurl=a||null,this.isSend=Boolean(t),this.seq=n>=0?n:se(),this.random=o>=0?o:ue(),this.time=r>=0?r:ie(),this.elems=[];var c=e.type()};Gt.prototype.getSession=function(){return this.sess},Gt.prototype.getType=function(){return this.subType},Gt.prototype.getSubType=function(){return this.subType},Gt.prototype.getFromAccount=function(){return this.fromAccount},Gt.prototype.getFromAccountNick=function(){return this.fromAccountNick},Gt.prototype.getIsSend=function(){return this.isSend},Gt.prototype.getSeq=function(){return this.seq},Gt.prototype.getTime=function(){return this.time},Gt.prototype.getRandom=function(){return this.random},Gt.prototype.getElems=function(){return this.elems},Gt.prototype.getMsgUniqueId=function(){return this.uniqueId},Gt.prototype.addText=function(e){this.addElem(new t.Msg.Elem(g.TEXT,e))},Gt.prototype.addFace=function(e){this.addElem(new t.Msg.Elem(g.FACE,e))},Gt.prototype.addImage=function(e){this.addElem(new t.Msg.Elem(g.IMAGE,e))},Gt.prototype.addLocation=function(e){this.addElem(new t.Msg.Elem(g.LOCATION,e))},Gt.prototype.addFile=function(e){this.addElem(new t.Msg.Elem(g.FILE,e))},Gt.prototype.addCustom=function(e){this.addElem(new t.Msg.Elem(g.CUSTOM,e))},Gt.prototype.addElem=function(e){this.elems.push(e)},Gt.prototype.toHtml=function(){var e="";for(var t in this.elems){e+=this.elems[t].toHtml()}return e},Gt.Elem=function(e,t){this.type=e,this.content=t},Gt.Elem.prototype.getType=function(){return this.type},Gt.Elem.prototype.getContent=function(){return this.content},Gt.Elem.prototype.toHtml=function(){return this.content.toHtml()},Gt.Elem.Text=function(e){this.text=oe.xssFilter(e)},Gt.Elem.Text.prototype.getText=function(){return this.text},Gt.Elem.Text.prototype.toHtml=function(){return this.text},Gt.Elem.Face=function(e,t){this.index=e,this.data=t},Gt.Elem.Face.prototype.getIndex=function(){return this.index},Gt.Elem.Face.prototype.getData=function(){return this.data},Gt.Elem.Face.prototype.toHtml=function(){var e=null,t=te[this.data],n=ne[t];return n&&n[1]&&(e=n[1]),e?"
":this.data},Gt.Elem.Location=function(e,t,n){this.latitude=t,this.longitude=e,this.desc=n},Gt.Elem.Location.prototype.getLatitude=function(){return this.latitude},Gt.Elem.Location.prototype.getLongitude=function(){return this.longitude},Gt.Elem.Location.prototype.getDesc=function(){return this.desc},Gt.Elem.Location.prototype.toHtml=function(){return"经度="+this.longitude+",纬度="+this.latitude+",描述="+this.desc},Gt.Elem.Images=function(e,t){this.UUID=e,"number"!=typeof t&&(t=parseInt(I[t]||I.UNKNOWN,10)),this.ImageFormat=t,this.ImageInfoArray=[]},Gt.Elem.Images.prototype.addImage=function(e){this.ImageInfoArray.push(e)},Gt.Elem.Images.prototype.toHtml=function(){var e=this.getImage(m.SMALL),t=this.getImage(m.LARGE),n=this.getImage(m.ORIGIN);return t||(t=e),n||(n=e),"
"},Gt.Elem.Images.prototype.getImageId=function(){return this.UUID},Gt.Elem.Images.prototype.getImageFormat=function(){return this.ImageFormat},Gt.Elem.Images.prototype.getImage=function(e){for(var t in this.ImageInfoArray)if(this.ImageInfoArray[t].getType()==e)return this.ImageInfoArray[t];var n=null;return this.ImageInfoArray.forEach(function(t){t.getType()==e&&(n=t)}),n},Gt.Elem.Images.Image=function(e,t,n,o,r){this.type=e,this.size=t,this.width=n,this.height=o,this.url=r},Gt.Elem.Images.Image.prototype.getType=function(){return this.type},Gt.Elem.Images.Image.prototype.getSize=function(){return this.size},Gt.Elem.Images.Image.prototype.getWidth=function(){return this.width},Gt.Elem.Images.Image.prototype.getHeight=function(){return this.height},
Gt.Elem.Images.Image.prototype.getUrl=function(){return this.url},Gt.Elem.Sound=function(e,t,n,o,r,i,s){this.uuid=e,this.second=t,this.size=n,this.senderId=o,this.receiverId=r,this.downFlag=i,this.busiId=s==l.C2C?2:1,void 0!==this.downFlag&&void 0!==this.busiId?Ie(e,o,0,i,r,this.busiId,y.SOUND):this.downUrl=ge(e,o)},Gt.Elem.Sound.prototype.getUUID=function(){return this.uuid},Gt.Elem.Sound.prototype.getSecond=function(){return this.second},Gt.Elem.Sound.prototype.getSize=function(){return this.size},Gt.Elem.Sound.prototype.getSenderId=function(){return this.senderId},Gt.Elem.Sound.prototype.getDownUrl=function(){return this.downUrl},Gt.Elem.Sound.prototype.toHtml=function(){return"ie"==s.type&&parseInt(s.ver)<=8?"[这是一条语音消息]demo暂不支持ie8(含)以下浏览器播放语音,语音URL:"+this.downUrl:''},Gt.Elem.File=function(e,t,n,o,r,i,s){this.uuid=e,this.name=t,this.size=n,this.senderId=o,this.receiverId=r,this.downFlag=i,this.busiId=s==l.C2C?2:1,void 0!==i&&void 0!==busiId?Ie(e,o,0,i,r,this.busiId,y.FILE):this.downUrl=me(e,o,t)},Gt.Elem.File.prototype.getUUID=function(){return this.uuid},Gt.Elem.File.prototype.getName=function(){return this.name},Gt.Elem.File.prototype.getSize=function(){return this.size},Gt.Elem.File.prototype.getSenderId=function(){return this.senderId},Gt.Elem.File.prototype.getDownUrl=function(){return this.downUrl},Gt.Elem.File.prototype.getDownFlag=function(){return this.downFlag},Gt.Elem.File.prototype.toHtml=function(){var e,t;return e=this.size,t="Byte",this.size>=1024&&(e=Math.round(this.size/1024),t="KB"),{uuid:this.uuid,name:this.name,size:e,unitStr:t}},Gt.Elem.GroupTip=function(e,t,n,o,r,i){this.opType=e,this.opUserId=t,this.groupId=n,this.groupName=o,this.userIdList=r||[],this.groupInfoList=[],this.memberInfoList=[],this.groupMemberNum=null,this.userinfo=i||[]},Gt.Elem.GroupTip.prototype.addGroupInfo=function(e){this.groupInfoList.push(e)},Gt.Elem.GroupTip.prototype.addMemberInfo=function(e){this.memberInfoList.push(e)},Gt.Elem.GroupTip.prototype.getOpType=function(){return this.opType},Gt.Elem.GroupTip.prototype.getOpUserId=function(){return this.opUserId},Gt.Elem.GroupTip.prototype.getGroupId=function(){return this.groupId},Gt.Elem.GroupTip.prototype.getGroupName=function(){return this.groupName},Gt.Elem.GroupTip.prototype.getUserIdList=function(){return this.userIdList},Gt.Elem.GroupTip.prototype.getUserInfo=function(){return this.userinfo},Gt.Elem.GroupTip.prototype.getGroupInfoList=function(){return this.groupInfoList},Gt.Elem.GroupTip.prototype.getMemberInfoList=function(){return this.memberInfoList},Gt.Elem.GroupTip.prototype.getGroupMemberNum=function(){return this.groupMemberNum},Gt.Elem.GroupTip.prototype.setGroupMemberNum=function(e){return this.groupMemberNum=e},Gt.Elem.GroupTip.prototype.toHtml=function(){var e="[群提示消息]";switch(this.opType){case F.JOIN:e+=this.opUserId+"邀请了";for(var t in this.userIdList)if(e+=this.userIdList[t]+",",this.userIdList.length>10&&9==t){e+="等"+this.userIdList.length+"人";break}e+="加入该群";break;case F.QUIT:e+=this.opUserId+"主动退出该群";break;case F.KICK:e+=this.opUserId+"将";for(var t in this.userIdList)if(e+=this.userIdList[t]+",",this.userIdList.length>10&&9==t){e+="等"+this.userIdList.length+"人";break}e+="踢出该群";break;case F.SET_ADMIN:e+=this.opUserId+"将";for(var t in this.userIdList)if(e+=this.userIdList[t]+",",this.userIdList.length>10&&9==t){e+="等"+this.userIdList.length+"人";break}e+="设为管理员";break;case F.CANCEL_ADMIN:e+=this.opUserId+"取消";for(var t in this.userIdList)if(e+=this.userIdList[t]+",",this.userIdList.length>10&&9==t){e+="等"+this.userIdList.length+"人";break}e+="的管理员资格";break;case F.MODIFY_GROUP_INFO:e+=this.opUserId+"修改了群资料:";for(var t in this.groupInfoList){var n=this.groupInfoList[t].getType(),o=this.groupInfoList[t].getValue();switch(n){case O.FACE_URL:e+="群头像为"+o+"; ";break;case O.NAME:e+="群名称为"+o+"; ";break;case O.OWNER:e+="群主为"+o+"; ";break;case O.NOTIFICATION:e+="群公告为"+o+"; ";break;case O.INTRODUCTION:e+="群简介为"+o+"; ";break;default:e+="未知信息为:type="+n+",value="+o+"; "}}break;case F.MODIFY_MEMBER_INFO:e+=this.opUserId+"修改了群成员资料:";for(var t in this.memberInfoList){var r=this.memberInfoList[t].getUserId(),i=this.memberInfoList[t].getShutupTime();if(e+=r+": ",e+=null!=i&&void 0!==i?0==i?"取消禁言; ":"禁言"+i+"秒; ":" shutupTime为空",this.memberInfoList.length>10&&9==t){e+="等"+this.memberInfoList.length+"人";break}}break;case F.READED:Log.info("消息已读同步");break;default:e+="未知群提示消息类型:type="+this.opType}return e},Gt.Elem.GroupTip.GroupInfo=function(e,t){this.type=e,this.value=t},Gt.Elem.GroupTip.GroupInfo.prototype.getType=function(){return this.type},Gt.Elem.GroupTip.GroupInfo.prototype.getValue=function(){return this.value},Gt.Elem.GroupTip.MemberInfo=function(e,t){this.userId=e,this.shutupTime=t},Gt.Elem.GroupTip.MemberInfo.prototype.getUserId=function(){return this.userId},Gt.Elem.GroupTip.MemberInfo.prototype.getShutupTime=function(){return this.shutupTime},Gt.Elem.Custom=function(e,t,n){this.data=e,this.desc=t,this.ext=n},Gt.Elem.Custom.prototype.getData=function(){return this.data},Gt.Elem.Custom.prototype.getDesc=function(){return this.desc},Gt.Elem.Custom.prototype.getExt=function(){return this.ext},Gt.Elem.Custom.prototype.toHtml=function(){return this.data};var Ft=new function(){var t={},n=[];e={},this.cookie="",this.syncFlag=0;var o=function(e){for(var n in t)e(t[n])},r=function(t){var n=!1,o=t.sess._impl.skey,r=t.isSend+t.seq+t.random;return e[o]&&e[o][r]&&(n=!0),e[o]?e[o][r]={time:t.time}:(e[o]={},e[o][r]={time:t.time}),n};this.sessMap=function(){return t},this.sessCount=function(){return n.length},this.sessByTypeId=function(e,n){var o=Ct.skey(e,n);return void 0===o||null==o?null:t[o]},this.delSessByTypeId=function(n,o){var r=Ct.skey(n,o);return void 0!==r&&null!=r&&(t[r]&&(delete t[r],delete e[r]),!0)},this.resetCookieAndSyncFlag=function(){this.cookie="",this.syncFlag=0},this.setAutoRead=function(e,t,n){if(n&&o(function(e){e._impl.isAutoRead=!1}),e&&(e._impl.isAutoRead=t,t))if(e._impl.unread=0,e._impl.type==l.C2C){var r=[];r.push(new St(e._impl.id,e._impl.time)),Oe(Ft.cookie,r,function(e){re.info("[setAutoRead]: c2CMsgReaded success")},function(e){re.error("[setAutoRead}: c2CMsgReaded failed:"+e.ErrorInfo)})}else if(e._impl.type==l.GROUP){var i={GroupId:e._impl.id,MsgReadedSeq:e._impl.curMaxMsgSeq};nt(i,function(e){re.info("groupMsgReaded success")},function(e){re.error("groupMsgReaded failed:"+e.ErrorInfo)})}},this.c2CMsgReaded=function(e,t,n){var o=[];o.push(new St(e.To_Account,e.LastedMsgTime)),Oe(Ft.cookie,o,function(e){t&&(re.info("c2CMsgReaded success"),t(e))},function(e){n&&(re.error("c2CMsgReaded failed:"+e.ErrorInfo),n(e))})},this.addSession=function(e){t[e._impl.skey]=e},this.delSession=function(e){delete t[e._impl.skey]},this.clear=function(){t={},n=[],e={},this.cookie="",this.syncFlag=0},this.addMsg=function(e,n){if(r(e))return!1;var o=e.sess;return t[o._impl.skey]||this.addSession(o),o._impl_addMsg(e,n),!0},this.updateTimeline=function(){var e=new Array;o(function(t){e.push(t)}),e.sort(function(e,t){return t.time-e.time}),n=e}},Ot=new function(){var e=null,t=null,n={1:null,2:null,3:null,4:null,5:null,6:null,7:null,8:null,9:null,10:null,11:null,15:null,255:null,12:null},o={1:null,2:null,3:null,4:null,5:null,6:null,7:null,8:null},r={1:null},i=null,s=!1,u=0,a=0,c=null,p=!1,f={},m=90,I=null,M={},E={92:null,96:null},_=null,y={},h={};this.setLongPollingOn=function(e){s=e},this.getLongPollingOn=function(){return s},this.resetLongPollingInfo=function(){s=!1,u=0,a=0},this.setBigGroupLongPollingOn=function(e){p=e},this.checkBigGroupLongPollingOn=function(e){return!!I[e]},this.setBigGroupLongPollingKey=function(e,t){I[e]=t},this.resetBigGroupLongPollingInfo=function(e){p=!1,f[e]=0,I[e]=null,M[e]={}},this.setBigGroupLongPollingMsgMap=function(e,t){var n=M[e];n?(n=parseInt(n)+t,M[e]=n):M[e]=t},this.clear=function(){t=null,n={1:null,2:null,3:null,4:null,5:null,6:null,7:null,8:null,9:null,10:null,11:null,15:null,255:null,12:null},o={1:null,2:null,3:null,4:null,5:null,6:null,7:null,8:null},r={1:null},e=null,s=!1,u=0,a=0,c=null,p=!1,f={},I={},M={},h={},H=[],z=null,J=null};var P=function(e,t){_t(function(t){H=t.IpList,z=t.AuthKey,J=t.ExpireTime,e&&e(t)},function(e){re.error("initIpAndAuthkey failed:"+e.ErrorInfo),t&&t(e)})},b=function(e,t){var n={Member_Account:V.identifier,Limit:1e3,Offset:0,GroupBaseInfoFilter:["NextMsgSeq"]};Qe(n,function(t){if(!t.GroupIdList||0==t.GroupIdList.length)return re.info("initMyGroupMaxSeqs: 目前还没有加入任何群组"),void(e&&e(t));for(var n=0;nn&&(y[e]=t):y[e]=t},Y=function(e,t){for(var n in e){var o=e[n];if(o.From_Account){var r=ue(o,!1,!0);r&&t.push(r),K(o.ToGroupId,o.MsgSeq)}}return t},X=function(t,n){var o={},r=[];for(var i in n){var s=o[n[i].ToGroupId];s||(s=o[n[i].ToGroupId]={min:99999999,max:-1,msgs:[]}),n[i].NoticeSeq>a&&(re.warn("noticeSeq="+a+",msgNoticeSeq="+n[i].NoticeSeq),a=n[i].NoticeSeq),n[i].Event=t,o[n[i].ToGroupId].msgs.push(n[i]),n[i].MsgSeqs.max&&(o[n[i].ToGroupId].max=n[i].MsgSeq)}for(var u in o)r=Y(o[u].msgs,r);r.length&&Ft.updateTimeline(),e&&r.length&&e(r)},j=function(t,n){var o={},r=[];for(var i in n){var s=o[n[i].ToGroupId];s||(s=o[n[i].ToGroupId]={min:99999999,max:-1,msgs:[]}),n[i].NoticeSeq>a&&(re.warn("noticeSeq="+a+",msgNoticeSeq="+n[i].NoticeSeq),a=n[i].NoticeSeq),n[i].Event=t,o[n[i].ToGroupId].msgs.push(n[i]),n[i].MsgSeqs.max&&(o[n[i].ToGroupId].max=n[i].MsgSeq)}for(var u in o)r=Y(o[u].msgs,r);r.length&&Ft.updateTimeline(),e&&r.length&&e(r)},W=function(e,t){for(var o in e){var r=e[o],i=r.MsgBody,s=i.ReportType;0==t&&r.NoticeSeq&&r.NoticeSeq>a&&(a=r.NoticeSeq);r.GroupInfo.To_Account;if(t){var u=r.ToGroupId+"_"+s+"_"+i.Operator_Account;if(h[u]){re.warn("收到重复的群系统消息:key="+u);continue}h[u]=!0}var c={SrcFlag:0,ReportType:s,GroupId:r.ToGroupId,GroupName:r.GroupInfo.GroupName,Operator_Account:i.Operator_Account,MsgTime:r.MsgTimeStamp,groupReportTypeMsg:i};switch(s){case R.JOIN_GROUP_REQUEST:c.RemarkInfo=i.RemarkInfo,c.MsgKey=i.MsgKey,c.Authentication=i.Authentication,c.UserDefinedField=r.UserDefinedField,c.From_Account=r.From_Account,c.MsgSeq=r.ClientSeq,c.MsgRandom=r.MsgRandom;break;case R.JOIN_GROUP_ACCEPT:case R.JOIN_GROUP_REFUSE:c.RemarkInfo=i.RemarkInfo;break;case R.KICK:case R.DESTORY:case R.CREATE:case R.INVITED_JOIN_GROUP_REQUEST:case R.INVITED_JOIN_GROUP_REQUEST_AGREE:case R.QUIT:case R.SET_ADMIN:case R.CANCEL_ADMIN:case R.REVOKE:case R.READED:break;case R.CUSTOM:c.MsgSeq=r.MsgSeq,c.UserDefinedField=i.UserDefinedField;break;default:re.error("未知群系统消息类型:reportType="+s)}if(t)n[s]?n[s](c):re.error("未知群系统消息类型:reportType="+s);else if(n[s])if(s==R.READED)for(var l=c.groupReportTypeMsg.GroupReadInfoArray,p=0,f=l.length;pa&&(a=n.NoticeSeq),i={Type:r},r){case N.FRIEND_ADD:i.Accounts=n.FriendAdd_Account;break;case N.FRIEND_DELETE:i.Accounts=n.FriendDel_Account;break;case N.PENDENCY_ADD:i.PendencyList=n.PendencyAdd;break;case N.PENDENCY_DELETE:i.Accounts=n.FrienPencydDel_Account;break;case N.BLACK_LIST_ADD:i.Accounts=n.BlackListAdd_Account;break;case N.BLACK_LIST_DELETE:i.Accounts=n.BlackListDel_Account;break;default:re.error("未知好友系统通知类型:friendNotice="+JSON.stringify(n))}t?r==N.PENDENCY_ADD&&o[r]&&o[r](i):o[r]&&o[r](i)}},$=function(e,t){var n,o,i;for(var s in e){switch(n=e[s],o=n.PushType,0==t&&n.NoticeSeq&&n.NoticeSeq>a&&(a=n.NoticeSeq),i={Type:o},o){case v.PROFILE_MODIFY:i.Profile_Account=n.Profile_Account,i.ProfileList=n.ProfileList;break;default:re.error("未知资料系统通知类型:profileNotice="+JSON.stringify(n))}t?o==v.PROFILE_MODIFY&&r[o]&&r[o](i):r[o]&&r[o](i)}},Z=function(e){var t=e.MsgBody,o=t.ReportType,r=(e.GroupInfo.To_Account,{SrcFlag:1,ReportType:o,GroupId:e.ToGroupId,GroupName:e.GroupInfo.GroupName,Operator_Account:t.Operator_Account,MsgTime:e.MsgTimeStamp});switch(o){case R.JOIN_GROUP_REQUEST:r.RemarkInfo=t.RemarkInfo,r.MsgKey=t.MsgKey,r.Authentication=t.Authentication,r.UserDefinedField=e.UserDefinedField,r.From_Account=e.From_Account,r.MsgSeq=e.ClientSeq,r.MsgRandom=e.MsgRandom;break;case R.JOIN_GROUP_ACCEPT:case R.JOIN_GROUP_REFUSE:r.RemarkInfo=t.RemarkInfo;break;case R.KICK:case R.DESTORY:case R.CREATE:case R.INVITED_JOIN_GROUP_REQUEST:case R.INVITED_JOIN_GROUP_REQUEST_AGREE:case R.QUIT:case R.SET_ADMIN:case R.CANCEL_ADMIN:case R.REVOKE:break;case R.CUSTOM:r.MsgSeq=e.MsgSeq,r.UserDefinedField=t.UserDefinedField;break;default:re.error("未知群系统消息类型:reportType="+o)}n[o]&&n[o](r)},ee=function(e){for(var t=0,n=e.length;tON)";break;case U.ON:t="connection is on...(ON->ON)";break;case U.RECONNECT:D=U.ON,t="connection is on...(RECONNECT->ON)";break;case U.OFF:n=!0,D=U.RECONNECT,t="reconnect successfully(OFF->RECONNECT)"}var o={ActionStatus:d.OK,ErrorCode:D,ErrorInfo:t};n&&At.callBack(o),s&&Ot.longPolling()}else if(91101==e.ErrorCode)re.error("多实例登录,被kick"),i&&i();else if(w++,re.warn("longPolling接口第"+w+"次报错: "+e.ErrorInfo),w<=10)setTimeout(ie,100);else{D=U.OFF;var r={ActionStatus:d.FAIL,ErrorCode:U.OFF,ErrorInfo:"connection is off"};0==k&&At.callBack(r),k=!0,re.warn("5000毫秒之后,SDK会发起新的longPolling请求..."),setTimeout(ie,5e3)}},X=function(t,n){var o=[],r=[];r=n;for(var i in r){var s,u,a=r[i],c=a.From_AccountHeadurl||"";a.From_Account==V.identifier?(s=!0,u=a.To_Account):(s=!1,u=a.From_Account);var p=Ft.sessByTypeId(l.C2C,u);p||(p=new Ct(l.C2C,u,u,c,0,0));var f=new Gt(p,s,a.MsgSeq,a.MsgRandom,a.MsgTimeStamp,a.From_Account,A.COMMON,a.From_AccountNick,c),d=null,m=null,I=null;for(var M in a.MsgBody){switch(d=a.MsgBody[M],I=d.MsgType){case g.TEXT:m=new Gt.Elem.Text(d.MsgContent.Text);break;case g.FACE:m=new Gt.Elem.Face(d.MsgContent.Index,d.MsgContent.Data);break;case g.IMAGE:m=new Gt.Elem.Images(d.MsgContent.UUID,d.MsgContent.ImageFormat||"");for(var E in d.MsgContent.ImageInfoArray){var _=d.MsgContent.ImageInfoArray[E];m.addImage(new Gt.Elem.Images.Image(_.Type,_.Size,_.Width,_.Height,_.URL))}break;case g.SOUND:d.MsgContent?m=new Gt.Elem.Sound(d.MsgContent.UUID,d.MsgContent.Second,d.MsgContent.Size,a.From_Account,a.To_Account,d.MsgContent.Download_Flag,l.C2C):(I=g.TEXT,m=new Gt.Elem.Text("[语音消息]下载地址解析出错"));break;case g.LOCATION:m=new Gt.Elem.Location(d.MsgContent.Longitude,d.MsgContent.Latitude,d.MsgContent.Desc);break;case g.FILE:case g.FILE+" ":I=g.FILE,d.MsgContent?m=new Gt.Elem.File(d.MsgContent.UUID,d.MsgContent.FileName,d.MsgContent.FileSize,a.From_Account,a.To_Account,d.MsgContent.Download_Flag,l.C2C):(I=g.TEXT,m=new Gt.Elem.Text("[文件消息下载地址解析出错]"));break;case g.CUSTOM:try{var y=JSON.parse(d.MsgContent.Data);if(y&&y.userAction&&y.userAction==L.ING)continue}catch(e){}I=g.CUSTOM,m=new Gt.Elem.Custom(d.MsgContent.Data,d.MsgContent.Desc,d.MsgContent.Ext);break;default:I=g.TEXT,m=new Gt.Elem.Text("web端暂不支持"+d.MsgType+"消息")}f.elems.push(new Gt.Elem(I,m))}f.elems.length>0&&Ft.addMsg(f,!0)&&o.push(f)}o.length>0&&Ft.updateTimeline(),o.length>0&&e&&e(o)},ie=function(){s&&Ot.longPolling()},se=function(e){for(var t in e){var n=e[t];switch(W(n.GroupTips,!0),n.Event){case T.GROUP_SYSTEM:re.warn("handlerApplyJoinGroupSystemMsgs: handler new group system msg"),W(n.GroupTips,!0);break;default:re.error("syncMsgs收到未知的群系统消息类型: Event="+n.Event)}}};this.syncMsgs=function(t,n){var o=[],r=[];Fe(Ft.cookie,Ft.syncFlag,function(n){2==n.SyncFlag&&(Ft.syncFlag=0),r=n.MsgList,Ft.cookie=n.Cookie;for(var i in r){var s,u,a,c=r[i];c.From_Account==V.identifier?(s=!0,u=c.To_Account,a=""):(s=!1,u=c.From_Account,a="");var p=Ft.sessByTypeId(l.C2C,u);p||(p=new Ct(l.C2C,u,u,a,0,0));var f=new Gt(p,s,c.MsgSeq,c.MsgRandom,c.MsgTimeStamp,c.From_Account,A.COMMON,c.From_AccountNick,c.From_AccountHeadurl),d=null,m=null,I=null;for(var M in c.MsgBody){switch(d=c.MsgBody[M],I=d.MsgType){case g.TEXT:m=new Gt.Elem.Text(d.MsgContent.Text);break;case g.FACE:m=new Gt.Elem.Face(d.MsgContent.Index,d.MsgContent.Data);break;case g.IMAGE:m=new Gt.Elem.Images(d.MsgContent.UUID,d.MsgContent.ImageFormat);for(var E in d.MsgContent.ImageInfoArray){var _=d.MsgContent.ImageInfoArray[E];m.addImage(new Gt.Elem.Images.Image(_.Type,_.Size,_.Width,_.Height,_.URL))}break;case g.SOUND:d.MsgContent?m=new Gt.Elem.Sound(d.MsgContent.UUID,d.MsgContent.Second,d.MsgContent.Size,c.From_Account,c.To_Account,d.MsgContent.Download_Flag,l.C2C):(I=g.TEXT,m=new Gt.Elem.Text("[语音消息]下载地址解析出错"));break;case g.LOCATION:m=new Gt.Elem.Location(d.MsgContent.Longitude,d.MsgContent.Latitude,d.MsgContent.Desc);break;case g.FILE:case g.FILE+" ":I=g.FILE,d.MsgContent?m=new Gt.Elem.File(d.MsgContent.UUID,d.MsgContent.FileName,d.MsgContent.FileSize,c.From_Account,c.To_Account,d.MsgContent.Download_Flag,l.C2C):(I=g.TEXT,m=new Gt.Elem.Text("[文件消息下载地址解析出错]"));break;case g.CUSTOM:try{var y=JSON.parse(d.MsgContent.Data);if(y&&y.userAction&&y.userAction==L.ING)continue}catch(e){}I=g.CUSTOM,m=new Gt.Elem.Custom(d.MsgContent.Data,d.MsgContent.Desc,d.MsgContent.Ext);break;default:I=g.TEXT,m=new Gt.Elem.Text("web端暂不支持"+d.MsgType+"消息")}f.elems.push(new Gt.Elem(I,m))}f.elems.length>0&&Ft.addMsg(f,!0)&&o.push(f)}se(n.EventArray),o.length>0&&Ft.updateTimeline(),t?t(o):o.length>0&&e&&e(o)},function(e){re.error("getMsgs failed:"+e.ErrorInfo),n&&n(e)})},this.getC2CHistoryMsgs=function(e,t,n){if(!e.Peer_Account&&n)return void n(oe.getReturnError("Peer_Account is empty",-13));if(e.MaxCnt||(e.MaxCnt=15),e.MaxCnt<=0&&n)return void n(oe.getReturnError("MaxCnt should be greater than 0",-14));if(e.MaxCnt>15){if(n)return void n(oe.getReturnError("MaxCnt can not be greater than 15",-15))}else{null!=e.MsgKey&&void 0!==e.MsgKey||(e.MsgKey="");var o={Peer_Account:e.Peer_Account,MaxCnt:e.MaxCnt,LastMsgTime:e.LastMsgTime,MsgKey:e.MsgKey};Ne(o,function(n){var o=[],r=[];r=n.MsgList;var i=Ft.sessByTypeId(l.C2C,e.Peer_Account);i||(i=new Ct(l.C2C,e.Peer_Account,e.Peer_Account,"",0,0));for(var s in r){var u,a=r[s],c=a.From_AccountHeadurl||"";a.From_Account==V.identifier?(u=!0,a.To_Account):(u=!1,a.From_Account);var p=new Gt(i,u,a.MsgSeq,a.MsgRandom,a.MsgTimeStamp,a.From_Account,A.COMMON,a.From_AccountNick,c),f=null,d=null,m=null;for(var I in a.MsgBody){switch(f=a.MsgBody[I],m=f.MsgType){case g.TEXT:d=new Gt.Elem.Text(f.MsgContent.Text);break;case g.FACE:d=new Gt.Elem.Face(f.MsgContent.Index,f.MsgContent.Data);break;case g.IMAGE:d=new Gt.Elem.Images(f.MsgContent.UUID,f.MsgContent.ImageFormat);for(var M in f.MsgContent.ImageInfoArray){var E=f.MsgContent.ImageInfoArray[M];d.addImage(new Gt.Elem.Images.Image(E.Type,E.Size,E.Width,E.Height,E.URL))}break;case g.SOUND:f.MsgContent?d=new Gt.Elem.Sound(f.MsgContent.UUID,f.MsgContent.Second,f.MsgContent.Size,a.From_Account,a.To_Account,f.MsgContent.Download_Flag,l.C2C):(m=g.TEXT,d=new Gt.Elem.Text("[语音消息]下载地址解析出错"));break;case g.LOCATION:d=new Gt.Elem.Location(f.MsgContent.Longitude,f.MsgContent.Latitude,f.MsgContent.Desc);break;case g.FILE:case g.FILE+" ":m=g.FILE,f.MsgContent?d=new Gt.Elem.File(f.MsgContent.UUID,f.MsgContent.FileName,f.MsgContent.FileSize,a.From_Account,a.To_Account,f.MsgContent.Download_Flag,l.C2C):(m=g.TEXT,d=new Gt.Elem.Text("[文件消息下载地址解析出错]"));break;case g.CUSTOM:m=g.CUSTOM,d=new Gt.Elem.Custom(f.MsgContent.Data,f.MsgContent.Desc,f.MsgContent.Ext);break;default:m=g.TEXT,d=new Gt.Elem.Text("web端暂不支持"+f.MsgType+"消息")}p.elems.push(new Gt.Elem(m,d))}Ft.addMsg(p),o.push(p)}if(Ft.updateTimeline(),t){var _={Complete:n.Complete,MsgCount:o.length,LastMsgTime:n.LastMsgTime,MsgKey:n.MsgKey,MsgList:o};i.isFinished(n.Complete),t(_)}},function(e){re.error("getC2CHistoryMsgs failed:"+e.ErrorInfo),n&&n(e)})}},this.syncGroupMsgs=function(t,n,o){if(t.ReqMsgSeq<=0){if(o){var r=oe.getReturnError("ReqMsgSeq must be greater than 0",-16);o(r)}}else{var i={GroupId:t.GroupId,ReqMsgSeq:t.ReqMsgSeq,ReqMsgNumber:t.ReqMsgNumber};tt(i,function(t){var o=[],r=(t.GroupId,t.RspMsgList),i=t.IsFinished;if(null==r||void 0===r)return void(n&&n([]));for(var s=r.length-1;s>=0;s--){var u=r[s];if(!u.IsPlaceMsg&&u.From_Account&&u.MsgBody&&0!=u.MsgBody.length){var a=ue(u,!0,!0,i);a&&o.push(a)}}o.length>0&&Ft.updateTimeline(),n?n(o):o.length>0&&e&&e(o)},function(e){re.error("getGroupMsgs failed:"+e.ErrorInfo),o&&o(e)})}};var ue=function(e,n,o,r){if(e.IsPlaceMsg||!e.From_Account||!e.MsgBody||0==e.MsgBody.length)return null;var i,s,u,a,c=e.ToGroupId,p=c;e.GroupInfo&&e.GroupInfo.GroupName&&(p=e.GroupInfo.GroupName),u=e.From_Account,e.GroupInfo&&(e.GroupInfo.From_AccountNick&&(u=e.GroupInfo.From_AccountNick),a=e.GroupInfo.From_AccountHeadurl?e.GroupInfo.From_AccountHeadurl:null),e.From_Account==V.identifier?(i=!0,e.From_Account,s=""):(i=!1,e.From_Account,s="");var f=Ft.sessByTypeId(l.GROUP,c);f||(f=new Ct(l.GROUP,c,p,s,0,0)),void 0!==r&&f.isFinished(r||0);var d=S.COMMON;if(T.GROUP_TIP==e.Event||T.GROUP_TIP2==e.Event){d=S.TIP;var m=e.MsgBody;e.MsgBody=[],e.MsgBody.push({MsgType:g.GROUP_TIP,MsgContent:m})}else e.MsgPriority&&(e.MsgPriority==G.REDPACKET?d=S.REDPACKET:e.MsgPriority==G.LOVEMSG&&(d=S.LOVEMSG));var I=new Gt(f,i,e.MsgSeq,e.MsgRandom,e.MsgTimeStamp,e.From_Account,d,u,a),M=null,E=null,_=null;for(var y in e.MsgBody){switch(M=e.MsgBody[y],_=M.MsgType){case g.TEXT:E=new Gt.Elem.Text(M.MsgContent.Text);break;case g.FACE:E=new Gt.Elem.Face(M.MsgContent.Index,M.MsgContent.Data);break;case g.IMAGE:E=new Gt.Elem.Images(M.MsgContent.UUID,M.MsgContent.ImageFormat||"");for(var h in M.MsgContent.ImageInfoArray)E.addImage(new Gt.Elem.Images.Image(M.MsgContent.ImageInfoArray[h].Type,M.MsgContent.ImageInfoArray[h].Size,M.MsgContent.ImageInfoArray[h].Width,M.MsgContent.ImageInfoArray[h].Height,M.MsgContent.ImageInfoArray[h].URL));break;case g.SOUND:M.MsgContent?E=new Gt.Elem.Sound(M.MsgContent.UUID,M.MsgContent.Second,M.MsgContent.Size,e.From_Account,e.To_Account,M.MsgContent.Download_Flag,l.GROUP):(_=g.TEXT,E=new Gt.Elem.Text("[语音消息]下载地址解析出错"));break;case g.LOCATION:E=new Gt.Elem.Location(M.MsgContent.Longitude,M.MsgContent.Latitude,M.MsgContent.Desc);break;case g.FILE:case g.FILE+" ":_=g.FILE;me(M.MsgContent.UUID,e.From_Account,M.MsgContent.FileName);M.MsgContent?E=new Gt.Elem.File(M.MsgContent.UUID,M.MsgContent.FileName,M.MsgContent.FileSize,e.From_Account,e.To_Account,M.MsgContent.Download_Flag,l.GROUP):(_=g.TEXT,E=new Gt.Elem.Text("[文件消息]地址解析出错"));break;case g.GROUP_TIP:var A=M.MsgContent.OpType;if(E=new Gt.Elem.GroupTip(A,M.MsgContent.Operator_Account,c,e.GroupInfo.GroupName,M.MsgContent.List_Account,M.MsgContent.MsgMemberExtraInfo),F.JOIN==A||F.QUIT==A)E.setGroupMemberNum(M.MsgContent.MemberNum);else if(F.MODIFY_GROUP_INFO==A){var C=!1,R={GroupId:c,GroupFaceUrl:null,GroupName:null,OwnerAccount:null,GroupNotification:null,GroupIntroduction:null},N=M.MsgContent.MsgGroupNewInfo;if(N.GroupFaceUrl){var v=new Gt.Elem.GroupTip.GroupInfo(O.FACE_URL,N.GroupFaceUrl);E.addGroupInfo(v),C=!0,R.GroupFaceUrl=N.GroupFaceUrl}if(N.GroupName){var P=new Gt.Elem.GroupTip.GroupInfo(O.NAME,N.GroupName);E.addGroupInfo(P),C=!0,R.GroupName=N.GroupName}if(N.Owner_Account){var U=new Gt.Elem.GroupTip.GroupInfo(O.OWNER,N.Owner_Account);E.addGroupInfo(U),C=!0,R.OwnerAccount=N.Owner_Account}if(N.GroupNotification){var b=new Gt.Elem.GroupTip.GroupInfo(O.NOTIFICATION,N.GroupNotification);E.addGroupInfo(b),C=!0,R.GroupNotification=N.GroupNotification}if(N.GroupIntroduction){var L=new Gt.Elem.GroupTip.GroupInfo(O.INTRODUCTION,N.GroupIntroduction);E.addGroupInfo(L),C=!0,R.GroupIntroduction=N.GroupIntroduction}0==n&&C&&t&&t(R)}else if(F.MODIFY_MEMBER_INFO==A){var D=M.MsgContent.MsgMemberInfo;for(var k in D){var w=D[k];E.addMemberInfo(new Gt.Elem.GroupTip.MemberInfo(w.User_Account,w.ShutupTime))}}break;case g.CUSTOM:_=g.CUSTOM,E=new Gt.Elem.Custom(M.MsgContent.Data,M.MsgContent.Desc,M.MsgContent.Ext);break;default:_=g.TEXT,E=new Gt.Elem.Text("web端暂不支持"+M.MsgType+"消息")}I.elems.push(new Gt.Elem(_,E))}return 0==o?I:Ft.addMsg(I,!0)?(I.extraInfo=e.GroupInfo.MsgFrom_AccountExtraInfo,I):null};this.init=function(u,a,l){if(u.onMsgNotify||re.warn("listeners.onMsgNotify is empty"),e=u.onMsgNotify,u.onBigGroupMsgNotify?c=u.onBigGroupMsgNotify:re.warn("listeners.onBigGroupMsgNotify is empty"),u.onC2cEventNotifys?E=u.onC2cEventNotifys:re.warn("listeners.onC2cEventNotifys is empty"),u.onGroupSystemNotifys?n=u.onGroupSystemNotifys:re.warn("listeners.onGroupSystemNotifys is empty"),u.onGroupInfoChangeNotify?t=u.onGroupInfoChangeNotify:re.warn("listeners.onGroupInfoChangeNotify is empty"),u.onFriendSystemNotifys?o=u.onFriendSystemNotifys:re.warn("listeners.onFriendSystemNotifys is empty"),u.onProfileSystemNotifys?r=u.onProfileSystemNotifys:re.warn("listeners.onProfileSystemNotifys is empty"),u.onKickedEventCall?i=u.onKickedEventCall:re.warn("listeners.onKickedEventCall is empty"),u.onLongPullingNotify?onLongPullingNotify=u.onLongPullingNotify:re.warn("listeners.onKickedEventCall is empty"),u.onAppliedDownloadUrl?_=u.onAppliedDownloadUrl:re.warn("listeners.onAppliedDownloadUrl is empty"),V.identifier&&V.userSig)b(function(e){re.info("initMyGroupMaxSeqs success"),P(function(e){if(re.info("initIpAndAuthkey success"),a){re.info("login success(have login state))");var t={ActionStatus:d.OK,ErrorCode:0,ErrorInfo:"login success"};a(t)}Ot.setLongPollingOn(!0),s&&Ot.longPolling(a)},l)},l);else if(a){var p={ActionStatus:d.OK,ErrorCode:0,ErrorInfo:"login success(no login state)"};a(p)}},this.sendMsg=function(e,t,n){Ce(e,function(o){if(e.sess.type()==l.C2C){if(!Ft.addMsg(e)){var r="sendMsg: addMsg failed!",i=oe.getReturnError(r,-17);return re.error(r),void(n&&n(i))}Ft.updateTimeline()}t&&t(o)},function(e){n&&n(e)})}},Rt=new function(){this.fileMd5=null;var e=function(e,t,n){function o(){var t=a*s,n=t+s>=e.size?e.size:t+s,o=i.call(e,t,n);r.readAsArrayBuffer(o)}var r=null;try{r=new FileReader}catch(e){if(n)return void n(oe.getReturnError("当前浏览器不支持FileReader",-18))}var i=File.prototype.mozSlice||File.prototype.webkitSlice||File.prototype.slice;if(!i&&n)return void n(oe.getReturnError("当前浏览器不支持FileAPI",-19));var s=2097152,u=Math.ceil(e.size/s),a=0,c=new SparkMD5;r.onload=function(e){for(var n="",r=new Uint8Array(e.target.result),i=r.byteLength,s=0;sn.total?(i=n.total,
n.sliceSize=i-e):n.sliceSize=n.step,n.sliceOffset=e,t=n.blobSlice.call(o,e,i),n.reader.readAsDataURL(t)},abortHandler:function(){var e=r;e.reader&&e.reader.abort()}};e(t.file,function(e){re.info("fileMd5: "+e),t.fileMd5=e,r.init(t,n,o),r.upload()},o)}};t.SESSION_TYPE=l,t.MSG_MAX_LENGTH=f,t.C2C_MSG_SUB_TYPE=A,t.GROUP_MSG_SUB_TYPE=S,t.MSG_ELEMENT_TYPE=g,t.GROUP_TIP_TYPE=F,t.IMAGE_TYPE=m,t.GROUP_SYSTEM_TYPE=R,t.FRIEND_NOTICE_TYPE=N,t.GROUP_TIP_MODIFY_GROUP_INFO_TYPE=O,t.BROWSER_INFO=s,t.Emotions=t.EmotionPicData=ne,t.EmotionDataIndexs=t.EmotionPicDataIndex=te,t.TLS_ERROR_CODE=P,t.CONNECTION_STATUS=U,t.UPLOAD_PIC_BUSSINESS_TYPE=b,t.RECENT_CONTACT_TYPE=p,t.UPLOAD_RES_TYPE=y,t.Tool=oe,t.Log=re,t.Msg=Gt,t.Session=Ct,t.MsgStore={sessMap:function(){return Ft.sessMap()},sessCount:function(){return Ft.sessCount()},sessByTypeId:function(e,t){return Ft.sessByTypeId(e,t)},delSessByTypeId:function(e,t){return Ft.delSessByTypeId(e,t)},resetCookieAndSyncFlag:function(){return Ft.resetCookieAndSyncFlag()}},t.Resources=ee,t.login=t.init=function(e,t,n,o,r){At.init(t.onConnNotify,o,r),_e(e,t,n,o,r)},t.logout=t.offline=function(e,t){return Ae("instance",e,t)},t.logoutAll=function(e,t){return Ae("all",e,t)},t.sendMsg=function(e,t,n){return Ot.sendMsg(e,t,n)},t.syncMsgs=function(e,t){return Ot.syncMsgs(e,t)},t.getC2CHistoryMsgs=function(e,t,n){return Ot.getC2CHistoryMsgs(e,t,n)},t.syncGroupMsgs=function(e,t,n){return Ot.syncGroupMsgs(e,t,n)},t.c2CMsgReaded=function(e,t,n){return Ft.c2CMsgReaded(e,t,n)},t.groupMsgReaded=function(e,t,n){return nt(e,t,n)},t.setAutoRead=function(e,t,n){return Ft.setAutoRead(e,t,n)},t.createGroup=function(e,t,n){return ve(e,t,n)},t.createGroupHigh=function(e,t,n){return Pe(e,t,n)},t.applyJoinGroup=function(e,t,n){return be(e,t,n)},t.handleApplyJoinGroupPendency=function(e,t,n){return De(e,t,n)},t.getPendencyGroup=function(e,t,n){return ke(e,t,n)},t.getPendencyGroupRead=function(e,t,n){return we(e,t,n)},t.handleInviteJoinGroupRequest=function(e,t,n){return qe(e,t,n)},t.deleteApplyJoinGroupPendency=function(e,t,n){return Re(e,t,n)},t.quitGroup=function(e,t,n){return Be(e,t,n)},t.searchGroupByName=function(e,t,n){return Ke(e,t,n)},t.getGroupPublicInfo=function(e,t,n){return He(e,t,n)},t.getGroupInfo=function(e,t,n){return ze(e,t,n)},t.modifyGroupBaseInfo=function(e,t,n){return Ue(e,t,n)},t.getGroupMemberInfo=function(e,t,n){return Je(e,t,n)},t.addGroupMember=function(e,t,n){return Ve(e,t,n)},t.modifyGroupMember=function(e,t,n){return Ye(e,t,n)},t.deleteGroupMember=function(e,t,n){return Xe(e,t,n)},t.destroyGroup=function(e,t,n){return je(e,t,n)},t.changeGroupOwner=function(e,t,n){return We(e,t,n)},t.getJoinedGroupListHigh=function(e,t,n){return Qe(e,t,n)},t.getRoleInGroup=function(e,t,n){return $e(e,t,n)},t.forbidSendMsg=function(e,t,n){return Ze(e,t,n)},t.sendCustomGroupNotify=function(e,t,n){return et(e,t,n)},t.applyJoinBigGroup=function(e,t,n){return Le(e,t,n)},t.quitBigGroup=function(e,t,n){return xe(e,t,n)},t.getProfilePortrait=function(e,t,n){return ft(e,t,n)},t.setProfilePortrait=function(e,t,n){return dt(e,t,n)},t.applyAddFriend=function(e,t,n){return rt(e,t,n)},t.getPendency=function(e,t,n){return ut(e,t,n)},t.getPendencyReport=function(e,t,n){return at(e,t,n)},t.deletePendency=function(e,t,n){return ct(e,t,n)},t.responseFriend=function(e,t,n){return lt(e,t,n)},t.getAllFriend=function(e,t,n){return pt(e,t,n)},t.deleteChat=function(e,t,n){return st(e,t,n)},t.deleteFriend=function(e,t,n){return it(e,t,n)},t.addBlackList=function(e,t,n){return gt(e,t,n)},t.deleteBlackList=function(e,t,n){return mt(e,t,n)},t.getBlackList=function(e,t,n){return It(e,t,n)},t.getRecentContactList=function(e,t,n){return Mt(e,t,n)},t.uploadFile=t.uploadPic=function(e,t,n){return Rt.uploadFile(e,t,n)},t.submitUploadFileForm=function(e,t,n){return Rt.submitUploadFileForm(e,t,n)},t.uploadFileByBase64=t.uploadPicByBase64=function(e,t,n){var o={To_Account:e.toAccount,Busi_Id:e.businessType,File_Type:e.File_Type,File_Str_Md5:e.fileMd5,PkgFlag:M.BASE64_DATA,File_Size:e.totalSize,Slice_Offset:0,Slice_Size:e.totalSize,Slice_Data:e.base64Str,Seq:se(),Timestamp:ie(),Random:ue()};return Et(o,t,n)},t.getLongPollingId=function(e,t,n){return ht(0,t,n)},t.applyDownload=function(e,t,n){return Tt(e,t,n)},t.checkLogin=function(e,t){return pe(e,t)}}(t),t}();