Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/cvetdv.ru/bitrix/js/im/v2/component/recent-list/dist/ |
Upload File : |
this.BX=this.BX||{};this.BX.Messenger=this.BX.Messenger||{};(function(t,e,i,s,n,a,r,o,c,l,d,h,u){"use strict";const m={name:"NewUserPopup",props:{title:{type:String,required:true},text:{type:String,required:true}},emits:["click","close"],mounted(){BX.MessengerProxy.playNewUserSound();this.setCloseTimer(5e3);this.onClosePopupHandler=this.onClosePopup.bind(this);h.EventEmitter.subscribe(u.EventType.dialog.closePopup,this.onClosePopupHandler)},beforeUnmount(){h.EventEmitter.unsubscribe(u.EventType.dialog.closePopup,this.onClosePopupHandler)},methods:{onClick(){this.$emit("click");this.$emit("close")},onMouseOver(){clearTimeout(this.closeTimeout)},onMouseLeave(){this.setCloseTimer(2e3)},setCloseTimer(t){this.closeTimeout=setTimeout((()=>{this.$emit("close")}),t)},onClosePopup(){this.$emit("close")}},template:`\n\t\t<Transition name="bx-im-recent-new-user-popup">\n\t\t\t<div @click="onClick" @mouseover="onMouseOver" @mouseleave="onMouseLeave" class="bx-im-recent-new-user-popup">\n\t\t\t\t<div class="bx-im-recent-new-user-popup-title">{{ title }}</div>\n\t\t\t\t<div class="bx-im-recent-new-user-popup-text">{{ text }}</div>\n\t\t\t</div>\n\t\t</Transition>\n\t`};const g={name:"RecentItem",components:{Avatar:o.Avatar,ChatTitle:o.ChatTitle,NewUserPopup:m},props:{item:{type:Object,required:true},compactMode:{type:Boolean,default:false},isVisibleOnScreen:{type:Boolean,required:true}},data(){return{showNewUserPopup:false}},computed:{AvatarSize:()=>u.AvatarSize,formattedDate(){if(this.needsBirthdayPlaceholder){return this.$Bitrix.Loc.getMessage("IM_RECENT_BIRTHDAY_DATE")}return this.formatDate(this.item.message.date)},messageText(){if(!this.item.message||!this.item.message.text){return this.isUser?this.$store.getters["users/getPosition"](this.item.dialogId):this.hiddenMessageText}return this.$store.getters["recent/getItemText"](this.item.dialogId)},hiddenMessageText(){if(this.isUser){return this.$store.getters["users/getPosition"](this.item.dialogId)}if(this.dialog.type===u.ChatTypes.open){return this.$Bitrix.Loc.getMessage("IM_RECENT_CHAT_TYPE_OPEN")}return this.$Bitrix.Loc.getMessage("IM_RECENT_CHAT_TYPE_GROUP")},statusIcon(){if(!this.isLastMessageAuthor||this.isBot||this.needsBirthdayPlaceholder||!this.item.message){return""}if(this.isSelfChat){return""}if(this.item.message.status===u.MessageStatus.error){return"error"}if(this.item.liked){return"like"}if(this.item.message.status===u.MessageStatus.delivered){return"read"}return"unread"},formattedCounter(){return this.dialog.counter>99?"99+":this.dialog.counter},user(){return this.$store.getters["users/get"](this.item.dialogId,true)},dialog(){return this.$store.getters["dialogues/get"](this.item.dialogId,true)},currentUserId(){return this.$store.state.application.common.userId},isUser(){return this.dialog.type===u.ChatTypes.user},isChat(){return!this.isUser},isSelfChat(){return this.isUser&&this.user.id===this.currentUserId},isBot(){if(this.isUser){return this.user.bot}return false},isLastMessageAuthor(){if(!this.item.message){return false}return this.currentUserId===this.item.message.senderId},lastMessageAuthorAvatar(){const t=this.$store.getters["dialogues/get"](this.item.message.senderId);if(!t){return""}return t.avatar},lastMessageAuthorAvatarStyle(){return{backgroundImage:`url('${this.lastMessageAuthorAvatar}')`}},isChatMuted(){if(this.isUser){return false}const t=this.dialog.muteList.find((t=>t===this.currentUserId));return!!t},needsBirthdayPlaceholder(){if(!this.isUser){return false}return this.$store.getters["recent/needsBirthdayPlaceholder"](this.item.dialogId)},showBirthdays(){return this.$store.getters["recent/getOption"](u.RecentSettings.showBirthday)},showLastMessage(){return this.$store.getters["recent/getOption"](u.RecentSettings.showLastMessage)},invitation(){return this.item.invitation},newUserPopupContainer(){return`#popup-window-content-bx-im-recent-welcome-${this.item.dialogId}`}},watch:{invitation(t,e){if(!this.compactMode){return false}if(e.isActive===true&&t.isActive===false){this.openNewUserPopup()}}},methods:{openNewUserPopup(){if(!this.isVisibleOnScreen||BX.MessengerProxy.isSliderOpened()){return false}this.newUserPopup=this.getNewUserPopup();this.newUserPopup.show();this.showNewUserPopup=true;this.$nextTick((()=>{this.newUserPopup.setOffset({offsetTop:-this.newUserPopup.popupContainer.offsetHeight+1,offsetLeft:-this.newUserPopup.popupContainer.offsetWidth+13});this.newUserPopup.adjustPosition()}))},getNewUserPopup(){return r.PopupManager.create({id:`bx-im-recent-welcome-${this.item.dialogId}`,bindElement:this.$refs.container,bindOptions:{forceBindPosition:true},className:"bx-im-recent-welcome",cacheable:false,animation:{showClassName:"bx-im-recent-new-user-popup-show",closeClassName:"bx-im-recent-new-user-popup-hide",closeAnimationType:"animation"}})},onNewUserPopupClick(t){const e=!this.compactMode||t.altKey?u.OpenTarget.current:u.OpenTarget.auto;h.EventEmitter.emit(u.EventType.dialog.open,{...this.item,target:e})},onNewUserPopupClose(){this.newUserPopup.close();this.newUserPopup=null;this.showNewUserPopup=false},formatDate(t){const e=[["today","H:i"],["d7","D"],["","d.m.Y"]];return BX.date.format(e,t)}},template:`\n\t\t<div :data-id="item.dialogId" class="bx-im-recent-item-wrap">\n\t\t<div v-if="!compactMode" :class="{'bx-im-recent-item-no-text': !showLastMessage, 'bx-im-recent-item-pinned': item.pinned}" class="bx-im-recent-item">\n\t\t\t<div class="bx-im-recent-avatar-wrap">\n\t\t\t\t<Avatar :dialogId="item.dialogId" :size="AvatarSize.L" :withTyping="true"/>\n\t\t\t</div>\n\t\t\t<div class="bx-im-recent-item-content">\n\t\t\t\t<div class="bx-im-recent-item-content-header">\n\t\t\t\t\t<ChatTitle :dialogId="item.dialogId" :withMute="true" />\n\t\t\t\t\t<div class="bx-im-recent-date">\n\t\t\t\t\t\t<div v-if="statusIcon" :class="'bx-im-recent-status-icon bx-im-recent-status-icon-' + statusIcon"></div>\n\t\t\t\t\t\t{{ formattedDate }}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div class="bx-im-recent-item-content-bottom">\n\t\t\t\t\t<div class="bx-im-recent-message-text-wrap">\n\t\t\t\t\t\t\x3c!-- Message text --\x3e\n\t\t\t\t\t\t<span class="bx-im-recent-message-text">\n\t\t\t\t\t\t\t<template v-if="item.draft.text && dialog.counter === 0">\n\t\t\t\t\t\t\t\t<span class="bx-im-recent-draft-prefix">{{ $Bitrix.Loc.getMessage('IM_RECENT_MESSAGE_DRAFT_2', {'#TEXT#': ''}) }}</span>\n\t\t\t\t\t\t\t\t<span>{{ item.draft.text }}</span>\n\t\t\t\t\t\t\t</template>\n\t\t\t\t\t\t\t<template v-else-if="item.invitation.isActive">\n\t\t\t\t\t\t\t\t<span class="bx-im-recent-message-text-invitation">{{ $Bitrix.Loc.getMessage('IM_RECENT_INVITATION_NOT_ACCEPTED') }}</span>\n\t\t\t\t\t\t\t</template>\n\t\t\t\t\t\t\t<template v-else-if="needsBirthdayPlaceholder">\n\t\t\t\t\t\t\t\t{{ $Bitrix.Loc.getMessage('IM_RECENT_BIRTHDAY') }}\n\t\t\t\t\t\t\t</template>\n\t\t\t\t\t\t\t<template v-else-if="!showLastMessage">\n\t\t\t\t\t\t\t\t{{ hiddenMessageText }}\n\t\t\t\t\t\t\t</template>\n\t\t\t\t\t\t\t<template v-else>\n\t\t\t\t\t\t\t\t<span v-if="isLastMessageAuthor" class="bx-im-recent-last-message-author-icon-self"></span>\n\t\t\t\t\t\t\t\t<template v-else-if="isChat && item.message.senderId">\n\t\t\t\t\t\t\t\t\t<span v-if="lastMessageAuthorAvatar" :style="lastMessageAuthorAvatarStyle" class="bx-im-recent-last-message-author-icon-user"></span>\n\t\t\t\t\t\t\t\t\t<span v-else class="bx-im-recent-last-message-author-icon-user bx-im-recent-last-message-author-icon-user-default"></span>\n\t\t\t\t\t\t\t\t</template>\n\t\t\t\t\t\t\t\t<span>{{ messageText }}</span>\n\t\t\t\t\t\t\t</template>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\x3c!-- End message text --\x3e\n\t\t\t\t\t</div>\n\t\t\t\t\t<div :class="{'bx-im-recent-counter-static-wrap-extended': dialog.counter > 99}" class="bx-im-recent-counter-static-wrap">\n\t\t\t\t\t\t<div v-if="item.unread || item.pinned || dialog.counter > 0" class="bx-im-recent-counter-wrap">\n\t\t\t\t\t\t\t<div v-if="item.pinned && dialog.counter === 0 && !item.unread" class="bx-im-recent-pinned-icon"></div>\n\t\t\t\t\t\t\t<div v-if="dialog.counter > 0 && !isSelfChat" :class="{'bx-im-recent-counter-muted': isChatMuted}" class="bx-im-recent-counter">\n\t\t\t\t\t\t\t\t{{ formattedCounter }}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div v-else-if="item.unread" :class="{'bx-im-recent-counter-muted': isChatMuted}" class="bx-im-recent-counter bx-im-recent-counter-unread"></div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t\t<div v-if="compactMode" class="bx-im-recent-item" :class="{'bx-im-recent-item-pinned': item.pinned, 'bx-im-recent-item-no-counter': dialog.counter === 0}" ref="container">\n\t\t\t<div class="bx-im-recent-avatar-wrap">\n\t\t\t\t<Avatar\n\t\t\t\t\t:dialogId="item.dialogId"\n\t\t\t\t\t:size="AvatarSize.M"\n\t\t\t\t\t:withStatus="false"\n\t\t\t\t\t:withCounter="true"\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<template v-if="showNewUserPopup">\n\t\t\t\t<Teleport :to="newUserPopupContainer">\n\t\t\t\t\t<NewUserPopup :title="dialog.name" :text="$Bitrix.Loc.getMessage('IM_RECENT_NEW_USER_POPUP_TEXT')" @click="onNewUserPopupClick" @close="onNewUserPopupClose"/>\n\t\t\t\t</Teleport>\n\t\t\t</template>\n\t\t</div>\n\t\t</div>\n\t`};const p={name:"ActiveCall",components:{Avatar:o.Avatar},props:{item:{type:Object,required:true},compactMode:{type:Boolean,default:false}},emits:["click","contextmenu"],computed:{RecentCallStatus:()=>u.RecentCallStatus,AvatarSize:()=>u.AvatarSize,chatData(){return this.item.call.associatedEntity},isUser(){return this.chatData.advanced.chatType===u.DialogType.private},isTabWithActiveCall(){return this.getCallController().hasActiveCall()},avatarStyle(){return{backgroundImage:`url(${this.chatData.avatar})`}},avatarText(){return l.Utils.text.getFirstLetters(this.item.name)},isDarkTheme(){return this.application.options.darkTheme},formattedName(){return l.Utils.text.htmlspecialcharsback(this.item.name)},...a.mapState({application:t=>t.application})},methods:{onJoinClick(t){if(this.joinMenu){this.joinMenu.destroy()}this.joinMenu=this.getJoinMenu(t);this.joinMenu.show()},onHangupClick(){this.getCallController().leaveCurrentCall()},onClick(t){if(this.item.state===u.RecentCallStatus.joined){this.getCallController().unfold();return}const e=this.$store.getters["recent/get"](this.item.dialogId);if(!e){return}this.$emit("click",{item:e,$event:t})},onRightClick(){const t=this.$store.getters["recent/get"](this.item.dialogId);if(!t){return}this.$emit("contextmenu",{item:t,$event:event})},getJoinMenu(t){return r.MenuManager.create({id:"im-recent-active-call-join-menu",bindElement:t.target,darkMode:this.isDarkTheme,cacheable:false,items:[{text:d.Loc.getMessage("IM_RECENT_ACTIVE_CALL_JOIN_VIDEO"),onclick:function(){this.getCallController().joinCall(this.item.call.id,true);this.joinMenu.close()}.bind(this)},{text:d.Loc.getMessage("IM_RECENT_ACTIVE_CALL_JOIN_AUDIO"),onclick:function(){this.getCallController().joinCall(this.item.call.id,false);this.joinMenu.close()}.bind(this)}]})},getCallController(){return BX.MessengerProxy.getCallController()}},template:`\n\t\t<div :data-id="item.dialogId" class="bx-im-recent-item-wrap">\n\t\t<div v-if="!compactMode" @click="onClick" @click.right.prevent="onRightClick" class="bx-im-recent-item bx-im-recent-active-call-item">\n\t\t\t<div class="bx-im-recent-avatar-wrap">\n\t\t\t\t<Avatar :dialogId="item.dialogId" :size="AvatarSize.L" />\n\t\t\t</div>\n\t\t\t<div class="bx-im-recent-item-content">\n\t\t\t\t\x3c!-- Waiting status --\x3e\n\t\t\t\t<template v-if="item.state === RecentCallStatus.waiting">\n\t\t\t\t\t\x3c!-- 1-on-1 --\x3e\n\t\t\t\t\t<div v-if="isUser" class="bx-im-recent-active-call-waiting-content">\n\t\t\t\t\t\t<div class="bx-im-recent-active-call-icon bx-im-recent-active-call-waiting-icon"></div>\n\t\t\t\t\t\t<div class="bx-im-recent-active-call-waiting-title">\n\t\t\t\t\t\t\t{{ formattedName }}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t\x3c!-- Chat --\x3e\n\t\t\t\t\t<div v-else>\n\t\t\t\t\t\t<div class="bx-im-recent-item-content-header">\n\t\t\t\t\t\t\t<div class="bx-im-recent-active-call-icon bx-im-recent-active-call-waiting-icon"></div>\n\t\t\t\t\t\t\t<span class="bx-im-recent-active-call-waiting-title" :title="formattedName">\n\t\t\t\t\t\t\t\t{{ formattedName }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="bx-im-recent-item-content-bottom">\n\t\t\t\t\t\t\t<div @click.stop="onJoinClick" class="bx-im-recent-active-call-button bx-im-recent-active-call-join-button">\n\t\t\t\t\t\t\t\t{{ $Bitrix.Loc.getMessage('IM_RECENT_ACTIVE_CALL_JOIN') }}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</template>\n\t\t\t\t\x3c!-- Joined status --\x3e\n\t\t\t\t<template v-else-if="item.state === RecentCallStatus.joined">\n\t\t\t\t\t\x3c!-- 1-on-1 --\x3e\n\t\t\t\t\t<div v-if="isUser || !isTabWithActiveCall" class="bx-im-recent-active-call-joined-content">\n\t\t\t\t\t\t<div class="bx-im-recent-active-call-icon bx-im-recent-active-call-joined-icon"></div>\n\t\t\t\t\t\t<div class="bx-im-recent-active-call-joined-title">\n\t\t\t\t\t\t\t{{ formattedName }}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t\x3c!-- Chat --\x3e\n\t\t\t\t\t<div v-else-if="!isUser && isTabWithActiveCall">\n\t\t\t\t\t\t<div class="bx-im-recent-item-content-header">\n\t\t\t\t\t\t\t<div class="bx-im-recent-active-call-icon bx-im-recent-active-call-joined-icon"></div>\n\t\t\t\t\t\t\t<span class="bx-im-recent-active-call-joined-title" :title="formattedName">\n\t\t\t\t\t\t\t\t{{ formattedName }}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="bx-im-recent-item-content-bottom">\n\t\t\t\t\t\t\t<div @click.stop="onHangupClick" class="bx-im-recent-active-call-button bx-im-recent-active-call-hangup-button">\n\t\t\t\t\t\t\t\t{{ $Bitrix.Loc.getMessage('IM_RECENT_ACTIVE_CALL_HANGUP') }}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</template>\n\t\t\t</div>\n\t\t</div>\n\t\t<div v-if="compactMode" @click="onClick" @click.right.prevent="onRightClick" class="bx-im-recent-item bx-im-recent-active-call-item">\n\t\t\t<div class="bx-im-recent-avatar-wrap">\n\t\t\t\t<Avatar :dialogId="item.dialogId" :size="AvatarSize.M" />\n\t\t\t\t<div class="bx-im-recent-active-call-compact-icon-container">\n\t\t\t\t\t<div v-if="item.state === RecentCallStatus.waiting" class="bx-im-recent-active-call-icon bx-im-recent-active-call-waiting-icon"></div>\n\t\t\t\t\t<div v-else-if="item.state === RecentCallStatus.joined" class="bx-im-recent-active-call-icon bx-im-recent-active-call-joined-icon"></div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t\t</div>\n\t`};class v{static init(t){if(this.instance){return}this.instance=new this(t)}constructor(t){this.store=null;this.store=t.Data.get("controller").store;this.initSettings();this.onSettingsChangeHandler=this.onSettingsChange.bind(this);h.EventEmitter.subscribe(u.EventType.dialog.settingsChange,this.onSettingsChangeHandler);if(l.Utils.platform.isBitrixDesktop()&&!d.Type.isUndefined(BX.desktop)){BX.desktop.addCustomEvent("bxSaveSettings",(t=>{this.onSettingsChangeHandler({data:t})}))}}initSettings(){if(!BX.MessengerProxy){console.error("Im.RecentList: SettingsManager: BX.MessengerProxy is not available");return false}this.initGeneralSettings();this.initRecentSettings()}initGeneralSettings(){const t={};Object.entries(u.SettingsMap).forEach((([e,i])=>{t[i]=BX.MessengerProxy.getOption(e)}));this.store.dispatch("application/setOptions",t)}initRecentSettings(){const t={};Object.entries(u.RecentSettingsMap).forEach((([e,i])=>{t[i]=BX.MessengerProxy.getOption(e)}));this.store.dispatch("recent/setOptions",t)}onSettingsChange({data:t}){c.Logger.warn("Im.RecentList: SettingsChange",t);const e={};const i={};Object.entries(t).forEach((([t,s])=>{if(Object.keys(u.RecentSettingsMap).includes(t)){i[u.RecentSettingsMap[t]]=s}if(Object.keys(u.SettingsMap).includes(t)){e[u.SettingsMap[t]]=s}}));this.store.dispatch("application/setOptions",e);this.store.dispatch("recent/setOptions",i)}destroy(){h.EventEmitter.unsubscribe(u.EventType.dialog.settingsChange,this.onSettingsChangeHandler)}}v.instance=null;class C extends h.EventEmitter{static getInstance(){if(!this.instance){this.instance=new this}return this.instance}constructor(){super();this.setEventNamespace(C.eventNamespace);this.init()}isSupported(){return!d.Type.isUndefined(window.BroadcastChannel)&&!l.Utils.platform.isBitrixDesktop()}init(){if(!this.isSupported()){return}this.channel=new BroadcastChannel(C.channelName);this.channel.addEventListener("message",(({data:{type:t,data:e}})=>{this.emit(t,e)}))}sendRecentList(t){if(!this.isSupported()){return}this.channel.postMessage({type:C.events.recentListUpdate,data:t})}}C.instance=null;C.channelName="im-recent";C.eventNamespace="BX.Messenger.v2.Recent.BroadcastManager";C.events={recentListUpdate:"recentListUpdate"};class b{static init(t){if(this.instance){return}this.instance=new this(t)}constructor(t){this.store=null;this.store=t.Data.get("controller").store;this.onCallCreatedHandler=this.onCallCreated.bind(this);h.EventEmitter.subscribe("CallEvents::callCreated",this.onCallCreatedHandler)}onCallCreated(t){const{call:e}=t.getData()[0];e.addEventListener(BX.Call.Event.onJoin,this.onCallJoin.bind(this));e.addEventListener(BX.Call.Event.onLeave,this.onCallLeave.bind(this));e.addEventListener(BX.Call.Event.onDestroy,this.onCallDestroy.bind(this));this.store.dispatch("recent/addActiveCall",{dialogId:e.associatedEntity.id,name:e.associatedEntity.name,call:e,state:u.RecentCallStatus.waiting})}onCallJoin(t){this.store.dispatch("recent/updateActiveCall",{dialogId:t.call.associatedEntity.id,fields:{state:u.RecentCallStatus.joined}})}onCallLeave(t){this.store.dispatch("recent/updateActiveCall",{dialogId:t.call.associatedEntity.id,fields:{state:u.RecentCallStatus.waiting}})}onCallDestroy(t){this.store.dispatch("recent/deleteActiveCall",{dialogId:t.call.associatedEntity.id})}destroy(){h.EventEmitter.unsubscribe(window,"CallEvents::callCreated",this.onCallCreatedHandler)}}b.instance=null;class f{static init(t){if(this.instance){return}this.instance=new this(t)}constructor(t){this.store=null;this.store=t.Data.get("controller").store;this.initDraftHistory();this.onSetDraftHandler=this.onSetDraft.bind(this);h.EventEmitter.subscribe(u.EventType.recent.setDraftMessage,this.onSetDraftHandler)}initDraftHistory(){const t=BX.MessengerProxy.getTextareaHistory();Object.entries(t).forEach((([t,e])=>{this.setDraftMessage(t,e)}))}onSetDraft({data:{dialogId:t,text:e}}){this.setDraftMessage(t,e)}setDraftMessage(t,e){this.store.dispatch("recent/draft",{id:t,text:e})}destroy(){h.EventEmitter.unsubscribe(u.EventType.recent.setDraftMessage,this.onSetDraftHandler)}}f.instance=null;class x{static init(t){if(this.instance){return}this.instance=new this(t)}constructor(t){this.store=null;this.store=t.Data.get("controller").store;this.subscribeToEvents()}subscribeToEvents(){this.onSetCounterHandler=this.onSetCounter.bind(this);this.onSetMessageHandler=this.onSetMessage.bind(this);this.onHideChatHandler=this.onHideChat.bind(this);this.onLeaveChatHandler=this.onLeaveChat.bind(this);this.onClearLikeHandler=this.onClearLike.bind(this);this.onClearHistoryHandler=this.onClearHistory.bind(this);h.EventEmitter.subscribe(u.EventType.recent.setCounter,this.onSetCounterHandler);h.EventEmitter.subscribe(u.EventType.recent.setMessage,this.onSetMessageHandler);h.EventEmitter.subscribe(u.EventType.recent.hideChat,this.onHideChatHandler);h.EventEmitter.subscribe(u.EventType.recent.leaveChat,this.onLeaveChatHandler);h.EventEmitter.subscribe(u.EventType.recent.clearLike,this.onClearLikeHandler);h.EventEmitter.subscribe(u.EventType.dialog.clearHistory,this.onClearHistoryHandler)}onSetCounter({data:{dialogId:t,counter:e}}){const i=this.store.getters["recent/get"](t);const s=this.store.getters["dialogues/get"](t);if(!i||!s){return false}this.store.dispatch("dialogues/update",{dialogId:t,fields:{counter:e}})}onSetMessage({data:{id:t,dialogId:e,text:i,date:s}}){const n=this.store.getters["recent/get"](e);const a=this.store.getters["dialogues/get"](e);if(!n||!a){return false}if(t&&!t.toString().startsWith("temp")&&t!==n.message.id){return false}this.store.dispatch("recent/update",{id:e,fields:{message:{id:t||0,text:i,senderId:this.getCurrentUserId(),status:n.message.status,date:s||n.message.date}}})}onHideChat({data:{dialogId:t}}){const e=this.store.getters["recent/get"](t);if(!e){return false}this.store.dispatch("recent/delete",{id:t})}onLeaveChat({data:{dialogId:t}}){this.onHideChat({data:{dialogId:t}})}onClearLike({data:{dialogId:t}}){const e=this.store.getters["recent/get"](t);if(!e||!e.liked){return false}this.store.dispatch("recent/like",{id:t,liked:false})}onClearHistory({data:{dialogId:t}}){const e=this.store.getters["recent/get"](t);if(!e){return false}this.store.dispatch("recent/update",{id:t,fields:{message:{...e.message,text:d.Loc.getMessage("IM_RECENT_DELETED_MESSAGE")}}})}getCurrentUserId(){return this.store.state.application.common.userId}destroy(){this.unsubscribeEvents()}unsubscribeEvents(){h.EventEmitter.unsubscribe(u.EventType.recent.setCounter,this.onSetCounterHandler);h.EventEmitter.unsubscribe(u.EventType.recent.setMessage,this.onSetMessageHandler);h.EventEmitter.unsubscribe(u.EventType.recent.hideChat,this.onHideChatHandler);h.EventEmitter.unsubscribe(u.EventType.recent.leaveChat,this.onLeaveChatHandler);h.EventEmitter.unsubscribe(u.EventType.recent.clearLike,this.onClearLikeHandler)}}x.instance=null;const M={name:"RecentList",components:{LoadingState:o.RecentLoadingState,RecentItem:g,ActiveCall:p},directives:{"recent-list-observer":{mounted(t,e){e.instance.observer.observe(t)}}},props:{compactMode:{type:Boolean,default:false}},data(){return{isLoading:false,visibleElements:new Set}},computed:{collection(){return this.$store.getters["recent/getCollection"]},sections(){return[this.pinnedItems,this.generalItems]},preparedItems(){const t=this.collection.filter((t=>{if(!this.showBirthdays&&t.options.birthdayPlaceholder){return false}const e=this.$store.getters["dialogues/get"](t.dialogId,true);const i=e.type===u.ChatTypes.user;const s=i&&this.showBirthdays&&this.$store.getters["users/hasBirthday"](t.dialogId);if(!this.showInvited&&t.options.defaultUserRecord&&!s){return false}return true}));return[...t].sort(((t,e)=>{const i=this.$store.getters["recent/getMessageDate"](t.dialogId);const s=this.$store.getters["recent/getMessageDate"](e.dialogId);return s-i}))},pinnedItems(){return this.preparedItems.filter((t=>t.pinned===true))},generalItems(){return this.preparedItems.filter((t=>t.pinned===false))},isDarkTheme(){return this.application.options.darkTheme},showBirthdays(){return this.$store.getters["recent/getOption"](u.RecentSettings.showBirthday)},showInvited(){return this.$store.getters["recent/getOption"](u.RecentSettings.showInvited)},transitionType(){if(this.compactMode){return""}if(this.isLoading){return""}return"bx-messenger-recent-transition"},...a.mapState({activeCalls:t=>t.recent.activeCalls,application:t=>t.application})},created(){this.recentService=i.RecentService.getInstance(this.$Bitrix);this.contextMenuManager=new s.RecentMenu(this.$Bitrix);b.init(this.$Bitrix);x.init(this.$Bitrix);v.init(this.$Bitrix);this.initBroadcastManager();this.initObserver();this.managePreloadedList();this.manageChatOptions()},mounted(){this.isLoading=true;this.recentService.loadFirstPage().then((()=>{this.isLoading=false;f.init(this.$Bitrix)}));this.initBirthdayCheck()},beforeUnmount(){this.contextMenuManager.destroy();this.clearBirthdayCheck();this.destroyBroadcastManager()},methods:{onScroll(t){this.contextMenuManager.close();if(!this.oneScreenRemaining(t)||!this.recentService.hasMoreItemsToLoad){return false}this.isLoading=true;this.recentService.loadNextPage().then((()=>{this.isLoading=false}))},onClick(t,e){const i=!this.compactMode||e.altKey?u.OpenTarget.current:u.OpenTarget.auto;h.EventEmitter.emit(u.EventType.dialog.open,{...t,chat:this.$store.getters["dialogues/get"](t.dialogId,true),user:this.$store.getters["users/get"](t.dialogId,true),target:i})},onRightClick(t,e){if(e.altKey&&e.shiftKey){return}const i=!this.compactMode||e.altKey?u.OpenTarget.current:u.OpenTarget.auto;const s={...t,compactMode:this.compactMode,target:i};this.contextMenuManager.openMenu(s,e.currentTarget);e.preventDefault()},onCallClick({item:t,$event:e}){this.onClick(t,e)},onCallRightClick({item:t,$event:e}){this.onRightClick(t,e)},oneScreenRemaining(t){return t.target.scrollTop+t.target.clientHeight>=t.target.scrollHeight-t.target.clientHeight},initObserver(){this.observer=new IntersectionObserver((t=>{t.forEach((t=>{if(t.isIntersecting&&t.intersectionRatio===1){this.visibleElements.add(t.target.dataset.id)}else if(!t.isIntersecting){this.visibleElements.delete(t.target.dataset.id)}}))}),{threshold:[0,1]})},initBroadcastManager(){this.onRecentListUpdate=t=>{this.recentService.setPreloadedData(t.data)};this.broadcastManager=C.getInstance();this.broadcastManager.subscribe(C.events.recentListUpdate,this.onRecentListUpdate)},destroyBroadcastManager(){this.broadcastManager=C.getInstance();this.broadcastManager.unsubscribe(C.events.recentListUpdate,this.onRecentListUpdate)},initBirthdayCheck(){const t=6e4*60*4;const e=6e4*60*24;this.birthdayCheckTimeout=setTimeout((()=>{this.recentService.loadFirstPage({ignorePreloadedItems:true});this.birthdayCheckInterval=setInterval((()=>{this.recentService.loadFirstPage({ignorePreloadedItems:true})}),e)}),l.Utils.date.getTimeToNextMidnight()+t)},clearBirthdayCheck(){clearTimeout(this.birthdayCheckTimeout);clearInterval(this.birthdayCheckInterval)},managePreloadedList(){const{preloadedList:t}=this.$Bitrix.Application.get().params;if(!t){return false}this.recentService.setPreloadedData(t);this.broadcastManager.sendRecentList(t)},manageChatOptions(){const{chatOptions:t}=this.$Bitrix.Application.get().params;if(!t){return false}this.$store.dispatch("dialogues/setChatOptions",t)}},template:`\n\t\t<div @scroll="onScroll" class="bx-messenger-recent-list" :class="{'bx-messenger-recent-compact': compactMode}" >\n\t\t\t<transition-group :name="transitionType">\n\t\t\t\t<ActiveCall\n\t\t\t\t\tv-for="activeCall in activeCalls"\n\t\t\t\t\t:key="'call-' + activeCall.dialogId"\n\t\t\t\t\t:item="activeCall"\n\t\t\t\t\t:compactMode="compactMode"\n\t\t\t\t\t@click="onCallClick"\n\t\t\t\t\t@click.right="onCallRightClick"\n\t\t\t\t/>\n\t\t\t\t<template v-for="section in sections">\n\t\t\t\t\t<RecentItem\n\t\t\t\t\t\tv-for="item in section"\n\t\t\t\t\t\t:key="item.dialogId"\n\t\t\t\t\t\t:item="item"\n\t\t\t\t\t\t:compactMode="compactMode"\n\t\t\t\t\t\t:isVisibleOnScreen="visibleElements.has(item.dialogId)"\n\t\t\t\t\t\tv-recent-list-observer\n\t\t\t\t\t\t@click="onClick(item, $event)"\n\t\t\t\t\t\t@click.right="onRightClick(item, $event)"\n\t\t\t\t\t/>\n\t\t\t\t</template>\n\t\t\t</transition-group>\n\t\t\t<LoadingState v-if="isLoading" :compactMode="compactMode" />\n\t\t\t<template v-if="collection.length === 0">\n\t\t\t\t<div class="bx-im-recent-empty">{{ $Bitrix.Loc.getMessage('IM_RECENT_EMPTY') }}</div>\n\t\t\t</template>\n\t\t</div>\n\t`};t.RecentList=M})(this.BX.Messenger.v2=this.BX.Messenger.v2||{},BX,BX.Messenger.v2.Provider.Service,BX.Messenger.v2.Lib,BX.Main,BX.Vue3.Vuex,BX.Main,BX.Messenger.v2,BX.Messenger.v2.Lib,BX.Messenger.v2.Lib,BX,BX.Event,BX.Messenger.v2.Const); //# sourceMappingURL=recent-list.bundle.map.js