@rongcloud/plugin-call-plus 2.44.0 → 2.46.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 +27 -2
- package/index.esm.js +1 -1
- package/index.js +1 -1
- package/package.json +3 -3
- package/wrapper/index.esm.js +1 -1
- package/wrapper/index.js +1 -1
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@rongcloud/engine"),t=require("@rongcloud/plugin-rtc");function i(e,t,i,r){return new(i||(i=Promise))(function(_,s){function o(e){try{n(r.next(e))}catch(e){s(e)}}function l(e){try{n(r.throw(e))}catch(e){s(e)}}function n(e){var t;e.done?_(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,l)}n((r=r.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const r={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 _,s,o,l,n,a,C,c;!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"}(_||(_={}));class L{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:r}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:_}),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 r=null,_=null;return t===this._context.getCurrentId()?(r=this._rtcModule.getLocalVideoTrack(),_=this._rtcModule.getLocalAudioTrack()):(r=this._rtcModule.getRemoteTrack(t,exports.RCCallPlusMediaType.VIDEO),_=this._rtcModule.getRemoteTrack(t,exports.RCCallPlusMediaType.AUDIO)),{userId:t,state:i,cameraEnable:!!r&&!r.isOwnerMuted(),microphoneEnable:!!_&&!_.isOwnerMuted()}})}getCreatorUserId(){return this._session.getStartCallerId()}getInviterUserId(){return this._session.getCallerId()}getCreateTimestamp(){return i(this,void 0,void 0,function*(){const e=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_SESSION_GET_CREATE_TIME_T,"",e),this._startTime)return{code:r.SUCCESS,startTime:this._startTime};const{code:t,clientStartTime:i}=yield this._callEngine.getCallStaringTime({callId:this._callId},e);return t!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,`errCode: ${t}`,e),{code:t}):(this._logger.info(_.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,"success",e),this._startTime=i,{code:r.SUCCESS,startTime:this._startTime})})}getDuration(){return i(this,void 0,void 0,function*(){const e=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_SESSION_GET_DURATION_T,"",e),this._duration)return this._logger.info(_.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${r.SUCCESS}, duration: ${this._duration}`,e),{code:r.SUCCESS,duration:this._duration};const{code:t,data:i}=yield this._callEngine.getCallTimeInfo(this._callId,e);return t!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${t}`,e),{code:t}):(this._logger.info(_.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${r.SUCCESS}, duration: ${i.duration}`,e),this._duration=i.duration,{code:r.SUCCESS,duration:this._duration})})}}(s=exports.RCCallPlusType||(exports.RCCallPlusType={}))[s.SINGLE=0]="SINGLE",s[s.MULTI=1]="MULTI",(o=exports.RCCallPlusSessionUserState||(exports.RCCallPlusSessionUserState={}))[o.IDLE=0]="IDLE",o[o.CALLING=100]="CALLING",o[o.INVITED=101]="INVITED",o[o.RINGING=102]="RINGING",o[o.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",o[o.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",o[o.CONNECTING=200]="CONNECTING",o[o.ONCALL=300]="ONCALL",o[o.ONPHONE=301]="ONPHONE",o[o.ENDED=1e3]="ENDED",o[o.NO_ANSWER=1001]="NO_ANSWER",o[o.MISSED=1002]="MISSED",o[o.CANCELLED=1003]="CANCELLED",o[o.DECLINED=1004]="DECLINED",o[o.ERROR=2e3]="ERROR",(l=exports.RCCallPlusMediaType||(exports.RCCallPlusMediaType={}))[l.AUDIO=0]="AUDIO",l[l.AUDIO_VIDEO=1]="AUDIO_VIDEO",l[l.VIDEO=2]="VIDEO",(n=exports.RCCallPlusCallState||(exports.RCCallPlusCallState={}))[n.IDLE=0]="IDLE",n[n.CALLING=100]="CALLING",n[n.INVITED=101]="INVITED",n[n.RINGING=102]="RINGING",n[n.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",n[n.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",n[n.CONNECTING=200]="CONNECTING",n[n.ONCALL=300]="ONCALL",n[n.ENDED=1e3]="ENDED",n[n.NOANSWER=1001]="NOANSWER",n[n.MISSED=1002]="MISSED",n[n.CANCELED=1003]="CANCELED",n[n.DECLINED=1004]="DECLINED",n[n.ERROR=2e3]="ERROR",(a=exports.RCCallPlusMediaTypeChangeResult||(exports.RCCallPlusMediaTypeChangeResult={}))[a.CANCEL_CHANGE_MEDIA_TYPE=0]="CANCEL_CHANGE_MEDIA_TYPE",a[a.REFUSE_CHANGE_MEDIA_TYPE=1]="REFUSE_CHANGE_MEDIA_TYPE",a[a.SERVER_ALLOW_MEDIA_TYPE=2]="SERVER_ALLOW_MEDIA_TYPE",a[a.CHANGE_MEDIA_TYPE_TIMEOUT=3]="CHANGE_MEDIA_TYPE_TIMEOUT",(C=exports.RCCallPlusReason||(exports.RCCallPlusReason={}))[C.IDLE=0]="IDLE",C[C.CALLING=100]="CALLING",C[C.INVITED=101]="INVITED",C[C.RINGING=102]="RINGING",C[C.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",C[C.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",C[C.CONNECTING=200]="CONNECTING",C[C.ONCALL=300]="ONCALL",C[C.ON_PHONE=301]="ON_PHONE",C[C.ON_PHONE_END=302]="ON_PHONE_END",C[C.ON_DEVICE_DISABLE=303]="ON_DEVICE_DISABLE",C[C.ON_DEVICE_ENABLE=304]="ON_DEVICE_ENABLE",C[C.ABNORMAL_END=999]="ABNORMAL_END",C[C.ENDED=1e3]="ENDED",C[C.NO_ANSWER=1001]="NO_ANSWER",C[C.MISSED=1002]="MISSED",C[C.CANCELLED=1003]="CANCELLED",C[C.DECLINED=1004]="DECLINED",C[C.OTHER_CLIENT_CALLING=1010]="OTHER_CLIENT_CALLING",C[C.OTHER_CLIENT_ACCEPT=1011]="OTHER_CLIENT_ACCEPT",C[C.JOIN_ROOM_ERR=1105]="JOIN_ROOM_ERR",C[C.PUBLISH_ERR=1106]="PUBLISH_ERR",C[C.SUBSCRIBE_ERR=1107]="SUBSCRIBE_ERR",C[C.ACCEPT_CARRIER=1108]="ACCEPT_CARRIER",C[C.KICKED_BY_SERVER=1109]="KICKED_BY_SERVER",C[C.CONNECTION_ERR=1110]="CONNECTION_ERR",C[C.LOGOUT=1111]="LOGOUT",C[C.OTHER_CLIENT_LOGIN=1112]="OTHER_CLIENT_LOGIN",C[C.OTHER_CLIENT_JOINED=1113]="OTHER_CLIENT_JOINED",C[C.OTHER_CLIENT_IN_ROOM=1114]="OTHER_CLIENT_IN_ROOM",C[C.OTHER_CLIENT_HANGUP=1151]="OTHER_CLIENT_HANGUP",C[C.REMOTE_JOIN_RTC_ERROR=1205]="REMOTE_JOIN_RTC_ERROR",C[C.REMOTE_PUBLISH_ERROR=1206]="REMOTE_PUBLISH_ERROR",C[C.REMOTE_SUBSCRIBE_ERROR=1207]="REMOTE_SUBSCRIBE_ERROR",C[C.REMOTE_KICKED_BY_SERVER=1209]="REMOTE_KICKED_BY_SERVER",C[C.REMOTE_CONNECTION_ERROR=1210]="REMOTE_CONNECTION_ERROR",C[C.REMOTE_LOGOUT=1211]="REMOTE_LOGOUT",C[C.REMOTE_OTHER_CLIENT_LOGIN=1212]="REMOTE_OTHER_CLIENT_LOGIN",C[C.REMOTE_OTHER_JOINED_RTC=1213]="REMOTE_OTHER_JOINED_RTC",C[C.REMOTE_OTHER_CLIENT_IN_RTC=1214]="REMOTE_OTHER_CLIENT_IN_RTC",(c=exports.IGroupCallStatusMessageType||(exports.IGroupCallStatusMessageType={}))[c.START=1]="START",c[c.END=2]="END";class E{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.isNumber(t)||!e.isNumber(i)||i<=0||t<=0||i<t?(this._logger.error(_.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.isNumber(t)?(this._audioConfig.sampleRate=t,this):(this._logger.error(_.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O,`params error -> sampleRate: ${t}`),this)}build(){return this._audioConfig}}class d{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:t.RCResolution.W640_H480,frameRate:t.RCFrameRate.FPS_15}})}setFrameRate(e){return t.RCFrameRate[e]?(this._videoConfig.frameRate=e,this):(this._logger.error(_.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O,`params error -> fps: ${e}`),this)}setVideoResolution(e){return t.RCResolution[e]?(this._videoConfig.resolution=e,this):(this._logger.error(_.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.isNumber(t)||!e.isNumber(i)||i<=0||t<=0||i<t?(this._logger.error(_.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 T=e=>{const{callId:t,callType:i,callDir:r,mediaType:_,callingUserId:s,callUserIds:o,callStatus:l,sessionStatus:n,startTime:a,endTime:C,duration:c,syncTime:L,sysStatus:E,crtTime:d}=e;return{callId:t,callType:i,callDirection:r,mediaType:_,callerUserId:s,callUserIds:o,sessionState:l,userState:n,startTimestamp:a,endTimestamp:C,duration:c,syncTimestamp:L,systemState:E,createTimestamp:d}},u=e=>e&&e.nodeName&&"VIDEO"===e.nodeName.toUpperCase(),S=e=>{const{voipCallInfo:t}=e;if(!t)return!1;const{strategy:i}=JSON.parse(t);return 1===i},I=(t,i)=>!t&&0!==t||e.isNumber(t)&&!(t<=0)?!i&&0!==i||e.isNumber(i)&&!(i<=0)?t&&i&&i<t?{code:r.PARAM_ERROR,errorMsg:`params error -> maxBitrate: ${i}, minBitrate: ${t}, maxBitrate should > minBitrate`}:{code:r.SUCCESS}:{code:r.PARAM_ERROR,errorMsg:`params error -> maxBitrate: a number of > 0, value: ${i}`}:{code:r.PARAM_ERROR,errorMsg:`params error -> minBitrate: a number of > 0, value: ${t}`},R=e=>{const t=[];for(const i in e){const{videoView:r,isTiny:_}=e[i];t.push({userId:i,videoView:r.nodeName,isTiny:_})}return t},g=(e,t={},i={})=>{const{threadId:r,apnsCollapseId:_,richMediaUri:s}=t,{channelIdMi:o,channelIdHW:l,channelIdOPPO:n,typeVivo:a,fcmChannelId:C,fcmCollapseKey:c,fcmImageUrl:L,importanceHW:E,categoryHW:d,imageUrlHW:T,categoryVivo:u,importanceHonor:S,imageUrlHonor:I}=i,R={};r&&(R["thread-id"]=r),R["apns-collapse-id"]=_||e,s&&(R.richMediaUri=s);const g={};l&&(g.channelId=l),T&&(g.image=T),d&&(g.category=d),g.importance=E||"NORMAL";const h=[{HW:g},{APNS:R}];let A,N,O,p;return(c||L||C)&&(A={},c&&(A.collapse_key=c),L&&(A.imageUrl=L),C&&(A.channelId=C),h[0].FCM=A),o&&(h[0].MI={channelId:o}),n&&(N={},N.channelId=n,h[0].OPPO=N),(a||u)&&(O={},a&&(O.classification=a),u&&(O.category=u),h[0].VIVO=O),(S||I)&&(p={},S&&(p.importance=S),I&&(p.image=I),h[0].HONOR=p),JSON.stringify(h)},h=(t,i)=>{const{pushTitle:r="",iOSConfig:_,androidConfig:s,disablePushTitle:o,templateId:l}=t,n={pushConfigs:g(i,_,s)};return e.isBoolean(o)&&(n.disableTitle=o),r&&(n.title=r),l&&(n.templateId=l),JSON.stringify(n)},A=t=>{const i=["pushTitle","pushContent","iOSConfig","androidConfig","disablePushTitle","templateId"];if(!Object.keys(t).every(e=>i.includes(e)))return{code:r.PARAM_ERROR,errorMsg:`right key: ${i.join(",")}`};for(let _=0;_<i.length;_++){const s=i[_];if("disablePushTitle"===s){if(!e.isUndefined(t[s])&&!e.isBoolean(t[s]))return{code:r.PARAM_ERROR,errorMsg:`${s} type is boolean`}}else if(("pushTitle"===s||"templateId"===s||"pushContent"===s)&&t[s]&&!e.isString(t[s]))return{code:r.PARAM_ERROR,errorMsg:`${s} type is string`}}const{iOSConfig:_,androidConfig:s}=t,o=N(_||{});if(o.code!==r.SUCCESS)return o;const l=O(s||{});return l.code!==r.SUCCESS?l:{code:r.SUCCESS}},N=t=>{const{threadId:i,richMediaUri:_}=t||{};return i&&!e.isString(i)?{code:r.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:_&&!e.isString(_)?{code:r.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:r.SUCCESS}},O=t=>{const i=["channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"];if(!Object.keys(t).every(e=>i.includes(e)))return{code:r.PARAM_ERROR,errorMsg:`right key: ${i.join(",")}`};for(let _=0;_<i.length;_++){const s=i[_];if("importanceHW"===s||"importanceHonor"===s){if(t[s]&&"LOW"!==t[s]&&"NORMAL"!==t[s])return{code:r.PARAM_ERROR,errorMsg:`androidConfig.${s} value is NORMAL|LOW`}}else if(t[s]&&!e.isString(t[s]))return{code:r.PARAM_ERROR,errorMsg:`androidConfig.${s} type is string`}}return{code:r.SUCCESS}},p=(e,t="utf-8")=>{let i=0;return i="utf-16"===t?m(e):P(e),i},m=e=>{let t,i=0;for(let r=0,_=e.length;r<_;r++)t=e.charCodeAt(r),i+=t<=65535?2:4;return i},P=e=>{let t,i=0;for(let r=0,_=e.length;r<_;r++)t=e.charCodeAt(r),i+=t<127?1:t<=2047?2:t<=65535?3:4;return i},U=/Electron/.test(navigator.userAgent);var f,M,v,y,D,b;!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"}(f||(f={}));class G{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 l=+new Date,{mediaType:n,callType:a,callId:C}=r?{mediaType:r.getMediaType(),callType:r.getCallType(),callId:r.getCallId()}:o,c={cr:"unknown",net:"unknown",cod:t,mtp:n,ctp:a,cid:C,time:l,uid:this._context.getCurrentId()};_&&Object.assign(c,{ccid:_});let L=null;switch(e){case f.L_QS_RECEIVE_CALL_S:L=Object.assign(Object.assign({},c),{rf:s});break;case f.L_QS_ABNORMAL_HANGUP_S:L=Object.assign({},c);break;default:L=Object.assign(Object.assign({},c),{dur:l-i})}this._logger.__statistics(e,JSON.stringify(L))}}!function(e){e.REQUEST="request",e.ACCEPT="accept",e.REFUSE="refuse",e.CANCEL="cancel",e.NOTICE="notice",e.TIMEOUT="timeout"}(M||(M={})),function(e){e[e.SWITCH_MEDIA_TYPE=1]="SWITCH_MEDIA_TYPE"}(v||(v={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.SECRET=1]="SECRET"}(y||(y={})),function(e){e.INVITER="inviter",e.INVITEE="invitee"}(D||(D={}));class V extends e.EventEmitter{constructor(e,t,i,r,_,s,o,l){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:r}),Object.defineProperty(this,"_startCallerId",{enumerable:!0,configurable:!0,writable:!0,value:_}),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:l}),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:r,systemState:_,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:l,systemState:n,userState:a}=this._callUsers[o],C=((e,t)=>{let i=!1;const r=[exports.RCCallPlusReason.INVITED,exports.RCCallPlusReason.RINGING,exports.RCCallPlusReason.BUSYLINE_RINGING,exports.RCCallPlusReason.BUSYLINE_WAIT,exports.RCCallPlusReason.CONNECTING,exports.RCCallPlusReason.ONCALL];return e===exports.RCCallPlusReason.ONCALL&&r.includes(t)&&(i=!0),i})(n,_),c=((e,t)=>{let i=!1;const r=[exports.RCCallPlusSessionUserState.INVITED,exports.RCCallPlusSessionUserState.RINGING,exports.RCCallPlusSessionUserState.BUSYLINE_RINGING,exports.RCCallPlusSessionUserState.BUSYLINE_WAIT,exports.RCCallPlusSessionUserState.CONNECTING,exports.RCCallPlusSessionUserState.ONCALL];return e===exports.RCCallPlusSessionUserState.ONCALL&&r.includes(t)&&(i=!0),i})(a,t),L=_===exports.RCCallPlusReason.ON_PHONE_END&&n!==exports.RCCallPlusReason.ON_PHONE&&t!==exports.RCCallPlusSessionUserState.IDLE;r&&l&&r<l||C&&c||(this._callUsers[o]=e,!L&&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===D.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"}(b||(b={}));const x=(e,t)=>setTimeout(e,t),H=[e.ErrorCode.RC_NET_CHANNEL_INVALID,e.ErrorCode.RC_NET_UNAVAILABLE,e.ErrorCode.RC_MSG_RESP_TIMEOUT,t.RCRTCCode.SIGNAL_DISCONNECTED,t.RCRTCCode.REQUEST_FAILED],w=({asyncFn:e,fnArgs:t,currentRetryTime:_=Date.now(),maxDuration:s=6e4,intervals:o=[2e3,4e3,8e3,16e3,32e3,64e3],index:l=0,onError:n})=>i(void 0,void 0,void 0,function*(){const i=yield e(...t);return i.code===r.SUCCESS||!H.includes(i.code)||Date.now()+2e3-_>s?i:(n&&n(i.code),yield(a=2e3,new Promise(e=>{setTimeout(e,a)})),w({asyncFn:e,fnArgs:t,currentRetryTime:_,maxDuration:s,intervals:o,index:l,onError:n}));var a});var k,$,B;!function(e){e.onBeforePublish="onBeforePublish",e.onPublishRes="onPublishRes",e.onPubInviteCall="onPubInviteCall",e.onPubInviteCallPullKv="onPubInviteCallPullKv",e.onPubInviteCallMiss="onPubInviteCallMiss"}(k||(k={})),function(e){e.NOT_CURRENT_DEVICEID="not current device id",e.SECRET_CALL="secret call",e.NOT_INVITEE="not an invitee"}($||($={})),function(e){e.PUB_INVITE="pubinvitecall",e.PULL_KV_INVITE="pullkv_invitecall",e.PUSH="system_pubsh"}(B||(B={}));const F=131072,j="RC:CallPlusMiss",Y="RC:CallGroupStatusMsg";class J extends e.EventEmitter{constructor(t,i,r,_,s,o){super(),Object.defineProperty(this,"_context",{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:r}),Object.defineProperty(this,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_needRetryActions",{enumerable:!0,configurable:!0,writable:!0,value:[b.START_SINGLE_CALL,b.START_GROUP_CALL,b.ACCEPT_CALL,b.JOIN_CALL,b.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=e.getUUID22()}_onMessage(e){return!![j,Y].includes(e.messageType)&&(e.messageType===j?this._dealMissMessage(e):this._dealGroupCallMessage(e),!0)}_dealMissMessage(t){const{content:{callId:i,mediaType:r,startTime:s,callSessionUsers:o},targetId:l,senderUserId:n}=t,a=this._context.getCurrentId();if(!localStorage.getItem(`missMessageMap-${a}-${i}`)){const C={callId:i,callerUserId:n,targetId:l,mediaType:r,firstFrameTime:0,callStartTime:s-this._timeCorrectioner.getLocalDelayTime(),callEndTime:0,hangupReason:o.filter(({userId:e})=>e===a)[0].sessionStatus};this._logger.info(_.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O,`receive miss message: ${JSON.stringify(t)}`);const c=Object.assign(t,{content:C,sentStatus:e.SentStatus.SENT});this._reportAppEventModule.onReceivedCallPlusSummaryMessage(c),localStorage.setItem(`missMessageMap-${a}-${i}`,i)}}_dealGroupCallMessage(e){this._reportAppEventModule.onReceivedGroupCallStatusMessage(e)}getSessionId(){return this._sessionId}getDeviceId(){return U?this._context.getDeviceId():this._sessionId}registerListener(e){this._listener=e}startCall(e,t){return i(this,void 0,void 0,function*(){const{clientCallId:i,callType:r,toUsers:_,mediaType:s,secretChat:o,targetType:l,targetId:n,nickName:a,oldRoomId:C,pushExt:c,pushContent:L,extra:E}=e;return r===exports.RCCallPlusType.SINGLE?this.startSingleCall({clientCallId:i,toUserId:_[0].userId,mediaType:s,secretChat:o,targetType:l,targetId:n,oldRoomId:C,toOrgId:_[0].orgId||"",pushExt:c,pushContent:L,extra:E},t):this.startGroupCall({clientCallId:i,toUsers:_,mediaType:s,targetType:l,targetId:n,nickName:a,oldRoomId:C,pushExt:c,pushContent:L,extra:E},t)})}startSingleCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(this._context.getCurrentId(),b.START_SINGLE_CALL,e)})}startGroupCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_GROUP_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(this._context.getCurrentId(),b.START_GROUP_CALL,e)})}inviteCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_INVITE_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.INVITE_CALL,e)})}ringingCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_RING_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.RINGING_CALL,e)})}acceptCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_ACCEPT_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.ACCEPT_CALL,e)})}joinCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_JOIN_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.JOIN_CALL,e)})}hangupCall(e,t){return i(this,void 0,void 0,function*(){this._logger.info(_.L_SIGNAL_TRANSPORTER_HANGUP_T,`params: ${JSON.stringify(e)}`,t);const{code:i}=yield this._sendCallSignal(e.callId,b.HANGUP_CALL,e);return i===r.NOT_IN_CALL?{code:r.SUCCESS}:{code:i}})}statusUpCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T,`call status up params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.STATUS_UP_CALL,e)})}eventUpCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.EVENT_UP_CALL,e)})}dialogUpCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.DIALOG_UP_CALL,e)})}deleteCallRecord(e,t,r){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T,`callIds: ${JSON.stringify(t)}`,r),this._sendCallSignal(e,b.DEL_CALL_LOG,{callIds:t})})}syncCallLog(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.userId,b.SYNC_CALL_LOG,e)})}queryUserHasCall(){return i(this,void 0,void 0,function*(){const e=this._context.getCurrentId();return this._sendCallSignal(e,b.QRY_CALL_STATE,null)})}getCallServerTimestamp(e){return i(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(_.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T,`userId: ${t}`,e),this._sendCallSignal(t,b.QRY_SRV_TIMESTAMP,null)})}getCallTimeInfo(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T,`callId: ${e}`,t),this._sendCallSignal(e,b.GET_CALL_TIME_INFO,{callId:e})})}getUserCallStateList(e){return i(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(_.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T,`userId: ${t}`,e),this._sendCallSignal(t,b.GET_CALL_STATE_LIST,null)})}clearCallRecord(e){return i(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(_.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T,`userId: ${t}`,e),this._sendCallSignal(t,b.CLEAR_CALL_LOG,null)})}getCallSession(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T,`callId: ${e.callId}`,t),this._sendCallSignal(e.callId,b.GET_CALL_SESSION,e)})}sysStatusUp(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T,`opts: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.SYS_STATUS_UP,e)})}upCallLogReaded(e){return i(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._sendCallSignal(t,b.UP_CALL_LOG_READED,e)})}endUserAbnormalCalls(e){return i(this,void 0,void 0,function*(){return this._sendCallSignal(this._context.getCurrentId(),b.END_ABNORMAL_CALL,e)})}_onIMConnectionStateChange(t){const i=this._logger.createTraceId();this._logger.info(_.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O,`state: ${t}`,i),this._listener.onIMStateChange(t),t===e.RCConnectionStatus.CONNECTED?this._timeCorrectioner.start(i):this._timeCorrectioner.stop(i)}_sendCallSignal(t,_,s){return i(this,void 0,void 0,function*(){let i,o="";s&&(o=U?JSON.stringify(s):JSON.stringify(Object.assign(Object.assign({},s),{sessionId:this._sessionId}))),i=this._needRetryActions.includes(_)?yield w({asyncFn:this._context.setCallInfo.bind(this._context),fnArgs:[t,_,o]}):yield this._context.setCallInfo(t,_,o);const{code:l,data:n}=i;if(l!==e.ErrorCode.SUCCESS)return{code:l};const{value:a}=n,C=JSON.parse(a).data;return{code:r.SUCCESS,data:C}})}_onRecvCallSignal(e){const t=this._logger.createTraceId();this._logger.info(_.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O,`data: ${e}`,t);JSON.parse(e).list.forEach(e=>{const{key:i}=e,r=JSON.parse(e.value);switch(i){case b.PUB_INVITE_CALL:this._onPubInviteCall(r,t,!0);break;case b.STATUS_DOWN_CALL:this._onStatusDownCall(r,t);break;case b.EVENT_DOWN_CALL:this._onEventDownCall(r,t);break;case b.DIALOG_DOWN_CALL:this._onDialogDownCall(r,t);break;case b.PUB_CALL_LOG:this._onPubCallLog(r,t);break;case b.PUB_CALL_LOG_READED:case b.PUB_NACK_SEQ_ID:break;default:this._onConpensationData(r,t)}})}isValidData(t){if(e.isNull(t))return!0;const i=t===this.getDeviceId();return!(!e.isString(t)||0!==(null==t?void 0:t.length)&&!i)}_onPubInviteCall(e,t,i=!0){try{const i=this._context.getCurrentId(),r=e.callSessionUsers.find(e=>e.userId===i),s=this._context.getConnectionStatus();this._logger.info(_.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`currentUser: ${JSON.stringify(r)}, currentUserId: ${i}, state: ${s}`,t)}catch(e){this._logger.error(_.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`error: ${e.message}`,t)}if(!this.isValidData(e.toDeviceId||"")){this._logger.warn(_.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`not current deviceId -> deviceInfo: ${JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this.getDeviceId()})}`,t);const r={extra:JSON.stringify(e),reason:$.NOT_CURRENT_DEVICEID,refer:i?B.PUB_INVITE:B.PULL_KV_INVITE};return void this.emit(k.onPubInviteCallMiss,Object.assign(e,r))}this._listener.onInvite(e,i,t),i?this.emit(k.onPubInviteCall,Object.assign(e,{extra:JSON.stringify(e)})):this.emit(k.onPubInviteCallPullKv,Object.assign(e,{extra:JSON.stringify(e)}))}_onStatusDownCall(e,t){if(e.callSessionUsers=e.callSessionUsers.filter(e=>Boolean(e.changed)),this._logger.info(_.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,"",t),!this.isValidData(e.toDeviceId||""))return this._logger.warn(_.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===v.SWITCH_MEDIA_TYPE&&this._listener.onSwitchMediaType(e,t)}_onPubCallLog(e,t){this._logger.info(_.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O,`call record: ${JSON.stringify(e)}`,t),this._listener.onRecvCallEndLog(e,t)}_onConpensationData(e,t){this._logger.info(_.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O,"",t);const{callId:i,callType:r,mediaType:s,secretChat:o,duration:l,callStatus:n,callingUserId:a,callSessionUsers:C,toDeviceId:c,callDialogEntitys:L,extra:E}=e;C.some(e=>e.sessionStatus===exports.RCCallPlusSessionUserState.INVITED&&e.userId===this._context.getCurrentId())?this._onPubInviteCall({callId:i,toDeviceId:c,callType:r,mediaType:s,inviteUserId:a,callingUserId:a,callSessionUsers:C,secretChat:o,extra:E},t,!0):this._onStatusDownCall({callId:i,toDeviceId:c,callStatus:n,duration:l,callSessionUsers:C},t),L.length>0&&L.forEach(e=>this._onDialogDownCall(e,t),this)}}const W=()=>{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 r=+e;const _=[];do{const e=r%i;r=(r-e)/i,_.unshift(t[e])}while(r);return _.join("")})(e),e.length>22&&(e=e.slice(0,22)),e};class K{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(K._STORAGE_KEY)||"{}");let r=i[e];r?r.push(t):r=[t],i[e]=r,this._localStore.setItem(K._STORAGE_KEY,JSON.stringify(i))}catch(e){this._logger.error(_.L_ABNORMAL_ADD_CALL_ID_E,e.message),console.error(e)}}removeAbnormalCallIds(e,t){try{const i=JSON.parse(this._localStore.getItem(K._STORAGE_KEY)||"{}");let r=i[e];r&&(r=r.filter(e=>!t.includes(e)),r.length>0?i[e]=r:delete i[e],this._localStore.setItem(K._STORAGE_KEY,JSON.stringify(i)))}catch(e){this._logger.error(_.L_ABNORMAL_REMOVE_CALL_IDS_E,e.message),console.error(e)}}getAbnormalCallIds(e){let t=null;try{const i=JSON.parse(this._localStore.getItem(K._STORAGE_KEY)||"{}")[e];i&&(t=i)}catch(e){this._logger.error(_.L_ABNORMAL_GET_CALL_IDS_E,e.message),console.error(e)}return Promise.resolve(t)}}var Q,q,X,z,Z;Object.defineProperty(K,"_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"}(Q||(Q={})),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"}(q||(q={}));class ee{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 i(this,void 0,void 0,function*(){this._logger.info(_.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(_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${q.INVALID_RESPONSE_TIME}`,t);const{code:i,data:s}=yield this._callEngine.getCallTimeInfo(e,t);if(i!==r.SUCCESS)return this._logger.error(_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${i}`,t),{code:i};const{startTime:o}=s,l=Math.floor(o-this._deltaTime);let n=(Date.now()+this._deltaTime-o)/1e3;return n<0&&(this._logger.warn(_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P,`invalid duration: ${n}`,t),n=0),n=Math.floor(n),this._RTT>this._validMinRTT&&this._RTT<=this._validMaxRTT&&this._logger.error(_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${q.NONOPTIMAL_RES_TIME}`,t),this._logger.info(_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,serverStartTime:o,clientStartTime:l,duration:n}),t),{code:i,duration:n,clientStartTime:o?l:o}})}calcClientStartTime(e,t,i){if(this._logger.info(_.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T,`callId: ${e}, startTime: ${t}`,i),this._RTT>this._validMaxRTT)return this._logger.error(_.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,`code: ${q.INVALID_RESPONSE_TIME}`,i),this._loopCorrectClientTime(e,i),{code:q.INVALID_RESPONSE_TIME};const r=Math.floor(t-this._deltaTime);return this._logger.info(_.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,startT:t,clientStartTime:r}),i),this._RTT>this._validMinRTT&&(this._retryTimesInCall=0,this._loopCorrectClientTime(e,i)),{code:q.SUCCESS,clientStartTime:r}}start(e){this._timerId||this._startTimes>=this._maxRetryTimes||(this._logger.info(_.L_TIME_CORRECT_START_O,`timerId: ${this._timerId}`),this._startTimes++,this._getDeltaTime(e),this._timerId=x(()=>{this._timerId=null,this.start(e)},this._interval))}stop(e){this._logger.info(_.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(_.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 i(this,void 0,void 0,function*(){const t=Date.now(),{code:i,data:s}=yield this._callEngine.getCallServerTimestamp(e),o=Date.now();if(i!==r.SUCCESS)return{code:i};const l=o-t;return(l<this._RTT||0===this._RTT)&&l<=this._validMaxRTT&&(this._RTT=l),l<this._validMinRTT&&this.stop(e),this._deltaTime=s-t-this._RTT/2,this._logger.info(_.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 i(this,void 0,void 0,function*(){const i=Date.now(),{code:s,data:o}=yield this._callEngine.getCallTimeInfo(e,t),l=Date.now();if(s!==r.SUCCESS)return{code:s};const n=l-i;n<this._RTT&&(this._RTT=n),this._deltaTime=o.syncTime-i-this._RTT/2,this._logger.info(_.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({callId:e,rtt:this._RTT,deltaT:this._deltaTime}),t);const a=Math.floor(o.startTime-this._deltaTime),C=Math.floor(o.firstFrametime-this._deltaTime);return n<this._validMinRTT?{code:q.SUCCESS,clientStartTime:a,clientFirstFrameTime:C}:{code:q.INVALID_RESPONSE_TIME,clientStartTime:a,clientFirstFrameTime:C}})}_loopCorrectClientTime(e,t){return i(this,void 0,void 0,function*(){this.stop(t),this._logger.info(_.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T,`callId: ${e}`,t);const{code:i,clientStartTime:s,clientFirstFrameTime:o}=yield this._getDeltaTimeInCall(e,t);return i===q.SUCCESS?(this._logger.info(_.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,`code: ${r.SUCCESS}`,t),void this._singleCallDurationEv(e,s,o,t)):this._retryTimesInCall>this._maxRetryTimesInCall&&i===q.INVALID_RESPONSE_TIME?(this._logger.info(_.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,`code: ${q.INVALID_RESPONSE_TIME}`,t),void this._singleCallDurationEv(e,s,o,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"}(X||(X={})),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"}(z||(z={})),function(e){e[e.OUT=-1]="OUT",e[e.GROUP=0]="GROUP",e[e.IN=1]="IN"}(Z||(Z={}));class te extends e.EventEmitter{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:r}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:_}),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 ee(this,r,this._onRecvSinCallDuration.bind(this)),this._signalModule=new J(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 K(t,r)}startCall(e,t){return i(this,void 0,void 0,function*(){const i=this._context.getCurrentId(),{callType:_,mediaType:s,toUsers:o,targetId:l,targetType:n,oldRoomId:a,pushConfig:C,extra:c}=e;this._clientCallId=e.callId;const L=C?h(C,this._clientCallId):"",{code:E,data:d}=yield this._signalModule.startCall({clientCallId:this._clientCallId,callType:_,mediaType:s,toUsers:o,secretChat:y.NORMAL,targetType:n,targetId:l,oldRoomId:a,pushExt:L,pushContent:(null==C?void 0:C.pushContent)||"",extra:c},t);if(E!==r.SUCCESS)return{code:E};const{callId:T,busylineUsers:u}=d;if(this._abnormalModule.addAbnormallCallId(i,T),this._mainSession=new V(T,exports.RCCallPlusCallState.INVITED,_,s,i,i,[],this._logger),_===exports.RCCallPlusType.SINGLE){const e=this._startTimer(d.callId,exports.RCCallPlusSessionUserState.NO_ANSWER,t);this._mainSession.updateTimerId(D.INVITER,e)}const S={userId:i,userState:exports.RCCallPlusSessionUserState.CALLING,systemState:exports.RCCallPlusReason.CALLING,targetType:n,targetId:l};let I=o.map(({userId:e,targetType:t,targetId:i})=>({userId:e,userState:exports.RCCallPlusSessionUserState.INVITED,systemState:exports.RCCallPlusReason.INVITED,targetType:t,targetId:i})),R=[];u&&(R=u.map(e=>{const{targetType:t,targetId:i}=I.find(t=>t.userId===e.userId);return{userId:e.userId,userState:e.sessionStatus,systemState:exports.RCCallPlusReason.BUSYLINE_RINGING,targetType:t,targetId:i}}),I=I.filter(({userId:e})=>R.every(({userId:t})=>t!==e)));const g=this.updateUsersState(T,[S,...I,...R],t);return setTimeout(()=>{g.length>0&&this.reportRemoteUserStateChange(T,g,t)}),{code:E,data:d}})}invite(e,t){var _;return i(this,void 0,void 0,function*(){if(!this._mainSession)return{code:r.NOT_IN_CALL};const{toUsers:i,pushConfig:s,extra:o}=e,l=s?h(s,this._clientCallId):"",n=this._mainSession.getCallId(),{code:a,data:C}=yield this._signalModule.inviteCall({callId:n,toUsers:i,pushExt:l,pushContent:(null==s?void 0:s.pushContent)||"",extra:o},t);if(a===r.SUCCESS){this._mainSession.getCallType()===exports.RCCallPlusType.SINGLE&&(this._mainSession.updateCallType(exports.RCCallPlusType.MULTI),this._onCallTypeChange(this._mainSession.getCallId(),exports.RCCallPlusType.MULTI,t));let e=i.map(({userId:e,targetType:t,targetId:i})=>({userId:e,userState:exports.RCCallPlusSessionUserState.INVITED,systemState:exports.RCCallPlusReason.INVITED,targetType:t,targetId:i})),r=[];C.busylineUsers&&(r=null===(_=C.busylineUsers)||void 0===_?void 0:_.map(t=>{const{targetType:i,targetId:r}=e.find(e=>e.userId===t.userId);return{userId:t.userId,userState:t.sessionStatus,systemState:exports.RCCallPlusReason.BUSYLINE_RINGING,targetType:i,targetId:r}}),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:a,data:C}})}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 i(this,void 0,void 0,function*(){const{callId:i,systemState:r,pushConfig:_}=e,s=_?h(_,this._clientCallId):"",{code:o}=yield this._signalModule.hangupCall({callId:i,sysStatus:r,pushExt:s,pushContent:(null==_?void 0:_.pushContent)||""},t);return this.endCurrentSession(e.systemState,i,t),{code:o}})}accept(e,t){return i(this,void 0,void 0,function*(){if(!this._mainSession)return{code:r.NOT_IN_CALL};const{callId:i}=e,{code:_}=yield this._signalModule.acceptCall({callId:i},t);return this._stopTimer(this._mainSession.getInviteeTimerId(),t),_!==r.SUCCESS||(this._clearMobileOnPhone(e.callId,t),this._mainSession.updateSessionState(exports.RCCallPlusCallState.CONNECTING)),{code:_}})}joinCall(e,t){return i(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 _!==r.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 i(this,void 0,void 0,function*(){if(!this._mainSession)return{code:r.NOT_IN_CALL};const i={mediaType:e.mediaType};this._mainSession.updateReqMediaType(e.mediaType);const _=W(),{code:s}=yield this._signalModule.dialogUpCall({transactionId:_,callId:this._mainSession.getCallId(),toUserIds:e.toUserIds,dialogType:v.SWITCH_MEDIA_TYPE,action:M.REQUEST,extraKeyVal:i},t);return s!==r.SUCCESS?{code:s}:{code:r.SUCCESS,data:{transactionId:_}}})}responseChangeMediaType(e,t){return i(this,void 0,void 0,function*(){return this._mainSession?this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:v.SWITCH_MEDIA_TYPE,action:e.agree?M.ACCEPT:M.REFUSE},t):{code:r.NOT_IN_CALL}})}cancelChangeMediaType(e,t){return i(this,void 0,void 0,function*(){return this._mainSession?this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:v.SWITCH_MEDIA_TYPE,action:M.CANCEL},t):{code:r.NOT_IN_CALL}})}getCallLogList(e,t){return i(this,void 0,void 0,function*(){const i=this._context.getCurrentId(),{timestamp:_,count:s,order:o}=e,{code:l,data:n}=yield this._signalModule.syncCallLog({userId:i,syncTime:_,count:s,order:o},t);if(l!==r.SUCCESS)return{code:l};const a=n.callLogList.map(e=>T(e));return{code:r.SUCCESS,data:{hasMore:Boolean(null==n?void 0:n.hasMore),syncTime:0===o?n.maxTime:n.minTime,list:a}}})}deleteCallLog(e,t){return i(this,void 0,void 0,function*(){const i=this._context.getCurrentId();return this._signalModule.deleteCallRecord(i,e,t)})}getCallServerTimestamp(e){return i(this,void 0,void 0,function*(){const{code:t,data:i}=yield this._signalModule.getCallServerTimestamp(e);return t!==r.SUCCESS?{code:t}:{code:t,data:i.syncTime}})}getCallTimeInfo(e,t){return i(this,void 0,void 0,function*(){return this._signalModule.getCallTimeInfo(e,t)})}getOpenCallList(e){return i(this,void 0,void 0,function*(){const t=this._context.getCurrentId(),{code:i,data:_}=yield this._signalModule.getUserCallStateList(e);if(i!==r.SUCCESS)return{code:i};return{code:i,data:_.callStateList.map(i=>{const{callId:r,callType:_,mediaType:s,callingUserId:o,callUserIds:l,callStatus:n,crtTime:a,userSessionStatus:C,startTime:c,syncTime:L}=i,E=o===t?Z.OUT:Z.IN,{clientStartTime:d=c}=this._timeCorrectioner.calcClientStartTime(r,c,e);return{callId:r,callType:_,callDirection:E,mediaType:s,callerUserId:o,callUserIds:l,sessionState:n,userState:C,startTimestamp:c,endTimestamp:0,duration:Math.floor((+new Date-d)/1e3),syncTimestamp:L,systemState:0,createTimestamp:a}})}})}removeAllCallLog(e){return i(this,void 0,void 0,function*(){const{code:t}=yield this._signalModule.clearCallRecord(e);return{code:t}})}getCallSession(e,t){return i(this,void 0,void 0,function*(){const{code:i,data:_}=yield this._signalModule.getCallSession(e,t);if(i!==r.SUCCESS)return{code:i};const{callId:s,callingUserId:o,callType:l,mediaType:n,callStatus:a,callSessionUsers:C,startTime:c,duration:L,syncTime:E}=_;return{code:i,data:{callId:s,startCallerId:o,callType:l,mediaType:n,sessionState:a,callSessionUsers:C.map(e=>{const{userId:t,sessionStatus:i,sysStatus:r,targetType:_,targetId:s}=e;return{userId:t,userState:i,systemState:r,targetType:_,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 L(t,this,this._logger,this._rtcModule,this._context):null}getLocalMainSession(){return this._mainSession?new L(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(_.L_CALL_ENGINE_UPDATE_USERS_STATE_O,`updateUsersState -> users: ${JSON.stringify(t)}`,i);const r=[this._mainSession,...this._holdSessions].find(t=>(null==t?void 0:t.getCallId())===e),s=[];return r?s.push(...r.updateUserList(t,i)):s.push(...t),s}getCallStaringTime(e,t){return i(this,void 0,void 0,function*(){return this._timeCorrectioner.getCallClientTimeByServer(e.callId,t)})}systemStatusUp(e,t){return i(this,void 0,void 0,function*(){return this._signalModule.sysStatusUp(e,t)})}upFirstFrameTime(e){return i(this,void 0,void 0,function*(){if(!this._mainSession||this._mainSession&&this._mainSession.getCallType()!==exports.RCCallPlusType.SINGLE||this._isUpFirstFrameTime)return{code:r.SUCCESS};const t=Date.now(),i=this._timeCorrectioner.getLocalDelayTime(),s=Math.floor(t+i);this._logger.info(_.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T,`now: ${t}; delay: ${i}; streamReadyTime: ${s}`,e),this._isUpFirstFrameTime=!0;const o=this._mainSession.getCallId(),{code:l}=yield this._signalModule.eventUpCall({callId:o,eventType:Q.FIRST_FRAME,eventArgs:{streamReadyTime:s},eventTime:Date.now()},e);return this._logger.info(_.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R,`code: ${l}`,e),{code:l}})}endCurrentSession(e,t,i){const r=this._context.getCurrentId();if(this._mainSession&&this._mainSession.getCallId()===t){const t=this._mainSession.getUserList().map(t=>{let{userId:i,systemState:_,targetType:s,targetId:o}=t;return i===r&&(_=e),{userId:i,sessionStatus:exports.RCCallPlusSessionUserState.ENDED,statusTime:Date.now(),duration:0,changed:1,inviteUserId:this._mainSession.getStartCallerId(),sysStatus:_,targetType:s,targetId:o}}),_={callId:this._mainSession.getCallId(),toDeviceId:this._signalModule.getDeviceId(),callStatus:exports.RCCallPlusCallState.ENDED,duration:0,callSessionUsers:t};this._onStatusDown(_,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 i(this,void 0,void 0,function*(){const t=this._context.getCurrentId(),i=yield this._abnormalModule.getAbnormalCallIds(t);if(!i)return{code:r.SUCCESS};const _=i.filter(e=>{var t;return e!==(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId())}),{code:s}=yield this._signalModule.endUserAbnormalCalls({callIds:_,allDevice:e?1:0});return s===r.SUCCESS&&this._abnormalModule.removeAbnormalCallIds(t,_),{code:s}})}setRTCModule(e){this._rtcModule=e}_onIMStateChange(t){const i=this._logger.createTraceId();let r=0;t===e.RCConnectionStatus.DISCONNECTED&&this._mainSession&&this._mainSession.getSessionState()!==exports.RCCallPlusCallState.ONCALL&&(r=x(()=>{var e;this._logger.info(_.L_CALL_ENGINE_IM_STATE_CHANGE_O,"endCurrentSession, IM disconnected for more than 60s",i),this.endCurrentSession(exports.RCCallPlusReason.CONNECTION_ERR,null===(e=this._mainSession)||void 0===e?void 0:e.getCallId(),i)},6e4)),t===e.RCConnectionStatus.CONNECTED&&(r&&clearTimeout(r),this._initOpts.isAllowNewCallWhenRinging&&this.endCurrentUserAbnormalCalls(!0))}_handleCallTimeout(e,t,i){this._logger.warn(_.L_CALL_ENGINE_CALL_TIMEOUT_O,`call timeout callId: ${e}, userState: ${t}`,i);const r=[this._mainSession,...this._holdSessions].find(t=>t&&t.getCallId()===e);if(!r)return void this._logger.warn(_.L_CALL_ENGINE_CALL_TIMEOUT_O,`handleCallTimeout without session, callId: ${e}`,i);const s=this._context.getCurrentId();this._onStatusDown({callId:e,toDeviceId:this._signalModule.getDeviceId(),callStatus:exports.RCCallPlusCallState.ENDED,duration:0,callSessionUsers:r.getUserList().map(e=>{const{userId:i,targetType:_,targetId:o,stateTime:l}=e;let n,a;return i===s?(n=t===exports.RCCallPlusSessionUserState.MISSED?exports.RCCallPlusReason.MISSED:exports.RCCallPlusReason.NO_ANSWER,a=t===exports.RCCallPlusSessionUserState.MISSED?exports.RCCallPlusSessionUserState.MISSED:exports.RCCallPlusSessionUserState.NO_ANSWER):(n=t===exports.RCCallPlusSessionUserState.MISSED?exports.RCCallPlusReason.NO_ANSWER:exports.RCCallPlusReason.MISSED,a=t===exports.RCCallPlusSessionUserState.MISSED?exports.RCCallPlusSessionUserState.NO_ANSWER:exports.RCCallPlusSessionUserState.MISSED),{userId:i,sessionStatus:a,statusTime:l?l+1:Date.now(),duration:0,changed:1,inviteUserId:r.getCallerId(),sysStatus:n,targetType:_,targetId:o}})},i)}_startTimer(e,t,i){const r=x(()=>{this._handleCallTimeout(e,t,i),this._signalModule.statusUpCall({callId:e,sessionStatus:t},i)},6e4);return this._logger.info(_.L_CALL_ENGINE_START_CALL_TIMER_O,`callId: ${e}, timerId: ${r}`,i),r}_stopTimer(e,t){clearTimeout(e),this._logger.info(_.L_CALL_ENGINE_STOP_CALL_TIMER_O,`timerId: ${e}`,t)}_onInvite(t,i,r){this._clientCallId=e.getUUID();const _=this._context.getCurrentId(),{callSessionUsers:s,secretChat:o,extra:l="{}"}=t;if(o===y.SECRET)return void this.emit(k.onPubInviteCallMiss,Object.assign(t,{extra:JSON.stringify(t),reason:$.SECRET_CALL,refer:i?B.PUB_INVITE:B.PULL_KV_INVITE}));s.some(e=>e.userId===_)&&this._selfIsInviteeHandle(t,i,r,l),this._othersIsInviteeHandle(t,r)}_selfIsInviteeHandle(e,t,i,r){const{callId:_,inviteUserId:s,callType:o,mediaType:l,callSessionUsers:n}=e,a=this._context.getCurrentId();this._abnormalModule.addAbnormallCallId(a,_);const C=new V(_,exports.RCCallPlusCallState.RINGING,o,l,s,s,[],this._logger);this._signalModule.ringingCall({callId:_},i);const c=this._startTimer(_,exports.RCCallPlusSessionUserState.MISSED,i);C.updateTimerId(D.INVITEE,c),this._mainSession?(this._holdSessions.push(C),this._mainSession.updateSessionState(exports.RCCallPlusCallState.BUSYLINE_WAIT)):this._mainSession=C;const E=new L(C,this,this._logger,this._rtcModule,this._context),d=t?z.PUB_INVITE_CALL:z.PULL_KV_INVITE_CALL;this.emit(te.__INNER_INVITE__,E,d);const T=n.map(({userId:e,sessionStatus:t,sysStatus:i,targetType:r,targetId:_,statusTime:s})=>({userId:e,userState:t,systemState:i,targetType:r,targetId:_,stateTime:s})),u=this.updateUsersState(_,T,i);this._reportAppEventModule.onReceivedCall(E,i,JSON.parse(r||"{}").extra),u.length>0&&this.reportRemoteUserStateChange(_,u,i)}_othersIsInviteeHandle(e,t){var i,r,_;const{callId:s,inviteUserId:o,callSessionUsers:l}=e,n=this._context.getCurrentId(),a=l.filter(e=>e.userId!==n&&e.userId!==o&&e.sessionStatus===exports.RCCallPlusSessionUserState.INVITED);if(!a.length)return;(null===(i=this._mainSession)||void 0===i?void 0:i.getCallType())===exports.RCCallPlusType.SINGLE&&(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())===s&&(this._onCallTypeChange(this._mainSession.getCallId(),exports.RCCallPlusType.MULTI,t),null===(_=this._mainSession)||void 0===_||_.updateCallType(exports.RCCallPlusType.MULTI));const C=[],c=[];a.forEach(e=>{const{userId:t,sessionStatus:i,sysStatus:r}=e;C.push({callId:s,userId:t,userState:i}),c.push({userId:t,userState:i,systemState:r})}),this._onOtherMemberInvite(C);const L=this.updateUsersState(s,c,t);L.length>0&&this.reportRemoteUserStateChange(s,L,t)}_onHangup(e,t,i){this._mainSession&&e.forEach(e=>{e.callId===this._mainSession.getCallId()&&(e.userState===exports.RCCallPlusSessionUserState.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(),l=[exports.RCCallPlusCallState.CONNECTING,exports.RCCallPlusCallState.ONCALL,exports.RCCallPlusCallState.BUSYLINE_WAIT];if((null===(r=this._mainSession)||void 0===r?void 0:r.getCallType())===exports.RCCallPlusType.SINGLE&&o&&l.includes(o))return;const n=this._mainSession.getStartCallerId(),a=this._context.getCurrentId();if((null===(_=this._mainSession)||void 0===_?void 0:_.getCallType())===exports.RCCallPlusType.SINGLE&&n===a){e.filter(e=>e.fromUserId!==a)&&this.emit(te.__INNER_SESSION_CONNECT__,this.getLocalMainSession().getCallId(),t)}null===(s=this._mainSession)||void 0===s||s.updateSessionState(exports.RCCallPlusCallState.CONNECTING),this._stopTimer(this._mainSession.getInviterTimerId(),t)}_onStatusDown(e,t){var r,_;return i(this,void 0,void 0,function*(){const{callStatus:i,startTime:s,callId:o}=e;if(o!==(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId()))return;if(this._callStartMap[o]=this._callStartMap[o]||{},!this._callStartMap[o].isReceiveCallStartTime&&i===exports.RCCallPlusCallState.ONCALL){this._callStartMap[o].isReceiveCallStartTime=!0;const{code:e,clientStartTime:i}=this._timeCorrectioner.calcClientStartTime(o,s,t);e===q.SUCCESS&&(this._callStartMap[o].callStartTime=i,this._reportAppEventModule.onReceivedCallStartTime({callId:o,callStartTime:i},t))}let l=!1;const n=this._context.getCurrentId(),a=e.callSessionUsers.map(e=>([exports.RCCallPlusSessionUserState.IDLE,exports.RCCallPlusSessionUserState.DECLINED,exports.RCCallPlusSessionUserState.MISSED,exports.RCCallPlusSessionUserState.NO_ANSWER,exports.RCCallPlusSessionUserState.CANCELLED].includes(e.sessionStatus)&&e.sysStatus!==exports.RCCallPlusReason.CANCELLED&&e.userId===n&&(l=!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:c,otherInvitedData:L}=(e=>{const{callId:t}=e,i=[],r=[],_=[],s=[];return e.callSessionUsers.forEach(e=>{const{userId:o,sessionStatus:l,sysStatus:n}=e;switch(l){case exports.RCCallPlusSessionUserState.INVITED:s.push({callId:t,userId:o,userState:l});break;case exports.RCCallPlusSessionUserState.RINGING:i.push({callId:t,fromUserId:o});break;case exports.RCCallPlusSessionUserState.CONNECTING:_.push({fromUserId:o});break;case exports.RCCallPlusSessionUserState.CANCELLED:case exports.RCCallPlusSessionUserState.DECLINED:case exports.RCCallPlusSessionUserState.ENDED:case exports.RCCallPlusSessionUserState.IDLE:r.push({callId:t,fromUserId:o,userState:l,systemState:n})}}),{ringingData:i,hangupData:r,acceptData:_,otherInvitedData:s}})(e);C.length>0&&this._onHangup(C,e.callStatus,t),c.length>0&&this._onAccept(c,t),L.length>0&&(null===(_=this._mainSession)||void 0===_?void 0:_.getCallType())===exports.RCCallPlusType.MULTI&&this._onOtherMemberInvite(L),(e.callStatus===exports.RCCallPlusCallState.ENDED||l)&&this._onSessionClose(e,t,l)})}_onOtherClientStatusDown(e,t){var i,r,_;const{callId:s,callSessionUsers:o}=e,l=this._context.getCurrentId(),n=o.find(({userId:e})=>e===l);if(n&&(this._mainSession||this._holdSessions.length)){const{userId:o,sessionStatus:a,statusTime:C}=n;if(a===exports.RCCallPlusSessionUserState.CONNECTING){const n=[exports.RCCallPlusSessionUserState.ONCALL,exports.RCCallPlusSessionUserState.CONNECTING],c=(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())===s,L=null===(_=null===(r=this._mainSession)||void 0===r?void 0:r.getUserList().find(e=>e.userId===l))||void 0===_?void 0:_.userState;if(!(c&&L&&n.includes(L))){const i=this.updateUsersState(s,[{userId:o,userState:a,systemState:exports.RCCallPlusReason.OTHER_CLIENT_ACCEPT,stateTime:C}],t);i.length>0&&this.reportRemoteUserStateChange(s,i,t),this._onSessionClose(e,t,!1)}}}}_onEventDown(e,t){var r;return i(this,void 0,void 0,function*(){const{callId:i,eventArgs:s,eventType:o}=e;if(i===(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())&&this._mainSession.getSessionState()===exports.RCCallPlusCallState.ONCALL&&o===Q.CALL_DURATION){const{firstFrameTime:e}=s,{code:r,clientStartTime:o}=this._timeCorrectioner.calcClientStartTime(i,e,t);this._logger.info(_.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O,`clientFirstFrameTime: ${o}`,t),r===q.SUCCESS&&(this._callStartMap[i].firstFrameTime=o,this._reportAppEventModule.onReceivedCallFirstFrameTime(i,o,t))}})}_onRecvSinCallDuration(e,t,i,r){var _;(null===(_=this._mainSession)||void 0===_?void 0:_.getCallId())===e&&(this._callStartMap[e].callStartTime=t,this._callStartMap[e].firstFrameTime=i,this._reportAppEventModule.onReceivedCallStartTime(Object.assign({callId:e},{callStartTime:t}),r),this._reportAppEventModule.onReceivedCallFirstFrameTime(e,i,r))}_onSwitchMediaType(e,t){var i,r,s,o,l;const{callId:n,action:a,extraKeyVal:C,transactionId:c,promoterId:L}=e,{mediaType:E,reason:d}=C,T=null===(i=this._mainSession)||void 0===i?void 0:i.getCallId();if(n!==T)return void this._logger.info(_.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,`not current session callId: ${T}, recvCallId: ${n}`,t);const{transactionId:u,action:S,mediaType:I}=(null===(r=this._mainSession)||void 0===r?void 0:r.getOldDialogData())||{};if(u!==c||S!==a||I!==E){if(this._logger.info(_.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,`action: ${a}, reason: ${d}`,t),null===(s=this._mainSession)||void 0===s||s.setOldDialogData({transactionId:c,action:a,mediaType:E}),a===M.REQUEST)this._onRequestChangeMediaType({transactionId:c,userId:L,mediaType:E},t);else{let e=null;switch(d){case M.CANCEL:e=exports.RCCallPlusMediaTypeChangeResult.CANCEL_CHANGE_MEDIA_TYPE;break;case M.ACCEPT:e=exports.RCCallPlusMediaTypeChangeResult.SERVER_ALLOW_MEDIA_TYPE,null===(o=this._mainSession)||void 0===o||o.updateMediaType(this._mainSession.getReqMediaType()),null===(l=this._mainSession)||void 0===l||l.updateReqMediaType(null);break;case M.REFUSE:e=exports.RCCallPlusMediaTypeChangeResult.REFUSE_CHANGE_MEDIA_TYPE;break;case M.TIMEOUT:e=exports.RCCallPlusMediaTypeChangeResult.CHANGE_MEDIA_TYPE_TIMEOUT}exports.RCCallPlusMediaTypeChangeResult[e]&&this._receiveMediaTypeChangeResult({transactionId:c,userId:L,mediaType:E},e,t)}a!==M.NOTICE||E!==exports.RCCallPlusMediaType.AUDIO||d||this._receiveMediaTypeChangeResult({transactionId:c,userId:L,mediaType:E},exports.RCCallPlusMediaTypeChangeResult.SERVER_ALLOW_MEDIA_TYPE,t)}else this._logger.info(_.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"duplicate dialog data",t)}_onRecvCallEndLog(e,t){const i=T(e);this._reportAppEventModule.onReceivedCallRecord(i,t)}_onSessionClose(e,t,i){const{callId:r}=e,s=this._context.getCurrentId();this._abnormalModule.removeAbnormalCallIds(s,[r]);let o=[this._mainSession,...this._holdSessions].find(e=>e&&e.getCallId()===r);if(!o)return void this._logger.warn(_.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,`unexpect session callId -> ${r}`,t);this._logger.warn(_.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,`callId: ${r}`,t),this.emit(te.__INNER_SESSION_CLOSE__,r,t);const l=o.getUserList().find(e=>e.userId===s);let n;n=i&&e.toDeviceId!==this._signalModule.getDeviceId()?o.getIsLocalClientHangup()?l.systemState:exports.RCCallPlusReason.OTHER_CLIENT_HANGUP:l.systemState,this._reportAppEventModule.onCallEnded(new L(o,this,this._logger,this._rtcModule,this._context),n,t),this._reportCallPlusSummaryMessage(o,r,n),this._mainSession&&this._mainSession.getCallId()===r&&(this._mainSession.getAllTimerIds().forEach(e=>this._stopTimer.bind(this)(e,t)),o.getCallType()===exports.RCCallPlusType.SINGLE&&(this._isUpFirstFrameTime=!1),delete this._callStartMap[r]),this._removeSession(r)}_reportCallPlusSummaryMessage(t,i,r){var _,s,o;const l=this._context.getCurrentId(),n=t.getUserList().filter(({userId:e})=>e!==l)[0].userId,a=t.getStartCallerId();if(!localStorage.getItem(`missMessageMap-${l}-${i}`)){const C={callId:i,callerUserId:a,targetId:n,mediaType:t.getMediaType(),firstFrameTime:(null===(_=this._callStartMap[i])||void 0===_?void 0:_.firstFrameTime)||0,callStartTime:(null===(s=this._callStartMap[i])||void 0===s?void 0:s.callStartTime)||0,callEndTime:(null===(o=this._callStartMap[i])||void 0===o?void 0:o.callStartTime)?+new Date-this._timeCorrectioner.getLocalDelayTime():0,hangupReason:r};this._reportAppEventModule.onReceivedCallPlusSummaryMessage({messageType:"RC:CallPlusSummary",content:C,senderUserId:a,targetId:n,channelId:"",conversationType:e.ConversationType.PRIVATE,sentTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),receivedTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),messageUId:i,messageDirection:a===l?e.MessageDirection.SEND:e.MessageDirection.RECEIVE,isPersited:!0,isCounted:!1,isOffLineMessage:!1,canIncludeExpansion:!1,receivedStatus:e.ReceivedStatus.READ,isStatusMessage:!1,isMentioned:!1,expansion:null,disableNotification:!1,sentStatus:e.SentStatus.SENT}),localStorage.setItem(`missMessageMap-${l}-${i}`,i)}}_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,s=!1){return i(this,void 0,void 0,function*(){this._logger.info(_.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T,`callId: ${e}`,t);const{code:i,data:o}=yield this.getCallSession({callId:e},t);if(i!==r.SUCCESS)return void this._logger.error(_.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,`errcode: ${i}`,t);this._logger.info(_.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,`code: ${i}, data: ${JSON.stringify(o)}`,t);const{callType:l,mediaType:n,callSessionUsers:a,startCallerId:C}=o;this._mainSession=new V(e,exports.RCCallPlusCallState.CONNECTING,l,n,C,C,[],this._logger),s&&this._clearMobileOnPhone(e,t);const c=this.updateUsersState(e,a,t);c.length>0&&this.reportRemoteUserStateChange(e,c,t)})}_clearMobileOnPhone(e,t){return i(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()===exports.RCCallPlusType.MULTI){this._logger.info(_.L_CALL_ENGINE_UP_ON_PHONE_END_T,`callId: ${e}`,t);const{code:i}=yield this.systemStatusUp({callId:e,sysStatus:exports.RCCallPlusReason.ON_PHONE_END,forward:X.CURRENT},t);i===r.SUCCESS?this._logger.info(_.L_CALL_ENGINE_UP_ON_PHONE_END_R,`callId: ${e}`,t):this._logger.warn(_.L_CALL_ENGINE_UP_ON_PHONE_END_R,`callId: ${e}, errCode: ${i}`,t)}})}reportRemoteUserStateChange(e,t,i){const r=this._context.getCurrentId();t.forEach(t=>{const{userId:_,userState:s,systemState:o}=t;_!==r&&this._reportAppEventModule.onRemoteUserStateChanged({callId:e,userId:_,userState:s,reason:o},i)}),t.forEach(({userId:t,systemState:_})=>{t===r&&_===exports.RCCallPlusReason.ABNORMAL_END&&this.emit(te.__INNER_SESSION_CLOSE__,e,i)})}_onOtherMemberInvite(e){e.forEach(e=>{var t;const{userId:i,callId:r}=e,_=null===(t=this.getLocalMainSession())||void 0===t?void 0:t.getInviterUserId();this._reportAppEventModule.onRemoteUserInvited([i],_,r)})}_onRequestChangeMediaType(e,t){var i;const{userId:r,transactionId:_,mediaType:s}=e;null===(i=this._mainSession)||void 0===i||i.updateReqMediaType(s),this._reportAppEventModule.onReceivedChangeMediaTypeRequest(r,_,s,t)}_receiveMediaTypeChangeResult(e,t,i){t===exports.RCCallPlusMediaTypeChangeResult.SERVER_ALLOW_MEDIA_TYPE&&this.emit(te.__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 ie,re;Object.defineProperty(te,"__INNER_SESSION_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-close"}),Object.defineProperty(te,"__INNER_SESSION_CONNECT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-connect"}),Object.defineProperty(te,"__INNER_CHANGE_MEDIA_TYPE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-change-media-type"}),Object.defineProperty(te,"__INNER_INVITE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-invite"}),function(e){e.NORMAL="RongCloudRTC",e.SCREEN="ScreenShare"}(ie||(ie={}));class _e extends e.EventEmitter{constructor(e,i,r,_,s,o){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:o}),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:t.RCResolution.W640_H480,frameRate:t.RCFrameRate.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==r?void 0:r.rtcClient,this._isPubTiny=r.isPubTiny||!1}setCallPlusStatusReportListener(e){this._callPlusStatusReportListener=e}getCameraVideoTrack(e){return i(this,void 0,void 0,function*(){const t=this.getLocalVideoTrack(),{code:i,track:_}=t&&!this._videoConfigIsChange?{track:t,code:r.SUCCESS}:yield this._createVideoTrack(e);return this._videoConfigIsChange=!1,i!==r.SUCCESS?{code:i}:{code:r.SUCCESS,track:_}})}getMicrophoneAudioTrack(e){return i(this,void 0,void 0,function*(){const t=this.getLocalAudioTrack(),{code:i,track:_}=t&&!this._audioConfigIsChange?{track:t,code:r.SUCCESS}:yield this._createAudioTrack(e);return this._audioConfigIsChange=!1,i!==r.SUCCESS?{code:i}:{code:r.SUCCESS,track:_}})}createCallMediaTracks(e,t){return i(this,void 0,void 0,function*(){this._callMediaType=e;const{code:i}=yield this.getMicrophoneAudioTrack(t);if(i!==r.SUCCESS)return{code:i};if(e===exports.RCCallPlusMediaType.AUDIO_VIDEO){const{code:e}=yield this.getCameraVideoTrack(t);e!==r.SUCCESS&&this._logger.warn(_.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P,`get camera video track error code: ${e}`,t)}return{code:r.SUCCESS}})}setVideoConfig(e){this._videoConfigIsChange=!0,this._videoConfig=e}setAudioConfig(e){this._audioConfigIsChange=!0,this._audioConfig=e}setAudioOutputDeviceId(e){return i(this,void 0,void 0,function*(){if("string"!=typeof e||0===e.length)return{code:r.PARAM_ERROR};if(this._audioOutputDeviceId===e)return{code:r.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:r.SUCCESS}})}destroyAllTracks(e){this._logger.info(_.L_RTC_MODULE_DESTROY_ALL_TRACKS_O,"",e),this._localTracks.forEach(e=>{e.destroy()}),this._localTracks.length=0}setAllRemoteAudioEnable(t,i){if(this._logger.info(_.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T,`enable: ${t}`,i),!e.isBoolean(t))return this._logger.error(_.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,`param error, enable: type is boolean, value: ${t}`),{code:r.PARAM_ERROR};if(this._remoteAudioEnable=t,!this._room)return{code:r.SUCCESS};return this._room.getRemoteTracks().filter(e=>e.isAudioTrack()).forEach(e=>{t?e.unmute():e.mute()}),this._logger.info(_.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,"success",i),{code:r.SUCCESS}}destroyTrack(e){return i(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 i(this,void 0,void 0,function*(){if(this._preHangupCallId=null,this._logger.info(_.L_RTC_MODULE_SESSION_CONNECT_T,`callId: ${e}`,t),!this._room){const{code:i,room:_}=yield this.joinRTCRoom(e,t);if(i!==r.SUCCESS)return;if(this._room=_,this._preHangupCallId&&this._room.getRoomId()===this._preHangupCallId)return this._rtcClient.leaveRoom(this._room),void this._releaseStoredData();const s=this._room.getRemoteUserIds();this._onSelfJoined(e,s,t)}this._callId=e,this._regRTCListeners();let i=this._room.getRemoteTracks();if(i&&i.length&&this._onRemoteTrackPublish(i),this._localTracks.length>0){this.emit(k.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(k.onPublishRes,i)}else this._logger.warn(_.L_RTC_MODULE_SESSION_CONNECT_P,"sessionConnected local tracks is empty",t);this._logger.info(_.L_RTC_MODULE_SESSION_CONNECT_R,`code: ${r.SUCCESS}`,t)})}sessionClose(e,r){var s;return i(this,void 0,void 0,function*(){this._logger.info(_.L_RTC_MODULE_SESSION_CLOSE_T,`callId: ${e}`,r),this._preHangupCallId=e,this.destroyAllTracks(r);const i=null===(s=this._room)||void 0===s?void 0:s.getRoomId();if(this._room&&e===i){const{code:e}=yield this._rtcClient.leaveRoom(this._room);if(this._releaseStoredData(),e!==t.RCRTCCode.SUCCESS)return void this._logger.error(_.L_RTC_MODULE_SESSION_CLOSE_R,`leaveRoom failed, code: ${e}`,r);this._logger.info(_.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom success",r)}else this._logger.warn(_.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom throw exception: not in room",r)})}disableVideoTrack(){return i(this,void 0,void 0,function*(){const e=this.getLocalVideoTrack();if(!e)return{code:r.CAMERA_CLOSED};return{code:yield e.mute(),track:e}})}enableVideoTrack(e){return i(this,void 0,void 0,function*(){const e=this.getLocalVideoTrack();if(!e)return{code:r.CAMERA_CLOSED};if(!e.isOwnerMuted())return{code:r.SUCCESS};return{code:yield e.unmute()}})}changeVideoDevice(e){return i(this,void 0,void 0,function*(){const i=[],_=[],{code:s,track:o}=yield this._rtcClient.createCameraVideoTrack(ie.NORMAL,this._videoConfig);if(s!==t.RCRTCCode.SUCCESS)return{code:s};const{minBitrate:l,maxBitrate:n}=this._videoConfig;let a;if((l||n)&&o.setBitrate(n,l),this._localTracks&&this._localTracks.forEach(e=>{e.isVideoTrack()?(e.destroy(),a=e):_.push(e)}),this._localTracks=this._localTracks.filter(e=>a&&e.getTrackId()!==a.getTrackId()),i.push(o),_.push(o),this._localTracks=_,this._onLocalTrackReady(i,e),this._room){const{code:e}=yield this._room.publish(i);if(e!==t.RCRTCCode.SUCCESS)return{code:e}}return{code:r.SUCCESS,track:o}})}changeAudioDevice(e){return i(this,void 0,void 0,function*(){const i=[],_=[],s=Object.assign(Object.assign({},this._audioConfig),{micphoneId:this._audioConfig.microphoneId}),{code:o,track:l}=yield this._rtcClient.createMicrophoneAudioTrack(ie.NORMAL,s);if(o!==t.RCRTCCode.SUCCESS)return{code:o};if(this._localTracks&&this._localTracks.forEach(e=>{e.isAudioTrack()||_.push(e)}),i.push(l),_.push(l),this._localTracks=_,this._onLocalTrackReady(i,e),this._room){const{code:e}=yield this._room.publish(i);if(e!==t.RCRTCCode.SUCCESS)return{code:e}}return{code:r.SUCCESS}})}disableAudioTrack(){return i(this,void 0,void 0,function*(){const e=this.getLocalAudioTrack();if(!e)return{code:r.MICROPHONE_CLOSED};return{code:yield e.mute(),track:e}})}changeMediaType(e,t){return i(this,void 0,void 0,function*(){let i;this._logger.info(_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T,`mediaType: ${e}`,t),i=e===exports.RCCallPlusMediaType.AUDIO_VIDEO?yield this._upgradeMediaType(t):yield this._downgradeMediaType(t),i.code===r.SUCCESS&&this._logger.info(_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"success",t)})}_upgradeMediaType(e){return i(this,void 0,void 0,function*(){let t=this.getLocalVideoTrack();if(!t){const{code:i,track:s}=yield this._createVideoTrack(e);if(i!==r.SUCCESS)return this._logger.error(_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`create video track errCode: ${i}`,e),{code:i};t=s;const{minBitrate:o,maxBitrate:l}=this._videoConfig;(o||l)&&t.setBitrate(l,o)}const i=this._isPubTiny?{track:t,isPubTiny:!0}:t,{code:s}=yield this.publish([i],e);return s!==r.SUCCESS&&this._logger.error(_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`publish errCode: ${s}`,e),{code:s}})}_downgradeMediaType(e){return i(this,void 0,void 0,function*(){const i=this.getLocalVideoTrack();if(i){const{code:r}=yield this._room.unpublish([i]);if(r!==t.RCRTCCode.SUCCESS)return this._logger.error(_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`unpublish errCode: ${r}`,e),{code:r};this.destroyTrack(i)}return{code:r.SUCCESS}})}joinRTCRoom(s,o){return i(this,void 0,void 0,function*(){this._logger.info(_.L_RTC_MODULE_JOIN_RTC_ROOM_T,`call: ${s}`,o);const{code:i,room:l,tracks:n}=yield w({asyncFn:this._rtcClient.joinRTCRoomWithOptions.bind(this._rtcClient),fnArgs:[s,{mode:e.RTCMode.CALL}]});return i!==t.RCRTCCode.SUCCESS?(this._logger.error(_.L_RTC_MODULE_JOIN_RTC_ROOM_R,`callId: ${s}, errCode: ${i}`,o),this._onRTCMethodFail(exports.RCCallPlusReason.JOIN_ROOM_ERR,o),{code:i}):(this._logger.info(_.L_RTC_MODULE_JOIN_RTC_ROOM_R,"success",o),this._callId=s,{code:r.SUCCESS,room:l,tracks:n})})}subscribeTracks(e,s){return i(this,void 0,void 0,function*(){if(this._logger.info(_.L_RTC_MODULE_SUBSCRIBE_T,JSON.stringify({params:e.map(e=>{const{track:t,subTiny:i}=e;return{trackId:t.getTrackId(),subTiny:i}})}),s),!this._room)return{code:r.SUCCESS};const{code:i}=yield w({asyncFn:this._room.subscribe.bind(this._room),fnArgs:[e],onError:e=>{}});return i!==t.RCRTCCode.SUCCESS?(this._reportAppEventModule.onFetchRemoteMediaError(e,i),this._onRTCMethodFail(exports.RCCallPlusReason.SUBSCRIBE_ERR,s),this._logger.error(_.L_RTC_MODULE_SUBSCRIBE_R,`errorCode: ${i}`,s),{code:i}):(this._logger.info(_.L_RTC_MODULE_SUBSCRIBE_R,"success",s),{code:r.SUCCESS})})}unsubscribeTracks(e,s){return i(this,void 0,void 0,function*(){if(this._logger.info(_.L_RTC_MODULE_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map(e=>e.getTrackId())}),s),!this._room)return{code:r.SUCCESS};const{code:i}=yield this._room.unsubscribe(e);return i!==t.RCRTCCode.SUCCESS?(this._logger.error(_.L_RTC_MODULE_UNSUBSCRIBE_R,`errorCode: ${i}`,s),{code:i}):(this._logger.info(_.L_RTC_MODULE_UNSUBSCRIBE_R,"success",s),{code:r.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===exports.RCCallPlusMediaType.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(_e.__INNER_RECEIVE_FIRST_FRAME__)}_onKickOff(e,i,r,s){this._logger.info(_.L_RTC_MODULE_RECEIVE_KICK_OFF_O,`roonId: ${i}, byServer: ${e}, state: ${r}, kickExtra: ${JSON.stringify(s)}`);let o=exports.RCCallPlusReason.CONNECTION_ERR;if(e)if(s)o=s.kickReasonCode;else switch(r){case t.RCKickReason.SERVER_KICK:o=exports.RCCallPlusReason.KICKED_BY_SERVER;break;case t.RCKickReason.OTHER_KICK:o=exports.RCCallPlusReason.OTHER_CLIENT_JOINED;break;case t.RCKickReason.IM_DISCONNECTED:o=exports.RCCallPlusReason.CONNECTION_ERR;break;case t.RCKickReason.IM_LOGOUT:o=exports.RCCallPlusReason.LOGOUT;break;case t.RCKickReason.OTHER_CLIENT_IM_CONNECTED:o=exports.RCCallPlusReason.OTHER_CLIENT_LOGIN}this.emit(_e.__INNER_ON_KICKOFF__,o,i)}_onRTCPeerConnectionCloseByException(){const e=this._logger.createTraceId();this._logger.info(_.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O,"",e),this.emit(_e.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,e)}_onSelfJoined(e,t,r){return i(this,void 0,void 0,function*(){this.emit(_e.__INNER_ON_SELF_JOINED__,e,t,r)})}_onRemoteTrackPublish(e){const t=this._logger.createTraceId();this._logger.info(_.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 r=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[r])||void 0===t?void 0:t.videoView){const{isTiny:t}=this._userViewMap[r];i.push({track:e,subTiny:t})}}),i.length&&this.subscribeTracks(i,t)}_onTrackUnpublish(e){return i(this,void 0,void 0,function*(){const t=this._logger.createTraceId();this._logger.info(_.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(_.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(_.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:i,receivers:r}=e;i.forEach(e=>{var t;const{kind:i,packetsLostRate:r,rtt:_}=e;this._callMediaType===exports.RCCallPlusMediaType.AUDIO_VIDEO&&"audio"===i||null===(t=this._callPlusStatusReportListener)||void 0===t||t.onSendPacketLoss(r||0,_||0)}),r.forEach(e=>{var i;const{trackId:r,kind:_,packetsLostRate:s,bitrate:o}=e;if(this._callMediaType===exports.RCCallPlusMediaType.AUDIO_VIDEO&&"audio"===_)return;const{userId:l}=t.helper.parseTrackId(r),n={};n[l]={packetLostRate:s||0,bitRate:o},null===(i=this._callPlusStatusReportListener)||void 0===i||i.onReceivePacketLoss(n)})}_onRTCMethodFail(e,t){this.emit(_e.__INNER_RTC_PROCESS_FAILED__,e,t)}_onOtherMemJoined(e,t){this.emit(_e.__INNER_ON_OTHER_JOINED__,e,t)}_createAudioTrack(e){return i(this,void 0,void 0,function*(){this._logger.info(_.L_RTC_MODULE_CREATE_AUDIO_TRACK_T,"",e);const i=Object.assign(this._audioConfig,{micphoneId:this._audioConfig.microphoneId}),{code:s,track:o}=yield this._rtcClient.createMicrophoneAudioTrack(ie.NORMAL,i);if(s!==t.RCRTCCode.SUCCESS)return this._logger.error(_.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,`errCode: ${s}`,e),{code:s};this._logger.info(_.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,"success",e);const{minBitrate:l,maxBitrate:n}=this._audioConfig;return(l||n)&&o.setBitrate(n,l),this._localTracks.push(o),this._onLocalTrackReady([o],e),{code:r.SUCCESS,track:o}})}_createVideoTrack(e){return i(this,void 0,void 0,function*(){this._logger.info(_.L_RTC_MODULE_CREATE_VIDEO_TRACK_T,"",e);const{code:i,track:s}=yield this._rtcClient.createCameraVideoTrack(ie.NORMAL,this._videoConfig);if(i!==t.RCRTCCode.SUCCESS)return this._logger.error(_.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,`errCode: ${i}`,e),{code:i};this._logger.info(_.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,"success",e);const{minBitrate:o,maxBitrate:l}=this._videoConfig;return(o||l)&&s.setBitrate(l,o),this._localTracks.push(s),this._onLocalTrackReady([s],e),{code:r.SUCCESS,track:s}})}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,s){return i(this,void 0,void 0,function*(){this._logger.info(_.L_RTC_MODULE_PUBLISH_T,`tracksIds: ${e.map(e=>e instanceof t.RCLocalTrack?e.getTrackId():e.track.getTrackId())}`,s);const{code:i}=yield w({asyncFn:this._room.publish.bind(this._room),fnArgs:[e],onError:e=>{}});return i!==t.RCRTCCode.SUCCESS?(this._onRTCMethodFail(exports.RCCallPlusReason.PUBLISH_ERR,s),this._logger.error(_.L_RTC_MODULE_PUBLISH_R,`errCode: ${i}`,s),{code:i}):(this._logger.info(_.L_RTC_MODULE_PUBLISH_R,`code: ${r.SUCCESS}`,s),{code:r.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:r,isTiny:_=!1}=e;if(this._userViewMap[t]={videoView:r,isTiny:_},t===this._context.getCurrentId())return;if(!this._room)return;const s=(this.getRemoteTracks()[t]||[]).map(e=>({track:e,subTiny:_}));i.push(...s)}),this._logger.info(_.L_RTC_MODULE_SET_VIDEO_VIEW_O,JSON.stringify({userViewMap:R(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(_.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O,JSON.stringify({userViewMap:R(this._userViewMap),unsubTracks:i.map(e=>e.getTrackId())}),t),i.length&&this.unsubscribeTracks(i,t)}getUserViewMap(){return this._userViewMap}playMedia(e,s,o,l){var n;return i(this,void 0,void 0,function*(){this._logger.info(_.L_RTC_MODULE_PLAY_MEDIA_T,`userId: ${e}, mediaType: ${s}, videoView: ${null==o?void 0:o.nodeName}`,l);const i=this._context.getCurrentId();if(e===i&&s===exports.RCCallPlusMediaType.AUDIO)return this._logger.error(_.L_RTC_MODULE_PLAY_MEDIA_R,"please avoid playing local audio to prevent echoes.",l),{code:r.PLAY_MEDIA_FAILED};let a=null;if(a=e===i?s===exports.RCCallPlusMediaType.AUDIO?null:this.getLocalVideoTrack():null===(n=this.getRemoteTracks()[e])||void 0===n?void 0:n.filter(e=>s===exports.RCCallPlusMediaType.AUDIO?e.isAudioTrack():e.isVideoTrack())[0],!a)return this._logger.error(_.L_RTC_MODULE_PLAY_MEDIA_R,`error code: ${r.MEDIA_RESOURCE_INVALIED}`,l),{code:r.MEDIA_RESOURCE_INVALIED};try{const{code:e}=a.isAudioTrack()?yield a.play(void 0,{audioDeviceId:this._audioOutputDeviceId||void 0}):yield a.play(o);return a.isAudioTrack()&&!this._remoteAudioEnable&&a.mute(),e!==t.RCRTCCode.SUCCESS?(this._logger.error(_.L_RTC_MODULE_PLAY_MEDIA_R,`errCode: ${e}`,l),{code:e}):(this._logger.info(_.L_RTC_MODULE_PLAY_MEDIA_R,"success",l),{code:r.SUCCESS})}catch(e){return this._logger.error(_.L_RTC_MODULE_PLAY_MEDIA_R,`errCode: ${r.PLAY_MEDIA_FAILED}, message: ${e.message},`,l),{code:r.PLAY_MEDIA_FAILED}}})}}Object.defineProperty(_e,"__INNER_RTC_PROCESS_FAILED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-process-failed"}),Object.defineProperty(_e,"__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-peerconnection-abnormal-close"}),Object.defineProperty(_e,"__INNER_ON_SELF_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-self-joined"}),Object.defineProperty(_e,"__INNER_ON_OTHER_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-other-joined"}),Object.defineProperty(_e,"__INNER_RECEIVE_FIRST_FRAME__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-receive-first-frame"}),Object.defineProperty(_e,"__INNER_ON_KICKOFF__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-kickoff-frame"});class se{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 r;return i(this,void 0,void 0,function*(){const i=null===(r=this._listener)||void 0===r?void 0:r[e];if(i)try{yield i(...t)}catch(e){console.error(e),this._logger.error(_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({name:e.name,message:e.message}))}})}onReceivedCall(e,t,i){this._logger.info(_.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(_.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(_.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(_.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:r,userState:s,reason:o}=e;this._logger.info(_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserStateChanged",callId:i,userId:r,userState:s,reason:o}),t),this._callAppListener("onRemoteUserStateChanged",i,r,s,o)}onCallEnded(e,t,i){this._logger.info(_.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(_.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(_.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(_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallRecord",record:e}),t),this._callAppListener("onReceivedCallRecord",e)}onReceivedChangeMediaTypeRequest(e,t,i,r){this._logger.info(_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeRequest",userId:e,transactionId:t}),r),this._callAppListener("onReceivedChangeMediaTypeRequest",e,t,i)}onReceivedChangeMediaTypeResult(e,t){const{userId:i,transactionId:r,mediaType:s,code:o}=e;this._logger.info(_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeResult",userId:i,mediaType:s}),t),this._callAppListener("onReceivedChangeMediaTypeResult",{userId:i,transactionId:r,mediaType:s,code:o})}onReceivedCallStartTime(e,t){this._logger.info(_.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(_.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(_.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()?exports.RCCallPlusMediaType.AUDIO:exports.RCCallPlusMediaType.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"}(re||(re={}));class oe{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(t){return e.isString(t)?(this._androidPushConfig.channelIdMi=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdMi type is string, value: ${t}`),this)}setMiLargeIconUrl(e){return this._logger.warn(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"`setMiLargeIconUrl` has been deprecated."),this}setChannelIdHW(t){return e.isString(t)?(this._androidPushConfig.channelIdHW=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdHW type is string, value: ${t}`),this)}setCategoryHW(t){return e.isString(t)?(this._androidPushConfig.categoryHW=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: categoryHW type is string, value: ${t}`),this)}setImportanceHW(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: importanceHW value is NORMAL|LOW, value: ${e}`),this):(this._androidPushConfig.importanceHW=e,this)}setImageUrlHW(t){return e.isString(t)?(this._androidPushConfig.imageUrlHW=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: imageUrlHW type is string, value: ${t}`),this)}setChannelIdOPPO(t){return e.isString(t)?(this._androidPushConfig.channelIdOPPO=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdOPPO type is string, value: ${t}`),this)}setTypeVivo(t){return e.isString(t)?(this._androidPushConfig.typeVivo=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: typeVivo type is string, value: ${t}`),this)}setCategoryVivo(t){return e.isString(t)?(this._androidPushConfig.categoryVivo=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: categoryVivo type is string, value: ${t}`),this)}setFcmChannelId(t){return e.isString(t)?(this._androidPushConfig.fcmChannelId=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmChannelId type is string, value: ${t}`),this)}setFcmCollapseKey(t){return e.isString(t)?(this._androidPushConfig.fcmCollapseKey=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmCollapseKey type is string, value: ${t}`),this)}setFcmImageUrl(t){return e.isString(t)?(this._androidPushConfig.fcmImageUrl=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmImageUrl type is string, value: ${t}`),this)}setimportanceHonor(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: importanceHonor value is NORMAL|LOW, value: ${e}`),this):(this._androidPushConfig.importanceHonor=e,this)}setimageUrlHonor(t){return e.isString(t)?(this._androidPushConfig.imageUrlHonor=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: imageUrlHonor type is string, value: ${t}`),this)}build(){return this._androidPushConfig}}class le{constructor(e,i,_,s){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:t.RCResolution.W640_H480,frameRate:t.RCFrameRate.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 se(i),this._callPlusStatistics=new G(this._logger,this._context),this._callEngine=new te(this._context,this._runtime,this._initOpts,this._logger,this._reportAppEventModule),this._rtcModule=new _e(this._context,this._runtime,this._initOpts,this._logger,this._callEngine,this._reportAppEventModule),this._callEngine.setRTCModule(this._rtcModule),this._rtcModule.on(_e.__INNER_RTC_PROCESS_FAILED__,this._rtcProcessFailHandle.bind(this)),this._rtcModule.on(_e.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,this._peerConnectionAbnormalClose.bind(this)),this._rtcModule.on(_e.__INNER_ON_SELF_JOINED__,this._selfJoinedHandle.bind(this)),this._rtcModule.on(_e.__INNER_ON_OTHER_JOINED__,this._otherJoinedHandle.bind(this)),this._rtcModule.on(_e.__INNER_RECEIVE_FIRST_FRAME__,this._receiveFirstFrameHandle.bind(this)),this._rtcModule.on(_e.__INNER_ON_KICKOFF__,this._kickoffHandle.bind(this)),this._callEngine.on(te.__INNER_SESSION_CONNECT__,this._rtcModule.sessionConnected.bind(this._rtcModule)),this._callEngine.on(te.__INNER_SESSION_CLOSE__,this._sessionCloseHandle.bind(this)),this._callEngine.on(te.__INNER_CHANGE_MEDIA_TYPE__,this._rtcModule.changeMediaType.bind(this._rtcModule)),this._callEngine.on(te.__INNER_INVITE__,(e,t)=>{this._callPlusStatistics.reportStatisticsData(f.L_QS_RECEIVE_CALL_S,r.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:X.CURRENT},t),this._callPlusStatistics.reportStatisticsData(f.L_QS_ABNORMAL_HANGUP_S,r.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:exports.RCCallPlusReason.CONNECTION_ERR,forward:X.CURRENT},e),this._callEngine.endCurrentSession(exports.RCCallPlusReason.CONNECTION_ERR,t.getCallId(),e))}_selfJoinedHandle(e,t,r){return i(this,void 0,void 0,function*(){const i=this._context.getCurrentId(),_=this._callEngine.getLocalMainSession();((null==_?void 0:_.getCallType())===exports.RCCallPlusType.MULTI||t.length)&&this._callEngine.updateMainSessionState(exports.RCCallPlusCallState.ONCALL);const s=[i,...t].map(e=>({userId:e,userState:exports.RCCallPlusSessionUserState.ONCALL,systemState:exports.RCCallPlusReason.ONCALL})),o=this._callEngine.updateUsersState(e,s,r);this._reportAppEventModule.onCallConnected(_),o.length>0&&this._callEngine.reportRemoteUserStateChange(e,o,r),this._callEngine.startTimeCorrection(r)})}_otherJoinedHandle(e,t){var i;let r="";const _=e.map(e=>(r=e.callId,{userId:e.userId,userState:exports.RCCallPlusSessionUserState.ONCALL,systemState:exports.RCCallPlusReason.ONCALL})),s=this._callEngine.updateUsersState(r,_,t);s.length>0&&this._callEngine.reportRemoteUserStateChange(r,s,t),(null===(i=this._callEngine.getLocalMainSession())||void 0===i?void 0:i.getState())!==exports.RCCallPlusCallState.ONCALL&&this._callEngine.updateMainSessionState(exports.RCCallPlusCallState.ONCALL)}_receiveFirstFrameHandle(e){var t;(null===(t=this._callEngine.getLocalMainSession())||void 0===t?void 0:t.getState())!==exports.RCCallPlusCallState.ONCALL&&this._callEngine.updateMainSessionState(exports.RCCallPlusCallState.ONCALL),this._callEngine.upFirstFrameTime(e)}_kickoffHandle(e,t,i){if(e===exports.RCCallPlusReason.CONNECTION_ERR)return void this._callEngine.endCurrentSession(e,t,i);const _=this._callEngine.getLocalMainSession();if(_){const s=_.getCallId();this._callPlusStatistics.reportStatisticsData(f.L_QS_ABNORMAL_HANGUP_S,r.SUCCESS,+new Date,_,this._clientCallId),this._callEngine.systemStatusUp({callId:s,sysStatus:e,forward:X.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(_.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._reportAppEventModule.registerEventListener(e)}setStatusReportListener(e){this._logger.info(_.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._rtcModule.setCallPlusStatusReportListener(e)}setVideoView(t){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T,JSON.stringify({list:t.map(e=>{const{userId:t,videoElement:i,isTiny:r}=e;return{userId:t,elementName:null==i?void 0:i.nodeName,isTiny:r}})}),i),!e.notEmptyArray(t))return this._logger.error(_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, list: not empty array, value: ${JSON.stringify(t)}`,i),{code:r.PARAM_ERROR};for(const s of t){const{userId:t,videoElement:o}=s;if(!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, userId: not empty string, value: ${t}`,i),{code:r.PARAM_ERROR};if(!u(o))return this._logger.error(_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, videoElement: need a video element, value: ${o instanceof HTMLElement?o.nodeName:o}`,i),{code:r.PARAM_ERROR}}return this._logger.info(_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"succes",i),this._rtcModule.setVideoView(t,i),{code:r.SUCCESS}}removeVideoView(t){const i=this._logger.createTraceId();return this._logger.info(_.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T,JSON.stringify({userIds:t}),i),e.notEmptyArray(t)&&t.every(t=>e.notEmptyString(t))?(this._logger.info(_.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,"succes",i),this._rtcModule.removeVideoView(t,i),{code:r.SUCCESS}):(this._logger.error(_.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(t)}`,i),{code:r.PARAM_ERROR})}playMedia(t,s){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_PLAY_MEDIA_T,JSON.stringify({userId:t,mediaType:s}),i),!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`params err, userId: not empty string, value: ${t}`,i),{code:r.PARAM_ERROR};if(e.isUndefined(exports.RCCallPlusMediaType[s]))return this._logger.error(_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`params err, mediaType is illegal, value: ${s}`,i),{code:r.PARAM_ERROR};if(s===exports.RCCallPlusMediaType.AUDIO&&t===this._context.getCurrentId())return this._logger.info(_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"success",i),{code:r.SUCCESS};const{videoView:o}=this._rtcModule.getUserViewMap()[t]||{};return s===exports.RCCallPlusMediaType.AUDIO||o?this._rtcModule.playMedia(t,s,o,i):(this._logger.error(_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`errCode: ${r.VIDEO_VIEW_NOT_SET}, video view not set`,i),{code:r.VIDEO_VIEW_NOT_SET})})}createVideoConfigBuilder(){return new d(this._logger)}setVideoConfig(e){this._logger.info(_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T,JSON.stringify(e));const{frameRate:i,resolution:s,maxBitrate:o,minBitrate:l}=e;if(!t.RCFrameRate[i])return this._logger.error(_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,`param error, frameRate is illegal, value: ${i}`),{code:r.PARAM_ERROR};if(!t.RCResolution[s])return this._logger.error(_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,`param error, resolution is illegal, value: ${s}`),{code:r.PARAM_ERROR};const{code:n,errorMsg:a}=I(l,o);return n!==r.SUCCESS&&this._logger.error(_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,a),this._logger.info(_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"success"),this._videoConfig=Object.assign({},e),this._rtcModule.setVideoConfig(this._videoConfig),{code:r.SUCCESS}}createAudioConfigBuilder(){return new E(this._logger)}createAndroidPushConfigBuilder(){return new oe(this._logger)}setAudioConfig(t){this._logger.info(_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T,JSON.stringify(t));const{sampleRate:i,minBitrate:s,maxBitrate:o}=t;if(i&&!e.isNumber(i))return this._logger.error(_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,`param error, sampleRate: type is number, value: ${i}`),{code:r.PARAM_ERROR};const{code:l,errorMsg:n}=I(s,o);return l!==r.SUCCESS&&this._logger.error(_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,n),this._logger.info(_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,"success"),this._audioConfig=Object.assign({},t),this._rtcModule.setAudioConfig(this._audioConfig),{code:r.SUCCESS}}setAudioOutputDeviceId(e){return this._logger.info(_.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O,e),this._rtcModule.setAudioOutputDeviceId(e)}startCall(t,s=exports.RCCallPlusType.SINGLE,o=exports.RCCallPlusMediaType.AUDIO_VIDEO,l,n,a){return i(this,void 0,void 0,function*(){this._clientCallId=e.getUUID();const i=+new Date,C=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_START_CALL_T,`userIds: ${t.join(",")}, callType: ${s}, mediaType: ${o}, pushConfig: ${l}, extra: ${n}`,C),this._context.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED)return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${r.SIGNAL_DISCONNECTED}`,C),{code:r.SIGNAL_DISCONNECTED};const c=this._context.getNaviInfo();if(!c||!S(c))return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${r.RTC_SERVICE_UNAVAILABLE}`,C),{code:r.RTC_SERVICE_UNAVAILABLE};if(!e.notEmptyArray(t)||!t.every(t=>e.notEmptyString(t)))return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(t)}`,C),{code:r.PARAM_ERROR};if(e.isUndefined(exports.RCCallPlusType[s]))return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, callType is illegal, value: ${s}`,C),{code:r.PARAM_ERROR};if(e.isUndefined(exports.RCCallPlusMediaType[o]))return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, mediaType is illegal, value: ${o}`,C),{code:r.PARAM_ERROR};if(l){const e=A(l);if(e.code!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,C),{code:r.PARAM_ERROR}}if(n){if(!e.isString(n))return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, extra is illegal, type: string, value: ${n}`,C),{code:r.PARAM_ERROR};if(p(n)>F)return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,"params err, extra max size is 128KB",C),{code:r.PARAM_ERROR}}if(t.length>1&&s===exports.RCCallPlusType.SINGLE)return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, You can only call one person in a single call, userIds: ${t.join(",")}`,C),{code:r.PARAM_ERROR};if(a&&!e.isString(a))return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, targetId is illegal, type: string, value: ${a}`,C),{code:r.PARAM_ERROR};if(this._callEngine.getLocalMainSession())return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${r.SESSION_EXIST}, session exist`,C),{code:r.SESSION_EXIST};const{code:L}=yield this._rtcModule.createCallMediaTracks(o,C);if(L!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`create meida tracks error code: ${L}`,C),{code:L};const{code:E,data:d}=yield this._callEngine.startCall({toUsers:t.map(e=>({userId:e})),callType:s,mediaType:o,callId:this._clientCallId,pushConfig:l,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:n}),targetId:a},C);if(this._callPlusStatistics.reportStatisticsData(f.L_QS_START_CALL_S,E,i,null,this._clientCallId,null,{mediaType:o,callType:s,callId:(null==d?void 0:d.callId)||""}),E!==r.SUCCESS)return this._rtcModule.destroyAllTracks(C),this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`signal error code: ${E}`,C),{code:E};const{callId:T,clientCallId:u}=d;return this._needHangupCallId===u?(this._callEngine.clearAllTimer(T,C),this._callEngine.hangup({callId:T,systemState:exports.RCCallPlusReason.CANCELLED},C),this._logger.info(_.L_CALLPLUS_CLIENT_START_CALL_R,`the ${T} call has been hangup`,C),{code:r.SUCCESS}):(s===exports.RCCallPlusType.MULTI&&this._rtcModule.sessionConnected(T,C),this._logger.info(_.L_CALLPLUS_CLIENT_START_CALL_R,JSON.stringify({data:d,code:E}),C),{code:r.SUCCESS,callId:T})})}joinMultiCall(t){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T,`callId: ${t}`,i),this._context.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED)return this._logger.error(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${r.SIGNAL_DISCONNECTED}`,i),{code:r.SIGNAL_DISCONNECTED};const s=this._context.getNaviInfo();if(!s||!S(s))return this._logger.error(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${r.RTC_SERVICE_UNAVAILABLE}`,i),{code:r.RTC_SERVICE_UNAVAILABLE};if(!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`params err, callId: not empty string, value: ${t}`,i),{code:r.PARAM_ERROR};const{code:o,data:l}=yield this._callEngine.getCallSession({callId:t},i);if(o!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`get call data error, code: ${o}`,i),{code:o};const{mediaType:n}=l,a=this._callEngine.getLocalMainSession();if(a&&a.getCallId()!==t)return{code:r.SESSION_EXIST};const{code:C}=yield this._rtcModule.createCallMediaTracks(n,i);if(C!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`create meida tracks error code: ${C}`,i),{code:C};const{code:c}=yield this._callEngine.joinCall({callId:t,mediaType:n},i);return c!==r.SUCCESS?(this._rtcModule.destroyAllTracks(i),this._logger.error(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`signal error code: ${c}`,i),{code:c}):(this._logger.info(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${r.SUCCESS}`,i),yield this._rtcModule.sessionConnected(t,i),{code:r.SUCCESS})})}invite(t,s,o){var l;return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_INVITE_T,`callId: ${t.join(",")}, pushConfig: ${s}, extra: ${o}`,i),!e.notEmptyArray(t)||!t.every(t=>e.notEmptyString(t)))return this._logger.error(_.L_CALLPLUS_CLIENT_INVITE_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(t)}`,i),{code:r.PARAM_ERROR};if(s){const e=A(s);if(e.code!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_INVITE_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,i),{code:r.PARAM_ERROR}}if(o){if(!e.isString(o))return this._logger.error(_.L_CALLPLUS_CLIENT_INVITE_R,`params err, extra is illegal, value: ${o}`,i),{code:r.PARAM_ERROR};if(p(o)>F)return this._logger.error(_.L_CALLPLUS_CLIENT_INVITE_R,"params err, extra max size is 128KB",i),{code:r.PARAM_ERROR}}const{code:n,data:a}=yield this._callEngine.invite({toUsers:t.map(e=>({userId:e})),pushConfig:s,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:o})},i);if(n!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_INVITE_R,`signal error code: ${n}`,i),{code:n};const C=[];return(null===(l=a.busylineUsers)||void 0===l?void 0:l.length)&&C.push(...a.busylineUsers.map(e=>({userId:e.userId,state:e.sessionStatus}))),this._logger.info(_.L_CALLPLUS_CLIENT_INVITE_R,`success busyUsers: ${JSON.stringify(C)}`,i),{code:r.SUCCESS,busyUsers:C}})}accept(t,s){return i(this,void 0,void 0,function*(){const i=+new Date,o=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_ACCEPT_T,`callId: ${t}, pushConfig: ${s}`,o),this._context.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED)return this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode: ${r.SIGNAL_DISCONNECTED}`,o),{code:r.SIGNAL_DISCONNECTED};const l=this._context.getNaviInfo();if(!l||!S(l))return this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode: ${r.RTC_SERVICE_UNAVAILABLE}`,o),{code:r.RTC_SERVICE_UNAVAILABLE};if(!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`params err, callId: not empty string, value: ${t}`,o),{code:r.PARAM_ERROR};if(s){const e=A(s);if(e.code!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,o),{code:r.PARAM_ERROR}}let n=this._callEngine.getLocalMainSession();const a=this._callEngine.getHoldSession(t);if(!n&&!a)return this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode : ${r.NOT_IN_CALL}, session not exist`,o),{code:r.NOT_IN_CALL};if(t===(null==a?void 0:a.getCallId())){const{code:e}=yield this.hangup(n.getCallId());if(e!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`hangup mainSession error code: ${e}`,o),{code:e};this._callEngine.upgradeMainSession(t),n=this._callEngine.getLocalMainSession()}const C=n.getMediaType(),{code:c}=yield this._rtcModule.createCallMediaTracks(C,o);if(c!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`create meida tracks error code: ${c}`,o),{code:c};const{code:L}=yield this._callEngine.accept({callId:t},o);return this._callPlusStatistics.reportStatisticsData(f.L_QS_ACCEPT_CALL_S,L,i,n),L!==r.SUCCESS?(this._rtcModule.destroyAllTracks(o),this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`signal error code: ${L}`,o),{code:L}):(this._logger.info(_.L_CALLPLUS_CLIENT_ACCEPT_R,"success",o),this._rtcModule.sessionConnected(t,o),{code:r.SUCCESS})})}__innerHangup(e,t){var _;return i(this,void 0,void 0,function*(){const{callId:i}=e;this._callEngine.setIsLocalClientHangup(!0),this._callEngine.clearAllTimer(i,t);const{code:s}=yield this._callEngine.hangup(e,t);return s===re.CALL_NOT_EXIST?{code:r.SUCCESS}:(s===r.SUCCESS&&i===(null===(_=this._callEngine.getLocalMainSession())||void 0===_?void 0:_.getCallId())&&(yield this._rtcModule.sessionClose(i,t)),{code:s})})}hangup(t,s){return i(this,void 0,void 0,function*(){const i=+new Date,o=this._logger.createTraceId();this._logger.info(_.L_CALLPLUS_CLIENT_HANGUP_T,`callId: ${t}, pushConfig: ${s}`,o);const l=this._callEngine.getLocalMainSession();if(!l)return{code:r.NOT_IN_CALL};if(t&&!e.isString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_HANGUP_R,`params err, callId: type is string, value: ${t}`,o),{code:r.PARAM_ERROR};if(s){const e=A(s);if(e.code!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_HANGUP_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,o),{code:r.PARAM_ERROR}}const n=l.getCallId();if(t&&t!==n&&!this._callEngine.getHoldSession(t))return this._logger.error(_.L_CALLPLUS_CLIENT_HANGUP_R,`params err, callId is invalid, value: ${t}`,o),{code:r.CALL_ID_INVALID};this._isLaunchHangup=!0,this._needHangupCallId=t||n;const a=this._callEngine.getHoldSession(this._needHangupCallId)||l,C=this._context.getCurrentId(),c=((e,t)=>{let i;switch(e){case exports.RCCallPlusSessionUserState.CALLING:i=exports.RCCallPlusReason.CANCELLED;break;case exports.RCCallPlusSessionUserState.RINGING:case exports.RCCallPlusSessionUserState.INVITED:i=exports.RCCallPlusReason.DECLINED;break;case exports.RCCallPlusSessionUserState.CONNECTING:i=t?exports.RCCallPlusReason.DECLINED:exports.RCCallPlusReason.CANCELLED;break;case exports.RCCallPlusSessionUserState.ONCALL:i=exports.RCCallPlusReason.ENDED}return i})(l.getUserList().filter(e=>e.userId===C)[0].state,[l.getCreatorUserId(),l.getInviterUserId()].includes(C))||exports.RCCallPlusReason.ENDED,{code:L}=yield this.__innerHangup({callId:this._needHangupCallId,systemState:c,pushConfig:s},o);return this._callPlusStatistics.reportStatisticsData(f.L_QS_HANGUP_CALL_S,L,i,a,this._clientCallId),L!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_HANGUP_R,`signal error code : ${L}`,o),{code:L}):(this._needHangupCallId=null,this._logger.info(_.L_CALLPLUS_CLIENT_HANGUP_R,"success",o),{code:r.SUCCESS})})}requestChangeMediaType(t){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T,`mediaType: ${t}`,i),e.isUndefined(exports.RCCallPlusMediaType[t]))return this._logger.error(_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`params err, mediaType is illegal, value: ${t}`,i),{code:r.PARAM_ERROR};const s=this.getCurrentCallSession(),o=null==s?void 0:s.getMediaType();if(t===o)return this._logger.error(_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`error code: ${r.MEDIATYPE_INVALID}`,i),{code:r.MEDIATYPE_INVALID};if(!this._callEngine.getLocalMainSession())return this._logger.error(_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`error code : ${r.NOT_IN_CALL}, session not exist`,i),{code:r.NOT_IN_CALL};const l=null==s?void 0:s.getUserList().filter(e=>e.userId!==this._context.getCurrentId()).map(e=>e.userId),{code:n,data:a}=yield this._callEngine.requestChangeMediaType({mediaType:t,toUserIds:l||[]},i);return n!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`signal error code: ${n}`,i),{code:n}):(this._logger.info(_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`success transactionId: ${a.transactionId}`,i),{code:r.SUCCESS,transactionId:a.transactionId})})}cancelChangeMediaType(t){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T,`transactionId: ${t}`,i),!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`param error, transactionId: not empty string, value: ${t}`,i),{code:r.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`error code : ${r.NOT_IN_CALL}, session not exist`,i),{code:r.NOT_IN_CALL};const{code:s}=yield this._callEngine.cancelChangeMediaType({transactionId:t},i);return s!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`signal error code: ${s}`,i),{code:s}):(this._logger.info(_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"success",i),{code:r.SUCCESS})})}replyChangeMediaType(t,s){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T,`transactionId: ${t}`,i),!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`param error, transactionId: not empty string, value: ${t}`,i),{code:r.PARAM_ERROR};if(!e.isBoolean(s))return this._logger.error(_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`param error, isAgree: type is boolean, value: ${s}`,i),{code:r.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`error code : ${r.NOT_IN_CALL}, session not exist`,i),{code:r.NOT_IN_CALL};const{code:o}=yield this._callEngine.responseChangeMediaType({transactionId:t,agree:s},i);return o!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`signal error: ${o}`,i),{code:o}):(this._logger.info(_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"success",i),{code:r.SUCCESS})})}getCurrentCallSession(){return this._callEngine.getLocalMainSession()}getAvailableCallRecordsFromServer(){return i(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(_.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T,"",e);const{code:t,data:i}=yield this._callEngine.getOpenCallList(e);return t!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(_.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,`success, data: ${JSON.stringify(i)}`,e),{code:r.SUCCESS,records:i})})}getCallRecords(t,s,o=0){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T,`startTimestamp: ${t}, count: ${s}`,i),!(e.isNumber(t)&&t>=0))return this._logger.error(_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`params error, startTimestamp: is a number >= 0, value: ${t}`,i),{code:r.PARAM_ERROR};if(!(e.isNumber(s)&&s>0))return this._logger.error(_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`params error, count: is a number >= 0, value: ${s}`,i),{code:r.PARAM_ERROR};const{code:l,data:n}=yield this._callEngine.getCallLogList({timestamp:t,count:s,order:o},i);return l!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`signal error code: ${l}`,i),{code:l}):(this._logger.info(_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"success",i),{code:r.SUCCESS,result:n})})}deleteCallRecordsFromServer(t){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T,`callIds: ${t.join(",")}`,i),!e.notEmptyArray(t)||!t.every(t=>e.notEmptyString(t)))return this._logger.error(_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,`params err, callIds: not empty array, callId: not empty string, callIds: ${JSON.stringify(t)}`,i),{code:r.PARAM_ERROR};const{code:s}=yield this._callEngine.deleteCallLog(t,i);return s!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,`signal error code: ${s}`,i),{code:s}):(this._logger.info(_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"success",i),{code:r.SUCCESS})})}deleteAllCallRecordsFromServer(){return i(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(_.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T,"",e);const{code:t}=yield this._callEngine.removeAllCallLog(e);return t!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(_.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,"success",e),{code:r.SUCCESS})})}startCamera(){var e;return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();this._logger.info(_.L_CALLPLUS_CLIENT_START_CAMERA_T,"",i);const{code:s,track:o}=yield this._rtcModule.getCameraVideoTrack(i);if(s!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_START_CAMERA_R,`create video track error code: ${s}`,i),{code:s};if(!(null==o?void 0:o.isPublished())&&(null===(e=this._callEngine.getLocalMainSession())||void 0===e?void 0:e.getState())===exports.RCCallPlusCallState.ONCALL){const{code:e}=yield this._rtcModule.publishVideoTrack();return e!==t.RCRTCCode.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_START_CAMERA_R,`publish error code: ${e}`,i),{code:e}):(this._logger.info(_.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",i),{code:r.SUCCESS})}const{code:l}=yield this._rtcModule.enableVideoTrack(i);return l!==t.RCRTCCode.SUCCESS&&l!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_START_CAMERA_R,`signal error code: ${l}`,i),{code:l}):(this._logger.info(_.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",i),{code:r.SUCCESS})})}stopCamera(){return i(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(_.L_CALLPLUS_CLIENT_STOP_CAMERA_T,"",e);const{code:i,track:s}=yield this._rtcModule.disableVideoTrack();return i!==r.SUCCESS&&i!==t.RCRTCCode.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_STOP_CAMERA_R,`error code: ${i}`,e),{code:i}):(this._rtcModule.destroyTrack(s),this._logger.info(_.L_CALLPLUS_CLIENT_STOP_CAMERA_R,"success",e),{code:r.SUCCESS})})}switchCamera(t){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T,`cameraId: ${t}`,i),!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`param error, cameraId: not empty string, value: ${t}`,i),{code:r.PARAM_ERROR};const s=this._callEngine.getLocalMainSession();if(!s)return this._logger.error(_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`errCode: ${r.NOT_IN_CALL}`,i),{code:r.NOT_IN_CALL};if(s.getMediaType()===exports.RCCallPlusMediaType.AUDIO)return this._logger.error(_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`errCode: ${r.NOT_VIDEO_CALL}`,i),{code:r.NOT_VIDEO_CALL};this._videoConfig.cameraId=t,this._rtcModule.setVideoConfig(this._videoConfig);const{code:o}=yield this._rtcModule.changeVideoDevice(i);return o!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`call client changeVideoDevice error code: ${o}`,i),{code:o}):(this._logger.info(_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"success",i),{code:r.SUCCESS})})}startMicrophone(){return i(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(_.L_CALLPLUS_CLIENT_START_MICROPHONE_T,"",e);const{code:i,track:s}=yield this._rtcModule.getMicrophoneAudioTrack(e);if(i!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,`create microphone audio track error code: ${i}`,e),{code:i};if(!s.isOwnerMuted())return this._logger.info(_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),{code:r.SUCCESS};const o=yield s.unmute();return o!==t.RCRTCCode.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,`signal error code: ${i}`,e),{code:o}):(this._logger.info(_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),{code:r.SUCCESS})})}stopMicrophone(){return i(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(_.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T,"",e);const{code:i}=yield this._rtcModule.disableAudioTrack();return i!==r.SUCCESS&&i!==t.RCRTCCode.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,`signal error code: ${i}`,e),{code:i}):(this._logger.info(_.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,"success",e),{code:r.SUCCESS})})}isMicrophoneEnabled(){const e=this._rtcModule.getLocalAudioTrack();return!!e&&!e.isOwnerMuted()}setAllRemoteAudioEnable(e){return i(this,void 0,void 0,function*(){const t=this._logger.createTraceId();return this._rtcModule.setAllRemoteAudioEnable(e,t)})}getVersion(){return"2.44.0"}getCameras(){return i(this,void 0,void 0,function*(){return t.device.getCameras()})}getMicrophones(){return i(this,void 0,void 0,function*(){return t.device.getMicrophones()})}getSpeakers(){return i(this,void 0,void 0,function*(){return t.device.getSpeakers()})}getRTCSessionId(){return this._rtcModule.getRTCSessionId()}switchMicrophone(t){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T,`microphoneId: ${t}`,i),!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`param error, microphoneId: not empty string, value: ${t}`,i),{code:r.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`errCode: ${r.NOT_IN_CALL}`,i),{code:r.NOT_IN_CALL};this._audioConfig.microphoneId=t,this._rtcModule.setAudioConfig(this._audioConfig);const{code:s}=yield this._rtcModule.changeAudioDevice(i);return s!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`call client changeAudioDevice error code: ${s}`,i),{code:s}):(this._logger.info(_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"success",i),{code:r.SUCCESS})})}}e.VersionManage.add("callplus","2.44.0");const ne={tag:"RCCallPlus",verify:t=>!!e.VersionManage.validEngine("5.44.0")||(console.error(`The current engine version '${e.VersionManage.getInfo().engine}' error, plugin-call-plus required engine version at least '5.44.0'.`),!1),setup(t,i,s){const o=(l=s)?e.isObject(l)?Object.keys(l).includes("rtcClient")?e.isObject(l.rtcClient)?{isLegal:!0}:{isLegal:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:{isLegal:!1,code:r.NOT_INSTALL_RTC_PLUGIN}:{isLegal:!1,msg:"Initialization options must be an object"}:{isLegal:!1,msg:"Initialization missing parameter -> options"};var l;if(!o.isLegal)throw new Error(`[CallPlusLib installer steup]${o.msg}`);e.isUndefined(s.isAllowNewCallWhenRinging)&&(s.isAllowNewCallWhenRinging=!0);const n=t.createLogger("CallPlus","RTC"),a=e.isUndefined(s.logOutputLevel)?e.LogL.WARN:s.logOutputLevel;return n.setOutputLevel(a),n.warn(_.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O,`CallPlus Version: 2.44.0, Commit: 7667d7a6b033b7320ce3fd33b4c8e5fc3f37c790, isAllowNewCallWhenRinging: ${s.isAllowNewCallWhenRinging}`),new le(t,n,i,s)}};Object.defineProperty(exports,"RCCallPlusFrameRate",{enumerable:!0,get:function(){return t.RCFrameRate}}),Object.defineProperty(exports,"RCCallPlusResolution",{enumerable:!0,get:function(){return t.RCResolution}}),exports.RCAudioConfigBuilder=E,exports.RCCallPlusAndroidPushConfigBuilder=oe,exports.RCCallPlusClient=le,exports.RCCallPlusCode=r,exports.RCCallPlusSession=L,exports.RCVideoConfigBuilder=d,exports.installer=ne;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@rongcloud/engine"),t=require("@rongcloud/plugin-rtc");function i(e,t,i,r){return new(i||(i=Promise))(function(_,s){function l(e){try{n(r.next(e))}catch(e){s(e)}}function o(e){try{n(r.throw(e))}catch(e){s(e)}}function n(e){var t;e.done?_(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(l,o)}n((r=r.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const r={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 _,s,l,o,n,a,C,c;!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"}(_||(_={}));class L{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:r}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:_}),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 r=null,_=null;return t===this._context.getCurrentId()?(r=this._rtcModule.getLocalVideoTrack(),_=this._rtcModule.getLocalAudioTrack()):(r=this._rtcModule.getRemoteTrack(t,exports.RCCallPlusMediaType.VIDEO),_=this._rtcModule.getRemoteTrack(t,exports.RCCallPlusMediaType.AUDIO)),{userId:t,state:i,cameraEnable:!!r&&!r.isOwnerMuted(),microphoneEnable:!!_&&!_.isOwnerMuted()}})}getCreatorUserId(){return this._session.getStartCallerId()}getInviterUserId(){return this._session.getCallerId()}getCreateTimestamp(){return i(this,void 0,void 0,function*(){const e=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_SESSION_GET_CREATE_TIME_T,"",e),this._startTime)return{code:r.SUCCESS,startTime:this._startTime};const{code:t,clientStartTime:i}=yield this._callEngine.getCallStaringTime({callId:this._callId},e);return t!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,`errCode: ${t}`,e),{code:t}):(this._logger.info(_.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,"success",e),this._startTime=i,{code:r.SUCCESS,startTime:this._startTime})})}getDuration(){return i(this,void 0,void 0,function*(){const e=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_SESSION_GET_DURATION_T,"",e),this._duration)return this._logger.info(_.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${r.SUCCESS}, duration: ${this._duration}`,e),{code:r.SUCCESS,duration:this._duration};const{code:t,data:i}=yield this._callEngine.getCallTimeInfo(this._callId,e);return t!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${t}`,e),{code:t}):(this._logger.info(_.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${r.SUCCESS}, duration: ${i.duration}`,e),this._duration=i.duration,{code:r.SUCCESS,duration:this._duration})})}}exports.RCCallPlusType=void 0,(s=exports.RCCallPlusType||(exports.RCCallPlusType={}))[s.SINGLE=0]="SINGLE",s[s.MULTI=1]="MULTI",exports.RCCallPlusSessionUserState=void 0,(l=exports.RCCallPlusSessionUserState||(exports.RCCallPlusSessionUserState={}))[l.IDLE=0]="IDLE",l[l.CALLING=100]="CALLING",l[l.INVITED=101]="INVITED",l[l.RINGING=102]="RINGING",l[l.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",l[l.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",l[l.CONNECTING=200]="CONNECTING",l[l.ONCALL=300]="ONCALL",l[l.ONPHONE=301]="ONPHONE",l[l.ENDED=1e3]="ENDED",l[l.NO_ANSWER=1001]="NO_ANSWER",l[l.MISSED=1002]="MISSED",l[l.CANCELLED=1003]="CANCELLED",l[l.DECLINED=1004]="DECLINED",l[l.ERROR=2e3]="ERROR",exports.RCCallPlusMediaType=void 0,(o=exports.RCCallPlusMediaType||(exports.RCCallPlusMediaType={}))[o.AUDIO=0]="AUDIO",o[o.AUDIO_VIDEO=1]="AUDIO_VIDEO",o[o.VIDEO=2]="VIDEO",exports.RCCallPlusCallState=void 0,(n=exports.RCCallPlusCallState||(exports.RCCallPlusCallState={}))[n.IDLE=0]="IDLE",n[n.CALLING=100]="CALLING",n[n.INVITED=101]="INVITED",n[n.RINGING=102]="RINGING",n[n.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",n[n.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",n[n.CONNECTING=200]="CONNECTING",n[n.ONCALL=300]="ONCALL",n[n.ENDED=1e3]="ENDED",n[n.NOANSWER=1001]="NOANSWER",n[n.MISSED=1002]="MISSED",n[n.CANCELED=1003]="CANCELED",n[n.DECLINED=1004]="DECLINED",n[n.ERROR=2e3]="ERROR",exports.RCCallPlusMediaTypeChangeResult=void 0,(a=exports.RCCallPlusMediaTypeChangeResult||(exports.RCCallPlusMediaTypeChangeResult={}))[a.CANCEL_CHANGE_MEDIA_TYPE=0]="CANCEL_CHANGE_MEDIA_TYPE",a[a.REFUSE_CHANGE_MEDIA_TYPE=1]="REFUSE_CHANGE_MEDIA_TYPE",a[a.SERVER_ALLOW_MEDIA_TYPE=2]="SERVER_ALLOW_MEDIA_TYPE",a[a.CHANGE_MEDIA_TYPE_TIMEOUT=3]="CHANGE_MEDIA_TYPE_TIMEOUT",exports.RCCallPlusReason=void 0,(C=exports.RCCallPlusReason||(exports.RCCallPlusReason={}))[C.IDLE=0]="IDLE",C[C.CALLING=100]="CALLING",C[C.INVITED=101]="INVITED",C[C.RINGING=102]="RINGING",C[C.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",C[C.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",C[C.CONNECTING=200]="CONNECTING",C[C.ONCALL=300]="ONCALL",C[C.ON_PHONE=301]="ON_PHONE",C[C.ON_PHONE_END=302]="ON_PHONE_END",C[C.ON_DEVICE_DISABLE=303]="ON_DEVICE_DISABLE",C[C.ON_DEVICE_ENABLE=304]="ON_DEVICE_ENABLE",C[C.ABNORMAL_END=999]="ABNORMAL_END",C[C.ENDED=1e3]="ENDED",C[C.NO_ANSWER=1001]="NO_ANSWER",C[C.MISSED=1002]="MISSED",C[C.CANCELLED=1003]="CANCELLED",C[C.DECLINED=1004]="DECLINED",C[C.OTHER_CLIENT_CALLING=1010]="OTHER_CLIENT_CALLING",C[C.OTHER_CLIENT_ACCEPT=1011]="OTHER_CLIENT_ACCEPT",C[C.JOIN_ROOM_ERR=1105]="JOIN_ROOM_ERR",C[C.PUBLISH_ERR=1106]="PUBLISH_ERR",C[C.SUBSCRIBE_ERR=1107]="SUBSCRIBE_ERR",C[C.ACCEPT_CARRIER=1108]="ACCEPT_CARRIER",C[C.KICKED_BY_SERVER=1109]="KICKED_BY_SERVER",C[C.CONNECTION_ERR=1110]="CONNECTION_ERR",C[C.LOGOUT=1111]="LOGOUT",C[C.OTHER_CLIENT_LOGIN=1112]="OTHER_CLIENT_LOGIN",C[C.OTHER_CLIENT_JOINED=1113]="OTHER_CLIENT_JOINED",C[C.OTHER_CLIENT_IN_ROOM=1114]="OTHER_CLIENT_IN_ROOM",C[C.OTHER_CLIENT_HANGUP=1151]="OTHER_CLIENT_HANGUP",C[C.REMOTE_JOIN_RTC_ERROR=1205]="REMOTE_JOIN_RTC_ERROR",C[C.REMOTE_PUBLISH_ERROR=1206]="REMOTE_PUBLISH_ERROR",C[C.REMOTE_SUBSCRIBE_ERROR=1207]="REMOTE_SUBSCRIBE_ERROR",C[C.REMOTE_KICKED_BY_SERVER=1209]="REMOTE_KICKED_BY_SERVER",C[C.REMOTE_CONNECTION_ERROR=1210]="REMOTE_CONNECTION_ERROR",C[C.REMOTE_LOGOUT=1211]="REMOTE_LOGOUT",C[C.REMOTE_OTHER_CLIENT_LOGIN=1212]="REMOTE_OTHER_CLIENT_LOGIN",C[C.REMOTE_OTHER_JOINED_RTC=1213]="REMOTE_OTHER_JOINED_RTC",C[C.REMOTE_OTHER_CLIENT_IN_RTC=1214]="REMOTE_OTHER_CLIENT_IN_RTC",exports.IGroupCallStatusMessageType=void 0,(c=exports.IGroupCallStatusMessageType||(exports.IGroupCallStatusMessageType={}))[c.START=1]="START",c[c.END=2]="END";class d{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.isNumber(t)||!e.isNumber(i)||i<=0||t<=0||i<t?(this._logger.error(_.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.isNumber(t)?(this._audioConfig.sampleRate=t,this):(this._logger.error(_.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O,`params error -> sampleRate: ${t}`),this)}build(){return this._audioConfig}}class E{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:t.RCResolution.W640_H480,frameRate:t.RCFrameRate.FPS_15}})}setFrameRate(e){return t.RCFrameRate[e]?(this._videoConfig.frameRate=e,this):(this._logger.error(_.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O,`params error -> fps: ${e}`),this)}setVideoResolution(e){return t.RCResolution[e]?(this._videoConfig.resolution=e,this):(this._logger.error(_.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.isNumber(t)||!e.isNumber(i)||i<=0||t<=0||i<t?(this._logger.error(_.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 u=e=>{const{callId:t,callType:i,callDir:r,mediaType:_,callingUserId:s,callUserIds:l,callStatus:o,sessionStatus:n,startTime:a,endTime:C,duration:c,syncTime:L,sysStatus:d,crtTime:E}=e;return{callId:t,callType:i,callDirection:r,mediaType:_,callerUserId:s,callUserIds:l,sessionState:o,userState:n,startTimestamp:a,endTimestamp:C,duration:c,syncTimestamp:L,systemState:d,createTimestamp:E}},T=e=>e&&e.nodeName&&"VIDEO"===e.nodeName.toUpperCase(),S=e=>{const{voipCallInfo:t}=e;if(!t)return!1;const{strategy:i}=JSON.parse(t);return 1===i},I=(t,i)=>!t&&0!==t||e.isNumber(t)&&!(t<=0)?!i&&0!==i||e.isNumber(i)&&!(i<=0)?t&&i&&i<t?{code:r.PARAM_ERROR,errorMsg:`params error -> maxBitrate: ${i}, minBitrate: ${t}, maxBitrate should > minBitrate`}:{code:r.SUCCESS}:{code:r.PARAM_ERROR,errorMsg:`params error -> maxBitrate: a number of > 0, value: ${i}`}:{code:r.PARAM_ERROR,errorMsg:`params error -> minBitrate: a number of > 0, value: ${t}`},R=e=>{const t=[];for(const i in e){const{videoView:r,isTiny:_}=e[i];t.push({userId:i,videoView:r.nodeName,isTiny:_})}return t},g=(e,t={},i={})=>{const{threadId:r,apnsCollapseId:_,richMediaUri:s}=t,{channelIdMi:l,templateIdMi:o,templateParamMi:n,channelIdHW:a,channelIdOPPO:C,typeVivo:c,fcmChannelId:L,fcmCollapseKey:d,fcmImageUrl:E,importanceHW:u,categoryHW:T,imageUrlHW:S,categoryVivo:I,importanceHonor:R,imageUrlHonor:g}=i,h={};r&&(h["thread-id"]=r),h["apns-collapse-id"]=_||e,s&&(h.richMediaUri=s);const A={};a&&(A.channelId=a),S&&(A.image=S),T&&(A.category=T),A.importance=u||"NORMAL";const N=[{HW:A},{APNS:h}];let O;(d||E||L)&&(O={},d&&(O.collapse_key=d),E&&(O.imageUrl=E),L&&(O.channelId=L),N[N.length]={FCM:O});const p=!!n&&Object.keys(n).length>0;if(l||o||p){const e={};l&&(e.channelId=l),o&&(e.templateId=o),p&&(e.templateParam=n),N[N.length]={MI:e}}let m,P,U;return C&&(m={},m.channelId=C,N[N.length]={OPPO:m}),(c||I)&&(P={},c&&(P.classification=c),I&&(P.category=I),N[N.length]={VIVO:P}),(R||g)&&(U={},R&&(U.importance=R),g&&(U.image=g),N[N.length]={HONOR:U}),JSON.stringify(N)},h=(t,i)=>{const{pushTitle:r="",iOSConfig:_,androidConfig:s,disablePushTitle:l,templateId:o}=t,n={pushConfigs:g(i,_,s)};return e.isBoolean(l)&&(n.disableTitle=l),r&&(n.title=r),o&&(n.templateId=o),JSON.stringify(n)},A=t=>{const i=["pushTitle","pushContent","iOSConfig","androidConfig","disablePushTitle","templateId"];if(!Object.keys(t).every(e=>i.includes(e)))return{code:r.PARAM_ERROR,errorMsg:`right key: ${i.join(",")}`};for(let _=0;_<i.length;_++){const s=i[_];if("disablePushTitle"===s){if(!e.isUndefined(t[s])&&!e.isBoolean(t[s]))return{code:r.PARAM_ERROR,errorMsg:`${s} type is boolean`}}else if(("pushTitle"===s||"templateId"===s||"pushContent"===s)&&t[s]&&!e.isString(t[s]))return{code:r.PARAM_ERROR,errorMsg:`${s} type is string`}}const{iOSConfig:_,androidConfig:s}=t,l=N(_||{});if(l.code!==r.SUCCESS)return l;const o=O(s||{});return o.code!==r.SUCCESS?o:{code:r.SUCCESS}},N=t=>{const{threadId:i,richMediaUri:_}=t||{};return i&&!e.isString(i)?{code:r.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:_&&!e.isString(_)?{code:r.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:r.SUCCESS}},O=t=>{const i=["channelIdMi","templateIdMi","templateParamMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"];if(!Object.keys(t).every(e=>i.includes(e)))return{code:r.PARAM_ERROR,errorMsg:`right key: ${i.join(",")}`};for(let _=0;_<i.length;_++){const s=i[_];if("importanceHW"===s||"importanceHonor"===s){if(t[s]&&"LOW"!==t[s]&&"NORMAL"!==t[s])return{code:r.PARAM_ERROR,errorMsg:`androidConfig.${s} value is NORMAL|LOW`}}else if("templateParamMi"===s){if(t[s]&&("object"!=typeof t[s]||Array.isArray(t[s])))return{code:r.PARAM_ERROR,errorMsg:`androidConfig.${s} type is object`};if(t[s]){const i=Object.keys(t[s]).find(i=>!e.isString(i)||!e.isString(t[s][i]));if(void 0!==i)return{code:r.PARAM_ERROR,errorMsg:`androidConfig.${s}.${i} key and value type is string`}}}else if(t[s]&&!e.isString(t[s]))return{code:r.PARAM_ERROR,errorMsg:`androidConfig.${s} type is string`}}return{code:r.SUCCESS}},p=(e,t="utf-8")=>{let i=0;return i="utf-16"===t?m(e):P(e),i},m=e=>{let t,i=0;for(let r=0,_=e.length;r<_;r++)t=e.charCodeAt(r),i+=t<=65535?2:4;return i},P=e=>{let t,i=0;for(let r=0,_=e.length;r<_;r++)t=e.charCodeAt(r),i+=t<127?1:t<=2047?2:t<=65535?3:4;return i},U=/Electron/.test(navigator.userAgent);var f,M,v,y,D,b;!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"}(f||(f={}));class G{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,l){const o=+new Date,{mediaType:n,callType:a,callId:C}=r?{mediaType:r.getMediaType(),callType:r.getCallType(),callId:r.getCallId()}:l,c={cr:"unknown",net:"unknown",cod:t,mtp:n,ctp:a,cid:C,time:o,uid:this._context.getCurrentId()};_&&Object.assign(c,{ccid:_});let L=null;switch(e){case f.L_QS_RECEIVE_CALL_S:L=Object.assign(Object.assign({},c),{rf:s});break;case f.L_QS_ABNORMAL_HANGUP_S:L=Object.assign({},c);break;default:L=Object.assign(Object.assign({},c),{dur:o-i})}this._logger.__statistics(e,JSON.stringify(L))}}!function(e){e.REQUEST="request",e.ACCEPT="accept",e.REFUSE="refuse",e.CANCEL="cancel",e.NOTICE="notice",e.TIMEOUT="timeout"}(M||(M={})),function(e){e[e.SWITCH_MEDIA_TYPE=1]="SWITCH_MEDIA_TYPE"}(v||(v={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.SECRET=1]="SECRET"}(y||(y={})),function(e){e.INVITER="inviter",e.INVITEE="invitee"}(D||(D={}));class V extends e.EventEmitter{constructor(e,t,i,r,_,s,l,o){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:r}),Object.defineProperty(this,"_startCallerId",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_callerId",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_callUsers",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:o}),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:r,systemState:_,userId:s}=e,l=this._callUsers.findIndex(e=>e.userId===s);if(l<0)return this._callUsers.push(e),void i.push(e);const{stateTime:o,systemState:n,userState:a}=this._callUsers[l],C=((e,t)=>{let i=!1;const r=[exports.RCCallPlusReason.INVITED,exports.RCCallPlusReason.RINGING,exports.RCCallPlusReason.BUSYLINE_RINGING,exports.RCCallPlusReason.BUSYLINE_WAIT,exports.RCCallPlusReason.CONNECTING,exports.RCCallPlusReason.ONCALL];return e===exports.RCCallPlusReason.ONCALL&&r.includes(t)&&(i=!0),i})(n,_),c=((e,t)=>{let i=!1;const r=[exports.RCCallPlusSessionUserState.INVITED,exports.RCCallPlusSessionUserState.RINGING,exports.RCCallPlusSessionUserState.BUSYLINE_RINGING,exports.RCCallPlusSessionUserState.BUSYLINE_WAIT,exports.RCCallPlusSessionUserState.CONNECTING,exports.RCCallPlusSessionUserState.ONCALL];return e===exports.RCCallPlusSessionUserState.ONCALL&&r.includes(t)&&(i=!0),i})(a,t),L=_===exports.RCCallPlusReason.ON_PHONE_END&&n!==exports.RCCallPlusReason.ON_PHONE&&t!==exports.RCCallPlusSessionUserState.IDLE;r&&o&&r<o||C&&c||(this._callUsers[l]=e,!L&&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===D.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"}(b||(b={}));const x=(e,t)=>setTimeout(e,t),H=[e.ErrorCode.RC_NET_CHANNEL_INVALID,e.ErrorCode.RC_NET_UNAVAILABLE,e.ErrorCode.RC_MSG_RESP_TIMEOUT,t.RCRTCCode.SIGNAL_DISCONNECTED,t.RCRTCCode.REQUEST_FAILED],w=({asyncFn:e,fnArgs:t,currentRetryTime:_=Date.now(),maxDuration:s=6e4,intervals:l=[2e3,4e3,8e3,16e3,32e3,64e3],index:o=0,onError:n})=>i(void 0,void 0,void 0,function*(){const i=yield e(...t);return i.code===r.SUCCESS||!H.includes(i.code)||Date.now()+2e3-_>s?i:(n&&n(i.code),yield(a=2e3,new Promise(e=>{setTimeout(e,a)})),w({asyncFn:e,fnArgs:t,currentRetryTime:_,maxDuration:s,intervals:l,index:o,onError:n}));var a});var k,$,B;!function(e){e.onBeforePublish="onBeforePublish",e.onPublishRes="onPublishRes",e.onPubInviteCall="onPubInviteCall",e.onPubInviteCallPullKv="onPubInviteCallPullKv",e.onPubInviteCallMiss="onPubInviteCallMiss"}(k||(k={})),function(e){e.NOT_CURRENT_DEVICEID="not current device id",e.SECRET_CALL="secret call",e.NOT_INVITEE="not an invitee"}($||($={})),function(e){e.PUB_INVITE="pubinvitecall",e.PULL_KV_INVITE="pullkv_invitecall",e.PUSH="system_pubsh"}(B||(B={}));const F=131072,j="RC:CallPlusMiss",Y="RC:CallGroupStatusMsg";class J extends e.EventEmitter{constructor(t,i,r,_,s,l){super(),Object.defineProperty(this,"_context",{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:r}),Object.defineProperty(this,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_needRetryActions",{enumerable:!0,configurable:!0,writable:!0,value:[b.START_SINGLE_CALL,b.START_GROUP_CALL,b.ACCEPT_CALL,b.JOIN_CALL,b.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=e.getUUID22()}_onMessage(e){return!![j,Y].includes(e.messageType)&&(e.messageType===j?this._dealMissMessage(e):this._dealGroupCallMessage(e),!0)}_dealMissMessage(t){const{content:{callId:i,mediaType:r,startTime:s,callSessionUsers:l},targetId:o,senderUserId:n}=t,a=this._context.getCurrentId();if(!localStorage.getItem(`missMessageMap-${a}-${i}`)){const C={callId:i,callerUserId:n,targetId:o,mediaType:r,firstFrameTime:0,callStartTime:s-this._timeCorrectioner.getLocalDelayTime(),callEndTime:0,hangupReason:l.filter(({userId:e})=>e===a)[0].sessionStatus};this._logger.info(_.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O,`receive miss message: ${JSON.stringify(t)}`);const c=Object.assign(t,{content:C,sentStatus:e.SentStatus.SENT});this._reportAppEventModule.onReceivedCallPlusSummaryMessage(c),localStorage.setItem(`missMessageMap-${a}-${i}`,i)}}_dealGroupCallMessage(e){this._reportAppEventModule.onReceivedGroupCallStatusMessage(e)}getSessionId(){return this._sessionId}getDeviceId(){return U?this._context.getDeviceId():this._sessionId}registerListener(e){this._listener=e}startCall(e,t){return i(this,void 0,void 0,function*(){const{clientCallId:i,callType:r,toUsers:_,mediaType:s,secretChat:l,targetType:o,targetId:n,nickName:a,oldRoomId:C,pushExt:c,pushContent:L,extra:d}=e;return r===exports.RCCallPlusType.SINGLE?this.startSingleCall({clientCallId:i,toUserId:_[0].userId,mediaType:s,secretChat:l,targetType:o,targetId:n,oldRoomId:C,toOrgId:_[0].orgId||"",pushExt:c,pushContent:L,extra:d},t):this.startGroupCall({clientCallId:i,toUsers:_,mediaType:s,targetType:o,targetId:n,nickName:a,oldRoomId:C,pushExt:c,pushContent:L,extra:d},t)})}startSingleCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(this._context.getCurrentId(),b.START_SINGLE_CALL,e)})}startGroupCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_GROUP_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(this._context.getCurrentId(),b.START_GROUP_CALL,e)})}inviteCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_INVITE_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.INVITE_CALL,e)})}ringingCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_RING_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.RINGING_CALL,e)})}acceptCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_ACCEPT_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.ACCEPT_CALL,e)})}joinCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_JOIN_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.JOIN_CALL,e)})}hangupCall(e,t){return i(this,void 0,void 0,function*(){this._logger.info(_.L_SIGNAL_TRANSPORTER_HANGUP_T,`params: ${JSON.stringify(e)}`,t);const{code:i}=yield this._sendCallSignal(e.callId,b.HANGUP_CALL,e);return i===r.NOT_IN_CALL?{code:r.SUCCESS}:{code:i}})}statusUpCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T,`call status up params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.STATUS_UP_CALL,e)})}eventUpCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.EVENT_UP_CALL,e)})}dialogUpCall(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.DIALOG_UP_CALL,e)})}deleteCallRecord(e,t,r){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T,`callIds: ${JSON.stringify(t)}`,r),this._sendCallSignal(e,b.DEL_CALL_LOG,{callIds:t})})}syncCallLog(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.userId,b.SYNC_CALL_LOG,e)})}queryUserHasCall(){return i(this,void 0,void 0,function*(){const e=this._context.getCurrentId();return this._sendCallSignal(e,b.QRY_CALL_STATE,null)})}getCallServerTimestamp(e){return i(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(_.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T,`userId: ${t}`,e),this._sendCallSignal(t,b.QRY_SRV_TIMESTAMP,null)})}getCallTimeInfo(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T,`callId: ${e}`,t),this._sendCallSignal(e,b.GET_CALL_TIME_INFO,{callId:e})})}getUserCallStateList(e){return i(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(_.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T,`userId: ${t}`,e),this._sendCallSignal(t,b.GET_CALL_STATE_LIST,null)})}clearCallRecord(e){return i(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(_.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T,`userId: ${t}`,e),this._sendCallSignal(t,b.CLEAR_CALL_LOG,null)})}getCallSession(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T,`callId: ${e.callId}`,t),this._sendCallSignal(e.callId,b.GET_CALL_SESSION,e)})}sysStatusUp(e,t){return i(this,void 0,void 0,function*(){return this._logger.info(_.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T,`opts: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,b.SYS_STATUS_UP,e)})}upCallLogReaded(e){return i(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._sendCallSignal(t,b.UP_CALL_LOG_READED,e)})}endUserAbnormalCalls(e){return i(this,void 0,void 0,function*(){return this._sendCallSignal(this._context.getCurrentId(),b.END_ABNORMAL_CALL,e)})}_onIMConnectionStateChange(t){const i=this._logger.createTraceId();this._logger.info(_.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O,`state: ${t}`,i),this._listener.onIMStateChange(t),t===e.RCConnectionStatus.CONNECTED?this._timeCorrectioner.start(i):this._timeCorrectioner.stop(i)}_sendCallSignal(t,_,s){return i(this,void 0,void 0,function*(){let i,l="";s&&(l=U?JSON.stringify(s):JSON.stringify(Object.assign(Object.assign({},s),{sessionId:this._sessionId}))),i=this._needRetryActions.includes(_)?yield w({asyncFn:this._context.setCallInfo.bind(this._context),fnArgs:[t,_,l]}):yield this._context.setCallInfo(t,_,l);const{code:o,data:n}=i;if(o!==e.ErrorCode.SUCCESS)return{code:o};const{value:a}=n,C=JSON.parse(a).data;return{code:r.SUCCESS,data:C}})}_onRecvCallSignal(e){const t=this._logger.createTraceId();this._logger.info(_.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O,`data: ${e}`,t);JSON.parse(e).list.forEach(e=>{const{key:i}=e,r=JSON.parse(e.value);switch(i){case b.PUB_INVITE_CALL:this._onPubInviteCall(r,t,!0);break;case b.STATUS_DOWN_CALL:this._onStatusDownCall(r,t);break;case b.EVENT_DOWN_CALL:this._onEventDownCall(r,t);break;case b.DIALOG_DOWN_CALL:this._onDialogDownCall(r,t);break;case b.PUB_CALL_LOG:this._onPubCallLog(r,t);break;case b.PUB_CALL_LOG_READED:case b.PUB_NACK_SEQ_ID:break;default:this._onConpensationData(r,t)}})}isValidData(t){if(e.isNull(t))return!0;const i=t===this.getDeviceId();return!(!e.isString(t)||0!==(null==t?void 0:t.length)&&!i)}_onPubInviteCall(e,t,i=!0){try{const i=this._context.getCurrentId(),r=e.callSessionUsers.find(e=>e.userId===i),s=this._context.getConnectionStatus();this._logger.info(_.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`currentUser: ${JSON.stringify(r)}, currentUserId: ${i}, state: ${s}`,t)}catch(e){this._logger.error(_.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`error: ${e.message}`,t)}if(!this.isValidData(e.toDeviceId||"")){this._logger.warn(_.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`not current deviceId -> deviceInfo: ${JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this.getDeviceId()})}`,t);const r={extra:JSON.stringify(e),reason:$.NOT_CURRENT_DEVICEID,refer:i?B.PUB_INVITE:B.PULL_KV_INVITE};return void this.emit(k.onPubInviteCallMiss,Object.assign(e,r))}this._listener.onInvite(e,i,t),i?this.emit(k.onPubInviteCall,Object.assign(e,{extra:JSON.stringify(e)})):this.emit(k.onPubInviteCallPullKv,Object.assign(e,{extra:JSON.stringify(e)}))}_onStatusDownCall(e,t){if(e.callSessionUsers=e.callSessionUsers.filter(e=>Boolean(e.changed)),this._logger.info(_.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,"",t),!this.isValidData(e.toDeviceId||""))return this._logger.warn(_.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===v.SWITCH_MEDIA_TYPE&&this._listener.onSwitchMediaType(e,t)}_onPubCallLog(e,t){this._logger.info(_.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O,`call record: ${JSON.stringify(e)}`,t),this._listener.onRecvCallEndLog(e,t)}_onConpensationData(e,t){this._logger.info(_.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O,"",t);const{callId:i,callType:r,mediaType:s,secretChat:l,duration:o,callStatus:n,callingUserId:a,callSessionUsers:C,toDeviceId:c,callDialogEntitys:L,extra:d}=e;C.some(e=>e.sessionStatus===exports.RCCallPlusSessionUserState.INVITED&&e.userId===this._context.getCurrentId())?this._onPubInviteCall({callId:i,toDeviceId:c,callType:r,mediaType:s,inviteUserId:a,callingUserId:a,callSessionUsers:C,secretChat:l,extra:d},t,!0):this._onStatusDownCall({callId:i,toDeviceId:c,callStatus:n,duration:o,callSessionUsers:C},t),L.length>0&&L.forEach(e=>this._onDialogDownCall(e,t),this)}}const W=()=>{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 r=+e;const _=[];do{const e=r%i;r=(r-e)/i,_.unshift(t[e])}while(r);return _.join("")})(e),e.length>22&&(e=e.slice(0,22)),e};class K{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(K._STORAGE_KEY)||"{}");let r=i[e];r?r.push(t):r=[t],i[e]=r,this._localStore.setItem(K._STORAGE_KEY,JSON.stringify(i))}catch(e){this._logger.error(_.L_ABNORMAL_ADD_CALL_ID_E,e.message),console.error(e)}}removeAbnormalCallIds(e,t){try{const i=JSON.parse(this._localStore.getItem(K._STORAGE_KEY)||"{}");let r=i[e];r&&(r=r.filter(e=>!t.includes(e)),r.length>0?i[e]=r:delete i[e],this._localStore.setItem(K._STORAGE_KEY,JSON.stringify(i)))}catch(e){this._logger.error(_.L_ABNORMAL_REMOVE_CALL_IDS_E,e.message),console.error(e)}}getAbnormalCallIds(e){let t=null;try{const i=JSON.parse(this._localStore.getItem(K._STORAGE_KEY)||"{}")[e];i&&(t=i)}catch(e){this._logger.error(_.L_ABNORMAL_GET_CALL_IDS_E,e.message),console.error(e)}return Promise.resolve(t)}}var Q,q,X,z,Z;Object.defineProperty(K,"_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"}(Q||(Q={})),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"}(q||(q={}));class ee{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 i(this,void 0,void 0,function*(){this._logger.info(_.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(_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${q.INVALID_RESPONSE_TIME}`,t);const{code:i,data:s}=yield this._callEngine.getCallTimeInfo(e,t);if(i!==r.SUCCESS)return this._logger.error(_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${i}`,t),{code:i};const{startTime:l}=s,o=Math.floor(l-this._deltaTime);let n=(Date.now()+this._deltaTime-l)/1e3;return n<0&&(this._logger.warn(_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P,`invalid duration: ${n}`,t),n=0),n=Math.floor(n),this._RTT>this._validMinRTT&&this._RTT<=this._validMaxRTT&&this._logger.error(_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${q.NONOPTIMAL_RES_TIME}`,t),this._logger.info(_.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,serverStartTime:l,clientStartTime:o,duration:n}),t),{code:i,duration:n,clientStartTime:l?o:l}})}calcClientStartTime(e,t,i){if(this._logger.info(_.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T,`callId: ${e}, startTime: ${t}`,i),this._RTT>this._validMaxRTT)return this._logger.error(_.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,`code: ${q.INVALID_RESPONSE_TIME}`,i),this._loopCorrectClientTime(e,i),{code:q.INVALID_RESPONSE_TIME};const r=Math.floor(t-this._deltaTime);return this._logger.info(_.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,startT:t,clientStartTime:r}),i),this._RTT>this._validMinRTT&&(this._retryTimesInCall=0,this._loopCorrectClientTime(e,i)),{code:q.SUCCESS,clientStartTime:r}}start(e){this._timerId||this._startTimes>=this._maxRetryTimes||(this._logger.info(_.L_TIME_CORRECT_START_O,`timerId: ${this._timerId}`),this._startTimes++,this._getDeltaTime(e),this._timerId=x(()=>{this._timerId=null,this.start(e)},this._interval))}stop(e){this._logger.info(_.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(_.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 i(this,void 0,void 0,function*(){const t=Date.now(),{code:i,data:s}=yield this._callEngine.getCallServerTimestamp(e),l=Date.now();if(i!==r.SUCCESS)return{code:i};const o=l-t;return(o<this._RTT||0===this._RTT)&&o<=this._validMaxRTT&&(this._RTT=o),o<this._validMinRTT&&this.stop(e),this._deltaTime=s-t-this._RTT/2,this._logger.info(_.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 i(this,void 0,void 0,function*(){const i=Date.now(),{code:s,data:l}=yield this._callEngine.getCallTimeInfo(e,t),o=Date.now();if(s!==r.SUCCESS)return{code:s};const n=o-i;n<this._RTT&&(this._RTT=n),this._deltaTime=l.syncTime-i-this._RTT/2,this._logger.info(_.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({callId:e,rtt:this._RTT,deltaT:this._deltaTime}),t);const a=Math.floor(l.startTime-this._deltaTime),C=Math.floor(l.firstFrametime-this._deltaTime);return n<this._validMinRTT?{code:q.SUCCESS,clientStartTime:a,clientFirstFrameTime:C}:{code:q.INVALID_RESPONSE_TIME,clientStartTime:a,clientFirstFrameTime:C}})}_loopCorrectClientTime(e,t){return i(this,void 0,void 0,function*(){this.stop(t),this._logger.info(_.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T,`callId: ${e}`,t);const{code:i,clientStartTime:s,clientFirstFrameTime:l}=yield this._getDeltaTimeInCall(e,t);return i===q.SUCCESS?(this._logger.info(_.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,`code: ${r.SUCCESS}`,t),void this._singleCallDurationEv(e,s,l,t)):this._retryTimesInCall>this._maxRetryTimesInCall&&i===q.INVALID_RESPONSE_TIME?(this._logger.info(_.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,`code: ${q.INVALID_RESPONSE_TIME}`,t),void this._singleCallDurationEv(e,s,l,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"}(X||(X={})),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"}(z||(z={})),function(e){e[e.OUT=-1]="OUT",e[e.GROUP=0]="GROUP",e[e.IN=1]="IN"}(Z||(Z={}));class te extends e.EventEmitter{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:r}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:_}),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 ee(this,r,this._onRecvSinCallDuration.bind(this)),this._signalModule=new J(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 K(t,r)}startCall(e,t){return i(this,void 0,void 0,function*(){const i=this._context.getCurrentId(),{callType:_,mediaType:s,toUsers:l,targetId:o,targetType:n,oldRoomId:a,pushConfig:C,extra:c}=e;this._clientCallId=e.callId;const L=C?h(C,this._clientCallId):"",{code:d,data:E}=yield this._signalModule.startCall({clientCallId:this._clientCallId,callType:_,mediaType:s,toUsers:l,secretChat:y.NORMAL,targetType:n,targetId:o,oldRoomId:a,pushExt:L,pushContent:(null==C?void 0:C.pushContent)||"",extra:c},t);if(d!==r.SUCCESS)return{code:d};const{callId:u,busylineUsers:T}=E;if(this._abnormalModule.addAbnormallCallId(i,u),this._mainSession=new V(u,exports.RCCallPlusCallState.INVITED,_,s,i,i,[],this._logger),_===exports.RCCallPlusType.SINGLE){const e=this._startTimer(E.callId,exports.RCCallPlusSessionUserState.NO_ANSWER,t);this._mainSession.updateTimerId(D.INVITER,e)}const S={userId:i,userState:exports.RCCallPlusSessionUserState.CALLING,systemState:exports.RCCallPlusReason.CALLING,targetType:n,targetId:o};let I=l.map(({userId:e,targetType:t,targetId:i})=>({userId:e,userState:exports.RCCallPlusSessionUserState.INVITED,systemState:exports.RCCallPlusReason.INVITED,targetType:t,targetId:i})),R=[];T&&(R=T.map(e=>{const{targetType:t,targetId:i}=I.find(t=>t.userId===e.userId);return{userId:e.userId,userState:e.sessionStatus,systemState:exports.RCCallPlusReason.BUSYLINE_RINGING,targetType:t,targetId:i}}),I=I.filter(({userId:e})=>R.every(({userId:t})=>t!==e)));const g=this.updateUsersState(u,[S,...I,...R],t);return setTimeout(()=>{g.length>0&&this.reportRemoteUserStateChange(u,g,t)}),{code:d,data:E}})}invite(e,t){var _;return i(this,void 0,void 0,function*(){if(!this._mainSession)return{code:r.NOT_IN_CALL};const{toUsers:i,pushConfig:s,extra:l}=e,o=s?h(s,this._clientCallId):"",n=this._mainSession.getCallId(),{code:a,data:C}=yield this._signalModule.inviteCall({callId:n,toUsers:i,pushExt:o,pushContent:(null==s?void 0:s.pushContent)||"",extra:l},t);if(a===r.SUCCESS){this._mainSession.getCallType()===exports.RCCallPlusType.SINGLE&&(this._mainSession.updateCallType(exports.RCCallPlusType.MULTI),this._onCallTypeChange(this._mainSession.getCallId(),exports.RCCallPlusType.MULTI,t));let e=i.map(({userId:e,targetType:t,targetId:i})=>({userId:e,userState:exports.RCCallPlusSessionUserState.INVITED,systemState:exports.RCCallPlusReason.INVITED,targetType:t,targetId:i})),r=[];C.busylineUsers&&(r=null===(_=C.busylineUsers)||void 0===_?void 0:_.map(t=>{const{targetType:i,targetId:r}=e.find(e=>e.userId===t.userId);return{userId:t.userId,userState:t.sessionStatus,systemState:exports.RCCallPlusReason.BUSYLINE_RINGING,targetType:i,targetId:r}}),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:a,data:C}})}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 i(this,void 0,void 0,function*(){const{callId:i,systemState:r,pushConfig:_}=e,s=_?h(_,this._clientCallId):"",{code:l}=yield this._signalModule.hangupCall({callId:i,sysStatus:r,pushExt:s,pushContent:(null==_?void 0:_.pushContent)||""},t);return this.endCurrentSession(e.systemState,i,t),{code:l}})}accept(e,t){return i(this,void 0,void 0,function*(){if(!this._mainSession)return{code:r.NOT_IN_CALL};const{callId:i}=e,{code:_}=yield this._signalModule.acceptCall({callId:i},t);return this._stopTimer(this._mainSession.getInviteeTimerId(),t),_!==r.SUCCESS||(this._clearMobileOnPhone(e.callId,t),this._mainSession.updateSessionState(exports.RCCallPlusCallState.CONNECTING)),{code:_}})}joinCall(e,t){return i(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 _!==r.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 i(this,void 0,void 0,function*(){if(!this._mainSession)return{code:r.NOT_IN_CALL};const i={mediaType:e.mediaType};this._mainSession.updateReqMediaType(e.mediaType);const _=W(),{code:s}=yield this._signalModule.dialogUpCall({transactionId:_,callId:this._mainSession.getCallId(),toUserIds:e.toUserIds,dialogType:v.SWITCH_MEDIA_TYPE,action:M.REQUEST,extraKeyVal:i},t);return s!==r.SUCCESS?{code:s}:{code:r.SUCCESS,data:{transactionId:_}}})}responseChangeMediaType(e,t){return i(this,void 0,void 0,function*(){return this._mainSession?this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:v.SWITCH_MEDIA_TYPE,action:e.agree?M.ACCEPT:M.REFUSE},t):{code:r.NOT_IN_CALL}})}cancelChangeMediaType(e,t){return i(this,void 0,void 0,function*(){return this._mainSession?this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:v.SWITCH_MEDIA_TYPE,action:M.CANCEL},t):{code:r.NOT_IN_CALL}})}getCallLogList(e,t){return i(this,void 0,void 0,function*(){const i=this._context.getCurrentId(),{timestamp:_,count:s,order:l}=e,{code:o,data:n}=yield this._signalModule.syncCallLog({userId:i,syncTime:_,count:s,order:l},t);if(o!==r.SUCCESS)return{code:o};const a=n.callLogList.map(e=>u(e));return{code:r.SUCCESS,data:{hasMore:Boolean(null==n?void 0:n.hasMore),syncTime:0===l?n.maxTime:n.minTime,list:a}}})}deleteCallLog(e,t){return i(this,void 0,void 0,function*(){const i=this._context.getCurrentId();return this._signalModule.deleteCallRecord(i,e,t)})}getCallServerTimestamp(e){return i(this,void 0,void 0,function*(){const{code:t,data:i}=yield this._signalModule.getCallServerTimestamp(e);return t!==r.SUCCESS?{code:t}:{code:t,data:i.syncTime}})}getCallTimeInfo(e,t){return i(this,void 0,void 0,function*(){return this._signalModule.getCallTimeInfo(e,t)})}getOpenCallList(e){return i(this,void 0,void 0,function*(){const t=this._context.getCurrentId(),{code:i,data:_}=yield this._signalModule.getUserCallStateList(e);if(i!==r.SUCCESS)return{code:i};return{code:i,data:_.callStateList.map(i=>{const{callId:r,callType:_,mediaType:s,callingUserId:l,callUserIds:o,callStatus:n,crtTime:a,userSessionStatus:C,startTime:c,syncTime:L}=i,d=l===t?Z.OUT:Z.IN,{clientStartTime:E=c}=this._timeCorrectioner.calcClientStartTime(r,c,e);return{callId:r,callType:_,callDirection:d,mediaType:s,callerUserId:l,callUserIds:o,sessionState:n,userState:C,startTimestamp:c,endTimestamp:0,duration:Math.floor((+new Date-E)/1e3),syncTimestamp:L,systemState:0,createTimestamp:a}})}})}removeAllCallLog(e){return i(this,void 0,void 0,function*(){const{code:t}=yield this._signalModule.clearCallRecord(e);return{code:t}})}getCallSession(e,t){return i(this,void 0,void 0,function*(){const{code:i,data:_}=yield this._signalModule.getCallSession(e,t);if(i!==r.SUCCESS)return{code:i};const{callId:s,callingUserId:l,callType:o,mediaType:n,callStatus:a,callSessionUsers:C,startTime:c,duration:L,syncTime:d}=_;return{code:i,data:{callId:s,startCallerId:l,callType:o,mediaType:n,sessionState:a,callSessionUsers:C.map(e=>{const{userId:t,sessionStatus:i,sysStatus:r,targetType:_,targetId:s}=e;return{userId:t,userState:i,systemState:r,targetType:_,targetId:s,cameraEnable:!1,microphoneEnable:!1}}),startTime:c,duration:L,syncTime:d}}})}getHoldSession(e){const t=this._holdSessions.find(t=>t&&t.getCallId()===e);return t?new L(t,this,this._logger,this._rtcModule,this._context):null}getLocalMainSession(){return this._mainSession?new L(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(_.L_CALL_ENGINE_UPDATE_USERS_STATE_O,`updateUsersState -> users: ${JSON.stringify(t)}`,i);const r=[this._mainSession,...this._holdSessions].find(t=>(null==t?void 0:t.getCallId())===e),s=[];return r?s.push(...r.updateUserList(t,i)):s.push(...t),s}getCallStaringTime(e,t){return i(this,void 0,void 0,function*(){return this._timeCorrectioner.getCallClientTimeByServer(e.callId,t)})}systemStatusUp(e,t){return i(this,void 0,void 0,function*(){return this._signalModule.sysStatusUp(e,t)})}upFirstFrameTime(e){return i(this,void 0,void 0,function*(){if(!this._mainSession||this._mainSession&&this._mainSession.getCallType()!==exports.RCCallPlusType.SINGLE||this._isUpFirstFrameTime)return{code:r.SUCCESS};const t=Date.now(),i=this._timeCorrectioner.getLocalDelayTime(),s=Math.floor(t+i);this._logger.info(_.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T,`now: ${t}; delay: ${i}; streamReadyTime: ${s}`,e),this._isUpFirstFrameTime=!0;const l=this._mainSession.getCallId(),{code:o}=yield this._signalModule.eventUpCall({callId:l,eventType:Q.FIRST_FRAME,eventArgs:{streamReadyTime:s},eventTime:Date.now()},e);return this._logger.info(_.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R,`code: ${o}`,e),{code:o}})}endCurrentSession(e,t,i){const r=this._context.getCurrentId();if(this._mainSession&&this._mainSession.getCallId()===t){const t=this._mainSession.getUserList().map(t=>{let{userId:i,systemState:_,targetType:s,targetId:l}=t;return i===r&&(_=e),{userId:i,sessionStatus:exports.RCCallPlusSessionUserState.ENDED,statusTime:Date.now(),duration:0,changed:1,inviteUserId:this._mainSession.getStartCallerId(),sysStatus:_,targetType:s,targetId:l}}),_={callId:this._mainSession.getCallId(),toDeviceId:this._signalModule.getDeviceId(),callStatus:exports.RCCallPlusCallState.ENDED,duration:0,callSessionUsers:t};this._onStatusDown(_,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 i(this,void 0,void 0,function*(){const t=this._context.getCurrentId(),i=yield this._abnormalModule.getAbnormalCallIds(t);if(!i)return{code:r.SUCCESS};const _=i.filter(e=>{var t;return e!==(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId())}),{code:s}=yield this._signalModule.endUserAbnormalCalls({callIds:_,allDevice:e?1:0});return s===r.SUCCESS&&this._abnormalModule.removeAbnormalCallIds(t,_),{code:s}})}setRTCModule(e){this._rtcModule=e}_onIMStateChange(t){const i=this._logger.createTraceId();let r=0;t===e.RCConnectionStatus.DISCONNECTED&&this._mainSession&&this._mainSession.getSessionState()!==exports.RCCallPlusCallState.ONCALL&&(r=x(()=>{var e;this._logger.info(_.L_CALL_ENGINE_IM_STATE_CHANGE_O,"endCurrentSession, IM disconnected for more than 60s",i),this.endCurrentSession(exports.RCCallPlusReason.CONNECTION_ERR,null===(e=this._mainSession)||void 0===e?void 0:e.getCallId(),i)},6e4)),t===e.RCConnectionStatus.CONNECTED&&(r&&clearTimeout(r),this._initOpts.isAllowNewCallWhenRinging&&this.endCurrentUserAbnormalCalls(!0))}_handleCallTimeout(e,t,i){this._logger.warn(_.L_CALL_ENGINE_CALL_TIMEOUT_O,`call timeout callId: ${e}, userState: ${t}`,i);const r=[this._mainSession,...this._holdSessions].find(t=>t&&t.getCallId()===e);if(!r)return void this._logger.warn(_.L_CALL_ENGINE_CALL_TIMEOUT_O,`handleCallTimeout without session, callId: ${e}`,i);const s=this._context.getCurrentId();this._onStatusDown({callId:e,toDeviceId:this._signalModule.getDeviceId(),callStatus:exports.RCCallPlusCallState.ENDED,duration:0,callSessionUsers:r.getUserList().map(e=>{const{userId:i,targetType:_,targetId:l,stateTime:o}=e;let n,a;return i===s?(n=t===exports.RCCallPlusSessionUserState.MISSED?exports.RCCallPlusReason.MISSED:exports.RCCallPlusReason.NO_ANSWER,a=t===exports.RCCallPlusSessionUserState.MISSED?exports.RCCallPlusSessionUserState.MISSED:exports.RCCallPlusSessionUserState.NO_ANSWER):(n=t===exports.RCCallPlusSessionUserState.MISSED?exports.RCCallPlusReason.NO_ANSWER:exports.RCCallPlusReason.MISSED,a=t===exports.RCCallPlusSessionUserState.MISSED?exports.RCCallPlusSessionUserState.NO_ANSWER:exports.RCCallPlusSessionUserState.MISSED),{userId:i,sessionStatus:a,statusTime:o?o+1:Date.now(),duration:0,changed:1,inviteUserId:r.getCallerId(),sysStatus:n,targetType:_,targetId:l}})},i)}_startTimer(e,t,i){const r=x(()=>{this._handleCallTimeout(e,t,i),this._signalModule.statusUpCall({callId:e,sessionStatus:t},i)},6e4);return this._logger.info(_.L_CALL_ENGINE_START_CALL_TIMER_O,`callId: ${e}, timerId: ${r}`,i),r}_stopTimer(e,t){clearTimeout(e),this._logger.info(_.L_CALL_ENGINE_STOP_CALL_TIMER_O,`timerId: ${e}`,t)}_onInvite(t,i,r){this._clientCallId=e.getUUID();const _=this._context.getCurrentId(),{callSessionUsers:s,secretChat:l,extra:o="{}"}=t;if(l===y.SECRET)return void this.emit(k.onPubInviteCallMiss,Object.assign(t,{extra:JSON.stringify(t),reason:$.SECRET_CALL,refer:i?B.PUB_INVITE:B.PULL_KV_INVITE}));s.some(e=>e.userId===_)&&this._selfIsInviteeHandle(t,i,r,o),this._othersIsInviteeHandle(t,r)}_selfIsInviteeHandle(e,t,i,r){const{callId:_,inviteUserId:s,callType:l,mediaType:o,callSessionUsers:n}=e,a=this._context.getCurrentId();this._abnormalModule.addAbnormallCallId(a,_);const C=new V(_,exports.RCCallPlusCallState.RINGING,l,o,s,s,[],this._logger);this._signalModule.ringingCall({callId:_},i);const c=this._startTimer(_,exports.RCCallPlusSessionUserState.MISSED,i);C.updateTimerId(D.INVITEE,c),this._mainSession?(this._holdSessions.push(C),this._mainSession.updateSessionState(exports.RCCallPlusCallState.BUSYLINE_WAIT)):this._mainSession=C;const d=new L(C,this,this._logger,this._rtcModule,this._context),E=t?z.PUB_INVITE_CALL:z.PULL_KV_INVITE_CALL;this.emit(te.__INNER_INVITE__,d,E);const u=n.map(({userId:e,sessionStatus:t,sysStatus:i,targetType:r,targetId:_,statusTime:s})=>({userId:e,userState:t,systemState:i,targetType:r,targetId:_,stateTime:s})),T=this.updateUsersState(_,u,i);this._reportAppEventModule.onReceivedCall(d,i,JSON.parse(r||"{}").extra),T.length>0&&this.reportRemoteUserStateChange(_,T,i)}_othersIsInviteeHandle(e,t){var i,r,_;const{callId:s,inviteUserId:l,callSessionUsers:o}=e,n=this._context.getCurrentId(),a=o.filter(e=>e.userId!==n&&e.userId!==l&&e.sessionStatus===exports.RCCallPlusSessionUserState.INVITED);if(!a.length)return;(null===(i=this._mainSession)||void 0===i?void 0:i.getCallType())===exports.RCCallPlusType.SINGLE&&(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())===s&&(this._onCallTypeChange(this._mainSession.getCallId(),exports.RCCallPlusType.MULTI,t),null===(_=this._mainSession)||void 0===_||_.updateCallType(exports.RCCallPlusType.MULTI));const C=[],c=[];a.forEach(e=>{const{userId:t,sessionStatus:i,sysStatus:r}=e;C.push({callId:s,userId:t,userState:i}),c.push({userId:t,userState:i,systemState:r})}),this._onOtherMemberInvite(C);const L=this.updateUsersState(s,c,t);L.length>0&&this.reportRemoteUserStateChange(s,L,t)}_onHangup(e,t,i){this._mainSession&&e.forEach(e=>{e.callId===this._mainSession.getCallId()&&(e.userState===exports.RCCallPlusSessionUserState.CANCELLED?this._stopTimer(this._mainSession.getInviteeTimerId(),i):this._stopTimer(this._mainSession.getInviterTimerId(),i))})}_onAccept(e,t){var i,r,_,s;const l=null===(i=this._mainSession)||void 0===i?void 0:i.getSessionState(),o=[exports.RCCallPlusCallState.CONNECTING,exports.RCCallPlusCallState.ONCALL,exports.RCCallPlusCallState.BUSYLINE_WAIT];if((null===(r=this._mainSession)||void 0===r?void 0:r.getCallType())===exports.RCCallPlusType.SINGLE&&l&&o.includes(l))return;const n=this._mainSession.getStartCallerId(),a=this._context.getCurrentId();if((null===(_=this._mainSession)||void 0===_?void 0:_.getCallType())===exports.RCCallPlusType.SINGLE&&n===a){e.filter(e=>e.fromUserId!==a)&&this.emit(te.__INNER_SESSION_CONNECT__,this.getLocalMainSession().getCallId(),t)}null===(s=this._mainSession)||void 0===s||s.updateSessionState(exports.RCCallPlusCallState.CONNECTING),this._stopTimer(this._mainSession.getInviterTimerId(),t)}_onStatusDown(e,t){var r,_;return i(this,void 0,void 0,function*(){const{callStatus:i,startTime:s,callId:l}=e;if(l!==(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId()))return;if(this._callStartMap[l]=this._callStartMap[l]||{},!this._callStartMap[l].isReceiveCallStartTime&&i===exports.RCCallPlusCallState.ONCALL){this._callStartMap[l].isReceiveCallStartTime=!0;const{code:e,clientStartTime:i}=this._timeCorrectioner.calcClientStartTime(l,s,t);e===q.SUCCESS&&(this._callStartMap[l].callStartTime=i,this._reportAppEventModule.onReceivedCallStartTime({callId:l,callStartTime:i},t))}let o=!1;const n=this._context.getCurrentId(),a=e.callSessionUsers.map(e=>([exports.RCCallPlusSessionUserState.IDLE,exports.RCCallPlusSessionUserState.DECLINED,exports.RCCallPlusSessionUserState.MISSED,exports.RCCallPlusSessionUserState.NO_ANSWER,exports.RCCallPlusSessionUserState.CANCELLED].includes(e.sessionStatus)&&e.sysStatus!==exports.RCCallPlusReason.CANCELLED&&e.userId===n&&(o=!0),{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,stateTime:e.statusTime}));if(a.length){const e=this.updateUsersState(l,a,t);e.length>0&&this.reportRemoteUserStateChange(l,e,t)}if(!this._mainSession&&!this._holdSessions.length)return;const{hangupData:C,acceptData:c,otherInvitedData:L}=(e=>{const{callId:t}=e,i=[],r=[],_=[],s=[];return e.callSessionUsers.forEach(e=>{const{userId:l,sessionStatus:o,sysStatus:n}=e;switch(o){case exports.RCCallPlusSessionUserState.INVITED:s.push({callId:t,userId:l,userState:o});break;case exports.RCCallPlusSessionUserState.RINGING:i.push({callId:t,fromUserId:l});break;case exports.RCCallPlusSessionUserState.CONNECTING:_.push({fromUserId:l});break;case exports.RCCallPlusSessionUserState.CANCELLED:case exports.RCCallPlusSessionUserState.DECLINED:case exports.RCCallPlusSessionUserState.ENDED:case exports.RCCallPlusSessionUserState.IDLE:r.push({callId:t,fromUserId:l,userState:o,systemState:n})}}),{ringingData:i,hangupData:r,acceptData:_,otherInvitedData:s}})(e);C.length>0&&this._onHangup(C,e.callStatus,t),c.length>0&&this._onAccept(c,t),L.length>0&&(null===(_=this._mainSession)||void 0===_?void 0:_.getCallType())===exports.RCCallPlusType.MULTI&&this._onOtherMemberInvite(L),(e.callStatus===exports.RCCallPlusCallState.ENDED||o)&&this._onSessionClose(e,t,o)})}_onOtherClientStatusDown(e,t){var i,r,_;const{callId:s,callSessionUsers:l}=e,o=this._context.getCurrentId(),n=l.find(({userId:e})=>e===o);if(n&&(this._mainSession||this._holdSessions.length)){const{userId:l,sessionStatus:a,statusTime:C}=n;if(a===exports.RCCallPlusSessionUserState.CONNECTING){const n=[exports.RCCallPlusSessionUserState.ONCALL,exports.RCCallPlusSessionUserState.CONNECTING],c=(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())===s,L=null===(_=null===(r=this._mainSession)||void 0===r?void 0:r.getUserList().find(e=>e.userId===o))||void 0===_?void 0:_.userState;if(!(c&&L&&n.includes(L))){const i=this.updateUsersState(s,[{userId:l,userState:a,systemState:exports.RCCallPlusReason.OTHER_CLIENT_ACCEPT,stateTime:C}],t);i.length>0&&this.reportRemoteUserStateChange(s,i,t),this._onSessionClose(e,t,!1)}}}}_onEventDown(e,t){var r;return i(this,void 0,void 0,function*(){const{callId:i,eventArgs:s,eventType:l}=e;if(i===(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())&&this._mainSession.getSessionState()===exports.RCCallPlusCallState.ONCALL&&l===Q.CALL_DURATION){const{firstFrameTime:e}=s,{code:r,clientStartTime:l}=this._timeCorrectioner.calcClientStartTime(i,e,t);this._logger.info(_.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O,`clientFirstFrameTime: ${l}`,t),r===q.SUCCESS&&(this._callStartMap[i].firstFrameTime=l,this._reportAppEventModule.onReceivedCallFirstFrameTime(i,l,t))}})}_onRecvSinCallDuration(e,t,i,r){var _;(null===(_=this._mainSession)||void 0===_?void 0:_.getCallId())===e&&(this._callStartMap[e].callStartTime=t,this._callStartMap[e].firstFrameTime=i,this._reportAppEventModule.onReceivedCallStartTime(Object.assign({callId:e},{callStartTime:t}),r),this._reportAppEventModule.onReceivedCallFirstFrameTime(e,i,r))}_onSwitchMediaType(e,t){var i,r,s,l,o;const{callId:n,action:a,extraKeyVal:C,transactionId:c,promoterId:L}=e,{mediaType:d,reason:E}=C,u=null===(i=this._mainSession)||void 0===i?void 0:i.getCallId();if(n!==u)return void this._logger.info(_.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,`not current session callId: ${u}, recvCallId: ${n}`,t);const{transactionId:T,action:S,mediaType:I}=(null===(r=this._mainSession)||void 0===r?void 0:r.getOldDialogData())||{};if(T!==c||S!==a||I!==d){if(this._logger.info(_.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,`action: ${a}, reason: ${E}`,t),null===(s=this._mainSession)||void 0===s||s.setOldDialogData({transactionId:c,action:a,mediaType:d}),a===M.REQUEST)this._onRequestChangeMediaType({transactionId:c,userId:L,mediaType:d},t);else{let e=null;switch(E){case M.CANCEL:e=exports.RCCallPlusMediaTypeChangeResult.CANCEL_CHANGE_MEDIA_TYPE;break;case M.ACCEPT:e=exports.RCCallPlusMediaTypeChangeResult.SERVER_ALLOW_MEDIA_TYPE,null===(l=this._mainSession)||void 0===l||l.updateMediaType(this._mainSession.getReqMediaType()),null===(o=this._mainSession)||void 0===o||o.updateReqMediaType(null);break;case M.REFUSE:e=exports.RCCallPlusMediaTypeChangeResult.REFUSE_CHANGE_MEDIA_TYPE;break;case M.TIMEOUT:e=exports.RCCallPlusMediaTypeChangeResult.CHANGE_MEDIA_TYPE_TIMEOUT}exports.RCCallPlusMediaTypeChangeResult[e]&&this._receiveMediaTypeChangeResult({transactionId:c,userId:L,mediaType:d},e,t)}a!==M.NOTICE||d!==exports.RCCallPlusMediaType.AUDIO||E||this._receiveMediaTypeChangeResult({transactionId:c,userId:L,mediaType:d},exports.RCCallPlusMediaTypeChangeResult.SERVER_ALLOW_MEDIA_TYPE,t)}else this._logger.info(_.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"duplicate dialog data",t)}_onRecvCallEndLog(e,t){const i=u(e);this._reportAppEventModule.onReceivedCallRecord(i,t)}_onSessionClose(e,t,i){const{callId:r}=e,s=this._context.getCurrentId();this._abnormalModule.removeAbnormalCallIds(s,[r]);let l=[this._mainSession,...this._holdSessions].find(e=>e&&e.getCallId()===r);if(!l)return void this._logger.warn(_.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,`unexpect session callId -> ${r}`,t);this._logger.warn(_.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,`callId: ${r}`,t),this.emit(te.__INNER_SESSION_CLOSE__,r,t);const o=l.getUserList().find(e=>e.userId===s);let n;n=i&&e.toDeviceId!==this._signalModule.getDeviceId()?l.getIsLocalClientHangup()?o.systemState:exports.RCCallPlusReason.OTHER_CLIENT_HANGUP:o.systemState,this._reportAppEventModule.onCallEnded(new L(l,this,this._logger,this._rtcModule,this._context),n,t),this._reportCallPlusSummaryMessage(l,r,n),this._mainSession&&this._mainSession.getCallId()===r&&(this._mainSession.getAllTimerIds().forEach(e=>this._stopTimer.bind(this)(e,t)),l.getCallType()===exports.RCCallPlusType.SINGLE&&(this._isUpFirstFrameTime=!1),delete this._callStartMap[r]),this._removeSession(r)}_reportCallPlusSummaryMessage(t,i,r){var _,s,l;const o=this._context.getCurrentId(),n=t.getUserList().filter(({userId:e})=>e!==o)[0].userId,a=t.getStartCallerId();if(!localStorage.getItem(`missMessageMap-${o}-${i}`)){const C={callId:i,callerUserId:a,targetId:n,mediaType:t.getMediaType(),firstFrameTime:(null===(_=this._callStartMap[i])||void 0===_?void 0:_.firstFrameTime)||0,callStartTime:(null===(s=this._callStartMap[i])||void 0===s?void 0:s.callStartTime)||0,callEndTime:(null===(l=this._callStartMap[i])||void 0===l?void 0:l.callStartTime)?+new Date-this._timeCorrectioner.getLocalDelayTime():0,hangupReason:r};this._reportAppEventModule.onReceivedCallPlusSummaryMessage({messageType:"RC:CallPlusSummary",content:C,senderUserId:a,targetId:n,channelId:"",conversationType:e.ConversationType.PRIVATE,sentTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),receivedTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),messageUId:i,messageDirection:a===o?e.MessageDirection.SEND:e.MessageDirection.RECEIVE,isPersited:!0,isCounted:!1,isOffLineMessage:!1,canIncludeExpansion:!1,receivedStatus:e.ReceivedStatus.READ,isStatusMessage:!1,isMentioned:!1,expansion:null,disableNotification:!1,sentStatus:e.SentStatus.SENT}),localStorage.setItem(`missMessageMap-${o}-${i}`,i)}}_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,s=!1){return i(this,void 0,void 0,function*(){this._logger.info(_.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T,`callId: ${e}`,t);const{code:i,data:l}=yield this.getCallSession({callId:e},t);if(i!==r.SUCCESS)return void this._logger.error(_.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,`errcode: ${i}`,t);this._logger.info(_.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,`code: ${i}, data: ${JSON.stringify(l)}`,t);const{callType:o,mediaType:n,callSessionUsers:a,startCallerId:C}=l;this._mainSession=new V(e,exports.RCCallPlusCallState.CONNECTING,o,n,C,C,[],this._logger),s&&this._clearMobileOnPhone(e,t);const c=this.updateUsersState(e,a,t);c.length>0&&this.reportRemoteUserStateChange(e,c,t)})}_clearMobileOnPhone(e,t){return i(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()===exports.RCCallPlusType.MULTI){this._logger.info(_.L_CALL_ENGINE_UP_ON_PHONE_END_T,`callId: ${e}`,t);const{code:i}=yield this.systemStatusUp({callId:e,sysStatus:exports.RCCallPlusReason.ON_PHONE_END,forward:X.CURRENT},t);i===r.SUCCESS?this._logger.info(_.L_CALL_ENGINE_UP_ON_PHONE_END_R,`callId: ${e}`,t):this._logger.warn(_.L_CALL_ENGINE_UP_ON_PHONE_END_R,`callId: ${e}, errCode: ${i}`,t)}})}reportRemoteUserStateChange(e,t,i){const r=this._context.getCurrentId();t.forEach(t=>{const{userId:_,userState:s,systemState:l}=t;_!==r&&this._reportAppEventModule.onRemoteUserStateChanged({callId:e,userId:_,userState:s,reason:l},i)}),t.forEach(({userId:t,systemState:_})=>{t===r&&_===exports.RCCallPlusReason.ABNORMAL_END&&this.emit(te.__INNER_SESSION_CLOSE__,e,i)})}_onOtherMemberInvite(e){e.forEach(e=>{var t;const{userId:i,callId:r}=e,_=null===(t=this.getLocalMainSession())||void 0===t?void 0:t.getInviterUserId();this._reportAppEventModule.onRemoteUserInvited([i],_,r)})}_onRequestChangeMediaType(e,t){var i;const{userId:r,transactionId:_,mediaType:s}=e;null===(i=this._mainSession)||void 0===i||i.updateReqMediaType(s),this._reportAppEventModule.onReceivedChangeMediaTypeRequest(r,_,s,t)}_receiveMediaTypeChangeResult(e,t,i){t===exports.RCCallPlusMediaTypeChangeResult.SERVER_ALLOW_MEDIA_TYPE&&this.emit(te.__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 ie,re;Object.defineProperty(te,"__INNER_SESSION_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-close"}),Object.defineProperty(te,"__INNER_SESSION_CONNECT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-connect"}),Object.defineProperty(te,"__INNER_CHANGE_MEDIA_TYPE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-change-media-type"}),Object.defineProperty(te,"__INNER_INVITE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-invite"}),function(e){e.NORMAL="RongCloudRTC",e.SCREEN="ScreenShare"}(ie||(ie={}));class _e extends e.EventEmitter{constructor(e,i,r,_,s,l){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:l}),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:t.RCResolution.W640_H480,frameRate:t.RCFrameRate.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==r?void 0:r.rtcClient,this._isPubTiny=r.isPubTiny||!1}setCallPlusStatusReportListener(e){this._callPlusStatusReportListener=e}getCameraVideoTrack(e){return i(this,void 0,void 0,function*(){const t=this.getLocalVideoTrack(),{code:i,track:_}=t&&!this._videoConfigIsChange?{track:t,code:r.SUCCESS}:yield this._createVideoTrack(e);return this._videoConfigIsChange=!1,i!==r.SUCCESS?{code:i}:{code:r.SUCCESS,track:_}})}getMicrophoneAudioTrack(e){return i(this,void 0,void 0,function*(){const t=this.getLocalAudioTrack(),{code:i,track:_}=t&&!this._audioConfigIsChange?{track:t,code:r.SUCCESS}:yield this._createAudioTrack(e);return this._audioConfigIsChange=!1,i!==r.SUCCESS?{code:i}:{code:r.SUCCESS,track:_}})}createCallMediaTracks(e,t){return i(this,void 0,void 0,function*(){this._callMediaType=e;const{code:i}=yield this.getMicrophoneAudioTrack(t);if(i!==r.SUCCESS)return{code:i};if(e===exports.RCCallPlusMediaType.AUDIO_VIDEO){const{code:e}=yield this.getCameraVideoTrack(t);e!==r.SUCCESS&&this._logger.warn(_.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P,`get camera video track error code: ${e}`,t)}return{code:r.SUCCESS}})}setVideoConfig(e){this._videoConfigIsChange=!0,this._videoConfig=e}setAudioConfig(e){this._audioConfigIsChange=!0,this._audioConfig=e}setAudioOutputDeviceId(e){return i(this,void 0,void 0,function*(){if("string"!=typeof e||0===e.length)return{code:r.PARAM_ERROR};if(this._audioOutputDeviceId===e)return{code:r.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:r.SUCCESS}})}destroyAllTracks(e){this._logger.info(_.L_RTC_MODULE_DESTROY_ALL_TRACKS_O,"",e),this._localTracks.forEach(e=>{e.destroy()}),this._localTracks.length=0}setAllRemoteAudioEnable(t,i){if(this._logger.info(_.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T,`enable: ${t}`,i),!e.isBoolean(t))return this._logger.error(_.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,`param error, enable: type is boolean, value: ${t}`),{code:r.PARAM_ERROR};if(this._remoteAudioEnable=t,!this._room)return{code:r.SUCCESS};return this._room.getRemoteTracks().filter(e=>e.isAudioTrack()).forEach(e=>{t?e.unmute():e.mute()}),this._logger.info(_.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,"success",i),{code:r.SUCCESS}}destroyTrack(e){return i(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 i(this,void 0,void 0,function*(){if(this._preHangupCallId=null,this._logger.info(_.L_RTC_MODULE_SESSION_CONNECT_T,`callId: ${e}`,t),!this._room){const{code:i,room:_}=yield this.joinRTCRoom(e,t);if(i!==r.SUCCESS)return;if(this._room=_,this._preHangupCallId&&this._room.getRoomId()===this._preHangupCallId)return this._rtcClient.leaveRoom(this._room),void this._releaseStoredData();const s=this._room.getRemoteUserIds();this._onSelfJoined(e,s,t)}this._callId=e,this._regRTCListeners();let i=this._room.getRemoteTracks();if(i&&i.length&&this._onRemoteTrackPublish(i),this._localTracks.length>0){this.emit(k.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(k.onPublishRes,i)}else this._logger.warn(_.L_RTC_MODULE_SESSION_CONNECT_P,"sessionConnected local tracks is empty",t);this._logger.info(_.L_RTC_MODULE_SESSION_CONNECT_R,`code: ${r.SUCCESS}`,t)})}sessionClose(e,r){var s;return i(this,void 0,void 0,function*(){this._logger.info(_.L_RTC_MODULE_SESSION_CLOSE_T,`callId: ${e}`,r),this._preHangupCallId=e,this.destroyAllTracks(r);const i=null===(s=this._room)||void 0===s?void 0:s.getRoomId();if(this._room&&e===i){const{code:e}=yield this._rtcClient.leaveRoom(this._room);if(this._releaseStoredData(),e!==t.RCRTCCode.SUCCESS)return void this._logger.error(_.L_RTC_MODULE_SESSION_CLOSE_R,`leaveRoom failed, code: ${e}`,r);this._logger.info(_.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom success",r)}else this._logger.warn(_.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom throw exception: not in room",r)})}disableVideoTrack(){return i(this,void 0,void 0,function*(){const e=this.getLocalVideoTrack();if(!e)return{code:r.CAMERA_CLOSED};return{code:yield e.mute(),track:e}})}enableVideoTrack(e){return i(this,void 0,void 0,function*(){const e=this.getLocalVideoTrack();if(!e)return{code:r.CAMERA_CLOSED};if(!e.isOwnerMuted())return{code:r.SUCCESS};return{code:yield e.unmute()}})}changeVideoDevice(e){return i(this,void 0,void 0,function*(){const i=[],_=[],{code:s,track:l}=yield this._rtcClient.createCameraVideoTrack(ie.NORMAL,this._videoConfig);if(s!==t.RCRTCCode.SUCCESS)return{code:s};const{minBitrate:o,maxBitrate:n}=this._videoConfig;let a;if((o||n)&&l.setBitrate(n,o),this._localTracks&&this._localTracks.forEach(e=>{e.isVideoTrack()?(e.destroy(),a=e):_.push(e)}),this._localTracks=this._localTracks.filter(e=>a&&e.getTrackId()!==a.getTrackId()),i.push(l),_.push(l),this._localTracks=_,this._onLocalTrackReady(i,e),this._room){const{code:e}=yield this._room.publish(i);if(e!==t.RCRTCCode.SUCCESS)return{code:e}}return{code:r.SUCCESS,track:l}})}changeAudioDevice(e){return i(this,void 0,void 0,function*(){const i=[],_=[],s=Object.assign(Object.assign({},this._audioConfig),{micphoneId:this._audioConfig.microphoneId}),{code:l,track:o}=yield this._rtcClient.createMicrophoneAudioTrack(ie.NORMAL,s);if(l!==t.RCRTCCode.SUCCESS)return{code:l};if(this._localTracks&&this._localTracks.forEach(e=>{e.isAudioTrack()||_.push(e)}),i.push(o),_.push(o),this._localTracks=_,this._onLocalTrackReady(i,e),this._room){const{code:e}=yield this._room.publish(i);if(e!==t.RCRTCCode.SUCCESS)return{code:e}}return{code:r.SUCCESS}})}disableAudioTrack(){return i(this,void 0,void 0,function*(){const e=this.getLocalAudioTrack();if(!e)return{code:r.MICROPHONE_CLOSED};return{code:yield e.mute(),track:e}})}changeMediaType(e,t){return i(this,void 0,void 0,function*(){let i;this._logger.info(_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T,`mediaType: ${e}`,t),i=e===exports.RCCallPlusMediaType.AUDIO_VIDEO?yield this._upgradeMediaType(t):yield this._downgradeMediaType(t),i.code===r.SUCCESS&&this._logger.info(_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"success",t)})}_upgradeMediaType(e){return i(this,void 0,void 0,function*(){let t=this.getLocalVideoTrack();if(!t){const{code:i,track:s}=yield this._createVideoTrack(e);if(i!==r.SUCCESS)return this._logger.error(_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`create video track errCode: ${i}`,e),{code:i};t=s;const{minBitrate:l,maxBitrate:o}=this._videoConfig;(l||o)&&t.setBitrate(o,l)}const i=this._isPubTiny?{track:t,isPubTiny:!0}:t,{code:s}=yield this.publish([i],e);return s!==r.SUCCESS&&this._logger.error(_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`publish errCode: ${s}`,e),{code:s}})}_downgradeMediaType(e){return i(this,void 0,void 0,function*(){const i=this.getLocalVideoTrack();if(i){const{code:r}=yield this._room.unpublish([i]);if(r!==t.RCRTCCode.SUCCESS)return this._logger.error(_.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`unpublish errCode: ${r}`,e),{code:r};this.destroyTrack(i)}return{code:r.SUCCESS}})}joinRTCRoom(s,l){return i(this,void 0,void 0,function*(){this._logger.info(_.L_RTC_MODULE_JOIN_RTC_ROOM_T,`call: ${s}`,l);const{code:i,room:o,tracks:n}=yield w({asyncFn:this._rtcClient.joinRTCRoomWithOptions.bind(this._rtcClient),fnArgs:[s,{mode:e.RTCMode.CALL}]});return i!==t.RCRTCCode.SUCCESS?(this._logger.error(_.L_RTC_MODULE_JOIN_RTC_ROOM_R,`callId: ${s}, errCode: ${i}`,l),this._onRTCMethodFail(exports.RCCallPlusReason.JOIN_ROOM_ERR,l),{code:i}):(this._logger.info(_.L_RTC_MODULE_JOIN_RTC_ROOM_R,"success",l),this._callId=s,{code:r.SUCCESS,room:o,tracks:n})})}subscribeTracks(e,s){return i(this,void 0,void 0,function*(){if(this._logger.info(_.L_RTC_MODULE_SUBSCRIBE_T,JSON.stringify({params:e.map(e=>{const{track:t,subTiny:i}=e;return{trackId:t.getTrackId(),subTiny:i}})}),s),!this._room)return{code:r.SUCCESS};const{code:i}=yield w({asyncFn:this._room.subscribe.bind(this._room),fnArgs:[e],onError:e=>{}});return i!==t.RCRTCCode.SUCCESS?(this._reportAppEventModule.onFetchRemoteMediaError(e,i),this._onRTCMethodFail(exports.RCCallPlusReason.SUBSCRIBE_ERR,s),this._logger.error(_.L_RTC_MODULE_SUBSCRIBE_R,`errorCode: ${i}`,s),{code:i}):(this._logger.info(_.L_RTC_MODULE_SUBSCRIBE_R,"success",s),{code:r.SUCCESS})})}unsubscribeTracks(e,s){return i(this,void 0,void 0,function*(){if(this._logger.info(_.L_RTC_MODULE_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map(e=>e.getTrackId())}),s),!this._room)return{code:r.SUCCESS};const{code:i}=yield this._room.unsubscribe(e);return i!==t.RCRTCCode.SUCCESS?(this._logger.error(_.L_RTC_MODULE_UNSUBSCRIBE_R,`errorCode: ${i}`,s),{code:i}):(this._logger.info(_.L_RTC_MODULE_UNSUBSCRIBE_R,"success",s),{code:r.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===exports.RCCallPlusMediaType.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(_e.__INNER_RECEIVE_FIRST_FRAME__)}_onKickOff(e,i,r,s){this._logger.info(_.L_RTC_MODULE_RECEIVE_KICK_OFF_O,`roonId: ${i}, byServer: ${e}, state: ${r}, kickExtra: ${JSON.stringify(s)}`);let l=exports.RCCallPlusReason.CONNECTION_ERR;if(e)if(s)l=s.kickReasonCode;else switch(r){case t.RCKickReason.SERVER_KICK:l=exports.RCCallPlusReason.KICKED_BY_SERVER;break;case t.RCKickReason.OTHER_KICK:l=exports.RCCallPlusReason.OTHER_CLIENT_JOINED;break;case t.RCKickReason.IM_DISCONNECTED:l=exports.RCCallPlusReason.CONNECTION_ERR;break;case t.RCKickReason.IM_LOGOUT:l=exports.RCCallPlusReason.LOGOUT;break;case t.RCKickReason.OTHER_CLIENT_IM_CONNECTED:l=exports.RCCallPlusReason.OTHER_CLIENT_LOGIN}this.emit(_e.__INNER_ON_KICKOFF__,l,i)}_onRTCPeerConnectionCloseByException(){const e=this._logger.createTraceId();this._logger.info(_.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O,"",e),this.emit(_e.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,e)}_onSelfJoined(e,t,r){return i(this,void 0,void 0,function*(){this.emit(_e.__INNER_ON_SELF_JOINED__,e,t,r)})}_onRemoteTrackPublish(e){const t=this._logger.createTraceId();this._logger.info(_.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 r=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[r])||void 0===t?void 0:t.videoView){const{isTiny:t}=this._userViewMap[r];i.push({track:e,subTiny:t})}}),i.length&&this.subscribeTracks(i,t)}_onTrackUnpublish(e){return i(this,void 0,void 0,function*(){const t=this._logger.createTraceId();this._logger.info(_.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(_.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(_.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:i,receivers:r}=e;i.forEach(e=>{var t;const{kind:i,packetsLostRate:r,rtt:_}=e;this._callMediaType===exports.RCCallPlusMediaType.AUDIO_VIDEO&&"audio"===i||null===(t=this._callPlusStatusReportListener)||void 0===t||t.onSendPacketLoss(r||0,_||0)}),r.forEach(e=>{var i;const{trackId:r,kind:_,packetsLostRate:s,bitrate:l}=e;if(this._callMediaType===exports.RCCallPlusMediaType.AUDIO_VIDEO&&"audio"===_)return;const{userId:o}=t.helper.parseTrackId(r),n={};n[o]={packetLostRate:s||0,bitRate:l},null===(i=this._callPlusStatusReportListener)||void 0===i||i.onReceivePacketLoss(n)})}_onRTCMethodFail(e,t){this.emit(_e.__INNER_RTC_PROCESS_FAILED__,e,t)}_onOtherMemJoined(e,t){this.emit(_e.__INNER_ON_OTHER_JOINED__,e,t)}_createAudioTrack(e){return i(this,void 0,void 0,function*(){this._logger.info(_.L_RTC_MODULE_CREATE_AUDIO_TRACK_T,"",e);const i=Object.assign(this._audioConfig,{micphoneId:this._audioConfig.microphoneId}),{code:s,track:l}=yield this._rtcClient.createMicrophoneAudioTrack(ie.NORMAL,i);if(s!==t.RCRTCCode.SUCCESS)return this._logger.error(_.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,`errCode: ${s}`,e),{code:s};this._logger.info(_.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,"success",e);const{minBitrate:o,maxBitrate:n}=this._audioConfig;return(o||n)&&l.setBitrate(n,o),this._localTracks.push(l),this._onLocalTrackReady([l],e),{code:r.SUCCESS,track:l}})}_createVideoTrack(e){return i(this,void 0,void 0,function*(){this._logger.info(_.L_RTC_MODULE_CREATE_VIDEO_TRACK_T,"",e);const{code:i,track:s}=yield this._rtcClient.createCameraVideoTrack(ie.NORMAL,this._videoConfig);if(i!==t.RCRTCCode.SUCCESS)return this._logger.error(_.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,`errCode: ${i}`,e),{code:i};this._logger.info(_.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,"success",e);const{minBitrate:l,maxBitrate:o}=this._videoConfig;return(l||o)&&s.setBitrate(o,l),this._localTracks.push(s),this._onLocalTrackReady([s],e),{code:r.SUCCESS,track:s}})}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,s){return i(this,void 0,void 0,function*(){this._logger.info(_.L_RTC_MODULE_PUBLISH_T,`tracksIds: ${e.map(e=>e instanceof t.RCLocalTrack?e.getTrackId():e.track.getTrackId())}`,s);const{code:i}=yield w({asyncFn:this._room.publish.bind(this._room),fnArgs:[e],onError:e=>{}});return i!==t.RCRTCCode.SUCCESS?(this._onRTCMethodFail(exports.RCCallPlusReason.PUBLISH_ERR,s),this._logger.error(_.L_RTC_MODULE_PUBLISH_R,`errCode: ${i}`,s),{code:i}):(this._logger.info(_.L_RTC_MODULE_PUBLISH_R,`code: ${r.SUCCESS}`,s),{code:r.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:r,isTiny:_=!1}=e;if(this._userViewMap[t]={videoView:r,isTiny:_},t===this._context.getCurrentId())return;if(!this._room)return;const s=(this.getRemoteTracks()[t]||[]).map(e=>({track:e,subTiny:_}));i.push(...s)}),this._logger.info(_.L_RTC_MODULE_SET_VIDEO_VIEW_O,JSON.stringify({userViewMap:R(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(_.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O,JSON.stringify({userViewMap:R(this._userViewMap),unsubTracks:i.map(e=>e.getTrackId())}),t),i.length&&this.unsubscribeTracks(i,t)}getUserViewMap(){return this._userViewMap}playMedia(e,s,l,o){var n;return i(this,void 0,void 0,function*(){this._logger.info(_.L_RTC_MODULE_PLAY_MEDIA_T,`userId: ${e}, mediaType: ${s}, videoView: ${null==l?void 0:l.nodeName}`,o);const i=this._context.getCurrentId();if(e===i&&s===exports.RCCallPlusMediaType.AUDIO)return this._logger.error(_.L_RTC_MODULE_PLAY_MEDIA_R,"please avoid playing local audio to prevent echoes.",o),{code:r.PLAY_MEDIA_FAILED};let a=null;if(a=e===i?s===exports.RCCallPlusMediaType.AUDIO?null:this.getLocalVideoTrack():null===(n=this.getRemoteTracks()[e])||void 0===n?void 0:n.filter(e=>s===exports.RCCallPlusMediaType.AUDIO?e.isAudioTrack():e.isVideoTrack())[0],!a)return this._logger.error(_.L_RTC_MODULE_PLAY_MEDIA_R,`error code: ${r.MEDIA_RESOURCE_INVALIED}`,o),{code:r.MEDIA_RESOURCE_INVALIED};try{const{code:e}=a.isAudioTrack()?yield a.play(void 0,{audioDeviceId:this._audioOutputDeviceId||void 0}):yield a.play(l);return a.isAudioTrack()&&!this._remoteAudioEnable&&a.mute(),e!==t.RCRTCCode.SUCCESS?(this._logger.error(_.L_RTC_MODULE_PLAY_MEDIA_R,`errCode: ${e}`,o),{code:e}):(this._logger.info(_.L_RTC_MODULE_PLAY_MEDIA_R,"success",o),{code:r.SUCCESS})}catch(e){return this._logger.error(_.L_RTC_MODULE_PLAY_MEDIA_R,`errCode: ${r.PLAY_MEDIA_FAILED}, message: ${e.message},`,o),{code:r.PLAY_MEDIA_FAILED}}})}}Object.defineProperty(_e,"__INNER_RTC_PROCESS_FAILED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-process-failed"}),Object.defineProperty(_e,"__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-peerconnection-abnormal-close"}),Object.defineProperty(_e,"__INNER_ON_SELF_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-self-joined"}),Object.defineProperty(_e,"__INNER_ON_OTHER_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-other-joined"}),Object.defineProperty(_e,"__INNER_RECEIVE_FIRST_FRAME__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-receive-first-frame"}),Object.defineProperty(_e,"__INNER_ON_KICKOFF__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-kickoff-frame"});class se{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 r;return i(this,void 0,void 0,function*(){const i=null===(r=this._listener)||void 0===r?void 0:r[e];if(i)try{yield i(...t)}catch(e){console.error(e),this._logger.error(_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({name:e.name,message:e.message}))}})}onReceivedCall(e,t,i){this._logger.info(_.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(_.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(_.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(_.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:r,userState:s,reason:l}=e;this._logger.info(_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserStateChanged",callId:i,userId:r,userState:s,reason:l}),t),this._callAppListener("onRemoteUserStateChanged",i,r,s,l)}onCallEnded(e,t,i){this._logger.info(_.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(_.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(_.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(_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallRecord",record:e}),t),this._callAppListener("onReceivedCallRecord",e)}onReceivedChangeMediaTypeRequest(e,t,i,r){this._logger.info(_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeRequest",userId:e,transactionId:t}),r),this._callAppListener("onReceivedChangeMediaTypeRequest",e,t,i)}onReceivedChangeMediaTypeResult(e,t){const{userId:i,transactionId:r,mediaType:s,code:l}=e;this._logger.info(_.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeResult",userId:i,mediaType:s}),t),this._callAppListener("onReceivedChangeMediaTypeResult",{userId:i,transactionId:r,mediaType:s,code:l})}onReceivedCallStartTime(e,t){this._logger.info(_.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(_.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(_.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()?exports.RCCallPlusMediaType.AUDIO:exports.RCCallPlusMediaType.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"}(re||(re={}));class le{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(t){return e.isString(t)?(this._androidPushConfig.channelIdMi=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdMi type is string, value: ${t}`),this)}setTemplateIdMi(t){return e.isString(t)?(this._androidPushConfig.templateIdMi=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: templateIdMi type is string, value: ${t}`),this)}setTemplateParamMi(t){if(!t||"object"!=typeof t||Array.isArray(t))return this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: templateParamMi type is object, value: ${JSON.stringify(t)}`),this;const i=Object.keys(t).find(i=>!e.isString(i)||!e.isString(t[i]));return void 0!==i?(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: templateParamMi.${i} key and value type is string, value: ${JSON.stringify(t)}`),this):(this._androidPushConfig.templateParamMi=Object.assign({},t),this)}setMiLargeIconUrl(e){return this._logger.warn(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"`setMiLargeIconUrl` has been deprecated."),this}setChannelIdHW(t){return e.isString(t)?(this._androidPushConfig.channelIdHW=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdHW type is string, value: ${t}`),this)}setCategoryHW(t){return e.isString(t)?(this._androidPushConfig.categoryHW=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: categoryHW type is string, value: ${t}`),this)}setImportanceHW(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: importanceHW value is NORMAL|LOW, value: ${e}`),this):(this._androidPushConfig.importanceHW=e,this)}setImageUrlHW(t){return e.isString(t)?(this._androidPushConfig.imageUrlHW=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: imageUrlHW type is string, value: ${t}`),this)}setChannelIdOPPO(t){return e.isString(t)?(this._androidPushConfig.channelIdOPPO=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdOPPO type is string, value: ${t}`),this)}setTypeVivo(t){return e.isString(t)?(this._androidPushConfig.typeVivo=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: typeVivo type is string, value: ${t}`),this)}setCategoryVivo(t){return e.isString(t)?(this._androidPushConfig.categoryVivo=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: categoryVivo type is string, value: ${t}`),this)}setFcmChannelId(t){return e.isString(t)?(this._androidPushConfig.fcmChannelId=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmChannelId type is string, value: ${t}`),this)}setFcmCollapseKey(t){return e.isString(t)?(this._androidPushConfig.fcmCollapseKey=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmCollapseKey type is string, value: ${t}`),this)}setFcmImageUrl(t){return e.isString(t)?(this._androidPushConfig.fcmImageUrl=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmImageUrl type is string, value: ${t}`),this)}setimportanceHonor(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: importanceHonor value is NORMAL|LOW, value: ${e}`),this):(this._androidPushConfig.importanceHonor=e,this)}setimageUrlHonor(t){return e.isString(t)?(this._androidPushConfig.imageUrlHonor=t,this):(this._logger.error(_.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: imageUrlHonor type is string, value: ${t}`),this)}build(){const e=Object.assign({},this._androidPushConfig);return e.templateParamMi&&(e.templateParamMi=Object.assign({},e.templateParamMi)),e}}class oe{constructor(e,i,_,s){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:t.RCResolution.W640_H480,frameRate:t.RCFrameRate.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 se(i),this._callPlusStatistics=new G(this._logger,this._context),this._callEngine=new te(this._context,this._runtime,this._initOpts,this._logger,this._reportAppEventModule),this._rtcModule=new _e(this._context,this._runtime,this._initOpts,this._logger,this._callEngine,this._reportAppEventModule),this._callEngine.setRTCModule(this._rtcModule),this._rtcModule.on(_e.__INNER_RTC_PROCESS_FAILED__,this._rtcProcessFailHandle.bind(this)),this._rtcModule.on(_e.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,this._peerConnectionAbnormalClose.bind(this)),this._rtcModule.on(_e.__INNER_ON_SELF_JOINED__,this._selfJoinedHandle.bind(this)),this._rtcModule.on(_e.__INNER_ON_OTHER_JOINED__,this._otherJoinedHandle.bind(this)),this._rtcModule.on(_e.__INNER_RECEIVE_FIRST_FRAME__,this._receiveFirstFrameHandle.bind(this)),this._rtcModule.on(_e.__INNER_ON_KICKOFF__,this._kickoffHandle.bind(this)),this._callEngine.on(te.__INNER_SESSION_CONNECT__,this._rtcModule.sessionConnected.bind(this._rtcModule)),this._callEngine.on(te.__INNER_SESSION_CLOSE__,this._sessionCloseHandle.bind(this)),this._callEngine.on(te.__INNER_CHANGE_MEDIA_TYPE__,this._rtcModule.changeMediaType.bind(this._rtcModule)),this._callEngine.on(te.__INNER_INVITE__,(e,t)=>{this._callPlusStatistics.reportStatisticsData(f.L_QS_RECEIVE_CALL_S,r.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:X.CURRENT},t),this._callPlusStatistics.reportStatisticsData(f.L_QS_ABNORMAL_HANGUP_S,r.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:exports.RCCallPlusReason.CONNECTION_ERR,forward:X.CURRENT},e),this._callEngine.endCurrentSession(exports.RCCallPlusReason.CONNECTION_ERR,t.getCallId(),e))}_selfJoinedHandle(e,t,r){return i(this,void 0,void 0,function*(){const i=this._context.getCurrentId(),_=this._callEngine.getLocalMainSession();((null==_?void 0:_.getCallType())===exports.RCCallPlusType.MULTI||t.length)&&this._callEngine.updateMainSessionState(exports.RCCallPlusCallState.ONCALL);const s=[i,...t].map(e=>({userId:e,userState:exports.RCCallPlusSessionUserState.ONCALL,systemState:exports.RCCallPlusReason.ONCALL})),l=this._callEngine.updateUsersState(e,s,r);this._reportAppEventModule.onCallConnected(_),l.length>0&&this._callEngine.reportRemoteUserStateChange(e,l,r),this._callEngine.startTimeCorrection(r)})}_otherJoinedHandle(e,t){var i;let r="";const _=e.map(e=>(r=e.callId,{userId:e.userId,userState:exports.RCCallPlusSessionUserState.ONCALL,systemState:exports.RCCallPlusReason.ONCALL})),s=this._callEngine.updateUsersState(r,_,t);s.length>0&&this._callEngine.reportRemoteUserStateChange(r,s,t),(null===(i=this._callEngine.getLocalMainSession())||void 0===i?void 0:i.getState())!==exports.RCCallPlusCallState.ONCALL&&this._callEngine.updateMainSessionState(exports.RCCallPlusCallState.ONCALL)}_receiveFirstFrameHandle(e){var t;(null===(t=this._callEngine.getLocalMainSession())||void 0===t?void 0:t.getState())!==exports.RCCallPlusCallState.ONCALL&&this._callEngine.updateMainSessionState(exports.RCCallPlusCallState.ONCALL),this._callEngine.upFirstFrameTime(e)}_kickoffHandle(e,t,i){if(e===exports.RCCallPlusReason.CONNECTION_ERR)return void this._callEngine.endCurrentSession(e,t,i);const _=this._callEngine.getLocalMainSession();if(_){const s=_.getCallId();this._callPlusStatistics.reportStatisticsData(f.L_QS_ABNORMAL_HANGUP_S,r.SUCCESS,+new Date,_,this._clientCallId),this._callEngine.systemStatusUp({callId:s,sysStatus:e,forward:X.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(_.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._reportAppEventModule.registerEventListener(e)}setStatusReportListener(e){this._logger.info(_.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._rtcModule.setCallPlusStatusReportListener(e)}setVideoView(t){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T,JSON.stringify({list:t.map(e=>{const{userId:t,videoElement:i,isTiny:r}=e;return{userId:t,elementName:null==i?void 0:i.nodeName,isTiny:r}})}),i),!e.notEmptyArray(t))return this._logger.error(_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, list: not empty array, value: ${JSON.stringify(t)}`,i),{code:r.PARAM_ERROR};for(const s of t){const{userId:t,videoElement:l}=s;if(!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, userId: not empty string, value: ${t}`,i),{code:r.PARAM_ERROR};if(!T(l))return this._logger.error(_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, videoElement: need a video element, value: ${l instanceof HTMLElement?l.nodeName:l}`,i),{code:r.PARAM_ERROR}}return this._logger.info(_.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"succes",i),this._rtcModule.setVideoView(t,i),{code:r.SUCCESS}}removeVideoView(t){const i=this._logger.createTraceId();return this._logger.info(_.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T,JSON.stringify({userIds:t}),i),e.notEmptyArray(t)&&t.every(t=>e.notEmptyString(t))?(this._logger.info(_.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,"succes",i),this._rtcModule.removeVideoView(t,i),{code:r.SUCCESS}):(this._logger.error(_.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(t)}`,i),{code:r.PARAM_ERROR})}playMedia(t,s){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_PLAY_MEDIA_T,JSON.stringify({userId:t,mediaType:s}),i),!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`params err, userId: not empty string, value: ${t}`,i),{code:r.PARAM_ERROR};if(e.isUndefined(exports.RCCallPlusMediaType[s]))return this._logger.error(_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`params err, mediaType is illegal, value: ${s}`,i),{code:r.PARAM_ERROR};if(s===exports.RCCallPlusMediaType.AUDIO&&t===this._context.getCurrentId())return this._logger.info(_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"success",i),{code:r.SUCCESS};const{videoView:l}=this._rtcModule.getUserViewMap()[t]||{};return s===exports.RCCallPlusMediaType.AUDIO||l?this._rtcModule.playMedia(t,s,l,i):(this._logger.error(_.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`errCode: ${r.VIDEO_VIEW_NOT_SET}, video view not set`,i),{code:r.VIDEO_VIEW_NOT_SET})})}createVideoConfigBuilder(){return new E(this._logger)}setVideoConfig(e){this._logger.info(_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T,JSON.stringify(e));const{frameRate:i,resolution:s,maxBitrate:l,minBitrate:o}=e;if(!t.RCFrameRate[i])return this._logger.error(_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,`param error, frameRate is illegal, value: ${i}`),{code:r.PARAM_ERROR};if(!t.RCResolution[s])return this._logger.error(_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,`param error, resolution is illegal, value: ${s}`),{code:r.PARAM_ERROR};const{code:n,errorMsg:a}=I(o,l);return n!==r.SUCCESS&&this._logger.error(_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,a),this._logger.info(_.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"success"),this._videoConfig=Object.assign({},e),this._rtcModule.setVideoConfig(this._videoConfig),{code:r.SUCCESS}}createAudioConfigBuilder(){return new d(this._logger)}createAndroidPushConfigBuilder(){return new le(this._logger)}setAudioConfig(t){this._logger.info(_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T,JSON.stringify(t));const{sampleRate:i,minBitrate:s,maxBitrate:l}=t;if(i&&!e.isNumber(i))return this._logger.error(_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,`param error, sampleRate: type is number, value: ${i}`),{code:r.PARAM_ERROR};const{code:o,errorMsg:n}=I(s,l);return o!==r.SUCCESS&&this._logger.error(_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,n),this._logger.info(_.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,"success"),this._audioConfig=Object.assign({},t),this._rtcModule.setAudioConfig(this._audioConfig),{code:r.SUCCESS}}setAudioOutputDeviceId(e){return this._logger.info(_.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O,e),this._rtcModule.setAudioOutputDeviceId(e)}startCall(t,s=exports.RCCallPlusType.SINGLE,l=exports.RCCallPlusMediaType.AUDIO_VIDEO,o,n,a){return i(this,void 0,void 0,function*(){this._clientCallId=e.getUUID();const i=+new Date,C=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_START_CALL_T,`userIds: ${t.join(",")}, callType: ${s}, mediaType: ${l}, pushConfig: ${JSON.stringify(o)}, extra: ${n}`,C),this._context.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED)return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${r.SIGNAL_DISCONNECTED}`,C),{code:r.SIGNAL_DISCONNECTED};const c=this._context.getNaviInfo();if(!c||!S(c))return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${r.RTC_SERVICE_UNAVAILABLE}`,C),{code:r.RTC_SERVICE_UNAVAILABLE};if(!e.notEmptyArray(t)||!t.every(t=>e.notEmptyString(t)))return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(t)}`,C),{code:r.PARAM_ERROR};if(e.isUndefined(exports.RCCallPlusType[s]))return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, callType is illegal, value: ${s}`,C),{code:r.PARAM_ERROR};if(e.isUndefined(exports.RCCallPlusMediaType[l]))return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, mediaType is illegal, value: ${l}`,C),{code:r.PARAM_ERROR};if(o){const e=A(o);if(e.code!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,C),{code:r.PARAM_ERROR}}if(n){if(!e.isString(n))return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, extra is illegal, type: string, value: ${n}`,C),{code:r.PARAM_ERROR};if(p(n)>F)return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,"params err, extra max size is 128KB",C),{code:r.PARAM_ERROR}}if(t.length>1&&s===exports.RCCallPlusType.SINGLE)return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, You can only call one person in a single call, userIds: ${t.join(",")}`,C),{code:r.PARAM_ERROR};if(a&&!e.isString(a))return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`params err, targetId is illegal, type: string, value: ${a}`,C),{code:r.PARAM_ERROR};if(this._callEngine.getLocalMainSession())return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${r.SESSION_EXIST}, session exist`,C),{code:r.SESSION_EXIST};const{code:L}=yield this._rtcModule.createCallMediaTracks(l,C);if(L!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`create meida tracks error code: ${L}`,C),{code:L};const{code:d,data:E}=yield this._callEngine.startCall({toUsers:t.map(e=>({userId:e})),callType:s,mediaType:l,callId:this._clientCallId,pushConfig:o,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:n}),targetId:a},C);if(this._callPlusStatistics.reportStatisticsData(f.L_QS_START_CALL_S,d,i,null,this._clientCallId,null,{mediaType:l,callType:s,callId:(null==E?void 0:E.callId)||""}),d!==r.SUCCESS)return this._rtcModule.destroyAllTracks(C),this._logger.error(_.L_CALLPLUS_CLIENT_START_CALL_R,`signal error code: ${d}`,C),{code:d};const{callId:u,clientCallId:T}=E;return this._needHangupCallId===T?(this._callEngine.clearAllTimer(u,C),this._callEngine.hangup({callId:u,systemState:exports.RCCallPlusReason.CANCELLED},C),this._logger.info(_.L_CALLPLUS_CLIENT_START_CALL_R,`the ${u} call has been hangup`,C),{code:r.SUCCESS}):(s===exports.RCCallPlusType.MULTI&&this._rtcModule.sessionConnected(u,C),this._logger.info(_.L_CALLPLUS_CLIENT_START_CALL_R,JSON.stringify({data:E,code:d}),C),{code:r.SUCCESS,callId:u})})}joinMultiCall(t){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T,`callId: ${t}`,i),this._context.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED)return this._logger.error(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${r.SIGNAL_DISCONNECTED}`,i),{code:r.SIGNAL_DISCONNECTED};const s=this._context.getNaviInfo();if(!s||!S(s))return this._logger.error(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${r.RTC_SERVICE_UNAVAILABLE}`,i),{code:r.RTC_SERVICE_UNAVAILABLE};if(!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`params err, callId: not empty string, value: ${t}`,i),{code:r.PARAM_ERROR};const{code:l,data:o}=yield this._callEngine.getCallSession({callId:t},i);if(l!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`get call data error, code: ${l}`,i),{code:l};const{mediaType:n}=o,a=this._callEngine.getLocalMainSession();if(a&&a.getCallId()!==t)return{code:r.SESSION_EXIST};const{code:C}=yield this._rtcModule.createCallMediaTracks(n,i);if(C!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`create meida tracks error code: ${C}`,i),{code:C};const{code:c}=yield this._callEngine.joinCall({callId:t,mediaType:n},i);return c!==r.SUCCESS?(this._rtcModule.destroyAllTracks(i),this._logger.error(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`signal error code: ${c}`,i),{code:c}):(this._logger.info(_.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${r.SUCCESS}`,i),yield this._rtcModule.sessionConnected(t,i),{code:r.SUCCESS})})}invite(t,s,l){var o;return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_INVITE_T,`callId: ${t.join(",")}, pushConfig: ${s}, extra: ${l}`,i),!e.notEmptyArray(t)||!t.every(t=>e.notEmptyString(t)))return this._logger.error(_.L_CALLPLUS_CLIENT_INVITE_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(t)}`,i),{code:r.PARAM_ERROR};if(s){const e=A(s);if(e.code!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_INVITE_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,i),{code:r.PARAM_ERROR}}if(l){if(!e.isString(l))return this._logger.error(_.L_CALLPLUS_CLIENT_INVITE_R,`params err, extra is illegal, value: ${l}`,i),{code:r.PARAM_ERROR};if(p(l)>F)return this._logger.error(_.L_CALLPLUS_CLIENT_INVITE_R,"params err, extra max size is 128KB",i),{code:r.PARAM_ERROR}}const{code:n,data:a}=yield this._callEngine.invite({toUsers:t.map(e=>({userId:e})),pushConfig:s,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:l})},i);if(n!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_INVITE_R,`signal error code: ${n}`,i),{code:n};const C=[];return(null===(o=a.busylineUsers)||void 0===o?void 0:o.length)&&C.push(...a.busylineUsers.map(e=>({userId:e.userId,state:e.sessionStatus}))),this._logger.info(_.L_CALLPLUS_CLIENT_INVITE_R,`success busyUsers: ${JSON.stringify(C)}`,i),{code:r.SUCCESS,busyUsers:C}})}accept(t,s){return i(this,void 0,void 0,function*(){const i=+new Date,l=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_ACCEPT_T,`callId: ${t}, pushConfig: ${s}`,l),this._context.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED)return this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode: ${r.SIGNAL_DISCONNECTED}`,l),{code:r.SIGNAL_DISCONNECTED};const o=this._context.getNaviInfo();if(!o||!S(o))return this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode: ${r.RTC_SERVICE_UNAVAILABLE}`,l),{code:r.RTC_SERVICE_UNAVAILABLE};if(!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`params err, callId: not empty string, value: ${t}`,l),{code:r.PARAM_ERROR};if(s){const e=A(s);if(e.code!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,l),{code:r.PARAM_ERROR}}let n=this._callEngine.getLocalMainSession();const a=this._callEngine.getHoldSession(t);if(!n&&!a)return this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode : ${r.NOT_IN_CALL}, session not exist`,l),{code:r.NOT_IN_CALL};if(t===(null==a?void 0:a.getCallId())){const{code:e}=yield this.hangup(n.getCallId());if(e!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`hangup mainSession error code: ${e}`,l),{code:e};this._callEngine.upgradeMainSession(t),n=this._callEngine.getLocalMainSession()}const C=n.getMediaType(),{code:c}=yield this._rtcModule.createCallMediaTracks(C,l);if(c!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`create meida tracks error code: ${c}`,l),{code:c};const{code:L}=yield this._callEngine.accept({callId:t},l);return this._callPlusStatistics.reportStatisticsData(f.L_QS_ACCEPT_CALL_S,L,i,n),L!==r.SUCCESS?(this._rtcModule.destroyAllTracks(l),this._logger.error(_.L_CALLPLUS_CLIENT_ACCEPT_R,`signal error code: ${L}`,l),{code:L}):(this._logger.info(_.L_CALLPLUS_CLIENT_ACCEPT_R,"success",l),this._rtcModule.sessionConnected(t,l),{code:r.SUCCESS})})}__innerHangup(e,t){var _;return i(this,void 0,void 0,function*(){const{callId:i}=e;this._callEngine.setIsLocalClientHangup(!0),this._callEngine.clearAllTimer(i,t);const{code:s}=yield this._callEngine.hangup(e,t);return s===re.CALL_NOT_EXIST?{code:r.SUCCESS}:(s===r.SUCCESS&&i===(null===(_=this._callEngine.getLocalMainSession())||void 0===_?void 0:_.getCallId())&&(yield this._rtcModule.sessionClose(i,t)),{code:s})})}hangup(t,s){return i(this,void 0,void 0,function*(){const i=+new Date,l=this._logger.createTraceId();this._logger.info(_.L_CALLPLUS_CLIENT_HANGUP_T,`callId: ${t}, pushConfig: ${JSON.stringify(s)}`,l);const o=this._callEngine.getLocalMainSession();if(!o)return{code:r.NOT_IN_CALL};if(t&&!e.isString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_HANGUP_R,`params err, callId: type is string, value: ${t}`,l),{code:r.PARAM_ERROR};if(s){const e=A(s);if(e.code!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_HANGUP_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,l),{code:r.PARAM_ERROR}}const n=o.getCallId();if(t&&t!==n&&!this._callEngine.getHoldSession(t))return this._logger.error(_.L_CALLPLUS_CLIENT_HANGUP_R,`params err, callId is invalid, value: ${t}`,l),{code:r.CALL_ID_INVALID};this._isLaunchHangup=!0,this._needHangupCallId=t||n;const a=this._callEngine.getHoldSession(this._needHangupCallId)||o,C=this._context.getCurrentId(),c=((e,t)=>{let i;switch(e){case exports.RCCallPlusSessionUserState.CALLING:i=exports.RCCallPlusReason.CANCELLED;break;case exports.RCCallPlusSessionUserState.RINGING:case exports.RCCallPlusSessionUserState.INVITED:i=exports.RCCallPlusReason.DECLINED;break;case exports.RCCallPlusSessionUserState.CONNECTING:i=t?exports.RCCallPlusReason.DECLINED:exports.RCCallPlusReason.CANCELLED;break;case exports.RCCallPlusSessionUserState.ONCALL:i=exports.RCCallPlusReason.ENDED}return i})(o.getUserList().filter(e=>e.userId===C)[0].state,[o.getCreatorUserId(),o.getInviterUserId()].includes(C))||exports.RCCallPlusReason.ENDED,{code:L}=yield this.__innerHangup({callId:this._needHangupCallId,systemState:c,pushConfig:s},l);return this._callPlusStatistics.reportStatisticsData(f.L_QS_HANGUP_CALL_S,L,i,a,this._clientCallId),L!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_HANGUP_R,`signal error code : ${L}`,l),{code:L}):(this._needHangupCallId=null,this._logger.info(_.L_CALLPLUS_CLIENT_HANGUP_R,"success",l),{code:r.SUCCESS})})}requestChangeMediaType(t){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T,`mediaType: ${t}`,i),e.isUndefined(exports.RCCallPlusMediaType[t]))return this._logger.error(_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`params err, mediaType is illegal, value: ${t}`,i),{code:r.PARAM_ERROR};const s=this.getCurrentCallSession(),l=null==s?void 0:s.getMediaType();if(t===l)return this._logger.error(_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`error code: ${r.MEDIATYPE_INVALID}`,i),{code:r.MEDIATYPE_INVALID};if(!this._callEngine.getLocalMainSession())return this._logger.error(_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`error code : ${r.NOT_IN_CALL}, session not exist`,i),{code:r.NOT_IN_CALL};const o=null==s?void 0:s.getUserList().filter(e=>e.userId!==this._context.getCurrentId()).map(e=>e.userId),{code:n,data:a}=yield this._callEngine.requestChangeMediaType({mediaType:t,toUserIds:o||[]},i);return n!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`signal error code: ${n}`,i),{code:n}):(this._logger.info(_.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`success transactionId: ${a.transactionId}`,i),{code:r.SUCCESS,transactionId:a.transactionId})})}cancelChangeMediaType(t){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T,`transactionId: ${t}`,i),!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`param error, transactionId: not empty string, value: ${t}`,i),{code:r.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`error code : ${r.NOT_IN_CALL}, session not exist`,i),{code:r.NOT_IN_CALL};const{code:s}=yield this._callEngine.cancelChangeMediaType({transactionId:t},i);return s!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`signal error code: ${s}`,i),{code:s}):(this._logger.info(_.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"success",i),{code:r.SUCCESS})})}replyChangeMediaType(t,s){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T,`transactionId: ${t}`,i),!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`param error, transactionId: not empty string, value: ${t}`,i),{code:r.PARAM_ERROR};if(!e.isBoolean(s))return this._logger.error(_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`param error, isAgree: type is boolean, value: ${s}`,i),{code:r.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`error code : ${r.NOT_IN_CALL}, session not exist`,i),{code:r.NOT_IN_CALL};const{code:l}=yield this._callEngine.responseChangeMediaType({transactionId:t,agree:s},i);return l!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`signal error: ${l}`,i),{code:l}):(this._logger.info(_.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"success",i),{code:r.SUCCESS})})}getCurrentCallSession(){return this._callEngine.getLocalMainSession()}getAvailableCallRecordsFromServer(){return i(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(_.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T,"",e);const{code:t,data:i}=yield this._callEngine.getOpenCallList(e);return t!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(_.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,`success, data: ${JSON.stringify(i)}`,e),{code:r.SUCCESS,records:i})})}getCallRecords(t,s,l=0){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T,`startTimestamp: ${t}, count: ${s}`,i),!(e.isNumber(t)&&t>=0))return this._logger.error(_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`params error, startTimestamp: is a number >= 0, value: ${t}`,i),{code:r.PARAM_ERROR};if(!(e.isNumber(s)&&s>0))return this._logger.error(_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`params error, count: is a number >= 0, value: ${s}`,i),{code:r.PARAM_ERROR};const{code:o,data:n}=yield this._callEngine.getCallLogList({timestamp:t,count:s,order:l},i);return o!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`signal error code: ${o}`,i),{code:o}):(this._logger.info(_.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"success",i),{code:r.SUCCESS,result:n})})}deleteCallRecordsFromServer(t){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T,`callIds: ${t.join(",")}`,i),!e.notEmptyArray(t)||!t.every(t=>e.notEmptyString(t)))return this._logger.error(_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,`params err, callIds: not empty array, callId: not empty string, callIds: ${JSON.stringify(t)}`,i),{code:r.PARAM_ERROR};const{code:s}=yield this._callEngine.deleteCallLog(t,i);return s!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,`signal error code: ${s}`,i),{code:s}):(this._logger.info(_.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"success",i),{code:r.SUCCESS})})}deleteAllCallRecordsFromServer(){return i(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(_.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T,"",e);const{code:t}=yield this._callEngine.removeAllCallLog(e);return t!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(_.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,"success",e),{code:r.SUCCESS})})}startCamera(){var e;return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();this._logger.info(_.L_CALLPLUS_CLIENT_START_CAMERA_T,"",i);const{code:s,track:l}=yield this._rtcModule.getCameraVideoTrack(i);if(s!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_START_CAMERA_R,`create video track error code: ${s}`,i),{code:s};if(!(null==l?void 0:l.isPublished())&&(null===(e=this._callEngine.getLocalMainSession())||void 0===e?void 0:e.getState())===exports.RCCallPlusCallState.ONCALL){const{code:e}=yield this._rtcModule.publishVideoTrack();return e!==t.RCRTCCode.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_START_CAMERA_R,`publish error code: ${e}`,i),{code:e}):(this._logger.info(_.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",i),{code:r.SUCCESS})}const{code:o}=yield this._rtcModule.enableVideoTrack(i);return o!==t.RCRTCCode.SUCCESS&&o!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_START_CAMERA_R,`signal error code: ${o}`,i),{code:o}):(this._logger.info(_.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",i),{code:r.SUCCESS})})}stopCamera(){return i(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(_.L_CALLPLUS_CLIENT_STOP_CAMERA_T,"",e);const{code:i,track:s}=yield this._rtcModule.disableVideoTrack();return i!==r.SUCCESS&&i!==t.RCRTCCode.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_STOP_CAMERA_R,`error code: ${i}`,e),{code:i}):(this._rtcModule.destroyTrack(s),this._logger.info(_.L_CALLPLUS_CLIENT_STOP_CAMERA_R,"success",e),{code:r.SUCCESS})})}switchCamera(t){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T,`cameraId: ${t}`,i),!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`param error, cameraId: not empty string, value: ${t}`,i),{code:r.PARAM_ERROR};const s=this._callEngine.getLocalMainSession();if(!s)return this._logger.error(_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`errCode: ${r.NOT_IN_CALL}`,i),{code:r.NOT_IN_CALL};if(s.getMediaType()===exports.RCCallPlusMediaType.AUDIO)return this._logger.error(_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`errCode: ${r.NOT_VIDEO_CALL}`,i),{code:r.NOT_VIDEO_CALL};this._videoConfig.cameraId=t,this._rtcModule.setVideoConfig(this._videoConfig);const{code:l}=yield this._rtcModule.changeVideoDevice(i);return l!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`call client changeVideoDevice error code: ${l}`,i),{code:l}):(this._logger.info(_.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"success",i),{code:r.SUCCESS})})}startMicrophone(){return i(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(_.L_CALLPLUS_CLIENT_START_MICROPHONE_T,"",e);const{code:i,track:s}=yield this._rtcModule.getMicrophoneAudioTrack(e);if(i!==r.SUCCESS)return this._logger.error(_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,`create microphone audio track error code: ${i}`,e),{code:i};if(!s.isOwnerMuted())return this._logger.info(_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),{code:r.SUCCESS};const l=yield s.unmute();return l!==t.RCRTCCode.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,`signal error code: ${i}`,e),{code:l}):(this._logger.info(_.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),{code:r.SUCCESS})})}stopMicrophone(){return i(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(_.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T,"",e);const{code:i}=yield this._rtcModule.disableAudioTrack();return i!==r.SUCCESS&&i!==t.RCRTCCode.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,`signal error code: ${i}`,e),{code:i}):(this._logger.info(_.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,"success",e),{code:r.SUCCESS})})}isMicrophoneEnabled(){const e=this._rtcModule.getLocalAudioTrack();return!!e&&!e.isOwnerMuted()}setAllRemoteAudioEnable(e){return i(this,void 0,void 0,function*(){const t=this._logger.createTraceId();return this._rtcModule.setAllRemoteAudioEnable(e,t)})}getVersion(){return"2.46.0"}getCameras(){return i(this,void 0,void 0,function*(){return t.device.getCameras()})}getMicrophones(){return i(this,void 0,void 0,function*(){return t.device.getMicrophones()})}getSpeakers(){return i(this,void 0,void 0,function*(){return t.device.getSpeakers()})}getRTCSessionId(){return this._rtcModule.getRTCSessionId()}switchMicrophone(t){return i(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T,`microphoneId: ${t}`,i),!e.notEmptyString(t))return this._logger.error(_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`param error, microphoneId: not empty string, value: ${t}`,i),{code:r.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`errCode: ${r.NOT_IN_CALL}`,i),{code:r.NOT_IN_CALL};this._audioConfig.microphoneId=t,this._rtcModule.setAudioConfig(this._audioConfig);const{code:s}=yield this._rtcModule.changeAudioDevice(i);return s!==r.SUCCESS?(this._logger.error(_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`call client changeAudioDevice error code: ${s}`,i),{code:s}):(this._logger.info(_.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"success",i),{code:r.SUCCESS})})}}e.VersionManage.add("callplus","2.46.0");const ne={tag:"RCCallPlus",verify:t=>!!e.VersionManage.validEngine("5.46.0")||(console.error(`The current engine version '${e.VersionManage.getInfo().engine}' error, plugin-call-plus required engine version at least '5.46.0'.`),!1),setup(t,i,s){const l=(o=s)?e.isObject(o)?Object.keys(o).includes("rtcClient")?e.isObject(o.rtcClient)?{isLegal:!0}:{isLegal:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:{isLegal:!1,code:r.NOT_INSTALL_RTC_PLUGIN}:{isLegal:!1,msg:"Initialization options must be an object"}:{isLegal:!1,msg:"Initialization missing parameter -> options"};var o;if(!l.isLegal)throw new Error(`[CallPlusLib installer steup]${l.msg}`);e.isUndefined(s.isAllowNewCallWhenRinging)&&(s.isAllowNewCallWhenRinging=!0);const n=t.createLogger("CallPlus","RTC"),a=e.isUndefined(s.logOutputLevel)?e.LogL.WARN:s.logOutputLevel;return n.setOutputLevel(a),n.warn(_.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O,`CallPlus Version: 2.46.0, Commit: 797b461e2e0627416c15f87383f9ed2bf4295c9d, isAllowNewCallWhenRinging: ${s.isAllowNewCallWhenRinging}`),new oe(t,n,i,s)}};Object.defineProperty(exports,"RCCallPlusFrameRate",{enumerable:!0,get:function(){return t.RCFrameRate}}),Object.defineProperty(exports,"RCCallPlusResolution",{enumerable:!0,get:function(){return t.RCResolution}}),exports.RCAudioConfigBuilder=d,exports.RCCallPlusAndroidPushConfigBuilder=le,exports.RCCallPlusClient=oe,exports.RCCallPlusCode=r,exports.RCCallPlusSession=L,exports.RCVideoConfigBuilder=E,exports.installer=ne;
|