@rongcloud/plugin-call-plus 2.46.0-alpha.1 → 2.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -0
- package/index.esm.js +1 -1
- package/index.js +1 -1
- package/package.json +3 -3
- package/wrapper/index.d.ts +20 -2
- package/wrapper/index.esm.js +1 -1
- package/wrapper/index.js +1 -1
package/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isNumber as e,isBoolean as t,isUndefined as i,isString as _,EventEmitter as r,ErrorCode as s,getUUID22 as o,SentStatus as n,RCConnectionStatus as l,isNull as a,getUUID as c,ConversationType as L,MessageDirection as E,ReceivedStatus as d,RTCMode as C,notEmptyArray as T,notEmptyString as I,isObject as S,VersionManage as u,LogL as g}from"@rongcloud/engine";import{RCResolution as h,RCFrameRate as R,RCRTCCode as A,RCKickReason as N,helper as O,RCLocalTrack as m,device as p}from"@rongcloud/plugin-rtc";export{RCFrameRate as RCCallPlusFrameRate,RCResolution as RCCallPlusResolution}from"@rongcloud/plugin-rtc";function f(e,t,i,_){return new(i||(i=Promise))(function(r,s){function o(e){try{l(_.next(e))}catch(e){s(e)}}function n(e){try{l(_.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,n)}l((_=_.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const U={SUCCESS:0,PARAM_ERROR:80001,SESSION_EXIST:80002,NOT_IN_CALL:80003,MEDIATYPE_INVALID:80004,NOT_VIDEO_CALL:80005,RTC_SERVICE_UNAVAILABLE:80006,USER_LIST_INVAILD:80007,CALL_ID_INVALID:80008,TRANSACTION_ID_INVALID:80009,USER_ID_INVALID:80010,SINGLE_CALL_NOT_SUPPORT_MULTI_PERSON:80011,SIGNAL_DISCONNECTED:80012,CAMERA_CLOSED:80100,MICROPHONE_CLOSED:80101,MEDIA_RESOURCE_INVALIED:80102,NOT_INSTALL_RTC_PLUGIN:80103,PLAY_MEDIA_FAILED:80104,VIDEO_VIEW_NOT_SET:80105};var v,M,P,D,y,b,G,V;!function(e){e.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O="L-index_install_call_plus_plugin-O",e.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O="L-callplus_client_set_event_listener-O",e.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O="L-callplus_client_call_event_listener-O",e.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O="L-callplus_client_set_status_report_listener-O",e.L_CALLPLUS_CLIENT_CALL_STATUS_REPORT_LISTENER_O="L-callplus_client_call_status_report_listener-O",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T="L-callplus_client_set_video_config-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R="L-callplus_client_set_video_config-R",e.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O="L-callplus_video_config_set_frame_rate-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O="L-callplus_video_config_set_resolution-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O="L-callplus_video_config_set_bitrate-O",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T="L-callplus_client_set_audio_config-T",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R="L-callplus_client_set_audio_config-R",e.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O="L-callplus_audio_config_set_bitrate-O",e.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O="L-callplus_audio_config_set_sample_rate-O",e.L_CALLPLUS_CLIENT_PREVIEW_T="L-callplus_client_preview-T",e.L_CALLPLUS_CLIENT_PREVIEW_R="L-callplus_client_preview-R",e.L_CALLPLUS_CLIENT_START_CALL_T="L-callplus_client_start_call-T",e.L_CALLPLUS_CLIENT_START_CALL_R="L-callplus_client_start_call-R",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T="L-callplus_client_join_multi_call-T",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R="L-callplus_client_join_multi_call-R",e.L_CALLPLUS_CLIENT_ACCEPT_T="L-callplus_client_accept-T",e.L_CALLPLUS_CLIENT_ACCEPT_R="L-callplus_client_accept-R",e.L_CALLPLUS_CLIENT_HANGUP_T="L-callplus_client_hangup-T",e.L_CALLPLUS_CLIENT_HANGUP_R="L-callplus_client_hangup-R",e.L_CALLPLUS_CLIENT_INVITE_T="L-callplus_client_invite-T",e.L_CALLPLUS_CLIENT_INVITE_R="L-callplus_client_invite-R",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T="L-callplus_client_request_change_media_type-T",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R="L-callplus_client_request_change_media_type-R",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T="L-callplus_client_cancel_change_media_type-T",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R="L-callplus_client_cancel_change_media_type-R",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T="L-callplus_client_reply_change_media_type-T",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R="L-callplus_client_reply_change_media_type-R",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_T="L-callplus_client_get_current_call_session-T",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_R="L-callplus_client_get_current_call_session-R",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_get_available_call_sessions_from_server-T",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_get_available_call_sessions_from_server-R",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T="L-callplus_client_get_call_records-T",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R="L-callplus_client_get_call_records-R",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T="L-callplus_client_delete_call_records_by_callId-T",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R="L-callplus_client_delete_call_records_by_callId-R",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_delete_all_call_records_from_server-T",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_delete_all_call_records_from_server-R",e.L_CALLPLUS_CLIENT_START_CAMERA_T="L-callplus_client_start_camera-T",e.L_CALLPLUS_CLIENT_START_CAMERA_R="L-callplus_client_start_camera-R",e.L_CALLPLUS_CLIENT_STOP_CAMERA_T="L-callplus_client_stop_camera-T",e.L_CALLPLUS_CLIENT_STOP_CAMERA_R="L-callplus_client_stop_camera-R",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T="L-callplus_client_switch_camera-T",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R="L-callplus_client_switch_camera-R",e.L_CALLPLUS_CLIENT_START_MICROPHONE_T="L-callplus_client_start_microphone-T",e.L_CALLPLUS_CLIENT_START_MICROPHONE_R="L-callplus_client_start_microphone-R",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T="L-callplus_client_stop_microphone-T",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R="L-callplus_client_stop_microphone-R",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T="L-callplus_client_switch_microphone-T",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R="L-callplus_client_switch_microphone-R",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T="L-callplus_client_set_video_view-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R="L-callplus_client_set_video_view-R",e.L_RTC_MODULE_SET_VIDEO_VIEW_O="L-rtc_module_set_video_view-O",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T="L-callplus_client_remove_video_view-T",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R="L-callplus_client_remove_video_view-R",e.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O="L-rtc_module_remove_video_view-O",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_T="L-callplus_client_play_media-T",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_R="L-callplus_client_play_media-R",e.L_RTC_MODULE_PLAY_MEDIA_T="L-rtc_module_play_media-T",e.L_RTC_MODULE_PLAY_MEDIA_R="L-rtc_module_play_media-R",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T="L-rtc_module_set_all_remote_audio_enbale-T",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R="L-rtc_module_set_all_remote_audio_enable-R",e.L_RTC_MODULE_SUBSCRIBE_T="L-rtc_module_subscribe-T",e.L_RTC_MODULE_SUBSCRIBE_R="L-rtc_module_subscribe-R",e.L_RTC_MODULE_UNSUBSCRIBE_T="L-rtc_module_unsubscribe-T",e.L_RTC_MODULE_UNSUBSCRIBE_R="L-rtc_module_unsubscribe-R",e.L_RTC_MODULE_PUBLISH_T="L-rtc_module_publish-T",e.L_RTC_MODULE_PUBLISH_R="L-rtc_module_publish-R",e.L_RTC_MODULE_UNPUBLISH_T="L-rtc_module_unpublish-T",e.L_RTC_MODULE_UNPUBLISH_R="L-rtc_module_unpublish-R",e.L_RTC_MODULE_DESTROY_ALL_TRACKS_O="L-rtc_module_destroy_all_tracks-O",e.L_RTC_MODULE_SESSION_CONNECT_T="L-rtc_module_session_connect-T",e.L_RTC_MODULE_SESSION_CONNECT_P="L-rtc_module_session_connect-P",e.L_RTC_MODULE_SESSION_CONNECT_R="L-rtc_module_session_connect-R",e.L_RTC_MODULE_SESSION_CLOSE_T="L-rtc_module_session_close-T",e.L_RTC_MODULE_SESSION_CLOSE_P="L-rtc_module_session_close-P",e.L_RTC_MODULE_SESSION_CLOSE_R="L-rtc_module_session_close-R",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_T="L-rtc_module_create_video_track-T",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_R="L-rtc_module_create_video_track-R",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_T="L-rtc_module_create_audio_track-T",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_R="L-rtc_module_create_audio_track-R",e.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O="L-rtc_module_receive_track_publish-O",e.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O="L-rtc_module_receive_track_unpublish-O",e.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O="L-rtc_module_receive_track_enable_change-O",e.L_RTC_MODULE_RECEIVE_KICK_OFF_O="L-rtc_module_receive_kick_off-O",e.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O="L-rtc_module_receive_peerconnection_except_close-O",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T="L-rtc_module_change_media_type-T",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R="L-rtc_module_change_media_type-R",e.L_RTC_MODULE_JOIN_RTC_ROOM_T="L-rtc_module_join_rtc_room-T",e.L_RTC_MODULE_JOIN_RTC_ROOM_R="L-rtc_module_join_rtc_room-R",e.L_RTC_MODULE_QUIT_RTC_ROOM_T="L-rtc_module_quit_rtc_room-T",e.L_RTC_MODULE_QUIT_RTC_ROOM_R="L-rtc_module_quit_rtc_room-R",e.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P="L-rtc_module_create_call_media_tracks-P",e.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T="L-signal_transporter_single_call-T",e.L_SIGNAL_TRANSPORTER_GROUP_CALL_T="L-signal_transporter_group_call-T",e.L_SIGNAL_TRANSPORTER_INVITE_T="L-signal_transporter_invite-T",e.L_SIGNAL_TRANSPORTER_RING_T="L-signal_transporter_ring-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_T="L-signal_transporter_accept-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_R="L-signal_transporter_accept-R",e.L_SIGNAL_TRANSPORTER_JOIN_CALL_T="L-signal_transporter_join_call-T",e.L_SIGNAL_TRANSPORTER_HANGUP_T="L-signal_transporter_hangup-T",e.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T="L-signal_transporter_call_status_up-T",e.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T="L-signal_transporter_call_event_up-T",e.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T="L-signal_transporter_call_dialog_up-T",e.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T="L-signal_transporter_delete_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T="L-signal_transporter_get_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T="L-signal_transporter_get_call_server_time-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T="L-signal_transporter_get_call_time_info-T",e.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T="L-signal_transporter_get_available_call_list-T",e.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T="L-signal_transporter_clear_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T="L-signal_transporter_get_call_info_by_callId-T",e.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T="L-signal_transporter_user_system_state_up-T",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O="L-signal_transporter_receive_call_signal_data-O",e.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O="L-signal_transporter_im_state_change-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O="L-signal_transporter_receive_invite-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O="L-signal_transporter_receive_call_status-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O="L-signal_transporter_receive_miss_message-O",e.L_CALL_ENGINE_UPDATE_USERS_STATE_O="L-call_engine_update_users_state-O",e.L_CALL_ENGINE_IM_STATE_CHANGE_O="L-call_engine_im_state_change-O",e.L_CALL_ENGINE_CALL_TIMEOUT_O="L-call_engine_call_timeout-O",e.L_CALL_ENGINE_START_CALL_TIMER_O="L-call_engine_start_call_timer-O",e.L_CALL_ENGINE_STOP_CALL_TIMER_O="L-call_engine_stop_call_timer-O",e.L_CALL_ENGINE_UP_ON_PHONE_END_T="L-call_engine_up_on_phone_end-T",e.L_CALL_ENGINE_UP_ON_PHONE_END_R="L-call_engine_up_on_phone_end-R",e.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O="L-call_engine_receive_first_frame_time-O",e.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O="L-call_engine_receive_mediatype_change-O",e.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O="L-call_engine_receive_close_session-O",e.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O="L-call_engine_receive_call_record-O",e.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O="L-call_engine_receive_complementary_data-O",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T="L-call_engine_create_session_by_server-T",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R="L-call_engine_create_session_by_server-R",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T="L-call_engine_up_first_frame_time-T",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R="L-call_engine_up_first_frame_time-R",e.L_TIME_CORRECT_START_O="L-time_correct_start-O",e.L_TIME_CORRECT_STOP_O="L-time_correct_stop-O",e.L_TIME_CORRECT_RESTART_O="L-time_correct_restart-O",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T="L-time_correct_get_call_client_time_by_server-T",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P="L-time_correct_get_call_client_time_by_server-P",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R="L-time_correct_get_call_client_time_by_server-R",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T="L-time_correct_calc_client_start_time-T",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R="L-time_correct_calc_client_start_time-R",e.L_TIME_CORRECT_SET_DELTA_TIME_O="L-time_correct_set_delta_time-O",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T="L-time_correct_loop_correct_client_time-T",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R="L-time_correct_loop_correct_client_time-R",e.L_INNER_SESSION_UPDATE_USER_STATE_O="L-inner_session_update_user_state-O",e.L_INNER_SESSION_SET_USER_DEVICE_ENABLE_O="L-inner_session_set_user_device_enable-O",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_T="L-callplus_session_get_create_time-T",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_R="L-callplus_session_get_create_time-R",e.L_CALLPLUS_SESSION_GET_DURATION_T="L-callplus_session_get_duration-T",e.L_CALLPLUS_SESSION_GET_DURATION_R="L-callplus_session_get_duration-R",e.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O="L-callplus_set_android_push_config-O",e.L_ABNORMAL_ADD_CALL_ID_E="L-ABNORMAL_ADD_CALL_ID-E",e.L_ABNORMAL_REMOVE_CALL_IDS_E="L-ABNORMAL_REMOVE_CALL_IDS-E",e.L_ABNORMAL_GET_CALL_IDS_E="L-ABNORMAL_GET_CALL_IDS-E",e.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O="L-set_audio_output_device_id-O"}(v||(v={}));class H{constructor(e,t,i,_,r){Object.defineProperty(this,"_session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_startTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_duration",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),this._callId=this._session.getCallId()}getCallId(){return this._callId}getState(){return this._session.getSessionState()}getCallType(){return this._session.getCallType()}getMediaType(){return this._session.getMediaType()}getUserList(){return this._session.getUserList().map(e=>{const{userId:t,userState:i}=e;let _=null,r=null;return t===this._context.getCurrentId()?(_=this._rtcModule.getLocalVideoTrack(),r=this._rtcModule.getLocalAudioTrack()):(_=this._rtcModule.getRemoteTrack(t,D.VIDEO),r=this._rtcModule.getRemoteTrack(t,D.AUDIO)),{userId:t,state:i,cameraEnable:!!_&&!_.isOwnerMuted(),microphoneEnable:!!r&&!r.isOwnerMuted()}})}getCreatorUserId(){return this._session.getStartCallerId()}getInviterUserId(){return this._session.getCallerId()}getCreateTimestamp(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_SESSION_GET_CREATE_TIME_T,"",e),this._startTime)return{code:U.SUCCESS,startTime:this._startTime};const{code:t,clientStartTime:i}=yield this._callEngine.getCallStaringTime({callId:this._callId},e);return t!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,`errCode: ${t}`,e),{code:t}):(this._logger.info(v.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,"success",e),this._startTime=i,{code:U.SUCCESS,startTime:this._startTime})})}getDuration(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_SESSION_GET_DURATION_T,"",e),this._duration)return this._logger.info(v.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${U.SUCCESS}, duration: ${this._duration}`,e),{code:U.SUCCESS,duration:this._duration};const{code:t,data:i}=yield this._callEngine.getCallTimeInfo(this._callId,e);return t!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${t}`,e),{code:t}):(this._logger.info(v.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${U.SUCCESS}, duration: ${i.duration}`,e),this._duration=i.duration,{code:U.SUCCESS,duration:this._duration})})}}!function(e){e[e.SINGLE=0]="SINGLE",e[e.MULTI=1]="MULTI"}(M||(M={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ONPHONE=301]="ONPHONE",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(P||(P={})),function(e){e[e.AUDIO=0]="AUDIO",e[e.AUDIO_VIDEO=1]="AUDIO_VIDEO",e[e.VIDEO=2]="VIDEO"}(D||(D={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ENDED=1e3]="ENDED",e[e.NOANSWER=1001]="NOANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELED=1003]="CANCELED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(y||(y={})),function(e){e[e.CANCEL_CHANGE_MEDIA_TYPE=0]="CANCEL_CHANGE_MEDIA_TYPE",e[e.REFUSE_CHANGE_MEDIA_TYPE=1]="REFUSE_CHANGE_MEDIA_TYPE",e[e.SERVER_ALLOW_MEDIA_TYPE=2]="SERVER_ALLOW_MEDIA_TYPE",e[e.CHANGE_MEDIA_TYPE_TIMEOUT=3]="CHANGE_MEDIA_TYPE_TIMEOUT"}(b||(b={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ON_PHONE=301]="ON_PHONE",e[e.ON_PHONE_END=302]="ON_PHONE_END",e[e.ON_DEVICE_DISABLE=303]="ON_DEVICE_DISABLE",e[e.ON_DEVICE_ENABLE=304]="ON_DEVICE_ENABLE",e[e.ABNORMAL_END=999]="ABNORMAL_END",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.OTHER_CLIENT_CALLING=1010]="OTHER_CLIENT_CALLING",e[e.OTHER_CLIENT_ACCEPT=1011]="OTHER_CLIENT_ACCEPT",e[e.JOIN_ROOM_ERR=1105]="JOIN_ROOM_ERR",e[e.PUBLISH_ERR=1106]="PUBLISH_ERR",e[e.SUBSCRIBE_ERR=1107]="SUBSCRIBE_ERR",e[e.ACCEPT_CARRIER=1108]="ACCEPT_CARRIER",e[e.KICKED_BY_SERVER=1109]="KICKED_BY_SERVER",e[e.CONNECTION_ERR=1110]="CONNECTION_ERR",e[e.LOGOUT=1111]="LOGOUT",e[e.OTHER_CLIENT_LOGIN=1112]="OTHER_CLIENT_LOGIN",e[e.OTHER_CLIENT_JOINED=1113]="OTHER_CLIENT_JOINED",e[e.OTHER_CLIENT_IN_ROOM=1114]="OTHER_CLIENT_IN_ROOM",e[e.OTHER_CLIENT_HANGUP=1151]="OTHER_CLIENT_HANGUP",e[e.REMOTE_JOIN_RTC_ERROR=1205]="REMOTE_JOIN_RTC_ERROR",e[e.REMOTE_PUBLISH_ERROR=1206]="REMOTE_PUBLISH_ERROR",e[e.REMOTE_SUBSCRIBE_ERROR=1207]="REMOTE_SUBSCRIBE_ERROR",e[e.REMOTE_KICKED_BY_SERVER=1209]="REMOTE_KICKED_BY_SERVER",e[e.REMOTE_CONNECTION_ERROR=1210]="REMOTE_CONNECTION_ERROR",e[e.REMOTE_LOGOUT=1211]="REMOTE_LOGOUT",e[e.REMOTE_OTHER_CLIENT_LOGIN=1212]="REMOTE_OTHER_CLIENT_LOGIN",e[e.REMOTE_OTHER_JOINED_RTC=1213]="REMOTE_OTHER_JOINED_RTC",e[e.REMOTE_OTHER_CLIENT_IN_RTC=1214]="REMOTE_OTHER_CLIENT_IN_RTC"}(G||(G={})),function(e){e[e.START=1]="START",e[e.END=2]="END"}(V||(V={}));class w{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}setDefaultMicrophoneId(e){return this._audioConfig.microphoneId=e,this}setBitrate(t,i){return!e(t)||!e(i)||i<=0||t<=0||i<t?(this._logger.error(v.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O,`params error -> max: ${i},min: ${t}, max and min is a number > 0, max should > min`),this):(this._audioConfig.minBitrate=t,this._audioConfig.maxBitrate=i,this)}setSampleRate(t){return e(t)?(this._audioConfig.sampleRate=t,this):(this._logger.error(v.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O,`params error -> sampleRate: ${t}`),this)}build(){return this._audioConfig}}class k{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:h.W640_H480,frameRate:R.FPS_15}})}setFrameRate(e){return R[e]?(this._videoConfig.frameRate=e,this):(this._logger.error(v.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O,`params error -> fps: ${e}`),this)}setVideoResolution(e){return h[e]?(this._videoConfig.resolution=e,this):(this._logger.error(v.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O,`params error -> resolution: ${e}`),this)}setDefaultCameraId(e){return this._videoConfig.cameraId=e,this}setBitrate(t,i){return!e(t)||!e(i)||i<=0||t<=0||i<t?(this._logger.error(v.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O,`params error -> max: ${i},min: ${t}, max and min is a number > 0, max should > min`),this):(this._videoConfig.minBitrate=t,this._videoConfig.maxBitrate=i,this)}build(){return this._videoConfig}}const $=e=>{const{callId:t,callType:i,callDir:_,mediaType:r,callingUserId:s,callUserIds:o,callStatus:n,sessionStatus:l,startTime:a,endTime:c,duration:L,syncTime:E,sysStatus:d,crtTime:C}=e;return{callId:t,callType:i,callDirection:_,mediaType:r,callerUserId:s,callUserIds:o,sessionState:n,userState:l,startTimestamp:a,endTimestamp:c,duration:L,syncTimestamp:E,systemState:d,createTimestamp:C}},B=e=>e&&e.nodeName&&"VIDEO"===e.nodeName.toUpperCase(),x=e=>{const{voipCallInfo:t}=e;if(!t)return!1;const{strategy:i}=JSON.parse(t);return 1===i},F=(t,i)=>!t&&0!==t||e(t)&&!(t<=0)?!i&&0!==i||e(i)&&!(i<=0)?t&&i&&i<t?{code:U.PARAM_ERROR,errorMsg:`params error -> maxBitrate: ${i}, minBitrate: ${t}, maxBitrate should > minBitrate`}:{code:U.SUCCESS}:{code:U.PARAM_ERROR,errorMsg:`params error -> maxBitrate: a number of > 0, value: ${i}`}:{code:U.PARAM_ERROR,errorMsg:`params error -> minBitrate: a number of > 0, value: ${t}`},j=e=>{const t=[];for(const i in e){const{videoView:_,isTiny:r}=e[i];t.push({userId:i,videoView:_.nodeName,isTiny:r})}return t},Y=(e,t={},i={})=>{const{threadId:_,apnsCollapseId:r,richMediaUri:s}=t,{channelIdMi:o,templateIdMi:n,templateParamMi:l,channelIdHW:a,channelIdOPPO:c,typeVivo:L,fcmChannelId:E,fcmCollapseKey:d,fcmImageUrl:C,importanceHW:T,categoryHW:I,imageUrlHW:S,categoryVivo:u,importanceHonor:g,imageUrlHonor:h}=i,R={};_&&(R["thread-id"]=_),R["apns-collapse-id"]=r||e,s&&(R.richMediaUri=s);const A={};a&&(A.channelId=a),S&&(A.image=S),I&&(A.category=I),A.importance=T||"NORMAL";const N=[{HW:A},{APNS:R}];let O;(d||C||E)&&(O={},d&&(O.collapse_key=d),C&&(O.imageUrl=C),E&&(O.channelId=E),N[N.length]={FCM:O});const m=!!l&&Object.keys(l).length>0;if(o||n||m){const e={};o&&(e.channelId=o),n&&(e.templateId=n),m&&(e.templateParam=l),N[N.length]={MI:e}}let p,f,U;return c&&(p={},p.channelId=c,N[N.length]={OPPO:p}),(L||u)&&(f={},L&&(f.classification=L),u&&(f.category=u),N[N.length]={VIVO:f}),(g||h)&&(U={},g&&(U.importance=g),h&&(U.image=h),N[N.length]={HONOR:U}),JSON.stringify(N)},J=(e,i)=>{const{pushTitle:_="",iOSConfig:r,androidConfig:s,disablePushTitle:o,templateId:n}=e,l={pushConfigs:Y(i,r,s)};return t(o)&&(l.disableTitle=o),_&&(l.title=_),n&&(l.templateId=n),JSON.stringify(l)},W=e=>{const r=["pushTitle","pushContent","iOSConfig","androidConfig","disablePushTitle","templateId"];if(!Object.keys(e).every(e=>r.includes(e)))return{code:U.PARAM_ERROR,errorMsg:`right key: ${r.join(",")}`};for(let s=0;s<r.length;s++){const o=r[s];if("disablePushTitle"===o){if(!i(e[o])&&!t(e[o]))return{code:U.PARAM_ERROR,errorMsg:`${o} type is boolean`}}else if(("pushTitle"===o||"templateId"===o||"pushContent"===o)&&e[o]&&!_(e[o]))return{code:U.PARAM_ERROR,errorMsg:`${o} type is string`}}const{iOSConfig:s,androidConfig:o}=e,n=K(s||{});if(n.code!==U.SUCCESS)return n;const l=Q(o||{});return l.code!==U.SUCCESS?l:{code:U.SUCCESS}},K=e=>{const{threadId:t,richMediaUri:i}=e||{};return t&&!_(t)?{code:U.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:i&&!_(i)?{code:U.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:U.SUCCESS}},Q=e=>{const t=["channelIdMi","templateIdMi","templateParamMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"];if(!Object.keys(e).every(e=>t.includes(e)))return{code:U.PARAM_ERROR,errorMsg:`right key: ${t.join(",")}`};for(let i=0;i<t.length;i++){const r=t[i];if("importanceHW"===r||"importanceHonor"===r){if(e[r]&&"LOW"!==e[r]&&"NORMAL"!==e[r])return{code:U.PARAM_ERROR,errorMsg:`androidConfig.${r} value is NORMAL|LOW`}}else if("templateParamMi"===r){if(e[r]&&("object"!=typeof e[r]||Array.isArray(e[r])))return{code:U.PARAM_ERROR,errorMsg:`androidConfig.${r} type is object`};if(e[r]){const t=Object.keys(e[r]).find(t=>!_(t)||!_(e[r][t]));if(void 0!==t)return{code:U.PARAM_ERROR,errorMsg:`androidConfig.${r}.${t} key and value type is string`}}}else if(e[r]&&!_(e[r]))return{code:U.PARAM_ERROR,errorMsg:`androidConfig.${r} type is string`}}return{code:U.SUCCESS}},q=(e,t="utf-8")=>{let i=0;return i="utf-16"===t?X(e):z(e),i},X=e=>{let t,i=0;for(let _=0,r=e.length;_<r;_++)t=e.charCodeAt(_),i+=t<=65535?2:4;return i},z=e=>{let t,i=0;for(let _=0,r=e.length;_<r;_++)t=e.charCodeAt(_),i+=t<127?1:t<=2047?2:t<=65535?3:4;return i},Z=/Electron/.test(navigator.userAgent);var ee,te,ie,_e,re,se;!function(e){e.L_QS_START_CALL_S="Call-start-S",e.L_QS_ACCEPT_CALL_S="Call-accept-S",e.L_QS_HANGUP_CALL_S="Call-hangup-S",e.L_QS_RECEIVE_CALL_S="Call-recv-S",e.L_QS_ABNORMAL_HANGUP_S="Call-interrupt-S"}(ee||(ee={}));class oe{constructor(e,t){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t})}reportStatisticsData(e,t,i,_,r,s,o){const n=+new Date,{mediaType:l,callType:a,callId:c}=_?{mediaType:_.getMediaType(),callType:_.getCallType(),callId:_.getCallId()}:o,L={cr:"unknown",net:"unknown",cod:t,mtp:l,ctp:a,cid:c,time:n,uid:this._context.getCurrentId()};r&&Object.assign(L,{ccid:r});let E=null;switch(e){case ee.L_QS_RECEIVE_CALL_S:E=Object.assign(Object.assign({},L),{rf:s});break;case ee.L_QS_ABNORMAL_HANGUP_S:E=Object.assign({},L);break;default:E=Object.assign(Object.assign({},L),{dur:n-i})}this._logger.__statistics(e,JSON.stringify(E))}}!function(e){e.REQUEST="request",e.ACCEPT="accept",e.REFUSE="refuse",e.CANCEL="cancel",e.NOTICE="notice",e.TIMEOUT="timeout"}(te||(te={})),function(e){e[e.SWITCH_MEDIA_TYPE=1]="SWITCH_MEDIA_TYPE"}(ie||(ie={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.SECRET=1]="SECRET"}(_e||(_e={})),function(e){e.INVITER="inviter",e.INVITEE="invitee"}(re||(re={}));class ne extends r{constructor(e,t,i,_,r,s,o,n){super(),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_callType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_startCallerId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_callerId",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_callUsers",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_reqMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_inviterTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_inviteeTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_oldDialogData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLocalClientHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1})}getCallId(){return this._callId}getSessionState(){return this._state}getCallType(){return this._callType}getMediaType(){return this._mediaType}getStartCallerId(){return this._startCallerId}getCallerId(){return this._callerId}getUserList(){return this._callUsers}getReqMediaType(){return this._reqMediaType}getInviterTimerId(){return this._inviterTimerId}getInviteeTimerId(){return this._inviteeTimerId}getAllTimerIds(){return[this._inviterTimerId,this._inviteeTimerId]}updateUserList(e,t){const i=[];return e.forEach(e=>{const{userState:t,stateTime:_,systemState:r,userId:s}=e,o=this._callUsers.findIndex(e=>e.userId===s);if(o<0)return this._callUsers.push(e),void i.push(e);const{stateTime:n,systemState:l,userState:a}=this._callUsers[o],c=((e,t)=>{let i=!1;const _=[G.INVITED,G.RINGING,G.BUSYLINE_RINGING,G.BUSYLINE_WAIT,G.CONNECTING,G.ONCALL];return e===G.ONCALL&&_.includes(t)&&(i=!0),i})(l,r),L=((e,t)=>{let i=!1;const _=[P.INVITED,P.RINGING,P.BUSYLINE_RINGING,P.BUSYLINE_WAIT,P.CONNECTING,P.ONCALL];return e===P.ONCALL&&_.includes(t)&&(i=!0),i})(a,t),E=r===G.ON_PHONE_END&&l!==G.ON_PHONE&&t!==P.IDLE;_&&n&&_<n||c&&L||(this._callUsers[o]=e,!E&&i.push(e))}),i}setOldDialogData(e){this._oldDialogData=e}updateSessionState(e){this._state=e}updateCallType(e){this._callType=e}updateMediaType(e){this._mediaType=e}updateReqMediaType(e){this._reqMediaType=e}updateTimerId(e,t){e===re.INVITER?this._inviterTimerId=t:this._inviteeTimerId=t}getOldDialogData(){return this._oldDialogData}setIsLocalClientHangup(e){this.isLocalClientHangup=e}getIsLocalClientHangup(){return this.isLocalClientHangup}}!function(e){e.START_SINGLE_CALL="startSingleCall",e.START_GROUP_CALL="startGroupCall",e.INVITE_CALL="inviteCall",e.PUB_INVITE_CALL="pubInviteCall",e.RINGING_CALL="ringCall",e.ACCEPT_CALL="acceptCall",e.JOIN_CALL="joinCall",e.HANGUP_CALL="hangupCall",e.STATUS_UP_CALL="statusUpCall",e.STATUS_DOWN_CALL="statusDownCall",e.EVENT_UP_CALL="eventUpCall",e.EVENT_DOWN_CALL="eventDownCall",e.DIALOG_UP_CALL="dialogUpCall",e.DIALOG_DOWN_CALL="dialogDownCall",e.GET_CALL_USER_SESSION_LIST="getCallUSerSessionList",e.SYNC_CALL_LOG="syncCallLog",e.PUB_CALL_LOG="pubCallLog",e.DEL_CALL_LOG="deleteCallLog",e.QRY_CALL_STATE="queryUserHasCall",e.QRY_SRV_TIMESTAMP="getCallSrvTimeStamp",e.GET_CALL_STATE_LIST="getUserCallStateList",e.CLEAR_CALL_LOG="cleanCallLog",e.GET_CALL_SESSION="getCallSession",e.GET_CALL_TIME_INFO="getCallTimeInfo",e.END_ABNORMAL_CALL="endUserAbnormalCalls",e.SYS_STATUS_UP="sysStatusUp",e.UP_CALL_LOG_READED="upCallLogReaded",e.PUB_CALL_LOG_READED="pubCallLogReaded",e.PUB_NACK_SEQ_ID="pubNACKSeqId",e.GET_USER_CALL_SESSION_ID_LIST="getUserCallSessionIdList"}(se||(se={}));const le=(e,t)=>setTimeout(e,t),ae=[s.RC_NET_CHANNEL_INVALID,s.RC_NET_UNAVAILABLE,s.RC_MSG_RESP_TIMEOUT,A.SIGNAL_DISCONNECTED,A.REQUEST_FAILED],ce=({asyncFn:e,fnArgs:t,currentRetryTime:i=Date.now(),maxDuration:_=6e4,intervals:r=[2e3,4e3,8e3,16e3,32e3,64e3],index:s=0,onError:o})=>f(void 0,void 0,void 0,function*(){const n=yield e(...t);return n.code===U.SUCCESS||!ae.includes(n.code)||Date.now()+2e3-i>_?n:(o&&o(n.code),yield(l=2e3,new Promise(e=>{setTimeout(e,l)})),ce({asyncFn:e,fnArgs:t,currentRetryTime:i,maxDuration:_,intervals:r,index:s,onError:o}));var l});var Le,Ee,de;!function(e){e.onBeforePublish="onBeforePublish",e.onPublishRes="onPublishRes",e.onPubInviteCall="onPubInviteCall",e.onPubInviteCallPullKv="onPubInviteCallPullKv",e.onPubInviteCallMiss="onPubInviteCallMiss"}(Le||(Le={})),function(e){e.NOT_CURRENT_DEVICEID="not current device id",e.SECRET_CALL="secret call",e.NOT_INVITEE="not an invitee"}(Ee||(Ee={})),function(e){e.PUB_INVITE="pubinvitecall",e.PULL_KV_INVITE="pullkv_invitecall",e.PUSH="system_pubsh"}(de||(de={}));const Ce=131072,Te="RC:CallPlusMiss",Ie="RC:CallGroupStatusMsg";class Se extends r{constructor(e,t,i,_,r,s){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_needRetryActions",{enumerable:!0,configurable:!0,writable:!0,value:[se.START_SINGLE_CALL,se.START_GROUP_CALL,se.ACCEPT_CALL,se.JOIN_CALL,se.EVENT_UP_CALL]}),Object.defineProperty(this,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:""}),this._context.onCallInfo=this._onRecvCallSignal.bind(this),this._context.onconnectionstatechange=this._onIMConnectionStateChange.bind(this),this._context.onmessage=this._onMessage.bind(this),this._sessionId=o()}_onMessage(e){return!![Te,Ie].includes(e.messageType)&&(e.messageType===Te?this._dealMissMessage(e):this._dealGroupCallMessage(e),!0)}_dealMissMessage(e){const{content:{callId:t,mediaType:i,startTime:_,callSessionUsers:r},targetId:s,senderUserId:o}=e,l=this._context.getCurrentId();if(!localStorage.getItem(`missMessageMap-${l}-${t}`)){const a={callId:t,callerUserId:o,targetId:s,mediaType:i,firstFrameTime:0,callStartTime:_-this._timeCorrectioner.getLocalDelayTime(),callEndTime:0,hangupReason:r.filter(({userId:e})=>e===l)[0].sessionStatus};this._logger.info(v.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O,`receive miss message: ${JSON.stringify(e)}`);const c=Object.assign(e,{content:a,sentStatus:n.SENT});this._reportAppEventModule.onReceivedCallPlusSummaryMessage(c),localStorage.setItem(`missMessageMap-${l}-${t}`,t)}}_dealGroupCallMessage(e){this._reportAppEventModule.onReceivedGroupCallStatusMessage(e)}getSessionId(){return this._sessionId}getDeviceId(){return Z?this._context.getDeviceId():this._sessionId}registerListener(e){this._listener=e}startCall(e,t){return f(this,void 0,void 0,function*(){const{clientCallId:i,callType:_,toUsers:r,mediaType:s,secretChat:o,targetType:n,targetId:l,nickName:a,oldRoomId:c,pushExt:L,pushContent:E,extra:d}=e;return _===M.SINGLE?this.startSingleCall({clientCallId:i,toUserId:r[0].userId,mediaType:s,secretChat:o,targetType:n,targetId:l,oldRoomId:c,toOrgId:r[0].orgId||"",pushExt:L,pushContent:E,extra:d},t):this.startGroupCall({clientCallId:i,toUsers:r,mediaType:s,targetType:n,targetId:l,nickName:a,oldRoomId:c,pushExt:L,pushContent:E,extra:d},t)})}startSingleCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(this._context.getCurrentId(),se.START_SINGLE_CALL,e)})}startGroupCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_GROUP_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(this._context.getCurrentId(),se.START_GROUP_CALL,e)})}inviteCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_INVITE_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.INVITE_CALL,e)})}ringingCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_RING_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.RINGING_CALL,e)})}acceptCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_ACCEPT_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.ACCEPT_CALL,e)})}joinCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_JOIN_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.JOIN_CALL,e)})}hangupCall(e,t){return f(this,void 0,void 0,function*(){this._logger.info(v.L_SIGNAL_TRANSPORTER_HANGUP_T,`params: ${JSON.stringify(e)}`,t);const{code:i}=yield this._sendCallSignal(e.callId,se.HANGUP_CALL,e);return i===U.NOT_IN_CALL?{code:U.SUCCESS}:{code:i}})}statusUpCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T,`call status up params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.STATUS_UP_CALL,e)})}eventUpCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.EVENT_UP_CALL,e)})}dialogUpCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.DIALOG_UP_CALL,e)})}deleteCallRecord(e,t,i){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T,`callIds: ${JSON.stringify(t)}`,i),this._sendCallSignal(e,se.DEL_CALL_LOG,{callIds:t})})}syncCallLog(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.userId,se.SYNC_CALL_LOG,e)})}queryUserHasCall(){return f(this,void 0,void 0,function*(){const e=this._context.getCurrentId();return this._sendCallSignal(e,se.QRY_CALL_STATE,null)})}getCallServerTimestamp(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(v.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T,`userId: ${t}`,e),this._sendCallSignal(t,se.QRY_SRV_TIMESTAMP,null)})}getCallTimeInfo(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T,`callId: ${e}`,t),this._sendCallSignal(e,se.GET_CALL_TIME_INFO,{callId:e})})}getUserCallStateList(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(v.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T,`userId: ${t}`,e),this._sendCallSignal(t,se.GET_CALL_STATE_LIST,null)})}clearCallRecord(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(v.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T,`userId: ${t}`,e),this._sendCallSignal(t,se.CLEAR_CALL_LOG,null)})}getCallSession(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T,`callId: ${e.callId}`,t),this._sendCallSignal(e.callId,se.GET_CALL_SESSION,e)})}sysStatusUp(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T,`opts: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.SYS_STATUS_UP,e)})}upCallLogReaded(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._sendCallSignal(t,se.UP_CALL_LOG_READED,e)})}endUserAbnormalCalls(e){return f(this,void 0,void 0,function*(){return this._sendCallSignal(this._context.getCurrentId(),se.END_ABNORMAL_CALL,e)})}_onIMConnectionStateChange(e){const t=this._logger.createTraceId();this._logger.info(v.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O,`state: ${e}`,t),this._listener.onIMStateChange(e),e===l.CONNECTED?this._timeCorrectioner.start(t):this._timeCorrectioner.stop(t)}_sendCallSignal(e,t,i){return f(this,void 0,void 0,function*(){let _,r="";i&&(r=Z?JSON.stringify(i):JSON.stringify(Object.assign(Object.assign({},i),{sessionId:this._sessionId}))),_=this._needRetryActions.includes(t)?yield ce({asyncFn:this._context.setCallInfo.bind(this._context),fnArgs:[e,t,r]}):yield this._context.setCallInfo(e,t,r);const{code:o,data:n}=_;if(o!==s.SUCCESS)return{code:o};const{value:l}=n,a=JSON.parse(l).data;return{code:U.SUCCESS,data:a}})}_onRecvCallSignal(e){const t=this._logger.createTraceId();this._logger.info(v.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O,`data: ${e}`,t);JSON.parse(e).list.forEach(e=>{const{key:i}=e,_=JSON.parse(e.value);switch(i){case se.PUB_INVITE_CALL:this._onPubInviteCall(_,t,!0);break;case se.STATUS_DOWN_CALL:this._onStatusDownCall(_,t);break;case se.EVENT_DOWN_CALL:this._onEventDownCall(_,t);break;case se.DIALOG_DOWN_CALL:this._onDialogDownCall(_,t);break;case se.PUB_CALL_LOG:this._onPubCallLog(_,t);break;case se.PUB_CALL_LOG_READED:case se.PUB_NACK_SEQ_ID:break;default:this._onConpensationData(_,t)}})}isValidData(e){if(a(e))return!0;const t=e===this.getDeviceId();return!(!_(e)||0!==(null==e?void 0:e.length)&&!t)}_onPubInviteCall(e,t,i=!0){try{const i=this._context.getCurrentId(),_=e.callSessionUsers.find(e=>e.userId===i),r=this._context.getConnectionStatus();this._logger.info(v.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`currentUser: ${JSON.stringify(_)}, currentUserId: ${i}, state: ${r}`,t)}catch(e){this._logger.error(v.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`error: ${e.message}`,t)}if(!this.isValidData(e.toDeviceId||"")){this._logger.warn(v.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`not current deviceId -> deviceInfo: ${JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this.getDeviceId()})}`,t);const _={extra:JSON.stringify(e),reason:Ee.NOT_CURRENT_DEVICEID,refer:i?de.PUB_INVITE:de.PULL_KV_INVITE};return void this.emit(Le.onPubInviteCallMiss,Object.assign(e,_))}this._listener.onInvite(e,i,t),i?this.emit(Le.onPubInviteCall,Object.assign(e,{extra:JSON.stringify(e)})):this.emit(Le.onPubInviteCallPullKv,Object.assign(e,{extra:JSON.stringify(e)}))}_onStatusDownCall(e,t){if(e.callSessionUsers=e.callSessionUsers.filter(e=>Boolean(e.changed)),this._logger.info(v.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,"",t),!this.isValidData(e.toDeviceId||""))return this._logger.warn(v.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,`not current deviceId -> deviceInfo: ${JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this.getDeviceId()})}`,t),void this._listener.onOtherClientStatusDown(e,t);this._listener.onStatusDown(e,t,this._sessionId)}_onEventDownCall(e,t){this._listener.onEventDown(e,t)}_onDialogDownCall(e,t){const{dialogType:i}=e;i===ie.SWITCH_MEDIA_TYPE&&this._listener.onSwitchMediaType(e,t)}_onPubCallLog(e,t){this._logger.info(v.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O,`call record: ${JSON.stringify(e)}`,t),this._listener.onRecvCallEndLog(e,t)}_onConpensationData(e,t){this._logger.info(v.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O,"",t);const{callId:i,callType:_,mediaType:r,secretChat:s,duration:o,callStatus:n,callingUserId:l,callSessionUsers:a,toDeviceId:c,callDialogEntitys:L,extra:E}=e;a.some(e=>e.sessionStatus===P.INVITED&&e.userId===this._context.getCurrentId())?this._onPubInviteCall({callId:i,toDeviceId:c,callType:_,mediaType:r,inviteUserId:l,callingUserId:l,callSessionUsers:a,secretChat:s,extra:E},t,!0):this._onStatusDownCall({callId:i,toDeviceId:c,callStatus:n,duration:o,callSessionUsers:a},t),L.length>0&&L.forEach(e=>this._onDialogDownCall(e,t),this)}}const ue=()=>{let e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});return e=`${e.replace(/-/g,"")}0`,e=parseInt(e,16),e=(e=>{const t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),i=t.length+1;let _=+e;const r=[];do{const e=_%i;_=(_-e)/i,r.unshift(t[e])}while(_);return r.join("")})(e),e.length>22&&(e=e.slice(0,22)),e};class ge{constructor(e,t){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_localStore",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._localStore=e.localStorage}addAbnormallCallId(e,t){try{const i=JSON.parse(this._localStore.getItem(ge._STORAGE_KEY)||"{}");let _=i[e];_?_.push(t):_=[t],i[e]=_,this._localStore.setItem(ge._STORAGE_KEY,JSON.stringify(i))}catch(e){this._logger.error(v.L_ABNORMAL_ADD_CALL_ID_E,e.message),console.error(e)}}removeAbnormalCallIds(e,t){try{const i=JSON.parse(this._localStore.getItem(ge._STORAGE_KEY)||"{}");let _=i[e];_&&(_=_.filter(e=>!t.includes(e)),_.length>0?i[e]=_:delete i[e],this._localStore.setItem(ge._STORAGE_KEY,JSON.stringify(i)))}catch(e){this._logger.error(v.L_ABNORMAL_REMOVE_CALL_IDS_E,e.message),console.error(e)}}getAbnormalCallIds(e){let t=null;try{const i=JSON.parse(this._localStore.getItem(ge._STORAGE_KEY)||"{}")[e];i&&(t=i)}catch(e){this._logger.error(v.L_ABNORMAL_GET_CALL_IDS_E,e.message),console.error(e)}return Promise.resolve(t)}}var he,Re,Ae,Ne,Oe;Object.defineProperty(ge,"_STORAGE_KEY",{enumerable:!0,configurable:!0,writable:!0,value:"CallPlus_AbnormalCall"}),function(e){e[e.PROMPT=0]="PROMPT",e[e.CALL_DURATION=10]="CALL_DURATION",e[e.FIRST_FRAME=20]="FIRST_FRAME"}(he||(he={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.INVALID_RESPONSE_TIME=80170]="INVALID_RESPONSE_TIME",e[e.NONOPTIMAL_RES_TIME=80171]="NONOPTIMAL_RES_TIME"}(Re||(Re={}));class me{constructor(e,t,i){Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_singleCallDurationEv",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_RTT",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_validMinRTT",{enumerable:!0,configurable:!0,writable:!0,value:200}),Object.defineProperty(this,"_validMaxRTT",{enumerable:!0,configurable:!0,writable:!0,value:1e3}),Object.defineProperty(this,"_deltaTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_timerId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_interval",{enumerable:!0,configurable:!0,writable:!0,value:2e3}),Object.defineProperty(this,"_maxRetryTimes",{enumerable:!0,configurable:!0,writable:!0,value:8}),Object.defineProperty(this,"_startTimes",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_retryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_maxRetryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:3})}getCallClientTimeByServer(e,t){return f(this,void 0,void 0,function*(){this._logger.info(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T,`callId: ${e}`,t),(!this._RTT||this._RTT>this._validMinRTT)&&(yield this._getDeltaTime(t)),this._RTT>this._validMaxRTT&&this._logger.error(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${Re.INVALID_RESPONSE_TIME}`,t);const{code:i,data:_}=yield this._callEngine.getCallTimeInfo(e,t);if(i!==U.SUCCESS)return this._logger.error(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${i}`,t),{code:i};const{startTime:r}=_,s=Math.floor(r-this._deltaTime);let o=(Date.now()+this._deltaTime-r)/1e3;return o<0&&(this._logger.warn(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P,`invalid duration: ${o}`,t),o=0),o=Math.floor(o),this._RTT>this._validMinRTT&&this._RTT<=this._validMaxRTT&&this._logger.error(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${Re.NONOPTIMAL_RES_TIME}`,t),this._logger.info(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,serverStartTime:r,clientStartTime:s,duration:o}),t),{code:i,duration:o,clientStartTime:r?s:r}})}calcClientStartTime(e,t,i){if(this._logger.info(v.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T,`callId: ${e}, startTime: ${t}`,i),this._RTT>this._validMaxRTT)return this._logger.error(v.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,`code: ${Re.INVALID_RESPONSE_TIME}`,i),this._loopCorrectClientTime(e,i),{code:Re.INVALID_RESPONSE_TIME};const _=Math.floor(t-this._deltaTime);return this._logger.info(v.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,startT:t,clientStartTime:_}),i),this._RTT>this._validMinRTT&&(this._retryTimesInCall=0,this._loopCorrectClientTime(e,i)),{code:Re.SUCCESS,clientStartTime:_}}start(e){this._timerId||this._startTimes>=this._maxRetryTimes||(this._logger.info(v.L_TIME_CORRECT_START_O,`timerId: ${this._timerId}`),this._startTimes++,this._getDeltaTime(e),this._timerId=le(()=>{this._timerId=null,this.start(e)},this._interval))}stop(e){this._logger.info(v.L_TIME_CORRECT_STOP_O,`timerId: ${this._timerId}`,e),this._timerId&&clearTimeout(this._timerId),this._timerId=null,this._startTimes=0}restart(e){this._logger.info(v.L_TIME_CORRECT_RESTART_O,`legal rtt time, RTT: ${this._RTT}, validMinRTT: ${this._validMinRTT}`,e),this._RTT<this._validMinRTT||(this.stop(e),this.start(e))}getLocalDelayTime(){return Math.round(this._deltaTime)}getRTT(){return this._RTT}_getDeltaTime(e){return f(this,void 0,void 0,function*(){const t=Date.now(),{code:i,data:_}=yield this._callEngine.getCallServerTimestamp(e),r=Date.now();if(i!==U.SUCCESS)return{code:i};const s=r-t;return(s<this._RTT||0===this._RTT)&&s<=this._validMaxRTT&&(this._RTT=s),s<this._validMinRTT&&this.stop(e),this._deltaTime=_-t-this._RTT/2,this._logger.info(v.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime}),e),{code:i,delayTime:this._deltaTime}})}_getDeltaTimeInCall(e,t){return f(this,void 0,void 0,function*(){const i=Date.now(),{code:_,data:r}=yield this._callEngine.getCallTimeInfo(e,t),s=Date.now();if(_!==U.SUCCESS)return{code:_};const o=s-i;o<this._RTT&&(this._RTT=o),this._deltaTime=r.syncTime-i-this._RTT/2,this._logger.info(v.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({callId:e,rtt:this._RTT,deltaT:this._deltaTime}),t);const n=Math.floor(r.startTime-this._deltaTime),l=Math.floor(r.firstFrametime-this._deltaTime);return o<this._validMinRTT?{code:Re.SUCCESS,clientStartTime:n,clientFirstFrameTime:l}:{code:Re.INVALID_RESPONSE_TIME,clientStartTime:n,clientFirstFrameTime:l}})}_loopCorrectClientTime(e,t){return f(this,void 0,void 0,function*(){this.stop(t),this._logger.info(v.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T,`callId: ${e}`,t);const{code:i,clientStartTime:_,clientFirstFrameTime:r}=yield this._getDeltaTimeInCall(e,t);return i===Re.SUCCESS?(this._logger.info(v.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,`code: ${U.SUCCESS}`,t),void this._singleCallDurationEv(e,_,r,t)):this._retryTimesInCall>this._maxRetryTimesInCall&&i===Re.INVALID_RESPONSE_TIME?(this._logger.info(v.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,`code: ${Re.INVALID_RESPONSE_TIME}`,t),void this._singleCallDurationEv(e,_,r,t)):void(this._retryTimesInCall>this._maxRetryTimesInCall||(this._retryTimesInCall++,setTimeout(()=>{this._loopCorrectClientTime(e,t)},this._interval)))})}}!function(e){e[e.SOON_AFETER=0]="SOON_AFETER",e[e.CURRENT=1]="CURRENT"}(Ae||(Ae={})),function(e){e[e.PUB_INVITE_CALL=0]="PUB_INVITE_CALL",e[e.PULL_KV_INVITE_CALL=1]="PULL_KV_INVITE_CALL",e[e.SYSTEM_PUSH=2]="SYSTEM_PUSH"}(Ne||(Ne={})),function(e){e[e.OUT=-1]="OUT",e[e.GROUP=0]="GROUP",e[e.IN=1]="IN"}(Oe||(Oe={}));class pe extends r{constructor(e,t,i,_,r){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_mainSession",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_holdSessions",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_signalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_abnormalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isUpFirstFrameTime",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_callStartMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._timeCorrectioner=new me(this,_,this._onRecvSinCallDuration.bind(this)),this._signalModule=new Se(e,t,i,this._timeCorrectioner,this._logger,this._reportAppEventModule),this._signalModule.registerListener({onInvite:this._onInvite.bind(this),onStatusDown:this._onStatusDown.bind(this),onOtherClientStatusDown:this._onOtherClientStatusDown.bind(this),onEventDown:this._onEventDown.bind(this),onSwitchMediaType:this._onSwitchMediaType.bind(this),onRecvCallEndLog:this._onRecvCallEndLog.bind(this),onIMStateChange:this._onIMStateChange.bind(this)}),this._abnormalModule=new ge(t,_)}startCall(e,t){return f(this,void 0,void 0,function*(){const i=this._context.getCurrentId(),{callType:_,mediaType:r,toUsers:s,targetId:o,targetType:n,oldRoomId:l,pushConfig:a,extra:c}=e;this._clientCallId=e.callId;const L=a?J(a,this._clientCallId):"",{code:E,data:d}=yield this._signalModule.startCall({clientCallId:this._clientCallId,callType:_,mediaType:r,toUsers:s,secretChat:_e.NORMAL,targetType:n,targetId:o,oldRoomId:l,pushExt:L,pushContent:(null==a?void 0:a.pushContent)||"",extra:c},t);if(E!==U.SUCCESS)return{code:E};const{callId:C,busylineUsers:T}=d;if(this._abnormalModule.addAbnormallCallId(i,C),this._mainSession=new ne(C,y.INVITED,_,r,i,i,[],this._logger),_===M.SINGLE){const e=this._startTimer(d.callId,P.NO_ANSWER,t);this._mainSession.updateTimerId(re.INVITER,e)}const I={userId:i,userState:P.CALLING,systemState:G.CALLING,targetType:n,targetId:o};let S=s.map(({userId:e,targetType:t,targetId:i})=>({userId:e,userState:P.INVITED,systemState:G.INVITED,targetType:t,targetId:i})),u=[];T&&(u=T.map(e=>{const{targetType:t,targetId:i}=S.find(t=>t.userId===e.userId);return{userId:e.userId,userState:e.sessionStatus,systemState:G.BUSYLINE_RINGING,targetType:t,targetId:i}}),S=S.filter(({userId:e})=>u.every(({userId:t})=>t!==e)));const g=this.updateUsersState(C,[I,...S,...u],t);return setTimeout(()=>{g.length>0&&this.reportRemoteUserStateChange(C,g,t)}),{code:E,data:d}})}invite(e,t){var i;return f(this,void 0,void 0,function*(){if(!this._mainSession)return{code:U.NOT_IN_CALL};const{toUsers:_,pushConfig:r,extra:s}=e,o=r?J(r,this._clientCallId):"",n=this._mainSession.getCallId(),{code:l,data:a}=yield this._signalModule.inviteCall({callId:n,toUsers:_,pushExt:o,pushContent:(null==r?void 0:r.pushContent)||"",extra:s},t);if(l===U.SUCCESS){this._mainSession.getCallType()===M.SINGLE&&(this._mainSession.updateCallType(M.MULTI),this._onCallTypeChange(this._mainSession.getCallId(),M.MULTI,t));let e=_.map(({userId:e,targetType:t,targetId:i})=>({userId:e,userState:P.INVITED,systemState:G.INVITED,targetType:t,targetId:i})),r=[];a.busylineUsers&&(r=null===(i=a.busylineUsers)||void 0===i?void 0:i.map(t=>{const{targetType:i,targetId:_}=e.find(e=>e.userId===t.userId);return{userId:t.userId,userState:t.sessionStatus,systemState:G.BUSYLINE_RINGING,targetType:i,targetId:_}}),e=e.filter(({userId:e})=>r.every(({userId:t})=>t!==e)));const s=this.updateUsersState(n,[...e,...r],t);s.length>0&&this.reportRemoteUserStateChange(n,s,t)}return{code:l,data:a}})}clearAllTimer(e,t){[this._mainSession,...this._holdSessions].forEach(i=>{i&&i.getCallId()===e&&i.getAllTimerIds().forEach(e=>this._stopTimer.bind(this)(e,t))})}hangup(e,t){return f(this,void 0,void 0,function*(){const{callId:i,systemState:_,pushConfig:r}=e,s=r?J(r,this._clientCallId):"",{code:o}=yield this._signalModule.hangupCall({callId:i,sysStatus:_,pushExt:s,pushContent:(null==r?void 0:r.pushContent)||""},t);return this.endCurrentSession(e.systemState,i,t),{code:o}})}accept(e,t){return f(this,void 0,void 0,function*(){if(!this._mainSession)return{code:U.NOT_IN_CALL};const{callId:i}=e,{code:_}=yield this._signalModule.acceptCall({callId:i},t);return this._stopTimer(this._mainSession.getInviteeTimerId(),t),_!==U.SUCCESS||(this._clearMobileOnPhone(e.callId,t),this._mainSession.updateSessionState(y.CONNECTING)),{code:_}})}joinCall(e,t){return f(this,void 0,void 0,function*(){const i=this._context.getCurrentId();this._mainSession&&this._stopTimer(this._mainSession.getInviteeTimerId(),t);const{code:_}=yield this._signalModule.joinCall({callId:e.callId},t);return _!==U.SUCCESS||(this._abnormalModule.addAbnormallCallId(i,e.callId),this._mainSession?this._clearMobileOnPhone(e.callId,t):yield this._createSessionByServer(e.callId,t,!0)),{code:_}})}requestChangeMediaType(e,t){return f(this,void 0,void 0,function*(){if(!this._mainSession)return{code:U.NOT_IN_CALL};const i={mediaType:e.mediaType};this._mainSession.updateReqMediaType(e.mediaType);const _=ue(),{code:r}=yield this._signalModule.dialogUpCall({transactionId:_,callId:this._mainSession.getCallId(),toUserIds:e.toUserIds,dialogType:ie.SWITCH_MEDIA_TYPE,action:te.REQUEST,extraKeyVal:i},t);return r!==U.SUCCESS?{code:r}:{code:U.SUCCESS,data:{transactionId:_}}})}responseChangeMediaType(e,t){return f(this,void 0,void 0,function*(){return this._mainSession?this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:ie.SWITCH_MEDIA_TYPE,action:e.agree?te.ACCEPT:te.REFUSE},t):{code:U.NOT_IN_CALL}})}cancelChangeMediaType(e,t){return f(this,void 0,void 0,function*(){return this._mainSession?this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:ie.SWITCH_MEDIA_TYPE,action:te.CANCEL},t):{code:U.NOT_IN_CALL}})}getCallLogList(e,t){return f(this,void 0,void 0,function*(){const i=this._context.getCurrentId(),{timestamp:_,count:r,order:s}=e,{code:o,data:n}=yield this._signalModule.syncCallLog({userId:i,syncTime:_,count:r,order:s},t);if(o!==U.SUCCESS)return{code:o};const l=n.callLogList.map(e=>$(e));return{code:U.SUCCESS,data:{hasMore:Boolean(null==n?void 0:n.hasMore),syncTime:0===s?n.maxTime:n.minTime,list:l}}})}deleteCallLog(e,t){return f(this,void 0,void 0,function*(){const i=this._context.getCurrentId();return this._signalModule.deleteCallRecord(i,e,t)})}getCallServerTimestamp(e){return f(this,void 0,void 0,function*(){const{code:t,data:i}=yield this._signalModule.getCallServerTimestamp(e);return t!==U.SUCCESS?{code:t}:{code:t,data:i.syncTime}})}getCallTimeInfo(e,t){return f(this,void 0,void 0,function*(){return this._signalModule.getCallTimeInfo(e,t)})}getOpenCallList(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId(),{code:i,data:_}=yield this._signalModule.getUserCallStateList(e);if(i!==U.SUCCESS)return{code:i};return{code:i,data:_.callStateList.map(i=>{const{callId:_,callType:r,mediaType:s,callingUserId:o,callUserIds:n,callStatus:l,crtTime:a,userSessionStatus:c,startTime:L,syncTime:E}=i,d=o===t?Oe.OUT:Oe.IN,{clientStartTime:C=L}=this._timeCorrectioner.calcClientStartTime(_,L,e);return{callId:_,callType:r,callDirection:d,mediaType:s,callerUserId:o,callUserIds:n,sessionState:l,userState:c,startTimestamp:L,endTimestamp:0,duration:Math.floor((+new Date-C)/1e3),syncTimestamp:E,systemState:0,createTimestamp:a}})}})}removeAllCallLog(e){return f(this,void 0,void 0,function*(){const{code:t}=yield this._signalModule.clearCallRecord(e);return{code:t}})}getCallSession(e,t){return f(this,void 0,void 0,function*(){const{code:i,data:_}=yield this._signalModule.getCallSession(e,t);if(i!==U.SUCCESS)return{code:i};const{callId:r,callingUserId:s,callType:o,mediaType:n,callStatus:l,callSessionUsers:a,startTime:c,duration:L,syncTime:E}=_;return{code:i,data:{callId:r,startCallerId:s,callType:o,mediaType:n,sessionState:l,callSessionUsers:a.map(e=>{const{userId:t,sessionStatus:i,sysStatus:_,targetType:r,targetId:s}=e;return{userId:t,userState:i,systemState:_,targetType:r,targetId:s,cameraEnable:!1,microphoneEnable:!1}}),startTime:c,duration:L,syncTime:E}}})}getHoldSession(e){const t=this._holdSessions.find(t=>t&&t.getCallId()===e);return t?new H(t,this,this._logger,this._rtcModule,this._context):null}getLocalMainSession(){return this._mainSession?new H(this._mainSession,this,this._logger,this._rtcModule,this._context):null}updateMainSessionState(e){var t;null===(t=this._mainSession)||void 0===t||t.updateSessionState(e)}setIsLocalClientHangup(e){var t;null===(t=this._mainSession)||void 0===t||t.setIsLocalClientHangup(e)}updateUsersState(e,t,i){this._logger.info(v.L_CALL_ENGINE_UPDATE_USERS_STATE_O,`updateUsersState -> users: ${JSON.stringify(t)}`,i);const _=[this._mainSession,...this._holdSessions].find(t=>(null==t?void 0:t.getCallId())===e),r=[];return _?r.push(..._.updateUserList(t,i)):r.push(...t),r}getCallStaringTime(e,t){return f(this,void 0,void 0,function*(){return this._timeCorrectioner.getCallClientTimeByServer(e.callId,t)})}systemStatusUp(e,t){return f(this,void 0,void 0,function*(){return this._signalModule.sysStatusUp(e,t)})}upFirstFrameTime(e){return f(this,void 0,void 0,function*(){if(!this._mainSession||this._mainSession&&this._mainSession.getCallType()!==M.SINGLE||this._isUpFirstFrameTime)return{code:U.SUCCESS};const t=Date.now(),i=this._timeCorrectioner.getLocalDelayTime(),_=Math.floor(t+i);this._logger.info(v.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T,`now: ${t}; delay: ${i}; streamReadyTime: ${_}`,e),this._isUpFirstFrameTime=!0;const r=this._mainSession.getCallId(),{code:s}=yield this._signalModule.eventUpCall({callId:r,eventType:he.FIRST_FRAME,eventArgs:{streamReadyTime:_},eventTime:Date.now()},e);return this._logger.info(v.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R,`code: ${s}`,e),{code:s}})}endCurrentSession(e,t,i){const _=this._context.getCurrentId();if(this._mainSession&&this._mainSession.getCallId()===t){const t=this._mainSession.getUserList().map(t=>{let{userId:i,systemState:r,targetType:s,targetId:o}=t;return i===_&&(r=e),{userId:i,sessionStatus:P.ENDED,statusTime:Date.now(),duration:0,changed:1,inviteUserId:this._mainSession.getStartCallerId(),sysStatus:r,targetType:s,targetId:o}}),r={callId:this._mainSession.getCallId(),toDeviceId:this._signalModule.getDeviceId(),callStatus:y.ENDED,duration:0,callSessionUsers:t};this._onStatusDown(r,i)}}startTimeCorrection(e){this._timeCorrectioner.restart(e)}getDelayTimeInfo(){return{delayTime:this._timeCorrectioner.getLocalDelayTime(),rtt:this._timeCorrectioner.getRTT()}}upgradeMainSession(e){var t;const i=this._holdSessions.findIndex(t=>t.getCallId()===e);this._mainSession=null===(t=this._holdSessions.splice(i,1))||void 0===t?void 0:t[0]}endCurrentUserAbnormalCalls(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId(),i=yield this._abnormalModule.getAbnormalCallIds(t);if(!i)return{code:U.SUCCESS};const _=i.filter(e=>{var t;return e!==(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId())}),{code:r}=yield this._signalModule.endUserAbnormalCalls({callIds:_,allDevice:e?1:0});return r===U.SUCCESS&&this._abnormalModule.removeAbnormalCallIds(t,_),{code:r}})}setRTCModule(e){this._rtcModule=e}_onIMStateChange(e){const t=this._logger.createTraceId();let i=0;e===l.DISCONNECTED&&this._mainSession&&this._mainSession.getSessionState()!==y.ONCALL&&(i=le(()=>{var e;this._logger.info(v.L_CALL_ENGINE_IM_STATE_CHANGE_O,"endCurrentSession, IM disconnected for more than 60s",t),this.endCurrentSession(G.CONNECTION_ERR,null===(e=this._mainSession)||void 0===e?void 0:e.getCallId(),t)},6e4)),e===l.CONNECTED&&(i&&clearTimeout(i),this._initOpts.isAllowNewCallWhenRinging&&this.endCurrentUserAbnormalCalls(!0))}_handleCallTimeout(e,t,i){this._logger.warn(v.L_CALL_ENGINE_CALL_TIMEOUT_O,`call timeout callId: ${e}, userState: ${t}`,i);const _=[this._mainSession,...this._holdSessions].find(t=>t&&t.getCallId()===e);if(!_)return void this._logger.warn(v.L_CALL_ENGINE_CALL_TIMEOUT_O,`handleCallTimeout without session, callId: ${e}`,i);const r=this._context.getCurrentId();this._onStatusDown({callId:e,toDeviceId:this._signalModule.getDeviceId(),callStatus:y.ENDED,duration:0,callSessionUsers:_.getUserList().map(e=>{const{userId:i,targetType:s,targetId:o,stateTime:n}=e;let l,a;return i===r?(l=t===P.MISSED?G.MISSED:G.NO_ANSWER,a=t===P.MISSED?P.MISSED:P.NO_ANSWER):(l=t===P.MISSED?G.NO_ANSWER:G.MISSED,a=t===P.MISSED?P.NO_ANSWER:P.MISSED),{userId:i,sessionStatus:a,statusTime:n?n+1:Date.now(),duration:0,changed:1,inviteUserId:_.getCallerId(),sysStatus:l,targetType:s,targetId:o}})},i)}_startTimer(e,t,i){const _=le(()=>{this._handleCallTimeout(e,t,i),this._signalModule.statusUpCall({callId:e,sessionStatus:t},i)},6e4);return this._logger.info(v.L_CALL_ENGINE_START_CALL_TIMER_O,`callId: ${e}, timerId: ${_}`,i),_}_stopTimer(e,t){clearTimeout(e),this._logger.info(v.L_CALL_ENGINE_STOP_CALL_TIMER_O,`timerId: ${e}`,t)}_onInvite(e,t,i){this._clientCallId=c();const _=this._context.getCurrentId(),{callSessionUsers:r,secretChat:s,extra:o="{}"}=e;if(s===_e.SECRET)return void this.emit(Le.onPubInviteCallMiss,Object.assign(e,{extra:JSON.stringify(e),reason:Ee.SECRET_CALL,refer:t?de.PUB_INVITE:de.PULL_KV_INVITE}));r.some(e=>e.userId===_)&&this._selfIsInviteeHandle(e,t,i,o),this._othersIsInviteeHandle(e,i)}_selfIsInviteeHandle(e,t,i,_){const{callId:r,inviteUserId:s,callType:o,mediaType:n,callSessionUsers:l}=e,a=this._context.getCurrentId();this._abnormalModule.addAbnormallCallId(a,r);const c=new ne(r,y.RINGING,o,n,s,s,[],this._logger);this._signalModule.ringingCall({callId:r},i);const L=this._startTimer(r,P.MISSED,i);c.updateTimerId(re.INVITEE,L),this._mainSession?(this._holdSessions.push(c),this._mainSession.updateSessionState(y.BUSYLINE_WAIT)):this._mainSession=c;const E=new H(c,this,this._logger,this._rtcModule,this._context),d=t?Ne.PUB_INVITE_CALL:Ne.PULL_KV_INVITE_CALL;this.emit(pe.__INNER_INVITE__,E,d);const C=l.map(({userId:e,sessionStatus:t,sysStatus:i,targetType:_,targetId:r,statusTime:s})=>({userId:e,userState:t,systemState:i,targetType:_,targetId:r,stateTime:s})),T=this.updateUsersState(r,C,i);this._reportAppEventModule.onReceivedCall(E,i,JSON.parse(_||"{}").extra),T.length>0&&this.reportRemoteUserStateChange(r,T,i)}_othersIsInviteeHandle(e,t){var i,_,r;const{callId:s,inviteUserId:o,callSessionUsers:n}=e,l=this._context.getCurrentId(),a=n.filter(e=>e.userId!==l&&e.userId!==o&&e.sessionStatus===P.INVITED);if(!a.length)return;(null===(i=this._mainSession)||void 0===i?void 0:i.getCallType())===M.SINGLE&&(null===(_=this._mainSession)||void 0===_?void 0:_.getCallId())===s&&(this._onCallTypeChange(this._mainSession.getCallId(),M.MULTI,t),null===(r=this._mainSession)||void 0===r||r.updateCallType(M.MULTI));const c=[],L=[];a.forEach(e=>{const{userId:t,sessionStatus:i,sysStatus:_}=e;c.push({callId:s,userId:t,userState:i}),L.push({userId:t,userState:i,systemState:_})}),this._onOtherMemberInvite(c);const E=this.updateUsersState(s,L,t);E.length>0&&this.reportRemoteUserStateChange(s,E,t)}_onHangup(e,t,i){this._mainSession&&e.forEach(e=>{e.callId===this._mainSession.getCallId()&&(e.userState===P.CANCELLED?this._stopTimer(this._mainSession.getInviteeTimerId(),i):this._stopTimer(this._mainSession.getInviterTimerId(),i))})}_onAccept(e,t){var i,_,r,s;const o=null===(i=this._mainSession)||void 0===i?void 0:i.getSessionState(),n=[y.CONNECTING,y.ONCALL,y.BUSYLINE_WAIT];if((null===(_=this._mainSession)||void 0===_?void 0:_.getCallType())===M.SINGLE&&o&&n.includes(o))return;const l=this._mainSession.getStartCallerId(),a=this._context.getCurrentId();if((null===(r=this._mainSession)||void 0===r?void 0:r.getCallType())===M.SINGLE&&l===a){e.filter(e=>e.fromUserId!==a)&&this.emit(pe.__INNER_SESSION_CONNECT__,this.getLocalMainSession().getCallId(),t)}null===(s=this._mainSession)||void 0===s||s.updateSessionState(y.CONNECTING),this._stopTimer(this._mainSession.getInviterTimerId(),t)}_onStatusDown(e,t){var i,_;return f(this,void 0,void 0,function*(){const{callStatus:r,startTime:s,callId:o}=e;if(o!==(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId()))return;if(this._callStartMap[o]=this._callStartMap[o]||{},!this._callStartMap[o].isReceiveCallStartTime&&r===y.ONCALL){this._callStartMap[o].isReceiveCallStartTime=!0;const{code:e,clientStartTime:i}=this._timeCorrectioner.calcClientStartTime(o,s,t);e===Re.SUCCESS&&(this._callStartMap[o].callStartTime=i,this._reportAppEventModule.onReceivedCallStartTime({callId:o,callStartTime:i},t))}let n=!1;const l=this._context.getCurrentId(),a=e.callSessionUsers.map(e=>([P.IDLE,P.DECLINED,P.MISSED,P.NO_ANSWER,P.CANCELLED].includes(e.sessionStatus)&&e.sysStatus!==G.CANCELLED&&e.userId===l&&(n=!0),{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,stateTime:e.statusTime}));if(a.length){const e=this.updateUsersState(o,a,t);e.length>0&&this.reportRemoteUserStateChange(o,e,t)}if(!this._mainSession&&!this._holdSessions.length)return;const{hangupData:c,acceptData:L,otherInvitedData:E}=(e=>{const{callId:t}=e,i=[],_=[],r=[],s=[];return e.callSessionUsers.forEach(e=>{const{userId:o,sessionStatus:n,sysStatus:l}=e;switch(n){case P.INVITED:s.push({callId:t,userId:o,userState:n});break;case P.RINGING:i.push({callId:t,fromUserId:o});break;case P.CONNECTING:r.push({fromUserId:o});break;case P.CANCELLED:case P.DECLINED:case P.ENDED:case P.IDLE:_.push({callId:t,fromUserId:o,userState:n,systemState:l})}}),{ringingData:i,hangupData:_,acceptData:r,otherInvitedData:s}})(e);c.length>0&&this._onHangup(c,e.callStatus,t),L.length>0&&this._onAccept(L,t),E.length>0&&(null===(_=this._mainSession)||void 0===_?void 0:_.getCallType())===M.MULTI&&this._onOtherMemberInvite(E),(e.callStatus===y.ENDED||n)&&this._onSessionClose(e,t,n)})}_onOtherClientStatusDown(e,t){var i,_,r;const{callId:s,callSessionUsers:o}=e,n=this._context.getCurrentId(),l=o.find(({userId:e})=>e===n);if(l&&(this._mainSession||this._holdSessions.length)){const{userId:o,sessionStatus:a,statusTime:c}=l;if(a===P.CONNECTING){const l=[P.ONCALL,P.CONNECTING],L=(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())===s,E=null===(r=null===(_=this._mainSession)||void 0===_?void 0:_.getUserList().find(e=>e.userId===n))||void 0===r?void 0:r.userState;if(!(L&&E&&l.includes(E))){const i=this.updateUsersState(s,[{userId:o,userState:a,systemState:G.OTHER_CLIENT_ACCEPT,stateTime:c}],t);i.length>0&&this.reportRemoteUserStateChange(s,i,t),this._onSessionClose(e,t,!1)}}}}_onEventDown(e,t){var i;return f(this,void 0,void 0,function*(){const{callId:_,eventArgs:r,eventType:s}=e;if(_===(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())&&this._mainSession.getSessionState()===y.ONCALL&&s===he.CALL_DURATION){const{firstFrameTime:e}=r,{code:i,clientStartTime:s}=this._timeCorrectioner.calcClientStartTime(_,e,t);this._logger.info(v.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O,`clientFirstFrameTime: ${s}`,t),i===Re.SUCCESS&&(this._callStartMap[_].firstFrameTime=s,this._reportAppEventModule.onReceivedCallFirstFrameTime(_,s,t))}})}_onRecvSinCallDuration(e,t,i,_){var r;(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())===e&&(this._callStartMap[e].callStartTime=t,this._callStartMap[e].firstFrameTime=i,this._reportAppEventModule.onReceivedCallStartTime(Object.assign({callId:e},{callStartTime:t}),_),this._reportAppEventModule.onReceivedCallFirstFrameTime(e,i,_))}_onSwitchMediaType(e,t){var i,_,r,s,o;const{callId:n,action:l,extraKeyVal:a,transactionId:c,promoterId:L}=e,{mediaType:E,reason:d}=a,C=null===(i=this._mainSession)||void 0===i?void 0:i.getCallId();if(n!==C)return void this._logger.info(v.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,`not current session callId: ${C}, recvCallId: ${n}`,t);const{transactionId:T,action:I,mediaType:S}=(null===(_=this._mainSession)||void 0===_?void 0:_.getOldDialogData())||{};if(T!==c||I!==l||S!==E){if(this._logger.info(v.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,`action: ${l}, reason: ${d}`,t),null===(r=this._mainSession)||void 0===r||r.setOldDialogData({transactionId:c,action:l,mediaType:E}),l===te.REQUEST)this._onRequestChangeMediaType({transactionId:c,userId:L,mediaType:E},t);else{let e=null;switch(d){case te.CANCEL:e=b.CANCEL_CHANGE_MEDIA_TYPE;break;case te.ACCEPT:e=b.SERVER_ALLOW_MEDIA_TYPE,null===(s=this._mainSession)||void 0===s||s.updateMediaType(this._mainSession.getReqMediaType()),null===(o=this._mainSession)||void 0===o||o.updateReqMediaType(null);break;case te.REFUSE:e=b.REFUSE_CHANGE_MEDIA_TYPE;break;case te.TIMEOUT:e=b.CHANGE_MEDIA_TYPE_TIMEOUT}b[e]&&this._receiveMediaTypeChangeResult({transactionId:c,userId:L,mediaType:E},e,t)}l!==te.NOTICE||E!==D.AUDIO||d||this._receiveMediaTypeChangeResult({transactionId:c,userId:L,mediaType:E},b.SERVER_ALLOW_MEDIA_TYPE,t)}else this._logger.info(v.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"duplicate dialog data",t)}_onRecvCallEndLog(e,t){const i=$(e);this._reportAppEventModule.onReceivedCallRecord(i,t)}_onSessionClose(e,t,i){const{callId:_}=e,r=this._context.getCurrentId();this._abnormalModule.removeAbnormalCallIds(r,[_]);let s=[this._mainSession,...this._holdSessions].find(e=>e&&e.getCallId()===_);if(!s)return void this._logger.warn(v.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,`unexpect session callId -> ${_}`,t);this._logger.warn(v.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,`callId: ${_}`,t),this.emit(pe.__INNER_SESSION_CLOSE__,_,t);const o=s.getUserList().find(e=>e.userId===r);let n;n=i&&e.toDeviceId!==this._signalModule.getDeviceId()?s.getIsLocalClientHangup()?o.systemState:G.OTHER_CLIENT_HANGUP:o.systemState,this._reportAppEventModule.onCallEnded(new H(s,this,this._logger,this._rtcModule,this._context),n,t),this._reportCallPlusSummaryMessage(s,_,n),this._mainSession&&this._mainSession.getCallId()===_&&(this._mainSession.getAllTimerIds().forEach(e=>this._stopTimer.bind(this)(e,t)),s.getCallType()===M.SINGLE&&(this._isUpFirstFrameTime=!1),delete this._callStartMap[_]),this._removeSession(_)}_reportCallPlusSummaryMessage(e,t,i){var _,r,s;const o=this._context.getCurrentId(),l=e.getUserList().filter(({userId:e})=>e!==o)[0].userId,a=e.getStartCallerId();if(!localStorage.getItem(`missMessageMap-${o}-${t}`)){const c={callId:t,callerUserId:a,targetId:l,mediaType:e.getMediaType(),firstFrameTime:(null===(_=this._callStartMap[t])||void 0===_?void 0:_.firstFrameTime)||0,callStartTime:(null===(r=this._callStartMap[t])||void 0===r?void 0:r.callStartTime)||0,callEndTime:(null===(s=this._callStartMap[t])||void 0===s?void 0:s.callStartTime)?+new Date-this._timeCorrectioner.getLocalDelayTime():0,hangupReason:i};this._reportAppEventModule.onReceivedCallPlusSummaryMessage({messageType:"RC:CallPlusSummary",content:c,senderUserId:a,targetId:l,channelId:"",conversationType:L.PRIVATE,sentTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),receivedTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),messageUId:t,messageDirection:a===o?E.SEND:E.RECEIVE,isPersited:!0,isCounted:!1,isOffLineMessage:!1,canIncludeExpansion:!1,receivedStatus:d.READ,isStatusMessage:!1,isMentioned:!1,expansion:null,disableNotification:!1,sentStatus:n.SENT}),localStorage.setItem(`missMessageMap-${o}-${t}`,t)}}_removeSession(e){var t;if(e===(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId()))this._mainSession=null;else{const t=this._holdSessions.findIndex(t=>(null==t?void 0:t.getCallId())===e);this._holdSessions.splice(t,1)}}_createSessionByServer(e,t,i=!1){return f(this,void 0,void 0,function*(){this._logger.info(v.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T,`callId: ${e}`,t);const{code:_,data:r}=yield this.getCallSession({callId:e},t);if(_!==U.SUCCESS)return void this._logger.error(v.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,`errcode: ${_}`,t);this._logger.info(v.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,`code: ${_}, data: ${JSON.stringify(r)}`,t);const{callType:s,mediaType:o,callSessionUsers:n,startCallerId:l}=r;this._mainSession=new ne(e,y.CONNECTING,s,o,l,l,[],this._logger),i&&this._clearMobileOnPhone(e,t);const a=this.updateUsersState(e,n,t);a.length>0&&this.reportRemoteUserStateChange(e,a,t)})}_clearMobileOnPhone(e,t){return f(this,void 0,void 0,function*(){const i=[this._mainSession,...this._holdSessions].find(t=>(null==t?void 0:t.getCallId())===e);if(i&&i.getCallType()===M.MULTI){this._logger.info(v.L_CALL_ENGINE_UP_ON_PHONE_END_T,`callId: ${e}`,t);const{code:i}=yield this.systemStatusUp({callId:e,sysStatus:G.ON_PHONE_END,forward:Ae.CURRENT},t);i===U.SUCCESS?this._logger.info(v.L_CALL_ENGINE_UP_ON_PHONE_END_R,`callId: ${e}`,t):this._logger.warn(v.L_CALL_ENGINE_UP_ON_PHONE_END_R,`callId: ${e}, errCode: ${i}`,t)}})}reportRemoteUserStateChange(e,t,i){const _=this._context.getCurrentId();t.forEach(t=>{const{userId:r,userState:s,systemState:o}=t;r!==_&&this._reportAppEventModule.onRemoteUserStateChanged({callId:e,userId:r,userState:s,reason:o},i)}),t.forEach(({userId:t,systemState:r})=>{t===_&&r===G.ABNORMAL_END&&this.emit(pe.__INNER_SESSION_CLOSE__,e,i)})}_onOtherMemberInvite(e){e.forEach(e=>{var t;const{userId:i,callId:_}=e,r=null===(t=this.getLocalMainSession())||void 0===t?void 0:t.getInviterUserId();this._reportAppEventModule.onRemoteUserInvited([i],r,_)})}_onRequestChangeMediaType(e,t){var i;const{userId:_,transactionId:r,mediaType:s}=e;null===(i=this._mainSession)||void 0===i||i.updateReqMediaType(s),this._reportAppEventModule.onReceivedChangeMediaTypeRequest(_,r,s,t)}_receiveMediaTypeChangeResult(e,t,i){t===b.SERVER_ALLOW_MEDIA_TYPE&&this.emit(pe.__INNER_CHANGE_MEDIA_TYPE__,e.mediaType,i),this._reportAppEventModule.onReceivedChangeMediaTypeResult(Object.assign(Object.assign({},e),{code:t}),i)}_onCallTypeChange(e,t,i){this._reportAppEventModule.onCallTypeChanged(t,e,i)}}var fe,Ue;Object.defineProperty(pe,"__INNER_SESSION_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-close"}),Object.defineProperty(pe,"__INNER_SESSION_CONNECT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-connect"}),Object.defineProperty(pe,"__INNER_CHANGE_MEDIA_TYPE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-change-media-type"}),Object.defineProperty(pe,"__INNER_INVITE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-invite"}),function(e){e.NORMAL="RongCloudRTC",e.SCREEN="ScreenShare"}(fe||(fe={}));class ve extends r{constructor(e,t,i,_,r,s){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_room",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_callMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:h.W640_H480,frameRate:R.FPS_15}}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_isPubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_audioOutputDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_videoConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_audioConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_userViewMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_callPlusStatusReportListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_remoteAudioEnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"_preHangupCallId",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._rtcClient=null==i?void 0:i.rtcClient,this._isPubTiny=i.isPubTiny||!1}setCallPlusStatusReportListener(e){this._callPlusStatusReportListener=e}getCameraVideoTrack(e){return f(this,void 0,void 0,function*(){const t=this.getLocalVideoTrack(),{code:i,track:_}=t&&!this._videoConfigIsChange?{track:t,code:U.SUCCESS}:yield this._createVideoTrack(e);return this._videoConfigIsChange=!1,i!==U.SUCCESS?{code:i}:{code:U.SUCCESS,track:_}})}getMicrophoneAudioTrack(e){return f(this,void 0,void 0,function*(){const t=this.getLocalAudioTrack(),{code:i,track:_}=t&&!this._audioConfigIsChange?{track:t,code:U.SUCCESS}:yield this._createAudioTrack(e);return this._audioConfigIsChange=!1,i!==U.SUCCESS?{code:i}:{code:U.SUCCESS,track:_}})}createCallMediaTracks(e,t){return f(this,void 0,void 0,function*(){this._callMediaType=e;const{code:i}=yield this.getMicrophoneAudioTrack(t);if(i!==U.SUCCESS)return{code:i};if(e===D.AUDIO_VIDEO){const{code:e}=yield this.getCameraVideoTrack(t);e!==U.SUCCESS&&this._logger.warn(v.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P,`get camera video track error code: ${e}`,t)}return{code:U.SUCCESS}})}setVideoConfig(e){this._videoConfigIsChange=!0,this._videoConfig=e}setAudioConfig(e){this._audioConfigIsChange=!0,this._audioConfig=e}setAudioOutputDeviceId(e){return f(this,void 0,void 0,function*(){if("string"!=typeof e||0===e.length)return{code:U.PARAM_ERROR};if(this._audioOutputDeviceId===e)return{code:U.SUCCESS};if(this._audioOutputDeviceId=e,this._room){this._room.getRemoteTracks().filter(e=>e.isAudioTrack()).forEach(t=>{t.isSubscribed()&&t.play(void 0,{audioDeviceId:e})})}return{code:U.SUCCESS}})}destroyAllTracks(e){this._logger.info(v.L_RTC_MODULE_DESTROY_ALL_TRACKS_O,"",e),this._localTracks.forEach(e=>{e.destroy()}),this._localTracks.length=0}setAllRemoteAudioEnable(e,i){if(this._logger.info(v.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T,`enable: ${e}`,i),!t(e))return this._logger.error(v.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,`param error, enable: type is boolean, value: ${e}`),{code:U.PARAM_ERROR};if(this._remoteAudioEnable=e,!this._room)return{code:U.SUCCESS};return this._room.getRemoteTracks().filter(e=>e.isAudioTrack()).forEach(t=>{e?t.unmute():t.mute()}),this._logger.info(v.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,"success",i),{code:U.SUCCESS}}destroyTrack(e){return f(this,void 0,void 0,function*(){e.destroy();const t=this._localTracks.findIndex(t=>t.getTrackId()===e.getTrackId());this._localTracks.splice(t,1)})}sessionConnected(e,t){return f(this,void 0,void 0,function*(){if(this._preHangupCallId=null,this._logger.info(v.L_RTC_MODULE_SESSION_CONNECT_T,`callId: ${e}`,t),!this._room){const{code:i,room:_}=yield this.joinRTCRoom(e,t);if(i!==U.SUCCESS)return;if(this._room=_,this._preHangupCallId&&this._room.getRoomId()===this._preHangupCallId)return this._rtcClient.leaveRoom(this._room),void this._releaseStoredData();const r=this._room.getRemoteUserIds();this._onSelfJoined(e,r,t)}this._callId=e,this._regRTCListeners();let i=this._room.getRemoteTracks();if(i&&i.length&&this._onRemoteTrackPublish(i),this._localTracks.length>0){this.emit(Le.onBeforePublish);const e=this._isPubTiny?this._localTracks.map(e=>e.isVideoTrack()?{track:e,isPubTiny:!0}:e):this._localTracks,{code:i}=yield this.publish(e,t);this.emit(Le.onPublishRes,i)}else this._logger.warn(v.L_RTC_MODULE_SESSION_CONNECT_P,"sessionConnected local tracks is empty",t);this._logger.info(v.L_RTC_MODULE_SESSION_CONNECT_R,`code: ${U.SUCCESS}`,t)})}sessionClose(e,t){var i;return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_SESSION_CLOSE_T,`callId: ${e}`,t),this._preHangupCallId=e,this.destroyAllTracks(t);const _=null===(i=this._room)||void 0===i?void 0:i.getRoomId();if(this._room&&e===_){const{code:e}=yield this._rtcClient.leaveRoom(this._room);if(this._releaseStoredData(),e!==A.SUCCESS)return void this._logger.error(v.L_RTC_MODULE_SESSION_CLOSE_R,`leaveRoom failed, code: ${e}`,t);this._logger.info(v.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom success",t)}else this._logger.warn(v.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom throw exception: not in room",t)})}disableVideoTrack(){return f(this,void 0,void 0,function*(){const e=this.getLocalVideoTrack();if(!e)return{code:U.CAMERA_CLOSED};return{code:yield e.mute(),track:e}})}enableVideoTrack(e){return f(this,void 0,void 0,function*(){const e=this.getLocalVideoTrack();if(!e)return{code:U.CAMERA_CLOSED};if(!e.isOwnerMuted())return{code:U.SUCCESS};return{code:yield e.unmute()}})}changeVideoDevice(e){return f(this,void 0,void 0,function*(){const t=[],i=[],{code:_,track:r}=yield this._rtcClient.createCameraVideoTrack(fe.NORMAL,this._videoConfig);if(_!==A.SUCCESS)return{code:_};const{minBitrate:s,maxBitrate:o}=this._videoConfig;let n;if((s||o)&&r.setBitrate(o,s),this._localTracks&&this._localTracks.forEach(e=>{e.isVideoTrack()?(e.destroy(),n=e):i.push(e)}),this._localTracks=this._localTracks.filter(e=>n&&e.getTrackId()!==n.getTrackId()),t.push(r),i.push(r),this._localTracks=i,this._onLocalTrackReady(t,e),this._room){const{code:e}=yield this._room.publish(t);if(e!==A.SUCCESS)return{code:e}}return{code:U.SUCCESS,track:r}})}changeAudioDevice(e){return f(this,void 0,void 0,function*(){const t=[],i=[],_=Object.assign(Object.assign({},this._audioConfig),{micphoneId:this._audioConfig.microphoneId}),{code:r,track:s}=yield this._rtcClient.createMicrophoneAudioTrack(fe.NORMAL,_);if(r!==A.SUCCESS)return{code:r};if(this._localTracks&&this._localTracks.forEach(e=>{e.isAudioTrack()||i.push(e)}),t.push(s),i.push(s),this._localTracks=i,this._onLocalTrackReady(t,e),this._room){const{code:e}=yield this._room.publish(t);if(e!==A.SUCCESS)return{code:e}}return{code:U.SUCCESS}})}disableAudioTrack(){return f(this,void 0,void 0,function*(){const e=this.getLocalAudioTrack();if(!e)return{code:U.MICROPHONE_CLOSED};return{code:yield e.mute(),track:e}})}changeMediaType(e,t){return f(this,void 0,void 0,function*(){let i;this._logger.info(v.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T,`mediaType: ${e}`,t),i=e===D.AUDIO_VIDEO?yield this._upgradeMediaType(t):yield this._downgradeMediaType(t),i.code===U.SUCCESS&&this._logger.info(v.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"success",t)})}_upgradeMediaType(e){return f(this,void 0,void 0,function*(){let t=this.getLocalVideoTrack();if(!t){const{code:i,track:_}=yield this._createVideoTrack(e);if(i!==U.SUCCESS)return this._logger.error(v.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`create video track errCode: ${i}`,e),{code:i};t=_;const{minBitrate:r,maxBitrate:s}=this._videoConfig;(r||s)&&t.setBitrate(s,r)}const i=this._isPubTiny?{track:t,isPubTiny:!0}:t,{code:_}=yield this.publish([i],e);return _!==U.SUCCESS&&this._logger.error(v.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`publish errCode: ${_}`,e),{code:_}})}_downgradeMediaType(e){return f(this,void 0,void 0,function*(){const t=this.getLocalVideoTrack();if(t){const{code:i}=yield this._room.unpublish([t]);if(i!==A.SUCCESS)return this._logger.error(v.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`unpublish errCode: ${i}`,e),{code:i};this.destroyTrack(t)}return{code:U.SUCCESS}})}joinRTCRoom(e,t){return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_JOIN_RTC_ROOM_T,`call: ${e}`,t);const{code:i,room:_,tracks:r}=yield ce({asyncFn:this._rtcClient.joinRTCRoomWithOptions.bind(this._rtcClient),fnArgs:[e,{mode:C.CALL}]});return i!==A.SUCCESS?(this._logger.error(v.L_RTC_MODULE_JOIN_RTC_ROOM_R,`callId: ${e}, errCode: ${i}`,t),this._onRTCMethodFail(G.JOIN_ROOM_ERR,t),{code:i}):(this._logger.info(v.L_RTC_MODULE_JOIN_RTC_ROOM_R,"success",t),this._callId=e,{code:U.SUCCESS,room:_,tracks:r})})}subscribeTracks(e,t){return f(this,void 0,void 0,function*(){if(this._logger.info(v.L_RTC_MODULE_SUBSCRIBE_T,JSON.stringify({params:e.map(e=>{const{track:t,subTiny:i}=e;return{trackId:t.getTrackId(),subTiny:i}})}),t),!this._room)return{code:U.SUCCESS};const{code:i}=yield ce({asyncFn:this._room.subscribe.bind(this._room),fnArgs:[e],onError:e=>{}});return i!==A.SUCCESS?(this._reportAppEventModule.onFetchRemoteMediaError(e,i),this._onRTCMethodFail(G.SUBSCRIBE_ERR,t),this._logger.error(v.L_RTC_MODULE_SUBSCRIBE_R,`errorCode: ${i}`,t),{code:i}):(this._logger.info(v.L_RTC_MODULE_SUBSCRIBE_R,"success",t),{code:U.SUCCESS})})}unsubscribeTracks(e,t){return f(this,void 0,void 0,function*(){if(this._logger.info(v.L_RTC_MODULE_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map(e=>e.getTrackId())}),t),!this._room)return{code:U.SUCCESS};const{code:i}=yield this._room.unsubscribe(e);return i!==A.SUCCESS?(this._logger.error(v.L_RTC_MODULE_UNSUBSCRIBE_R,`errorCode: ${i}`,t),{code:i}):(this._logger.info(v.L_RTC_MODULE_UNSUBSCRIBE_R,"success",t),{code:U.SUCCESS})})}_releaseStoredData(){this._room=null,this._remoteAudioEnable=!0,this._userViewMap={},this._preHangupCallId=null}getRemoteTracks(){const e={};if(!this._room)return e;return this._room.getRemoteUserIds().forEach(t=>{e[t]=this._room.getRemoteTracksByUserId(t)}),e}getRemoteTrack(e,t){var i;return null===(i=this._room)||void 0===i?void 0:i.getRemoteTracksByUserId(e).find(e=>t===D.AUDIO?e.isAudioTrack():e.isVideoTrack())}getRTCSessionId(){return this._room?this._room.getSessionId():null}_regRTCListeners(){this._room.registerRoomEventListener({onKickOff:(e,t)=>{this._onKickOff(e,this._room.getRoomId(),t),this._releaseStoredData()},onUserJoin:e=>{const t=e.map(e=>({callId:this._callId,userId:e})),i=this._logger.createTraceId();this._onOtherMemJoined(t,i)},onUserLeave:e=>{e.forEach(e=>{delete this._userViewMap[e]})},onTrackPublish:this._onRemoteTrackPublish.bind(this),onTrackUnpublish:this._onTrackUnpublish.bind(this),onTrackReady:e=>{this._onRemoteTrackReady([e])},onVideoMuteChange:e=>{this._onVideoMuteChagne({fromUserId:e.getUserId(),muted:e.isOwnerMuted(),trackId:e.getTrackId()})},onAudioMuteChange:e=>{this._onAudioMuteChange({fromUserId:e.getUserId(),muted:e.isOwnerMuted(),trackId:e.getTrackId()})},onRTCPeerConnectionCloseByException:this._onRTCPeerConnectionCloseByException.bind(this)}),this._room.registerReportListener({onStateReport:this._onRTCStateReport.bind(this)}),this._room.onAudioLevelChange(e=>{this._reportAppEventModule.onUserAudioLevelChanged(e)})}_onLocalTrackReady(e,t){this._reportAppEventModule.onUserMediaAvailable(e,t)}_onRemoteTrackReady(e){this._reportAppEventModule.onUserMediaAvailable(e),this.emit(ve.__INNER_RECEIVE_FIRST_FRAME__)}_onKickOff(e,t,i,_){this._logger.info(v.L_RTC_MODULE_RECEIVE_KICK_OFF_O,`roonId: ${t}, byServer: ${e}, state: ${i}, kickExtra: ${JSON.stringify(_)}`);let r=G.CONNECTION_ERR;if(e)if(_)r=_.kickReasonCode;else switch(i){case N.SERVER_KICK:r=G.KICKED_BY_SERVER;break;case N.OTHER_KICK:r=G.OTHER_CLIENT_JOINED;break;case N.IM_DISCONNECTED:r=G.CONNECTION_ERR;break;case N.IM_LOGOUT:r=G.LOGOUT;break;case N.OTHER_CLIENT_IM_CONNECTED:r=G.OTHER_CLIENT_LOGIN}this.emit(ve.__INNER_ON_KICKOFF__,r,t)}_onRTCPeerConnectionCloseByException(){const e=this._logger.createTraceId();this._logger.info(v.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O,"",e),this.emit(ve.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,e)}_onSelfJoined(e,t,i){return f(this,void 0,void 0,function*(){this.emit(ve.__INNER_ON_SELF_JOINED__,e,t,i)})}_onRemoteTrackPublish(e){const t=this._logger.createTraceId();this._logger.info(v.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map(e=>e.getTrackId())}),t);const i=[];e.forEach(e=>{var t;const _=e.getUserId();if(e.isAudioTrack())i.push({track:e,subTiny:!1}),this._reportAppEventModule.onRemoteMicrophoneStateChanged(this._callId,e);else if(this._reportAppEventModule.onRemoteCameraStateChanged(this._callId,e),null===(t=this._userViewMap[_])||void 0===t?void 0:t.videoView){const{isTiny:t}=this._userViewMap[_];i.push({track:e,subTiny:t})}}),i.length&&this.subscribeTracks(i,t)}_onTrackUnpublish(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();this._logger.info(v.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map(e=>e.getTrackId())}),t),yield this.unsubscribeTracks(e,t)})}_onAudioMuteChange(e){const t=this._logger.createTraceId();this._logger.info(v.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);const i=this._room.getRemoteTrack(e.trackId);this._reportAppEventModule.onRemoteMicrophoneStateChanged(this._callId,i)}_onVideoMuteChagne(e){const t=this._logger.createTraceId();this._logger.info(v.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);const i=this._room.getRemoteTrack(e.trackId);this._reportAppEventModule.onRemoteCameraStateChanged(this._callId,i)}_onRTCStateReport(e){const{senders:t,receivers:i}=e;t.forEach(e=>{var t;const{kind:i,packetsLostRate:_,rtt:r}=e;this._callMediaType===D.AUDIO_VIDEO&&"audio"===i||null===(t=this._callPlusStatusReportListener)||void 0===t||t.onSendPacketLoss(_||0,r||0)}),i.forEach(e=>{var t;const{trackId:i,kind:_,packetsLostRate:r,bitrate:s}=e;if(this._callMediaType===D.AUDIO_VIDEO&&"audio"===_)return;const{userId:o}=O.parseTrackId(i),n={};n[o]={packetLostRate:r||0,bitRate:s},null===(t=this._callPlusStatusReportListener)||void 0===t||t.onReceivePacketLoss(n)})}_onRTCMethodFail(e,t){this.emit(ve.__INNER_RTC_PROCESS_FAILED__,e,t)}_onOtherMemJoined(e,t){this.emit(ve.__INNER_ON_OTHER_JOINED__,e,t)}_createAudioTrack(e){return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_CREATE_AUDIO_TRACK_T,"",e);const t=Object.assign(this._audioConfig,{micphoneId:this._audioConfig.microphoneId}),{code:i,track:_}=yield this._rtcClient.createMicrophoneAudioTrack(fe.NORMAL,t);if(i!==A.SUCCESS)return this._logger.error(v.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,`errCode: ${i}`,e),{code:i};this._logger.info(v.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,"success",e);const{minBitrate:r,maxBitrate:s}=this._audioConfig;return(r||s)&&_.setBitrate(s,r),this._localTracks.push(_),this._onLocalTrackReady([_],e),{code:U.SUCCESS,track:_}})}_createVideoTrack(e){return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_CREATE_VIDEO_TRACK_T,"",e);const{code:t,track:i}=yield this._rtcClient.createCameraVideoTrack(fe.NORMAL,this._videoConfig);if(t!==A.SUCCESS)return this._logger.error(v.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,`errCode: ${t}`,e),{code:t};this._logger.info(v.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,"success",e);const{minBitrate:_,maxBitrate:r}=this._videoConfig;return(_||r)&&i.setBitrate(r,_),this._localTracks.push(i),this._onLocalTrackReady([i],e),{code:U.SUCCESS,track:i}})}getLocalVideoTrack(){let e;return this._localTracks&&([e]=this._localTracks.filter(e=>e.isVideoTrack())),e}getLocalAudioTrack(){let e;return this._localTracks&&([e]=this._localTracks.filter(e=>e.isAudioTrack())),e}publish(e,t){return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_PUBLISH_T,`tracksIds: ${e.map(e=>e instanceof m?e.getTrackId():e.track.getTrackId())}`,t);const{code:i}=yield ce({asyncFn:this._room.publish.bind(this._room),fnArgs:[e],onError:e=>{}});return i!==A.SUCCESS?(this._onRTCMethodFail(G.PUBLISH_ERR,t),this._logger.error(v.L_RTC_MODULE_PUBLISH_R,`errCode: ${i}`,t),{code:i}):(this._logger.info(v.L_RTC_MODULE_PUBLISH_R,`code: ${U.SUCCESS}`,t),{code:U.SUCCESS})})}publishVideoTrack(){const e=this.getLocalVideoTrack(),t=this._isPubTiny?{track:e,isPubTiny:!0}:e;return this._room.publish([t])}setVideoView(e,t){const i=[];e.forEach(e=>{const{userId:t,videoElement:_,isTiny:r=!1}=e;if(this._userViewMap[t]={videoView:_,isTiny:r},t===this._context.getCurrentId())return;if(!this._room)return;const s=(this.getRemoteTracks()[t]||[]).map(e=>({track:e,subTiny:r}));i.push(...s)}),this._logger.info(v.L_RTC_MODULE_SET_VIDEO_VIEW_O,JSON.stringify({userViewMap:j(this._userViewMap),needSubTrackIds:i.map(({track:e})=>e.getTrackId())}),t),i.length&&this.subscribeTracks(i,t)}removeVideoView(e,t){const i=[];e.forEach(e=>{const t=this.getRemoteTracks()[e];if(t&&t.length){const e=t.filter(e=>e.isVideoTrack());e.length&&i.push(e[0])}delete this._userViewMap[e]}),this._logger.info(v.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O,JSON.stringify({userViewMap:j(this._userViewMap),unsubTracks:i.map(e=>e.getTrackId())}),t),i.length&&this.unsubscribeTracks(i,t)}getUserViewMap(){return this._userViewMap}playMedia(e,t,i,_){var r;return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_PLAY_MEDIA_T,`userId: ${e}, mediaType: ${t}, videoView: ${null==i?void 0:i.nodeName}`,_);const s=this._context.getCurrentId();if(e===s&&t===D.AUDIO)return this._logger.error(v.L_RTC_MODULE_PLAY_MEDIA_R,"please avoid playing local audio to prevent echoes.",_),{code:U.PLAY_MEDIA_FAILED};let o=null;if(o=e===s?t===D.AUDIO?null:this.getLocalVideoTrack():null===(r=this.getRemoteTracks()[e])||void 0===r?void 0:r.filter(e=>t===D.AUDIO?e.isAudioTrack():e.isVideoTrack())[0],!o)return this._logger.error(v.L_RTC_MODULE_PLAY_MEDIA_R,`error code: ${U.MEDIA_RESOURCE_INVALIED}`,_),{code:U.MEDIA_RESOURCE_INVALIED};try{const{code:e}=o.isAudioTrack()?yield o.play(void 0,{audioDeviceId:this._audioOutputDeviceId||void 0}):yield o.play(i);return o.isAudioTrack()&&!this._remoteAudioEnable&&o.mute(),e!==A.SUCCESS?(this._logger.error(v.L_RTC_MODULE_PLAY_MEDIA_R,`errCode: ${e}`,_),{code:e}):(this._logger.info(v.L_RTC_MODULE_PLAY_MEDIA_R,"success",_),{code:U.SUCCESS})}catch(e){return this._logger.error(v.L_RTC_MODULE_PLAY_MEDIA_R,`errCode: ${U.PLAY_MEDIA_FAILED}, message: ${e.message},`,_),{code:U.PLAY_MEDIA_FAILED}}})}}Object.defineProperty(ve,"__INNER_RTC_PROCESS_FAILED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-process-failed"}),Object.defineProperty(ve,"__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-peerconnection-abnormal-close"}),Object.defineProperty(ve,"__INNER_ON_SELF_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-self-joined"}),Object.defineProperty(ve,"__INNER_ON_OTHER_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-other-joined"}),Object.defineProperty(ve,"__INNER_RECEIVE_FIRST_FRAME__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-receive-first-frame"}),Object.defineProperty(ve,"__INNER_ON_KICKOFF__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-kickoff-frame"});class Me{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}registerEventListener(e){this._listener=e}_callAppListener(e,...t){var i;return f(this,void 0,void 0,function*(){const _=null===(i=this._listener)||void 0===i?void 0:i[e];if(_)try{yield _(...t)}catch(e){console.error(e),this._logger.error(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({name:e.name,message:e.message}))}})}onReceivedCall(e,t,i){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCall",callId:e.getCallId()}),t),this._callAppListener("onReceivedCall",e,i)}onRemoteUserInvited(e,t,i){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserInvited",inviteeUserList:e,inviterUserId:t,callId:i})),this._callAppListener("onRemoteUserInvited",e,t,i)}onCallConnected(e){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallConnected",callId:e.getCallId()})),this._callAppListener("onCallConnected",e)}onCallTypeChanged(e,t,i){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallTypeChanged",callId:t,callType:e}),i),this._callAppListener("onCallTypeChanged",e,t)}onRemoteUserStateChanged(e,t){const{callId:i,userId:_,userState:r,reason:s}=e;this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserStateChanged",callId:i,userId:_,userState:r,reason:s}),t),this._callAppListener("onRemoteUserStateChanged",i,_,r,s)}onCallEnded(e,t,i){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallEnded",callId:e.getCallId(),closeReason:t}),i),this._callAppListener("onCallEnded",e,t)}onRemoteCameraStateChanged(e,t){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteCameraStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));const i=null==t?void 0:t.getUserId();this._callAppListener("onRemoteCameraStateChanged",e,i,null==t?void 0:t.isOwnerMuted())}onRemoteMicrophoneStateChanged(e,t){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteMicrophoneStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));const i=null==t?void 0:t.getUserId();this._callAppListener("onRemoteMicrophoneStateChanged",e,i,null==t?void 0:t.isOwnerMuted())}onReceivedCallRecord(e,t){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallRecord",record:e}),t),this._callAppListener("onReceivedCallRecord",e)}onReceivedChangeMediaTypeRequest(e,t,i,_){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeRequest",userId:e,transactionId:t}),_),this._callAppListener("onReceivedChangeMediaTypeRequest",e,t,i)}onReceivedChangeMediaTypeResult(e,t){const{userId:i,transactionId:_,mediaType:r,code:s}=e;this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeResult",userId:i,mediaType:r}),t),this._callAppListener("onReceivedChangeMediaTypeResult",{userId:i,transactionId:_,mediaType:r,code:s})}onReceivedCallStartTime(e,t){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallStartTime",info:e}),t),this._callAppListener("onReceivedCallStartTime",e)}onReceivedCallFirstFrameTime(e,t,i){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallFirstFrameTime",callId:e,callFirstFrameTime:t}),i),this._callAppListener("onReceivedCallFirstFrameTime",e,t)}onUserMediaAvailable(e,t){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onUserMediaAvailable",trackIds:e.map(e=>e.getTrackId())}),t),e.forEach(e=>{const t=e.getUserId(),i=e.isAudioTrack()?D.AUDIO:D.VIDEO;this._callAppListener("onUserMediaAvailable",t,i)})}onFetchRemoteMediaError(e,t){e.forEach(({track:e})=>{const i=e.getUserId();this._callAppListener("onFetchRemoteMediaError",i,t)})}onUserAudioLevelChanged(e){e.forEach(({track:e,audioLevel:t})=>{const i=e.getUserId();this._callAppListener("onUserAudioLevelChanged",i,t)})}onReceivedCallPlusSummaryMessage(e){this._callAppListener("onReceivedCallPlusSummaryMessage",e)}onReceivedGroupCallStatusMessage(e){this._callAppListener("onReceivedGroupCallStatusMessage",e)}}!function(e){e[e.UNKNOW_ERR=41e3]="UNKNOW_ERR",e[e.DB_ERR=41001]="DB_ERR",e[e.JSON_ERR=41002]="JSON_ERR",e[e.INVALID_JSON_ERR=41003]="INVALID_JSON_ERR",e[e.MISSING_PARAMS=41004]="MISSING_PARAMS",e[e.PARAMS_REQUIRED=41005]="PARAMS_REQUIRED",e[e.DATA_FORMAT_ERR=41006]="DATA_FORMAT_ERR",e[e.METHOD_NOT_IMPLEMENTED=41007]="METHOD_NOT_IMPLEMENTED",e[e.CALL_NOT_EXIST=41010]="CALL_NOT_EXIST",e[e.SINGAL_EXCEED_TWO_INVITEE=41011]="SINGAL_EXCEED_TWO_INVITEE",e[e.GROUP_EXCEEDS_QUORUM=41012]="GROUP_EXCEEDS_QUORUM",e[e.OPERATION_EXPIRED=41013]="OPERATION_EXPIRED",e[e.DEVICE_IS_CALLING=41014]="DEVICE_IS_CALLING",e[e.REPORT_STREAM_READY_TIME_IS_INVALID=41018]="REPORT_STREAM_READY_TIME_IS_INVALID",e[e.NOT_CALL_YOURSELF=41019]="NOT_CALL_YOURSELF",e[e.SESSION_STATUS_NOT_EXIST=41020]="SESSION_STATUS_NOT_EXIST",e[e.HANGUP_NOT_ALLOW=41021]="HANGUP_NOT_ALLOW",e[e.ACCEPT_NOT_ALLOW=41022]="ACCEPT_NOT_ALLOW",e[e.OPERATION_NOT_ALLOW=41025]="OPERATION_NOT_ALLOW",e[e.TRANSACTION_ID_ERR=41100]="TRANSACTION_ID_ERR",e[e.UP_VIDEO_CANCELED=41050]="UP_VIDEO_CANCELED",e[e.CURRENT_CALL_IS_AUDIO=41051]="CURRENT_CALL_IS_AUDIO",e[e.CURRENT_CALL_IS_VIDEO=41052]="CURRENT_CALL_IS_VIDEO"}(Ue||(Ue={}));class Pe{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_androidPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}setChannelIdMi(e){return _(e)?(this._androidPushConfig.channelIdMi=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdMi type is string, value: ${e}`),this)}setTemplateIdMi(e){return _(e)?(this._androidPushConfig.templateIdMi=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: templateIdMi type is string, value: ${e}`),this)}setTemplateParamMi(e){if(!e||"object"!=typeof e||Array.isArray(e))return this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: templateParamMi type is object, value: ${JSON.stringify(e)}`),this;const t=Object.keys(e).find(t=>!_(t)||!_(e[t]));return void 0!==t?(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: templateParamMi.${t} key and value type is string, value: ${JSON.stringify(e)}`),this):(this._androidPushConfig.templateParamMi=Object.assign({},e),this)}setMiLargeIconUrl(e){return this._logger.warn(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"`setMiLargeIconUrl` has been deprecated."),this}setChannelIdHW(e){return _(e)?(this._androidPushConfig.channelIdHW=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdHW type is string, value: ${e}`),this)}setCategoryHW(e){return _(e)?(this._androidPushConfig.categoryHW=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: categoryHW type is string, value: ${e}`),this)}setImportanceHW(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: importanceHW value is NORMAL|LOW, value: ${e}`),this):(this._androidPushConfig.importanceHW=e,this)}setImageUrlHW(e){return _(e)?(this._androidPushConfig.imageUrlHW=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: imageUrlHW type is string, value: ${e}`),this)}setChannelIdOPPO(e){return _(e)?(this._androidPushConfig.channelIdOPPO=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdOPPO type is string, value: ${e}`),this)}setTypeVivo(e){return _(e)?(this._androidPushConfig.typeVivo=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: typeVivo type is string, value: ${e}`),this)}setCategoryVivo(e){return _(e)?(this._androidPushConfig.categoryVivo=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: categoryVivo type is string, value: ${e}`),this)}setFcmChannelId(e){return _(e)?(this._androidPushConfig.fcmChannelId=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmChannelId type is string, value: ${e}`),this)}setFcmCollapseKey(e){return _(e)?(this._androidPushConfig.fcmCollapseKey=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmCollapseKey type is string, value: ${e}`),this)}setFcmImageUrl(e){return _(e)?(this._androidPushConfig.fcmImageUrl=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmImageUrl type is string, value: ${e}`),this)}setimportanceHonor(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: importanceHonor value is NORMAL|LOW, value: ${e}`),this):(this._androidPushConfig.importanceHonor=e,this)}setimageUrlHonor(e){return _(e)?(this._androidPushConfig.imageUrlHonor=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: imageUrlHonor type is string, value: ${e}`),this)}build(){const e=Object.assign({},this._androidPushConfig);return e.templateParamMi&&(e.templateParamMi=Object.assign({},e.templateParamMi)),e}}class De{constructor(e,t,i,_){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:h.W640_H480,frameRate:R.FPS_15}}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_callPlusStatistics",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_isLaunchHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_needHangupCallId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._context.registerMessageType("RC:CallPlusMiss",!0,!1,[]),this._reportAppEventModule=new Me(t),this._callPlusStatistics=new oe(this._logger,this._context),this._callEngine=new pe(this._context,this._runtime,this._initOpts,this._logger,this._reportAppEventModule),this._rtcModule=new ve(this._context,this._runtime,this._initOpts,this._logger,this._callEngine,this._reportAppEventModule),this._callEngine.setRTCModule(this._rtcModule),this._rtcModule.on(ve.__INNER_RTC_PROCESS_FAILED__,this._rtcProcessFailHandle.bind(this)),this._rtcModule.on(ve.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,this._peerConnectionAbnormalClose.bind(this)),this._rtcModule.on(ve.__INNER_ON_SELF_JOINED__,this._selfJoinedHandle.bind(this)),this._rtcModule.on(ve.__INNER_ON_OTHER_JOINED__,this._otherJoinedHandle.bind(this)),this._rtcModule.on(ve.__INNER_RECEIVE_FIRST_FRAME__,this._receiveFirstFrameHandle.bind(this)),this._rtcModule.on(ve.__INNER_ON_KICKOFF__,this._kickoffHandle.bind(this)),this._callEngine.on(pe.__INNER_SESSION_CONNECT__,this._rtcModule.sessionConnected.bind(this._rtcModule)),this._callEngine.on(pe.__INNER_SESSION_CLOSE__,this._sessionCloseHandle.bind(this)),this._callEngine.on(pe.__INNER_CHANGE_MEDIA_TYPE__,this._rtcModule.changeMediaType.bind(this._rtcModule)),this._callEngine.on(pe.__INNER_INVITE__,(e,t)=>{this._callPlusStatistics.reportStatisticsData(ee.L_QS_RECEIVE_CALL_S,U.SUCCESS,+new Date,e,"",t)})}_rtcProcessFailHandle(e,t){const i=this._callEngine.getLocalMainSession();if(i){const _=i.getCallId();this._callEngine.systemStatusUp({callId:_,sysStatus:e,forward:Ae.CURRENT},t),this._callPlusStatistics.reportStatisticsData(ee.L_QS_ABNORMAL_HANGUP_S,U.SUCCESS,+new Date,i),this.__innerHangup({callId:_,systemState:e},t)}}_peerConnectionAbnormalClose(e){const t=this._callEngine.getLocalMainSession();t&&(this._callEngine.systemStatusUp({callId:t.getCallId(),sysStatus:G.CONNECTION_ERR,forward:Ae.CURRENT},e),this._callEngine.endCurrentSession(G.CONNECTION_ERR,t.getCallId(),e))}_selfJoinedHandle(e,t,i){return f(this,void 0,void 0,function*(){const _=this._context.getCurrentId(),r=this._callEngine.getLocalMainSession();((null==r?void 0:r.getCallType())===M.MULTI||t.length)&&this._callEngine.updateMainSessionState(y.ONCALL);const s=[_,...t].map(e=>({userId:e,userState:P.ONCALL,systemState:G.ONCALL})),o=this._callEngine.updateUsersState(e,s,i);this._reportAppEventModule.onCallConnected(r),o.length>0&&this._callEngine.reportRemoteUserStateChange(e,o,i),this._callEngine.startTimeCorrection(i)})}_otherJoinedHandle(e,t){var i;let _="";const r=e.map(e=>(_=e.callId,{userId:e.userId,userState:P.ONCALL,systemState:G.ONCALL})),s=this._callEngine.updateUsersState(_,r,t);s.length>0&&this._callEngine.reportRemoteUserStateChange(_,s,t),(null===(i=this._callEngine.getLocalMainSession())||void 0===i?void 0:i.getState())!==y.ONCALL&&this._callEngine.updateMainSessionState(y.ONCALL)}_receiveFirstFrameHandle(e){var t;(null===(t=this._callEngine.getLocalMainSession())||void 0===t?void 0:t.getState())!==y.ONCALL&&this._callEngine.updateMainSessionState(y.ONCALL),this._callEngine.upFirstFrameTime(e)}_kickoffHandle(e,t,i){if(e===G.CONNECTION_ERR)return void this._callEngine.endCurrentSession(e,t,i);const _=this._callEngine.getLocalMainSession();if(_){const r=_.getCallId();this._callPlusStatistics.reportStatisticsData(ee.L_QS_ABNORMAL_HANGUP_S,U.SUCCESS,+new Date,_,this._clientCallId),this._callEngine.systemStatusUp({callId:r,sysStatus:e,forward:Ae.CURRENT},i),this._callEngine.endCurrentSession(e,t,i)}}_sessionCloseHandle(e,t){this._isLaunchHangup||(this._clientCallId=""),this._isLaunchHangup=!1,this._rtcModule.sessionClose(e,t)}setCallPlusEventListener(e){this._logger.info(v.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._reportAppEventModule.registerEventListener(e)}setStatusReportListener(e){this._logger.info(v.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._rtcModule.setCallPlusStatusReportListener(e)}setVideoView(e){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T,JSON.stringify({list:e.map(e=>{const{userId:t,videoElement:i,isTiny:_}=e;return{userId:t,elementName:null==i?void 0:i.nodeName,isTiny:_}})}),t),!T(e))return this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, list: not empty array, value: ${JSON.stringify(e)}`,t),{code:U.PARAM_ERROR};for(const i of e){const{userId:e,videoElement:_}=i;if(!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, userId: not empty string, value: ${e}`,t),{code:U.PARAM_ERROR};if(!B(_))return this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, videoElement: need a video element, value: ${_ instanceof HTMLElement?_.nodeName:_}`,t),{code:U.PARAM_ERROR}}return this._logger.info(v.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"succes",t),this._rtcModule.setVideoView(e,t),{code:U.SUCCESS}}removeVideoView(e){const t=this._logger.createTraceId();return this._logger.info(v.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T,JSON.stringify({userIds:e}),t),T(e)&&e.every(e=>I(e))?(this._logger.info(v.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,"succes",t),this._rtcModule.removeVideoView(e,t),{code:U.SUCCESS}):(this._logger.error(v.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(e)}`,t),{code:U.PARAM_ERROR})}playMedia(e,t){return f(this,void 0,void 0,function*(){const _=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_PLAY_MEDIA_T,JSON.stringify({userId:e,mediaType:t}),_),!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`params err, userId: not empty string, value: ${e}`,_),{code:U.PARAM_ERROR};if(i(D[t]))return this._logger.error(v.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`params err, mediaType is illegal, value: ${t}`,_),{code:U.PARAM_ERROR};if(t===D.AUDIO&&e===this._context.getCurrentId())return this._logger.info(v.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"success",_),{code:U.SUCCESS};const{videoView:r}=this._rtcModule.getUserViewMap()[e]||{};return t===D.AUDIO||r?this._rtcModule.playMedia(e,t,r,_):(this._logger.error(v.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`errCode: ${U.VIDEO_VIEW_NOT_SET}, video view not set`,_),{code:U.VIDEO_VIEW_NOT_SET})})}createVideoConfigBuilder(){return new k(this._logger)}setVideoConfig(e){this._logger.info(v.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T,JSON.stringify(e));const{frameRate:t,resolution:i,maxBitrate:_,minBitrate:r}=e;if(!R[t])return this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,`param error, frameRate is illegal, value: ${t}`),{code:U.PARAM_ERROR};if(!h[i])return this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,`param error, resolution is illegal, value: ${i}`),{code:U.PARAM_ERROR};const{code:s,errorMsg:o}=F(r,_);return s!==U.SUCCESS&&this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,o),this._logger.info(v.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"success"),this._videoConfig=Object.assign({},e),this._rtcModule.setVideoConfig(this._videoConfig),{code:U.SUCCESS}}createAudioConfigBuilder(){return new w(this._logger)}createAndroidPushConfigBuilder(){return new Pe(this._logger)}setAudioConfig(t){this._logger.info(v.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T,JSON.stringify(t));const{sampleRate:i,minBitrate:_,maxBitrate:r}=t;if(i&&!e(i))return this._logger.error(v.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,`param error, sampleRate: type is number, value: ${i}`),{code:U.PARAM_ERROR};const{code:s,errorMsg:o}=F(_,r);return s!==U.SUCCESS&&this._logger.error(v.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,o),this._logger.info(v.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,"success"),this._audioConfig=Object.assign({},t),this._rtcModule.setAudioConfig(this._audioConfig),{code:U.SUCCESS}}setAudioOutputDeviceId(e){return this._logger.info(v.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O,e),this._rtcModule.setAudioOutputDeviceId(e)}startCall(e,t=M.SINGLE,r=D.AUDIO_VIDEO,s,o,n){return f(this,void 0,void 0,function*(){this._clientCallId=c();const a=+new Date,L=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_START_CALL_T,`userIds: ${e.join(",")}, callType: ${t}, mediaType: ${r}, pushConfig: ${JSON.stringify(s)}, extra: ${o}`,L),this._context.getConnectionStatus()!==l.CONNECTED)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${U.SIGNAL_DISCONNECTED}`,L),{code:U.SIGNAL_DISCONNECTED};const E=this._context.getNaviInfo();if(!E||!x(E))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${U.RTC_SERVICE_UNAVAILABLE}`,L),{code:U.RTC_SERVICE_UNAVAILABLE};if(!T(e)||!e.every(e=>I(e)))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(e)}`,L),{code:U.PARAM_ERROR};if(i(M[t]))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, callType is illegal, value: ${t}`,L),{code:U.PARAM_ERROR};if(i(D[r]))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, mediaType is illegal, value: ${r}`,L),{code:U.PARAM_ERROR};if(s){const e=W(s);if(e.code!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,L),{code:U.PARAM_ERROR}}if(o){if(!_(o))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, extra is illegal, type: string, value: ${o}`,L),{code:U.PARAM_ERROR};if(q(o)>Ce)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,"params err, extra max size is 128KB",L),{code:U.PARAM_ERROR}}if(e.length>1&&t===M.SINGLE)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, You can only call one person in a single call, userIds: ${e.join(",")}`,L),{code:U.PARAM_ERROR};if(n&&!_(n))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, targetId is illegal, type: string, value: ${n}`,L),{code:U.PARAM_ERROR};if(this._callEngine.getLocalMainSession())return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${U.SESSION_EXIST}, session exist`,L),{code:U.SESSION_EXIST};const{code:d}=yield this._rtcModule.createCallMediaTracks(r,L);if(d!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`create meida tracks error code: ${d}`,L),{code:d};const{code:C,data:S}=yield this._callEngine.startCall({toUsers:e.map(e=>({userId:e})),callType:t,mediaType:r,callId:this._clientCallId,pushConfig:s,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:o}),targetId:n},L);if(this._callPlusStatistics.reportStatisticsData(ee.L_QS_START_CALL_S,C,a,null,this._clientCallId,null,{mediaType:r,callType:t,callId:(null==S?void 0:S.callId)||""}),C!==U.SUCCESS)return this._rtcModule.destroyAllTracks(L),this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`signal error code: ${C}`,L),{code:C};const{callId:u,clientCallId:g}=S;return this._needHangupCallId===g?(this._callEngine.clearAllTimer(u,L),this._callEngine.hangup({callId:u,systemState:G.CANCELLED},L),this._logger.info(v.L_CALLPLUS_CLIENT_START_CALL_R,`the ${u} call has been hangup`,L),{code:U.SUCCESS}):(t===M.MULTI&&this._rtcModule.sessionConnected(u,L),this._logger.info(v.L_CALLPLUS_CLIENT_START_CALL_R,JSON.stringify({data:S,code:C}),L),{code:U.SUCCESS,callId:u})})}joinMultiCall(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T,`callId: ${e}`,t),this._context.getConnectionStatus()!==l.CONNECTED)return this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${U.SIGNAL_DISCONNECTED}`,t),{code:U.SIGNAL_DISCONNECTED};const i=this._context.getNaviInfo();if(!i||!x(i))return this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${U.RTC_SERVICE_UNAVAILABLE}`,t),{code:U.RTC_SERVICE_UNAVAILABLE};if(!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`params err, callId: not empty string, value: ${e}`,t),{code:U.PARAM_ERROR};const{code:_,data:r}=yield this._callEngine.getCallSession({callId:e},t);if(_!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`get call data error, code: ${_}`,t),{code:_};const{mediaType:s}=r,o=this._callEngine.getLocalMainSession();if(o&&o.getCallId()!==e)return{code:U.SESSION_EXIST};const{code:n}=yield this._rtcModule.createCallMediaTracks(s,t);if(n!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`create meida tracks error code: ${n}`,t),{code:n};const{code:a}=yield this._callEngine.joinCall({callId:e,mediaType:s},t);return a!==U.SUCCESS?(this._rtcModule.destroyAllTracks(t),this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`signal error code: ${a}`,t),{code:a}):(this._logger.info(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${U.SUCCESS}`,t),yield this._rtcModule.sessionConnected(e,t),{code:U.SUCCESS})})}invite(e,t,i){var r;return f(this,void 0,void 0,function*(){const s=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_INVITE_T,`callId: ${e.join(",")}, pushConfig: ${t}, extra: ${i}`,s),!T(e)||!e.every(e=>I(e)))return this._logger.error(v.L_CALLPLUS_CLIENT_INVITE_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(e)}`,s),{code:U.PARAM_ERROR};if(t){const e=W(t);if(e.code!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_INVITE_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,s),{code:U.PARAM_ERROR}}if(i){if(!_(i))return this._logger.error(v.L_CALLPLUS_CLIENT_INVITE_R,`params err, extra is illegal, value: ${i}`,s),{code:U.PARAM_ERROR};if(q(i)>Ce)return this._logger.error(v.L_CALLPLUS_CLIENT_INVITE_R,"params err, extra max size is 128KB",s),{code:U.PARAM_ERROR}}const{code:o,data:n}=yield this._callEngine.invite({toUsers:e.map(e=>({userId:e})),pushConfig:t,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:i})},s);if(o!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_INVITE_R,`signal error code: ${o}`,s),{code:o};const l=[];return(null===(r=n.busylineUsers)||void 0===r?void 0:r.length)&&l.push(...n.busylineUsers.map(e=>({userId:e.userId,state:e.sessionStatus}))),this._logger.info(v.L_CALLPLUS_CLIENT_INVITE_R,`success busyUsers: ${JSON.stringify(l)}`,s),{code:U.SUCCESS,busyUsers:l}})}accept(e,t){return f(this,void 0,void 0,function*(){const i=+new Date,_=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_ACCEPT_T,`callId: ${e}, pushConfig: ${t}`,_),this._context.getConnectionStatus()!==l.CONNECTED)return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode: ${U.SIGNAL_DISCONNECTED}`,_),{code:U.SIGNAL_DISCONNECTED};const r=this._context.getNaviInfo();if(!r||!x(r))return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode: ${U.RTC_SERVICE_UNAVAILABLE}`,_),{code:U.RTC_SERVICE_UNAVAILABLE};if(!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`params err, callId: not empty string, value: ${e}`,_),{code:U.PARAM_ERROR};if(t){const e=W(t);if(e.code!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,_),{code:U.PARAM_ERROR}}let s=this._callEngine.getLocalMainSession();const o=this._callEngine.getHoldSession(e);if(!s&&!o)return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode : ${U.NOT_IN_CALL}, session not exist`,_),{code:U.NOT_IN_CALL};if(e===(null==o?void 0:o.getCallId())){const{code:t}=yield this.hangup(s.getCallId());if(t!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`hangup mainSession error code: ${t}`,_),{code:t};this._callEngine.upgradeMainSession(e),s=this._callEngine.getLocalMainSession()}const n=s.getMediaType(),{code:a}=yield this._rtcModule.createCallMediaTracks(n,_);if(a!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`create meida tracks error code: ${a}`,_),{code:a};const{code:c}=yield this._callEngine.accept({callId:e},_);return this._callPlusStatistics.reportStatisticsData(ee.L_QS_ACCEPT_CALL_S,c,i,s),c!==U.SUCCESS?(this._rtcModule.destroyAllTracks(_),this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`signal error code: ${c}`,_),{code:c}):(this._logger.info(v.L_CALLPLUS_CLIENT_ACCEPT_R,"success",_),this._rtcModule.sessionConnected(e,_),{code:U.SUCCESS})})}__innerHangup(e,t){var i;return f(this,void 0,void 0,function*(){const{callId:_}=e;this._callEngine.setIsLocalClientHangup(!0),this._callEngine.clearAllTimer(_,t);const{code:r}=yield this._callEngine.hangup(e,t);return r===Ue.CALL_NOT_EXIST?{code:U.SUCCESS}:(r===U.SUCCESS&&_===(null===(i=this._callEngine.getLocalMainSession())||void 0===i?void 0:i.getCallId())&&(yield this._rtcModule.sessionClose(_,t)),{code:r})})}hangup(e,t){return f(this,void 0,void 0,function*(){const i=+new Date,r=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_HANGUP_T,`callId: ${e}, pushConfig: ${JSON.stringify(t)}`,r);const s=this._callEngine.getLocalMainSession();if(!s)return{code:U.NOT_IN_CALL};if(e&&!_(e))return this._logger.error(v.L_CALLPLUS_CLIENT_HANGUP_R,`params err, callId: type is string, value: ${e}`,r),{code:U.PARAM_ERROR};if(t){const e=W(t);if(e.code!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_HANGUP_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,r),{code:U.PARAM_ERROR}}const o=s.getCallId();if(e&&e!==o&&!this._callEngine.getHoldSession(e))return this._logger.error(v.L_CALLPLUS_CLIENT_HANGUP_R,`params err, callId is invalid, value: ${e}`,r),{code:U.CALL_ID_INVALID};this._isLaunchHangup=!0,this._needHangupCallId=e||o;const n=this._callEngine.getHoldSession(this._needHangupCallId)||s,l=this._context.getCurrentId(),a=((e,t)=>{let i;switch(e){case P.CALLING:i=G.CANCELLED;break;case P.RINGING:case P.INVITED:i=G.DECLINED;break;case P.CONNECTING:i=t?G.DECLINED:G.CANCELLED;break;case P.ONCALL:i=G.ENDED}return i})(s.getUserList().filter(e=>e.userId===l)[0].state,[s.getCreatorUserId(),s.getInviterUserId()].includes(l))||G.ENDED,{code:c}=yield this.__innerHangup({callId:this._needHangupCallId,systemState:a,pushConfig:t},r);return this._callPlusStatistics.reportStatisticsData(ee.L_QS_HANGUP_CALL_S,c,i,n,this._clientCallId),c!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_HANGUP_R,`signal error code : ${c}`,r),{code:c}):(this._needHangupCallId=null,this._logger.info(v.L_CALLPLUS_CLIENT_HANGUP_R,"success",r),{code:U.SUCCESS})})}requestChangeMediaType(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T,`mediaType: ${e}`,t),i(D[e]))return this._logger.error(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`params err, mediaType is illegal, value: ${e}`,t),{code:U.PARAM_ERROR};const _=this.getCurrentCallSession(),r=null==_?void 0:_.getMediaType();if(e===r)return this._logger.error(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`error code: ${U.MEDIATYPE_INVALID}`,t),{code:U.MEDIATYPE_INVALID};if(!this._callEngine.getLocalMainSession())return this._logger.error(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`error code : ${U.NOT_IN_CALL}, session not exist`,t),{code:U.NOT_IN_CALL};const s=null==_?void 0:_.getUserList().filter(e=>e.userId!==this._context.getCurrentId()).map(e=>e.userId),{code:o,data:n}=yield this._callEngine.requestChangeMediaType({mediaType:e,toUserIds:s||[]},t);return o!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`signal error code: ${o}`,t),{code:o}):(this._logger.info(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`success transactionId: ${n.transactionId}`,t),{code:U.SUCCESS,transactionId:n.transactionId})})}cancelChangeMediaType(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T,`transactionId: ${e}`,t),!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`param error, transactionId: not empty string, value: ${e}`,t),{code:U.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(v.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`error code : ${U.NOT_IN_CALL}, session not exist`,t),{code:U.NOT_IN_CALL};const{code:i}=yield this._callEngine.cancelChangeMediaType({transactionId:e},t);return i!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`signal error code: ${i}`,t),{code:i}):(this._logger.info(v.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"success",t),{code:U.SUCCESS})})}replyChangeMediaType(e,i){return f(this,void 0,void 0,function*(){const _=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T,`transactionId: ${e}`,_),!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`param error, transactionId: not empty string, value: ${e}`,_),{code:U.PARAM_ERROR};if(!t(i))return this._logger.error(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`param error, isAgree: type is boolean, value: ${i}`,_),{code:U.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`error code : ${U.NOT_IN_CALL}, session not exist`,_),{code:U.NOT_IN_CALL};const{code:r}=yield this._callEngine.responseChangeMediaType({transactionId:e,agree:i},_);return r!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`signal error: ${r}`,_),{code:r}):(this._logger.info(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"success",_),{code:U.SUCCESS})})}getCurrentCallSession(){return this._callEngine.getLocalMainSession()}getAvailableCallRecordsFromServer(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T,"",e);const{code:t,data:i}=yield this._callEngine.getOpenCallList(e);return t!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(v.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,`success, data: ${JSON.stringify(i)}`,e),{code:U.SUCCESS,records:i})})}getCallRecords(t,i,_=0){return f(this,void 0,void 0,function*(){const r=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T,`startTimestamp: ${t}, count: ${i}`,r),!(e(t)&&t>=0))return this._logger.error(v.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`params error, startTimestamp: is a number >= 0, value: ${t}`,r),{code:U.PARAM_ERROR};if(!(e(i)&&i>0))return this._logger.error(v.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`params error, count: is a number >= 0, value: ${i}`,r),{code:U.PARAM_ERROR};const{code:s,data:o}=yield this._callEngine.getCallLogList({timestamp:t,count:i,order:_},r);return s!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`signal error code: ${s}`,r),{code:s}):(this._logger.info(v.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"success",r),{code:U.SUCCESS,result:o})})}deleteCallRecordsFromServer(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T,`callIds: ${e.join(",")}`,t),!T(e)||!e.every(e=>I(e)))return this._logger.error(v.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,`params err, callIds: not empty array, callId: not empty string, callIds: ${JSON.stringify(e)}`,t),{code:U.PARAM_ERROR};const{code:i}=yield this._callEngine.deleteCallLog(e,t);return i!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,`signal error code: ${i}`,t),{code:i}):(this._logger.info(v.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"success",t),{code:U.SUCCESS})})}deleteAllCallRecordsFromServer(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T,"",e);const{code:t}=yield this._callEngine.removeAllCallLog(e);return t!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(v.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,"success",e),{code:U.SUCCESS})})}startCamera(){var e;return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_START_CAMERA_T,"",t);const{code:i,track:_}=yield this._rtcModule.getCameraVideoTrack(t);if(i!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CAMERA_R,`create video track error code: ${i}`,t),{code:i};if(!(null==_?void 0:_.isPublished())&&(null===(e=this._callEngine.getLocalMainSession())||void 0===e?void 0:e.getState())===y.ONCALL){const{code:e}=yield this._rtcModule.publishVideoTrack();return e!==A.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_START_CAMERA_R,`publish error code: ${e}`,t),{code:e}):(this._logger.info(v.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),{code:U.SUCCESS})}const{code:r}=yield this._rtcModule.enableVideoTrack(t);return r!==A.SUCCESS&&r!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_START_CAMERA_R,`signal error code: ${r}`,t),{code:r}):(this._logger.info(v.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),{code:U.SUCCESS})})}stopCamera(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_STOP_CAMERA_T,"",e);const{code:t,track:i}=yield this._rtcModule.disableVideoTrack();return t!==U.SUCCESS&&t!==A.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_STOP_CAMERA_R,`error code: ${t}`,e),{code:t}):(this._rtcModule.destroyTrack(i),this._logger.info(v.L_CALLPLUS_CLIENT_STOP_CAMERA_R,"success",e),{code:U.SUCCESS})})}switchCamera(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T,`cameraId: ${e}`,t),!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`param error, cameraId: not empty string, value: ${e}`,t),{code:U.PARAM_ERROR};const i=this._callEngine.getLocalMainSession();if(!i)return this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`errCode: ${U.NOT_IN_CALL}`,t),{code:U.NOT_IN_CALL};if(i.getMediaType()===D.AUDIO)return this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`errCode: ${U.NOT_VIDEO_CALL}`,t),{code:U.NOT_VIDEO_CALL};this._videoConfig.cameraId=e,this._rtcModule.setVideoConfig(this._videoConfig);const{code:_}=yield this._rtcModule.changeVideoDevice(t);return _!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`call client changeVideoDevice error code: ${_}`,t),{code:_}):(this._logger.info(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"success",t),{code:U.SUCCESS})})}startMicrophone(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_START_MICROPHONE_T,"",e);const{code:t,track:i}=yield this._rtcModule.getMicrophoneAudioTrack(e);if(t!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_START_MICROPHONE_R,`create microphone audio track error code: ${t}`,e),{code:t};if(!i.isOwnerMuted())return this._logger.info(v.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),{code:U.SUCCESS};const _=yield i.unmute();return _!==A.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_START_MICROPHONE_R,`signal error code: ${t}`,e),{code:_}):(this._logger.info(v.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),{code:U.SUCCESS})})}stopMicrophone(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T,"",e);const{code:t}=yield this._rtcModule.disableAudioTrack();return t!==U.SUCCESS&&t!==A.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(v.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,"success",e),{code:U.SUCCESS})})}isMicrophoneEnabled(){const e=this._rtcModule.getLocalAudioTrack();return!!e&&!e.isOwnerMuted()}setAllRemoteAudioEnable(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();return this._rtcModule.setAllRemoteAudioEnable(e,t)})}getVersion(){return"2.46.0-alpha.1"}getCameras(){return f(this,void 0,void 0,function*(){return p.getCameras()})}getMicrophones(){return f(this,void 0,void 0,function*(){return p.getMicrophones()})}getSpeakers(){return f(this,void 0,void 0,function*(){return p.getSpeakers()})}getRTCSessionId(){return this._rtcModule.getRTCSessionId()}switchMicrophone(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T,`microphoneId: ${e}`,t),!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`param error, microphoneId: not empty string, value: ${e}`,t),{code:U.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`errCode: ${U.NOT_IN_CALL}`,t),{code:U.NOT_IN_CALL};this._audioConfig.microphoneId=e,this._rtcModule.setAudioConfig(this._audioConfig);const{code:i}=yield this._rtcModule.changeAudioDevice(t);return i!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`call client changeAudioDevice error code: ${i}`,t),{code:i}):(this._logger.info(v.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"success",t),{code:U.SUCCESS})})}}u.add("callplus","2.46.0-alpha.1");const ye={tag:"RCCallPlus",verify:e=>!!u.validEngine("5.46.0")||(console.error(`The current engine version '${u.getInfo().engine}' error, plugin-call-plus required engine version at least '5.46.0'.`),!1),setup(e,t,_){const r=(s=_)?S(s)?Object.keys(s).includes("rtcClient")?S(s.rtcClient)?{isLegal:!0}:{isLegal:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:{isLegal:!1,code:U.NOT_INSTALL_RTC_PLUGIN}:{isLegal:!1,msg:"Initialization options must be an object"}:{isLegal:!1,msg:"Initialization missing parameter -> options"};var s;if(!r.isLegal)throw new Error(`[CallPlusLib installer steup]${r.msg}`);i(_.isAllowNewCallWhenRinging)&&(_.isAllowNewCallWhenRinging=!0);const o=e.createLogger("CallPlus","RTC"),n=i(_.logOutputLevel)?g.WARN:_.logOutputLevel;return o.setOutputLevel(n),o.warn(v.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O,`CallPlus Version: 2.46.0-alpha.1, Commit: df1ee047af8b3579320159e1fa82c748fd2f6037, isAllowNewCallWhenRinging: ${_.isAllowNewCallWhenRinging}`),new De(e,o,t,_)}};export{V as IGroupCallStatusMessageType,w as RCAudioConfigBuilder,Pe as RCCallPlusAndroidPushConfigBuilder,y as RCCallPlusCallState,De as RCCallPlusClient,U as RCCallPlusCode,D as RCCallPlusMediaType,b as RCCallPlusMediaTypeChangeResult,G as RCCallPlusReason,H as RCCallPlusSession,P as RCCallPlusSessionUserState,M as RCCallPlusType,k as RCVideoConfigBuilder,ye as installer};
|
|
1
|
+
import{isNumber as e,isBoolean as t,isUndefined as i,isString as _,EventEmitter as r,ErrorCode as s,getUUID22 as o,SentStatus as n,RCConnectionStatus as l,isNull as a,getUUID as c,ConversationType as L,MessageDirection as E,ReceivedStatus as d,RTCMode as C,notEmptyArray as T,notEmptyString as I,isObject as S,VersionManage as u,LogL as g}from"@rongcloud/engine";import{RCResolution as h,RCFrameRate as R,RCRTCCode as A,RCKickReason as N,helper as O,RCLocalTrack as m,device as p}from"@rongcloud/plugin-rtc";export{RCFrameRate as RCCallPlusFrameRate,RCResolution as RCCallPlusResolution}from"@rongcloud/plugin-rtc";function f(e,t,i,_){return new(i||(i=Promise))(function(r,s){function o(e){try{l(_.next(e))}catch(e){s(e)}}function n(e){try{l(_.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,n)}l((_=_.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const U={SUCCESS:0,PARAM_ERROR:80001,SESSION_EXIST:80002,NOT_IN_CALL:80003,MEDIATYPE_INVALID:80004,NOT_VIDEO_CALL:80005,RTC_SERVICE_UNAVAILABLE:80006,USER_LIST_INVAILD:80007,CALL_ID_INVALID:80008,TRANSACTION_ID_INVALID:80009,USER_ID_INVALID:80010,SINGLE_CALL_NOT_SUPPORT_MULTI_PERSON:80011,SIGNAL_DISCONNECTED:80012,CAMERA_CLOSED:80100,MICROPHONE_CLOSED:80101,MEDIA_RESOURCE_INVALIED:80102,NOT_INSTALL_RTC_PLUGIN:80103,PLAY_MEDIA_FAILED:80104,VIDEO_VIEW_NOT_SET:80105};var v,M,P,D,y,b,G,V;!function(e){e.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O="L-index_install_call_plus_plugin-O",e.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O="L-callplus_client_set_event_listener-O",e.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O="L-callplus_client_call_event_listener-O",e.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O="L-callplus_client_set_status_report_listener-O",e.L_CALLPLUS_CLIENT_CALL_STATUS_REPORT_LISTENER_O="L-callplus_client_call_status_report_listener-O",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T="L-callplus_client_set_video_config-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R="L-callplus_client_set_video_config-R",e.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O="L-callplus_video_config_set_frame_rate-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O="L-callplus_video_config_set_resolution-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O="L-callplus_video_config_set_bitrate-O",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T="L-callplus_client_set_audio_config-T",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R="L-callplus_client_set_audio_config-R",e.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O="L-callplus_audio_config_set_bitrate-O",e.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O="L-callplus_audio_config_set_sample_rate-O",e.L_CALLPLUS_CLIENT_PREVIEW_T="L-callplus_client_preview-T",e.L_CALLPLUS_CLIENT_PREVIEW_R="L-callplus_client_preview-R",e.L_CALLPLUS_CLIENT_START_CALL_T="L-callplus_client_start_call-T",e.L_CALLPLUS_CLIENT_START_CALL_R="L-callplus_client_start_call-R",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T="L-callplus_client_join_multi_call-T",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R="L-callplus_client_join_multi_call-R",e.L_CALLPLUS_CLIENT_ACCEPT_T="L-callplus_client_accept-T",e.L_CALLPLUS_CLIENT_ACCEPT_R="L-callplus_client_accept-R",e.L_CALLPLUS_CLIENT_HANGUP_T="L-callplus_client_hangup-T",e.L_CALLPLUS_CLIENT_HANGUP_R="L-callplus_client_hangup-R",e.L_CALLPLUS_CLIENT_INVITE_T="L-callplus_client_invite-T",e.L_CALLPLUS_CLIENT_INVITE_R="L-callplus_client_invite-R",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T="L-callplus_client_request_change_media_type-T",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R="L-callplus_client_request_change_media_type-R",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T="L-callplus_client_cancel_change_media_type-T",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R="L-callplus_client_cancel_change_media_type-R",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T="L-callplus_client_reply_change_media_type-T",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R="L-callplus_client_reply_change_media_type-R",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_T="L-callplus_client_get_current_call_session-T",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_R="L-callplus_client_get_current_call_session-R",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_get_available_call_sessions_from_server-T",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_get_available_call_sessions_from_server-R",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T="L-callplus_client_get_call_records-T",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R="L-callplus_client_get_call_records-R",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T="L-callplus_client_delete_call_records_by_callId-T",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R="L-callplus_client_delete_call_records_by_callId-R",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_delete_all_call_records_from_server-T",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_delete_all_call_records_from_server-R",e.L_CALLPLUS_CLIENT_START_CAMERA_T="L-callplus_client_start_camera-T",e.L_CALLPLUS_CLIENT_START_CAMERA_R="L-callplus_client_start_camera-R",e.L_CALLPLUS_CLIENT_STOP_CAMERA_T="L-callplus_client_stop_camera-T",e.L_CALLPLUS_CLIENT_STOP_CAMERA_R="L-callplus_client_stop_camera-R",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T="L-callplus_client_switch_camera-T",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R="L-callplus_client_switch_camera-R",e.L_CALLPLUS_CLIENT_START_MICROPHONE_T="L-callplus_client_start_microphone-T",e.L_CALLPLUS_CLIENT_START_MICROPHONE_R="L-callplus_client_start_microphone-R",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T="L-callplus_client_stop_microphone-T",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R="L-callplus_client_stop_microphone-R",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T="L-callplus_client_switch_microphone-T",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R="L-callplus_client_switch_microphone-R",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T="L-callplus_client_set_video_view-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R="L-callplus_client_set_video_view-R",e.L_RTC_MODULE_SET_VIDEO_VIEW_O="L-rtc_module_set_video_view-O",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T="L-callplus_client_remove_video_view-T",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R="L-callplus_client_remove_video_view-R",e.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O="L-rtc_module_remove_video_view-O",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_T="L-callplus_client_play_media-T",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_R="L-callplus_client_play_media-R",e.L_RTC_MODULE_PLAY_MEDIA_T="L-rtc_module_play_media-T",e.L_RTC_MODULE_PLAY_MEDIA_R="L-rtc_module_play_media-R",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T="L-rtc_module_set_all_remote_audio_enbale-T",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R="L-rtc_module_set_all_remote_audio_enable-R",e.L_RTC_MODULE_SUBSCRIBE_T="L-rtc_module_subscribe-T",e.L_RTC_MODULE_SUBSCRIBE_R="L-rtc_module_subscribe-R",e.L_RTC_MODULE_UNSUBSCRIBE_T="L-rtc_module_unsubscribe-T",e.L_RTC_MODULE_UNSUBSCRIBE_R="L-rtc_module_unsubscribe-R",e.L_RTC_MODULE_PUBLISH_T="L-rtc_module_publish-T",e.L_RTC_MODULE_PUBLISH_R="L-rtc_module_publish-R",e.L_RTC_MODULE_UNPUBLISH_T="L-rtc_module_unpublish-T",e.L_RTC_MODULE_UNPUBLISH_R="L-rtc_module_unpublish-R",e.L_RTC_MODULE_DESTROY_ALL_TRACKS_O="L-rtc_module_destroy_all_tracks-O",e.L_RTC_MODULE_SESSION_CONNECT_T="L-rtc_module_session_connect-T",e.L_RTC_MODULE_SESSION_CONNECT_P="L-rtc_module_session_connect-P",e.L_RTC_MODULE_SESSION_CONNECT_R="L-rtc_module_session_connect-R",e.L_RTC_MODULE_SESSION_CLOSE_T="L-rtc_module_session_close-T",e.L_RTC_MODULE_SESSION_CLOSE_P="L-rtc_module_session_close-P",e.L_RTC_MODULE_SESSION_CLOSE_R="L-rtc_module_session_close-R",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_T="L-rtc_module_create_video_track-T",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_R="L-rtc_module_create_video_track-R",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_T="L-rtc_module_create_audio_track-T",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_R="L-rtc_module_create_audio_track-R",e.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O="L-rtc_module_receive_track_publish-O",e.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O="L-rtc_module_receive_track_unpublish-O",e.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O="L-rtc_module_receive_track_enable_change-O",e.L_RTC_MODULE_RECEIVE_KICK_OFF_O="L-rtc_module_receive_kick_off-O",e.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O="L-rtc_module_receive_peerconnection_except_close-O",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T="L-rtc_module_change_media_type-T",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R="L-rtc_module_change_media_type-R",e.L_RTC_MODULE_JOIN_RTC_ROOM_T="L-rtc_module_join_rtc_room-T",e.L_RTC_MODULE_JOIN_RTC_ROOM_R="L-rtc_module_join_rtc_room-R",e.L_RTC_MODULE_QUIT_RTC_ROOM_T="L-rtc_module_quit_rtc_room-T",e.L_RTC_MODULE_QUIT_RTC_ROOM_R="L-rtc_module_quit_rtc_room-R",e.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P="L-rtc_module_create_call_media_tracks-P",e.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T="L-signal_transporter_single_call-T",e.L_SIGNAL_TRANSPORTER_GROUP_CALL_T="L-signal_transporter_group_call-T",e.L_SIGNAL_TRANSPORTER_INVITE_T="L-signal_transporter_invite-T",e.L_SIGNAL_TRANSPORTER_RING_T="L-signal_transporter_ring-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_T="L-signal_transporter_accept-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_R="L-signal_transporter_accept-R",e.L_SIGNAL_TRANSPORTER_JOIN_CALL_T="L-signal_transporter_join_call-T",e.L_SIGNAL_TRANSPORTER_HANGUP_T="L-signal_transporter_hangup-T",e.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T="L-signal_transporter_call_status_up-T",e.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T="L-signal_transporter_call_event_up-T",e.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T="L-signal_transporter_call_dialog_up-T",e.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T="L-signal_transporter_delete_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T="L-signal_transporter_get_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T="L-signal_transporter_get_call_server_time-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T="L-signal_transporter_get_call_time_info-T",e.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T="L-signal_transporter_get_available_call_list-T",e.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T="L-signal_transporter_clear_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T="L-signal_transporter_get_call_info_by_callId-T",e.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T="L-signal_transporter_user_system_state_up-T",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O="L-signal_transporter_receive_call_signal_data-O",e.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O="L-signal_transporter_im_state_change-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O="L-signal_transporter_receive_invite-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O="L-signal_transporter_receive_call_status-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O="L-signal_transporter_receive_miss_message-O",e.L_CALL_ENGINE_UPDATE_USERS_STATE_O="L-call_engine_update_users_state-O",e.L_CALL_ENGINE_IM_STATE_CHANGE_O="L-call_engine_im_state_change-O",e.L_CALL_ENGINE_CALL_TIMEOUT_O="L-call_engine_call_timeout-O",e.L_CALL_ENGINE_START_CALL_TIMER_O="L-call_engine_start_call_timer-O",e.L_CALL_ENGINE_STOP_CALL_TIMER_O="L-call_engine_stop_call_timer-O",e.L_CALL_ENGINE_UP_ON_PHONE_END_T="L-call_engine_up_on_phone_end-T",e.L_CALL_ENGINE_UP_ON_PHONE_END_R="L-call_engine_up_on_phone_end-R",e.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O="L-call_engine_receive_first_frame_time-O",e.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O="L-call_engine_receive_mediatype_change-O",e.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O="L-call_engine_receive_close_session-O",e.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O="L-call_engine_receive_call_record-O",e.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O="L-call_engine_receive_complementary_data-O",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T="L-call_engine_create_session_by_server-T",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R="L-call_engine_create_session_by_server-R",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T="L-call_engine_up_first_frame_time-T",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R="L-call_engine_up_first_frame_time-R",e.L_TIME_CORRECT_START_O="L-time_correct_start-O",e.L_TIME_CORRECT_STOP_O="L-time_correct_stop-O",e.L_TIME_CORRECT_RESTART_O="L-time_correct_restart-O",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T="L-time_correct_get_call_client_time_by_server-T",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P="L-time_correct_get_call_client_time_by_server-P",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R="L-time_correct_get_call_client_time_by_server-R",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T="L-time_correct_calc_client_start_time-T",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R="L-time_correct_calc_client_start_time-R",e.L_TIME_CORRECT_SET_DELTA_TIME_O="L-time_correct_set_delta_time-O",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T="L-time_correct_loop_correct_client_time-T",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R="L-time_correct_loop_correct_client_time-R",e.L_INNER_SESSION_UPDATE_USER_STATE_O="L-inner_session_update_user_state-O",e.L_INNER_SESSION_SET_USER_DEVICE_ENABLE_O="L-inner_session_set_user_device_enable-O",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_T="L-callplus_session_get_create_time-T",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_R="L-callplus_session_get_create_time-R",e.L_CALLPLUS_SESSION_GET_DURATION_T="L-callplus_session_get_duration-T",e.L_CALLPLUS_SESSION_GET_DURATION_R="L-callplus_session_get_duration-R",e.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O="L-callplus_set_android_push_config-O",e.L_ABNORMAL_ADD_CALL_ID_E="L-ABNORMAL_ADD_CALL_ID-E",e.L_ABNORMAL_REMOVE_CALL_IDS_E="L-ABNORMAL_REMOVE_CALL_IDS-E",e.L_ABNORMAL_GET_CALL_IDS_E="L-ABNORMAL_GET_CALL_IDS-E",e.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O="L-set_audio_output_device_id-O"}(v||(v={}));class H{constructor(e,t,i,_,r){Object.defineProperty(this,"_session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_startTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_duration",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),this._callId=this._session.getCallId()}getCallId(){return this._callId}getState(){return this._session.getSessionState()}getCallType(){return this._session.getCallType()}getMediaType(){return this._session.getMediaType()}getUserList(){return this._session.getUserList().map(e=>{const{userId:t,userState:i}=e;let _=null,r=null;return t===this._context.getCurrentId()?(_=this._rtcModule.getLocalVideoTrack(),r=this._rtcModule.getLocalAudioTrack()):(_=this._rtcModule.getRemoteTrack(t,D.VIDEO),r=this._rtcModule.getRemoteTrack(t,D.AUDIO)),{userId:t,state:i,cameraEnable:!!_&&!_.isOwnerMuted(),microphoneEnable:!!r&&!r.isOwnerMuted()}})}getCreatorUserId(){return this._session.getStartCallerId()}getInviterUserId(){return this._session.getCallerId()}getCreateTimestamp(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_SESSION_GET_CREATE_TIME_T,"",e),this._startTime)return{code:U.SUCCESS,startTime:this._startTime};const{code:t,clientStartTime:i}=yield this._callEngine.getCallStaringTime({callId:this._callId},e);return t!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,`errCode: ${t}`,e),{code:t}):(this._logger.info(v.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,"success",e),this._startTime=i,{code:U.SUCCESS,startTime:this._startTime})})}getDuration(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_SESSION_GET_DURATION_T,"",e),this._duration)return this._logger.info(v.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${U.SUCCESS}, duration: ${this._duration}`,e),{code:U.SUCCESS,duration:this._duration};const{code:t,data:i}=yield this._callEngine.getCallTimeInfo(this._callId,e);return t!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${t}`,e),{code:t}):(this._logger.info(v.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${U.SUCCESS}, duration: ${i.duration}`,e),this._duration=i.duration,{code:U.SUCCESS,duration:this._duration})})}}!function(e){e[e.SINGLE=0]="SINGLE",e[e.MULTI=1]="MULTI"}(M||(M={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ONPHONE=301]="ONPHONE",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(P||(P={})),function(e){e[e.AUDIO=0]="AUDIO",e[e.AUDIO_VIDEO=1]="AUDIO_VIDEO",e[e.VIDEO=2]="VIDEO"}(D||(D={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ENDED=1e3]="ENDED",e[e.NOANSWER=1001]="NOANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELED=1003]="CANCELED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(y||(y={})),function(e){e[e.CANCEL_CHANGE_MEDIA_TYPE=0]="CANCEL_CHANGE_MEDIA_TYPE",e[e.REFUSE_CHANGE_MEDIA_TYPE=1]="REFUSE_CHANGE_MEDIA_TYPE",e[e.SERVER_ALLOW_MEDIA_TYPE=2]="SERVER_ALLOW_MEDIA_TYPE",e[e.CHANGE_MEDIA_TYPE_TIMEOUT=3]="CHANGE_MEDIA_TYPE_TIMEOUT"}(b||(b={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ON_PHONE=301]="ON_PHONE",e[e.ON_PHONE_END=302]="ON_PHONE_END",e[e.ON_DEVICE_DISABLE=303]="ON_DEVICE_DISABLE",e[e.ON_DEVICE_ENABLE=304]="ON_DEVICE_ENABLE",e[e.ABNORMAL_END=999]="ABNORMAL_END",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.OTHER_CLIENT_CALLING=1010]="OTHER_CLIENT_CALLING",e[e.OTHER_CLIENT_ACCEPT=1011]="OTHER_CLIENT_ACCEPT",e[e.JOIN_ROOM_ERR=1105]="JOIN_ROOM_ERR",e[e.PUBLISH_ERR=1106]="PUBLISH_ERR",e[e.SUBSCRIBE_ERR=1107]="SUBSCRIBE_ERR",e[e.ACCEPT_CARRIER=1108]="ACCEPT_CARRIER",e[e.KICKED_BY_SERVER=1109]="KICKED_BY_SERVER",e[e.CONNECTION_ERR=1110]="CONNECTION_ERR",e[e.LOGOUT=1111]="LOGOUT",e[e.OTHER_CLIENT_LOGIN=1112]="OTHER_CLIENT_LOGIN",e[e.OTHER_CLIENT_JOINED=1113]="OTHER_CLIENT_JOINED",e[e.OTHER_CLIENT_IN_ROOM=1114]="OTHER_CLIENT_IN_ROOM",e[e.OTHER_CLIENT_HANGUP=1151]="OTHER_CLIENT_HANGUP",e[e.REMOTE_JOIN_RTC_ERROR=1205]="REMOTE_JOIN_RTC_ERROR",e[e.REMOTE_PUBLISH_ERROR=1206]="REMOTE_PUBLISH_ERROR",e[e.REMOTE_SUBSCRIBE_ERROR=1207]="REMOTE_SUBSCRIBE_ERROR",e[e.REMOTE_KICKED_BY_SERVER=1209]="REMOTE_KICKED_BY_SERVER",e[e.REMOTE_CONNECTION_ERROR=1210]="REMOTE_CONNECTION_ERROR",e[e.REMOTE_LOGOUT=1211]="REMOTE_LOGOUT",e[e.REMOTE_OTHER_CLIENT_LOGIN=1212]="REMOTE_OTHER_CLIENT_LOGIN",e[e.REMOTE_OTHER_JOINED_RTC=1213]="REMOTE_OTHER_JOINED_RTC",e[e.REMOTE_OTHER_CLIENT_IN_RTC=1214]="REMOTE_OTHER_CLIENT_IN_RTC"}(G||(G={})),function(e){e[e.START=1]="START",e[e.END=2]="END"}(V||(V={}));class w{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}setDefaultMicrophoneId(e){return this._audioConfig.microphoneId=e,this}setBitrate(t,i){return!e(t)||!e(i)||i<=0||t<=0||i<t?(this._logger.error(v.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O,`params error -> max: ${i},min: ${t}, max and min is a number > 0, max should > min`),this):(this._audioConfig.minBitrate=t,this._audioConfig.maxBitrate=i,this)}setSampleRate(t){return e(t)?(this._audioConfig.sampleRate=t,this):(this._logger.error(v.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O,`params error -> sampleRate: ${t}`),this)}build(){return this._audioConfig}}class k{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:h.W640_H480,frameRate:R.FPS_15}})}setFrameRate(e){return R[e]?(this._videoConfig.frameRate=e,this):(this._logger.error(v.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O,`params error -> fps: ${e}`),this)}setVideoResolution(e){return h[e]?(this._videoConfig.resolution=e,this):(this._logger.error(v.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O,`params error -> resolution: ${e}`),this)}setDefaultCameraId(e){return this._videoConfig.cameraId=e,this}setBitrate(t,i){return!e(t)||!e(i)||i<=0||t<=0||i<t?(this._logger.error(v.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O,`params error -> max: ${i},min: ${t}, max and min is a number > 0, max should > min`),this):(this._videoConfig.minBitrate=t,this._videoConfig.maxBitrate=i,this)}build(){return this._videoConfig}}const $=e=>{const{callId:t,callType:i,callDir:_,mediaType:r,callingUserId:s,callUserIds:o,callStatus:n,sessionStatus:l,startTime:a,endTime:c,duration:L,syncTime:E,sysStatus:d,crtTime:C}=e;return{callId:t,callType:i,callDirection:_,mediaType:r,callerUserId:s,callUserIds:o,sessionState:n,userState:l,startTimestamp:a,endTimestamp:c,duration:L,syncTimestamp:E,systemState:d,createTimestamp:C}},B=e=>e&&e.nodeName&&"VIDEO"===e.nodeName.toUpperCase(),x=e=>{const{voipCallInfo:t}=e;if(!t)return!1;const{strategy:i}=JSON.parse(t);return 1===i},F=(t,i)=>!t&&0!==t||e(t)&&!(t<=0)?!i&&0!==i||e(i)&&!(i<=0)?t&&i&&i<t?{code:U.PARAM_ERROR,errorMsg:`params error -> maxBitrate: ${i}, minBitrate: ${t}, maxBitrate should > minBitrate`}:{code:U.SUCCESS}:{code:U.PARAM_ERROR,errorMsg:`params error -> maxBitrate: a number of > 0, value: ${i}`}:{code:U.PARAM_ERROR,errorMsg:`params error -> minBitrate: a number of > 0, value: ${t}`},j=e=>{const t=[];for(const i in e){const{videoView:_,isTiny:r}=e[i];t.push({userId:i,videoView:_.nodeName,isTiny:r})}return t},Y=(e,t={},i={})=>{const{threadId:_,apnsCollapseId:r,richMediaUri:s}=t,{channelIdMi:o,templateIdMi:n,templateParamMi:l,channelIdHW:a,channelIdOPPO:c,typeVivo:L,fcmChannelId:E,fcmCollapseKey:d,fcmImageUrl:C,importanceHW:T,categoryHW:I,imageUrlHW:S,categoryVivo:u,importanceHonor:g,imageUrlHonor:h}=i,R={};_&&(R["thread-id"]=_),R["apns-collapse-id"]=r||e,s&&(R.richMediaUri=s);const A={};a&&(A.channelId=a),S&&(A.image=S),I&&(A.category=I),A.importance=T||"NORMAL";const N=[{HW:A},{APNS:R}];let O;(d||C||E)&&(O={},d&&(O.collapse_key=d),C&&(O.imageUrl=C),E&&(O.channelId=E),N[N.length]={FCM:O});const m=!!l&&Object.keys(l).length>0;if(o||n||m){const e={};o&&(e.channelId=o),n&&(e.templateId=n),m&&(e.templateParam=l),N[N.length]={MI:e}}let p,f,U;return c&&(p={},p.channelId=c,N[N.length]={OPPO:p}),(L||u)&&(f={},L&&(f.classification=L),u&&(f.category=u),N[N.length]={VIVO:f}),(g||h)&&(U={},g&&(U.importance=g),h&&(U.image=h),N[N.length]={HONOR:U}),JSON.stringify(N)},J=(e,i)=>{const{pushTitle:_="",iOSConfig:r,androidConfig:s,disablePushTitle:o,templateId:n}=e,l={pushConfigs:Y(i,r,s)};return t(o)&&(l.disableTitle=o),_&&(l.title=_),n&&(l.templateId=n),JSON.stringify(l)},W=e=>{const r=["pushTitle","pushContent","iOSConfig","androidConfig","disablePushTitle","templateId"];if(!Object.keys(e).every(e=>r.includes(e)))return{code:U.PARAM_ERROR,errorMsg:`right key: ${r.join(",")}`};for(let s=0;s<r.length;s++){const o=r[s];if("disablePushTitle"===o){if(!i(e[o])&&!t(e[o]))return{code:U.PARAM_ERROR,errorMsg:`${o} type is boolean`}}else if(("pushTitle"===o||"templateId"===o||"pushContent"===o)&&e[o]&&!_(e[o]))return{code:U.PARAM_ERROR,errorMsg:`${o} type is string`}}const{iOSConfig:s,androidConfig:o}=e,n=K(s||{});if(n.code!==U.SUCCESS)return n;const l=Q(o||{});return l.code!==U.SUCCESS?l:{code:U.SUCCESS}},K=e=>{const{threadId:t,richMediaUri:i}=e||{};return t&&!_(t)?{code:U.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:i&&!_(i)?{code:U.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:U.SUCCESS}},Q=e=>{const t=["channelIdMi","templateIdMi","templateParamMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"];if(!Object.keys(e).every(e=>t.includes(e)))return{code:U.PARAM_ERROR,errorMsg:`right key: ${t.join(",")}`};for(let i=0;i<t.length;i++){const r=t[i];if("importanceHW"===r||"importanceHonor"===r){if(e[r]&&"LOW"!==e[r]&&"NORMAL"!==e[r])return{code:U.PARAM_ERROR,errorMsg:`androidConfig.${r} value is NORMAL|LOW`}}else if("templateParamMi"===r){if(e[r]&&("object"!=typeof e[r]||Array.isArray(e[r])))return{code:U.PARAM_ERROR,errorMsg:`androidConfig.${r} type is object`};if(e[r]){const t=Object.keys(e[r]).find(t=>!_(t)||!_(e[r][t]));if(void 0!==t)return{code:U.PARAM_ERROR,errorMsg:`androidConfig.${r}.${t} key and value type is string`}}}else if(e[r]&&!_(e[r]))return{code:U.PARAM_ERROR,errorMsg:`androidConfig.${r} type is string`}}return{code:U.SUCCESS}},q=(e,t="utf-8")=>{let i=0;return i="utf-16"===t?X(e):z(e),i},X=e=>{let t,i=0;for(let _=0,r=e.length;_<r;_++)t=e.charCodeAt(_),i+=t<=65535?2:4;return i},z=e=>{let t,i=0;for(let _=0,r=e.length;_<r;_++)t=e.charCodeAt(_),i+=t<127?1:t<=2047?2:t<=65535?3:4;return i},Z=/Electron/.test(navigator.userAgent);var ee,te,ie,_e,re,se;!function(e){e.L_QS_START_CALL_S="Call-start-S",e.L_QS_ACCEPT_CALL_S="Call-accept-S",e.L_QS_HANGUP_CALL_S="Call-hangup-S",e.L_QS_RECEIVE_CALL_S="Call-recv-S",e.L_QS_ABNORMAL_HANGUP_S="Call-interrupt-S"}(ee||(ee={}));class oe{constructor(e,t){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t})}reportStatisticsData(e,t,i,_,r,s,o){const n=+new Date,{mediaType:l,callType:a,callId:c}=_?{mediaType:_.getMediaType(),callType:_.getCallType(),callId:_.getCallId()}:o,L={cr:"unknown",net:"unknown",cod:t,mtp:l,ctp:a,cid:c,time:n,uid:this._context.getCurrentId()};r&&Object.assign(L,{ccid:r});let E=null;switch(e){case ee.L_QS_RECEIVE_CALL_S:E=Object.assign(Object.assign({},L),{rf:s});break;case ee.L_QS_ABNORMAL_HANGUP_S:E=Object.assign({},L);break;default:E=Object.assign(Object.assign({},L),{dur:n-i})}this._logger.__statistics(e,JSON.stringify(E))}}!function(e){e.REQUEST="request",e.ACCEPT="accept",e.REFUSE="refuse",e.CANCEL="cancel",e.NOTICE="notice",e.TIMEOUT="timeout"}(te||(te={})),function(e){e[e.SWITCH_MEDIA_TYPE=1]="SWITCH_MEDIA_TYPE"}(ie||(ie={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.SECRET=1]="SECRET"}(_e||(_e={})),function(e){e.INVITER="inviter",e.INVITEE="invitee"}(re||(re={}));class ne extends r{constructor(e,t,i,_,r,s,o,n){super(),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_callType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_startCallerId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_callerId",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_callUsers",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_reqMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_inviterTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_inviteeTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_oldDialogData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLocalClientHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1})}getCallId(){return this._callId}getSessionState(){return this._state}getCallType(){return this._callType}getMediaType(){return this._mediaType}getStartCallerId(){return this._startCallerId}getCallerId(){return this._callerId}getUserList(){return this._callUsers}getReqMediaType(){return this._reqMediaType}getInviterTimerId(){return this._inviterTimerId}getInviteeTimerId(){return this._inviteeTimerId}getAllTimerIds(){return[this._inviterTimerId,this._inviteeTimerId]}updateUserList(e,t){const i=[];return e.forEach(e=>{const{userState:t,stateTime:_,systemState:r,userId:s}=e,o=this._callUsers.findIndex(e=>e.userId===s);if(o<0)return this._callUsers.push(e),void i.push(e);const{stateTime:n,systemState:l,userState:a}=this._callUsers[o],c=((e,t)=>{let i=!1;const _=[G.INVITED,G.RINGING,G.BUSYLINE_RINGING,G.BUSYLINE_WAIT,G.CONNECTING,G.ONCALL];return e===G.ONCALL&&_.includes(t)&&(i=!0),i})(l,r),L=((e,t)=>{let i=!1;const _=[P.INVITED,P.RINGING,P.BUSYLINE_RINGING,P.BUSYLINE_WAIT,P.CONNECTING,P.ONCALL];return e===P.ONCALL&&_.includes(t)&&(i=!0),i})(a,t),E=r===G.ON_PHONE_END&&l!==G.ON_PHONE&&t!==P.IDLE;_&&n&&_<n||c&&L||(this._callUsers[o]=e,!E&&i.push(e))}),i}setOldDialogData(e){this._oldDialogData=e}updateSessionState(e){this._state=e}updateCallType(e){this._callType=e}updateMediaType(e){this._mediaType=e}updateReqMediaType(e){this._reqMediaType=e}updateTimerId(e,t){e===re.INVITER?this._inviterTimerId=t:this._inviteeTimerId=t}getOldDialogData(){return this._oldDialogData}setIsLocalClientHangup(e){this.isLocalClientHangup=e}getIsLocalClientHangup(){return this.isLocalClientHangup}}!function(e){e.START_SINGLE_CALL="startSingleCall",e.START_GROUP_CALL="startGroupCall",e.INVITE_CALL="inviteCall",e.PUB_INVITE_CALL="pubInviteCall",e.RINGING_CALL="ringCall",e.ACCEPT_CALL="acceptCall",e.JOIN_CALL="joinCall",e.HANGUP_CALL="hangupCall",e.STATUS_UP_CALL="statusUpCall",e.STATUS_DOWN_CALL="statusDownCall",e.EVENT_UP_CALL="eventUpCall",e.EVENT_DOWN_CALL="eventDownCall",e.DIALOG_UP_CALL="dialogUpCall",e.DIALOG_DOWN_CALL="dialogDownCall",e.GET_CALL_USER_SESSION_LIST="getCallUSerSessionList",e.SYNC_CALL_LOG="syncCallLog",e.PUB_CALL_LOG="pubCallLog",e.DEL_CALL_LOG="deleteCallLog",e.QRY_CALL_STATE="queryUserHasCall",e.QRY_SRV_TIMESTAMP="getCallSrvTimeStamp",e.GET_CALL_STATE_LIST="getUserCallStateList",e.CLEAR_CALL_LOG="cleanCallLog",e.GET_CALL_SESSION="getCallSession",e.GET_CALL_TIME_INFO="getCallTimeInfo",e.END_ABNORMAL_CALL="endUserAbnormalCalls",e.SYS_STATUS_UP="sysStatusUp",e.UP_CALL_LOG_READED="upCallLogReaded",e.PUB_CALL_LOG_READED="pubCallLogReaded",e.PUB_NACK_SEQ_ID="pubNACKSeqId",e.GET_USER_CALL_SESSION_ID_LIST="getUserCallSessionIdList"}(se||(se={}));const le=(e,t)=>setTimeout(e,t),ae=[s.RC_NET_CHANNEL_INVALID,s.RC_NET_UNAVAILABLE,s.RC_MSG_RESP_TIMEOUT,A.SIGNAL_DISCONNECTED,A.REQUEST_FAILED],ce=({asyncFn:e,fnArgs:t,currentRetryTime:i=Date.now(),maxDuration:_=6e4,intervals:r=[2e3,4e3,8e3,16e3,32e3,64e3],index:s=0,onError:o})=>f(void 0,void 0,void 0,function*(){const n=yield e(...t);return n.code===U.SUCCESS||!ae.includes(n.code)||Date.now()+2e3-i>_?n:(o&&o(n.code),yield(l=2e3,new Promise(e=>{setTimeout(e,l)})),ce({asyncFn:e,fnArgs:t,currentRetryTime:i,maxDuration:_,intervals:r,index:s,onError:o}));var l});var Le,Ee,de;!function(e){e.onBeforePublish="onBeforePublish",e.onPublishRes="onPublishRes",e.onPubInviteCall="onPubInviteCall",e.onPubInviteCallPullKv="onPubInviteCallPullKv",e.onPubInviteCallMiss="onPubInviteCallMiss"}(Le||(Le={})),function(e){e.NOT_CURRENT_DEVICEID="not current device id",e.SECRET_CALL="secret call",e.NOT_INVITEE="not an invitee"}(Ee||(Ee={})),function(e){e.PUB_INVITE="pubinvitecall",e.PULL_KV_INVITE="pullkv_invitecall",e.PUSH="system_pubsh"}(de||(de={}));const Ce=131072,Te="RC:CallPlusMiss",Ie="RC:CallGroupStatusMsg";class Se extends r{constructor(e,t,i,_,r,s){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_needRetryActions",{enumerable:!0,configurable:!0,writable:!0,value:[se.START_SINGLE_CALL,se.START_GROUP_CALL,se.ACCEPT_CALL,se.JOIN_CALL,se.EVENT_UP_CALL]}),Object.defineProperty(this,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:""}),this._context.onCallInfo=this._onRecvCallSignal.bind(this),this._context.onconnectionstatechange=this._onIMConnectionStateChange.bind(this),this._context.onmessage=this._onMessage.bind(this),this._sessionId=o()}_onMessage(e){return!![Te,Ie].includes(e.messageType)&&(e.messageType===Te?this._dealMissMessage(e):this._dealGroupCallMessage(e),!0)}_dealMissMessage(e){const{content:{callId:t,mediaType:i,startTime:_,callSessionUsers:r},targetId:s,senderUserId:o}=e,l=this._context.getCurrentId();if(!localStorage.getItem(`missMessageMap-${l}-${t}`)){const a={callId:t,callerUserId:o,targetId:s,mediaType:i,firstFrameTime:0,callStartTime:_-this._timeCorrectioner.getLocalDelayTime(),callEndTime:0,hangupReason:r.filter(({userId:e})=>e===l)[0].sessionStatus};this._logger.info(v.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O,`receive miss message: ${JSON.stringify(e)}`);const c=Object.assign(e,{content:a,sentStatus:n.SENT});this._reportAppEventModule.onReceivedCallPlusSummaryMessage(c),localStorage.setItem(`missMessageMap-${l}-${t}`,t)}}_dealGroupCallMessage(e){this._reportAppEventModule.onReceivedGroupCallStatusMessage(e)}getSessionId(){return this._sessionId}getDeviceId(){return Z?this._context.getDeviceId():this._sessionId}registerListener(e){this._listener=e}startCall(e,t){return f(this,void 0,void 0,function*(){const{clientCallId:i,callType:_,toUsers:r,mediaType:s,secretChat:o,targetType:n,targetId:l,nickName:a,oldRoomId:c,pushExt:L,pushContent:E,extra:d}=e;return _===M.SINGLE?this.startSingleCall({clientCallId:i,toUserId:r[0].userId,mediaType:s,secretChat:o,targetType:n,targetId:l,oldRoomId:c,toOrgId:r[0].orgId||"",pushExt:L,pushContent:E,extra:d},t):this.startGroupCall({clientCallId:i,toUsers:r,mediaType:s,targetType:n,targetId:l,nickName:a,oldRoomId:c,pushExt:L,pushContent:E,extra:d},t)})}startSingleCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(this._context.getCurrentId(),se.START_SINGLE_CALL,e)})}startGroupCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_GROUP_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(this._context.getCurrentId(),se.START_GROUP_CALL,e)})}inviteCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_INVITE_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.INVITE_CALL,e)})}ringingCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_RING_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.RINGING_CALL,e)})}acceptCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_ACCEPT_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.ACCEPT_CALL,e)})}joinCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_JOIN_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.JOIN_CALL,e)})}hangupCall(e,t){return f(this,void 0,void 0,function*(){this._logger.info(v.L_SIGNAL_TRANSPORTER_HANGUP_T,`params: ${JSON.stringify(e)}`,t);const{code:i}=yield this._sendCallSignal(e.callId,se.HANGUP_CALL,e);return i===U.NOT_IN_CALL?{code:U.SUCCESS}:{code:i}})}statusUpCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T,`call status up params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.STATUS_UP_CALL,e)})}eventUpCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.EVENT_UP_CALL,e)})}dialogUpCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.DIALOG_UP_CALL,e)})}deleteCallRecord(e,t,i){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T,`callIds: ${JSON.stringify(t)}`,i),this._sendCallSignal(e,se.DEL_CALL_LOG,{callIds:t})})}syncCallLog(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.userId,se.SYNC_CALL_LOG,e)})}queryUserHasCall(){return f(this,void 0,void 0,function*(){const e=this._context.getCurrentId();return this._sendCallSignal(e,se.QRY_CALL_STATE,null)})}getCallServerTimestamp(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(v.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T,`userId: ${t}`,e),this._sendCallSignal(t,se.QRY_SRV_TIMESTAMP,null)})}getCallTimeInfo(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T,`callId: ${e}`,t),this._sendCallSignal(e,se.GET_CALL_TIME_INFO,{callId:e})})}getUserCallStateList(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(v.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T,`userId: ${t}`,e),this._sendCallSignal(t,se.GET_CALL_STATE_LIST,null)})}clearCallRecord(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(v.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T,`userId: ${t}`,e),this._sendCallSignal(t,se.CLEAR_CALL_LOG,null)})}getCallSession(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T,`callId: ${e.callId}`,t),this._sendCallSignal(e.callId,se.GET_CALL_SESSION,e)})}sysStatusUp(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T,`opts: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.SYS_STATUS_UP,e)})}upCallLogReaded(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._sendCallSignal(t,se.UP_CALL_LOG_READED,e)})}endUserAbnormalCalls(e){return f(this,void 0,void 0,function*(){return this._sendCallSignal(this._context.getCurrentId(),se.END_ABNORMAL_CALL,e)})}_onIMConnectionStateChange(e){const t=this._logger.createTraceId();this._logger.info(v.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O,`state: ${e}`,t),this._listener.onIMStateChange(e),e===l.CONNECTED?this._timeCorrectioner.start(t):this._timeCorrectioner.stop(t)}_sendCallSignal(e,t,i){return f(this,void 0,void 0,function*(){let _,r="";i&&(r=Z?JSON.stringify(i):JSON.stringify(Object.assign(Object.assign({},i),{sessionId:this._sessionId}))),_=this._needRetryActions.includes(t)?yield ce({asyncFn:this._context.setCallInfo.bind(this._context),fnArgs:[e,t,r]}):yield this._context.setCallInfo(e,t,r);const{code:o,data:n}=_;if(o!==s.SUCCESS)return{code:o};const{value:l}=n,a=JSON.parse(l).data;return{code:U.SUCCESS,data:a}})}_onRecvCallSignal(e){const t=this._logger.createTraceId();this._logger.info(v.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O,`data: ${e}`,t);JSON.parse(e).list.forEach(e=>{const{key:i}=e,_=JSON.parse(e.value);switch(i){case se.PUB_INVITE_CALL:this._onPubInviteCall(_,t,!0);break;case se.STATUS_DOWN_CALL:this._onStatusDownCall(_,t);break;case se.EVENT_DOWN_CALL:this._onEventDownCall(_,t);break;case se.DIALOG_DOWN_CALL:this._onDialogDownCall(_,t);break;case se.PUB_CALL_LOG:this._onPubCallLog(_,t);break;case se.PUB_CALL_LOG_READED:case se.PUB_NACK_SEQ_ID:break;default:this._onConpensationData(_,t)}})}isValidData(e){if(a(e))return!0;const t=e===this.getDeviceId();return!(!_(e)||0!==(null==e?void 0:e.length)&&!t)}_onPubInviteCall(e,t,i=!0){try{const i=this._context.getCurrentId(),_=e.callSessionUsers.find(e=>e.userId===i),r=this._context.getConnectionStatus();this._logger.info(v.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`currentUser: ${JSON.stringify(_)}, currentUserId: ${i}, state: ${r}`,t)}catch(e){this._logger.error(v.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`error: ${e.message}`,t)}if(!this.isValidData(e.toDeviceId||"")){this._logger.warn(v.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`not current deviceId -> deviceInfo: ${JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this.getDeviceId()})}`,t);const _={extra:JSON.stringify(e),reason:Ee.NOT_CURRENT_DEVICEID,refer:i?de.PUB_INVITE:de.PULL_KV_INVITE};return void this.emit(Le.onPubInviteCallMiss,Object.assign(e,_))}this._listener.onInvite(e,i,t),i?this.emit(Le.onPubInviteCall,Object.assign(e,{extra:JSON.stringify(e)})):this.emit(Le.onPubInviteCallPullKv,Object.assign(e,{extra:JSON.stringify(e)}))}_onStatusDownCall(e,t){if(e.callSessionUsers=e.callSessionUsers.filter(e=>Boolean(e.changed)),this._logger.info(v.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,"",t),!this.isValidData(e.toDeviceId||""))return this._logger.warn(v.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,`not current deviceId -> deviceInfo: ${JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this.getDeviceId()})}`,t),void this._listener.onOtherClientStatusDown(e,t);this._listener.onStatusDown(e,t,this._sessionId)}_onEventDownCall(e,t){this._listener.onEventDown(e,t)}_onDialogDownCall(e,t){const{dialogType:i}=e;i===ie.SWITCH_MEDIA_TYPE&&this._listener.onSwitchMediaType(e,t)}_onPubCallLog(e,t){this._logger.info(v.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O,`call record: ${JSON.stringify(e)}`,t),this._listener.onRecvCallEndLog(e,t)}_onConpensationData(e,t){this._logger.info(v.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O,"",t);const{callId:i,callType:_,mediaType:r,secretChat:s,duration:o,callStatus:n,callingUserId:l,callSessionUsers:a,toDeviceId:c,callDialogEntitys:L,extra:E}=e;a.some(e=>e.sessionStatus===P.INVITED&&e.userId===this._context.getCurrentId())?this._onPubInviteCall({callId:i,toDeviceId:c,callType:_,mediaType:r,inviteUserId:l,callingUserId:l,callSessionUsers:a,secretChat:s,extra:E},t,!0):this._onStatusDownCall({callId:i,toDeviceId:c,callStatus:n,duration:o,callSessionUsers:a},t),L.length>0&&L.forEach(e=>this._onDialogDownCall(e,t),this)}}const ue=()=>{let e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});return e=`${e.replace(/-/g,"")}0`,e=parseInt(e,16),e=(e=>{const t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),i=t.length+1;let _=+e;const r=[];do{const e=_%i;_=(_-e)/i,r.unshift(t[e])}while(_);return r.join("")})(e),e.length>22&&(e=e.slice(0,22)),e};class ge{constructor(e,t){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_localStore",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._localStore=e.localStorage}addAbnormallCallId(e,t){try{const i=JSON.parse(this._localStore.getItem(ge._STORAGE_KEY)||"{}");let _=i[e];_?_.push(t):_=[t],i[e]=_,this._localStore.setItem(ge._STORAGE_KEY,JSON.stringify(i))}catch(e){this._logger.error(v.L_ABNORMAL_ADD_CALL_ID_E,e.message),console.error(e)}}removeAbnormalCallIds(e,t){try{const i=JSON.parse(this._localStore.getItem(ge._STORAGE_KEY)||"{}");let _=i[e];_&&(_=_.filter(e=>!t.includes(e)),_.length>0?i[e]=_:delete i[e],this._localStore.setItem(ge._STORAGE_KEY,JSON.stringify(i)))}catch(e){this._logger.error(v.L_ABNORMAL_REMOVE_CALL_IDS_E,e.message),console.error(e)}}getAbnormalCallIds(e){let t=null;try{const i=JSON.parse(this._localStore.getItem(ge._STORAGE_KEY)||"{}")[e];i&&(t=i)}catch(e){this._logger.error(v.L_ABNORMAL_GET_CALL_IDS_E,e.message),console.error(e)}return Promise.resolve(t)}}var he,Re,Ae,Ne,Oe;Object.defineProperty(ge,"_STORAGE_KEY",{enumerable:!0,configurable:!0,writable:!0,value:"CallPlus_AbnormalCall"}),function(e){e[e.PROMPT=0]="PROMPT",e[e.CALL_DURATION=10]="CALL_DURATION",e[e.FIRST_FRAME=20]="FIRST_FRAME"}(he||(he={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.INVALID_RESPONSE_TIME=80170]="INVALID_RESPONSE_TIME",e[e.NONOPTIMAL_RES_TIME=80171]="NONOPTIMAL_RES_TIME"}(Re||(Re={}));class me{constructor(e,t,i){Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_singleCallDurationEv",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_RTT",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_validMinRTT",{enumerable:!0,configurable:!0,writable:!0,value:200}),Object.defineProperty(this,"_validMaxRTT",{enumerable:!0,configurable:!0,writable:!0,value:1e3}),Object.defineProperty(this,"_deltaTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_timerId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_interval",{enumerable:!0,configurable:!0,writable:!0,value:2e3}),Object.defineProperty(this,"_maxRetryTimes",{enumerable:!0,configurable:!0,writable:!0,value:8}),Object.defineProperty(this,"_startTimes",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_retryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_maxRetryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:3})}getCallClientTimeByServer(e,t){return f(this,void 0,void 0,function*(){this._logger.info(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T,`callId: ${e}`,t),(!this._RTT||this._RTT>this._validMinRTT)&&(yield this._getDeltaTime(t)),this._RTT>this._validMaxRTT&&this._logger.error(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${Re.INVALID_RESPONSE_TIME}`,t);const{code:i,data:_}=yield this._callEngine.getCallTimeInfo(e,t);if(i!==U.SUCCESS)return this._logger.error(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${i}`,t),{code:i};const{startTime:r}=_,s=Math.floor(r-this._deltaTime);let o=(Date.now()+this._deltaTime-r)/1e3;return o<0&&(this._logger.warn(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P,`invalid duration: ${o}`,t),o=0),o=Math.floor(o),this._RTT>this._validMinRTT&&this._RTT<=this._validMaxRTT&&this._logger.error(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${Re.NONOPTIMAL_RES_TIME}`,t),this._logger.info(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,serverStartTime:r,clientStartTime:s,duration:o}),t),{code:i,duration:o,clientStartTime:r?s:r}})}calcClientStartTime(e,t,i){if(this._logger.info(v.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T,`callId: ${e}, startTime: ${t}`,i),this._RTT>this._validMaxRTT)return this._logger.error(v.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,`code: ${Re.INVALID_RESPONSE_TIME}`,i),this._loopCorrectClientTime(e,i),{code:Re.INVALID_RESPONSE_TIME};const _=Math.floor(t-this._deltaTime);return this._logger.info(v.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,startT:t,clientStartTime:_}),i),this._RTT>this._validMinRTT&&(this._retryTimesInCall=0,this._loopCorrectClientTime(e,i)),{code:Re.SUCCESS,clientStartTime:_}}start(e){this._timerId||this._startTimes>=this._maxRetryTimes||(this._logger.info(v.L_TIME_CORRECT_START_O,`timerId: ${this._timerId}`),this._startTimes++,this._getDeltaTime(e),this._timerId=le(()=>{this._timerId=null,this.start(e)},this._interval))}stop(e){this._logger.info(v.L_TIME_CORRECT_STOP_O,`timerId: ${this._timerId}`,e),this._timerId&&clearTimeout(this._timerId),this._timerId=null,this._startTimes=0}restart(e){this._logger.info(v.L_TIME_CORRECT_RESTART_O,`legal rtt time, RTT: ${this._RTT}, validMinRTT: ${this._validMinRTT}`,e),this._RTT<this._validMinRTT||(this.stop(e),this.start(e))}getLocalDelayTime(){return Math.round(this._deltaTime)}getRTT(){return this._RTT}_getDeltaTime(e){return f(this,void 0,void 0,function*(){const t=Date.now(),{code:i,data:_}=yield this._callEngine.getCallServerTimestamp(e),r=Date.now();if(i!==U.SUCCESS)return{code:i};const s=r-t;return(s<this._RTT||0===this._RTT)&&s<=this._validMaxRTT&&(this._RTT=s),s<this._validMinRTT&&this.stop(e),this._deltaTime=_-t-this._RTT/2,this._logger.info(v.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime}),e),{code:i,delayTime:this._deltaTime}})}_getDeltaTimeInCall(e,t){return f(this,void 0,void 0,function*(){const i=Date.now(),{code:_,data:r}=yield this._callEngine.getCallTimeInfo(e,t),s=Date.now();if(_!==U.SUCCESS)return{code:_};const o=s-i;o<this._RTT&&(this._RTT=o),this._deltaTime=r.syncTime-i-this._RTT/2,this._logger.info(v.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({callId:e,rtt:this._RTT,deltaT:this._deltaTime}),t);const n=Math.floor(r.startTime-this._deltaTime),l=Math.floor(r.firstFrametime-this._deltaTime);return o<this._validMinRTT?{code:Re.SUCCESS,clientStartTime:n,clientFirstFrameTime:l}:{code:Re.INVALID_RESPONSE_TIME,clientStartTime:n,clientFirstFrameTime:l}})}_loopCorrectClientTime(e,t){return f(this,void 0,void 0,function*(){this.stop(t),this._logger.info(v.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T,`callId: ${e}`,t);const{code:i,clientStartTime:_,clientFirstFrameTime:r}=yield this._getDeltaTimeInCall(e,t);return i===Re.SUCCESS?(this._logger.info(v.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,`code: ${U.SUCCESS}`,t),void this._singleCallDurationEv(e,_,r,t)):this._retryTimesInCall>this._maxRetryTimesInCall&&i===Re.INVALID_RESPONSE_TIME?(this._logger.info(v.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,`code: ${Re.INVALID_RESPONSE_TIME}`,t),void this._singleCallDurationEv(e,_,r,t)):void(this._retryTimesInCall>this._maxRetryTimesInCall||(this._retryTimesInCall++,setTimeout(()=>{this._loopCorrectClientTime(e,t)},this._interval)))})}}!function(e){e[e.SOON_AFETER=0]="SOON_AFETER",e[e.CURRENT=1]="CURRENT"}(Ae||(Ae={})),function(e){e[e.PUB_INVITE_CALL=0]="PUB_INVITE_CALL",e[e.PULL_KV_INVITE_CALL=1]="PULL_KV_INVITE_CALL",e[e.SYSTEM_PUSH=2]="SYSTEM_PUSH"}(Ne||(Ne={})),function(e){e[e.OUT=-1]="OUT",e[e.GROUP=0]="GROUP",e[e.IN=1]="IN"}(Oe||(Oe={}));class pe extends r{constructor(e,t,i,_,r){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_mainSession",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_holdSessions",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_signalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_abnormalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isUpFirstFrameTime",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_callStartMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._timeCorrectioner=new me(this,_,this._onRecvSinCallDuration.bind(this)),this._signalModule=new Se(e,t,i,this._timeCorrectioner,this._logger,this._reportAppEventModule),this._signalModule.registerListener({onInvite:this._onInvite.bind(this),onStatusDown:this._onStatusDown.bind(this),onOtherClientStatusDown:this._onOtherClientStatusDown.bind(this),onEventDown:this._onEventDown.bind(this),onSwitchMediaType:this._onSwitchMediaType.bind(this),onRecvCallEndLog:this._onRecvCallEndLog.bind(this),onIMStateChange:this._onIMStateChange.bind(this)}),this._abnormalModule=new ge(t,_)}startCall(e,t){return f(this,void 0,void 0,function*(){const i=this._context.getCurrentId(),{callType:_,mediaType:r,toUsers:s,targetId:o,targetType:n,oldRoomId:l,pushConfig:a,extra:c}=e;this._clientCallId=e.callId;const L=a?J(a,this._clientCallId):"",{code:E,data:d}=yield this._signalModule.startCall({clientCallId:this._clientCallId,callType:_,mediaType:r,toUsers:s,secretChat:_e.NORMAL,targetType:n,targetId:o,oldRoomId:l,pushExt:L,pushContent:(null==a?void 0:a.pushContent)||"",extra:c},t);if(E!==U.SUCCESS)return{code:E};const{callId:C,busylineUsers:T}=d;if(this._abnormalModule.addAbnormallCallId(i,C),this._mainSession=new ne(C,y.INVITED,_,r,i,i,[],this._logger),_===M.SINGLE){const e=this._startTimer(d.callId,P.NO_ANSWER,t);this._mainSession.updateTimerId(re.INVITER,e)}const I={userId:i,userState:P.CALLING,systemState:G.CALLING,targetType:n,targetId:o};let S=s.map(({userId:e,targetType:t,targetId:i})=>({userId:e,userState:P.INVITED,systemState:G.INVITED,targetType:t,targetId:i})),u=[];T&&(u=T.map(e=>{const{targetType:t,targetId:i}=S.find(t=>t.userId===e.userId);return{userId:e.userId,userState:e.sessionStatus,systemState:G.BUSYLINE_RINGING,targetType:t,targetId:i}}),S=S.filter(({userId:e})=>u.every(({userId:t})=>t!==e)));const g=this.updateUsersState(C,[I,...S,...u],t);return setTimeout(()=>{g.length>0&&this.reportRemoteUserStateChange(C,g,t)}),{code:E,data:d}})}invite(e,t){var i;return f(this,void 0,void 0,function*(){if(!this._mainSession)return{code:U.NOT_IN_CALL};const{toUsers:_,pushConfig:r,extra:s}=e,o=r?J(r,this._clientCallId):"",n=this._mainSession.getCallId(),{code:l,data:a}=yield this._signalModule.inviteCall({callId:n,toUsers:_,pushExt:o,pushContent:(null==r?void 0:r.pushContent)||"",extra:s},t);if(l===U.SUCCESS){this._mainSession.getCallType()===M.SINGLE&&(this._mainSession.updateCallType(M.MULTI),this._onCallTypeChange(this._mainSession.getCallId(),M.MULTI,t));let e=_.map(({userId:e,targetType:t,targetId:i})=>({userId:e,userState:P.INVITED,systemState:G.INVITED,targetType:t,targetId:i})),r=[];a.busylineUsers&&(r=null===(i=a.busylineUsers)||void 0===i?void 0:i.map(t=>{const{targetType:i,targetId:_}=e.find(e=>e.userId===t.userId);return{userId:t.userId,userState:t.sessionStatus,systemState:G.BUSYLINE_RINGING,targetType:i,targetId:_}}),e=e.filter(({userId:e})=>r.every(({userId:t})=>t!==e)));const s=this.updateUsersState(n,[...e,...r],t);s.length>0&&this.reportRemoteUserStateChange(n,s,t)}return{code:l,data:a}})}clearAllTimer(e,t){[this._mainSession,...this._holdSessions].forEach(i=>{i&&i.getCallId()===e&&i.getAllTimerIds().forEach(e=>this._stopTimer.bind(this)(e,t))})}hangup(e,t){return f(this,void 0,void 0,function*(){const{callId:i,systemState:_,pushConfig:r}=e,s=r?J(r,this._clientCallId):"",{code:o}=yield this._signalModule.hangupCall({callId:i,sysStatus:_,pushExt:s,pushContent:(null==r?void 0:r.pushContent)||""},t);return this.endCurrentSession(e.systemState,i,t),{code:o}})}accept(e,t){return f(this,void 0,void 0,function*(){if(!this._mainSession)return{code:U.NOT_IN_CALL};const{callId:i}=e,{code:_}=yield this._signalModule.acceptCall({callId:i},t);return this._stopTimer(this._mainSession.getInviteeTimerId(),t),_!==U.SUCCESS||(this._clearMobileOnPhone(e.callId,t),this._mainSession.updateSessionState(y.CONNECTING)),{code:_}})}joinCall(e,t){return f(this,void 0,void 0,function*(){const i=this._context.getCurrentId();this._mainSession&&this._stopTimer(this._mainSession.getInviteeTimerId(),t);const{code:_}=yield this._signalModule.joinCall({callId:e.callId},t);return _!==U.SUCCESS||(this._abnormalModule.addAbnormallCallId(i,e.callId),this._mainSession?this._clearMobileOnPhone(e.callId,t):yield this._createSessionByServer(e.callId,t,!0)),{code:_}})}requestChangeMediaType(e,t){return f(this,void 0,void 0,function*(){if(!this._mainSession)return{code:U.NOT_IN_CALL};const i={mediaType:e.mediaType};this._mainSession.updateReqMediaType(e.mediaType);const _=ue(),{code:r}=yield this._signalModule.dialogUpCall({transactionId:_,callId:this._mainSession.getCallId(),toUserIds:e.toUserIds,dialogType:ie.SWITCH_MEDIA_TYPE,action:te.REQUEST,extraKeyVal:i},t);return r!==U.SUCCESS?{code:r}:{code:U.SUCCESS,data:{transactionId:_}}})}responseChangeMediaType(e,t){return f(this,void 0,void 0,function*(){return this._mainSession?this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:ie.SWITCH_MEDIA_TYPE,action:e.agree?te.ACCEPT:te.REFUSE},t):{code:U.NOT_IN_CALL}})}cancelChangeMediaType(e,t){return f(this,void 0,void 0,function*(){return this._mainSession?this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:ie.SWITCH_MEDIA_TYPE,action:te.CANCEL},t):{code:U.NOT_IN_CALL}})}getCallLogList(e,t){return f(this,void 0,void 0,function*(){const i=this._context.getCurrentId(),{timestamp:_,count:r,order:s}=e,{code:o,data:n}=yield this._signalModule.syncCallLog({userId:i,syncTime:_,count:r,order:s},t);if(o!==U.SUCCESS)return{code:o};const l=n.callLogList.map(e=>$(e));return{code:U.SUCCESS,data:{hasMore:Boolean(null==n?void 0:n.hasMore),syncTime:0===s?n.maxTime:n.minTime,list:l}}})}deleteCallLog(e,t){return f(this,void 0,void 0,function*(){const i=this._context.getCurrentId();return this._signalModule.deleteCallRecord(i,e,t)})}getCallServerTimestamp(e){return f(this,void 0,void 0,function*(){const{code:t,data:i}=yield this._signalModule.getCallServerTimestamp(e);return t!==U.SUCCESS?{code:t}:{code:t,data:i.syncTime}})}getCallTimeInfo(e,t){return f(this,void 0,void 0,function*(){return this._signalModule.getCallTimeInfo(e,t)})}getOpenCallList(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId(),{code:i,data:_}=yield this._signalModule.getUserCallStateList(e);if(i!==U.SUCCESS)return{code:i};return{code:i,data:_.callStateList.map(i=>{const{callId:_,callType:r,mediaType:s,callingUserId:o,callUserIds:n,callStatus:l,crtTime:a,userSessionStatus:c,startTime:L,syncTime:E}=i,d=o===t?Oe.OUT:Oe.IN,{clientStartTime:C=L}=this._timeCorrectioner.calcClientStartTime(_,L,e);return{callId:_,callType:r,callDirection:d,mediaType:s,callerUserId:o,callUserIds:n,sessionState:l,userState:c,startTimestamp:L,endTimestamp:0,duration:Math.floor((+new Date-C)/1e3),syncTimestamp:E,systemState:0,createTimestamp:a}})}})}removeAllCallLog(e){return f(this,void 0,void 0,function*(){const{code:t}=yield this._signalModule.clearCallRecord(e);return{code:t}})}getCallSession(e,t){return f(this,void 0,void 0,function*(){const{code:i,data:_}=yield this._signalModule.getCallSession(e,t);if(i!==U.SUCCESS)return{code:i};const{callId:r,callingUserId:s,callType:o,mediaType:n,callStatus:l,callSessionUsers:a,startTime:c,duration:L,syncTime:E}=_;return{code:i,data:{callId:r,startCallerId:s,callType:o,mediaType:n,sessionState:l,callSessionUsers:a.map(e=>{const{userId:t,sessionStatus:i,sysStatus:_,targetType:r,targetId:s}=e;return{userId:t,userState:i,systemState:_,targetType:r,targetId:s,cameraEnable:!1,microphoneEnable:!1}}),startTime:c,duration:L,syncTime:E}}})}getHoldSession(e){const t=this._holdSessions.find(t=>t&&t.getCallId()===e);return t?new H(t,this,this._logger,this._rtcModule,this._context):null}getLocalMainSession(){return this._mainSession?new H(this._mainSession,this,this._logger,this._rtcModule,this._context):null}updateMainSessionState(e){var t;null===(t=this._mainSession)||void 0===t||t.updateSessionState(e)}setIsLocalClientHangup(e){var t;null===(t=this._mainSession)||void 0===t||t.setIsLocalClientHangup(e)}updateUsersState(e,t,i){this._logger.info(v.L_CALL_ENGINE_UPDATE_USERS_STATE_O,`updateUsersState -> users: ${JSON.stringify(t)}`,i);const _=[this._mainSession,...this._holdSessions].find(t=>(null==t?void 0:t.getCallId())===e),r=[];return _?r.push(..._.updateUserList(t,i)):r.push(...t),r}getCallStaringTime(e,t){return f(this,void 0,void 0,function*(){return this._timeCorrectioner.getCallClientTimeByServer(e.callId,t)})}systemStatusUp(e,t){return f(this,void 0,void 0,function*(){return this._signalModule.sysStatusUp(e,t)})}upFirstFrameTime(e){return f(this,void 0,void 0,function*(){if(!this._mainSession||this._mainSession&&this._mainSession.getCallType()!==M.SINGLE||this._isUpFirstFrameTime)return{code:U.SUCCESS};const t=Date.now(),i=this._timeCorrectioner.getLocalDelayTime(),_=Math.floor(t+i);this._logger.info(v.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T,`now: ${t}; delay: ${i}; streamReadyTime: ${_}`,e),this._isUpFirstFrameTime=!0;const r=this._mainSession.getCallId(),{code:s}=yield this._signalModule.eventUpCall({callId:r,eventType:he.FIRST_FRAME,eventArgs:{streamReadyTime:_},eventTime:Date.now()},e);return this._logger.info(v.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R,`code: ${s}`,e),{code:s}})}endCurrentSession(e,t,i){const _=this._context.getCurrentId();if(this._mainSession&&this._mainSession.getCallId()===t){const t=this._mainSession.getUserList().map(t=>{let{userId:i,systemState:r,targetType:s,targetId:o}=t;return i===_&&(r=e),{userId:i,sessionStatus:P.ENDED,statusTime:Date.now(),duration:0,changed:1,inviteUserId:this._mainSession.getStartCallerId(),sysStatus:r,targetType:s,targetId:o}}),r={callId:this._mainSession.getCallId(),toDeviceId:this._signalModule.getDeviceId(),callStatus:y.ENDED,duration:0,callSessionUsers:t};this._onStatusDown(r,i)}}startTimeCorrection(e){this._timeCorrectioner.restart(e)}getDelayTimeInfo(){return{delayTime:this._timeCorrectioner.getLocalDelayTime(),rtt:this._timeCorrectioner.getRTT()}}upgradeMainSession(e){var t;const i=this._holdSessions.findIndex(t=>t.getCallId()===e);this._mainSession=null===(t=this._holdSessions.splice(i,1))||void 0===t?void 0:t[0]}endCurrentUserAbnormalCalls(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId(),i=yield this._abnormalModule.getAbnormalCallIds(t);if(!i)return{code:U.SUCCESS};const _=i.filter(e=>{var t;return e!==(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId())}),{code:r}=yield this._signalModule.endUserAbnormalCalls({callIds:_,allDevice:e?1:0});return r===U.SUCCESS&&this._abnormalModule.removeAbnormalCallIds(t,_),{code:r}})}setRTCModule(e){this._rtcModule=e}_onIMStateChange(e){const t=this._logger.createTraceId();let i=0;e===l.DISCONNECTED&&this._mainSession&&this._mainSession.getSessionState()!==y.ONCALL&&(i=le(()=>{var e;this._logger.info(v.L_CALL_ENGINE_IM_STATE_CHANGE_O,"endCurrentSession, IM disconnected for more than 60s",t),this.endCurrentSession(G.CONNECTION_ERR,null===(e=this._mainSession)||void 0===e?void 0:e.getCallId(),t)},6e4)),e===l.CONNECTED&&(i&&clearTimeout(i),this._initOpts.isAllowNewCallWhenRinging&&this.endCurrentUserAbnormalCalls(!0))}_handleCallTimeout(e,t,i){this._logger.warn(v.L_CALL_ENGINE_CALL_TIMEOUT_O,`call timeout callId: ${e}, userState: ${t}`,i);const _=[this._mainSession,...this._holdSessions].find(t=>t&&t.getCallId()===e);if(!_)return void this._logger.warn(v.L_CALL_ENGINE_CALL_TIMEOUT_O,`handleCallTimeout without session, callId: ${e}`,i);const r=this._context.getCurrentId();this._onStatusDown({callId:e,toDeviceId:this._signalModule.getDeviceId(),callStatus:y.ENDED,duration:0,callSessionUsers:_.getUserList().map(e=>{const{userId:i,targetType:s,targetId:o,stateTime:n}=e;let l,a;return i===r?(l=t===P.MISSED?G.MISSED:G.NO_ANSWER,a=t===P.MISSED?P.MISSED:P.NO_ANSWER):(l=t===P.MISSED?G.NO_ANSWER:G.MISSED,a=t===P.MISSED?P.NO_ANSWER:P.MISSED),{userId:i,sessionStatus:a,statusTime:n?n+1:Date.now(),duration:0,changed:1,inviteUserId:_.getCallerId(),sysStatus:l,targetType:s,targetId:o}})},i)}_startTimer(e,t,i){const _=le(()=>{this._handleCallTimeout(e,t,i),this._signalModule.statusUpCall({callId:e,sessionStatus:t},i)},6e4);return this._logger.info(v.L_CALL_ENGINE_START_CALL_TIMER_O,`callId: ${e}, timerId: ${_}`,i),_}_stopTimer(e,t){clearTimeout(e),this._logger.info(v.L_CALL_ENGINE_STOP_CALL_TIMER_O,`timerId: ${e}`,t)}_onInvite(e,t,i){this._clientCallId=c();const _=this._context.getCurrentId(),{callSessionUsers:r,secretChat:s,extra:o="{}"}=e;if(s===_e.SECRET)return void this.emit(Le.onPubInviteCallMiss,Object.assign(e,{extra:JSON.stringify(e),reason:Ee.SECRET_CALL,refer:t?de.PUB_INVITE:de.PULL_KV_INVITE}));r.some(e=>e.userId===_)&&this._selfIsInviteeHandle(e,t,i,o),this._othersIsInviteeHandle(e,i)}_selfIsInviteeHandle(e,t,i,_){const{callId:r,inviteUserId:s,callType:o,mediaType:n,callSessionUsers:l}=e,a=this._context.getCurrentId();this._abnormalModule.addAbnormallCallId(a,r);const c=new ne(r,y.RINGING,o,n,s,s,[],this._logger);this._signalModule.ringingCall({callId:r},i);const L=this._startTimer(r,P.MISSED,i);c.updateTimerId(re.INVITEE,L),this._mainSession?(this._holdSessions.push(c),this._mainSession.updateSessionState(y.BUSYLINE_WAIT)):this._mainSession=c;const E=new H(c,this,this._logger,this._rtcModule,this._context),d=t?Ne.PUB_INVITE_CALL:Ne.PULL_KV_INVITE_CALL;this.emit(pe.__INNER_INVITE__,E,d);const C=l.map(({userId:e,sessionStatus:t,sysStatus:i,targetType:_,targetId:r,statusTime:s})=>({userId:e,userState:t,systemState:i,targetType:_,targetId:r,stateTime:s})),T=this.updateUsersState(r,C,i);this._reportAppEventModule.onReceivedCall(E,i,JSON.parse(_||"{}").extra),T.length>0&&this.reportRemoteUserStateChange(r,T,i)}_othersIsInviteeHandle(e,t){var i,_,r;const{callId:s,inviteUserId:o,callSessionUsers:n}=e,l=this._context.getCurrentId(),a=n.filter(e=>e.userId!==l&&e.userId!==o&&e.sessionStatus===P.INVITED);if(!a.length)return;(null===(i=this._mainSession)||void 0===i?void 0:i.getCallType())===M.SINGLE&&(null===(_=this._mainSession)||void 0===_?void 0:_.getCallId())===s&&(this._onCallTypeChange(this._mainSession.getCallId(),M.MULTI,t),null===(r=this._mainSession)||void 0===r||r.updateCallType(M.MULTI));const c=[],L=[];a.forEach(e=>{const{userId:t,sessionStatus:i,sysStatus:_}=e;c.push({callId:s,userId:t,userState:i}),L.push({userId:t,userState:i,systemState:_})}),this._onOtherMemberInvite(c);const E=this.updateUsersState(s,L,t);E.length>0&&this.reportRemoteUserStateChange(s,E,t)}_onHangup(e,t,i){this._mainSession&&e.forEach(e=>{e.callId===this._mainSession.getCallId()&&(e.userState===P.CANCELLED?this._stopTimer(this._mainSession.getInviteeTimerId(),i):this._stopTimer(this._mainSession.getInviterTimerId(),i))})}_onAccept(e,t){var i,_,r,s;const o=null===(i=this._mainSession)||void 0===i?void 0:i.getSessionState(),n=[y.CONNECTING,y.ONCALL,y.BUSYLINE_WAIT];if((null===(_=this._mainSession)||void 0===_?void 0:_.getCallType())===M.SINGLE&&o&&n.includes(o))return;const l=this._mainSession.getStartCallerId(),a=this._context.getCurrentId();if((null===(r=this._mainSession)||void 0===r?void 0:r.getCallType())===M.SINGLE&&l===a){e.filter(e=>e.fromUserId!==a)&&this.emit(pe.__INNER_SESSION_CONNECT__,this.getLocalMainSession().getCallId(),t)}null===(s=this._mainSession)||void 0===s||s.updateSessionState(y.CONNECTING),this._stopTimer(this._mainSession.getInviterTimerId(),t)}_onStatusDown(e,t){var i,_;return f(this,void 0,void 0,function*(){const{callStatus:r,startTime:s,callId:o}=e;if(o!==(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId()))return;if(this._callStartMap[o]=this._callStartMap[o]||{},!this._callStartMap[o].isReceiveCallStartTime&&r===y.ONCALL){this._callStartMap[o].isReceiveCallStartTime=!0;const{code:e,clientStartTime:i}=this._timeCorrectioner.calcClientStartTime(o,s,t);e===Re.SUCCESS&&(this._callStartMap[o].callStartTime=i,this._reportAppEventModule.onReceivedCallStartTime({callId:o,callStartTime:i},t))}let n=!1;const l=this._context.getCurrentId(),a=e.callSessionUsers.map(e=>([P.IDLE,P.DECLINED,P.MISSED,P.NO_ANSWER,P.CANCELLED].includes(e.sessionStatus)&&e.sysStatus!==G.CANCELLED&&e.userId===l&&(n=!0),{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,stateTime:e.statusTime}));if(a.length){const e=this.updateUsersState(o,a,t);e.length>0&&this.reportRemoteUserStateChange(o,e,t)}if(!this._mainSession&&!this._holdSessions.length)return;const{hangupData:c,acceptData:L,otherInvitedData:E}=(e=>{const{callId:t}=e,i=[],_=[],r=[],s=[];return e.callSessionUsers.forEach(e=>{const{userId:o,sessionStatus:n,sysStatus:l}=e;switch(n){case P.INVITED:s.push({callId:t,userId:o,userState:n});break;case P.RINGING:i.push({callId:t,fromUserId:o});break;case P.CONNECTING:r.push({fromUserId:o});break;case P.CANCELLED:case P.DECLINED:case P.ENDED:case P.IDLE:_.push({callId:t,fromUserId:o,userState:n,systemState:l})}}),{ringingData:i,hangupData:_,acceptData:r,otherInvitedData:s}})(e);c.length>0&&this._onHangup(c,e.callStatus,t),L.length>0&&this._onAccept(L,t),E.length>0&&(null===(_=this._mainSession)||void 0===_?void 0:_.getCallType())===M.MULTI&&this._onOtherMemberInvite(E),(e.callStatus===y.ENDED||n)&&this._onSessionClose(e,t,n)})}_onOtherClientStatusDown(e,t){var i,_,r;const{callId:s,callSessionUsers:o}=e,n=this._context.getCurrentId(),l=o.find(({userId:e})=>e===n);if(l&&(this._mainSession||this._holdSessions.length)){const{userId:o,sessionStatus:a,statusTime:c}=l;if(a===P.CONNECTING){const l=[P.ONCALL,P.CONNECTING],L=(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())===s,E=null===(r=null===(_=this._mainSession)||void 0===_?void 0:_.getUserList().find(e=>e.userId===n))||void 0===r?void 0:r.userState;if(!(L&&E&&l.includes(E))){const i=this.updateUsersState(s,[{userId:o,userState:a,systemState:G.OTHER_CLIENT_ACCEPT,stateTime:c}],t);i.length>0&&this.reportRemoteUserStateChange(s,i,t),this._onSessionClose(e,t,!1)}}}}_onEventDown(e,t){var i;return f(this,void 0,void 0,function*(){const{callId:_,eventArgs:r,eventType:s}=e;if(_===(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())&&this._mainSession.getSessionState()===y.ONCALL&&s===he.CALL_DURATION){const{firstFrameTime:e}=r,{code:i,clientStartTime:s}=this._timeCorrectioner.calcClientStartTime(_,e,t);this._logger.info(v.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O,`clientFirstFrameTime: ${s}`,t),i===Re.SUCCESS&&(this._callStartMap[_].firstFrameTime=s,this._reportAppEventModule.onReceivedCallFirstFrameTime(_,s,t))}})}_onRecvSinCallDuration(e,t,i,_){var r;(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())===e&&(this._callStartMap[e].callStartTime=t,this._callStartMap[e].firstFrameTime=i,this._reportAppEventModule.onReceivedCallStartTime(Object.assign({callId:e},{callStartTime:t}),_),this._reportAppEventModule.onReceivedCallFirstFrameTime(e,i,_))}_onSwitchMediaType(e,t){var i,_,r,s,o;const{callId:n,action:l,extraKeyVal:a,transactionId:c,promoterId:L}=e,{mediaType:E,reason:d}=a,C=null===(i=this._mainSession)||void 0===i?void 0:i.getCallId();if(n!==C)return void this._logger.info(v.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,`not current session callId: ${C}, recvCallId: ${n}`,t);const{transactionId:T,action:I,mediaType:S}=(null===(_=this._mainSession)||void 0===_?void 0:_.getOldDialogData())||{};if(T!==c||I!==l||S!==E){if(this._logger.info(v.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,`action: ${l}, reason: ${d}`,t),null===(r=this._mainSession)||void 0===r||r.setOldDialogData({transactionId:c,action:l,mediaType:E}),l===te.REQUEST)this._onRequestChangeMediaType({transactionId:c,userId:L,mediaType:E},t);else{let e=null;switch(d){case te.CANCEL:e=b.CANCEL_CHANGE_MEDIA_TYPE;break;case te.ACCEPT:e=b.SERVER_ALLOW_MEDIA_TYPE,null===(s=this._mainSession)||void 0===s||s.updateMediaType(this._mainSession.getReqMediaType()),null===(o=this._mainSession)||void 0===o||o.updateReqMediaType(null);break;case te.REFUSE:e=b.REFUSE_CHANGE_MEDIA_TYPE;break;case te.TIMEOUT:e=b.CHANGE_MEDIA_TYPE_TIMEOUT}b[e]&&this._receiveMediaTypeChangeResult({transactionId:c,userId:L,mediaType:E},e,t)}l!==te.NOTICE||E!==D.AUDIO||d||this._receiveMediaTypeChangeResult({transactionId:c,userId:L,mediaType:E},b.SERVER_ALLOW_MEDIA_TYPE,t)}else this._logger.info(v.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"duplicate dialog data",t)}_onRecvCallEndLog(e,t){const i=$(e);this._reportAppEventModule.onReceivedCallRecord(i,t)}_onSessionClose(e,t,i){const{callId:_}=e,r=this._context.getCurrentId();this._abnormalModule.removeAbnormalCallIds(r,[_]);let s=[this._mainSession,...this._holdSessions].find(e=>e&&e.getCallId()===_);if(!s)return void this._logger.warn(v.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,`unexpect session callId -> ${_}`,t);this._logger.warn(v.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,`callId: ${_}`,t),this.emit(pe.__INNER_SESSION_CLOSE__,_,t);const o=s.getUserList().find(e=>e.userId===r);let n;n=i&&e.toDeviceId!==this._signalModule.getDeviceId()?s.getIsLocalClientHangup()?o.systemState:G.OTHER_CLIENT_HANGUP:o.systemState,this._reportAppEventModule.onCallEnded(new H(s,this,this._logger,this._rtcModule,this._context),n,t),this._reportCallPlusSummaryMessage(s,_,n),this._mainSession&&this._mainSession.getCallId()===_&&(this._mainSession.getAllTimerIds().forEach(e=>this._stopTimer.bind(this)(e,t)),s.getCallType()===M.SINGLE&&(this._isUpFirstFrameTime=!1),delete this._callStartMap[_]),this._removeSession(_)}_reportCallPlusSummaryMessage(e,t,i){var _,r,s;const o=this._context.getCurrentId(),l=e.getUserList().filter(({userId:e})=>e!==o)[0].userId,a=e.getStartCallerId();if(!localStorage.getItem(`missMessageMap-${o}-${t}`)){const c={callId:t,callerUserId:a,targetId:l,mediaType:e.getMediaType(),firstFrameTime:(null===(_=this._callStartMap[t])||void 0===_?void 0:_.firstFrameTime)||0,callStartTime:(null===(r=this._callStartMap[t])||void 0===r?void 0:r.callStartTime)||0,callEndTime:(null===(s=this._callStartMap[t])||void 0===s?void 0:s.callStartTime)?+new Date-this._timeCorrectioner.getLocalDelayTime():0,hangupReason:i};this._reportAppEventModule.onReceivedCallPlusSummaryMessage({messageType:"RC:CallPlusSummary",content:c,senderUserId:a,targetId:l,channelId:"",conversationType:L.PRIVATE,sentTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),receivedTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),messageUId:t,messageDirection:a===o?E.SEND:E.RECEIVE,isPersited:!0,isCounted:!1,isOffLineMessage:!1,canIncludeExpansion:!1,receivedStatus:d.READ,isStatusMessage:!1,isMentioned:!1,expansion:null,disableNotification:!1,sentStatus:n.SENT}),localStorage.setItem(`missMessageMap-${o}-${t}`,t)}}_removeSession(e){var t;if(e===(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId()))this._mainSession=null;else{const t=this._holdSessions.findIndex(t=>(null==t?void 0:t.getCallId())===e);this._holdSessions.splice(t,1)}}_createSessionByServer(e,t,i=!1){return f(this,void 0,void 0,function*(){this._logger.info(v.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T,`callId: ${e}`,t);const{code:_,data:r}=yield this.getCallSession({callId:e},t);if(_!==U.SUCCESS)return void this._logger.error(v.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,`errcode: ${_}`,t);this._logger.info(v.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,`code: ${_}, data: ${JSON.stringify(r)}`,t);const{callType:s,mediaType:o,callSessionUsers:n,startCallerId:l}=r;this._mainSession=new ne(e,y.CONNECTING,s,o,l,l,[],this._logger),i&&this._clearMobileOnPhone(e,t);const a=this.updateUsersState(e,n,t);a.length>0&&this.reportRemoteUserStateChange(e,a,t)})}_clearMobileOnPhone(e,t){return f(this,void 0,void 0,function*(){const i=[this._mainSession,...this._holdSessions].find(t=>(null==t?void 0:t.getCallId())===e);if(i&&i.getCallType()===M.MULTI){this._logger.info(v.L_CALL_ENGINE_UP_ON_PHONE_END_T,`callId: ${e}`,t);const{code:i}=yield this.systemStatusUp({callId:e,sysStatus:G.ON_PHONE_END,forward:Ae.CURRENT},t);i===U.SUCCESS?this._logger.info(v.L_CALL_ENGINE_UP_ON_PHONE_END_R,`callId: ${e}`,t):this._logger.warn(v.L_CALL_ENGINE_UP_ON_PHONE_END_R,`callId: ${e}, errCode: ${i}`,t)}})}reportRemoteUserStateChange(e,t,i){const _=this._context.getCurrentId();t.forEach(t=>{const{userId:r,userState:s,systemState:o}=t;r!==_&&this._reportAppEventModule.onRemoteUserStateChanged({callId:e,userId:r,userState:s,reason:o},i)}),t.forEach(({userId:t,systemState:r})=>{t===_&&r===G.ABNORMAL_END&&this.emit(pe.__INNER_SESSION_CLOSE__,e,i)})}_onOtherMemberInvite(e){e.forEach(e=>{var t;const{userId:i,callId:_}=e,r=null===(t=this.getLocalMainSession())||void 0===t?void 0:t.getInviterUserId();this._reportAppEventModule.onRemoteUserInvited([i],r,_)})}_onRequestChangeMediaType(e,t){var i;const{userId:_,transactionId:r,mediaType:s}=e;null===(i=this._mainSession)||void 0===i||i.updateReqMediaType(s),this._reportAppEventModule.onReceivedChangeMediaTypeRequest(_,r,s,t)}_receiveMediaTypeChangeResult(e,t,i){t===b.SERVER_ALLOW_MEDIA_TYPE&&this.emit(pe.__INNER_CHANGE_MEDIA_TYPE__,e.mediaType,i),this._reportAppEventModule.onReceivedChangeMediaTypeResult(Object.assign(Object.assign({},e),{code:t}),i)}_onCallTypeChange(e,t,i){this._reportAppEventModule.onCallTypeChanged(t,e,i)}}var fe,Ue;Object.defineProperty(pe,"__INNER_SESSION_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-close"}),Object.defineProperty(pe,"__INNER_SESSION_CONNECT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-connect"}),Object.defineProperty(pe,"__INNER_CHANGE_MEDIA_TYPE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-change-media-type"}),Object.defineProperty(pe,"__INNER_INVITE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-invite"}),function(e){e.NORMAL="RongCloudRTC",e.SCREEN="ScreenShare"}(fe||(fe={}));class ve extends r{constructor(e,t,i,_,r,s){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_room",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_callMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:h.W640_H480,frameRate:R.FPS_15}}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_isPubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_audioOutputDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_videoConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_audioConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_userViewMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_callPlusStatusReportListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_remoteAudioEnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"_preHangupCallId",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._rtcClient=null==i?void 0:i.rtcClient,this._isPubTiny=i.isPubTiny||!1}setCallPlusStatusReportListener(e){this._callPlusStatusReportListener=e}getCameraVideoTrack(e){return f(this,void 0,void 0,function*(){const t=this.getLocalVideoTrack(),{code:i,track:_}=t&&!this._videoConfigIsChange?{track:t,code:U.SUCCESS}:yield this._createVideoTrack(e);return this._videoConfigIsChange=!1,i!==U.SUCCESS?{code:i}:{code:U.SUCCESS,track:_}})}getMicrophoneAudioTrack(e){return f(this,void 0,void 0,function*(){const t=this.getLocalAudioTrack(),{code:i,track:_}=t&&!this._audioConfigIsChange?{track:t,code:U.SUCCESS}:yield this._createAudioTrack(e);return this._audioConfigIsChange=!1,i!==U.SUCCESS?{code:i}:{code:U.SUCCESS,track:_}})}createCallMediaTracks(e,t){return f(this,void 0,void 0,function*(){this._callMediaType=e;const{code:i}=yield this.getMicrophoneAudioTrack(t);if(i!==U.SUCCESS)return{code:i};if(e===D.AUDIO_VIDEO){const{code:e}=yield this.getCameraVideoTrack(t);e!==U.SUCCESS&&this._logger.warn(v.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P,`get camera video track error code: ${e}`,t)}return{code:U.SUCCESS}})}setVideoConfig(e){this._videoConfigIsChange=!0,this._videoConfig=e}setAudioConfig(e){this._audioConfigIsChange=!0,this._audioConfig=e}setAudioOutputDeviceId(e){return f(this,void 0,void 0,function*(){if("string"!=typeof e||0===e.length)return{code:U.PARAM_ERROR};if(this._audioOutputDeviceId===e)return{code:U.SUCCESS};if(this._audioOutputDeviceId=e,this._room){this._room.getRemoteTracks().filter(e=>e.isAudioTrack()).forEach(t=>{t.isSubscribed()&&t.play(void 0,{audioDeviceId:e})})}return{code:U.SUCCESS}})}destroyAllTracks(e){this._logger.info(v.L_RTC_MODULE_DESTROY_ALL_TRACKS_O,"",e),this._localTracks.forEach(e=>{e.destroy()}),this._localTracks.length=0}setAllRemoteAudioEnable(e,i){if(this._logger.info(v.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T,`enable: ${e}`,i),!t(e))return this._logger.error(v.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,`param error, enable: type is boolean, value: ${e}`),{code:U.PARAM_ERROR};if(this._remoteAudioEnable=e,!this._room)return{code:U.SUCCESS};return this._room.getRemoteTracks().filter(e=>e.isAudioTrack()).forEach(t=>{e?t.unmute():t.mute()}),this._logger.info(v.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,"success",i),{code:U.SUCCESS}}destroyTrack(e){return f(this,void 0,void 0,function*(){e.destroy();const t=this._localTracks.findIndex(t=>t.getTrackId()===e.getTrackId());this._localTracks.splice(t,1)})}sessionConnected(e,t){return f(this,void 0,void 0,function*(){if(this._preHangupCallId=null,this._logger.info(v.L_RTC_MODULE_SESSION_CONNECT_T,`callId: ${e}`,t),!this._room){const{code:i,room:_}=yield this.joinRTCRoom(e,t);if(i!==U.SUCCESS)return;if(this._room=_,this._preHangupCallId&&this._room.getRoomId()===this._preHangupCallId)return this._rtcClient.leaveRoom(this._room),void this._releaseStoredData();const r=this._room.getRemoteUserIds();this._onSelfJoined(e,r,t)}this._callId=e,this._regRTCListeners();let i=this._room.getRemoteTracks();if(i&&i.length&&this._onRemoteTrackPublish(i),this._localTracks.length>0){this.emit(Le.onBeforePublish);const e=this._isPubTiny?this._localTracks.map(e=>e.isVideoTrack()?{track:e,isPubTiny:!0}:e):this._localTracks,{code:i}=yield this.publish(e,t);this.emit(Le.onPublishRes,i)}else this._logger.warn(v.L_RTC_MODULE_SESSION_CONNECT_P,"sessionConnected local tracks is empty",t);this._logger.info(v.L_RTC_MODULE_SESSION_CONNECT_R,`code: ${U.SUCCESS}`,t)})}sessionClose(e,t){var i;return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_SESSION_CLOSE_T,`callId: ${e}`,t),this._preHangupCallId=e,this.destroyAllTracks(t);const _=null===(i=this._room)||void 0===i?void 0:i.getRoomId();if(this._room&&e===_){const{code:e}=yield this._rtcClient.leaveRoom(this._room);if(this._releaseStoredData(),e!==A.SUCCESS)return void this._logger.error(v.L_RTC_MODULE_SESSION_CLOSE_R,`leaveRoom failed, code: ${e}`,t);this._logger.info(v.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom success",t)}else this._logger.warn(v.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom throw exception: not in room",t)})}disableVideoTrack(){return f(this,void 0,void 0,function*(){const e=this.getLocalVideoTrack();if(!e)return{code:U.CAMERA_CLOSED};return{code:yield e.mute(),track:e}})}enableVideoTrack(e){return f(this,void 0,void 0,function*(){const e=this.getLocalVideoTrack();if(!e)return{code:U.CAMERA_CLOSED};if(!e.isOwnerMuted())return{code:U.SUCCESS};return{code:yield e.unmute()}})}changeVideoDevice(e){return f(this,void 0,void 0,function*(){const t=[],i=[],{code:_,track:r}=yield this._rtcClient.createCameraVideoTrack(fe.NORMAL,this._videoConfig);if(_!==A.SUCCESS)return{code:_};const{minBitrate:s,maxBitrate:o}=this._videoConfig;let n;if((s||o)&&r.setBitrate(o,s),this._localTracks&&this._localTracks.forEach(e=>{e.isVideoTrack()?(e.destroy(),n=e):i.push(e)}),this._localTracks=this._localTracks.filter(e=>n&&e.getTrackId()!==n.getTrackId()),t.push(r),i.push(r),this._localTracks=i,this._onLocalTrackReady(t,e),this._room){const{code:e}=yield this._room.publish(t);if(e!==A.SUCCESS)return{code:e}}return{code:U.SUCCESS,track:r}})}changeAudioDevice(e){return f(this,void 0,void 0,function*(){const t=[],i=[],_=Object.assign(Object.assign({},this._audioConfig),{micphoneId:this._audioConfig.microphoneId}),{code:r,track:s}=yield this._rtcClient.createMicrophoneAudioTrack(fe.NORMAL,_);if(r!==A.SUCCESS)return{code:r};if(this._localTracks&&this._localTracks.forEach(e=>{e.isAudioTrack()||i.push(e)}),t.push(s),i.push(s),this._localTracks=i,this._onLocalTrackReady(t,e),this._room){const{code:e}=yield this._room.publish(t);if(e!==A.SUCCESS)return{code:e}}return{code:U.SUCCESS}})}disableAudioTrack(){return f(this,void 0,void 0,function*(){const e=this.getLocalAudioTrack();if(!e)return{code:U.MICROPHONE_CLOSED};return{code:yield e.mute(),track:e}})}changeMediaType(e,t){return f(this,void 0,void 0,function*(){let i;this._logger.info(v.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T,`mediaType: ${e}`,t),i=e===D.AUDIO_VIDEO?yield this._upgradeMediaType(t):yield this._downgradeMediaType(t),i.code===U.SUCCESS&&this._logger.info(v.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"success",t)})}_upgradeMediaType(e){return f(this,void 0,void 0,function*(){let t=this.getLocalVideoTrack();if(!t){const{code:i,track:_}=yield this._createVideoTrack(e);if(i!==U.SUCCESS)return this._logger.error(v.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`create video track errCode: ${i}`,e),{code:i};t=_;const{minBitrate:r,maxBitrate:s}=this._videoConfig;(r||s)&&t.setBitrate(s,r)}const i=this._isPubTiny?{track:t,isPubTiny:!0}:t,{code:_}=yield this.publish([i],e);return _!==U.SUCCESS&&this._logger.error(v.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`publish errCode: ${_}`,e),{code:_}})}_downgradeMediaType(e){return f(this,void 0,void 0,function*(){const t=this.getLocalVideoTrack();if(t){const{code:i}=yield this._room.unpublish([t]);if(i!==A.SUCCESS)return this._logger.error(v.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`unpublish errCode: ${i}`,e),{code:i};this.destroyTrack(t)}return{code:U.SUCCESS}})}joinRTCRoom(e,t){return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_JOIN_RTC_ROOM_T,`call: ${e}`,t);const{code:i,room:_,tracks:r}=yield ce({asyncFn:this._rtcClient.joinRTCRoomWithOptions.bind(this._rtcClient),fnArgs:[e,{mode:C.CALL}]});return i!==A.SUCCESS?(this._logger.error(v.L_RTC_MODULE_JOIN_RTC_ROOM_R,`callId: ${e}, errCode: ${i}`,t),this._onRTCMethodFail(G.JOIN_ROOM_ERR,t),{code:i}):(this._logger.info(v.L_RTC_MODULE_JOIN_RTC_ROOM_R,"success",t),this._callId=e,{code:U.SUCCESS,room:_,tracks:r})})}subscribeTracks(e,t){return f(this,void 0,void 0,function*(){if(this._logger.info(v.L_RTC_MODULE_SUBSCRIBE_T,JSON.stringify({params:e.map(e=>{const{track:t,subTiny:i}=e;return{trackId:t.getTrackId(),subTiny:i}})}),t),!this._room)return{code:U.SUCCESS};const{code:i}=yield ce({asyncFn:this._room.subscribe.bind(this._room),fnArgs:[e],onError:e=>{}});return i!==A.SUCCESS?(this._reportAppEventModule.onFetchRemoteMediaError(e,i),this._onRTCMethodFail(G.SUBSCRIBE_ERR,t),this._logger.error(v.L_RTC_MODULE_SUBSCRIBE_R,`errorCode: ${i}`,t),{code:i}):(this._logger.info(v.L_RTC_MODULE_SUBSCRIBE_R,"success",t),{code:U.SUCCESS})})}unsubscribeTracks(e,t){return f(this,void 0,void 0,function*(){if(this._logger.info(v.L_RTC_MODULE_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map(e=>e.getTrackId())}),t),!this._room)return{code:U.SUCCESS};const{code:i}=yield this._room.unsubscribe(e);return i!==A.SUCCESS?(this._logger.error(v.L_RTC_MODULE_UNSUBSCRIBE_R,`errorCode: ${i}`,t),{code:i}):(this._logger.info(v.L_RTC_MODULE_UNSUBSCRIBE_R,"success",t),{code:U.SUCCESS})})}_releaseStoredData(){this._room=null,this._remoteAudioEnable=!0,this._userViewMap={},this._preHangupCallId=null}getRemoteTracks(){const e={};if(!this._room)return e;return this._room.getRemoteUserIds().forEach(t=>{e[t]=this._room.getRemoteTracksByUserId(t)}),e}getRemoteTrack(e,t){var i;return null===(i=this._room)||void 0===i?void 0:i.getRemoteTracksByUserId(e).find(e=>t===D.AUDIO?e.isAudioTrack():e.isVideoTrack())}getRTCSessionId(){return this._room?this._room.getSessionId():null}_regRTCListeners(){this._room.registerRoomEventListener({onKickOff:(e,t)=>{this._onKickOff(e,this._room.getRoomId(),t),this._releaseStoredData()},onUserJoin:e=>{const t=e.map(e=>({callId:this._callId,userId:e})),i=this._logger.createTraceId();this._onOtherMemJoined(t,i)},onUserLeave:e=>{e.forEach(e=>{delete this._userViewMap[e]})},onTrackPublish:this._onRemoteTrackPublish.bind(this),onTrackUnpublish:this._onTrackUnpublish.bind(this),onTrackReady:e=>{this._onRemoteTrackReady([e])},onVideoMuteChange:e=>{this._onVideoMuteChagne({fromUserId:e.getUserId(),muted:e.isOwnerMuted(),trackId:e.getTrackId()})},onAudioMuteChange:e=>{this._onAudioMuteChange({fromUserId:e.getUserId(),muted:e.isOwnerMuted(),trackId:e.getTrackId()})},onRTCPeerConnectionCloseByException:this._onRTCPeerConnectionCloseByException.bind(this)}),this._room.registerReportListener({onStateReport:this._onRTCStateReport.bind(this)}),this._room.onAudioLevelChange(e=>{this._reportAppEventModule.onUserAudioLevelChanged(e)})}_onLocalTrackReady(e,t){this._reportAppEventModule.onUserMediaAvailable(e,t)}_onRemoteTrackReady(e){this._reportAppEventModule.onUserMediaAvailable(e),this.emit(ve.__INNER_RECEIVE_FIRST_FRAME__)}_onKickOff(e,t,i,_){this._logger.info(v.L_RTC_MODULE_RECEIVE_KICK_OFF_O,`roonId: ${t}, byServer: ${e}, state: ${i}, kickExtra: ${JSON.stringify(_)}`);let r=G.CONNECTION_ERR;if(e)if(_)r=_.kickReasonCode;else switch(i){case N.SERVER_KICK:r=G.KICKED_BY_SERVER;break;case N.OTHER_KICK:r=G.OTHER_CLIENT_JOINED;break;case N.IM_DISCONNECTED:r=G.CONNECTION_ERR;break;case N.IM_LOGOUT:r=G.LOGOUT;break;case N.OTHER_CLIENT_IM_CONNECTED:r=G.OTHER_CLIENT_LOGIN}this.emit(ve.__INNER_ON_KICKOFF__,r,t)}_onRTCPeerConnectionCloseByException(){const e=this._logger.createTraceId();this._logger.info(v.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O,"",e),this.emit(ve.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,e)}_onSelfJoined(e,t,i){return f(this,void 0,void 0,function*(){this.emit(ve.__INNER_ON_SELF_JOINED__,e,t,i)})}_onRemoteTrackPublish(e){const t=this._logger.createTraceId();this._logger.info(v.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map(e=>e.getTrackId())}),t);const i=[];e.forEach(e=>{var t;const _=e.getUserId();if(e.isAudioTrack())i.push({track:e,subTiny:!1}),this._reportAppEventModule.onRemoteMicrophoneStateChanged(this._callId,e);else if(this._reportAppEventModule.onRemoteCameraStateChanged(this._callId,e),null===(t=this._userViewMap[_])||void 0===t?void 0:t.videoView){const{isTiny:t}=this._userViewMap[_];i.push({track:e,subTiny:t})}}),i.length&&this.subscribeTracks(i,t)}_onTrackUnpublish(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();this._logger.info(v.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map(e=>e.getTrackId())}),t),yield this.unsubscribeTracks(e,t)})}_onAudioMuteChange(e){const t=this._logger.createTraceId();this._logger.info(v.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);const i=this._room.getRemoteTrack(e.trackId);this._reportAppEventModule.onRemoteMicrophoneStateChanged(this._callId,i)}_onVideoMuteChagne(e){const t=this._logger.createTraceId();this._logger.info(v.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);const i=this._room.getRemoteTrack(e.trackId);this._reportAppEventModule.onRemoteCameraStateChanged(this._callId,i)}_onRTCStateReport(e){const{senders:t,receivers:i}=e;t.forEach(e=>{var t;const{kind:i,packetsLostRate:_,rtt:r}=e;this._callMediaType===D.AUDIO_VIDEO&&"audio"===i||null===(t=this._callPlusStatusReportListener)||void 0===t||t.onSendPacketLoss(_||0,r||0)}),i.forEach(e=>{var t;const{trackId:i,kind:_,packetsLostRate:r,bitrate:s}=e;if(this._callMediaType===D.AUDIO_VIDEO&&"audio"===_)return;const{userId:o}=O.parseTrackId(i),n={};n[o]={packetLostRate:r||0,bitRate:s},null===(t=this._callPlusStatusReportListener)||void 0===t||t.onReceivePacketLoss(n)})}_onRTCMethodFail(e,t){this.emit(ve.__INNER_RTC_PROCESS_FAILED__,e,t)}_onOtherMemJoined(e,t){this.emit(ve.__INNER_ON_OTHER_JOINED__,e,t)}_createAudioTrack(e){return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_CREATE_AUDIO_TRACK_T,"",e);const t=Object.assign(this._audioConfig,{micphoneId:this._audioConfig.microphoneId}),{code:i,track:_}=yield this._rtcClient.createMicrophoneAudioTrack(fe.NORMAL,t);if(i!==A.SUCCESS)return this._logger.error(v.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,`errCode: ${i}`,e),{code:i};this._logger.info(v.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,"success",e);const{minBitrate:r,maxBitrate:s}=this._audioConfig;return(r||s)&&_.setBitrate(s,r),this._localTracks.push(_),this._onLocalTrackReady([_],e),{code:U.SUCCESS,track:_}})}_createVideoTrack(e){return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_CREATE_VIDEO_TRACK_T,"",e);const{code:t,track:i}=yield this._rtcClient.createCameraVideoTrack(fe.NORMAL,this._videoConfig);if(t!==A.SUCCESS)return this._logger.error(v.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,`errCode: ${t}`,e),{code:t};this._logger.info(v.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,"success",e);const{minBitrate:_,maxBitrate:r}=this._videoConfig;return(_||r)&&i.setBitrate(r,_),this._localTracks.push(i),this._onLocalTrackReady([i],e),{code:U.SUCCESS,track:i}})}getLocalVideoTrack(){let e;return this._localTracks&&([e]=this._localTracks.filter(e=>e.isVideoTrack())),e}getLocalAudioTrack(){let e;return this._localTracks&&([e]=this._localTracks.filter(e=>e.isAudioTrack())),e}publish(e,t){return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_PUBLISH_T,`tracksIds: ${e.map(e=>e instanceof m?e.getTrackId():e.track.getTrackId())}`,t);const{code:i}=yield ce({asyncFn:this._room.publish.bind(this._room),fnArgs:[e],onError:e=>{}});return i!==A.SUCCESS?(this._onRTCMethodFail(G.PUBLISH_ERR,t),this._logger.error(v.L_RTC_MODULE_PUBLISH_R,`errCode: ${i}`,t),{code:i}):(this._logger.info(v.L_RTC_MODULE_PUBLISH_R,`code: ${U.SUCCESS}`,t),{code:U.SUCCESS})})}publishVideoTrack(){const e=this.getLocalVideoTrack(),t=this._isPubTiny?{track:e,isPubTiny:!0}:e;return this._room.publish([t])}setVideoView(e,t){const i=[];e.forEach(e=>{const{userId:t,videoElement:_,isTiny:r=!1}=e;if(this._userViewMap[t]={videoView:_,isTiny:r},t===this._context.getCurrentId())return;if(!this._room)return;const s=(this.getRemoteTracks()[t]||[]).map(e=>({track:e,subTiny:r}));i.push(...s)}),this._logger.info(v.L_RTC_MODULE_SET_VIDEO_VIEW_O,JSON.stringify({userViewMap:j(this._userViewMap),needSubTrackIds:i.map(({track:e})=>e.getTrackId())}),t),i.length&&this.subscribeTracks(i,t)}removeVideoView(e,t){const i=[];e.forEach(e=>{const t=this.getRemoteTracks()[e];if(t&&t.length){const e=t.filter(e=>e.isVideoTrack());e.length&&i.push(e[0])}delete this._userViewMap[e]}),this._logger.info(v.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O,JSON.stringify({userViewMap:j(this._userViewMap),unsubTracks:i.map(e=>e.getTrackId())}),t),i.length&&this.unsubscribeTracks(i,t)}getUserViewMap(){return this._userViewMap}playMedia(e,t,i,_){var r;return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_PLAY_MEDIA_T,`userId: ${e}, mediaType: ${t}, videoView: ${null==i?void 0:i.nodeName}`,_);const s=this._context.getCurrentId();if(e===s&&t===D.AUDIO)return this._logger.error(v.L_RTC_MODULE_PLAY_MEDIA_R,"please avoid playing local audio to prevent echoes.",_),{code:U.PLAY_MEDIA_FAILED};let o=null;if(o=e===s?t===D.AUDIO?null:this.getLocalVideoTrack():null===(r=this.getRemoteTracks()[e])||void 0===r?void 0:r.filter(e=>t===D.AUDIO?e.isAudioTrack():e.isVideoTrack())[0],!o)return this._logger.error(v.L_RTC_MODULE_PLAY_MEDIA_R,`error code: ${U.MEDIA_RESOURCE_INVALIED}`,_),{code:U.MEDIA_RESOURCE_INVALIED};try{const{code:e}=o.isAudioTrack()?yield o.play(void 0,{audioDeviceId:this._audioOutputDeviceId||void 0}):yield o.play(i);return o.isAudioTrack()&&!this._remoteAudioEnable&&o.mute(),e!==A.SUCCESS?(this._logger.error(v.L_RTC_MODULE_PLAY_MEDIA_R,`errCode: ${e}`,_),{code:e}):(this._logger.info(v.L_RTC_MODULE_PLAY_MEDIA_R,"success",_),{code:U.SUCCESS})}catch(e){return this._logger.error(v.L_RTC_MODULE_PLAY_MEDIA_R,`errCode: ${U.PLAY_MEDIA_FAILED}, message: ${e.message},`,_),{code:U.PLAY_MEDIA_FAILED}}})}}Object.defineProperty(ve,"__INNER_RTC_PROCESS_FAILED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-process-failed"}),Object.defineProperty(ve,"__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-peerconnection-abnormal-close"}),Object.defineProperty(ve,"__INNER_ON_SELF_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-self-joined"}),Object.defineProperty(ve,"__INNER_ON_OTHER_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-other-joined"}),Object.defineProperty(ve,"__INNER_RECEIVE_FIRST_FRAME__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-receive-first-frame"}),Object.defineProperty(ve,"__INNER_ON_KICKOFF__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-kickoff-frame"});class Me{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}registerEventListener(e){this._listener=e}_callAppListener(e,...t){var i;return f(this,void 0,void 0,function*(){const _=null===(i=this._listener)||void 0===i?void 0:i[e];if(_)try{yield _(...t)}catch(e){console.error(e),this._logger.error(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({name:e.name,message:e.message}))}})}onReceivedCall(e,t,i){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCall",callId:e.getCallId()}),t),this._callAppListener("onReceivedCall",e,i)}onRemoteUserInvited(e,t,i){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserInvited",inviteeUserList:e,inviterUserId:t,callId:i})),this._callAppListener("onRemoteUserInvited",e,t,i)}onCallConnected(e){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallConnected",callId:e.getCallId()})),this._callAppListener("onCallConnected",e)}onCallTypeChanged(e,t,i){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallTypeChanged",callId:t,callType:e}),i),this._callAppListener("onCallTypeChanged",e,t)}onRemoteUserStateChanged(e,t){const{callId:i,userId:_,userState:r,reason:s}=e;this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserStateChanged",callId:i,userId:_,userState:r,reason:s}),t),this._callAppListener("onRemoteUserStateChanged",i,_,r,s)}onCallEnded(e,t,i){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallEnded",callId:e.getCallId(),closeReason:t}),i),this._callAppListener("onCallEnded",e,t)}onRemoteCameraStateChanged(e,t){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteCameraStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));const i=null==t?void 0:t.getUserId();this._callAppListener("onRemoteCameraStateChanged",e,i,null==t?void 0:t.isOwnerMuted())}onRemoteMicrophoneStateChanged(e,t){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteMicrophoneStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));const i=null==t?void 0:t.getUserId();this._callAppListener("onRemoteMicrophoneStateChanged",e,i,null==t?void 0:t.isOwnerMuted())}onReceivedCallRecord(e,t){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallRecord",record:e}),t),this._callAppListener("onReceivedCallRecord",e)}onReceivedChangeMediaTypeRequest(e,t,i,_){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeRequest",userId:e,transactionId:t}),_),this._callAppListener("onReceivedChangeMediaTypeRequest",e,t,i)}onReceivedChangeMediaTypeResult(e,t){const{userId:i,transactionId:_,mediaType:r,code:s}=e;this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeResult",userId:i,mediaType:r}),t),this._callAppListener("onReceivedChangeMediaTypeResult",{userId:i,transactionId:_,mediaType:r,code:s})}onReceivedCallStartTime(e,t){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallStartTime",info:e}),t),this._callAppListener("onReceivedCallStartTime",e)}onReceivedCallFirstFrameTime(e,t,i){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallFirstFrameTime",callId:e,callFirstFrameTime:t}),i),this._callAppListener("onReceivedCallFirstFrameTime",e,t)}onUserMediaAvailable(e,t){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onUserMediaAvailable",trackIds:e.map(e=>e.getTrackId())}),t),e.forEach(e=>{const t=e.getUserId(),i=e.isAudioTrack()?D.AUDIO:D.VIDEO;this._callAppListener("onUserMediaAvailable",t,i)})}onFetchRemoteMediaError(e,t){e.forEach(({track:e})=>{const i=e.getUserId();this._callAppListener("onFetchRemoteMediaError",i,t)})}onUserAudioLevelChanged(e){e.forEach(({track:e,audioLevel:t})=>{const i=e.getUserId();this._callAppListener("onUserAudioLevelChanged",i,t)})}onReceivedCallPlusSummaryMessage(e){this._callAppListener("onReceivedCallPlusSummaryMessage",e)}onReceivedGroupCallStatusMessage(e){this._callAppListener("onReceivedGroupCallStatusMessage",e)}}!function(e){e[e.UNKNOW_ERR=41e3]="UNKNOW_ERR",e[e.DB_ERR=41001]="DB_ERR",e[e.JSON_ERR=41002]="JSON_ERR",e[e.INVALID_JSON_ERR=41003]="INVALID_JSON_ERR",e[e.MISSING_PARAMS=41004]="MISSING_PARAMS",e[e.PARAMS_REQUIRED=41005]="PARAMS_REQUIRED",e[e.DATA_FORMAT_ERR=41006]="DATA_FORMAT_ERR",e[e.METHOD_NOT_IMPLEMENTED=41007]="METHOD_NOT_IMPLEMENTED",e[e.CALL_NOT_EXIST=41010]="CALL_NOT_EXIST",e[e.SINGAL_EXCEED_TWO_INVITEE=41011]="SINGAL_EXCEED_TWO_INVITEE",e[e.GROUP_EXCEEDS_QUORUM=41012]="GROUP_EXCEEDS_QUORUM",e[e.OPERATION_EXPIRED=41013]="OPERATION_EXPIRED",e[e.DEVICE_IS_CALLING=41014]="DEVICE_IS_CALLING",e[e.REPORT_STREAM_READY_TIME_IS_INVALID=41018]="REPORT_STREAM_READY_TIME_IS_INVALID",e[e.NOT_CALL_YOURSELF=41019]="NOT_CALL_YOURSELF",e[e.SESSION_STATUS_NOT_EXIST=41020]="SESSION_STATUS_NOT_EXIST",e[e.HANGUP_NOT_ALLOW=41021]="HANGUP_NOT_ALLOW",e[e.ACCEPT_NOT_ALLOW=41022]="ACCEPT_NOT_ALLOW",e[e.OPERATION_NOT_ALLOW=41025]="OPERATION_NOT_ALLOW",e[e.TRANSACTION_ID_ERR=41100]="TRANSACTION_ID_ERR",e[e.UP_VIDEO_CANCELED=41050]="UP_VIDEO_CANCELED",e[e.CURRENT_CALL_IS_AUDIO=41051]="CURRENT_CALL_IS_AUDIO",e[e.CURRENT_CALL_IS_VIDEO=41052]="CURRENT_CALL_IS_VIDEO"}(Ue||(Ue={}));class Pe{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_androidPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}setChannelIdMi(e){return _(e)?(this._androidPushConfig.channelIdMi=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdMi type is string, value: ${e}`),this)}setTemplateIdMi(e){return _(e)?(this._androidPushConfig.templateIdMi=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: templateIdMi type is string, value: ${e}`),this)}setTemplateParamMi(e){if(!e||"object"!=typeof e||Array.isArray(e))return this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: templateParamMi type is object, value: ${JSON.stringify(e)}`),this;const t=Object.keys(e).find(t=>!_(t)||!_(e[t]));return void 0!==t?(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: templateParamMi.${t} key and value type is string, value: ${JSON.stringify(e)}`),this):(this._androidPushConfig.templateParamMi=Object.assign({},e),this)}setMiLargeIconUrl(e){return this._logger.warn(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"`setMiLargeIconUrl` has been deprecated."),this}setChannelIdHW(e){return _(e)?(this._androidPushConfig.channelIdHW=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdHW type is string, value: ${e}`),this)}setCategoryHW(e){return _(e)?(this._androidPushConfig.categoryHW=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: categoryHW type is string, value: ${e}`),this)}setImportanceHW(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: importanceHW value is NORMAL|LOW, value: ${e}`),this):(this._androidPushConfig.importanceHW=e,this)}setImageUrlHW(e){return _(e)?(this._androidPushConfig.imageUrlHW=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: imageUrlHW type is string, value: ${e}`),this)}setChannelIdOPPO(e){return _(e)?(this._androidPushConfig.channelIdOPPO=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdOPPO type is string, value: ${e}`),this)}setTypeVivo(e){return _(e)?(this._androidPushConfig.typeVivo=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: typeVivo type is string, value: ${e}`),this)}setCategoryVivo(e){return _(e)?(this._androidPushConfig.categoryVivo=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: categoryVivo type is string, value: ${e}`),this)}setFcmChannelId(e){return _(e)?(this._androidPushConfig.fcmChannelId=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmChannelId type is string, value: ${e}`),this)}setFcmCollapseKey(e){return _(e)?(this._androidPushConfig.fcmCollapseKey=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmCollapseKey type is string, value: ${e}`),this)}setFcmImageUrl(e){return _(e)?(this._androidPushConfig.fcmImageUrl=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmImageUrl type is string, value: ${e}`),this)}setimportanceHonor(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: importanceHonor value is NORMAL|LOW, value: ${e}`),this):(this._androidPushConfig.importanceHonor=e,this)}setimageUrlHonor(e){return _(e)?(this._androidPushConfig.imageUrlHonor=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: imageUrlHonor type is string, value: ${e}`),this)}build(){const e=Object.assign({},this._androidPushConfig);return e.templateParamMi&&(e.templateParamMi=Object.assign({},e.templateParamMi)),e}}class De{constructor(e,t,i,_){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:h.W640_H480,frameRate:R.FPS_15}}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_callPlusStatistics",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_isLaunchHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_needHangupCallId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"__rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._context.registerMessageType("RC:CallPlusMiss",!0,!1,[]),this._reportAppEventModule=new Me(t),this._callPlusStatistics=new oe(this._logger,this._context),this._callEngine=new pe(this._context,this._runtime,this._initOpts,this._logger,this._reportAppEventModule),this.__rtcClient=this._initOpts.rtcClient,this._rtcModule=new ve(this._context,this._runtime,this._initOpts,this._logger,this._callEngine,this._reportAppEventModule),this._callEngine.setRTCModule(this._rtcModule),this._rtcModule.on(ve.__INNER_RTC_PROCESS_FAILED__,this._rtcProcessFailHandle.bind(this)),this._rtcModule.on(ve.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,this._peerConnectionAbnormalClose.bind(this)),this._rtcModule.on(ve.__INNER_ON_SELF_JOINED__,this._selfJoinedHandle.bind(this)),this._rtcModule.on(ve.__INNER_ON_OTHER_JOINED__,this._otherJoinedHandle.bind(this)),this._rtcModule.on(ve.__INNER_RECEIVE_FIRST_FRAME__,this._receiveFirstFrameHandle.bind(this)),this._rtcModule.on(ve.__INNER_ON_KICKOFF__,this._kickoffHandle.bind(this)),this._callEngine.on(pe.__INNER_SESSION_CONNECT__,this._rtcModule.sessionConnected.bind(this._rtcModule)),this._callEngine.on(pe.__INNER_SESSION_CLOSE__,this._sessionCloseHandle.bind(this)),this._callEngine.on(pe.__INNER_CHANGE_MEDIA_TYPE__,this._rtcModule.changeMediaType.bind(this._rtcModule)),this._callEngine.on(pe.__INNER_INVITE__,(e,t)=>{this._callPlusStatistics.reportStatisticsData(ee.L_QS_RECEIVE_CALL_S,U.SUCCESS,+new Date,e,"",t)})}_rtcProcessFailHandle(e,t){const i=this._callEngine.getLocalMainSession();if(i){const _=i.getCallId();this._callEngine.systemStatusUp({callId:_,sysStatus:e,forward:Ae.CURRENT},t),this._callPlusStatistics.reportStatisticsData(ee.L_QS_ABNORMAL_HANGUP_S,U.SUCCESS,+new Date,i),this.__innerHangup({callId:_,systemState:e},t)}}_peerConnectionAbnormalClose(e){const t=this._callEngine.getLocalMainSession();t&&(this._callEngine.systemStatusUp({callId:t.getCallId(),sysStatus:G.CONNECTION_ERR,forward:Ae.CURRENT},e),this._callEngine.endCurrentSession(G.CONNECTION_ERR,t.getCallId(),e))}_selfJoinedHandle(e,t,i){return f(this,void 0,void 0,function*(){const _=this._context.getCurrentId(),r=this._callEngine.getLocalMainSession();((null==r?void 0:r.getCallType())===M.MULTI||t.length)&&this._callEngine.updateMainSessionState(y.ONCALL);const s=[_,...t].map(e=>({userId:e,userState:P.ONCALL,systemState:G.ONCALL})),o=this._callEngine.updateUsersState(e,s,i);this._reportAppEventModule.onCallConnected(r),o.length>0&&this._callEngine.reportRemoteUserStateChange(e,o,i),this._callEngine.startTimeCorrection(i)})}_otherJoinedHandle(e,t){var i;let _="";const r=e.map(e=>(_=e.callId,{userId:e.userId,userState:P.ONCALL,systemState:G.ONCALL})),s=this._callEngine.updateUsersState(_,r,t);s.length>0&&this._callEngine.reportRemoteUserStateChange(_,s,t),(null===(i=this._callEngine.getLocalMainSession())||void 0===i?void 0:i.getState())!==y.ONCALL&&this._callEngine.updateMainSessionState(y.ONCALL)}_receiveFirstFrameHandle(e){var t;(null===(t=this._callEngine.getLocalMainSession())||void 0===t?void 0:t.getState())!==y.ONCALL&&this._callEngine.updateMainSessionState(y.ONCALL),this._callEngine.upFirstFrameTime(e)}_kickoffHandle(e,t,i){if(e===G.CONNECTION_ERR)return void this._callEngine.endCurrentSession(e,t,i);const _=this._callEngine.getLocalMainSession();if(_){const r=_.getCallId();this._callPlusStatistics.reportStatisticsData(ee.L_QS_ABNORMAL_HANGUP_S,U.SUCCESS,+new Date,_,this._clientCallId),this._callEngine.systemStatusUp({callId:r,sysStatus:e,forward:Ae.CURRENT},i),this._callEngine.endCurrentSession(e,t,i)}}_sessionCloseHandle(e,t){this._isLaunchHangup||(this._clientCallId=""),this._isLaunchHangup=!1,this._rtcModule.sessionClose(e,t)}setCallPlusEventListener(e){this._logger.info(v.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._reportAppEventModule.registerEventListener(e)}setStatusReportListener(e){this._logger.info(v.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._rtcModule.setCallPlusStatusReportListener(e)}setVideoView(e){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T,JSON.stringify({list:e.map(e=>{const{userId:t,videoElement:i,isTiny:_}=e;return{userId:t,elementName:null==i?void 0:i.nodeName,isTiny:_}})}),t),!T(e))return this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, list: not empty array, value: ${JSON.stringify(e)}`,t),{code:U.PARAM_ERROR};for(const i of e){const{userId:e,videoElement:_}=i;if(!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, userId: not empty string, value: ${e}`,t),{code:U.PARAM_ERROR};if(!B(_))return this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, videoElement: need a video element, value: ${_ instanceof HTMLElement?_.nodeName:_}`,t),{code:U.PARAM_ERROR}}return this._logger.info(v.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"succes",t),this._rtcModule.setVideoView(e,t),{code:U.SUCCESS}}removeVideoView(e){const t=this._logger.createTraceId();return this._logger.info(v.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T,JSON.stringify({userIds:e}),t),T(e)&&e.every(e=>I(e))?(this._logger.info(v.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,"succes",t),this._rtcModule.removeVideoView(e,t),{code:U.SUCCESS}):(this._logger.error(v.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(e)}`,t),{code:U.PARAM_ERROR})}playMedia(e,t){return f(this,void 0,void 0,function*(){const _=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_PLAY_MEDIA_T,JSON.stringify({userId:e,mediaType:t}),_),!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`params err, userId: not empty string, value: ${e}`,_),{code:U.PARAM_ERROR};if(i(D[t]))return this._logger.error(v.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`params err, mediaType is illegal, value: ${t}`,_),{code:U.PARAM_ERROR};if(t===D.AUDIO&&e===this._context.getCurrentId())return this._logger.info(v.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"success",_),{code:U.SUCCESS};const{videoView:r}=this._rtcModule.getUserViewMap()[e]||{};return t===D.AUDIO||r?this._rtcModule.playMedia(e,t,r,_):(this._logger.error(v.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`errCode: ${U.VIDEO_VIEW_NOT_SET}, video view not set`,_),{code:U.VIDEO_VIEW_NOT_SET})})}createVideoConfigBuilder(){return new k(this._logger)}setVideoConfig(e){this._logger.info(v.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T,JSON.stringify(e));const{frameRate:t,resolution:i,maxBitrate:_,minBitrate:r}=e;if(!R[t])return this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,`param error, frameRate is illegal, value: ${t}`),{code:U.PARAM_ERROR};if(!h[i])return this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,`param error, resolution is illegal, value: ${i}`),{code:U.PARAM_ERROR};const{code:s,errorMsg:o}=F(r,_);return s!==U.SUCCESS&&this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,o),this._logger.info(v.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"success"),this._videoConfig=Object.assign({},e),this._rtcModule.setVideoConfig(this._videoConfig),{code:U.SUCCESS}}createAudioConfigBuilder(){return new w(this._logger)}createAndroidPushConfigBuilder(){return new Pe(this._logger)}setAudioConfig(t){this._logger.info(v.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T,JSON.stringify(t));const{sampleRate:i,minBitrate:_,maxBitrate:r}=t;if(i&&!e(i))return this._logger.error(v.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,`param error, sampleRate: type is number, value: ${i}`),{code:U.PARAM_ERROR};const{code:s,errorMsg:o}=F(_,r);return s!==U.SUCCESS&&this._logger.error(v.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,o),this._logger.info(v.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,"success"),this._audioConfig=Object.assign({},t),this._rtcModule.setAudioConfig(this._audioConfig),{code:U.SUCCESS}}setAudioOutputDeviceId(e){return this._logger.info(v.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O,e),this._rtcModule.setAudioOutputDeviceId(e)}startCall(e,t=M.SINGLE,r=D.AUDIO_VIDEO,s,o,n){return f(this,void 0,void 0,function*(){this._clientCallId=c();const a=+new Date,L=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_START_CALL_T,`userIds: ${e.join(",")}, callType: ${t}, mediaType: ${r}, pushConfig: ${JSON.stringify(s)}, extra: ${o}`,L),this._context.getConnectionStatus()!==l.CONNECTED)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${U.SIGNAL_DISCONNECTED}`,L),{code:U.SIGNAL_DISCONNECTED};const E=this._context.getNaviInfo();if(!E||!x(E))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${U.RTC_SERVICE_UNAVAILABLE}`,L),{code:U.RTC_SERVICE_UNAVAILABLE};if(!T(e)||!e.every(e=>I(e)))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(e)}`,L),{code:U.PARAM_ERROR};if(i(M[t]))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, callType is illegal, value: ${t}`,L),{code:U.PARAM_ERROR};if(i(D[r]))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, mediaType is illegal, value: ${r}`,L),{code:U.PARAM_ERROR};if(s){const e=W(s);if(e.code!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,L),{code:U.PARAM_ERROR}}if(o){if(!_(o))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, extra is illegal, type: string, value: ${o}`,L),{code:U.PARAM_ERROR};if(q(o)>Ce)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,"params err, extra max size is 128KB",L),{code:U.PARAM_ERROR}}if(e.length>1&&t===M.SINGLE)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, You can only call one person in a single call, userIds: ${e.join(",")}`,L),{code:U.PARAM_ERROR};if(n&&!_(n))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, targetId is illegal, type: string, value: ${n}`,L),{code:U.PARAM_ERROR};if(this._callEngine.getLocalMainSession())return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${U.SESSION_EXIST}, session exist`,L),{code:U.SESSION_EXIST};const{code:d}=yield this._rtcModule.createCallMediaTracks(r,L);if(d!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`create meida tracks error code: ${d}`,L),{code:d};const{code:C,data:S}=yield this._callEngine.startCall({toUsers:e.map(e=>({userId:e})),callType:t,mediaType:r,callId:this._clientCallId,pushConfig:s,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:o}),targetId:n},L);if(this._callPlusStatistics.reportStatisticsData(ee.L_QS_START_CALL_S,C,a,null,this._clientCallId,null,{mediaType:r,callType:t,callId:(null==S?void 0:S.callId)||""}),C!==U.SUCCESS)return this._rtcModule.destroyAllTracks(L),this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`signal error code: ${C}`,L),{code:C};const{callId:u,clientCallId:g}=S;return this._needHangupCallId===g?(this._callEngine.clearAllTimer(u,L),this._callEngine.hangup({callId:u,systemState:G.CANCELLED},L),this._logger.info(v.L_CALLPLUS_CLIENT_START_CALL_R,`the ${u} call has been hangup`,L),{code:U.SUCCESS}):(t===M.MULTI&&this._rtcModule.sessionConnected(u,L),this._logger.info(v.L_CALLPLUS_CLIENT_START_CALL_R,JSON.stringify({data:S,code:C}),L),{code:U.SUCCESS,callId:u})})}joinMultiCall(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T,`callId: ${e}`,t),this._context.getConnectionStatus()!==l.CONNECTED)return this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${U.SIGNAL_DISCONNECTED}`,t),{code:U.SIGNAL_DISCONNECTED};const i=this._context.getNaviInfo();if(!i||!x(i))return this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${U.RTC_SERVICE_UNAVAILABLE}`,t),{code:U.RTC_SERVICE_UNAVAILABLE};if(!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`params err, callId: not empty string, value: ${e}`,t),{code:U.PARAM_ERROR};const{code:_,data:r}=yield this._callEngine.getCallSession({callId:e},t);if(_!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`get call data error, code: ${_}`,t),{code:_};const{mediaType:s}=r,o=this._callEngine.getLocalMainSession();if(o&&o.getCallId()!==e)return{code:U.SESSION_EXIST};const{code:n}=yield this._rtcModule.createCallMediaTracks(s,t);if(n!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`create meida tracks error code: ${n}`,t),{code:n};const{code:a}=yield this._callEngine.joinCall({callId:e,mediaType:s},t);return a!==U.SUCCESS?(this._rtcModule.destroyAllTracks(t),this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`signal error code: ${a}`,t),{code:a}):(this._logger.info(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${U.SUCCESS}`,t),yield this._rtcModule.sessionConnected(e,t),{code:U.SUCCESS})})}invite(e,t,i){var r;return f(this,void 0,void 0,function*(){const s=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_INVITE_T,`callId: ${e.join(",")}, pushConfig: ${t}, extra: ${i}`,s),!T(e)||!e.every(e=>I(e)))return this._logger.error(v.L_CALLPLUS_CLIENT_INVITE_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(e)}`,s),{code:U.PARAM_ERROR};if(t){const e=W(t);if(e.code!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_INVITE_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,s),{code:U.PARAM_ERROR}}if(i){if(!_(i))return this._logger.error(v.L_CALLPLUS_CLIENT_INVITE_R,`params err, extra is illegal, value: ${i}`,s),{code:U.PARAM_ERROR};if(q(i)>Ce)return this._logger.error(v.L_CALLPLUS_CLIENT_INVITE_R,"params err, extra max size is 128KB",s),{code:U.PARAM_ERROR}}const{code:o,data:n}=yield this._callEngine.invite({toUsers:e.map(e=>({userId:e})),pushConfig:t,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:i})},s);if(o!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_INVITE_R,`signal error code: ${o}`,s),{code:o};const l=[];return(null===(r=n.busylineUsers)||void 0===r?void 0:r.length)&&l.push(...n.busylineUsers.map(e=>({userId:e.userId,state:e.sessionStatus}))),this._logger.info(v.L_CALLPLUS_CLIENT_INVITE_R,`success busyUsers: ${JSON.stringify(l)}`,s),{code:U.SUCCESS,busyUsers:l}})}accept(e,t){return f(this,void 0,void 0,function*(){const i=+new Date,_=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_ACCEPT_T,`callId: ${e}, pushConfig: ${t}`,_),this._context.getConnectionStatus()!==l.CONNECTED)return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode: ${U.SIGNAL_DISCONNECTED}`,_),{code:U.SIGNAL_DISCONNECTED};const r=this._context.getNaviInfo();if(!r||!x(r))return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode: ${U.RTC_SERVICE_UNAVAILABLE}`,_),{code:U.RTC_SERVICE_UNAVAILABLE};if(!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`params err, callId: not empty string, value: ${e}`,_),{code:U.PARAM_ERROR};if(t){const e=W(t);if(e.code!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,_),{code:U.PARAM_ERROR}}let s=this._callEngine.getLocalMainSession();const o=this._callEngine.getHoldSession(e);if(!s&&!o)return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode : ${U.NOT_IN_CALL}, session not exist`,_),{code:U.NOT_IN_CALL};if(e===(null==o?void 0:o.getCallId())){const{code:t}=yield this.hangup(s.getCallId());if(t!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`hangup mainSession error code: ${t}`,_),{code:t};this._callEngine.upgradeMainSession(e),s=this._callEngine.getLocalMainSession()}const n=s.getMediaType(),{code:a}=yield this._rtcModule.createCallMediaTracks(n,_);if(a!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`create meida tracks error code: ${a}`,_),{code:a};const{code:c}=yield this._callEngine.accept({callId:e},_);return this._callPlusStatistics.reportStatisticsData(ee.L_QS_ACCEPT_CALL_S,c,i,s),c!==U.SUCCESS?(this._rtcModule.destroyAllTracks(_),this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`signal error code: ${c}`,_),{code:c}):(this._logger.info(v.L_CALLPLUS_CLIENT_ACCEPT_R,"success",_),this._rtcModule.sessionConnected(e,_),{code:U.SUCCESS})})}__innerHangup(e,t){var i;return f(this,void 0,void 0,function*(){const{callId:_}=e;this._callEngine.setIsLocalClientHangup(!0),this._callEngine.clearAllTimer(_,t);const{code:r}=yield this._callEngine.hangup(e,t);return r===Ue.CALL_NOT_EXIST?{code:U.SUCCESS}:(r===U.SUCCESS&&_===(null===(i=this._callEngine.getLocalMainSession())||void 0===i?void 0:i.getCallId())&&(yield this._rtcModule.sessionClose(_,t)),{code:r})})}hangup(e,t){return f(this,void 0,void 0,function*(){const i=+new Date,r=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_HANGUP_T,`callId: ${e}, pushConfig: ${JSON.stringify(t)}`,r);const s=this._callEngine.getLocalMainSession();if(!s)return{code:U.NOT_IN_CALL};if(e&&!_(e))return this._logger.error(v.L_CALLPLUS_CLIENT_HANGUP_R,`params err, callId: type is string, value: ${e}`,r),{code:U.PARAM_ERROR};if(t){const e=W(t);if(e.code!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_HANGUP_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,r),{code:U.PARAM_ERROR}}const o=s.getCallId();if(e&&e!==o&&!this._callEngine.getHoldSession(e))return this._logger.error(v.L_CALLPLUS_CLIENT_HANGUP_R,`params err, callId is invalid, value: ${e}`,r),{code:U.CALL_ID_INVALID};this._isLaunchHangup=!0,this._needHangupCallId=e||o;const n=this._callEngine.getHoldSession(this._needHangupCallId)||s,l=this._context.getCurrentId(),a=((e,t)=>{let i;switch(e){case P.CALLING:i=G.CANCELLED;break;case P.RINGING:case P.INVITED:i=G.DECLINED;break;case P.CONNECTING:i=t?G.DECLINED:G.CANCELLED;break;case P.ONCALL:i=G.ENDED}return i})(s.getUserList().filter(e=>e.userId===l)[0].state,[s.getCreatorUserId(),s.getInviterUserId()].includes(l))||G.ENDED,{code:c}=yield this.__innerHangup({callId:this._needHangupCallId,systemState:a,pushConfig:t},r);return this._callPlusStatistics.reportStatisticsData(ee.L_QS_HANGUP_CALL_S,c,i,n,this._clientCallId),c!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_HANGUP_R,`signal error code : ${c}`,r),{code:c}):(this._needHangupCallId=null,this._logger.info(v.L_CALLPLUS_CLIENT_HANGUP_R,"success",r),{code:U.SUCCESS})})}requestChangeMediaType(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T,`mediaType: ${e}`,t),i(D[e]))return this._logger.error(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`params err, mediaType is illegal, value: ${e}`,t),{code:U.PARAM_ERROR};const _=this.getCurrentCallSession(),r=null==_?void 0:_.getMediaType();if(e===r)return this._logger.error(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`error code: ${U.MEDIATYPE_INVALID}`,t),{code:U.MEDIATYPE_INVALID};if(!this._callEngine.getLocalMainSession())return this._logger.error(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`error code : ${U.NOT_IN_CALL}, session not exist`,t),{code:U.NOT_IN_CALL};const s=null==_?void 0:_.getUserList().filter(e=>e.userId!==this._context.getCurrentId()).map(e=>e.userId),{code:o,data:n}=yield this._callEngine.requestChangeMediaType({mediaType:e,toUserIds:s||[]},t);return o!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`signal error code: ${o}`,t),{code:o}):(this._logger.info(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`success transactionId: ${n.transactionId}`,t),{code:U.SUCCESS,transactionId:n.transactionId})})}cancelChangeMediaType(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T,`transactionId: ${e}`,t),!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`param error, transactionId: not empty string, value: ${e}`,t),{code:U.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(v.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`error code : ${U.NOT_IN_CALL}, session not exist`,t),{code:U.NOT_IN_CALL};const{code:i}=yield this._callEngine.cancelChangeMediaType({transactionId:e},t);return i!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`signal error code: ${i}`,t),{code:i}):(this._logger.info(v.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"success",t),{code:U.SUCCESS})})}replyChangeMediaType(e,i){return f(this,void 0,void 0,function*(){const _=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T,`transactionId: ${e}`,_),!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`param error, transactionId: not empty string, value: ${e}`,_),{code:U.PARAM_ERROR};if(!t(i))return this._logger.error(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`param error, isAgree: type is boolean, value: ${i}`,_),{code:U.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`error code : ${U.NOT_IN_CALL}, session not exist`,_),{code:U.NOT_IN_CALL};const{code:r}=yield this._callEngine.responseChangeMediaType({transactionId:e,agree:i},_);return r!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`signal error: ${r}`,_),{code:r}):(this._logger.info(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"success",_),{code:U.SUCCESS})})}getCurrentCallSession(){return this._callEngine.getLocalMainSession()}getAvailableCallRecordsFromServer(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T,"",e);const{code:t,data:i}=yield this._callEngine.getOpenCallList(e);return t!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(v.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,`success, data: ${JSON.stringify(i)}`,e),{code:U.SUCCESS,records:i})})}getCallRecords(t,i,_=0){return f(this,void 0,void 0,function*(){const r=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T,`startTimestamp: ${t}, count: ${i}`,r),!(e(t)&&t>=0))return this._logger.error(v.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`params error, startTimestamp: is a number >= 0, value: ${t}`,r),{code:U.PARAM_ERROR};if(!(e(i)&&i>0))return this._logger.error(v.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`params error, count: is a number >= 0, value: ${i}`,r),{code:U.PARAM_ERROR};const{code:s,data:o}=yield this._callEngine.getCallLogList({timestamp:t,count:i,order:_},r);return s!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`signal error code: ${s}`,r),{code:s}):(this._logger.info(v.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"success",r),{code:U.SUCCESS,result:o})})}deleteCallRecordsFromServer(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T,`callIds: ${e.join(",")}`,t),!T(e)||!e.every(e=>I(e)))return this._logger.error(v.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,`params err, callIds: not empty array, callId: not empty string, callIds: ${JSON.stringify(e)}`,t),{code:U.PARAM_ERROR};const{code:i}=yield this._callEngine.deleteCallLog(e,t);return i!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,`signal error code: ${i}`,t),{code:i}):(this._logger.info(v.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"success",t),{code:U.SUCCESS})})}deleteAllCallRecordsFromServer(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T,"",e);const{code:t}=yield this._callEngine.removeAllCallLog(e);return t!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(v.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,"success",e),{code:U.SUCCESS})})}startCamera(){var e;return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_START_CAMERA_T,"",t);const{code:i,track:_}=yield this._rtcModule.getCameraVideoTrack(t);if(i!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CAMERA_R,`create video track error code: ${i}`,t),{code:i};if(!(null==_?void 0:_.isPublished())&&(null===(e=this._callEngine.getLocalMainSession())||void 0===e?void 0:e.getState())===y.ONCALL){const{code:e}=yield this._rtcModule.publishVideoTrack();return e!==A.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_START_CAMERA_R,`publish error code: ${e}`,t),{code:e}):(this._logger.info(v.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),{code:U.SUCCESS})}const{code:r}=yield this._rtcModule.enableVideoTrack(t);return r!==A.SUCCESS&&r!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_START_CAMERA_R,`signal error code: ${r}`,t),{code:r}):(this._logger.info(v.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),{code:U.SUCCESS})})}stopCamera(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_STOP_CAMERA_T,"",e);const{code:t,track:i}=yield this._rtcModule.disableVideoTrack();return t!==U.SUCCESS&&t!==A.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_STOP_CAMERA_R,`error code: ${t}`,e),{code:t}):(this._rtcModule.destroyTrack(i),this._logger.info(v.L_CALLPLUS_CLIENT_STOP_CAMERA_R,"success",e),{code:U.SUCCESS})})}switchCamera(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T,`cameraId: ${e}`,t),!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`param error, cameraId: not empty string, value: ${e}`,t),{code:U.PARAM_ERROR};const i=this._callEngine.getLocalMainSession();if(!i)return this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`errCode: ${U.NOT_IN_CALL}`,t),{code:U.NOT_IN_CALL};if(i.getMediaType()===D.AUDIO)return this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`errCode: ${U.NOT_VIDEO_CALL}`,t),{code:U.NOT_VIDEO_CALL};this._videoConfig.cameraId=e,this._rtcModule.setVideoConfig(this._videoConfig);const{code:_}=yield this._rtcModule.changeVideoDevice(t);return _!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`call client changeVideoDevice error code: ${_}`,t),{code:_}):(this._logger.info(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"success",t),{code:U.SUCCESS})})}startMicrophone(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_START_MICROPHONE_T,"",e);const{code:t,track:i}=yield this._rtcModule.getMicrophoneAudioTrack(e);if(t!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_START_MICROPHONE_R,`create microphone audio track error code: ${t}`,e),{code:t};if(!i.isOwnerMuted())return this._logger.info(v.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),{code:U.SUCCESS};const _=yield i.unmute();return _!==A.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_START_MICROPHONE_R,`signal error code: ${t}`,e),{code:_}):(this._logger.info(v.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),{code:U.SUCCESS})})}stopMicrophone(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T,"",e);const{code:t}=yield this._rtcModule.disableAudioTrack();return t!==U.SUCCESS&&t!==A.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(v.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,"success",e),{code:U.SUCCESS})})}isMicrophoneEnabled(){const e=this._rtcModule.getLocalAudioTrack();return!!e&&!e.isOwnerMuted()}setAllRemoteAudioEnable(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();return this._rtcModule.setAllRemoteAudioEnable(e,t)})}getVersion(){return"2.48.0"}getCameras(){return f(this,void 0,void 0,function*(){return p.getCameras()})}getMicrophones(){return f(this,void 0,void 0,function*(){return p.getMicrophones()})}getSpeakers(){return f(this,void 0,void 0,function*(){return p.getSpeakers()})}getRTCSessionId(){return this._rtcModule.getRTCSessionId()}switchMicrophone(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T,`microphoneId: ${e}`,t),!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`param error, microphoneId: not empty string, value: ${e}`,t),{code:U.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`errCode: ${U.NOT_IN_CALL}`,t),{code:U.NOT_IN_CALL};this._audioConfig.microphoneId=e,this._rtcModule.setAudioConfig(this._audioConfig);const{code:i}=yield this._rtcModule.changeAudioDevice(t);return i!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`call client changeAudioDevice error code: ${i}`,t),{code:i}):(this._logger.info(v.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"success",t),{code:U.SUCCESS})})}}u.add("callplus","2.48.0");const ye={tag:"RCCallPlus",verify:e=>!!u.validEngine("5.48.0")||(console.error(`The current engine version '${u.getInfo().engine}' error, plugin-call-plus required engine version at least '5.48.0'.`),!1),setup(e,t,_){const r=(s=_)?S(s)?Object.keys(s).includes("rtcClient")?S(s.rtcClient)?{isLegal:!0}:{isLegal:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:{isLegal:!1,code:U.NOT_INSTALL_RTC_PLUGIN}:{isLegal:!1,msg:"Initialization options must be an object"}:{isLegal:!1,msg:"Initialization missing parameter -> options"};var s;if(!r.isLegal)throw new Error(`[CallPlusLib installer steup]${r.msg}`);i(_.isAllowNewCallWhenRinging)&&(_.isAllowNewCallWhenRinging=!0);const o=e.createLogger("CallPlus","RTC"),n=i(_.logOutputLevel)?g.WARN:_.logOutputLevel;return o.setOutputLevel(n),o.warn(v.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O,`CallPlus Version: 2.48.0, Commit: b76edf41b74ea423e7c0818b765ec19e41b5b3a9, isAllowNewCallWhenRinging: ${_.isAllowNewCallWhenRinging}`),new De(e,o,t,_)}};export{V as IGroupCallStatusMessageType,w as RCAudioConfigBuilder,Pe as RCCallPlusAndroidPushConfigBuilder,y as RCCallPlusCallState,De as RCCallPlusClient,U as RCCallPlusCode,D as RCCallPlusMediaType,b as RCCallPlusMediaTypeChangeResult,G as RCCallPlusReason,H as RCCallPlusSession,P as RCCallPlusSessionUserState,M as RCCallPlusType,k as RCVideoConfigBuilder,ye as installer};
|