File manager - Edit - /home/web/vm-3fadc827.na4u.ru/www/bitrix/modules/im/install/js/im/call/controller.min.js
Back
(function(){BX.namespace("BX.Call");if(BX.Call.Controller){return}var e={onViewStateChanged:"onViewStateChanged"};var t={Opened:"Opened",Closed:"Closed",Folded:"Folded"};var i={Resume:"resume",Blank:"blank"};var n=961;var l=328;var a="im:call-document:16102021:web";var o=6e4*5;var s="CallController::documentCreated";var r="docx";var c="xlsx";var d="pptx";BX.Call.Controller=function(i){this.messenger=i.messenger;this.container=null;this.docEditor=null;this.docEditorIframe=null;this.maxEditorWidth=l;this.docCreatedForCurrentCall=false;this.folded=false;this.currentCall=null;this.childCall=null;this.callView=null;this.callNotification=null;this.invitePopup=null;this.videoStrategy=null;this.isHttps=window.location.protocol==="https:";this.callWithLegacyMobile=false;this.featureScreenSharing=BX.Call.Controller.FeatureState.Enabled;this.featureRecord=BX.Call.Controller.FeatureState.Enabled;this.callRecordState=BX.Call.View.RecordState.Stopped;this.callRecordType=BX.Call.View.RecordType.None;this.autoCloseCallView=true;this.talkingUsers={};this._callViewState=t.Closed;Object.defineProperty(this,"callViewState",{get:function(){return this._callViewState},set:function(t){if(this.callViewState==t){return}this._callViewState=t;this.eventEmitter.emit(e.onViewStateChanged,{callViewState:t})}});this._onCallUserInvitedHandler=this._onCallUserInvited.bind(this);this._onCallDestroyHandler=this._onCallDestroy.bind(this);this._onCallUserStateChangedHandler=this._onCallUserStateChanged.bind(this);this._onCallUserMicrophoneStateHandler=this._onCallUserMicrophoneState.bind(this);this._onCallUserCameraStateHandler=this._onCallUserCameraState.bind(this);this._onCallUserVideoPausedHandler=this._onCallUserVideoPaused.bind(this);this._onCallLocalMediaReceivedHandler=this._onCallLocalMediaReceived.bind(this);this._onCallLocalMediaStoppedHandler=this._onCallLocalMediaStopped.bind(this);this._onCallLocalCameraFlipHandler=this._onCallLocalCameraFlip.bind(this);this._onCallLocalCameraFlipInDesktopHandler=this._onCallLocalCameraFlipInDesktop.bind(this);this._onCallRemoteMediaReceivedHandler=this._onCallRemoteMediaReceived.bind(this);this._onCallRemoteMediaStoppedHandler=this._onCallRemoteMediaStopped.bind(this);this._onCallUserVoiceStartedHandler=this._onCallUserVoiceStarted.bind(this);this._onCallUserVoiceStoppedHandler=this._onCallUserVoiceStopped.bind(this);this._onCallUserScreenStateHandler=this._onCallUserScreenState.bind(this);this._onCallUserRecordStateHandler=this._onCallUserRecordState.bind(this);this.onCallUserFloorRequestHandler=this._onCallUserFloorRequest.bind(this);this._onCallFailureHandler=this._onCallFailure.bind(this);this._onNetworkProblemHandler=this._onNetworkProblem.bind(this);this._onMicrophoneLevelHandler=this._onMicrophoneLevel.bind(this);this._onReconnectingHandler=this._onReconnecting.bind(this);this._onReconnectedHandler=this._onReconnected.bind(this);this._onCustomMessageHandler=this._onCustomMessage.bind(this);this._onCallLeaveHandler=this._onCallLeave.bind(this);this._onCallJoinHandler=this._onCallJoin.bind(this);this._onBeforeUnloadHandler=this._onBeforeUnload.bind(this);this._onImTabChangeHandler=this._onImTabChange.bind(this);this._onUpdateChatCounterHandler=this._onUpdateChatCounter.bind(this);this._onChildCallFirstMediaHandler=this._onChildCallFirstMedia.bind(this);this._onWindowFocusHandler=this._onWindowFocus.bind(this);this._onWindowBlurHandler=this._onWindowBlur.bind(this);if(BX.desktop&&false){this.floatingWindow=new BX.Call.FloatingVideo({onMainAreaClick:this._onFloatingVideoMainAreaClick.bind(this),onButtonClick:this._onFloatingVideoButtonClick.bind(this)});this.floatingWindowUser=0}this.showFloatingWindowTimeout=0;this.hideIncomingCallTimeout=0;if(BX.desktop){var n=!!BX.MessengerTheme.isDark();this.floatingScreenShareWindow=new BX.Call.FloatingScreenShare({darkMode:n,onBackToCallClick:this._onFloatingScreenShareBackToCallClick.bind(this),onStopSharingClick:this._onFloatingScreenShareStopClick.bind(this),onChangeScreenClick:this._onFloatingScreenShareChangeScreenClick.bind(this)})}this.showFloatingScreenShareWindowTimeout=0;this.mutePopup=null;this.allowMutePopup=true;this.webScreenSharePopup=null;this.feedbackPopup=null;this.eventEmitter=new BX.Event.EventEmitter(this,"BX.Call.Controller");this.resizeObserver=new BX.ResizeObserver(this._onResize.bind(this));this.init()};BX.Call.Controller.prototype={init:function(){BX.addCustomEvent(window,"CallEvents::incomingCall",this.onIncomingCall.bind(this));BX.Call.Hardware.subscribe(BX.Call.Hardware.Events.deviceChanged,this._onDeviceChange.bind(this));BX.Call.Hardware.subscribe(BX.Call.Hardware.Events.onChangeMirroringVideo,this._onCallLocalCameraFlipHandler);if(BX.desktop&&this.floatingWindow){window.addEventListener("blur",this._onWindowBlurHandler);window.addEventListener("focus",this._onWindowFocusHandler);BX.desktop.addCustomEvent("BXForegroundChanged",function(e){if(e){this._onWindowFocus()}else{this._onWindowBlur()}}.bind(this))}if(BX.desktop&&this.floatingScreenShareWindow){BX.desktop.addCustomEvent("BXScreenMediaSharing",function(e,t,i,n,l,a,o){this.floatingScreenShareWindow.close();this.floatingScreenShareWindow.setSharingData({title:t,x:i,y:n,width:l,height:a,app:o}).then(function(){this.floatingScreenShareWindow.show()}.bind(this)).catch(function(e){console.error("setSharingData error",e)}.bind(this))}.bind(this));window.addEventListener("blur",this._onWindowBlurHandler);window.addEventListener("focus",this._onWindowFocusHandler);BX.desktop.addCustomEvent("BXForegroundChanged",function(e){if(e){this._onWindowFocus()}else{this._onWindowBlur()}}.bind(this))}if(BX.desktop){BX.desktop.addCustomEvent(BX.Call.Hardware.Events.onChangeMirroringVideo,this._onCallLocalCameraFlipInDesktopHandler)}if(window["VoxImplant"]){VoxImplant.getInstance().addEventListener(VoxImplant.Events.MicAccessResult,this.voxMicAccessResult.bind(this))}window.addEventListener("beforeunload",this._onBeforeUnloadHandler);BX.addCustomEvent("OnDesktopTabChange",this._onImTabChangeHandler);BX.addCustomEvent(window,"onImUpdateCounterMessage",this._onUpdateChatCounter.bind(this));BX.garbage(this.destroy,this)},subscribe:function(e,t){return this.eventEmitter.subscribe(e,t)},unsubscribe:function(e,t){return this.eventEmitter.unsubscribe(e,t)},voxMicAccessResult:function(e){if(e.stream&&e.stream.getAudioTracks().length>0&&this.callView){this.callView.microphoneId=e.stream.getAudioTracks()[0].getSettings().deviceId}},getCallUsers:function(e){var t=Object.keys(this.currentCall.getUsers());if(e){t.push(this.currentCall.userId)}return t},getActiveCallUsers:function(){var e=[];var t=this.currentCall.getUsers();for(var i in t){if(t.hasOwnProperty(i)){if(t[i]===BX.Call.UserState.Connected||t[i]===BX.Call.UserState.Connecting||t[i]===BX.Call.UserState.Calling){e.push(i)}}}return e},updateFloatingWindowContent:function(){if(!this.floatingWindow||!this.currentCall){return}this.floatingWindow.setTitle(this.currentCall.associatedEntity.name);BX.Call.Util.getUserAvatars(this.currentCall.id,this.getActiveCallUsers()).then(function(e){this.floatingWindow.setAvatars(e)}.bind(this))},onIncomingCall:function(e){console.warn("incoming.call",e);var t=this;var i=e.call;this.callWithLegacyMobile=e.isLegacyMobile===true;var n=this.currentCall&&(this.callView||this.callNotification);if(!n){if(this.callView){return}this.checkDesktop().then((function(){return BX.Call.Hardware.init()})).then(function(){if(this.currentCall||i.state==BX.Call.State.Finished){return}this.currentCall=i;this.bindCallEvents();this.updateFloatingWindowContent();if(this.currentCall.associatedEntity.type==="chat"&&this.currentCall.associatedEntity.advanced["chatType"]==="videoconf"){this.isConferencePageOpened(this.currentCall.associatedEntity.id).then(function(e){if(e){this.removeCallEvents();this.currentCall=null}else{this.showIncomingConference()}}.bind(this))}else{var t=e.video===true;if(t&&!BX.Call.Hardware.hasCamera()){this.showNotification(BX.message("IM_CALL_ERROR_NO_CAMERA"));t=false}this.showIncomingCall({video:t})}}.bind(this),(function(e){if(t.currentCall){t.removeVideoStrategy();t.removeCallEvents();t.currentCall=null}console.error(e);t.log(e);if(!t.isHttps){t.showNotification(BX.message("IM_CALL_INCOMING_ERROR_HTTPS_REQUIRED"))}else{t.showNotification(BX.message("IM_CALL_INCOMING_UNSUPPORTED_BROWSER"))}}))}else{if(i.id==this.currentCall.id){}else if(i.parentId==this.currentCall.id){if(!this.childCall){this.childCall=i;this.childCall.users.forEach((function(e){this.callView.addUser(e,BX.Call.UserState.Calling)}),this);BX.Call.Util.getUsers(i.id,this.childCall.users).then(function(e){this.callView.updateUserData(e)}.bind(this));this.answerChildCall()}}else{i.decline(486);return false}}},bindCallEvents:function(){this.currentCall.addEventListener(BX.Call.Event.onUserInvited,this._onCallUserInvitedHandler);this.currentCall.addEventListener(BX.Call.Event.onDestroy,this._onCallDestroyHandler);this.currentCall.addEventListener(BX.Call.Event.onUserStateChanged,this._onCallUserStateChangedHandler);this.currentCall.addEventListener(BX.Call.Event.onUserMicrophoneState,this._onCallUserMicrophoneStateHandler);this.currentCall.addEventListener(BX.Call.Event.onUserCameraState,this._onCallUserCameraStateHandler);this.currentCall.addEventListener(BX.Call.Event.onUserVideoPaused,this._onCallUserVideoPausedHandler);this.currentCall.addEventListener(BX.Call.Event.onUserScreenState,this._onCallUserScreenStateHandler);this.currentCall.addEventListener(BX.Call.Event.onUserRecordState,this._onCallUserRecordStateHandler);this.currentCall.addEventListener(BX.Call.Event.onUserFloorRequest,this.onCallUserFloorRequestHandler);this.currentCall.addEventListener(BX.Call.Event.onLocalMediaReceived,this._onCallLocalMediaReceivedHandler);this.currentCall.addEventListener(BX.Call.Event.onLocalMediaStopped,this._onCallLocalMediaStoppedHandler);this.currentCall.addEventListener(BX.Call.Event.onRemoteMediaReceived,this._onCallRemoteMediaReceivedHandler);this.currentCall.addEventListener(BX.Call.Event.onRemoteMediaStopped,this._onCallRemoteMediaStoppedHandler);this.currentCall.addEventListener(BX.Call.Event.onUserVoiceStarted,this._onCallUserVoiceStartedHandler);this.currentCall.addEventListener(BX.Call.Event.onUserVoiceStopped,this._onCallUserVoiceStoppedHandler);this.currentCall.addEventListener(BX.Call.Event.onCallFailure,this._onCallFailureHandler);this.currentCall.addEventListener(BX.Call.Event.onNetworkProblem,this._onNetworkProblemHandler);this.currentCall.addEventListener(BX.Call.Event.onMicrophoneLevel,this._onMicrophoneLevelHandler);this.currentCall.addEventListener(BX.Call.Event.onReconnecting,this._onReconnectingHandler);this.currentCall.addEventListener(BX.Call.Event.onReconnected,this._onReconnectedHandler);this.currentCall.addEventListener(BX.Call.Event.onCustomMessage,this._onCustomMessageHandler);this.currentCall.addEventListener(BX.Call.Event.onJoin,this._onCallJoinHandler);this.currentCall.addEventListener(BX.Call.Event.onLeave,this._onCallLeaveHandler)},removeCallEvents:function(){this.currentCall.removeEventListener(BX.Call.Event.onUserInvited,this._onCallUserInvitedHandler);this.currentCall.removeEventListener(BX.Call.Event.onDestroy,this._onCallDestroyHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserStateChanged,this._onCallUserStateChangedHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserMicrophoneState,this._onCallUserMicrophoneStateHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserCameraState,this._onCallUserCameraStateHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserVideoPaused,this._onCallUserVideoPausedHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserScreenState,this._onCallUserScreenStateHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserRecordState,this._onCallUserRecordStateHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserFloorRequest,this.onCallUserFloorRequestHandler);this.currentCall.removeEventListener(BX.Call.Event.onLocalMediaReceived,this._onCallLocalMediaReceivedHandler);this.currentCall.removeEventListener(BX.Call.Event.onLocalMediaStopped,this._onCallLocalMediaStoppedHandler);this.currentCall.removeEventListener(BX.Call.Event.onRemoteMediaReceived,this._onCallRemoteMediaReceivedHandler);this.currentCall.removeEventListener(BX.Call.Event.onRemoteMediaStopped,this._onCallRemoteMediaStoppedHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserVoiceStarted,this._onCallUserVoiceStartedHandler);this.currentCall.removeEventListener(BX.Call.Event.onUserVoiceStopped,this._onCallUserVoiceStoppedHandler);this.currentCall.removeEventListener(BX.Call.Event.onCallFailure,this._onCallFailureHandler);this.currentCall.removeEventListener(BX.Call.Event.onNetworkProblem,this._onNetworkProblemHandler);this.currentCall.removeEventListener(BX.Call.Event.onMicrophoneLevel,this._onMicrophoneLevelHandler);this.currentCall.removeEventListener(BX.Call.Event.onReconnecting,this._onReconnectingHandler);this.currentCall.removeEventListener(BX.Call.Event.onReconnected,this._onReconnectedHandler);this.currentCall.removeEventListener(BX.Call.Event.onCustomMessage,this._onCustomMessageHandler);this.currentCall.removeEventListener(BX.Call.Event.onJoin,this._onCallJoinHandler);this.currentCall.removeEventListener(BX.Call.Event.onLeave,this._onCallLeaveHandler)},bindCallViewEvents:function(){this.callView.setCallback(BX.Call.View.Event.onShow,this._onCallViewShow.bind(this));this.callView.setCallback(BX.Call.View.Event.onClose,this._onCallViewClose.bind(this));this.callView.setCallback(BX.Call.View.Event.onDestroy,this._onCallViewDestroy.bind(this));this.callView.setCallback(BX.Call.View.Event.onButtonClick,this._onCallViewButtonClick.bind(this));this.callView.setCallback(BX.Call.View.Event.onBodyClick,this._onCallViewBodyClick.bind(this));this.callView.setCallback(BX.Call.View.Event.onReplaceCamera,this._onCallViewReplaceCamera.bind(this));this.callView.setCallback(BX.Call.View.Event.onReplaceMicrophone,this._onCallViewReplaceMicrophone.bind(this));this.callView.setCallback(BX.Call.View.Event.onSetCentralUser,this._onCallViewSetCentralUser.bind(this));this.callView.setCallback(BX.Call.View.Event.onChangeHdVideo,this._onCallViewChangeHdVideo.bind(this));this.callView.setCallback(BX.Call.View.Event.onChangeMicAutoParams,this._onCallViewChangeMicAutoParams.bind(this));this.callView.setCallback(BX.Call.View.Event.onChangeFaceImprove,this._onCallViewChangeFaceImprove.bind(this));this.callView.setCallback(BX.Call.View.Event.onReplaceSpeaker,this._onCallViewReplaceSpeaker.bind(this))},createVideoStrategy:function(){if(this.videoStrategy){this.videoStrategy.destroy()}var e=window.BXIM.settings.callAcceptIncomingVideo||BX.Call.VideoStrategy.Type.AllowAll;this.videoStrategy=new BX.Call.VideoStrategy({call:this.currentCall,callView:this.callView,strategyType:e})},removeVideoStrategy:function(){if(this.videoStrategy){this.videoStrategy.destroy()}this.videoStrategy=null},setFeatureScreenSharing:function(e){this.featureScreenSharing=e},setFeatureRecord:function(e){this.featureRecord=e},setVideoStrategyType:function(e){if(this.videoStrategy){this.videoStrategy.setType(e)}},isMessengerOpen:function(){return!!this.messenger.popupMessenger},createContainer:function(){this.container=BX.create("div",{props:{className:"bx-messenger-call-overlay"}});if(BX.MessengerWindow){BX.MessengerWindow.content.insertBefore(this.container,BX.MessengerWindow.content.firstChild)}else{this.messenger.popupMessengerContent.insertBefore(this.container,this.messenger.popupMessengerContent.firstChild)}this.messenger.popupMessengerContent.classList.add("bx-messenger-call")},removeContainer:function(){if(this.container){BX.remove(this.container);this.container=null;this.messenger.popupMessengerContent.classList.remove("bx-messenger-call")}},answerChildCall:function(){this.removeCallEvents();this.removeVideoStrategy();this.childCall.addEventListener(BX.Call.Event.onRemoteMediaReceived,this._onChildCallFirstMediaHandler);this.childCall.addEventListener(BX.Call.Event.onLocalMediaReceived,this._onCallLocalMediaReceivedHandler);this.childCall.answer({useVideo:this.currentCall.isVideoEnabled()})},_onChildCallFirstMedia:function(e){this.log("Finishing one-to-one call, switching to group call");var t=BX.Call.View.RecordType.None;if(this.isRecording()){t=this.callRecordType;BXDesktopSystem.CallRecordStop();this.callRecordState=BX.Call.View.RecordState.Stopped;this.callRecordType=BX.Call.View.RecordType.None;this.callView.setRecordState(this.callView.getDefaultRecordState());this.callView.setButtonActive("record",false)}this.callView.showButton("floorRequest");if(this.callView){if("track"in e){this.callView.setUserMedia(e.userId,e.kind,e.track)}if("mediaRenderer"in e&&e.mediaRenderer.kind==="audio"){this.callView.setUserMedia(e.userId,"audio",e.mediaRenderer.stream.getAudioTracks()[0])}if("mediaRenderer"in e&&(e.mediaRenderer.kind==="video"||e.mediaRenderer.kind==="sharing")){this.callView.setVideoRenderer(e.userId,e.mediaRenderer)}}this.childCall.removeEventListener(BX.Call.Event.onRemoteMediaReceived,this._onChildCallFirstMediaHandler);this.removeCallEvents();var i=this.currentCall;i.hangup();this.currentCall=this.childCall;this.childCall=null;if(this.currentCall.associatedEntity&&this.currentCall.associatedEntity.id){this.messenger.openMessenger(this.currentCall.associatedEntity.id)}if(i.muted){this.currentCall.setMuted(true)}this.bindCallEvents();this.createVideoStrategy();if(t!==BX.Call.View.RecordType.None){this._startRecordCall(t)}},checkDesktop:function(){return new Promise((function(e){BX.desktopUtils.runningCheck((function(){}),(function(){e()}))}))},isConferencePageOpened:function(e){return new Promise(function(t,i){var n=BX.Messenger.Lib.LocalStorage.get(BX.CallEngine.getSiteId(),BX.CallEngine.getCurrentUserId(),BX.CallEngine.getConferencePageTag(e),"N");return t(n==="Y")}.bind(this))},showIncomingCall:function(e){if(!BX.type.isPlainObject(e)){e={}}e.video=e.video==true;if(this.feedbackPopup){this.feedbackPopup.close()}var t=this.callWithLegacyMobile?e.video===true:true;this.callNotification=new BX.Call.Notification({callerName:this.currentCall.associatedEntity.name,callerAvatar:this.currentCall.associatedEntity.avatar,callerType:this.currentCall.associatedEntity.advanced.chatType,callerColor:this.currentCall.associatedEntity.avatarColor,video:e.video,hasCamera:BX.Call.Hardware.hasCamera()&&t,onClose:this._onCallNotificationClose.bind(this),onDestroy:this._onCallNotificationDestroy.bind(this),onButtonClick:this._onCallNotificationButtonClick.bind(this)});this.callNotification.show();this.scheduleCancelNotification();window.BXIM.repeatSound("ringtone",3500,true)},showIncomingConference:function(){this.callNotification=new BX.Call.NotificationConference({callerName:this.currentCall.associatedEntity.name,callerAvatar:this.currentCall.associatedEntity.avatar,callerColor:this.currentCall.associatedEntity.avatarColor,onClose:this._onCallNotificationClose.bind(this),onDestroy:this._onCallNotificationDestroy.bind(this),onButtonClick:this._onCallConferenceNotificationButtonClick.bind(this)});this.callNotification.show();this.scheduleCancelNotification();window.BXIM.repeatSound("ringtone",3500,true)},scheduleCancelNotification:function(){clearTimeout(this.hideIncomingCallTimeout);this.hideIncomingCallTimeout=setTimeout(function(){if(this.callNotification){this.callNotification.close()}if(this.currentCall){this.removeVideoStrategy();this.removeCallEvents();this.currentCall=null}}.bind(this),30*1e3)},showNotification:function(e,t){if(!t){t=[]}BX.UI.Notification.Center.notify({content:BX.util.htmlspecialchars(e),position:"top-right",autoHideDelay:5e3,closeButton:true,actions:t})},showNetworkProblemNotification:function(e){BX.UI.Notification.Center.notify({content:BX.util.htmlspecialchars(e),position:"top-right",autoHideDelay:5e3,closeButton:true,actions:[{title:BX.message("IM_M_CALL_HELP"),events:{click:function(e,t,i){top.BX.Helper.show("redirect=detail&code=12723718");t.close()}}}]})},showUnsupportedNotification:function(){if(BX.desktop&&BX.desktop.apiReady){window.BXIM.openConfirm(BX.message("IM_CALL_DESKTOP_TOO_OLD"),[updateButton=new BX.PopupWindowButton({text:BX.message("IM_M_CALL_BTN_UPDATE"),className:"popup-window-button-accept",events:{click:function(){window.open(BX.browser.IsMac()?"http://dl.bitrix24.com/b24/bitrix24_desktop.dmg":"http://dl.bitrix24.com/b24/bitrix24_desktop.exe","desktopApp");this.popupWindow.close()}}}),new BX.PopupWindowButton({text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close()}}})])}else{window.BXIM.openConfirm(BX.message("IM_CALL_WEBRTC_USE_CHROME_OR_DESKTOP"),[new BX.PopupWindowButton({text:BX.message("IM_CALL_DETAILS"),className:"popup-window-button-accept",events:{click:function(){this.popupWindow.close();top.BX.Helper.show("redirect=detail&code=11387752")}}}),new BX.PopupWindowButton({text:BX.message("IM_NOTIFY_CONFIRM_CLOSE"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close()}}})])}},isUserAgentSupported:function(){if(BX.desktop&&BX.desktop.apiReady){return BX.desktop.enableInVersion(48)}if("VoxImplant"in window){return VoxImplant.getInstance().isRTCsupported()}return BX.Call.Util.isWebRTCSupported()},startCall:function(e,t){if(!this.isUserAgentSupported()){this.showUnsupportedNotification();return}if(this.callView||this.currentCall){return}if(this.feedbackPopup){this.feedbackPopup.close()}var i=BX.Call.Provider.Plain;if(BX.Call.Util.isCallServerAllowed()&&e.toString().substr(0,4)==="chat"){i=BX.Call.Provider.Voximplant}var n=+new Date;this._openMessenger(e).then(function(){return BX.Call.Hardware.init()}.bind(this)).then(function(){this.createContainer();var n=[];if(i===BX.Call.Provider.Plain){n.push("floorRequest")}if(!BX.Call.Util.shouldShowDocumentButton()){n.push("document")}this.callView=new BX.Call.View({container:this.container,showChatButtons:true,userLimit:BX.Call.Util.getUserLimit(),language:window.BXIM.language,layout:e.toString().startsWith("chat")?BX.Call.View.Layout.Grid:BX.Call.View.Layout.Centered,microphoneId:BX.Call.Hardware.defaultMicrophone,showShareButton:this.featureScreenSharing!==BX.Call.Controller.FeatureState.Disabled,showRecordButton:this.featureRecord!==BX.Call.Controller.FeatureState.Disabled,hiddenButtons:n,blockedButtons:["record"]});this.bindCallViewEvents();if(t&&!BX.Call.Hardware.hasCamera()){this.showNotification(BX.message("IM_CALL_ERROR_NO_CAMERA"));t=false}return BX.Call.Engine.getInstance().createCall({entityType:"chat",entityId:e,provider:i,videoEnabled:!!t,enableMicAutoParameters:BX.Call.Hardware.enableMicAutoParameters,joinExisting:true})}.bind(this)).then(function(e){var i=+new Date;this.currentCall=e.call;this.log("Call creation time: "+(i-n)/1e3+" seconds");this.currentCall.useHdVideo(BX.Call.Hardware.preferHdQuality);if(BX.Call.Hardware.defaultMicrophone){this.currentCall.setMicrophoneId(BX.Call.Hardware.defaultMicrophone)}if(BX.Call.Hardware.defaultCamera){this.currentCall.setCameraId(BX.Call.Hardware.defaultCamera)}if(this.currentCall.associatedEntity&&this.currentCall.associatedEntity.id){if(this.messenger.currentTab!=this.currentCall.associatedEntity.id){this.messenger.openMessenger(this.currentCall.associatedEntity.id)}}this.autoCloseCallView=true;this.bindCallEvents();this.createVideoStrategy();this.callView.appendUsers(this.currentCall.getUsers());BX.Call.Util.getUsers(this.currentCall.id,this.getCallUsers(true)).then(function(e){this.callView.updateUserData(e)}.bind(this));this.callView.show();this.showDocumentPromo();if(e.isNew){this.log("Inviting users");this.currentCall.inviteUsers();window.BXIM.repeatSound("dialtone",5e3,true)}else{this.log("Joining existing call");this.currentCall.answer({useVideo:t})}}.bind(this)).catch(function(e){console.error(e);var t;if(typeof e=="string"){t=e}else if(typeof e=="object"&&e.code){t=e.code=="access_denied"?"ACCESS_DENIED":e.code}else{t="UNKNOWN_ERROR"}this._onCallFailure({code:t,message:e.message||""})}.bind(this))},joinCall:function(e,t,i){var n=BX.prop.getBoolean(i,"joinAsViewer",false);if(!this.isUserAgentSupported()){this.showUnsupportedNotification();return}if(this.callView||this.currentCall){return}var l;this.log("Joining call "+e);BX.CallEngine.getCallWithId(e).then(function(e){this.currentCall=e.call;l=this.currentCall.associatedEntity.id.toString().startsWith("chat");return this._openMessenger()}.bind(this)).then(function(){return BX.Call.Hardware.init()}.bind(this)).then(function(){this.createContainer();var e=[];if(this.currentCall instanceof BX.Call.PlainCall){e.push("floorRequest")}if(!BX.Call.Util.shouldShowDocumentButton()){e.push("document")}this.callView=new BX.Call.View({container:this.container,showChatButtons:true,userLimit:BX.Call.Util.getUserLimit(),language:window.BXIM.language,layout:l?BX.Call.View.Layout.Grid:BX.Call.View.Layout.Centered,showRecordButton:this.featureRecord!==BX.Call.Controller.FeatureState.Disabled,microphoneId:BX.Call.Hardware.defaultMicrophone,hiddenButtons:e,blockedButtons:["record"]});this.autoCloseCallView=true;this.bindCallViewEvents();this.callView.appendUsers(this.currentCall.getUsers());BX.Call.Util.getUsers(this.currentCall.id,this.getCallUsers(true)).then(function(e){this.callView.updateUserData(e)}.bind(this));this.callView.show();this.showDocumentPromo();this.currentCall.useHdVideo(BX.Call.Hardware.preferHdQuality);if(BX.Call.Hardware.defaultMicrophone){this.currentCall.setMicrophoneId(BX.Call.Hardware.defaultMicrophone)}if(BX.Call.Hardware.defaultCamera){this.currentCall.setCameraId(BX.Call.Hardware.defaultCamera)}this.bindCallEvents();this.createVideoStrategy();if(t&&!BX.Call.Hardware.hasCamera()){this.showNotification(BX.message("IM_CALL_ERROR_NO_CAMERA"));t=false}if(this.getCallUsers(true).length>this.getMaxActiveMicrophonesCount()){this.currentCall.setMuted(true);this.callView.setMuted(true);this.showAutoMicMuteNotification()}this.currentCall.answer({useVideo:!!t,joinAsViewer:n})}.bind(this))},leaveCurrentCall:function(){if(this.callView){this.callView.releaseLocalMedia()}if(this.currentCall){this.currentCall.hangup()}if(this.callView){this.callView.close()}},hasActiveCall:function(){return this.currentCall!=null&&this.currentCall.isAnyoneParticipating()||this.callView!=null},hasVisibleCall:function(){return!!(this.callView&&this.callView.visible&&this.callView.size==BX.Call.View.Size.Full)},canRecord:function(){return BX.desktop&&BX.desktop.getApiVersion()>=54},isRecording:function(){return this.canRecord()&&this.callRecordState!=BX.Call.View.RecordState.Stopped},useDevicesInCurrentCall:function(e){if(!this.currentCall||!this.currentCall.ready){return}for(var t=0;t<e.length;t++){var i=e[t];switch(i.kind){case"audioinput":this.currentCall.setMicrophoneId(i.deviceId);break;case"videoinput":this.currentCall.setCameraId(i.deviceId);break;case"audiooutput":if(this.callView){this.callView.setSpeakerId(i.deviceId)}break}}},removeDevicesFromCurrentCall:function(e){if(!this.currentCall||!this.currentCall.ready){return}for(var t=0;t<e.length;t++){var i=e[t];switch(i.kind){case"audioinput":if(this.currentCall.microphoneId==i.deviceId){var n=Object.keys(BX.Call.Hardware.microphoneList);this.currentCall.setMicrophoneId(n.length>0?n[0]:"")}break;case"videoinput":if(this.currentCall.cameraId==i.deviceId){var l=Object.keys(BX.Call.Hardware.cameraList);this.currentCall.setCameraId(l.length>0?l[0]:"")}break;case"audiooutput":if(this.callView&&this.callView.speakerId==i.deviceId){var a=Object.keys(BX.Call.Hardware.audioOutputList);this.callView.setSpeakerId(a.length>0?a[0]:"")}break}}},showChat:function(){if(BX.desktop&&this.floatingWindow){this.detached=true;this.callView.hide();this.floatingWindow.setTitle(this.currentCall.associatedEntity.name);BX.Call.Util.getUserAvatars(this.currentCall.id,this.getActiveCallUsers()).then(function(e){this.floatingWindow.setAvatars(e);this.floatingWindow.show()}.bind(this));this.container.style.width=0}else{this.fold(BX.util.htmlspecialcharsback(this.currentCall.associatedEntity.name))}},fold:function(e){if(this.folded||BX.desktop&&this.floatingWindow){return}if(!e&&this.currentCall){e=BX.util.htmlspecialcharsback(this.currentCall.associatedEntity.name)}this.folded=true;this.resizeObserver.unobserve(this.container);this.container.classList.add("bx-messenger-call-overlay-folded");this.callView.setTitle(e);this.callView.setSize(BX.Call.View.Size.Folded);this.callViewState=t.Folded;if(this.sidebar){this.sidebar.toggleHidden(true)}if(this.documentPromoPopup){this.documentPromoPopup.close()}BX.onCustomEvent(this,"CallController::onFold",{})},setCallEditorMaxWidth:function(e){if(e!=this.maxEditorWidth){this.maxEditorWidth=e;this._onResize()}},findCallEditorWidth:function(){var e=this.container.clientWidth;var t=e<this.maxEditorWidth+BX.Call.View.MIN_WIDTH?e-BX.Call.View.MIN_WIDTH:this.maxEditorWidth;var i=e-t;return{callWidth:i,editorWidth:t}},showDocumentsMenu:function(){var e=this.callView.buttons.document.elements.root.offsetWidth;var t=BX.Call.Util.getResumesArticleCode();var n=BX.Call.Util.getDocumentsArticleCode();var l=[{text:BX.message("IM_M_CALL_MENU_CREATE_RESUME"),onclick:function(e,n){this.documentsMenu.close();this.maybeShowDocumentEditor({type:i.Resume},t)}.bind(this)},{text:BX.message("IM_M_CALL_MENU_CREATE_FILE"),items:[{text:BX.message("IM_M_CALL_MENU_CREATE_FILE_DOC"),onclick:function(e,t){this.documentsMenu.close();this.maybeShowDocumentEditor({type:i.Blank,typeFile:r},n)}.bind(this)},{text:BX.message("IM_M_CALL_MENU_CREATE_FILE_XLS"),onclick:function(e,t){this.documentsMenu.close();this.maybeShowDocumentEditor({type:i.Blank,typeFile:c},n)}.bind(this)},{text:BX.message("IM_M_CALL_MENU_CREATE_FILE_PPT"),onclick:function(e,t){this.documentsMenu.close();this.maybeShowDocumentEditor({type:i.Blank,typeFile:d},n)}.bind(this)}]}];if(!t){l.push({text:BX.message("IM_M_CALL_MENU_OPEN_LAST_RESUME"),cacheable:true,items:[{id:"loading",text:BX.message("IM_M_CALL_MENU_LOADING_RESUME_LIST")}],events:{onSubMenuShow:function(e){this.buildPreviousResumesSubmenu(e.target)}.bind(this)}})}this.documentsMenu=new BX.PopupMenuWindow({angle:false,bindElement:this.callView.buttons.document.elements.root,targetContainer:this.container,offsetTop:-15,bindOptions:{position:"top"},cacheable:false,subMenuOptions:{maxWidth:450},events:{onShow:function(t){var i=t.getTarget();i.getPopupContainer().style.display="block";var n=e/2-i.getPopupContainer().offsetWidth/2;i.setOffset({offsetLeft:n+40});i.setAngle({offset:i.getPopupContainer().offsetWidth/2-17})},onDestroy:function(){this.documentsMenu=null}.bind(this)},items:l});this.documentsMenu.show()},buildPreviousResumesSubmenu:function(e){BX.ajax.runAction("disk.api.integration.messengerCall.listResumesInChatByCall",{data:{callId:this.currentCall.id}}).then(function(t){var i=t.data.resumes;if(i.length>0){i.forEach(function(t){e.getSubMenu().addMenuItem({id:t.id,text:t.object.createDate+": "+t.object.name,onclick:function(e,i){this.documentsMenu.close();this.viewDocumentByLink(t.links.view)}.bind(this)})}.bind(this))}else{e.getSubMenu().addMenuItem({id:"nothing",text:BX.message("IM_M_CALL_MENU_NO_RESUME"),disabled:true})}e.getSubMenu().removeMenuItem("loading");e.adjustSubMenu()}.bind(this))},maybeShowDocumentEditor:function(e,t){if(t){if(t){BX.UI.InfoHelper.show(t);return}}this.showDocumentEditor(e)},showDocumentEditor:function(e){e=e||{};var t=true;if(this.sidebar){if(e.force){this.sidebar.close(false);this.sidebar.destroy();this.sidebar=null;t=false}else{return}}if(this.callView){this.callView.setButtonActive("document",true)}clearTimeout(this.showPromoPopupTimeout);this._createAndOpenSidebarWithIframe("about:blank",t);BX.loadExt("disk.onlyoffice-im-integration").then(function(){var t=new BX.Disk.OnlyOfficeImIntegration.CreateDocument({dialog:{id:this.currentCall.associatedEntity.id},call:{id:this.currentCall.id},delegate:{setMaxWidth:this.setCallEditorMaxWidth.bind(this),onDocumentCreated:this._onDocumentCreated.bind(this)}});var n;if(e.type===i.Resume){n=t.getIframeUrlForTemplates()}else if(e.type===i.Blank){n=t.getIframeUrlForCreate({typeFile:e.typeFile})}else{n=t.getIframeUrl({viewerItem:e.viewerItem})}n.then(function(e){this.docEditorIframe.src=e}.bind(this)).catch(function(e){console.error(e);this.closeDocumentEditor();alert(BX.message("IM_F_ERROR"))}.bind(this));this.docEditor=t}.bind(this)).catch(function(e){console.error(e);this.closeDocumentEditor();alert(BX.message("IM_F_ERROR"))}.bind(this));this.resizeObserver.observe(this.container)},closeDocumentEditor:function(){return new Promise(function(e){if(this.docEditor&&this.docEditorIframe){this.docEditor.onCloseIframe(this.docEditorIframe)}if(this.container){this.resizeObserver.unobserve(this.container)}if(this.callView){this.callView.setButtonActive("document",false);this.callView.removeMaxWidth()}if(!this.sidebar){return e()}var t=this.sidebar;this.sidebar=null;t.close().then(function(){this.docEditor=null;this.docEditorIframe=null;t.destroy();this.maxEditorWidth=this.docCreatedForCurrentCall?n:l;if(!this.callView){this.removeContainer();e()}}.bind(this))}.bind(this))},viewDocumentByLink:function(e){if(this.sidebar){return}if(this.callView){this.callView.setButtonActive("document",true)}this.maxEditorWidth=n;this._createAndOpenSidebarWithIframe(e)},_createAndOpenSidebarWithIframe:function(e,t){t=t!=false;var i=this.findCallEditorWidth();var n=i.callWidth;var l=i.editorWidth;this.callView.setMaxWidth(n);this.sidebar=new BX.Call.Sidebar({container:this.container,width:l,events:{onCloseClicked:this.onSideBarCloseClicked.bind(this)}});this.sidebar.open(t);var a=new BX.Loader({target:this.sidebar.elements.contentContainer});a.show();var o=BX.create("iframe",{attrs:{src:e,frameborder:"0"},style:{display:"none",border:"0",margin:"0",width:"100%",height:"100%"}});o.addEventListener("load",(function(){a.destroy();o.style.display="block"}),{once:true});o.addEventListener("error",function(e){console.error(e);this.closeDocumentEditor();alert(BX.message("IM_F_ERROR"))}.bind(this));this.sidebar.elements.contentContainer.appendChild(o);this.docEditorIframe=o},_onDocumentCreated:function(){this.docCreatedForCurrentCall=true;if(this.currentCall){this.currentCall.sendCustomMessage(s,true)}},onSideBarCloseClicked:function(){this.closeDocumentEditor()},_ensureDocumentEditorClosed:function(){return new Promise(function(e,t){if(!this.sidebar){return e()}var i=this;window.BXIM.openConfirm(BX.message("IM_CALL_CLOSE_DOCUMENT_EDITOR_TO_ANSWER"),[new BX.PopupWindowButton({text:BX.message("IM_CALL_CLOSE_DOCUMENT_EDITOR_YES"),className:"popup-window-button-accept",events:{click:function(){this.popupWindow.close();i.closeDocumentEditor().then((function(){e()}))}}}),new BX.PopupWindowButton({text:BX.message("IM_CALL_CLOSE_DOCUMENT_EDITOR_NO"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close();t()}}})],true,{maxWidth:600})}.bind(this))},onDocumentPromoActionClicked:function(){if(this.documentPromoPopup){this.documentPromoPopup.close()}var e=BX.Call.Util.getResumesArticleCode();if(e){BX.UI.InfoHelper.show(e);return}this.showDocumentEditor({type:i.Resume})},onDocumentPromoClosed:function(){this.documentPromoPopup=null},unfold:function(){if(this.detached){this.container.style.removeProperty("width");this.callView.show();this.detached=false;if(this.floatingWindow){this.floatingWindow.hide()}}if(this.folded){this.folded=false;this.container.classList.remove("bx-messenger-call-overlay-folded");this.callView.setSize(BX.Call.View.Size.Full);this.callViewState=t.Opened;if(this.sidebar){this.sidebar.toggleHidden(false);this.resizeObserver.observe(this.container)}}BX.onCustomEvent(this,"CallController::onUnfold",{})},isFullScreen:function(){if("webkitFullscreenElement"in document){return!!document.webkitFullscreenElement}else if("fullscreenElement"in document){return!!document.fullscreenElement}return false},toggleFullScreen:function(){if(this.isFullScreen()){this.exitFullScreen()}else{this.enterFullScreen()}},enterFullScreen:function(){if(BX.MessengerSlider&&BX.MessengerSlider.isFocus()&&BX.getClass("BX.SidePanel.Instance.enterFullScreen")){BX.SidePanel.Instance.enterFullScreen()}else{if(BX.browser.IsChrome()||BX.browser.IsSafari()){document.body.webkitRequestFullScreen()}else if(BX.browser.IsFirefox()){document.body.requestFullscreen()}}},exitFullScreen:function(){if(BX.MessengerSlider&&BX.MessengerSlider.isFocus()&&BX.getClass("BX.SidePanel.Instance.exitFullScreen")){BX.SidePanel.Instance.exitFullScreen()}else{if(document.cancelFullScreen){document.cancelFullScreen()}else if(document.mozCancelFullScreen){document.mozCancelFullScreen()}else if(document.webkitCancelFullScreen){document.webkitCancelFullScreen()}else if(document.exitFullscreen){document.exitFullscreen()}}},showDocumentPromo:function(){if(!this.callView||!this.currentCall||!BX.Call.Util.shouldShowDocumentButton()){return false}if(!BX.MessengerPromo||!BX.MessengerPromo.needToShow(a)){return false}var e=this.callView.buttons.document.elements.root;var t=e.querySelector(".bx-messenger-videocall-panel-icon");if(!t){return false}this.documentPromoPopup=new BX.Call.PromoPopup({bindElement:t,promoCode:a,events:{onActionClick:this.onDocumentPromoActionClicked.bind(this),onClose:this.onDocumentPromoClosed.bind(this)}});this.showPromoPopupTimeout=setTimeout(function(){if(this.folded){return false}this.documentPromoPopup.show()}.bind(this),o)},_openMessenger:function(e){return new Promise(function(t,i){this.messenger.openMessenger(e).then((function(){t()})).catch((function(e){i(e)}))}.bind(this))},_startRecordCall:function(e){this.callView.setButtonActive("record",true);this.callRecordType=e;this.currentCall.sendRecordState({action:BX.Call.View.RecordState.Started,date:new Date});this.callRecordState=BX.Call.View.RecordState.Started},_onCallNotificationClose:function(e){clearTimeout(this.hideIncomingCallTimeout);window.BXIM.stopRepeatSound("ringtone");if(this.callNotification){this.callNotification.destroy()}},_onCallNotificationDestroy:function(e){this.callNotification=null},_onCallNotificationButtonClick:function(e){clearTimeout(this.hideIncomingCallTimeout);this.callNotification.close();switch(e.button){case"answer":this._onAnswerButtonClick(e.video);break;case"decline":if(this.currentCall){this.removeVideoStrategy();this.removeCallEvents();this.currentCall.decline();this.currentCall=null}break}},_onAnswerButtonClick:function(e){if(BX.desktop){BX.desktop.windowCommand("show")}if(!this.isUserAgentSupported()){this.log("Error: unsupported user agent");this.removeVideoStrategy();this.removeCallEvents();this.currentCall.decline();this.currentCall=null;this.showUnsupportedNotification();return}if(this.callView){this.callView.destroy()}var t=this.currentCall.associatedEntity&&this.currentCall.associatedEntity.id?this.currentCall.associatedEntity.id:false;var i=t.toString().startsWith("chat");this._ensureDocumentEditorClosed().then(function(){return this._openMessenger(t)}.bind(this)).then(function(){this.createContainer();var t=[];if(this.currentCall instanceof BX.Call.PlainCall){t.push("floorRequest")}if(!BX.Call.Util.shouldShowDocumentButton()){t.push("document")}this.callView=new BX.Call.View({container:this.container,users:this.currentCall.users,userStates:this.currentCall.getUsers(),showChatButtons:true,showRecordButton:this.featureRecord!==BX.Call.Controller.FeatureState.Disabled,userLimit:BX.Call.Util.getUserLimit(),layout:i?BX.Call.View.Layout.Grid:BX.Call.View.Layout.Centered,microphoneId:BX.Call.Hardware.defaultMicrophone,blockedButtons:["record"],hiddenButtons:t});this.autoCloseCallView=true;if(this.callWithLegacyMobile){this.callView.blockAddUser()}this.bindCallViewEvents();BX.Call.Util.getUsers(this.currentCall.id,this.getCallUsers(true)).then(function(e){this.callView.updateUserData(e)}.bind(this));this.callView.show();this.showDocumentPromo();this.currentCall.useHdVideo(BX.Call.Hardware.preferHdQuality);if(BX.Call.Hardware.defaultMicrophone){this.currentCall.setMicrophoneId(BX.Call.Hardware.defaultMicrophone)}if(BX.Call.Hardware.defaultCamera){this.currentCall.setCameraId(BX.Call.Hardware.defaultCamera)}if(this.getCallUsers(true).length>this.getMaxActiveMicrophonesCount()){this.currentCall.setMuted(true);this.callView.setMuted(true);this.showAutoMicMuteNotification()}this.currentCall.answer({useVideo:e,enableMicAutoParameters:BX.Call.Hardware.enableMicAutoParameters});this.createVideoStrategy()}.bind(this))},_onCallConferenceNotificationButtonClick:function(e){clearTimeout(this.hideIncomingCallTimeout);this.callNotification.close();switch(e.button){case"answerConference":if(this.currentCall&&"id"in this.currentCall.associatedEntity){var t=this.currentCall.associatedEntity.id.toString();if(t.startsWith("chat")){t=t.substr(4)}if(window.BXIM.messenger.chat.hasOwnProperty(t)){window.BXIM.openVideoconf(window.BXIM.messenger.chat[t].public.code)}}break;case"skipConference":if(this.currentCall){this.removeVideoStrategy();this.removeCallEvents();this.currentCall.decline();this.currentCall=null}break}},_onCallViewShow:function(e){this.callView.setButtonCounter("chat",BXIM.messenger.messageCount);this.callViewState=t.Opened},_onCallViewClose:function(e){this.callView.destroy();this.callViewState=t.Closed;if(this.floatingWindow){this.floatingWindow.close()}if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.documentPromoPopup){this.documentPromoPopup.close()}if(this.documentsMenu){this.documentsMenu.close()}clearTimeout(this.showPromoPopupTimeout);this._closeReconnectionBaloon()},_onCallViewDestroy:function(e){this.callView=null;this.folded=false;this.autoCloseCallView=true;if(this.sidebar){BX.adjust(this.container,{style:{backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(5px)"}})}else{this.removeContainer();this.maxEditorWidth=l}},_onCallViewBodyClick:function(e){if(this.folded){this.unfold()}},_onCallViewButtonClick:function(e){var t=e.buttonName;var i={hangup:this._onCallViewHangupButtonClick.bind(this),close:this._onCallViewCloseButtonClick.bind(this),inviteUser:this._onCallViewInviteUserButtonClick.bind(this),toggleMute:this._onCallViewToggleMuteButtonClick.bind(this),toggleScreenSharing:this._onCallViewToggleScreenSharingButtonClick.bind(this),record:this._onCallViewRecordButtonClick.bind(this),toggleVideo:this._onCallViewToggleVideoButtonClick.bind(this),showChat:this._onCallViewShowChatButtonClick.bind(this),floorRequest:this._onCallViewFloorRequestButtonClick.bind(this),showHistory:this._onCallViewShowHistoryButtonClick.bind(this),fullscreen:this._onCallViewFullScreenButtonClick.bind(this),document:this._onCallViewDocumentButtonClick.bind(this)};if(BX.type.isFunction(i[t])){i[t].call(this,e)}},_onCallViewHangupButtonClick:function(e){this.leaveCurrentCall()},_onCallViewCloseButtonClick:function(e){if(this.callView){this.callView.close()}},_onCallViewShowChatButtonClick:function(e){this.messenger.openMessenger(this.currentCall.associatedEntity.id);this.showChat()},_onCallViewFloorRequestButtonClick:function(e){var t=this.callView.getUserFloorRequestState(BX.CallEngine.getCurrentUserId());var i=this.callView.getUserTalking(BX.CallEngine.getCurrentUserId());this.callView.setUserFloorRequestState(BX.CallEngine.getCurrentUserId(),!t);if(this.currentCall){this.currentCall.requestFloor(!t)}clearTimeout(this.callViewFloorRequestTimeout);if(i&&!t){this.callViewFloorRequestTimeout=setTimeout(function(){if(this.currentCall){this.currentCall.requestFloor(false)}}.bind(this),1500)}},_getDisconnectedUsers:function(){var e=[];var t=this.currentCall.getUsers();for(var i in t){if(t[i]!==BX.Call.UserState.Connected&&BX.Call.Util.userData[i]){e.push(BX.Call.Util.userData[i])}}return e},_closeReconnectionBaloon:function(){if(this.reconnectionBaloon){this.reconnectionBaloon.close();this.reconnectionBaloon=null}},_onCallViewInviteUserButtonClick:function(e){if(this.invitePopup){this.invitePopup.close();return}var t=this.currentCall.getUsers();var i=this._getDisconnectedUsers();this.invitePopup=new BX.Call.InvitePopup({viewElement:this.callView.container,bindElement:e.node,zIndex:BX.MessengerCommon.getDefaultZIndex()+200,idleUsers:i,allowNewUsers:Object.keys(t).length<BX.Call.Util.getUserLimit()-1,onDestroy:this._onInvitePopupDestroy.bind(this),onSelect:this._onInvitePopupSelect.bind(this)});this.callView.setHotKeyTemporaryBlock(true);this.invitePopup.show()},_onCallViewToggleMuteButtonClick:function(e){this.currentCall.setMuted(e.muted);this.callView.setMuted(e.muted);if(this.floatingWindow){this.floatingWindow.setAudioMuted(e.muted)}if(this.mutePopup){this.mutePopup.close()}if(!e.muted){this.allowMutePopup=true}if(this.isRecording()){BXDesktopSystem.CallRecordMute(e.muted)}},_onCallViewRecordButtonClick:function(e){if(e.recordState===BX.Call.View.RecordState.Started){if(this.featureRecord===BX.Call.Controller.FeatureState.Limited){BX.MessengerLimit.showHelpSlider("call_record");return}if(this.featureRecord===BX.Call.Controller.FeatureState.Disabled){return}if(this.canRecord()){var t=BX.prop.getBoolean(e,"forceRecord",BX.Call.View.RecordType.None);if(t!==BX.Call.View.RecordType.None){this._startRecordCall(t)}else if(BX.desktop&&BX.desktop.enableInVersion(55)){if(!this.callRecordMenu){this.callRecordMenu=new BX.PopupMenuWindow({bindElement:e.node,targetContainer:this.callView.container,items:[{text:BX.message("IM_M_CALL_MENU_RECORD_VIDEO"),onclick:function(e,t){this._startRecordCall(BX.Call.View.RecordType.Video);t.getMenuWindow().close()}.bind(this)},{text:BX.message("IM_M_CALL_MENU_RECORD_AUDIO"),onclick:function(e,t){this._startRecordCall(BX.Call.View.RecordType.Audio);t.getMenuWindow().close()}.bind(this)}],autoHide:true,angle:{position:"top",offset:80},offsetTop:0,offsetLeft:-25,events:{onPopupClose:function(){this.callRecordMenu.destroy()}.bind(this),onPopupDestroy:function(){this.callRecordMenu=null}.bind(this)}})}this.callRecordMenu.toggle();return}this.callView.setButtonActive("record",true)}else{if(window.BX.Helper){window.BX.Helper.show("redirect=detail&code=12398134")}return}}else if(e.recordState===BX.Call.View.RecordState.Paused){if(this.canRecord()){BXDesktopSystem.CallRecordPause(true)}}else if(e.recordState===BX.Call.View.RecordState.Resumed){if(this.canRecord()){BXDesktopSystem.CallRecordPause(false)}}else if(e.recordState===BX.Call.View.RecordState.Stopped){this.callView.setButtonActive("record",false)}this.currentCall.sendRecordState({action:e.recordState,date:new Date});this.callRecordState=e.recordState},_onCallViewToggleScreenSharingButtonClick:function(e){if(this.featureScreenSharing===BX.Call.Controller.FeatureState.Limited){BX.MessengerLimit.showHelpSlider("call_screen_sharing");return}if(this.featureScreenSharing===BX.Call.Controller.FeatureState.Disabled){return}if(this.currentCall.isScreenSharingStarted()){if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.webScreenSharePopup){this.webScreenSharePopup.close()}if(this.documentPromoPopup){this.documentPromoPopup.close()}this.currentCall.stopScreenSharing();if(this.isRecording()){BXDesktopSystem.CallRecordStopSharing()}}else{this.currentCall.startScreenSharing();BX.CallEngine.getRestClient().callMethod("im.call.onShareScreen",{callId:this.currentCall.id})}},_onCallViewToggleVideoButtonClick:function(e){if(!BX.Call.Hardware.initialized){return}if(e.video&&Object.values(BX.Call.Hardware.cameraList).length===0){return}if(!e.video){this.callView.releaseLocalMedia()}this.currentCall.setVideoEnabled(e.video)},_onCallViewShowHistoryButtonClick:function(e){this.messenger.openHistory(this.currentCall.associatedEntity.id)},_onCallViewFullScreenButtonClick:function(e){if(this.folded){this.unfold()}this.toggleFullScreen()},_onCallViewDocumentButtonClick:function(e){this.sidebar?this.closeDocumentEditor():this.showDocumentsMenu()},_onCallViewReplaceCamera:function(e){if(this.currentCall){this.currentCall.setCameraId(e.deviceId)}BX.Call.Hardware.defaultCamera=e.deviceId},_onCallViewReplaceMicrophone:function(e){if(this.currentCall){this.currentCall.setMicrophoneId(e.deviceId)}if(this.currentCall instanceof BX.Call.VoximplantCall){this.callView.setMicrophoneId(e.deviceId)}BX.Call.Hardware.defaultMicrophone=e.deviceId},_onCallViewReplaceSpeaker:function(e){BX.Call.Hardware.defaultSpeaker=e.deviceId},_onCallViewChangeHdVideo:function(e){BX.Call.Hardware.preferHdQuality=e.allowHdVideo},_onCallViewChangeMicAutoParams:function(e){BX.Call.Hardware.enableMicAutoParameters=e.allowMicAutoParams},_onCallViewChangeFaceImprove:function(e){if(typeof BX.desktop==="undefined"){return}BX.desktop.cameraSmoothingStatus(e.faceImproveEnabled)},_onCallViewSetCentralUser:function(e){if(e.stream&&this.floatingWindow){this.floatingWindowUser=e.userId}},_onCallUserInvited:function(e){if(this.callView){BX.Call.Util.getUsers(this.currentCall.id,[e.userId]).then(function(e){this.callView.updateUserData(e)}.bind(this));this.callView.addUser(e.userId)}},_onCallDestroy:function(e){if(this.currentCall){this.removeVideoStrategy();this.removeCallEvents();this.currentCall=null}this.callWithLegacyMobile=false;if(this.callNotification){this.callNotification.close()}if(this.invitePopup){this.invitePopup.close()}if(this.isRecording()){BXDesktopSystem.CallRecordStop()}this.callRecordState=BX.Call.View.RecordState.Stopped;this.callRecordType=BX.Call.View.RecordType.None;if(this.callRecordMenu){this.callRecordMenu.close()}if(this.callView&&this.autoCloseCallView){this.callView.close()}if(this.floatingWindow){this.floatingWindow.close()}if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.webScreenSharePopup){this.webScreenSharePopup.close()}if(this.mutePopup){this.mutePopup.close()}if(this.documentPromoPopup){this.documentPromoPopup.close()}this.allowMutePopup=true;this.docCreatedForCurrentCall=false;this._closeReconnectionBaloon();window.BXIM.messenger.dialogStatusRedraw();window.BXIM.stopRepeatSound("dialtone");window.BXIM.stopRepeatSound("ringtone")},_onCallUserStateChanged:function(e){setTimeout(this.updateFloatingWindowContent.bind(this),100);if(this.callView){this.callView.setUserState(e.userId,e.state);if(e.isLegacyMobile){this.callView.blockAddUser();this.callView.blockSwitchCamera();this.callView.blockScreenSharing();this.callView.disableMediaSelection();this.callView.updateButtons()}}if(e.state==BX.Call.UserState.Connecting||e.state==BX.Call.UserState.Connected){window.BXIM.stopRepeatSound("dialtone")}if(e.state==BX.Call.UserState.Connected){if(!e.isLegacyMobile){this.callView.unblockButtons(["camera","floorRequest","screen"])}if(this.callRecordState===BX.Call.View.RecordState.Stopped){this.callView.unblockButtons(["record"])}}else if(e.state==BX.Call.UserState.Idle&&e.previousState==BX.Call.UserState.Connected){}else if(e.state==BX.Call.UserState.Failed){if(e.networkProblem){this.showNetworkProblemNotification(BX.message("IM_M_CALL_TURN_UNAVAILABLE"))}else{BX.Call.Util.getUser(this.currentCall.id,e.userId).then(function(e){this.showNotification(BX.Call.Util.getCustomMessage("IM_M_CALL_USER_FAILED",{gender:e.gender,name:e.name}))}.bind(this))}}else if(e.state==BX.Call.UserState.Declined){BX.Call.Util.getUser(this.currentCall.id,e.userId).then(function(e){this.showNotification(BX.Call.Util.getCustomMessage("IM_M_CALL_USER_DECLINED",{gender:e.gender,name:e.name}))}.bind(this))}else if(e.state==BX.Call.UserState.Busy){BX.Call.Util.getUser(this.currentCall.id,e.userId).then(function(e){this.showNotification(BX.Call.Util.getCustomMessage("IM_M_CALL_USER_BUSY",{gender:e.gender,name:e.name}))}.bind(this))}},_onCallUserMicrophoneState:function(e){if(!this.callView){return}this.callView.setUserMicrophoneState(e.userId,e.microphoneState)},_onCallUserCameraState:function(e){if(!this.callView){return}this.callView.setUserCameraState(e.userId,e.cameraState)},_onCallUserVideoPaused:function(e){if(!this.callView){return}this.callView.setUserVideoPaused(e.userId,e.videoPaused)},_onCallLocalMediaReceived:function(e){this.log("Received local media stream "+e.tag);if(this.callView){var t=e.tag=="main"?BX.Call.Hardware.enableMirroring:false;this.callView.setLocalStream(e.stream);this.callView.flipLocalVideo(t);this.callView.setButtonActive("screen",e.tag=="screen");if(e.tag=="screen"){if(!BX.desktop){this.showWebScreenSharePopup()}this.callView.blockSwitchCamera();this.callView.updateButtons()}else{if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.webScreenSharePopup){this.webScreenSharePopup.close()}if(this.isRecording()){BXDesktopSystem.CallRecordStopSharing()}if(!this.currentCall.callFromMobile){this.callView.unblockSwitchCamera();this.callView.updateButtons()}}}if(this.currentCall&&this.currentCall.videoEnabled&&e.stream.getVideoTracks().length===0){this.showNotification(BX.message("IM_CALL_CAMERA_ERROR_FALLBACK_TO_MIC"));this.currentCall.setVideoEnabled(false)}},_onCallLocalCameraFlip:function(e){this._onCallLocalCameraFlipInDesktop(e.data.enableMirroring)},_onCallLocalCameraFlipInDesktop:function(e){if(this.callView){this.callView.flipLocalVideo(e)}},_onCallLocalMediaStopped:function(e){},_onCallRemoteMediaReceived:function(e){if(this.callView){if("track"in e){this.callView.setUserMedia(e.userId,e.kind,e.track)}if("mediaRenderer"in e&&e.mediaRenderer.kind==="audio"){this.callView.setUserMedia(e.userId,"audio",e.mediaRenderer.stream.getAudioTracks()[0])}if("mediaRenderer"in e&&(e.mediaRenderer.kind==="video"||e.mediaRenderer.kind==="sharing")){this.callView.setVideoRenderer(e.userId,e.mediaRenderer)}}},_onCallRemoteMediaStopped:function(e){if(this.callView){if("mediaRenderer"in e){if(e.kind==="video"||e.kind==="sharing"){this.callView.setVideoRenderer(e.userId,null)}}else{this.callView.setUserMedia(e.userId,e.kind,null)}}},_onCallUserVoiceStarted:function(e){if(e.local){if(this.currentCall.muted&&this.allowMutePopup){this.showMicMutedNotification()}return}this.talkingUsers[e.userId]=true;if(this.callView){this.callView.setUserTalking(e.userId,true);this.callView.setUserFloorRequestState(e.userId,false)}if(this.floatingWindow){this.floatingWindow.setTalking(Object.keys(this.talkingUsers).map((function(e){return Number(e)})))}},_onCallUserVoiceStopped:function(e){if(e.local){return}if(this.talkingUsers[e.userId]){delete this.talkingUsers[e.userId]}if(this.callView){this.callView.setUserTalking(e.userId,false)}if(this.floatingWindow){this.floatingWindow.setTalking(Object.keys(this.talkingUsers).map((function(e){return Number(e)})))}},_onCallUserScreenState:function(e){if(this.callView){this.callView.setUserScreenState(e.userId,e.screenState)}if(e.userId==BX.CallEngine.getCurrentUserId()){this.callView.setButtonActive("screen",e.screenState);if(e.screenState){if(!BX.desktop){this.showWebScreenSharePopup()}this.callView.blockSwitchCamera()}else{if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.webScreenSharePopup){this.webScreenSharePopup.close()}if(this.isRecording()){BXDesktopSystem.CallRecordStopSharing()}if(!this.currentCall.callFromMobile){this.callView.unblockSwitchCamera();this.callView.updateButtons()}}this.callView.updateButtons()}},_onCallUserRecordState:function(e){this.callRecordState=e.recordState.state;this.callView.setRecordState(e.recordState);if(!this.canRecord()||e.userId!=BX.message["USER_ID"]){return true}if(e.recordState.state===BX.Call.View.RecordState.Started&&e.recordState.userId==BX.message["USER_ID"]){var t=BX.Call.View.RecordSource.Chat;var i=this.currentCall.associatedEntity.id;var n=this.currentCall.associatedEntity.name;var l=this.currentCall.id;var a=BX.date.format(window.BXIM.webrtc.formatRecordDate||"d.m.Y");var o=BX.message("IM_CALL_RECORD_NAME");if(o){o=o.replace("#CHAT_TITLE#",n).replace("#CALL_ID#",l).replace("#DATE#",a)}else{o="call_record_"+this.currentCall.id}BX.CallEngine.getRestClient().callMethod("im.call.onStartRecord",{callId:this.currentCall.id});BXDesktopSystem.CallRecordStart({windowId:t,fileName:o,callId:l,callDate:a,dialogId:i,dialogName:n,video:this.callRecordType!==BX.Call.View.RecordType.Audio,muted:this.currentCall.isMuted(),cropTop:72,cropBottom:73,shareMethod:"im.disk.record.share"})}else if(e.recordState.state===BX.Call.View.RecordState.Stopped){BXDesktopSystem.CallRecordStop()}return true},_onCallUserFloorRequest:function(e){if(this.callView){this.callView.setUserFloorRequestState(e.userId,e.requestActive)}},_onCallFailure:function(e){var t=e.code||e.name||e.error;console.error("Call failure: ",e);var i;if(e.name=="AuthResult"||t=="AUTHORIZE_ERROR"){i=BX.message("IM_CALL_ERROR_AUTHORIZATION")}else if(e.name=="Failed"&&t==403){i=BX.message("IM_CALL_ERROR_HARDWARE_ACCESS_DENIED")}else if(t=="ERROR_UNEXPECTED_ANSWER"){i=BX.message("IM_CALL_ERROR_UNEXPECTED_ANSWER")}else if(t=="BLANK_ANSWER_WITH_ERROR_CODE"){i=BX.message("IM_CALL_ERROR_BLANK_ANSWER")}else if(t=="BLANK_ANSWER"){i=BX.message("IM_CALL_ERROR_BLANK_ANSWER")}else if(t=="ACCESS_DENIED"){i=BX.message("IM_CALL_ERROR_ACCESS_DENIED")}else if(t=="NO_WEBRTC"){i=this.isHttps?BX.message("IM_CALL_NO_WEBRT"):BX.message("IM_CALL_ERROR_HTTPS_REQUIRED")}else if(t=="UNKNOWN_ERROR"){i=BX.message("IM_CALL_ERROR_UNKNOWN")}else if(t=="NotAllowedError"){i=BX.message("IM_CALL_ERROR_HARDWARE_ACCESS_DENIED")}else{i=BX.message("IM_CALL_ERROR_UNKNOWN_WITH_CODE").replace("#ERROR_CODE#",t)}if(this.callView){this.callView.showFatalError({text:i})}else{this.showNotification(i)}window.BXIM.stopRepeatSound("dialtone");this.autoCloseCallView=false;if(this.currentCall){this.removeVideoStrategy();this.removeCallEvents();this.currentCall.destroy();this.currentCall=null}},_onNetworkProblem:function(e){this.showNetworkProblemNotification(BX.message("IM_M_CALL_TURN_UNAVAILABLE"))},_onMicrophoneLevel:function(e){if(this.callView){this.callView.setMicrophoneLevel(e.level)}},_onReconnecting:function(){return false;if(this.reconnectionBaloon){return}this.reconnectionBaloon=BX.UI.Notification.Center.notify({content:BX.util.htmlspecialchars(BX.message("IM_CALL_RECONNECTING")),autoHide:false,position:"top-right",closeButton:false})},_onReconnected:function(){return false;this._closeReconnectionBaloon()},_onCustomMessage:function(e){if(e.message===s){this.docCreatedForCurrentCall=true;this.maxEditorWidth=n}},_onCallJoin:function(e){if(e.local){return}if(this.currentCall){this.removeVideoStrategy();this.removeCallEvents();this.currentCall=null}if(this.callView){this.callView.close()}if(this.callNotification){this.callNotification.close()}if(this.invitePopup){this.invitePopup.close()}if(this.floatingWindow){this.floatingWindow.close()}if(this.mutePopup){this.mutePopup.close()}window.BXIM.stopRepeatSound("dialtone")},_onCallLeave:function(e){if(!e.local&&this.currentCall&&this.currentCall.ready){this.log(new Error("received remote leave with active call!"));return}if(this.isRecording()){BXDesktopSystem.CallRecordStop()}this.callRecordState=BX.Call.View.RecordState.Stopped;this.callRecordType=BX.Call.View.RecordType.None;this.docCreatedForCurrentCall=false;var t=false;var i;if(this.currentCall){this.removeVideoStrategy();this.removeCallEvents();t=this.currentCall.wasConnected;i={id:this.currentCall.id,provider:this.currentCall.provider,userCount:this.currentCall.users.length,browser:BX.Call.Util.getBrowserForStatistics(),isMobile:BX.browser.IsMobile(),isConference:false};this.currentCall=null}if(this.callView){this.callView.close()}if(this.invitePopup){this.invitePopup.close()}if(this.floatingWindow){this.floatingWindow.close()}if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.webScreenSharePopup){this.webScreenSharePopup.close()}if(this.callNotification){this.callNotification.close()}if(this.mutePopup){this.mutePopup.close()}this.allowMutePopup=true;if(this.documentPromoPopup){this.documentPromoPopup.close()}this._closeReconnectionBaloon();window.BXIM.messenger.dialogStatusRedraw();window.BXIM.stopRepeatSound("dialtone");window.BXIM.stopRepeatSound("ringtone");if(t){}},_onInvitePopupDestroy:function(e){this.callView.setHotKeyTemporaryBlock(false);this.invitePopup=null},_onInvitePopupSelect:function(e){this.invitePopup.close();if(!this.currentCall){return}var t=e.user.id;if(BX.Call.Util.isCallServerAllowed()&&this.currentCall instanceof BX.Call.PlainCall){this.removeVideoStrategy();this.removeCallEvents();BX.Call.Engine.getInstance().createChildCall(this.currentCall.id,BX.Call.Provider.Voximplant,[t]).then(function(e){this.childCall=e.call;this.childCall.addEventListener(BX.Call.Event.onRemoteMediaReceived,this._onChildCallFirstMediaHandler);this.childCall.addEventListener(BX.Call.Event.onLocalMediaReceived,this._onCallLocalMediaReceivedHandler);this.childCall.useHdVideo(BX.Call.Hardware.preferHdQuality);if(this.currentCall.microphoneId){this.childCall.setMicrophoneId(this.currentCall.microphoneId)}if(this.currentCall.cameraId){this.childCall.setCameraId(this.currentCall.cameraId)}this.childCall.inviteUsers({users:this.childCall.users})}.bind(this));this.callView.addUser(t,BX.Call.UserState.Calling);if(BXIM.messenger.users[t]){var i={};i[t]=BXIM.messenger.users[t];this.callView.updateUserData(i)}}else{var n=this.currentCall.getUsers();if(Object.keys(n).length<BX.Call.Util.getUserLimit()-1||n.hasOwnProperty(t)){this.currentCall.inviteUsers({users:[t]})}}},_onWindowFocus:function(){if(!this.detached){clearTimeout(this.showFloatingWindowTimeout);clearTimeout(this.showFloatingScreenShareWindowTimeout);if(this.floatingWindow){this.floatingWindow.hide()}if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.hide()}}},_onWindowBlur:function(e){clearTimeout(this.showFloatingWindowTimeout);clearTimeout(this.showFloatingScreenShareWindowTimeout);if(this.currentCall&&this.floatingWindow&&this.callView){this.showFloatingWindowTimeout=setTimeout(function(){if(this.currentCall&&this.floatingWindow&&this.callView){this.floatingWindow.setTitle(this.currentCall.associatedEntity.name);BX.Call.Util.getUserAvatars(this.currentCall.id,this.getActiveCallUsers()).then(function(e){this.floatingWindow.setAvatars(e);this.floatingWindow.show()}.bind(this))}}.bind(this),300)}if(this.currentCall&&this.floatingScreenShareWindow&&this.callView&&this.currentCall.isScreenSharingStarted()){this.showFloatingScreenShareWindowTimeout=setTimeout(function(){if(this.currentCall&&this.floatingScreenShareWindow&&this.callView&&this.currentCall.isScreenSharingStarted()){this.floatingScreenShareWindow.show()}}.bind(this),300)}},_onBeforeUnload:function(e){if(this.floatingWindow){this.floatingWindow.close()}if(this.callNotification){this.callNotification.close()}if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.hasActiveCall()){e.preventDefault();e.returnValue=""}},_onImTabChange:function(e){if(e==="notify"&&this.currentCall&&this.callView){this.fold(BX.util.htmlspecialcharsback(this.currentCall.associatedEntity.name))}},_onUpdateChatCounter:function(e){if(!this.currentCall||!this.currentCall.associatedEntity||!this.currentCall.associatedEntity.id||!this.callView){return}this.callView.setButtonCounter("chat",e)},_onDeviceChange:function(e){if(!this.currentCall||!this.currentCall.ready){return}var t=e.data.added;var i=e.data.removed;if(t.length>0){this.log("New devices: ",t);BX.UI.Notification.Center.notify({content:BX.message("IM_CALL_DEVICES_FOUND")+"<br><ul>"+t.map((function(e){return"<li>"+e.label}))+"</ul>",position:"top-right",autoHideDelay:1e4,closeButton:true,actions:[{title:BX.message("IM_CALL_DEVICES_CLOSE"),events:{click:function(e,t,i){t.close()}.bind(this)}}]});setTimeout(function(){this.useDevicesInCurrentCall(t)}.bind(this),500)}if(i.length>0){this.log("Removed devices: ",i);BX.UI.Notification.Center.notify({content:BX.message("IM_CALL_DEVICES_DETACHED")+"<br><ul>"+i.map((function(e){return"<li>"+e.label}))+"</ul>",position:"top-right",autoHideDelay:1e4,closeButton:true,actions:[{title:BX.message("IM_CALL_DEVICES_CLOSE"),events:{click:function(e,t,i){t.close()}}}]});setTimeout(function(){this.removeDevicesFromCurrentCall(i)}.bind(this),500)}},_onFloatingVideoMainAreaClick:function(e){BX.desktop.windowCommand("show");BX.desktop.changeTab("im");if(!this.currentCall){return}if(this.currentCall.associatedEntity&&this.currentCall.associatedEntity.id){this.messenger.openMessenger(this.currentCall.associatedEntity.id)}else if(!this.isMessengerOpen()){this.messenger.openMessenger()}if(this.detached){this.container.style.removeProperty("width");this.callView.show();this.detached=false}},_onFloatingVideoButtonClick:function(e){switch(e.buttonName){case"toggleMute":this._onCallViewToggleMuteButtonClick(e);break;case"hangup":this._onCallViewHangupButtonClick();break}},_onFloatingScreenShareBackToCallClick:function(){BX.desktop.windowCommand("show");BX.desktop.changeTab("im");if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.hide()}},_onFloatingScreenShareStopClick:function(){BX.desktop.windowCommand("show");BX.desktop.changeTab("im");this.currentCall.stopScreenSharing();if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.close()}if(this.isRecording()){BXDesktopSystem.CallRecordStopSharing()}},_onFloatingScreenShareChangeScreenClick:function(){if(this.currentCall){this.currentCall.startScreenSharing(true)}},_onResize:function(){if(this.sidebar&&this.callView){var e=this.findCallEditorWidth();var t=e.callWidth;var i=e.editorWidth;this.callView.setMaxWidth(t);this.sidebar.setWidth(i)}},destroy:function(){if(this.floatingWindow){this.floatingWindow.destroy();this.floatingWindow=null}if(this.floatingScreenShareWindow){this.floatingScreenShareWindow.destroy();this.floatingScreenShareWindow=null}if(this.resizeObserver){this.resizeObserver.disconnect();this.resizeObserver=null}BX.Call.Hardware.unsubscribe(BX.Call.Hardware.Events.onChangeMirroringVideo,this._onCallLocalCameraFlipHandler)},log:function(){if(this.currentCall){var e=[this.currentCall.id];BX.CallEngine.log.apply(BX.CallEngine,e.concat(Array.prototype.slice.call(arguments)))}else{BX.CallEngine.log.apply(BX.CallEngine,arguments)}},test:function(e,t,i){var n;var l;e=typeof e=="undefined"?[473,464]:e;t=typeof t=="undefined"?{width:320,height:180}:t;i=typeof i=="undefined"?false:i;this._openMessenger().then(function(){return t||i?BX.Call.Hardware.init():null}.bind(this)).then(function(){this.createContainer();var e=["floorRequest"];if(!BX.Call.Util.shouldShowDocumentButton()){e.push("document")}this.callView=new BX.Call.View({container:this.container,showChatButtons:true,userLimit:48,language:window.BXIM.language,layout:BX.Call.View.Layout.Grid,hiddenButtons:e});var n=1;this.callView.setCallback("onButtonClick",function(e){console.log(e.buttonName);switch(e.buttonName){case"hangup":case"close":this.callView.close();break;case"inviteUser":n++;BX.rest.callMethod("im.user.list.get",{ID:[n],AVATAR_HR:"Y"}).then(function(e){this.callView.updateUserData(e.data())}.bind(this));this.callView.addUser(n,BX.Call.UserState.Connecting);break;case"fullscreen":this.toggleFullScreen();break;case"record":this._onCallViewRecordButtonClick(e);break;case"floorRequest":this._onCallViewFloorRequestButtonClick(e);break;case"showChat":this.fold('asd "asd"');break;case"toggleScreenSharing":this.callView.setUserMedia(464,"screen",l.getVideoTracks()[0]);break;case"returnToCall":break;case"document":this._onCallViewDocumentButtonClick();break}}.bind(this));this.callView.setCallback(BX.Call.View.Event.onUserClick,function(e){if(!e.stream){this.callView.setUserState(e.userId,BX.Call.UserState.Connected);this.callView.setUserMedia(e.userId,"video",l.getVideoTracks()[0])}}.bind(this));this.callView.setUiState(BX.Call.View.UiState.Connected);this.callView.setCallback(BX.Call.View.Event.onBodyClick,this._onCallViewBodyClick.bind(this));this.callView.setCallback("onShow",this._onCallViewShow.bind(this));this.callView.setCallback("onClose",this._onCallViewClose.bind(this));this.callView.setCallback("onReplaceMicrophone",(function(e){console.log("onReplaceMicrophone",e)}));this.callView.setCallback("onReplaceCamera",(function(e){console.log("onReplaceCamera",e)}));this.callView.setCallback("onReplaceSpeaker",(function(e){console.log("onReplaceSpeaker",e)}));this.callView.show();if(i||t){return navigator.mediaDevices.getUserMedia({audio:i,video:t})}else{return new MediaStream}}.bind(this)).then(function(l){n=l;this.callView.setLocalStream(n);e.forEach((function(e){this.callView.addUser(e,BX.Call.UserState.Connected)}),this);if(i!==false){this.vad=new BX.SimpleVAD({mediaStream:n});setInterval(function(){this.callView.setMicrophoneLevel(this.vad.currentVolume)}.bind(this),100)}if(t){return navigator.mediaDevices.getUserMedia({audio:false,video:{width:320,height:180}})}else{return new MediaStream}}.bind(this)).then(function(t){l=t;this.callView.setUserMedia(e[0],"video",l.getVideoTracks()[0]);BX.rest.callMethod("im.user.list.get",{ID:e.concat(BXIM.userId),AVATAR_HR:"Y"}).then(function(e){this.callView.updateUserData(e.data())}.bind(this))}.bind(this))},testIncoming:function(){this.callNotification=new BX.Call.Notification({callerName:"this.currentCall.associatedEntity.name",callerAvatar:"this.currentCall.associatedEntity.avatar",callerType:"this.currentCall.associatedEntity.advanced.chatType",callerColor:"",video:true,hasCamera:false,onClose:this._onCallNotificationClose.bind(this),onDestroy:this._onCallNotificationDestroy.bind(this),onButtonClick:function(){this.callNotification.close()}.bind(this)});this.callNotification.show()},getMaxActiveMicrophonesCount:function(){return 4},showMicMutedNotification:function(){if(this.mutePopup||!this.callView){return}this.mutePopup=new BX.Call.MicMutedPopup({callFolded:this.folded,bindElement:this.folded?null:this.callView.buttons.microphone.elements.icon,targetContainer:this.folded?this.messenger.popupMessengerContent:this.callView.container,onClose:function(){this.allowMutePopup=false;this.mutePopup.destroy();this.mutePopup=null}.bind(this),onUnmuteClick:function(){this._onCallViewToggleMuteButtonClick({muted:false});this.mutePopup.destroy();this.mutePopup=null}.bind(this)});this.mutePopup.show()},showAutoMicMuteNotification:function(){if(this.mutePopup||!this.callView){return}this.mutePopup=new BX.Call.MicMutedPopup({callFolded:this.folded,bindElement:this.folded?null:this.callView.buttons.microphone.elements.icon,targetContainer:this.folded?this.messenger.popupMessengerContent:this.callView.container,title:BX.util.htmlspecialchars(BX.message("IM_CALL_MIC_AUTO_MUTED")),onClose:function(){this.mutePopup.destroy();this.mutePopup=null}.bind(this),onUnmuteClick:function(){this._onCallViewToggleMuteButtonClick({muted:false});this.mutePopup.destroy();this.mutePopup=null}.bind(this)});this.mutePopup.show()},showWebScreenSharePopup:function(){if(this.webScreenSharePopup){this.webScreenSharePopup.show();return}this.webScreenSharePopup=new BX.Call.WebScreenSharePopup({bindElement:this.callView.buttons.screen.elements.root,targetContainer:this.callView.container,onClose:function(){this.webScreenSharePopup.destroy();this.webScreenSharePopup=null}.bind(this),onStopSharingClick:function(){this._onCallViewToggleScreenSharingButtonClick();this.webScreenSharePopup.destroy();this.webScreenSharePopup=null}.bind(this)});this.webScreenSharePopup.show()},showFeedbackPopup:function(e){if(this.feedbackPopup){return}var t=!!BX.MessengerTheme.isDark();if(!BX.type.isPlainObject(e)){e={}}BX.loadExt("im.component.call-feedback").then(function(){var i;this.feedbackPopup=new BX.PopupWindow({id:"im-call-feedback",content:"",titleBar:BX.message("IM_CALL_QUALITY_FEEDBACK"),closeIcon:true,noAllPaddings:true,cacheable:false,background:t?"#3A414B":null,darkMode:t,closeByEsc:true,autoHide:true,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:function(){if(i){i.$destroy()}this.feedbackPopup=null}.bind(this)}});var n="<bx-im-component-call-feedback "+'@feedbackSent="onFeedbackSent" '+':darkMode="darkMode" '+':callDetails="callDetails" />';i=BX.Vue.createApp({template:n,data:function(){return{darkMode:t,callDetails:e}},methods:{onFeedbackSent:function(){setTimeout(function(){if(this.feedbackPopup){this.feedbackPopup.close()}}.bind(this),1500)}.bind(this)}});i.mount("#"+this.feedbackPopup.getContentContainer().id);this.feedbackPopup.show()}.bind(this))}};BX.Call.Controller.FeatureState={Enabled:"enabled",Disabled:"disabled",Limited:"limited"};BX.Call.Controller.Events=e;BX.Call.Controller.ViewState=t;BX.Call.Controller.DocumentType=i})(); //# sourceMappingURL=controller.map.js
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.25 |
proxy
|
phpinfo
|
Settings