@rongcloud/plugin-call-plus 2.30.0 → 2.32.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.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.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isNumber as e,isBoolean as t,isUndefined as r,isString as i,EventEmitter as n,ErrorCode as o,SentStatus as a,RCConnectionStatus as _,isNull as l,getUUID22 as s,getUUID as c,ConversationType as u,MessageDirection as L,ReceivedStatus as d,RTCMode as E,notEmptyArray as C,notEmptyString as T,isObject as I,VersionManage as g,LogL as S}from"@rongcloud/engine";import{RCFrameRate as f,RCResolution as p,RCRTCCode as h,RCKickReason as R,helper as b,RCLocalTrack as O,device as A}from"@rongcloud/plugin-rtc";export{RCFrameRate as RCCallPlusFrameRate,RCResolution as RCCallPlusResolution}from"@rongcloud/plugin-rtc";var N=function(e,t){return N=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},N(e,t)};function m(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}N(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var v=function(){return v=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},v.apply(this,arguments)};function y(e,t,r,i){return new(r||(r=Promise))(function(n,o){function a(e){try{l(i.next(e))}catch(e){o(e)}}function _(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,_)}l((i=i.apply(e,t||[])).next())})}function P(e,t){var r,i,n,o,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:_(0),throw:_(1),return:_(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function _(_){return function(l){return function(_){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,_[0]&&(a=0)),a;)try{if(r=1,i&&(n=2&_[0]?i.return:_[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,_[1])).done)return n;switch(i=0,n&&(_=[2&_[0],n.value]),_[0]){case 0:case 1:n=_;break;case 4:return a.label++,{value:_[1],done:!1};case 5:a.label++,i=_[1],_=[0];continue;case 7:_=a.ops.pop(),a.trys.pop();continue;default:if(!(n=a.trys,(n=n.length>0&&n[n.length-1])||6!==_[0]&&2!==_[0])){a=0;continue}if(3===_[0]&&(!n||_[1]>n[0]&&_[1]<n[3])){a.label=_[1];break}if(6===_[0]&&a.label<n[1]){a.label=n[1],n=_;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(_);break}n[2]&&a.ops.pop(),a.trys.pop();continue}_=t.call(e,a)}catch(e){_=[6,e],i=0}finally{r=n=0}if(5&_[0])throw _[1];return{value:_[0]?_[1]:void 0,done:!0}}([_,l])}}}function U(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return a}function M(e,t,r){if(r||2===arguments.length)for(var i,n=0,o=t.length;n<o;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var D,w={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};!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"}(D||(D={}));var j,G,V,H,k,B,x,F=function(){function e(e,t,r,i,n){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:r}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:n}),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()}return Object.defineProperty(e.prototype,"getCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callId}}),Object.defineProperty(e.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getSessionState()}}),Object.defineProperty(e.prototype,"getCallType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getCallType()}}),Object.defineProperty(e.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getMediaType()}}),Object.defineProperty(e.prototype,"getUserList",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;return this._session.getUserList().map(function(t){var r=t.userId,i=t.userState,n=null,o=null;return r===e._context.getCurrentId()?(n=e._rtcModule.getLocalVideoTrack(),o=e._rtcModule.getLocalAudioTrack()):(n=e._rtcModule.getRemoteTrack(r,V.VIDEO),o=e._rtcModule.getRemoteTrack(r,V.AUDIO)),{userId:r,state:i,cameraEnable:!!n&&!n.isOwnerMuted(),microphoneEnable:!!o&&!o.isOwnerMuted()}})}}),Object.defineProperty(e.prototype,"getCreatorUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getStartCallerId()}}),Object.defineProperty(e.prototype,"getInviterUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._session.getCallerId()}}),Object.defineProperty(e.prototype,"getCreateTimestamp",{enumerable:!1,configurable:!0,writable:!0,value:function(){return y(this,void 0,void 0,function(){var e,t,r,i;return P(this,function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_SESSION_GET_CREATE_TIME_T,"",e),this._startTime?[2,{code:w.SUCCESS,startTime:this._startTime}]:[4,this._callEngine.getCallStaringTime({callId:this._callId},e)];case 1:return t=n.sent(),r=t.code,i=t.clientStartTime,r!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,"errCode: ".concat(r),e),[2,{code:r}]):(this._logger.info(D.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,"success",e),this._startTime=i,[2,{code:w.SUCCESS,startTime:this._startTime}])}})})}}),Object.defineProperty(e.prototype,"getDuration",{enumerable:!1,configurable:!0,writable:!0,value:function(){return y(this,void 0,void 0,function(){var e,t,r,i;return P(this,function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_SESSION_GET_DURATION_T,"",e),this._duration?(this._logger.info(D.L_CALLPLUS_SESSION_GET_DURATION_R,"code: ".concat(w.SUCCESS,", duration: ").concat(this._duration),e),[2,{code:w.SUCCESS,duration:this._duration}]):[4,this._callEngine.getCallTimeInfo(this._callId,e)];case 1:return t=n.sent(),r=t.code,i=t.data,r!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_SESSION_GET_DURATION_R,"code: ".concat(r),e),[2,{code:r}]):(this._logger.info(D.L_CALLPLUS_SESSION_GET_DURATION_R,"code: ".concat(w.SUCCESS,", duration: ").concat(i.duration),e),this._duration=i.duration,[2,{code:w.SUCCESS,duration:this._duration}])}})})}}),e}();!function(e){e[e.SINGLE=0]="SINGLE",e[e.MULTI=1]="MULTI"}(j||(j={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ONPHONE=301]="ONPHONE",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(G||(G={})),function(e){e[e.AUDIO=0]="AUDIO",e[e.AUDIO_VIDEO=1]="AUDIO_VIDEO",e[e.VIDEO=2]="VIDEO"}(V||(V={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ENDED=1e3]="ENDED",e[e.NOANSWER=1001]="NOANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELED=1003]="CANCELED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(H||(H={})),function(e){e[e.CANCEL_CHANGE_MEDIA_TYPE=0]="CANCEL_CHANGE_MEDIA_TYPE",e[e.REFUSE_CHANGE_MEDIA_TYPE=1]="REFUSE_CHANGE_MEDIA_TYPE",e[e.SERVER_ALLOW_MEDIA_TYPE=2]="SERVER_ALLOW_MEDIA_TYPE",e[e.CHANGE_MEDIA_TYPE_TIMEOUT=3]="CHANGE_MEDIA_TYPE_TIMEOUT"}(k||(k={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ON_PHONE=301]="ON_PHONE",e[e.ON_PHONE_END=302]="ON_PHONE_END",e[e.ON_DEVICE_DISABLE=303]="ON_DEVICE_DISABLE",e[e.ON_DEVICE_ENABLE=304]="ON_DEVICE_ENABLE",e[e.ABNORMAL_END=999]="ABNORMAL_END",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.OTHER_CLIENT_CALLING=1010]="OTHER_CLIENT_CALLING",e[e.OTHER_CLIENT_ACCEPT=1011]="OTHER_CLIENT_ACCEPT",e[e.JOIN_ROOM_ERR=1105]="JOIN_ROOM_ERR",e[e.PUBLISH_ERR=1106]="PUBLISH_ERR",e[e.SUBSCRIBE_ERR=1107]="SUBSCRIBE_ERR",e[e.ACCEPT_CARRIER=1108]="ACCEPT_CARRIER",e[e.KICKED_BY_SERVER=1109]="KICKED_BY_SERVER",e[e.CONNECTION_ERR=1110]="CONNECTION_ERR",e[e.LOGOUT=1111]="LOGOUT",e[e.OTHER_CLIENT_LOGIN=1112]="OTHER_CLIENT_LOGIN",e[e.OTHER_CLIENT_JOINED=1113]="OTHER_CLIENT_JOINED",e[e.OTHER_CLIENT_IN_ROOM=1114]="OTHER_CLIENT_IN_ROOM",e[e.OTHER_CLIENT_HANGUP=1151]="OTHER_CLIENT_HANGUP",e[e.REMOTE_JOIN_RTC_ERROR=1205]="REMOTE_JOIN_RTC_ERROR",e[e.REMOTE_PUBLISH_ERROR=1206]="REMOTE_PUBLISH_ERROR",e[e.REMOTE_SUBSCRIBE_ERROR=1207]="REMOTE_SUBSCRIBE_ERROR",e[e.REMOTE_KICKED_BY_SERVER=1209]="REMOTE_KICKED_BY_SERVER",e[e.REMOTE_CONNECTION_ERROR=1210]="REMOTE_CONNECTION_ERROR",e[e.REMOTE_LOGOUT=1211]="REMOTE_LOGOUT",e[e.REMOTE_OTHER_CLIENT_LOGIN=1212]="REMOTE_OTHER_CLIENT_LOGIN",e[e.REMOTE_OTHER_JOINED_RTC=1213]="REMOTE_OTHER_JOINED_RTC",e[e.REMOTE_OTHER_CLIENT_IN_RTC=1214]="REMOTE_OTHER_CLIENT_IN_RTC"}(B||(B={})),function(e){e[e.START=1]="START",e[e.END=2]="END"}(x||(x={}));var Y,J=function(){function t(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}return Object.defineProperty(t.prototype,"setDefaultMicrophoneId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._audioConfig.microphoneId=e,this}}),Object.defineProperty(t.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return!e(t)||!e(r)||r<=0||t<=0||r<t?(this._logger.error(D.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O,"params error -> max: ".concat(r,",min: ").concat(t,", max and min is a number > 0, max should > min")),this):(this._audioConfig.minBitrate=t,this._audioConfig.maxBitrate=r,this)}}),Object.defineProperty(t.prototype,"setSampleRate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e(t)?(this._audioConfig.sampleRate=t,this):(this._logger.error(D.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O,"params error -> sampleRate: ".concat(t)),this)}}),Object.defineProperty(t.prototype,"build",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._audioConfig}}),t}(),W=function(){function t(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:p.W640_H480,frameRate:f.FPS_15}})}return Object.defineProperty(t.prototype,"setFrameRate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f[e]?(this._videoConfig.frameRate=e,this):(this._logger.error(D.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O,"params error -> fps: ".concat(e)),this)}}),Object.defineProperty(t.prototype,"setVideoResolution",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return p[e]?(this._videoConfig.resolution=e,this):(this._logger.error(D.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O,"params error -> resolution: ".concat(e)),this)}}),Object.defineProperty(t.prototype,"setDefaultCameraId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._videoConfig.cameraId=e,this}}),Object.defineProperty(t.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return!e(t)||!e(r)||r<=0||t<=0||r<t?(this._logger.error(D.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O,"params error -> max: ".concat(r,",min: ").concat(t,", max and min is a number > 0, max should > min")),this):(this._videoConfig.minBitrate=t,this._videoConfig.maxBitrate=r,this)}}),Object.defineProperty(t.prototype,"build",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._videoConfig}}),t}(),K=function(e){return{callId:e.callId,callType:e.callType,callDirection:e.callDir,mediaType:e.mediaType,callerUserId:e.callingUserId,callUserIds:e.callUserIds,sessionState:e.callStatus,userState:e.sessionStatus,startTimestamp:e.startTime,endTimestamp:e.endTime,duration:e.duration,syncTimestamp:e.syncTime,systemState:e.sysStatus,createTimestamp:e.crtTime}},Q=function(e){return e&&e.nodeName&&"VIDEO"===e.nodeName.toUpperCase()},q=function(e){var t=e.voipCallInfo;return!!t&&1===JSON.parse(t).strategy},X=function(t,r){return!t&&0!==t||e(t)&&!(t<=0)?!r&&0!==r||e(r)&&!(r<=0)?t&&r&&r<t?{code:w.PARAM_ERROR,errorMsg:"params error -> maxBitrate: ".concat(r,", minBitrate: ").concat(t,", maxBitrate should > minBitrate")}:{code:w.SUCCESS}:{code:w.PARAM_ERROR,errorMsg:"params error -> maxBitrate: a number of > 0, value: ".concat(r)}:{code:w.PARAM_ERROR,errorMsg:"params error -> minBitrate: a number of > 0, value: ".concat(t)}},z=function(e){var t=[];for(var r in e){var i=e[r],n=i.videoView,o=i.isTiny;t.push({userId:r,videoView:n.nodeName,isTiny:o})}return t},Z=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r={});var i=t.threadId,n=t.apnsCollapseId,o=t.richMediaUri,a=r.channelIdMi,_=r.channelIdHW,l=r.channelIdOPPO,s=r.typeVivo,c=r.fcmChannelId,u=r.fcmCollapseKey,L=r.fcmImageUrl,d=r.importanceHW,E=r.categoryHW,C=r.imageUrlHW,T=r.categoryVivo,I=r.importanceHonor,g=r.imageUrlHonor,S={};i&&(S["thread-id"]=i),S["apns-collapse-id"]=n||e,o&&(S.richMediaUri=o);var f={};_&&(f.channelId=_),C&&(f.image=C),E&&(f.category=E),f.importance=d||"NORMAL";var p,h,R,b,O=[{HW:f},{APNS:S}];return(u||L||c)&&(p={},u&&(p.collapse_key=u),L&&(p.imageUrl=L),c&&(p.channelId=c),O[0].FCM=p),a&&(O[0].MI={channelId:a}),l&&((h={}).channelId=l,O[0].OPPO=h),(s||T)&&(R={},s&&(R.classification=s),T&&(R.category=T),O[0].VIVO=R),(I||g)&&(b={},I&&(b.importance=I),g&&(b.image=g),O[0].HONOR=b),JSON.stringify(O)},$=function(e,r){var i=e.pushTitle,n=void 0===i?"":i,o=e.iOSConfig,a=e.androidConfig,_=e.disablePushTitle,l=e.templateId,s={pushConfigs:Z(r,o,a)};return t(_)&&(s.disableTitle=_),n&&(s.title=n),l&&(s.templateId=l),JSON.stringify(s)},ee=function(e){var n=["pushTitle","pushContent","iOSConfig","androidConfig","disablePushTitle","templateId"],o=Object.keys(e).every(function(e){return n.includes(e)});if(!o)return{code:w.PARAM_ERROR,errorMsg:"right key: ".concat(n.join(","))};for(var a=0;a<n.length;a++){var _=n[a];if("disablePushTitle"===_){if(!r(e[_])&&!t(e[_]))return{code:w.PARAM_ERROR,errorMsg:"".concat(_," type is boolean")}}else if(("pushTitle"===_||"templateId"===_||"pushContent"===_)&&e[_]&&!i(e[_]))return{code:w.PARAM_ERROR,errorMsg:"".concat(_," type is string")}}var l=e.iOSConfig,s=e.androidConfig,c=te(l||{});if(c.code!==w.SUCCESS)return c;var u=re(s||{});return u.code!==w.SUCCESS?u:{code:w.SUCCESS}},te=function(e){var t=e||{},r=t.threadId,n=t.richMediaUri;return r&&!i(r)?{code:w.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:n&&!i(n)?{code:w.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:w.SUCCESS}},re=function(e){var t=["channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"],r=Object.keys(e).every(function(e){return t.includes(e)});if(!r)return{code:w.PARAM_ERROR,errorMsg:"right key: ".concat(t.join(","))};for(var n=0;n<t.length;n++){var o=t[n];if("importanceHW"===o||"importanceHonor"===o){if(e[o]&&"LOW"!==e[o]&&"NORMAL"!==e[o])return{code:w.PARAM_ERROR,errorMsg:"androidConfig.".concat(o," value is NORMAL|LOW")}}else if(e[o]&&!i(e[o]))return{code:w.PARAM_ERROR,errorMsg:"androidConfig.".concat(o," type is string")}}return{code:w.SUCCESS}},ie=function(e,t){void 0===t&&(t="utf-8");return"utf-16"===t?ne(e):oe(e)},ne=function(e){for(var t=0,r=0,i=e.length;r<i;r++)t+=e.charCodeAt(r)<=65535?2:4;return t},oe=function(e){for(var t,r=0,i=0,n=e.length;i<n;i++)r+=(t=e.charCodeAt(i))<127?1:t<=2047?2:t<=65535?3:4;return r},ae=/Electron/.test(navigator.userAgent);!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"}(Y||(Y={}));var _e,le,se,ce,ue=function(){function e(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})}return Object.defineProperty(e.prototype,"reportStatisticsData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n,o,a){var _=+new Date,l=i?{mediaType:i.getMediaType(),callType:i.getCallType(),callId:i.getCallId()}:a,s={cr:"unknown",net:"unknown",cod:t,mtp:l.mediaType,ctp:l.callType,cid:l.callId,time:_,uid:this._context.getCurrentId()};n&&Object.assign(s,{ccid:n});var c=null;switch(e){case Y.L_QS_RECEIVE_CALL_S:c=v(v({},s),{rf:o});break;case Y.L_QS_ABNORMAL_HANGUP_S:c=v({},s);break;default:c=v(v({},s),{dur:_-r})}this._logger.__statistics(e,JSON.stringify(c))}}),e}();!function(e){e.REQUEST="request",e.ACCEPT="accept",e.REFUSE="refuse",e.CANCEL="cancel",e.NOTICE="notice",e.TIMEOUT="timeout"}(_e||(_e={})),function(e){e[e.SWITCH_MEDIA_TYPE=1]="SWITCH_MEDIA_TYPE"}(le||(le={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.SECRET=1]="SECRET"}(se||(se={})),function(e){e.INVITER="inviter",e.INVITEE="invitee"}(ce||(ce={}));var Le,de=function(e){function t(t,r,i,n,o,a,_,l){var s=e.call(this)||this;return Object.defineProperty(s,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(s,"_state",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"_callType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(s,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(s,"_startCallerId",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(s,"_callerId",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(s,"_callUsers",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(s,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(s,"_reqMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"_inviterTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"_inviteeTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"_oldDialogData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"isLocalClientHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1}),s}return m(t,e),Object.defineProperty(t.prototype,"getCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callId}}),Object.defineProperty(t.prototype,"getSessionState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._state}}),Object.defineProperty(t.prototype,"getCallType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callType}}),Object.defineProperty(t.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._mediaType}}),Object.defineProperty(t.prototype,"getStartCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._startCallerId}}),Object.defineProperty(t.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callerId}}),Object.defineProperty(t.prototype,"getUserList",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callUsers}}),Object.defineProperty(t.prototype,"getReqMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._reqMediaType}}),Object.defineProperty(t.prototype,"getInviterTimerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._inviterTimerId}}),Object.defineProperty(t.prototype,"getInviteeTimerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._inviteeTimerId}}),Object.defineProperty(t.prototype,"getAllTimerIds",{enumerable:!1,configurable:!0,writable:!0,value:function(){return[this._inviterTimerId,this._inviteeTimerId]}}),Object.defineProperty(t.prototype,"updateUserList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,i=[];return e.forEach(function(e){var t=e.userState,n=e.stateTime,o=e.systemState,a=e.userId,_=r._callUsers.findIndex(function(e){return e.userId===a});if(_<0)return r._callUsers.push(e),void i.push(e);var l,s,c,u,L=r._callUsers[_],d=L.stateTime,E=L.systemState,C=L.userState,T=(l=E,s=o,c=!1,u=[B.INVITED,B.RINGING,B.BUSYLINE_RINGING,B.BUSYLINE_WAIT,B.CONNECTING,B.ONCALL],l===B.ONCALL&&u.includes(s)&&(c=!0),c),I=function(e,t){var r=!1,i=[G.INVITED,G.RINGING,G.BUSYLINE_RINGING,G.BUSYLINE_WAIT,G.CONNECTING,G.ONCALL];return e===G.ONCALL&&i.includes(t)&&(r=!0),r}(C,t),g=o===B.ON_PHONE_END&&E!==B.ON_PHONE&&t!==G.IDLE;n&&d&&n<d||T&&I||(r._callUsers[_]=e,!g&&i.push(e))}),i}}),Object.defineProperty(t.prototype,"setOldDialogData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._oldDialogData=e}}),Object.defineProperty(t.prototype,"updateSessionState",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._state=e}}),Object.defineProperty(t.prototype,"updateCallType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._callType=e}}),Object.defineProperty(t.prototype,"updateMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._mediaType=e}}),Object.defineProperty(t.prototype,"updateReqMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._reqMediaType=e}}),Object.defineProperty(t.prototype,"updateTimerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e===ce.INVITER?this._inviterTimerId=t:this._inviteeTimerId=t}}),Object.defineProperty(t.prototype,"getOldDialogData",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._oldDialogData}}),Object.defineProperty(t.prototype,"setIsLocalClientHangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.isLocalClientHangup=e}}),Object.defineProperty(t.prototype,"getIsLocalClientHangup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.isLocalClientHangup}}),t}(n);!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"}(Le||(Le={}));var Ee,Ce,Te,Ie=function(e,t){return setTimeout(e,t)},ge=[o.RC_NET_CHANNEL_INVALID,o.RC_NET_UNAVAILABLE,o.RC_MSG_RESP_TIMEOUT,h.SIGNAL_DISCONNECTED,h.REQUEST_FAILED],Se=function(e){var t=e.asyncFn,r=e.fnArgs,i=e.currentRetryTime,n=void 0===i?Date.now():i,o=e.maxDuration,a=void 0===o?6e4:o,_=e.intervals,l=void 0===_?[2e3,4e3,8e3,16e3,32e3,64e3]:_,s=e.index,c=void 0===s?0:s,u=e.onError;return y(void 0,void 0,void 0,function(){var e;return P(this,function(i){switch(i.label){case 0:return[4,t.apply(void 0,M([],U(r),!1))];case 1:return e=i.sent(),e.code===w.SUCCESS||!ge.includes(e.code)||Date.now()+2e3-n>a?[3,3]:(u&&u(e.code),[4,(o=2e3,new Promise(function(e){setTimeout(e,o)}))]);case 2:return i.sent(),[2,Se({asyncFn:t,fnArgs:r,currentRetryTime:n,maxDuration:a,intervals:l,index:c,onError:u})];case 3:return[2,e]}var o})})};!function(e){e.onBeforePublish="onBeforePublish",e.onPublishRes="onPublishRes",e.onPubInviteCall="onPubInviteCall",e.onPubInviteCallPullKv="onPubInviteCallPullKv",e.onPubInviteCallMiss="onPubInviteCallMiss"}(Ee||(Ee={})),function(e){e.NOT_CURRENT_DEVICEID="not current device id",e.SECRET_CALL="secret call",e.NOT_INVITEE="not an invitee"}(Ce||(Ce={})),function(e){e.PUB_INVITE="pubinvitecall",e.PULL_KV_INVITE="pullkv_invitecall",e.PUSH="system_pubsh"}(Te||(Te={}));var fe,pe,he=131072,Re="RC:CallPlusMiss",be="RC:CallGroupStatusMsg",Oe=function(e){function t(t,r,i,n,o,a){var _=e.call(this)||this;return Object.defineProperty(_,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(_,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(_,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(_,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(_,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(_,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(_,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_needRetryActions",{enumerable:!0,configurable:!0,writable:!0,value:[Le.START_SINGLE_CALL,Le.START_GROUP_CALL,Le.ACCEPT_CALL,Le.JOIN_CALL,Le.EVENT_UP_CALL]}),Object.defineProperty(_,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:""}),_._context.onCallInfo=_._onRecvCallSignal.bind(_),_._context.onconnectionstatechange=_._onIMConnectionStateChange.bind(_),_._context.onmessage=_._onMessage.bind(_),_._sessionId=s(),_}return m(t,e),Object.defineProperty(t.prototype,"_onMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!![Re,be].includes(e.messageType)&&(e.messageType===Re?this._dealMissMessage(e):this._dealGroupCallMessage(e),!0)}}),Object.defineProperty(t.prototype,"_dealMissMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.content,r=t.callId,i=t.mediaType,n=t.startTime,o=t.callSessionUsers,_=e.targetId,l=e.senderUserId,s=this._context.getCurrentId();if(!localStorage.getItem("missMessageMap-".concat(s,"-").concat(r))){var c={callId:r,callerUserId:l,targetId:_,mediaType:i,firstFrameTime:0,callStartTime:n-this._timeCorrectioner.getLocalDelayTime(),callEndTime:0,hangupReason:o.filter(function(e){return e.userId===s})[0].sessionStatus};this._logger.info(D.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O,"receive miss message: ".concat(JSON.stringify(e)));var u=Object.assign(e,{content:c,sentStatus:a.SENT});this._reportAppEventModule.onReceivedCallPlusSummaryMessage(u),localStorage.setItem("missMessageMap-".concat(s,"-").concat(r),r)}}}),Object.defineProperty(t.prototype,"_dealGroupCallMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._reportAppEventModule.onReceivedGroupCallStatusMessage(e)}}),Object.defineProperty(t.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._sessionId}}),Object.defineProperty(t.prototype,"getDeviceId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return ae?this._context.getDeviceId():this._sessionId}}),Object.defineProperty(t.prototype,"registerListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._listener=e}}),Object.defineProperty(t.prototype,"startCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i,n,o,a,_,l,s,c,u,L,d;return P(this,function(E){return r=e.clientCallId,i=e.callType,n=e.toUsers,o=e.mediaType,a=e.secretChat,_=e.targetType,l=e.targetId,s=e.nickName,c=e.oldRoomId,u=e.pushExt,L=e.pushContent,d=e.extra,i===j.SINGLE?[2,this.startSingleCall({clientCallId:r,toUserId:n[0].userId,mediaType:o,secretChat:a,targetType:_,targetId:l,oldRoomId:c,toOrgId:n[0].orgId||"",pushExt:u,pushContent:L,extra:d},t)]:[2,this.startGroupCall({clientCallId:r,toUsers:n,mediaType:o,targetType:_,targetId:l,nickName:s,oldRoomId:c,pushExt:u,pushContent:L,extra:d},t)]})})}}),Object.defineProperty(t.prototype,"startSingleCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return this._logger.info(D.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(this._context.getCurrentId(),Le.START_SINGLE_CALL,e)]})})}}),Object.defineProperty(t.prototype,"startGroupCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return this._logger.info(D.L_SIGNAL_TRANSPORTER_GROUP_CALL_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(this._context.getCurrentId(),Le.START_GROUP_CALL,e)]})})}}),Object.defineProperty(t.prototype,"inviteCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return this._logger.info(D.L_SIGNAL_TRANSPORTER_INVITE_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,Le.INVITE_CALL,e)]})})}}),Object.defineProperty(t.prototype,"ringingCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return this._logger.info(D.L_SIGNAL_TRANSPORTER_RING_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,Le.RINGING_CALL,e)]})})}}),Object.defineProperty(t.prototype,"acceptCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return this._logger.info(D.L_SIGNAL_TRANSPORTER_ACCEPT_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,Le.ACCEPT_CALL,e)]})})}}),Object.defineProperty(t.prototype,"joinCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return this._logger.info(D.L_SIGNAL_TRANSPORTER_JOIN_CALL_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,Le.JOIN_CALL,e)]})})}}),Object.defineProperty(t.prototype,"hangupCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r;return P(this,function(i){switch(i.label){case 0:return this._logger.info(D.L_SIGNAL_TRANSPORTER_HANGUP_T,"params: ".concat(JSON.stringify(e)),t),[4,this._sendCallSignal(e.callId,Le.HANGUP_CALL,e)];case 1:return(r=i.sent().code)===w.NOT_IN_CALL?[2,{code:w.SUCCESS}]:[2,{code:r}]}})})}}),Object.defineProperty(t.prototype,"statusUpCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return this._logger.info(D.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T,"call status up params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,Le.STATUS_UP_CALL,e)]})})}}),Object.defineProperty(t.prototype,"eventUpCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return this._logger.info(D.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,Le.EVENT_UP_CALL,e)]})})}}),Object.defineProperty(t.prototype,"dialogUpCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return this._logger.info(D.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,Le.DIALOG_UP_CALL,e)]})})}}),Object.defineProperty(t.prototype,"deleteCallRecord",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return y(this,void 0,void 0,function(){return P(this,function(i){return this._logger.info(D.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T,"callIds: ".concat(JSON.stringify(t)),r),[2,this._sendCallSignal(e,Le.DEL_CALL_LOG,{callIds:t})]})})}}),Object.defineProperty(t.prototype,"syncCallLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return this._logger.info(D.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T,"params: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.userId,Le.SYNC_CALL_LOG,e)]})})}}),Object.defineProperty(t.prototype,"queryUserHasCall",{enumerable:!1,configurable:!0,writable:!0,value:function(){return y(this,void 0,void 0,function(){var e;return P(this,function(t){return e=this._context.getCurrentId(),[2,this._sendCallSignal(e,Le.QRY_CALL_STATE,null)]})})}}),Object.defineProperty(t.prototype,"getCallServerTimestamp",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t;return P(this,function(r){return t=this._context.getCurrentId(),this._logger.info(D.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T,"userId: ".concat(t),e),[2,this._sendCallSignal(t,Le.QRY_SRV_TIMESTAMP,null)]})})}}),Object.defineProperty(t.prototype,"getCallTimeInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return this._logger.info(D.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T,"callId: ".concat(e),t),[2,this._sendCallSignal(e,Le.GET_CALL_TIME_INFO,{callId:e})]})})}}),Object.defineProperty(t.prototype,"getUserCallStateList",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t;return P(this,function(r){return t=this._context.getCurrentId(),this._logger.info(D.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T,"userId: ".concat(t),e),[2,this._sendCallSignal(t,Le.GET_CALL_STATE_LIST,null)]})})}}),Object.defineProperty(t.prototype,"clearCallRecord",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t;return P(this,function(r){return t=this._context.getCurrentId(),this._logger.info(D.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T,"userId: ".concat(t),e),[2,this._sendCallSignal(t,Le.CLEAR_CALL_LOG,null)]})})}}),Object.defineProperty(t.prototype,"getCallSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return this._logger.info(D.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T,"callId: ".concat(e.callId),t),[2,this._sendCallSignal(e.callId,Le.GET_CALL_SESSION,e)]})})}}),Object.defineProperty(t.prototype,"sysStatusUp",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return this._logger.info(D.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T,"opts: ".concat(JSON.stringify(e)),t),[2,this._sendCallSignal(e.callId,Le.SYS_STATUS_UP,e)]})})}}),Object.defineProperty(t.prototype,"upCallLogReaded",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t;return P(this,function(r){return t=this._context.getCurrentId(),[2,this._sendCallSignal(t,Le.UP_CALL_LOG_READED,e)]})})}}),Object.defineProperty(t.prototype,"endUserAbnormalCalls",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){return P(this,function(t){return[2,this._sendCallSignal(this._context.getCurrentId(),Le.END_ABNORMAL_CALL,e)]})})}}),Object.defineProperty(t.prototype,"_onIMConnectionStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._logger.createTraceId();this._logger.info(D.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O,"state: ".concat(e),t),this._listener.onIMStateChange(e),e===_.CONNECTED?this._timeCorrectioner.start(t):this._timeCorrectioner.stop(t)}}),Object.defineProperty(t.prototype,"_sendCallSignal",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return y(this,void 0,void 0,function(){var i,n,a,_,l,s;return P(this,function(c){switch(c.label){case 0:return i="",r&&(i=ae?JSON.stringify(r):JSON.stringify(v(v({},r),{sessionId:this._sessionId}))),this._needRetryActions.includes(t)?[4,Se({asyncFn:this._context.setCallInfo.bind(this._context),fnArgs:[e,t,i]})]:[3,2];case 1:return n=c.sent(),[3,4];case 2:return[4,this._context.setCallInfo(e,t,i)];case 3:n=c.sent(),c.label=4;case 4:return a=n.code,_=n.data,a!==o.SUCCESS?[2,{code:a}]:(l=_.value,s=JSON.parse(l).data,[2,{code:w.SUCCESS,data:s}])}})})}}),Object.defineProperty(t.prototype,"_onRecvCallSignal",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=this._logger.createTraceId();this._logger.info(D.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O,"data: ".concat(e),r),JSON.parse(e).list.forEach(function(e){var i=e.key,n=JSON.parse(e.value);switch(i){case Le.PUB_INVITE_CALL:t._onPubInviteCall(n,r,!0);break;case Le.STATUS_DOWN_CALL:t._onStatusDownCall(n,r);break;case Le.EVENT_DOWN_CALL:t._onEventDownCall(n,r);break;case Le.DIALOG_DOWN_CALL:t._onDialogDownCall(n,r);break;case Le.PUB_CALL_LOG:t._onPubCallLog(n,r);break;case Le.PUB_CALL_LOG_READED:case Le.PUB_NACK_SEQ_ID:break;default:t._onConpensationData(n,r)}})}}),Object.defineProperty(t.prototype,"isValidData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(l(e))return!0;var t=e===this.getDeviceId();return!(!i(e)||0!==(null==e?void 0:e.length)&&!t)}}),Object.defineProperty(t.prototype,"_onPubInviteCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){void 0===r&&(r=!0);try{var i=this._context.getCurrentId(),n=e.callSessionUsers.find(function(e){return e.userId===i}),o=this._context.getConnectionStatus();this._logger.info(D.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,"currentUser: ".concat(JSON.stringify(n),", currentUserId: ").concat(i,", state: ").concat(o),t)}catch(e){this._logger.error(D.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,"error: ".concat(e.message),t)}if(this.isValidData(e.toDeviceId||""))this._listener.onInvite(e,r,t),r?this.emit(Ee.onPubInviteCall,Object.assign(e,{extra:JSON.stringify(e)})):this.emit(Ee.onPubInviteCallPullKv,Object.assign(e,{extra:JSON.stringify(e)}));else{this._logger.warn(D.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,"not current deviceId -> deviceInfo: ".concat(JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this._sessionId})),t);var a={extra:JSON.stringify(e),reason:Ce.NOT_CURRENT_DEVICEID,refer:r?Te.PUB_INVITE:Te.PULL_KV_INVITE};this.emit(Ee.onPubInviteCallMiss,Object.assign(e,a))}}}),Object.defineProperty(t.prototype,"_onStatusDownCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(e.callSessionUsers=e.callSessionUsers.filter(function(e){return Boolean(e.changed)}),this._logger.info(D.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,"",t),!this.isValidData(e.toDeviceId||""))return this._logger.warn(D.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,"not current deviceId -> deviceInfo: ".concat(JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this._sessionId})),t),void this._listener.onOtherClientStatusDown(e,t);this._listener.onStatusDown(e,t,this._sessionId)}}),Object.defineProperty(t.prototype,"_onEventDownCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._listener.onEventDown(e,t)}}),Object.defineProperty(t.prototype,"_onDialogDownCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.dialogType===le.SWITCH_MEDIA_TYPE&&this._listener.onSwitchMediaType(e,t)}}),Object.defineProperty(t.prototype,"_onPubCallLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(D.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O,"call record: ".concat(JSON.stringify(e)),t),this._listener.onRecvCallEndLog(e,t)}}),Object.defineProperty(t.prototype,"_onConpensationData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;this._logger.info(D.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O,"",t);var i=e.callId,n=e.callType,o=e.mediaType,a=e.secretChat,_=e.duration,l=e.callStatus,s=e.callingUserId,c=e.callSessionUsers,u=e.toDeviceId,L=e.callDialogEntitys,d=e.extra;c.some(function(e){return e.sessionStatus===G.INVITED&&e.userId===r._context.getCurrentId()})?this._onPubInviteCall({callId:i,toDeviceId:u,callType:n,mediaType:o,inviteUserId:s,callingUserId:s,callSessionUsers:c,secretChat:a,extra:d},t,!0):this._onStatusDownCall({callId:i,toDeviceId:u,callStatus:l,duration:_,callSessionUsers:c},t),L.length>0&&L.forEach(function(e){return r._onDialogDownCall(e,t)},this)}}),t}(n),Ae=function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});return e="".concat(e.replace(/-/g,""),"0"),(e=function(e){var t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),r=t.length+1,i=+e,n=[];do{var o=i%r;i=(i-o)/r,n.unshift(t[o])}while(i);return n.join("")}(e=parseInt(e,16))).length>22&&(e=e.slice(0,22)),e},Ne=function(){function e(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}return Object.defineProperty(e.prototype,"addAbnormallCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){try{var i=JSON.parse(this._localStore.getItem(e._STORAGE_KEY)||"{}"),n=i[t];n?n.push(r):n=[r],i[t]=n,this._localStore.setItem(e._STORAGE_KEY,JSON.stringify(i))}catch(e){this._logger.error(D.L_ABNORMAL_ADD_CALL_ID_E,e.message),console.error(e)}}}),Object.defineProperty(e.prototype,"removeAbnormalCallIds",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){try{var i=JSON.parse(this._localStore.getItem(e._STORAGE_KEY)||"{}"),n=i[t];n&&((n=n.filter(function(e){return!r.includes(e)})).length>0?i[t]=n:delete i[t],this._localStore.setItem(e._STORAGE_KEY,JSON.stringify(i)))}catch(e){this._logger.error(D.L_ABNORMAL_REMOVE_CALL_IDS_E,e.message),console.error(e)}}}),Object.defineProperty(e.prototype,"getAbnormalCallIds",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=null;try{var i=JSON.parse(this._localStore.getItem(e._STORAGE_KEY)||"{}")[t];i&&(r=i)}catch(e){this._logger.error(D.L_ABNORMAL_GET_CALL_IDS_E,e.message),console.error(e)}return Promise.resolve(r)}}),Object.defineProperty(e,"_STORAGE_KEY",{enumerable:!0,configurable:!0,writable:!0,value:"CallPlus_AbnormalCall"}),e}();!function(e){e[e.PROMPT=0]="PROMPT",e[e.CALL_DURATION=10]="CALL_DURATION",e[e.FIRST_FRAME=20]="FIRST_FRAME"}(fe||(fe={})),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"}(pe||(pe={}));var me,ve,ye,Pe=function(){function e(e,t,r){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:r}),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})}return Object.defineProperty(e.prototype,"getCallClientTimeByServer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i,n,o,a,_,l;return P(this,function(s){switch(s.label){case 0:return this._logger.info(D.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T,"callId: ".concat(e),t),!this._RTT||this._RTT>this._validMinRTT?[4,this._getDeltaTime(t)]:[3,2];case 1:s.sent(),s.label=2;case 2:return this._RTT>this._validMaxRTT&&this._logger.error(D.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,"code: ".concat(pe.INVALID_RESPONSE_TIME),t),[4,this._callEngine.getCallTimeInfo(e,t)];case 3:return r=s.sent(),i=r.code,n=r.data,i!==w.SUCCESS?(this._logger.error(D.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,"code: ".concat(i),t),[2,{code:i}]):(o=n.startTime,a=Math.floor(o-this._deltaTime),_=Date.now(),(l=(_+this._deltaTime-o)/1e3)<0&&(this._logger.warn(D.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P,"invalid duration: ".concat(l),t),l=0),l=Math.floor(l),this._RTT>this._validMinRTT&&this._RTT<=this._validMaxRTT&&this._logger.error(D.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,"code: ".concat(pe.NONOPTIMAL_RES_TIME),t),this._logger.info(D.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,serverStartTime:o,clientStartTime:a,duration:l}),t),[2,{code:i,duration:l,clientStartTime:o?a:o}])}})})}}),Object.defineProperty(e.prototype,"calcClientStartTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){if(this._logger.info(D.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T,"callId: ".concat(e,", startTime: ").concat(t),r),this._RTT>this._validMaxRTT)return this._logger.error(D.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,"code: ".concat(pe.INVALID_RESPONSE_TIME),r),this._loopCorrectClientTime(e,r),{code:pe.INVALID_RESPONSE_TIME};var i=Math.floor(t-this._deltaTime);return this._logger.info(D.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,startT:t,clientStartTime:i}),r),this._RTT>this._validMinRTT&&(this._retryTimesInCall=0,this._loopCorrectClientTime(e,r)),{code:pe.SUCCESS,clientStartTime:i}}}),Object.defineProperty(e.prototype,"start",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this._timerId||this._startTimes>=this._maxRetryTimes||(this._logger.info(D.L_TIME_CORRECT_START_O,"timerId: ".concat(this._timerId)),this._startTimes++,this._getDeltaTime(e),this._timerId=Ie(function(){t._timerId=null,t.start(e)},this._interval))}}),Object.defineProperty(e.prototype,"stop",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(D.L_TIME_CORRECT_STOP_O,"timerId: ".concat(this._timerId),e),this._timerId&&clearTimeout(this._timerId),this._timerId=null,this._startTimes=0}}),Object.defineProperty(e.prototype,"restart",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(D.L_TIME_CORRECT_RESTART_O,"legal rtt time, RTT: ".concat(this._RTT,", validMinRTT: ").concat(this._validMinRTT),e),this._RTT<this._validMinRTT||(this.stop(e),this.start(e))}}),Object.defineProperty(e.prototype,"getLocalDelayTime",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Math.round(this._deltaTime)}}),Object.defineProperty(e.prototype,"getRTT",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._RTT}}),Object.defineProperty(e.prototype,"_getDeltaTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r,i,n,o,a;return P(this,function(_){switch(_.label){case 0:return t=Date.now(),[4,this._callEngine.getCallServerTimestamp(e)];case 1:return r=_.sent(),i=r.code,n=r.data,o=Date.now(),i!==w.SUCCESS?[2,{code:i}]:(((a=o-t)<this._RTT||0===this._RTT)&&a<=this._validMaxRTT&&(this._RTT=a),a<this._validMinRTT&&this.stop(e),this._deltaTime=n-t-this._RTT/2,this._logger.info(D.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime}),e),[2,{code:i,delayTime:this._deltaTime}])}})})}}),Object.defineProperty(e.prototype,"_getDeltaTimeInCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i,n,o,a,_,l,s;return P(this,function(c){switch(c.label){case 0:return r=Date.now(),[4,this._callEngine.getCallTimeInfo(e,t)];case 1:return i=c.sent(),n=i.code,o=i.data,a=Date.now(),n!==w.SUCCESS?[2,{code:n}]:((_=a-r)<this._RTT&&(this._RTT=_),this._deltaTime=o.syncTime-r-this._RTT/2,this._logger.info(D.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({callId:e,rtt:this._RTT,deltaT:this._deltaTime}),t),l=Math.floor(o.startTime-this._deltaTime),s=Math.floor(o.firstFrametime-this._deltaTime),_<this._validMinRTT?[2,{code:pe.SUCCESS,clientStartTime:l,clientFirstFrameTime:s}]:[2,{code:pe.INVALID_RESPONSE_TIME,clientStartTime:l,clientFirstFrameTime:s}])}})})}}),Object.defineProperty(e.prototype,"_loopCorrectClientTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i,n,o,a=this;return P(this,function(_){switch(_.label){case 0:return this.stop(t),this._logger.info(D.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T,"callId: ".concat(e),t),[4,this._getDeltaTimeInCall(e,t)];case 1:return r=_.sent(),i=r.code,n=r.clientStartTime,o=r.clientFirstFrameTime,i===pe.SUCCESS?(this._logger.info(D.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,"code: ".concat(w.SUCCESS),t),this._singleCallDurationEv(e,n,o,t),[2]):this._retryTimesInCall>this._maxRetryTimesInCall&&i===pe.INVALID_RESPONSE_TIME?(this._logger.info(D.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,"code: ".concat(pe.INVALID_RESPONSE_TIME),t),this._singleCallDurationEv(e,n,o,t),[2]):(this._retryTimesInCall>this._maxRetryTimesInCall||(this._retryTimesInCall++,setTimeout(function(){a._loopCorrectClientTime(e,t)},this._interval)),[2])}})})}}),e}();!function(e){e[e.SOON_AFETER=0]="SOON_AFETER",e[e.CURRENT=1]="CURRENT"}(me||(me={})),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"}(ve||(ve={})),function(e){e[e.OUT=-1]="OUT",e[e.GROUP=0]="GROUP",e[e.IN=1]="IN"}(ye||(ye={}));var Ue,Me=function(e){function t(t,r,i,n,o){var a=e.call(this)||this;return Object.defineProperty(a,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(a,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(a,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(a,"_mainSession",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(a,"_holdSessions",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(a,"_signalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_abnormalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_isUpFirstFrameTime",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(a,"_callStartMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(a,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(a,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:null}),a._timeCorrectioner=new Pe(a,n,a._onRecvSinCallDuration.bind(a)),a._signalModule=new Oe(t,r,i,a._timeCorrectioner,a._logger,a._reportAppEventModule),a._signalModule.registerListener({onInvite:a._onInvite.bind(a),onStatusDown:a._onStatusDown.bind(a),onOtherClientStatusDown:a._onOtherClientStatusDown.bind(a),onEventDown:a._onEventDown.bind(a),onSwitchMediaType:a._onSwitchMediaType.bind(a),onRecvCallEndLog:a._onRecvCallEndLog.bind(a),onIMStateChange:a._onIMStateChange.bind(a)}),a._abnormalModule=new Ne(r,n),a}return m(t,e),Object.defineProperty(t.prototype,"startCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i,n,o,a,_,l,s,c,u,L,d,E,C,T,I,g,S,f,p,h,R=this;return P(this,function(b){switch(b.label){case 0:return r=this._context.getCurrentId(),i=e.callType,n=e.mediaType,o=e.toUsers,a=e.targetId,_=e.targetType,l=e.oldRoomId,s=e.pushConfig,c=e.extra,this._clientCallId=e.callId,u=s?$(s,this._clientCallId):"",[4,this._signalModule.startCall({clientCallId:this._clientCallId,callType:i,mediaType:n,toUsers:o,secretChat:se.NORMAL,targetType:_,targetId:a,oldRoomId:l,pushExt:u,pushContent:(null==s?void 0:s.pushContent)||"",extra:c},t)];case 1:return L=b.sent(),d=L.code,E=L.data,d!==w.SUCCESS?[2,{code:d}]:(T=(C=E).callId,I=C.busylineUsers,this._abnormalModule.addAbnormallCallId(r,T),this._mainSession=new de(T,H.INVITED,i,n,r,r,[],this._logger),i===j.SINGLE&&(g=this._startTimer(E.callId,G.NO_ANSWER,t),this._mainSession.updateTimerId(ce.INVITER,g)),S={userId:r,userState:G.CALLING,systemState:B.CALLING,targetType:_,targetId:a},f=o.map(function(e){var t=e.userId,r=e.targetType,i=e.targetId;return{userId:t,userState:G.INVITED,systemState:B.INVITED,targetType:r,targetId:i}}),p=[],I&&(p=I.map(function(e){var t=f.find(function(t){return t.userId===e.userId}),r=t.targetType,i=t.targetId;return{userId:e.userId,userState:e.sessionStatus,systemState:B.BUSYLINE_RINGING,targetType:r,targetId:i}}),f=f.filter(function(e){var t=e.userId;return p.every(function(e){return e.userId!==t})})),h=this.updateUsersState(T,M(M([S],U(f),!1),U(p),!1),t),setTimeout(function(){h.length>0&&R.reportRemoteUserStateChange(T,h,t)}),[2,{code:d,data:E}])}})})}}),Object.defineProperty(t.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return y(this,void 0,void 0,function(){var i,n,o,a,_,l,s,c,u,L,d;return P(this,function(E){switch(E.label){case 0:return this._mainSession?(i=e.toUsers,n=e.pushConfig,o=e.extra,a=n?$(n,this._clientCallId):"",_=this._mainSession.getCallId(),[4,this._signalModule.inviteCall({callId:_,toUsers:i,pushExt:a,pushContent:(null==n?void 0:n.pushContent)||"",extra:o},t)]):[2,{code:w.NOT_IN_CALL}];case 1:return l=E.sent(),s=l.code,c=l.data,s===w.SUCCESS&&(this._mainSession.getCallType()===j.SINGLE&&(this._mainSession.updateCallType(j.MULTI),this._onCallTypeChange(this._mainSession.getCallId(),j.MULTI,t)),u=i.map(function(e){var t=e.userId,r=e.targetType,i=e.targetId;return{userId:t,userState:G.INVITED,systemState:B.INVITED,targetType:r,targetId:i}}),L=[],c.busylineUsers&&(L=null===(r=c.busylineUsers)||void 0===r?void 0:r.map(function(e){var t=u.find(function(t){return t.userId===e.userId}),r=t.targetType,i=t.targetId;return{userId:e.userId,userState:e.sessionStatus,systemState:B.BUSYLINE_RINGING,targetType:r,targetId:i}}),u=u.filter(function(e){var t=e.userId;return L.every(function(e){return e.userId!==t})})),(d=this.updateUsersState(_,M(M([],U(u),!1),U(L),!1),t)).length>0&&this.reportRemoteUserStateChange(_,d,t)),[2,{code:s,data:c}]}})})}}),Object.defineProperty(t.prototype,"clearAllTimer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;M([this._mainSession],U(this._holdSessions),!1).forEach(function(i){i&&i.getCallId()===e&&i.getAllTimerIds().forEach(function(e){return r._stopTimer.bind(r)(e,t)})})}}),Object.defineProperty(t.prototype,"hangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i,n,o,a;return P(this,function(_){switch(_.label){case 0:return r=e.callId,i=e.systemState,n=e.pushConfig,o=n?$(n,this._clientCallId):"",[4,this._signalModule.hangupCall({callId:r,sysStatus:i,pushExt:o,pushContent:(null==n?void 0:n.pushContent)||""},t)];case 1:return a=_.sent().code,this.endCurrentSession(e.systemState,r,t),[2,{code:a}]}})})}}),Object.defineProperty(t.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i;return P(this,function(n){switch(n.label){case 0:return this._mainSession?(r=e.callId,[4,this._signalModule.acceptCall({callId:r},t)]):[2,{code:w.NOT_IN_CALL}];case 1:return i=n.sent().code,this._stopTimer(this._mainSession.getInviteeTimerId(),t),i!==w.SUCCESS?[2,{code:i}]:(this._clearMobileOnPhone(e.callId,t),this._mainSession.updateSessionState(H.CONNECTING),[2,{code:i}])}})})}}),Object.defineProperty(t.prototype,"joinCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i;return P(this,function(n){switch(n.label){case 0:return r=this._context.getCurrentId(),this._mainSession&&this._stopTimer(this._mainSession.getInviteeTimerId(),t),[4,this._signalModule.joinCall({callId:e.callId},t)];case 1:return(i=n.sent().code)!==w.SUCCESS?[2,{code:i}]:(this._abnormalModule.addAbnormallCallId(r,e.callId),this._mainSession?[3,3]:[4,this._createSessionByServer(e.callId,t,!0)]);case 2:return n.sent(),[3,4];case 3:this._clearMobileOnPhone(e.callId,t),n.label=4;case 4:return[2,{code:i}]}})})}}),Object.defineProperty(t.prototype,"requestChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i,n;return P(this,function(o){switch(o.label){case 0:return this._mainSession?(r={mediaType:e.mediaType},this._mainSession.updateReqMediaType(e.mediaType),i=Ae(),[4,this._signalModule.dialogUpCall({transactionId:i,callId:this._mainSession.getCallId(),toUserIds:e.toUserIds,dialogType:le.SWITCH_MEDIA_TYPE,action:_e.REQUEST,extraKeyVal:r},t)]):[2,{code:w.NOT_IN_CALL}];case 1:return(n=o.sent().code)!==w.SUCCESS?[2,{code:n}]:[2,{code:w.SUCCESS,data:{transactionId:i}}]}})})}}),Object.defineProperty(t.prototype,"responseChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return this._mainSession?[2,this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:le.SWITCH_MEDIA_TYPE,action:e.agree?_e.ACCEPT:_e.REFUSE},t)]:[2,{code:w.NOT_IN_CALL}]})})}}),Object.defineProperty(t.prototype,"cancelChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return this._mainSession?[2,this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:le.SWITCH_MEDIA_TYPE,action:_e.CANCEL},t)]:[2,{code:w.NOT_IN_CALL}]})})}}),Object.defineProperty(t.prototype,"getCallLogList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i,n,o,a,_,l,s;return P(this,function(c){switch(c.label){case 0:return r=this._context.getCurrentId(),i=e.timestamp,n=e.count,o=e.order,[4,this._signalModule.syncCallLog({userId:r,syncTime:i,count:n,order:o},t)];case 1:return a=c.sent(),_=a.code,l=a.data,_!==w.SUCCESS?[2,{code:_}]:(s=l.callLogList.map(function(e){return K(e)}),[2,{code:w.SUCCESS,data:{hasMore:Boolean(null==l?void 0:l.hasMore),syncTime:0===o?l.maxTime:l.minTime,list:s}}])}})})}}),Object.defineProperty(t.prototype,"deleteCallLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r;return P(this,function(i){return r=this._context.getCurrentId(),[2,this._signalModule.deleteCallRecord(r,e,t)]})})}}),Object.defineProperty(t.prototype,"getCallServerTimestamp",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r,i;return P(this,function(n){switch(n.label){case 0:return[4,this._signalModule.getCallServerTimestamp(e)];case 1:return t=n.sent(),r=t.code,i=t.data,r!==w.SUCCESS?[2,{code:r}]:[2,{code:r,data:i.syncTime}]}})})}}),Object.defineProperty(t.prototype,"getCallTimeInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return[2,this._signalModule.getCallTimeInfo(e,t)]})})}}),Object.defineProperty(t.prototype,"getOpenCallList",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r,i,n,o,a=this;return P(this,function(_){switch(_.label){case 0:return t=this._context.getCurrentId(),[4,this._signalModule.getUserCallStateList(e)];case 1:return r=_.sent(),i=r.code,n=r.data,i!==w.SUCCESS?[2,{code:i}]:(o=n.callStateList.map(function(r){var i=r.callId,n=r.callType,o=r.mediaType,_=r.callingUserId,l=r.callUserIds,s=r.callStatus,c=r.crtTime,u=r.userSessionStatus,L=r.startTime,d=r.syncTime,E=_===t?ye.OUT:ye.IN,C=a._timeCorrectioner.calcClientStartTime(i,L,e).clientStartTime,T=void 0===C?L:C;return{callId:i,callType:n,callDirection:E,mediaType:o,callerUserId:_,callUserIds:l,sessionState:s,userState:u,startTimestamp:L,endTimestamp:0,duration:Math.floor((+new Date-T)/1e3),syncTimestamp:d,systemState:0,createTimestamp:c}}),[2,{code:i,data:o}])}})})}}),Object.defineProperty(t.prototype,"removeAllCallLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){return P(this,function(t){switch(t.label){case 0:return[4,this._signalModule.clearCallRecord(e)];case 1:return[2,{code:t.sent().code}]}})})}}),Object.defineProperty(t.prototype,"getCallSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i,n,o,a,_,l,s,c,u,L,d,E,C;return P(this,function(T){switch(T.label){case 0:return[4,this._signalModule.getCallSession(e,t)];case 1:return r=T.sent(),i=r.code,n=r.data,i!==w.SUCCESS?[2,{code:i}]:(a=(o=n).callId,_=o.callingUserId,l=o.callType,s=o.mediaType,c=o.callStatus,u=o.callSessionUsers,L=o.startTime,d=o.duration,E=o.syncTime,C=u.map(function(e){return{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,targetType:e.targetType,targetId:e.targetId,cameraEnable:!1,microphoneEnable:!1}}),[2,{code:i,data:{callId:a,startCallerId:_,callType:l,mediaType:s,sessionState:c,callSessionUsers:C,startTime:L,duration:d,syncTime:E}}])}})})}}),Object.defineProperty(t.prototype,"getHoldSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._holdSessions.find(function(t){return t&&t.getCallId()===e});return t?new F(t,this,this._logger,this._rtcModule,this._context):null}}),Object.defineProperty(t.prototype,"getLocalMainSession",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._mainSession?new F(this._mainSession,this,this._logger,this._rtcModule,this._context):null}}),Object.defineProperty(t.prototype,"updateMainSessionState",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;null===(t=this._mainSession)||void 0===t||t.updateSessionState(e)}}),Object.defineProperty(t.prototype,"setIsLocalClientHangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;null===(t=this._mainSession)||void 0===t||t.setIsLocalClientHangup(e)}}),Object.defineProperty(t.prototype,"updateUsersState",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(D.L_CALL_ENGINE_UPDATE_USERS_STATE_O,"updateUsersState -> users: ".concat(JSON.stringify(t)),r);var i=M([this._mainSession],U(this._holdSessions),!1).find(function(t){return(null==t?void 0:t.getCallId())===e}),n=[];return i?n.push.apply(n,M([],U(i.updateUserList(t,r)),!1)):n.push.apply(n,M([],U(t),!1)),n}}),Object.defineProperty(t.prototype,"getCallStaringTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return[2,this._timeCorrectioner.getCallClientTimeByServer(e.callId,t)]})})}}),Object.defineProperty(t.prototype,"systemStatusUp",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){return P(this,function(r){return[2,this._signalModule.sysStatusUp(e,t)]})})}}),Object.defineProperty(t.prototype,"upFirstFrameTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r,i,n,o;return P(this,function(a){switch(a.label){case 0:return!this._mainSession||this._mainSession&&this._mainSession.getCallType()!==j.SINGLE||this._isUpFirstFrameTime?[2,{code:w.SUCCESS}]:(t=Date.now(),r=this._timeCorrectioner.getLocalDelayTime(),i=Math.floor(t+r),this._logger.info(D.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T,"now: ".concat(t,"; delay: ").concat(r,"; streamReadyTime: ").concat(i),e),this._isUpFirstFrameTime=!0,n=this._mainSession.getCallId(),[4,this._signalModule.eventUpCall({callId:n,eventType:fe.FIRST_FRAME,eventArgs:{streamReadyTime:i},eventTime:Date.now()},e)]);case 1:return o=a.sent().code,this._logger.info(D.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R,"code: ".concat(o),e),[2,{code:o}]}})})}}),Object.defineProperty(t.prototype,"endCurrentSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=this,n=this._context.getCurrentId();if(this._mainSession&&this._mainSession.getCallId()===t){var o=this._mainSession.getUserList().map(function(t){var r=t.userId,o=t.systemState,a=t.targetType,_=t.targetId;return r===n&&(o=e),{userId:r,sessionStatus:G.ENDED,statusTime:Date.now(),duration:0,changed:1,inviteUserId:i._mainSession.getStartCallerId(),sysStatus:o,targetType:a,targetId:_}}),a={callId:this._mainSession.getCallId(),toDeviceId:this._signalModule.getDeviceId(),callStatus:H.ENDED,duration:0,callSessionUsers:o};this._onStatusDown(a,r)}}}),Object.defineProperty(t.prototype,"startTimeCorrection",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._timeCorrectioner.restart(e)}}),Object.defineProperty(t.prototype,"getDelayTimeInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return{delayTime:this._timeCorrectioner.getLocalDelayTime(),rtt:this._timeCorrectioner.getRTT()}}}),Object.defineProperty(t.prototype,"upgradeMainSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=this._holdSessions.findIndex(function(t){return t.getCallId()===e});this._mainSession=null===(t=this._holdSessions.splice(r,1))||void 0===t?void 0:t[0]}}),Object.defineProperty(t.prototype,"endCurrentUserAbnormalCalls",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r,i,n,o=this;return P(this,function(a){switch(a.label){case 0:return t=this._context.getCurrentId(),[4,this._abnormalModule.getAbnormalCallIds(t)];case 1:return(r=a.sent())?(i=r.filter(function(e){var t;return e!==(null===(t=o._mainSession)||void 0===t?void 0:t.getCallId())}),[4,this._signalModule.endUserAbnormalCalls({callIds:i,allDevice:e?1:0})]):[2,{code:w.SUCCESS}];case 2:return(n=a.sent().code)===w.SUCCESS&&this._abnormalModule.removeAbnormalCallIds(t,i),[2,{code:n}]}})})}}),Object.defineProperty(t.prototype,"setRTCModule",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._rtcModule=e}}),Object.defineProperty(t.prototype,"_onIMStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=this._logger.createTraceId(),i=0;e===_.DISCONNECTED&&this._mainSession&&this._mainSession.getSessionState()!==H.ONCALL&&(i=Ie(function(){var e;t._logger.info(D.L_CALL_ENGINE_IM_STATE_CHANGE_O,"endCurrentSession, IM disconnected for more than 60s",r),t.endCurrentSession(B.CONNECTION_ERR,null===(e=t._mainSession)||void 0===e?void 0:e.getCallId(),r)},6e4)),e===_.CONNECTED&&(i&&clearTimeout(i),this._initOpts.isAllowNewCallWhenRinging&&this.endCurrentUserAbnormalCalls(!0))}}),Object.defineProperty(t.prototype,"_handleCallTimeout",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.warn(D.L_CALL_ENGINE_CALL_TIMEOUT_O,"call timeout callId: ".concat(e,", userState: ").concat(t),r);var i=M([this._mainSession],U(this._holdSessions),!1).find(function(t){return t&&t.getCallId()===e});if(i){var n=this._context.getCurrentId();this._onStatusDown({callId:e,toDeviceId:this._signalModule.getDeviceId(),callStatus:H.ENDED,duration:0,callSessionUsers:i.getUserList().map(function(e){var r,o,a=e.userId,_=e.targetType,l=e.targetId,s=e.stateTime;return a===n?(r=t===G.MISSED?B.MISSED:B.NO_ANSWER,o=t===G.MISSED?G.MISSED:G.NO_ANSWER):(r=t===G.MISSED?B.NO_ANSWER:B.MISSED,o=t===G.MISSED?G.NO_ANSWER:G.MISSED),{userId:a,sessionStatus:o,statusTime:s?s+1:Date.now(),duration:0,changed:1,inviteUserId:i.getCallerId(),sysStatus:r,targetType:_,targetId:l}})},r)}else this._logger.warn(D.L_CALL_ENGINE_CALL_TIMEOUT_O,"handleCallTimeout without session, callId: ".concat(e),r)}}),Object.defineProperty(t.prototype,"_startTimer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=this,n=Ie(function(){i._handleCallTimeout(e,t,r),i._signalModule.statusUpCall({callId:e,sessionStatus:t},r)},6e4);return this._logger.info(D.L_CALL_ENGINE_START_CALL_TIMER_O,"callId: ".concat(e,", timerId: ").concat(n),r),n}}),Object.defineProperty(t.prototype,"_stopTimer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){clearTimeout(e),this._logger.info(D.L_CALL_ENGINE_STOP_CALL_TIMER_O,"timerId: ".concat(e),t)}}),Object.defineProperty(t.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._clientCallId=c();var i=this._context.getCurrentId(),n=e.callSessionUsers,o=e.secretChat,a=e.extra,_=void 0===a?"{}":a;o!==se.SECRET?(n.some(function(e){return e.userId===i})&&this._selfIsInviteeHandle(e,t,r,_),this._othersIsInviteeHandle(e,r)):this.emit(Ee.onPubInviteCallMiss,Object.assign(e,{extra:JSON.stringify(e),reason:Ce.SECRET_CALL,refer:t?Te.PUB_INVITE:Te.PULL_KV_INVITE}))}}),Object.defineProperty(t.prototype,"_selfIsInviteeHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i,n){var o=e.callId,a=e.inviteUserId,_=e.callType,l=e.mediaType,s=e.callSessionUsers,c=this._context.getCurrentId();this._abnormalModule.addAbnormallCallId(c,o);var u=new de(o,H.RINGING,_,l,a,a,[],this._logger);this._signalModule.ringingCall({callId:o},i);var L=this._startTimer(o,G.MISSED,i);u.updateTimerId(ce.INVITEE,L),this._mainSession?(this._holdSessions.push(u),this._mainSession.updateSessionState(H.BUSYLINE_WAIT)):this._mainSession=u;var d=new F(u,this,this._logger,this._rtcModule,this._context),E=r?ve.PUB_INVITE_CALL:ve.PULL_KV_INVITE_CALL;this.emit(t.__INNER_INVITE__,d,E);var C=s.map(function(e){return{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,targetType:e.targetType,targetId:e.targetId,stateTime:e.statusTime}}),T=this.updateUsersState(o,C,i);this._reportAppEventModule.onReceivedCall(d,i,JSON.parse(n||"{}").extra),T.length>0&&this.reportRemoteUserStateChange(o,T,i)}}),Object.defineProperty(t.prototype,"_othersIsInviteeHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i,n,o=e.callId,a=e.inviteUserId,_=e.callSessionUsers,l=this._context.getCurrentId(),s=_.filter(function(e){return e.userId!==l&&e.userId!==a&&e.sessionStatus===G.INVITED});if(s.length){(null===(r=this._mainSession)||void 0===r?void 0:r.getCallType())===j.SINGLE&&(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())===o&&(this._onCallTypeChange(this._mainSession.getCallId(),j.MULTI,t),null===(n=this._mainSession)||void 0===n||n.updateCallType(j.MULTI));var c=[],u=[];s.forEach(function(e){var t=e.userId,r=e.sessionStatus,i=e.sysStatus;c.push({callId:o,userId:t,userState:r}),u.push({userId:t,userState:r,systemState:i})}),this._onOtherMemberInvite(c);var L=this.updateUsersState(o,u,t);L.length>0&&this.reportRemoteUserStateChange(o,L,t)}}}),Object.defineProperty(t.prototype,"_onHangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=this;this._mainSession&&e.forEach(function(e){e.callId===i._mainSession.getCallId()&&(e.userState===G.CANCELLED?i._stopTimer(i._mainSession.getInviteeTimerId(),r):i._stopTimer(i._mainSession.getInviterTimerId(),r))})}}),Object.defineProperty(t.prototype,"_onAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){var i,n,o,a,_=null===(i=this._mainSession)||void 0===i?void 0:i.getSessionState(),l=[H.CONNECTING,H.ONCALL,H.BUSYLINE_WAIT];if((null===(n=this._mainSession)||void 0===n?void 0:n.getCallType())!==j.SINGLE||!_||!l.includes(_)){var s=this._mainSession.getStartCallerId(),c=this._context.getCurrentId();if((null===(o=this._mainSession)||void 0===o?void 0:o.getCallType())===j.SINGLE&&s===c)e.filter(function(e){return e.fromUserId!==c})&&this.emit(t.__INNER_SESSION_CONNECT__,this.getLocalMainSession().getCallId(),r);null===(a=this._mainSession)||void 0===a||a.updateSessionState(H.CONNECTING),this._stopTimer(this._mainSession.getInviterTimerId(),r)}}}),Object.defineProperty(t.prototype,"_onStatusDown",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i;return y(this,void 0,void 0,function(){var n,o,a,_,l,s,c,u,L,d,E,C,T,I;return P(this,function(g){return n=e.callStatus,o=e.startTime,(a=e.callId)!==(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())?[2]:(this._callStartMap[a]=this._callStartMap[a]||{},this._callStartMap[a].isReceiveCallStartTime||n!==H.ONCALL||(this._callStartMap[a].isReceiveCallStartTime=!0,_=this._timeCorrectioner.calcClientStartTime(a,o,t),l=_.code,s=_.clientStartTime,l===pe.SUCCESS&&(this._callStartMap[a].callStartTime=s,this._reportAppEventModule.onReceivedCallStartTime({callId:a,callStartTime:s},t))),c=!1,u=this._context.getCurrentId(),(L=e.callSessionUsers.map(function(e){return[G.IDLE,G.DECLINED,G.MISSED,G.NO_ANSWER,G.CANCELLED].includes(e.sessionStatus)&&e.sysStatus!==B.CANCELLED&&e.userId===u&&(c=!0),{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,stateTime:e.statusTime}})).length&&(d=this.updateUsersState(a,L,t)).length>0&&this.reportRemoteUserStateChange(a,d,t),this._mainSession||this._holdSessions.length?(E=function(e){var t=e.callId,r=[],i=[],n=[],o=[];return e.callSessionUsers.forEach(function(e){var a=e.userId,_=e.sessionStatus,l=e.sysStatus;switch(_){case G.INVITED:o.push({callId:t,userId:a,userState:_});break;case G.RINGING:r.push({callId:t,fromUserId:a});break;case G.CONNECTING:n.push({fromUserId:a});break;case G.CANCELLED:case G.DECLINED:case G.ENDED:case G.IDLE:i.push({callId:t,fromUserId:a,userState:_,systemState:l})}}),{ringingData:r,hangupData:i,acceptData:n,otherInvitedData:o}}(e),C=E.hangupData,T=E.acceptData,I=E.otherInvitedData,C.length>0&&this._onHangup(C,e.callStatus,t),T.length>0&&this._onAccept(T,t),I.length>0&&(null===(i=this._mainSession)||void 0===i?void 0:i.getCallType())===j.MULTI&&this._onOtherMemberInvite(I),(e.callStatus===H.ENDED||c)&&this._onSessionClose(e,t,c),[2]):[2])})})}}),Object.defineProperty(t.prototype,"_onOtherClientStatusDown",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i,n,o=e.callId,a=e.callSessionUsers,_=this._context.getCurrentId(),l=a.find(function(e){return e.userId===_});if(l&&(this._mainSession||this._holdSessions.length)){var s=l.userId,c=l.sessionStatus,u=l.statusTime;if(c===G.CONNECTING){var L=[G.ONCALL,G.CONNECTING],d=(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())===o,E=null===(n=null===(i=this._mainSession)||void 0===i?void 0:i.getUserList().find(function(e){return e.userId===_}))||void 0===n?void 0:n.userState;if(!(d&&E&&L.includes(E))){var C=this.updateUsersState(o,[{userId:s,userState:c,systemState:B.OTHER_CLIENT_ACCEPT,stateTime:u}],t);C.length>0&&this.reportRemoteUserStateChange(o,C,t),this._onSessionClose(e,t,!1)}}}}}),Object.defineProperty(t.prototype,"_onEventDown",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return y(this,void 0,void 0,function(){var i,n,o,a,_,l,s;return P(this,function(c){return i=e.callId,n=e.eventArgs,o=e.eventType,i!==(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())||this._mainSession.getSessionState()!==H.ONCALL||o===fe.CALL_DURATION&&(a=n.firstFrameTime,_=this._timeCorrectioner.calcClientStartTime(i,a,t),l=_.code,s=_.clientStartTime,this._logger.info(D.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O,"clientFirstFrameTime: ".concat(s),t),l===pe.SUCCESS&&(this._callStartMap[i].firstFrameTime=s,this._reportAppEventModule.onReceivedCallFirstFrameTime(i,s,t))),[2]})})}}),Object.defineProperty(t.prototype,"_onRecvSinCallDuration",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var n;(null===(n=this._mainSession)||void 0===n?void 0:n.getCallId())===e&&(this._callStartMap[e].callStartTime=t,this._callStartMap[e].firstFrameTime=r,this._reportAppEventModule.onReceivedCallStartTime(v({callId:e},{callStartTime:t}),i),this._reportAppEventModule.onReceivedCallFirstFrameTime(e,r,i))}}),Object.defineProperty(t.prototype,"_onSwitchMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i,n,o,a,_=e.callId,l=e.action,s=e.extraKeyVal,c=e.transactionId,u=e.promoterId,L=s.mediaType,d=s.reason,E=null===(r=this._mainSession)||void 0===r?void 0:r.getCallId();if(_===E){var C=(null===(i=this._mainSession)||void 0===i?void 0:i.getOldDialogData())||{},T=C.transactionId,I=C.action,g=C.mediaType;if(T!==c||I!==l||g!==L){if(this._logger.info(D.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"action: ".concat(l,", reason: ").concat(d),t),null===(n=this._mainSession)||void 0===n||n.setOldDialogData({transactionId:c,action:l,mediaType:L}),l===_e.REQUEST)this._onRequestChangeMediaType({transactionId:c,userId:u,mediaType:L},t);else{var S=null;switch(d){case _e.CANCEL:S=k.CANCEL_CHANGE_MEDIA_TYPE;break;case _e.ACCEPT:S=k.SERVER_ALLOW_MEDIA_TYPE,null===(o=this._mainSession)||void 0===o||o.updateMediaType(this._mainSession.getReqMediaType()),null===(a=this._mainSession)||void 0===a||a.updateReqMediaType(null);break;case _e.REFUSE:S=k.REFUSE_CHANGE_MEDIA_TYPE;break;case _e.TIMEOUT:S=k.CHANGE_MEDIA_TYPE_TIMEOUT}k[S]&&this._receiveMediaTypeChangeResult({transactionId:c,userId:u,mediaType:L},S,t)}l!==_e.NOTICE||L!==V.AUDIO||d||this._receiveMediaTypeChangeResult({transactionId:c,userId:u,mediaType:L},k.SERVER_ALLOW_MEDIA_TYPE,t)}else this._logger.info(D.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"duplicate dialog data",t)}else this._logger.info(D.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"not current session callId: ".concat(E,", recvCallId: ").concat(_),t)}}),Object.defineProperty(t.prototype,"_onRecvCallEndLog",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=K(e);this._reportAppEventModule.onReceivedCallRecord(r,t)}}),Object.defineProperty(t.prototype,"_onSessionClose",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i){var n=this,o=e.callId,a=this._context.getCurrentId();this._abnormalModule.removeAbnormalCallIds(a,[o]);var _=M([this._mainSession],U(this._holdSessions),!1).find(function(e){return e&&e.getCallId()===o});if(_){this._logger.warn(D.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,"callId: ".concat(o),r),this.emit(t.__INNER_SESSION_CLOSE__,o,r);var l,s=_.getUserList().find(function(e){return e.userId===a});l=i&&e.toDeviceId!==this._signalModule.getDeviceId()?_.getIsLocalClientHangup()?s.systemState:B.OTHER_CLIENT_HANGUP:s.systemState,this._reportAppEventModule.onCallEnded(new F(_,this,this._logger,this._rtcModule,this._context),l,r),this._reportCallPlusSummaryMessage(_,o,l),this._mainSession&&this._mainSession.getCallId()===o&&(this._mainSession.getAllTimerIds().forEach(function(e){return n._stopTimer.bind(n)(e,r)}),_.getCallType()===j.SINGLE&&(this._isUpFirstFrameTime=!1),delete this._callStartMap[o]),this._removeSession(o)}else this._logger.warn(D.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,"unexpect session callId -> ".concat(o),r)}}),Object.defineProperty(t.prototype,"_reportCallPlusSummaryMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i,n,o,_=this._context.getCurrentId(),l=e.getUserList().filter(function(e){return e.userId!==_})[0].userId,s=e.getStartCallerId();if(!localStorage.getItem("missMessageMap-".concat(_,"-").concat(t))){var c={callId:t,callerUserId:s,targetId:l,mediaType:e.getMediaType(),firstFrameTime:(null===(i=this._callStartMap[t])||void 0===i?void 0:i.firstFrameTime)||0,callStartTime:(null===(n=this._callStartMap[t])||void 0===n?void 0:n.callStartTime)||0,callEndTime:(null===(o=this._callStartMap[t])||void 0===o?void 0:o.callStartTime)?+new Date-this._timeCorrectioner.getLocalDelayTime():0,hangupReason:r};this._reportAppEventModule.onReceivedCallPlusSummaryMessage({messageType:"RC:CallPlusSummary",content:c,senderUserId:s,targetId:l,channelId:"",conversationType:u.PRIVATE,sentTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),receivedTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),messageUId:t,messageDirection:s===_?L.SEND:L.RECEIVE,isPersited:!0,isCounted:!1,isOffLineMessage:!1,canIncludeExpansion:!1,receivedStatus:d.READ,isStatusMessage:!1,isMentioned:!1,expansion:null,disableNotification:!1,sentStatus:a.SENT}),localStorage.setItem("missMessageMap-".concat(_,"-").concat(t),t)}}}),Object.defineProperty(t.prototype,"_removeSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;if(e===(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId()))this._mainSession=null;else{var r=this._holdSessions.findIndex(function(t){return(null==t?void 0:t.getCallId())===e});this._holdSessions.splice(r,1)}}}),Object.defineProperty(t.prototype,"_createSessionByServer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return void 0===r&&(r=!1),y(this,void 0,void 0,function(){var i,n,o,a,_,l,s,c,u;return P(this,function(L){switch(L.label){case 0:return this._logger.info(D.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T,"callId: ".concat(e),t),[4,this.getCallSession({callId:e},t)];case 1:return i=L.sent(),n=i.code,o=i.data,n!==w.SUCCESS?(this._logger.error(D.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,"errcode: ".concat(n),t),[2]):(this._logger.info(D.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,"code: ".concat(n,", data: ").concat(JSON.stringify(o)),t),_=(a=o).callType,l=a.mediaType,s=a.callSessionUsers,c=a.startCallerId,this._mainSession=new de(e,H.CONNECTING,_,l,c,c,[],this._logger),r&&this._clearMobileOnPhone(e,t),(u=this.updateUsersState(e,s,t)).length>0&&this.reportRemoteUserStateChange(e,u,t),[2])}})})}}),Object.defineProperty(t.prototype,"_clearMobileOnPhone",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i;return P(this,function(n){switch(n.label){case 0:return(r=M([this._mainSession],U(this._holdSessions),!1).find(function(t){return(null==t?void 0:t.getCallId())===e}))&&r.getCallType()===j.MULTI?(this._logger.info(D.L_CALL_ENGINE_UP_ON_PHONE_END_T,"callId: ".concat(e),t),[4,this.systemStatusUp({callId:e,sysStatus:B.ON_PHONE_END,forward:me.CURRENT},t)]):[3,2];case 1:(i=n.sent().code)===w.SUCCESS?this._logger.info(D.L_CALL_ENGINE_UP_ON_PHONE_END_R,"callId: ".concat(e),t):this._logger.warn(D.L_CALL_ENGINE_UP_ON_PHONE_END_R,"callId: ".concat(e,", errCode: ").concat(i),t),n.label=2;case 2:return[2]}})})}}),Object.defineProperty(t.prototype,"reportRemoteUserStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i){var n=this,o=this._context.getCurrentId();r.forEach(function(t){var r=t.userId,a=t.userState,_=t.systemState;r!==o&&n._reportAppEventModule.onRemoteUserStateChanged({callId:e,userId:r,userState:a,reason:_},i)}),r.forEach(function(r){var a=r.userId,_=r.systemState;a===o&&_===B.ABNORMAL_END&&n.emit(t.__INNER_SESSION_CLOSE__,e,i)})}}),Object.defineProperty(t.prototype,"_onOtherMemberInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.forEach(function(e){var r,i=e.userId,n=e.callId,o=null===(r=t.getLocalMainSession())||void 0===r?void 0:r.getInviterUserId();t._reportAppEventModule.onRemoteUserInvited([i],o,n)})}}),Object.defineProperty(t.prototype,"_onRequestChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i=e.userId,n=e.transactionId,o=e.mediaType;null===(r=this._mainSession)||void 0===r||r.updateReqMediaType(o),this._reportAppEventModule.onReceivedChangeMediaTypeRequest(i,n,o,t)}}),Object.defineProperty(t.prototype,"_receiveMediaTypeChangeResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i){r===k.SERVER_ALLOW_MEDIA_TYPE&&this.emit(t.__INNER_CHANGE_MEDIA_TYPE__,e.mediaType,i),this._reportAppEventModule.onReceivedChangeMediaTypeResult(v(v({},e),{code:r}),i)}}),Object.defineProperty(t.prototype,"_onCallTypeChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._reportAppEventModule.onCallTypeChanged(t,e,r)}}),Object.defineProperty(t,"__INNER_SESSION_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-close"}),Object.defineProperty(t,"__INNER_SESSION_CONNECT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-connect"}),Object.defineProperty(t,"__INNER_CHANGE_MEDIA_TYPE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-change-media-type"}),Object.defineProperty(t,"__INNER_INVITE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-invite"}),t}(n);!function(e){e.NORMAL="RongCloudRTC",e.SCREEN="ScreenShare"}(Ue||(Ue={}));var De,we=function(e){function r(t,r,i,n,o,a){var _=e.call(this)||this;return Object.defineProperty(_,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(_,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(_,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(_,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(_,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(_,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(_,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(_,"_room",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(_,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(_,"_callMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:p.W640_H480,frameRate:f.FPS_15}}),Object.defineProperty(_,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(_,"_isPubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(_,"_audioOutputDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(_,"_videoConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(_,"_audioConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(_,"_userViewMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(_,"_callPlusStatusReportListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(_,"_remoteAudioEnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(_,"_preHangupCallId",{enumerable:!0,configurable:!0,writable:!0,value:null}),_._rtcClient=null==i?void 0:i.rtcClient,_._isPubTiny=i.isPubTiny||!1,_}return m(r,e),Object.defineProperty(r.prototype,"setCallPlusStatusReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._callPlusStatusReportListener=e}}),Object.defineProperty(r.prototype,"getCameraVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r,i,n,o;return P(this,function(a){switch(a.label){case 0:return!(t=this.getLocalVideoTrack())||this._videoConfigIsChange?[3,1]:(o={track:t,code:w.SUCCESS},[3,3]);case 1:return[4,this._createVideoTrack(e)];case 2:o=a.sent(),a.label=3;case 3:return i=(r=o).code,n=r.track,this._videoConfigIsChange=!1,i!==w.SUCCESS?[2,{code:i}]:[2,{code:w.SUCCESS,track:n}]}})})}}),Object.defineProperty(r.prototype,"getMicrophoneAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r,i,n,o;return P(this,function(a){switch(a.label){case 0:return!(t=this.getLocalAudioTrack())||this._audioConfigIsChange?[3,1]:(o={track:t,code:w.SUCCESS},[3,3]);case 1:return[4,this._createAudioTrack(e)];case 2:o=a.sent(),a.label=3;case 3:return i=(r=o).code,n=r.track,this._audioConfigIsChange=!1,i!==w.SUCCESS?[2,{code:i}]:[2,{code:w.SUCCESS,track:n}]}})})}}),Object.defineProperty(r.prototype,"createCallMediaTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i;return P(this,function(n){switch(n.label){case 0:return this._callMediaType=e,[4,this.getMicrophoneAudioTrack(t)];case 1:return(r=n.sent().code)!==w.SUCCESS?[2,{code:r}]:e!==V.AUDIO_VIDEO?[3,3]:[4,this.getCameraVideoTrack(t)];case 2:(i=n.sent().code)!==w.SUCCESS&&this._logger.warn(D.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P,"get camera video track error code: ".concat(i),t),n.label=3;case 3:return[2,{code:w.SUCCESS}]}})})}}),Object.defineProperty(r.prototype,"setVideoConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._videoConfigIsChange=!0,this._videoConfig=e}}),Object.defineProperty(r.prototype,"setAudioConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._audioConfigIsChange=!0,this._audioConfig=e}}),Object.defineProperty(r.prototype,"setAudioOutputDeviceId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){return P(this,function(t){return"string"!=typeof e||0===e.length?[2,{code:w.PARAM_ERROR}]:(this._audioOutputDeviceId===e||(this._audioOutputDeviceId=e,this._room&&this._room.getRemoteTracks().filter(function(e){return e.isAudioTrack()}).forEach(function(t){t.isSubscribed()&&t.play(void 0,{audioDeviceId:e})})),[2,{code:w.SUCCESS}])})})}}),Object.defineProperty(r.prototype,"destroyAllTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(D.L_RTC_MODULE_DESTROY_ALL_TRACKS_O,"",e),this._localTracks.forEach(function(e){e.destroy()}),this._localTracks.length=0}}),Object.defineProperty(r.prototype,"setAllRemoteAudioEnable",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return this._logger.info(D.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T,"enable: ".concat(e),r),t(e)?(this._remoteAudioEnable=e,this._room?(this._room.getRemoteTracks().filter(function(e){return e.isAudioTrack()}).forEach(function(t){e?t.unmute():t.mute()}),this._logger.info(D.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,"success",r),{code:w.SUCCESS}):{code:w.SUCCESS}):(this._logger.error(D.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,"param error, enable: type is boolean, value: ".concat(e)),{code:w.PARAM_ERROR})}}),Object.defineProperty(r.prototype,"destroyTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t;return P(this,function(r){return e.destroy(),t=this._localTracks.findIndex(function(t){return t.getTrackId()===e.getTrackId()}),this._localTracks.splice(t,1),[2]})})}}),Object.defineProperty(r.prototype,"sessionConnected",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i,n,o,a,_;return P(this,function(l){switch(l.label){case 0:return this._preHangupCallId=null,this._logger.info(D.L_RTC_MODULE_SESSION_CONNECT_T,"callId: ".concat(e),t),this._room?[3,2]:[4,this.joinRTCRoom(e,t)];case 1:if(r=l.sent(),_=r.code,i=r.room,_!==w.SUCCESS)return[2];if(this._room=i,this._preHangupCallId&&this._room.getRoomId()===this._preHangupCallId)return this._rtcClient.leaveRoom(this._room),this._releaseStoredData(),[2];n=this._room.getRemoteUserIds(),this._onSelfJoined(e,n,t),l.label=2;case 2:return this._callId=e,this._regRTCListeners(),(o=this._room.getRemoteTracks())&&o.length&&this._onRemoteTrackPublish(o),this._localTracks.length>0?(this.emit(Ee.onBeforePublish),a=this._isPubTiny?this._localTracks.map(function(e){return e.isVideoTrack()?{track:e,isPubTiny:!0}:e}):this._localTracks,[4,this.publish(a,t)]):[3,4];case 3:return _=l.sent().code,this.emit(Ee.onPublishRes,_),[3,5];case 4:this._logger.warn(D.L_RTC_MODULE_SESSION_CONNECT_P,"sessionConnected local tracks is empty",t),l.label=5;case 5:return this._logger.info(D.L_RTC_MODULE_SESSION_CONNECT_R,"code: ".concat(w.SUCCESS),t),[2]}})})}}),Object.defineProperty(r.prototype,"sessionClose",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return y(this,void 0,void 0,function(){var i,n;return P(this,function(o){switch(o.label){case 0:return this._logger.info(D.L_RTC_MODULE_SESSION_CLOSE_T,"callId: ".concat(e),t),this._preHangupCallId=e,this.destroyAllTracks(t),i=null===(r=this._room)||void 0===r?void 0:r.getRoomId(),this._room&&e===i?[4,this._rtcClient.leaveRoom(this._room)]:[3,2];case 1:return n=o.sent().code,this._releaseStoredData(),n!==h.SUCCESS?(this._logger.error(D.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom failed, code: ".concat(n),t),[2]):(this._logger.info(D.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom success",t),[3,3]);case 2:this._logger.warn(D.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom throw exception: not in room",t),o.label=3;case 3:return[2]}})})}}),Object.defineProperty(r.prototype,"disableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return y(this,void 0,void 0,function(){var e;return P(this,function(t){switch(t.label){case 0:return(e=this.getLocalVideoTrack())?[4,e.mute()]:[2,{code:w.CAMERA_CLOSED}];case 1:return[2,{code:t.sent(),track:e}]}})})}}),Object.defineProperty(r.prototype,"enableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var e;return P(this,function(t){switch(t.label){case 0:return(e=this.getLocalVideoTrack())?e.isOwnerMuted()?[4,e.unmute()]:[2,{code:w.SUCCESS}]:[2,{code:w.CAMERA_CLOSED}];case 1:return[2,{code:t.sent()}]}})})}}),Object.defineProperty(r.prototype,"changeVideoDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r,i,n,o,a,_,l,s,c;return P(this,function(u){switch(u.label){case 0:return t=[],r=[],[4,this._rtcClient.createCameraVideoTrack(Ue.NORMAL,this._videoConfig)];case 1:return i=u.sent(),n=i.code,o=i.track,n!==h.SUCCESS?[2,{code:n}]:(a=this._videoConfig,_=a.minBitrate,l=a.maxBitrate,(_||l)&&o.setBitrate(l,_),this._localTracks&&this._localTracks.forEach(function(e){e.isVideoTrack()?(e.destroy(),s=e):r.push(e)}),this._localTracks=this._localTracks.filter(function(e){return s&&e.getTrackId()!==s.getTrackId()}),t.push(o),r.push(o),this._localTracks=r,this._onLocalTrackReady(t,e),this._room?[4,this._room.publish(t)]:[3,3]);case 2:if((c=u.sent().code)!==h.SUCCESS)return[2,{code:c}];u.label=3;case 3:return[2,{code:w.SUCCESS,track:o}]}})})}}),Object.defineProperty(r.prototype,"changeAudioDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r,i,n,o,a,_;return P(this,function(l){switch(l.label){case 0:return t=[],r=[],i=v(v({},this._audioConfig),{micphoneId:this._audioConfig.microphoneId}),[4,this._rtcClient.createMicrophoneAudioTrack(Ue.NORMAL,i)];case 1:return n=l.sent(),o=n.code,a=n.track,o!==h.SUCCESS?[2,{code:o}]:(this._localTracks&&this._localTracks.forEach(function(e){e.isAudioTrack()||r.push(e)}),t.push(a),r.push(a),this._localTracks=r,this._onLocalTrackReady(t,e),this._room?[4,this._room.publish(t)]:[3,3]);case 2:if((_=l.sent().code)!==h.SUCCESS)return[2,{code:_}];l.label=3;case 3:return[2,{code:w.SUCCESS}]}})})}}),Object.defineProperty(r.prototype,"disableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return y(this,void 0,void 0,function(){var e;return P(this,function(t){switch(t.label){case 0:return(e=this.getLocalAudioTrack())?[4,e.mute()]:[2,{code:w.MICROPHONE_CLOSED}];case 1:return[2,{code:t.sent(),track:e}]}})})}}),Object.defineProperty(r.prototype,"changeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r;return P(this,function(i){switch(i.label){case 0:return this._logger.info(D.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T,"mediaType: ".concat(e),t),e!==V.AUDIO_VIDEO?[3,2]:[4,this._upgradeMediaType(t)];case 1:return r=i.sent(),[3,4];case 2:return[4,this._downgradeMediaType(t)];case 3:r=i.sent(),i.label=4;case 4:return r.code===w.SUCCESS&&this._logger.info(D.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"success",t),[2]}})})}}),Object.defineProperty(r.prototype,"_upgradeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r,i,n,o,a,_,l,s;return P(this,function(c){switch(c.label){case 0:return(t=this.getLocalVideoTrack())?[3,2]:[4,this._createVideoTrack(e)];case 1:if(r=c.sent(),i=r.code,n=r.track,i!==w.SUCCESS)return this._logger.error(D.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"create video track errCode: ".concat(i),e),[2,{code:i}];t=n,o=this._videoConfig,a=o.minBitrate,_=o.maxBitrate,(a||_)&&t.setBitrate(_,a),c.label=2;case 2:return l=this._isPubTiny?{track:t,isPubTiny:!0}:t,[4,this.publish([l],e)];case 3:return(s=c.sent().code)!==w.SUCCESS&&this._logger.error(D.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"publish errCode: ".concat(s),e),[2,{code:s}]}})})}}),Object.defineProperty(r.prototype,"_downgradeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r;return P(this,function(i){switch(i.label){case 0:return(t=this.getLocalVideoTrack())?[4,this._room.unpublish([t])]:[3,2];case 1:if((r=i.sent().code)!==h.SUCCESS)return this._logger.error(D.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"unpublish errCode: ".concat(r),e),[2,{code:r}];this.destroyTrack(t),i.label=2;case 2:return[2,{code:w.SUCCESS}]}})})}}),Object.defineProperty(r.prototype,"joinRTCRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i,n,o;return P(this,function(a){switch(a.label){case 0:return this._logger.info(D.L_RTC_MODULE_JOIN_RTC_ROOM_T,"call: ".concat(e),t),[4,Se({asyncFn:this._rtcClient.joinRTCRoomWithOptions.bind(this._rtcClient),fnArgs:[e,{mode:E.CALL}]})];case 1:return r=a.sent(),i=r.code,n=r.room,o=r.tracks,i!==h.SUCCESS?(this._logger.error(D.L_RTC_MODULE_JOIN_RTC_ROOM_R,"callId: ".concat(e,", errCode: ").concat(i),t),this._onRTCMethodFail(B.JOIN_ROOM_ERR,t),[2,{code:i}]):(this._logger.info(D.L_RTC_MODULE_JOIN_RTC_ROOM_R,"success",t),this._callId=e,[2,{code:w.SUCCESS,room:n,tracks:o}])}})})}}),Object.defineProperty(r.prototype,"subscribeTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r;return P(this,function(i){switch(i.label){case 0:return this._logger.info(D.L_RTC_MODULE_SUBSCRIBE_T,JSON.stringify({params:e.map(function(e){var t=e.track,r=e.subTiny;return{trackId:t.getTrackId(),subTiny:r}})}),t),this._room?[4,Se({asyncFn:this._room.subscribe.bind(this._room),fnArgs:[e],onError:function(e){}})]:[2,{code:w.SUCCESS}];case 1:return(r=i.sent().code)!==h.SUCCESS?(this._reportAppEventModule.onFetchRemoteMediaError(e,r),this._onRTCMethodFail(B.SUBSCRIBE_ERR,t),this._logger.error(D.L_RTC_MODULE_SUBSCRIBE_R,"errorCode: ".concat(r),t),[2,{code:r}]):(this._logger.info(D.L_RTC_MODULE_SUBSCRIBE_R,"success",t),[2,{code:w.SUCCESS}])}})})}}),Object.defineProperty(r.prototype,"unsubscribeTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r;return P(this,function(i){switch(i.label){case 0:return this._logger.info(D.L_RTC_MODULE_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map(function(e){return e.getTrackId()})}),t),this._room?[4,this._room.unsubscribe(e)]:[2,{code:w.SUCCESS}];case 1:return(r=i.sent().code)!==h.SUCCESS?(this._logger.error(D.L_RTC_MODULE_UNSUBSCRIBE_R,"errorCode: ".concat(r),t),[2,{code:r}]):(this._logger.info(D.L_RTC_MODULE_UNSUBSCRIBE_R,"success",t),[2,{code:w.SUCCESS}])}})})}}),Object.defineProperty(r.prototype,"_releaseStoredData",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._room=null,this._remoteAudioEnable=!0,this._userViewMap={},this._preHangupCallId=null}}),Object.defineProperty(r.prototype,"getRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t={};return this._room?(this._room.getRemoteUserIds().forEach(function(r){t[r]=e._room.getRemoteTracksByUserId(r)}),t):t}}),Object.defineProperty(r.prototype,"getRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return null===(r=this._room)||void 0===r?void 0:r.getRemoteTracksByUserId(e).find(function(e){return t===V.AUDIO?e.isAudioTrack():e.isVideoTrack()})}}),Object.defineProperty(r.prototype,"getRTCSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._room?this._room.getSessionId():null}}),Object.defineProperty(r.prototype,"_regRTCListeners",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._room.registerRoomEventListener({onKickOff:function(t,r){e._onKickOff(t,e._room.getRoomId(),r),e._releaseStoredData()},onUserJoin:function(t){var r=t.map(function(t){return{callId:e._callId,userId:t}}),i=e._logger.createTraceId();e._onOtherMemJoined(r,i)},onUserLeave:function(t){t.forEach(function(t){delete e._userViewMap[t]})},onTrackPublish:this._onRemoteTrackPublish.bind(this),onTrackUnpublish:this._onTrackUnpublish.bind(this),onTrackReady:function(t){e._onRemoteTrackReady([t])},onVideoMuteChange:function(t){e._onVideoMuteChagne({fromUserId:t.getUserId(),muted:t.isOwnerMuted(),trackId:t.getTrackId()})},onAudioMuteChange:function(t){e._onAudioMuteChange({fromUserId:t.getUserId(),muted:t.isOwnerMuted(),trackId:t.getTrackId()})},onRTCPeerConnectionCloseByException:this._onRTCPeerConnectionCloseByException.bind(this)}),this._room.registerReportListener({onStateReport:this._onRTCStateReport.bind(this)}),this._room.onAudioLevelChange(function(t){e._reportAppEventModule.onUserAudioLevelChanged(t)})}}),Object.defineProperty(r.prototype,"_onLocalTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._reportAppEventModule.onUserMediaAvailable(e,t)}}),Object.defineProperty(r.prototype,"_onRemoteTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._reportAppEventModule.onUserMediaAvailable(e),this.emit(r.__INNER_RECEIVE_FIRST_FRAME__)}}),Object.defineProperty(r.prototype,"_onKickOff",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,i,n){this._logger.info(D.L_RTC_MODULE_RECEIVE_KICK_OFF_O,"roonId: ".concat(t,", byServer: ").concat(e,", state: ").concat(i,", kickExtra: ").concat(JSON.stringify(n)));var o=B.CONNECTION_ERR;if(e)if(n)o=n.kickReasonCode;else switch(i){case R.SERVER_KICK:o=B.KICKED_BY_SERVER;break;case R.OTHER_KICK:o=B.OTHER_CLIENT_JOINED;break;case R.IM_DISCONNECTED:o=B.CONNECTION_ERR;break;case R.IM_LOGOUT:o=B.LOGOUT;break;case R.OTHER_CLIENT_IM_CONNECTED:o=B.OTHER_CLIENT_LOGIN}this.emit(r.__INNER_ON_KICKOFF__,o,t)}}),Object.defineProperty(r.prototype,"_onRTCPeerConnectionCloseByException",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._logger.createTraceId();this._logger.info(D.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O,"",e),this.emit(r.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,e)}}),Object.defineProperty(r.prototype,"_onSelfJoined",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,i){return y(this,void 0,void 0,function(){return P(this,function(n){return this.emit(r.__INNER_ON_SELF_JOINED__,e,t,i),[2]})})}}),Object.defineProperty(r.prototype,"_onRemoteTrackPublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=this._logger.createTraceId();this._logger.info(D.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map(function(e){return e.getTrackId()})}),r);var i=[];e.forEach(function(e){var r,n=e.getUserId();if(e.isAudioTrack())i.push({track:e,subTiny:!1}),t._reportAppEventModule.onRemoteMicrophoneStateChanged(t._callId,e);else if(t._reportAppEventModule.onRemoteCameraStateChanged(t._callId,e),null===(r=t._userViewMap[n])||void 0===r?void 0:r.videoView){var o=t._userViewMap[n].isTiny;i.push({track:e,subTiny:o})}}),i.length&&this.subscribeTracks(i,r)}}),Object.defineProperty(r.prototype,"_onTrackUnpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t;return P(this,function(r){switch(r.label){case 0:return t=this._logger.createTraceId(),this._logger.info(D.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map(function(e){return e.getTrackId()})}),t),[4,this.unsubscribeTracks(e,t)];case 1:return r.sent(),[2]}})})}}),Object.defineProperty(r.prototype,"_onAudioMuteChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._logger.createTraceId();this._logger.info(D.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);var r=this._room.getRemoteTrack(e.trackId);this._reportAppEventModule.onRemoteMicrophoneStateChanged(this._callId,r)}}),Object.defineProperty(r.prototype,"_onVideoMuteChagne",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._logger.createTraceId();this._logger.info(D.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);var r=this._room.getRemoteTrack(e.trackId);this._reportAppEventModule.onRemoteCameraStateChanged(this._callId,r)}}),Object.defineProperty(r.prototype,"_onRTCStateReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=e.senders,i=e.receivers;r.forEach(function(e){var r,i=e.kind,n=e.packetsLostRate,o=e.rtt;t._callMediaType===V.AUDIO_VIDEO&&"audio"===i||null===(r=t._callPlusStatusReportListener)||void 0===r||r.onSendPacketLoss(n||0,o||0)}),i.forEach(function(e){var r,i=e.trackId,n=e.kind,o=e.packetsLostRate,a=e.bitrate;if(t._callMediaType!==V.AUDIO_VIDEO||"audio"!==n){var _={};_[b.parseTrackId(i).userId]={packetLostRate:o||0,bitRate:a},null===(r=t._callPlusStatusReportListener)||void 0===r||r.onReceivePacketLoss(_)}})}}),Object.defineProperty(r.prototype,"_onRTCMethodFail",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.emit(r.__INNER_RTC_PROCESS_FAILED__,e,t)}}),Object.defineProperty(r.prototype,"_onOtherMemJoined",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.emit(r.__INNER_ON_OTHER_JOINED__,e,t)}}),Object.defineProperty(r.prototype,"_createAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r,i,n,o,a,_;return P(this,function(l){switch(l.label){case 0:return this._logger.info(D.L_RTC_MODULE_CREATE_AUDIO_TRACK_T,"",e),t=Object.assign(this._audioConfig,{micphoneId:this._audioConfig.microphoneId}),[4,this._rtcClient.createMicrophoneAudioTrack(Ue.NORMAL,t)];case 1:return r=l.sent(),i=r.code,n=r.track,i!==h.SUCCESS?(this._logger.error(D.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,"errCode: ".concat(i),e),[2,{code:i}]):(this._logger.info(D.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,"success",e),o=this._audioConfig,a=o.minBitrate,_=o.maxBitrate,(a||_)&&n.setBitrate(_,a),this._localTracks.push(n),this._onLocalTrackReady([n],e),[2,{code:w.SUCCESS,track:n}])}})})}}),Object.defineProperty(r.prototype,"_createVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r,i,n,o,a;return P(this,function(_){switch(_.label){case 0:return this._logger.info(D.L_RTC_MODULE_CREATE_VIDEO_TRACK_T,"",e),[4,this._rtcClient.createCameraVideoTrack(Ue.NORMAL,this._videoConfig)];case 1:return t=_.sent(),r=t.code,i=t.track,r!==h.SUCCESS?(this._logger.error(D.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,"errCode: ".concat(r),e),[2,{code:r}]):(this._logger.info(D.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,"success",e),n=this._videoConfig,o=n.minBitrate,a=n.maxBitrate,(o||a)&&i.setBitrate(a,o),this._localTracks.push(i),this._onLocalTrackReady([i],e),[2,{code:w.SUCCESS,track:i}])}})})}}),Object.defineProperty(r.prototype,"getLocalVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return this._localTracks&&(e=U(this._localTracks.filter(function(e){return e.isVideoTrack()}),1)[0]),e}}),Object.defineProperty(r.prototype,"getLocalAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return this._localTracks&&(e=U(this._localTracks.filter(function(e){return e.isAudioTrack()}),1)[0]),e}}),Object.defineProperty(r.prototype,"publish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r;return P(this,function(i){switch(i.label){case 0:return this._logger.info(D.L_RTC_MODULE_PUBLISH_T,"tracksIds: ".concat(e.map(function(e){return e instanceof O?e.getTrackId():e.track.getTrackId()})),t),[4,Se({asyncFn:this._room.publish.bind(this._room),fnArgs:[e],onError:function(e){}})];case 1:return(r=i.sent().code)!==h.SUCCESS?(this._onRTCMethodFail(B.PUBLISH_ERR,t),this._logger.error(D.L_RTC_MODULE_PUBLISH_R,"errCode: ".concat(r),t),[2,{code:r}]):(this._logger.info(D.L_RTC_MODULE_PUBLISH_R,"code: ".concat(w.SUCCESS),t),[2,{code:w.SUCCESS}])}})})}}),Object.defineProperty(r.prototype,"publishVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getLocalVideoTrack(),t=this._isPubTiny?{track:e,isPubTiny:!0}:e;return this._room.publish([t])}}),Object.defineProperty(r.prototype,"setVideoView",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,i=[];e.forEach(function(e){var t=e.userId,n=e.videoElement,o=e.isTiny,a=void 0!==o&&o;if(r._userViewMap[t]={videoView:n,isTiny:a},t!==r._context.getCurrentId()&&r._room){var _=(r.getRemoteTracks()[t]||[]).map(function(e){return{track:e,subTiny:a}});i.push.apply(i,M([],U(_),!1))}}),this._logger.info(D.L_RTC_MODULE_SET_VIDEO_VIEW_O,JSON.stringify({userViewMap:z(this._userViewMap),needSubTrackIds:i.map(function(e){return e.track.getTrackId()})}),t),i.length&&this.subscribeTracks(i,t)}}),Object.defineProperty(r.prototype,"removeVideoView",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,i=[];e.forEach(function(e){var t=r.getRemoteTracks()[e];if(t&&t.length){var n=t.filter(function(e){return e.isVideoTrack()});n.length&&i.push(n[0])}delete r._userViewMap[e]}),this._logger.info(D.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O,JSON.stringify({userViewMap:z(this._userViewMap),unsubTracks:i.map(function(e){return e.getTrackId()})}),t),i.length&&this.unsubscribeTracks(i,t)}}),Object.defineProperty(r.prototype,"getUserViewMap",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._userViewMap}}),Object.defineProperty(r.prototype,"playMedia",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var n;return y(this,void 0,void 0,function(){var o,a,_,l,s;return P(this,function(c){switch(c.label){case 0:if(this._logger.info(D.L_RTC_MODULE_PLAY_MEDIA_T,"userId: ".concat(e,", mediaType: ").concat(t,", videoView: ").concat(null==r?void 0:r.nodeName),i),o=this._context.getCurrentId(),e===o&&t===V.AUDIO)return this._logger.error(D.L_RTC_MODULE_PLAY_MEDIA_R,"please avoid playing local audio to prevent echoes.",i),[2,{code:w.PLAY_MEDIA_FAILED}];if(a=null,!(a=e===o?t===V.AUDIO?null:this.getLocalVideoTrack():null===(n=this.getRemoteTracks()[e])||void 0===n?void 0:n.filter(function(e){return t===V.AUDIO?e.isAudioTrack():e.isVideoTrack()})[0]))return this._logger.error(D.L_RTC_MODULE_PLAY_MEDIA_R,"error code: ".concat(w.MEDIA_RESOURCE_INVALIED),i),[2,{code:w.MEDIA_RESOURCE_INVALIED}];c.label=1;case 1:return c.trys.push([1,6,,7]),a.isAudioTrack()?[4,a.play(void 0,{audioDeviceId:this._audioOutputDeviceId||void 0})]:[3,3];case 2:return l=c.sent(),[3,5];case 3:return[4,a.play(r)];case 4:l=c.sent(),c.label=5;case 5:return _=l.code,a.isAudioTrack()&&!this._remoteAudioEnable&&a.mute(),_!==h.SUCCESS?(this._logger.error(D.L_RTC_MODULE_PLAY_MEDIA_R,"errCode: ".concat(_),i),[2,{code:_}]):(this._logger.info(D.L_RTC_MODULE_PLAY_MEDIA_R,"success",i),[2,{code:w.SUCCESS}]);case 6:return s=c.sent(),this._logger.error(D.L_RTC_MODULE_PLAY_MEDIA_R,"errCode: ".concat(w.PLAY_MEDIA_FAILED,", message: ").concat(s.message,","),i),[2,{code:w.PLAY_MEDIA_FAILED}];case 7:return[2]}})})}}),Object.defineProperty(r,"__INNER_RTC_PROCESS_FAILED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-process-failed"}),Object.defineProperty(r,"__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-peerconnection-abnormal-close"}),Object.defineProperty(r,"__INNER_ON_SELF_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-self-joined"}),Object.defineProperty(r,"__INNER_ON_OTHER_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-other-joined"}),Object.defineProperty(r,"__INNER_RECEIVE_FIRST_FRAME__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-receive-first-frame"}),Object.defineProperty(r,"__INNER_ON_KICKOFF__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-kickoff-frame"}),r}(n),je=function(){function e(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})}return Object.defineProperty(e.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._listener=e}}),Object.defineProperty(e.prototype,"_callAppListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return y(this,void 0,void 0,function(){var i,n;return P(this,function(o){switch(o.label){case 0:if(!(i=null===(t=this._listener)||void 0===t?void 0:t[e]))return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,i.apply(void 0,M([],U(r),!1))];case 2:return o.sent(),[3,4];case 3:return n=o.sent(),console.error(n),this._logger.error(D.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({name:n.name,message:n.message})),[3,4];case 4:return[2]}})})}}),Object.defineProperty(e.prototype,"onReceivedCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(D.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCall",callId:e.getCallId()}),t),this._callAppListener("onReceivedCall",e,r)}}),Object.defineProperty(e.prototype,"onRemoteUserInvited",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(D.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserInvited",inviteeUserList:e,inviterUserId:t,callId:r})),this._callAppListener("onRemoteUserInvited",e,t,r)}}),Object.defineProperty(e.prototype,"onCallConnected",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(D.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallConnected",callId:e.getCallId()})),this._callAppListener("onCallConnected",e)}}),Object.defineProperty(e.prototype,"onCallTypeChanged",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(D.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallTypeChanged",callId:t,callType:e}),r),this._callAppListener("onCallTypeChanged",e,t)}}),Object.defineProperty(e.prototype,"onRemoteUserStateChanged",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.callId,i=e.userId,n=e.userState,o=e.reason;this._logger.info(D.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserStateChanged",callId:r,userId:i,userState:n,reason:o}),t),this._callAppListener("onRemoteUserStateChanged",r,i,n,o)}}),Object.defineProperty(e.prototype,"onCallEnded",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(D.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallEnded",callId:e.getCallId(),closeReason:t}),r),this._callAppListener("onCallEnded",e,t)}}),Object.defineProperty(e.prototype,"onRemoteCameraStateChanged",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(D.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()}));var r=null==t?void 0:t.getUserId();this._callAppListener("onRemoteCameraStateChanged",e,r,null==t?void 0:t.isOwnerMuted())}}),Object.defineProperty(e.prototype,"onRemoteMicrophoneStateChanged",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(D.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()}));var r=null==t?void 0:t.getUserId();this._callAppListener("onRemoteMicrophoneStateChanged",e,r,null==t?void 0:t.isOwnerMuted())}}),Object.defineProperty(e.prototype,"onReceivedCallRecord",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(D.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallRecord",record:e}),t),this._callAppListener("onReceivedCallRecord",e)}}),Object.defineProperty(e.prototype,"onReceivedChangeMediaTypeRequest",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){this._logger.info(D.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeRequest",userId:e,transactionId:t}),i),this._callAppListener("onReceivedChangeMediaTypeRequest",e,t,r)}}),Object.defineProperty(e.prototype,"onReceivedChangeMediaTypeResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.userId,i=e.transactionId,n=e.mediaType,o=e.code;this._logger.info(D.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeResult",userId:r,mediaType:n}),t),this._callAppListener("onReceivedChangeMediaTypeResult",{userId:r,transactionId:i,mediaType:n,code:o})}}),Object.defineProperty(e.prototype,"onReceivedCallStartTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(D.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallStartTime",info:e}),t),this._callAppListener("onReceivedCallStartTime",e)}}),Object.defineProperty(e.prototype,"onReceivedCallFirstFrameTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(D.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallFirstFrameTime",callId:e,callFirstFrameTime:t}),r),this._callAppListener("onReceivedCallFirstFrameTime",e,t)}}),Object.defineProperty(e.prototype,"onUserMediaAvailable",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;this._logger.info(D.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onUserMediaAvailable",trackIds:e.map(function(e){return e.getTrackId()})}),t),e.forEach(function(e){var t=e.getUserId(),i=e.isAudioTrack()?V.AUDIO:V.VIDEO;r._callAppListener("onUserMediaAvailable",t,i)})}}),Object.defineProperty(e.prototype,"onFetchRemoteMediaError",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;e.forEach(function(e){var i=e.track.getUserId();r._callAppListener("onFetchRemoteMediaError",i,t)})}}),Object.defineProperty(e.prototype,"onUserAudioLevelChanged",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.forEach(function(e){var r=e.track,i=e.audioLevel,n=r.getUserId();t._callAppListener("onUserAudioLevelChanged",n,i)})}}),Object.defineProperty(e.prototype,"onReceivedCallPlusSummaryMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._callAppListener("onReceivedCallPlusSummaryMessage",e)}}),Object.defineProperty(e.prototype,"onReceivedGroupCallStatusMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._callAppListener("onReceivedGroupCallStatusMessage",e)}}),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"}(De||(De={}));var Ge=function(){function e(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_androidPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}return Object.defineProperty(e.prototype,"setChannelIdMi",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.channelIdMi=e,this):(this._logger.error(D.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: channelIdMi type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setMiLargeIconUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._logger.warn(D.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"`setMiLargeIconUrl` has been deprecated."),this}}),Object.defineProperty(e.prototype,"setChannelIdHW",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.channelIdHW=e,this):(this._logger.error(D.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: channelIdHW type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setCategoryHW",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.categoryHW=e,this):(this._logger.error(D.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: categoryHW type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setImportanceHW",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(D.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: importanceHW value is NORMAL|LOW, value: ".concat(e)),this):(this._androidPushConfig.importanceHW=e,this)}}),Object.defineProperty(e.prototype,"setImageUrlHW",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.imageUrlHW=e,this):(this._logger.error(D.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: imageUrlHW type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setChannelIdOPPO",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.channelIdOPPO=e,this):(this._logger.error(D.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: channelIdOPPO type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setTypeVivo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.typeVivo=e,this):(this._logger.error(D.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: typeVivo type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setCategoryVivo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.categoryVivo=e,this):(this._logger.error(D.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: categoryVivo type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setFcmChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.fcmChannelId=e,this):(this._logger.error(D.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: fcmChannelId type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setFcmCollapseKey",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.fcmCollapseKey=e,this):(this._logger.error(D.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: fcmCollapseKey type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setFcmImageUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.fcmImageUrl=e,this):(this._logger.error(D.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: fcmImageUrl type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"setimportanceHonor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(D.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: importanceHonor value is NORMAL|LOW, value: ".concat(e)),this):(this._androidPushConfig.importanceHonor=e,this)}}),Object.defineProperty(e.prototype,"setimageUrlHonor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return i(e)?(this._androidPushConfig.imageUrlHonor=e,this):(this._logger.error(D.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"errorMsg: imageUrlHonor type is string, value: ".concat(e)),this)}}),Object.defineProperty(e.prototype,"build",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._androidPushConfig}}),e}(),Ve=function(){function n(e,t,r,i){var n=this;Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:p.W640_H480,frameRate:f.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 je(t),this._callPlusStatistics=new ue(this._logger,this._context),this._callEngine=new Me(this._context,this._runtime,this._initOpts,this._logger,this._reportAppEventModule),this._rtcModule=new we(this._context,this._runtime,this._initOpts,this._logger,this._callEngine,this._reportAppEventModule),this._callEngine.setRTCModule(this._rtcModule),this._rtcModule.on(we.__INNER_RTC_PROCESS_FAILED__,this._rtcProcessFailHandle.bind(this)),this._rtcModule.on(we.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,this._peerConnectionAbnormalClose.bind(this)),this._rtcModule.on(we.__INNER_ON_SELF_JOINED__,this._selfJoinedHandle.bind(this)),this._rtcModule.on(we.__INNER_ON_OTHER_JOINED__,this._otherJoinedHandle.bind(this)),this._rtcModule.on(we.__INNER_RECEIVE_FIRST_FRAME__,this._receiveFirstFrameHandle.bind(this)),this._rtcModule.on(we.__INNER_ON_KICKOFF__,this._kickoffHandle.bind(this)),this._callEngine.on(Me.__INNER_SESSION_CONNECT__,this._rtcModule.sessionConnected.bind(this._rtcModule)),this._callEngine.on(Me.__INNER_SESSION_CLOSE__,this._sessionCloseHandle.bind(this)),this._callEngine.on(Me.__INNER_CHANGE_MEDIA_TYPE__,this._rtcModule.changeMediaType.bind(this._rtcModule)),this._callEngine.on(Me.__INNER_INVITE__,function(e,t){n._callPlusStatistics.reportStatisticsData(Y.L_QS_RECEIVE_CALL_S,w.SUCCESS,+new Date,e,"",t)})}return Object.defineProperty(n.prototype,"_rtcProcessFailHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this._callEngine.getLocalMainSession();if(r){var i=r.getCallId();this._callEngine.systemStatusUp({callId:i,sysStatus:e,forward:me.CURRENT},t),this._callPlusStatistics.reportStatisticsData(Y.L_QS_ABNORMAL_HANGUP_S,w.SUCCESS,+new Date,r),this.__innerHangup({callId:i,systemState:e},t)}}}),Object.defineProperty(n.prototype,"_peerConnectionAbnormalClose",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._callEngine.getLocalMainSession();t&&(this._callEngine.systemStatusUp({callId:t.getCallId(),sysStatus:B.CONNECTION_ERR,forward:me.CURRENT},e),this._callEngine.endCurrentSession(B.CONNECTION_ERR,t.getCallId(),e))}}),Object.defineProperty(n.prototype,"_selfJoinedHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return y(this,void 0,void 0,function(){var i,n,o,a;return P(this,function(_){return i=this._context.getCurrentId(),((null==(n=this._callEngine.getLocalMainSession())?void 0:n.getCallType())===j.MULTI||t.length)&&this._callEngine.updateMainSessionState(H.ONCALL),o=M([i],U(t),!1).map(function(e){return{userId:e,userState:G.ONCALL,systemState:B.ONCALL}}),a=this._callEngine.updateUsersState(e,o,r),this._reportAppEventModule.onCallConnected(n),a.length>0&&this._callEngine.reportRemoteUserStateChange(e,a,r),this._callEngine.startTimeCorrection(r),[2]})})}}),Object.defineProperty(n.prototype,"_otherJoinedHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i="",n=e.map(function(e){return i=e.callId,{userId:e.userId,userState:G.ONCALL,systemState:B.ONCALL}}),o=this._callEngine.updateUsersState(i,n,t);o.length>0&&this._callEngine.reportRemoteUserStateChange(i,o,t),(null===(r=this._callEngine.getLocalMainSession())||void 0===r?void 0:r.getState())!==H.ONCALL&&this._callEngine.updateMainSessionState(H.ONCALL)}}),Object.defineProperty(n.prototype,"_receiveFirstFrameHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;(null===(t=this._callEngine.getLocalMainSession())||void 0===t?void 0:t.getState())!==H.ONCALL&&this._callEngine.updateMainSessionState(H.ONCALL),this._callEngine.upFirstFrameTime(e)}}),Object.defineProperty(n.prototype,"_kickoffHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){if(e!==B.CONNECTION_ERR){var i=this._callEngine.getLocalMainSession();if(i){var n=i.getCallId();this._callPlusStatistics.reportStatisticsData(Y.L_QS_ABNORMAL_HANGUP_S,w.SUCCESS,+new Date,i,this._clientCallId),this._callEngine.systemStatusUp({callId:n,sysStatus:e,forward:me.CURRENT},r),this._callEngine.endCurrentSession(e,t,r)}}else this._callEngine.endCurrentSession(e,t,r)}}),Object.defineProperty(n.prototype,"_sessionCloseHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._isLaunchHangup||(this._clientCallId=""),this._isLaunchHangup=!1,this._rtcModule.sessionClose(e,t)}}),Object.defineProperty(n.prototype,"setCallPlusEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(D.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._reportAppEventModule.registerEventListener(e)}}),Object.defineProperty(n.prototype,"setStatusReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(D.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._rtcModule.setCallPlusStatusReportListener(e)}}),Object.defineProperty(n.prototype,"setVideoView",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,i=this._logger.createTraceId();if(this._logger.info(D.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T,JSON.stringify({list:e.map(function(e){var t=e.userId,r=e.videoElement,i=e.isTiny;return{userId:t,elementName:null==r?void 0:r.nodeName,isTiny:i}})}),i),!C(e))return this._logger.error(D.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"params err, list: not empty array, value: ".concat(JSON.stringify(e)),i),{code:w.PARAM_ERROR};try{for(var n=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),o=n.next();!o.done;o=n.next()){var a=o.value,_=a.userId,l=a.videoElement;if(!T(_))return this._logger.error(D.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"params err, userId: not empty string, value: ".concat(_),i),{code:w.PARAM_ERROR};if(!Q(l))return this._logger.error(D.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"params err, videoElement: need a video element, value: ".concat(l instanceof HTMLElement?l.nodeName:l),i),{code:w.PARAM_ERROR}}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return this._logger.info(D.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"succes",i),this._rtcModule.setVideoView(e,i),{code:w.SUCCESS}}}),Object.defineProperty(n.prototype,"removeVideoView",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._logger.createTraceId();return this._logger.info(D.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T,JSON.stringify({userIds:e}),t),C(e)&&e.every(function(e){return T(e)})?(this._logger.info(D.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,"succes",t),this._rtcModule.removeVideoView(e,t),{code:w.SUCCESS}):(this._logger.error(D.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,"params err, userIds: not empty array, userId: not empty string, value: ".concat(JSON.stringify(e)),t),{code:w.PARAM_ERROR})}}),Object.defineProperty(n.prototype,"playMedia",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var i,n;return P(this,function(o){return i=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_PLAY_MEDIA_T,JSON.stringify({userId:e,mediaType:t}),i),T(e)?r(V[t])?(this._logger.error(D.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"params err, mediaType is illegal, value: ".concat(t),i),[2,{code:w.PARAM_ERROR}]):t===V.AUDIO&&e===this._context.getCurrentId()?(this._logger.info(D.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"success",i),[2,{code:w.SUCCESS}]):(n=(this._rtcModule.getUserViewMap()[e]||{}).videoView,t===V.AUDIO||n?[2,this._rtcModule.playMedia(e,t,n,i)]:(this._logger.error(D.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"errCode: ".concat(w.VIDEO_VIEW_NOT_SET,", video view not set"),i),[2,{code:w.VIDEO_VIEW_NOT_SET}])):(this._logger.error(D.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"params err, userId: not empty string, value: ".concat(e),i),[2,{code:w.PARAM_ERROR}])})})}}),Object.defineProperty(n.prototype,"createVideoConfigBuilder",{enumerable:!1,configurable:!0,writable:!0,value:function(){return new W(this._logger)}}),Object.defineProperty(n.prototype,"setVideoConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(D.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T,JSON.stringify(e));var t=e.frameRate,r=e.resolution,i=e.maxBitrate,n=e.minBitrate;if(!f[t])return this._logger.error(D.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"param error, frameRate is illegal, value: ".concat(t)),{code:w.PARAM_ERROR};if(!p[r])return this._logger.error(D.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"param error, resolution is illegal, value: ".concat(r)),{code:w.PARAM_ERROR};var o=X(n,i),a=o.code,_=o.errorMsg;return a!==w.SUCCESS&&this._logger.error(D.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,_),this._logger.info(D.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"success"),this._videoConfig=v({},e),this._rtcModule.setVideoConfig(this._videoConfig),{code:w.SUCCESS}}}),Object.defineProperty(n.prototype,"createAudioConfigBuilder",{enumerable:!1,configurable:!0,writable:!0,value:function(){return new J(this._logger)}}),Object.defineProperty(n.prototype,"createAndroidPushConfigBuilder",{enumerable:!1,configurable:!0,writable:!0,value:function(){return new Ge(this._logger)}}),Object.defineProperty(n.prototype,"setAudioConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this._logger.info(D.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T,JSON.stringify(t));var r=t.sampleRate,i=t.minBitrate,n=t.maxBitrate;if(r&&!e(r))return this._logger.error(D.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,"param error, sampleRate: type is number, value: ".concat(r)),{code:w.PARAM_ERROR};var o=X(i,n),a=o.code,_=o.errorMsg;return a!==w.SUCCESS&&this._logger.error(D.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,_),this._logger.info(D.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,"success"),this._audioConfig=v({},t),this._rtcModule.setAudioConfig(this._audioConfig),{code:w.SUCCESS}}}),Object.defineProperty(n.prototype,"setAudioOutputDeviceId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._logger.info(D.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O,e),this._rtcModule.setAudioOutputDeviceId(e)}}),Object.defineProperty(n.prototype,"startCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,o,a,l){return void 0===t&&(t=j.SINGLE),void 0===n&&(n=V.AUDIO_VIDEO),y(this,void 0,void 0,function(){var s,u,L,d,E,I,g,S,f,p,h;return P(this,function(R){switch(R.label){case 0:if(this._clientCallId=c(),s=+new Date,u=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_START_CALL_T,"userIds: ".concat(e.join(","),", callType: ").concat(t,", mediaType: ").concat(n,", pushConfig: ").concat(o,", extra: ").concat(a),u),this._context.getConnectionStatus()!==_.CONNECTED)return this._logger.error(D.L_CALLPLUS_CLIENT_START_CALL_R,"errCode: ".concat(w.SIGNAL_DISCONNECTED),u),[2,{code:w.SIGNAL_DISCONNECTED}];if(!(L=this._context.getNaviInfo())||!q(L))return this._logger.error(D.L_CALLPLUS_CLIENT_START_CALL_R,"errCode: ".concat(w.RTC_SERVICE_UNAVAILABLE),u),[2,{code:w.RTC_SERVICE_UNAVAILABLE}];if(!C(e)||!e.every(function(e){return T(e)}))return this._logger.error(D.L_CALLPLUS_CLIENT_START_CALL_R,"params err, userIds: not empty array, userId: not empty string, value: ".concat(JSON.stringify(e)),u),[2,{code:w.PARAM_ERROR}];if(r(j[t]))return this._logger.error(D.L_CALLPLUS_CLIENT_START_CALL_R,"params err, callType is illegal, value: ".concat(t),u),[2,{code:w.PARAM_ERROR}];if(r(V[n]))return this._logger.error(D.L_CALLPLUS_CLIENT_START_CALL_R,"params err, mediaType is illegal, value: ".concat(n),u),[2,{code:w.PARAM_ERROR}];if(o&&(d=ee(o)).code!==w.SUCCESS)return this._logger.error(D.L_CALLPLUS_CLIENT_START_CALL_R,"params err, pushConfig is illegal, msg: ".concat(d.errorMsg),u),[2,{code:w.PARAM_ERROR}];if(a){if(!i(a))return this._logger.error(D.L_CALLPLUS_CLIENT_START_CALL_R,"params err, extra is illegal, type: string, value: ".concat(a),u),[2,{code:w.PARAM_ERROR}];if(ie(a)>he)return this._logger.error(D.L_CALLPLUS_CLIENT_START_CALL_R,"params err, extra max size is 128KB",u),[2,{code:w.PARAM_ERROR}]}return e.length>1&&t===j.SINGLE?(this._logger.error(D.L_CALLPLUS_CLIENT_START_CALL_R,"params err, You can only call one person in a single call, userIds: ".concat(e.join(",")),u),[2,{code:w.PARAM_ERROR}]):l&&!i(l)?(this._logger.error(D.L_CALLPLUS_CLIENT_START_CALL_R,"params err, targetId is illegal, type: string, value: ".concat(l),u),[2,{code:w.PARAM_ERROR}]):this._callEngine.getLocalMainSession()?(this._logger.error(D.L_CALLPLUS_CLIENT_START_CALL_R,"errCode: ".concat(w.SESSION_EXIST,", session exist"),u),[2,{code:w.SESSION_EXIST}]):[4,this._rtcModule.createCallMediaTracks(n,u)];case 1:return(E=R.sent().code)!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_START_CALL_R,"create meida tracks error code: ".concat(E),u),[2,{code:E}]):[4,this._callEngine.startCall({toUsers:e.map(function(e){return{userId:e}}),callType:t,mediaType:n,callId:this._clientCallId,pushConfig:o,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:a}),targetId:l},u)];case 2:return I=R.sent(),g=I.code,S=I.data,this._callPlusStatistics.reportStatisticsData(Y.L_QS_START_CALL_S,g,s,null,this._clientCallId,null,{mediaType:n,callType:t,callId:(null==S?void 0:S.callId)||""}),g!==w.SUCCESS?(this._rtcModule.destroyAllTracks(u),this._logger.error(D.L_CALLPLUS_CLIENT_START_CALL_R,"signal error code: ".concat(g),u),[2,{code:g}]):(p=(f=S).callId,h=f.clientCallId,this._needHangupCallId===h?(this._callEngine.clearAllTimer(p,u),this._callEngine.hangup({callId:p,systemState:B.CANCELLED},u),this._logger.info(D.L_CALLPLUS_CLIENT_START_CALL_R,"the ".concat(p," call has been hangup"),u),[2,{code:w.SUCCESS}]):(t===j.MULTI&&this._rtcModule.sessionConnected(p,u),this._logger.info(D.L_CALLPLUS_CLIENT_START_CALL_R,JSON.stringify({data:S,code:g}),u),[2,{code:w.SUCCESS,callId:p}]))}})})}}),Object.defineProperty(n.prototype,"joinMultiCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r,i,n,o,a,l,s,c;return P(this,function(u){switch(u.label){case 0:return t=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T,"callId: ".concat(e),t),this._context.getConnectionStatus()!==_.CONNECTED?(this._logger.error(D.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"code: ".concat(w.SIGNAL_DISCONNECTED),t),[2,{code:w.SIGNAL_DISCONNECTED}]):(r=this._context.getNaviInfo())&&q(r)?T(e)?[4,this._callEngine.getCallSession({callId:e},t)]:(this._logger.error(D.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"params err, callId: not empty string, value: ".concat(e),t),[2,{code:w.PARAM_ERROR}]):(this._logger.error(D.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"code: ".concat(w.RTC_SERVICE_UNAVAILABLE),t),[2,{code:w.RTC_SERVICE_UNAVAILABLE}]);case 1:return i=u.sent(),n=i.code,o=i.data,n!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"get call data error, code: ".concat(n),t),[2,{code:n}]):(a=o.mediaType,(l=this._callEngine.getLocalMainSession())&&l.getCallId()!==e?[2,{code:w.SESSION_EXIST}]:[4,this._rtcModule.createCallMediaTracks(a,t)]);case 2:return(s=u.sent().code)!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"create meida tracks error code: ".concat(s),t),[2,{code:s}]):[4,this._callEngine.joinCall({callId:e,mediaType:a},t)];case 3:return(c=u.sent().code)!==w.SUCCESS?(this._rtcModule.destroyAllTracks(t),this._logger.error(D.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"signal error code: ".concat(c),t),[2,{code:c}]):(this._logger.info(D.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,"code: ".concat(w.SUCCESS),t),[4,this._rtcModule.sessionConnected(e,t)]);case 4:return u.sent(),[2,{code:w.SUCCESS}]}})})}}),Object.defineProperty(n.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n;return y(this,void 0,void 0,function(){var o,a,_,l,s,c;return P(this,function(u){switch(u.label){case 0:if(o=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_INVITE_T,"callId: ".concat(e.join(","),", pushConfig: ").concat(t,", extra: ").concat(r),o),!C(e)||!e.every(function(e){return T(e)}))return this._logger.error(D.L_CALLPLUS_CLIENT_INVITE_R,"params err, userIds: not empty array, userId: not empty string, value: ".concat(JSON.stringify(e)),o),[2,{code:w.PARAM_ERROR}];if(t&&(a=ee(t)).code!==w.SUCCESS)return this._logger.error(D.L_CALLPLUS_CLIENT_INVITE_R,"params err, pushConfig is illegal, msg: ".concat(a.errorMsg),o),[2,{code:w.PARAM_ERROR}];if(r){if(!i(r))return this._logger.error(D.L_CALLPLUS_CLIENT_INVITE_R,"params err, extra is illegal, value: ".concat(r),o),[2,{code:w.PARAM_ERROR}];if(ie(r)>he)return this._logger.error(D.L_CALLPLUS_CLIENT_INVITE_R,"params err, extra max size is 128KB",o),[2,{code:w.PARAM_ERROR}]}return[4,this._callEngine.invite({toUsers:e.map(function(e){return{userId:e}}),pushConfig:t,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:r})},o)];case 1:return _=u.sent(),l=_.code,s=_.data,l!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_INVITE_R,"signal error code: ".concat(l),o),[2,{code:l}]):(c=[],(null===(n=s.busylineUsers)||void 0===n?void 0:n.length)&&c.push.apply(c,M([],U(s.busylineUsers.map(function(e){return{userId:e.userId,state:e.sessionStatus}})),!1)),this._logger.info(D.L_CALLPLUS_CLIENT_INVITE_R,"success busyUsers: ".concat(JSON.stringify(c)),o),[2,{code:w.SUCCESS,busyUsers:c}])}})})}}),Object.defineProperty(n.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,i,n,o,a,l,s,c,u,L;return P(this,function(d){switch(d.label){case 0:return r=+new Date,i=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_ACCEPT_T,"callId: ".concat(e,", pushConfig: ").concat(t),i),this._context.getConnectionStatus()!==_.CONNECTED?(this._logger.error(D.L_CALLPLUS_CLIENT_ACCEPT_R,"errCode: ".concat(w.SIGNAL_DISCONNECTED),i),[2,{code:w.SIGNAL_DISCONNECTED}]):(n=this._context.getNaviInfo())&&q(n)?T(e)?t&&(o=ee(t)).code!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_ACCEPT_R,"params err, pushConfig is illegal, msg: ".concat(o.errorMsg),i),[2,{code:w.PARAM_ERROR}]):(a=this._callEngine.getLocalMainSession(),l=this._callEngine.getHoldSession(e),a||l?e===(null==l?void 0:l.getCallId())?[4,this.hangup(a.getCallId())]:[3,2]:(this._logger.error(D.L_CALLPLUS_CLIENT_ACCEPT_R,"errCode : ".concat(w.NOT_IN_CALL,", session not exist"),i),[2,{code:w.NOT_IN_CALL}])):(this._logger.error(D.L_CALLPLUS_CLIENT_ACCEPT_R,"params err, callId: not empty string, value: ".concat(e),i),[2,{code:w.PARAM_ERROR}]):(this._logger.error(D.L_CALLPLUS_CLIENT_ACCEPT_R,"errCode: ".concat(w.RTC_SERVICE_UNAVAILABLE),i),[2,{code:w.RTC_SERVICE_UNAVAILABLE}]);case 1:if((s=d.sent().code)!==w.SUCCESS)return this._logger.error(D.L_CALLPLUS_CLIENT_ACCEPT_R,"hangup mainSession error code: ".concat(s),i),[2,{code:s}];this._callEngine.upgradeMainSession(e),a=this._callEngine.getLocalMainSession(),d.label=2;case 2:return c=a.getMediaType(),[4,this._rtcModule.createCallMediaTracks(c,i)];case 3:return(u=d.sent().code)!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_ACCEPT_R,"create meida tracks error code: ".concat(u),i),[2,{code:u}]):[4,this._callEngine.accept({callId:e},i)];case 4:return L=d.sent().code,this._callPlusStatistics.reportStatisticsData(Y.L_QS_ACCEPT_CALL_S,L,r,a),L!==w.SUCCESS?(this._rtcModule.destroyAllTracks(i),this._logger.error(D.L_CALLPLUS_CLIENT_ACCEPT_R,"signal error code: ".concat(L),i),[2,{code:L}]):(this._logger.info(D.L_CALLPLUS_CLIENT_ACCEPT_R,"success",i),this._rtcModule.sessionConnected(e,i),[2,{code:w.SUCCESS}])}})})}}),Object.defineProperty(n.prototype,"__innerHangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return y(this,void 0,void 0,function(){var i,n;return P(this,function(o){switch(o.label){case 0:return i=e.callId,this._callEngine.setIsLocalClientHangup(!0),this._callEngine.clearAllTimer(i,t),[4,this._callEngine.hangup(e,t)];case 1:return(n=o.sent().code)===De.CALL_NOT_EXIST?[2,{code:w.SUCCESS}]:n!==w.SUCCESS||i!==(null===(r=this._callEngine.getLocalMainSession())||void 0===r?void 0:r.getCallId())?[3,3]:[4,this._rtcModule.sessionClose(i,t)];case 2:o.sent(),o.label=3;case 3:return[2,{code:n}]}})})}}),Object.defineProperty(n.prototype,"hangup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return y(this,void 0,void 0,function(){var r,n,o,a,_,l,s,c,u,L,d,E;return P(this,function(C){switch(C.label){case 0:return r=+new Date,n=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_HANGUP_T,"callId: ".concat(e,", pushConfig: ").concat(t),n),(o=this._callEngine.getLocalMainSession())?e&&!i(e)?(this._logger.error(D.L_CALLPLUS_CLIENT_HANGUP_R,"params err, callId: type is string, value: ".concat(e),n),[2,{code:w.PARAM_ERROR}]):t&&(a=ee(t)).code!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_HANGUP_R,"params err, pushConfig is illegal, msg: ".concat(a.errorMsg),n),[2,{code:w.PARAM_ERROR}]):(_=o.getCallId(),e&&e!==_&&!this._callEngine.getHoldSession(e)?(this._logger.error(D.L_CALLPLUS_CLIENT_HANGUP_R,"params err, callId is invalid, value: ".concat(e),n),[2,{code:w.CALL_ID_INVALID}]):(this._isLaunchHangup=!0,this._needHangupCallId=e||_,l=this._callEngine.getHoldSession(this._needHangupCallId),s=l||o,c=this._context.getCurrentId(),u=o.getUserList().filter(function(e){return e.userId===c})[0].state,L=[o.getCreatorUserId(),o.getInviterUserId()].includes(c),d=function(e,t){var r;switch(e){case G.CALLING:r=B.CANCELLED;break;case G.RINGING:case G.INVITED:r=B.DECLINED;break;case G.CONNECTING:r=t?B.DECLINED:B.CANCELLED;break;case G.ONCALL:r=B.ENDED}return r}(u,L)||B.ENDED,[4,this.__innerHangup({callId:this._needHangupCallId,systemState:d,pushConfig:t},n)])):[2,{code:w.NOT_IN_CALL}];case 1:return E=C.sent().code,this._callPlusStatistics.reportStatisticsData(Y.L_QS_HANGUP_CALL_S,E,r,s,this._clientCallId),E!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_HANGUP_R,"signal error code : ".concat(E),n),[2,{code:E}]):(this._needHangupCallId=null,this._logger.info(D.L_CALLPLUS_CLIENT_HANGUP_R,"success",n),[2,{code:w.SUCCESS}])}})})}}),Object.defineProperty(n.prototype,"requestChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,i,n,o,a,_,l,s=this;return P(this,function(c){switch(c.label){case 0:return t=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T,"mediaType: ".concat(e),t),r(V[e])?(this._logger.error(D.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"params err, mediaType is illegal, value: ".concat(e),t),[2,{code:w.PARAM_ERROR}]):(i=this.getCurrentCallSession(),n=null==i?void 0:i.getMediaType(),e===n?(this._logger.error(D.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"error code: ".concat(w.MEDIATYPE_INVALID),t),[2,{code:w.MEDIATYPE_INVALID}]):this._callEngine.getLocalMainSession()?(o=null==i?void 0:i.getUserList().filter(function(e){return e.userId!==s._context.getCurrentId()}).map(function(e){return e.userId}),[4,this._callEngine.requestChangeMediaType({mediaType:e,toUserIds:o||[]},t)]):(this._logger.error(D.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"error code : ".concat(w.NOT_IN_CALL,", session not exist"),t),[2,{code:w.NOT_IN_CALL}]));case 1:return a=c.sent(),_=a.code,l=a.data,_!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"signal error code: ".concat(_),t),[2,{code:_}]):(this._logger.info(D.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,"success transactionId: ".concat(l.transactionId),t),[2,{code:w.SUCCESS,transactionId:l.transactionId}])}})})}}),Object.defineProperty(n.prototype,"cancelChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r;return P(this,function(i){switch(i.label){case 0:return t=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T,"transactionId: ".concat(e),t),T(e)?this._callEngine.getLocalMainSession()?[4,this._callEngine.cancelChangeMediaType({transactionId:e},t)]:(this._logger.error(D.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"error code : ".concat(w.NOT_IN_CALL,", session not exist"),t),[2,{code:w.NOT_IN_CALL}]):(this._logger.error(D.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"param error, transactionId: not empty string, value: ".concat(e),t),[2,{code:w.PARAM_ERROR}]);case 1:return(r=i.sent().code)!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"signal error code: ".concat(r),t),[2,{code:r}]):(this._logger.info(D.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"success",t),[2,{code:w.SUCCESS}])}})})}}),Object.defineProperty(n.prototype,"replyChangeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return y(this,void 0,void 0,function(){var i,n;return P(this,function(o){switch(o.label){case 0:return i=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T,"transactionId: ".concat(e),i),T(e)?t(r)?this._callEngine.getLocalMainSession()?[4,this._callEngine.responseChangeMediaType({transactionId:e,agree:r},i)]:(this._logger.error(D.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"error code : ".concat(w.NOT_IN_CALL,", session not exist"),i),[2,{code:w.NOT_IN_CALL}]):(this._logger.error(D.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"param error, isAgree: type is boolean, value: ".concat(r),i),[2,{code:w.PARAM_ERROR}]):(this._logger.error(D.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"param error, transactionId: not empty string, value: ".concat(e),i),[2,{code:w.PARAM_ERROR}]);case 1:return(n=o.sent().code)!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"signal error: ".concat(n),i),[2,{code:n}]):(this._logger.info(D.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"success",i),[2,{code:w.SUCCESS}])}})})}}),Object.defineProperty(n.prototype,"getCurrentCallSession",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callEngine.getLocalMainSession()}}),Object.defineProperty(n.prototype,"getAvailableCallRecordsFromServer",{enumerable:!1,configurable:!0,writable:!0,value:function(){return y(this,void 0,void 0,function(){var e,t,r,i;return P(this,function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T,"",e),[4,this._callEngine.getOpenCallList(e)];case 1:return t=n.sent(),r=t.code,i=t.data,r!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,"signal error code: ".concat(r),e),[2,{code:r}]):(this._logger.info(D.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,"success, data: ".concat(JSON.stringify(i)),e),[2,{code:w.SUCCESS,records:i}])}})})}}),Object.defineProperty(n.prototype,"getCallRecords",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return void 0===i&&(i=0),y(this,void 0,void 0,function(){var n,o,a,_;return P(this,function(l){switch(l.label){case 0:return n=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T,"startTimestamp: ".concat(t,", count: ").concat(r),n),e(t)&&t>=0?e(r)&&r>0?[4,this._callEngine.getCallLogList({timestamp:t,count:r,order:i},n)]:(this._logger.error(D.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"params error, count: is a number >= 0, value: ".concat(r),n),[2,{code:w.PARAM_ERROR}]):(this._logger.error(D.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"params error, startTimestamp: is a number >= 0, value: ".concat(t),n),[2,{code:w.PARAM_ERROR}]);case 1:return o=l.sent(),a=o.code,_=o.data,a!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"signal error code: ".concat(a),n),[2,{code:a}]):(this._logger.info(D.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"success",n),[2,{code:w.SUCCESS,result:_}])}})})}}),Object.defineProperty(n.prototype,"deleteCallRecordsFromServer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r;return P(this,function(i){switch(i.label){case 0:return t=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T,"callIds: ".concat(e.join(",")),t),C(e)&&e.every(function(e){return T(e)})?[4,this._callEngine.deleteCallLog(e,t)]:(this._logger.error(D.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"params err, callIds: not empty array, callId: not empty string, callIds: ".concat(JSON.stringify(e)),t),[2,{code:w.PARAM_ERROR}]);case 1:return(r=i.sent().code)!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"signal error code: ".concat(r),t),[2,{code:r}]):(this._logger.info(D.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"success",t),[2,{code:w.SUCCESS}])}})})}}),Object.defineProperty(n.prototype,"deleteAllCallRecordsFromServer",{enumerable:!1,configurable:!0,writable:!0,value:function(){return y(this,void 0,void 0,function(){var e,t;return P(this,function(r){switch(r.label){case 0:return e=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T,"",e),[4,this._callEngine.removeAllCallLog(e)];case 1:return(t=r.sent().code)!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,"signal error code: ".concat(t),e),[2,{code:t}]):(this._logger.info(D.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,"success",e),[2,{code:w.SUCCESS}])}})})}}),Object.defineProperty(n.prototype,"startCamera",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return y(this,void 0,void 0,function(){var t,r,i,n,o,a;return P(this,function(_){switch(_.label){case 0:return t=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_START_CAMERA_T,"",t),[4,this._rtcModule.getCameraVideoTrack(t)];case 1:return r=_.sent(),i=r.code,n=r.track,i!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_START_CAMERA_R,"create video track error code: ".concat(i),t),[2,{code:i}]):(null==n?void 0:n.isPublished())||(null===(e=this._callEngine.getLocalMainSession())||void 0===e?void 0:e.getState())!==H.ONCALL?[3,3]:[4,this._rtcModule.publishVideoTrack()];case 2:return(o=_.sent().code)!==h.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_START_CAMERA_R,"publish error code: ".concat(o),t),[2,{code:o}]):(this._logger.info(D.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),[2,{code:w.SUCCESS}]);case 3:return[4,this._rtcModule.enableVideoTrack(t)];case 4:return(a=_.sent().code)!==h.SUCCESS&&a!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_START_CAMERA_R,"signal error code: ".concat(a),t),[2,{code:a}]):(this._logger.info(D.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),[2,{code:w.SUCCESS}])}})})}}),Object.defineProperty(n.prototype,"stopCamera",{enumerable:!1,configurable:!0,writable:!0,value:function(){return y(this,void 0,void 0,function(){var e,t,r,i;return P(this,function(n){switch(n.label){case 0:return e=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_STOP_CAMERA_T,"",e),[4,this._rtcModule.disableVideoTrack()];case 1:return t=n.sent(),r=t.code,i=t.track,r!==w.SUCCESS&&r!==h.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_STOP_CAMERA_R,"error code: ".concat(r),e),[2,{code:r}]):(this._rtcModule.destroyTrack(i),this._logger.info(D.L_CALLPLUS_CLIENT_STOP_CAMERA_R,"success",e),[2,{code:w.SUCCESS}])}})})}}),Object.defineProperty(n.prototype,"switchCamera",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r,i;return P(this,function(n){switch(n.label){case 0:return t=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T,"cameraId: ".concat(e),t),T(e)?(r=this._callEngine.getLocalMainSession())?r.getMediaType()===V.AUDIO?(this._logger.error(D.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"errCode: ".concat(w.NOT_VIDEO_CALL),t),[2,{code:w.NOT_VIDEO_CALL}]):(this._videoConfig.cameraId=e,this._rtcModule.setVideoConfig(this._videoConfig),[4,this._rtcModule.changeVideoDevice(t)]):(this._logger.error(D.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"errCode: ".concat(w.NOT_IN_CALL),t),[2,{code:w.NOT_IN_CALL}]):(this._logger.error(D.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"param error, cameraId: not empty string, value: ".concat(e),t),[2,{code:w.PARAM_ERROR}]);case 1:return(i=n.sent().code)!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"call client changeVideoDevice error code: ".concat(i),t),[2,{code:i}]):(this._logger.info(D.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"success",t),[2,{code:w.SUCCESS}])}})})}}),Object.defineProperty(n.prototype,"startMicrophone",{enumerable:!1,configurable:!0,writable:!0,value:function(){return y(this,void 0,void 0,function(){var e,t,r,i,n;return P(this,function(o){switch(o.label){case 0:return e=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_START_MICROPHONE_T,"",e),[4,this._rtcModule.getMicrophoneAudioTrack(e)];case 1:return t=o.sent(),r=t.code,i=t.track,r!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"create microphone audio track error code: ".concat(r),e),[2,{code:r}]):i.isOwnerMuted()?[4,i.unmute()]:(this._logger.info(D.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),[2,{code:w.SUCCESS}]);case 2:return(n=o.sent())!==h.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"signal error code: ".concat(r),e),[2,{code:n}]):(this._logger.info(D.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),[2,{code:w.SUCCESS}])}})})}}),Object.defineProperty(n.prototype,"stopMicrophone",{enumerable:!1,configurable:!0,writable:!0,value:function(){return y(this,void 0,void 0,function(){var e,t;return P(this,function(r){switch(r.label){case 0:return e=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T,"",e),[4,this._rtcModule.disableAudioTrack()];case 1:return(t=r.sent().code)!==w.SUCCESS&&t!==h.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,"signal error code: ".concat(t),e),[2,{code:t}]):(this._logger.info(D.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,"success",e),[2,{code:w.SUCCESS}])}})})}}),Object.defineProperty(n.prototype,"isMicrophoneEnabled",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._rtcModule.getLocalAudioTrack();return!!e&&!e.isOwnerMuted()}}),Object.defineProperty(n.prototype,"setAllRemoteAudioEnable",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t;return P(this,function(r){return t=this._logger.createTraceId(),[2,this._rtcModule.setAllRemoteAudioEnable(e,t)]})})}}),Object.defineProperty(n.prototype,"getVersion",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"2.30.0"}}),Object.defineProperty(n.prototype,"getCameras",{enumerable:!1,configurable:!0,writable:!0,value:function(){return y(this,void 0,void 0,function(){return P(this,function(e){return[2,A.getCameras()]})})}}),Object.defineProperty(n.prototype,"getMicrophones",{enumerable:!1,configurable:!0,writable:!0,value:function(){return y(this,void 0,void 0,function(){return P(this,function(e){return[2,A.getMicrophones()]})})}}),Object.defineProperty(n.prototype,"getSpeakers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return y(this,void 0,void 0,function(){return P(this,function(e){return[2,A.getSpeakers()]})})}}),Object.defineProperty(n.prototype,"getRTCSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._rtcModule.getRTCSessionId()}}),Object.defineProperty(n.prototype,"switchMicrophone",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return y(this,void 0,void 0,function(){var t,r;return P(this,function(i){switch(i.label){case 0:return t=this._logger.createTraceId(),this._logger.info(D.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T,"microphoneId: ".concat(e),t),T(e)?this._callEngine.getLocalMainSession()?(this._audioConfig.microphoneId=e,this._rtcModule.setAudioConfig(this._audioConfig),[4,this._rtcModule.changeAudioDevice(t)]):(this._logger.error(D.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"errCode: ".concat(w.NOT_IN_CALL),t),[2,{code:w.NOT_IN_CALL}]):(this._logger.error(D.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"param error, microphoneId: not empty string, value: ".concat(e),t),[2,{code:w.PARAM_ERROR}]);case 1:return(r=i.sent().code)!==w.SUCCESS?(this._logger.error(D.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"call client changeAudioDevice error code: ".concat(r),t),[2,{code:r}]):(this._logger.info(D.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"success",t),[2,{code:w.SUCCESS}])}})})}}),n}();g.add("callplus","2.30.0");var He={tag:"RCCallPlus",verify:function(e){return!!g.validEngine("5.30.0")||(console.error("The current engine version '".concat(g.getInfo().engine,"' error, plugin-call-plus required engine version at least '").concat("5.30.0","'.")),!1)},setup:function(e,t,i){var n,o=(n=i)?I(n)?Object.keys(n).includes("rtcClient")?I(n.rtcClient)?{isLegal:!0}:{isLegal:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:{isLegal:!1,code:w.NOT_INSTALL_RTC_PLUGIN}:{isLegal:!1,msg:"Initialization options must be an object"}:{isLegal:!1,msg:"Initialization missing parameter -> options"};if(!o.isLegal)throw new Error("[CallPlusLib installer steup]".concat(o.msg));r(i.isAllowNewCallWhenRinging)&&(i.isAllowNewCallWhenRinging=!0);var a=e.createLogger("CallPlus","RTC"),_=r(i.logOutputLevel)?S.WARN:i.logOutputLevel;return a.setOutputLevel(_),a.warn(D.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O,"CallPlus Version: ".concat("2.30.0",", Commit: ").concat("35ff803e92945b8eee33503a101ca8f566a63975",", isAllowNewCallWhenRinging: ").concat(i.isAllowNewCallWhenRinging)),new Ve(e,a,t,i)}};export{x as IGroupCallStatusMessageType,J as RCAudioConfigBuilder,Ge as RCCallPlusAndroidPushConfigBuilder,H as RCCallPlusCallState,Ve as RCCallPlusClient,w as RCCallPlusCode,V as RCCallPlusMediaType,k as RCCallPlusMediaTypeChangeResult,B as RCCallPlusReason,F as RCCallPlusSession,G as RCCallPlusSessionUserState,j as RCCallPlusType,W as RCVideoConfigBuilder,He as installer};
|
|
1
|
+
import{isNumber as e,isUndefined as t,isBoolean as i,isString as _,EventEmitter as r,ErrorCode as s,getUUID22 as o,SentStatus as n,RCConnectionStatus as l,isNull as a,getUUID as c,ConversationType as L,MessageDirection as E,ReceivedStatus as d,RTCMode as C,notEmptyArray as T,notEmptyString as I,isObject as S,VersionManage as u,LogL as g}from"@rongcloud/engine";import{RCResolution as h,RCFrameRate as R,RCRTCCode as A,RCKickReason as N,helper as O,RCLocalTrack as m,device as p}from"@rongcloud/plugin-rtc";export{RCFrameRate as RCCallPlusFrameRate,RCResolution as RCCallPlusResolution}from"@rongcloud/plugin-rtc";function f(e,t,i,_){return new(i||(i=Promise))(function(r,s){function o(e){try{l(_.next(e))}catch(e){s(e)}}function n(e){try{l(_.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,n)}l((_=_.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const U={SUCCESS:0,PARAM_ERROR:80001,SESSION_EXIST:80002,NOT_IN_CALL:80003,MEDIATYPE_INVALID:80004,NOT_VIDEO_CALL:80005,RTC_SERVICE_UNAVAILABLE:80006,USER_LIST_INVAILD:80007,CALL_ID_INVALID:80008,TRANSACTION_ID_INVALID:80009,USER_ID_INVALID:80010,SINGLE_CALL_NOT_SUPPORT_MULTI_PERSON:80011,SIGNAL_DISCONNECTED:80012,CAMERA_CLOSED:80100,MICROPHONE_CLOSED:80101,MEDIA_RESOURCE_INVALIED:80102,NOT_INSTALL_RTC_PLUGIN:80103,PLAY_MEDIA_FAILED:80104,VIDEO_VIEW_NOT_SET:80105};var v,M,P,D,y,b,G,V;!function(e){e.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O="L-index_install_call_plus_plugin-O",e.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O="L-callplus_client_set_event_listener-O",e.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O="L-callplus_client_call_event_listener-O",e.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O="L-callplus_client_set_status_report_listener-O",e.L_CALLPLUS_CLIENT_CALL_STATUS_REPORT_LISTENER_O="L-callplus_client_call_status_report_listener-O",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T="L-callplus_client_set_video_config-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R="L-callplus_client_set_video_config-R",e.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O="L-callplus_video_config_set_frame_rate-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O="L-callplus_video_config_set_resolution-O",e.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O="L-callplus_video_config_set_bitrate-O",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T="L-callplus_client_set_audio_config-T",e.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R="L-callplus_client_set_audio_config-R",e.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O="L-callplus_audio_config_set_bitrate-O",e.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O="L-callplus_audio_config_set_sample_rate-O",e.L_CALLPLUS_CLIENT_PREVIEW_T="L-callplus_client_preview-T",e.L_CALLPLUS_CLIENT_PREVIEW_R="L-callplus_client_preview-R",e.L_CALLPLUS_CLIENT_START_CALL_T="L-callplus_client_start_call-T",e.L_CALLPLUS_CLIENT_START_CALL_R="L-callplus_client_start_call-R",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T="L-callplus_client_join_multi_call-T",e.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R="L-callplus_client_join_multi_call-R",e.L_CALLPLUS_CLIENT_ACCEPT_T="L-callplus_client_accept-T",e.L_CALLPLUS_CLIENT_ACCEPT_R="L-callplus_client_accept-R",e.L_CALLPLUS_CLIENT_HANGUP_T="L-callplus_client_hangup-T",e.L_CALLPLUS_CLIENT_HANGUP_R="L-callplus_client_hangup-R",e.L_CALLPLUS_CLIENT_INVITE_T="L-callplus_client_invite-T",e.L_CALLPLUS_CLIENT_INVITE_R="L-callplus_client_invite-R",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T="L-callplus_client_request_change_media_type-T",e.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R="L-callplus_client_request_change_media_type-R",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T="L-callplus_client_cancel_change_media_type-T",e.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R="L-callplus_client_cancel_change_media_type-R",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T="L-callplus_client_reply_change_media_type-T",e.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R="L-callplus_client_reply_change_media_type-R",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_T="L-callplus_client_get_current_call_session-T",e.L_CALLPLUS_CLIENT_GET_CURRENT_CALL_SESSION_R="L-callplus_client_get_current_call_session-R",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_get_available_call_sessions_from_server-T",e.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_get_available_call_sessions_from_server-R",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T="L-callplus_client_get_call_records-T",e.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R="L-callplus_client_get_call_records-R",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T="L-callplus_client_delete_call_records_by_callId-T",e.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R="L-callplus_client_delete_call_records_by_callId-R",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T="L-callplus_client_delete_all_call_records_from_server-T",e.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R="L-callplus_client_delete_all_call_records_from_server-R",e.L_CALLPLUS_CLIENT_START_CAMERA_T="L-callplus_client_start_camera-T",e.L_CALLPLUS_CLIENT_START_CAMERA_R="L-callplus_client_start_camera-R",e.L_CALLPLUS_CLIENT_STOP_CAMERA_T="L-callplus_client_stop_camera-T",e.L_CALLPLUS_CLIENT_STOP_CAMERA_R="L-callplus_client_stop_camera-R",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T="L-callplus_client_switch_camera-T",e.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R="L-callplus_client_switch_camera-R",e.L_CALLPLUS_CLIENT_START_MICROPHONE_T="L-callplus_client_start_microphone-T",e.L_CALLPLUS_CLIENT_START_MICROPHONE_R="L-callplus_client_start_microphone-R",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T="L-callplus_client_stop_microphone-T",e.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R="L-callplus_client_stop_microphone-R",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T="L-callplus_client_switch_microphone-T",e.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R="L-callplus_client_switch_microphone-R",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T="L-callplus_client_set_video_view-T",e.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R="L-callplus_client_set_video_view-R",e.L_RTC_MODULE_SET_VIDEO_VIEW_O="L-rtc_module_set_video_view-O",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T="L-callplus_client_remove_video_view-T",e.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R="L-callplus_client_remove_video_view-R",e.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O="L-rtc_module_remove_video_view-O",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_T="L-callplus_client_play_media-T",e.L_CALLPLUS_CLIENT_PLAY_MEDIA_R="L-callplus_client_play_media-R",e.L_RTC_MODULE_PLAY_MEDIA_T="L-rtc_module_play_media-T",e.L_RTC_MODULE_PLAY_MEDIA_R="L-rtc_module_play_media-R",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T="L-rtc_module_set_all_remote_audio_enbale-T",e.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R="L-rtc_module_set_all_remote_audio_enable-R",e.L_RTC_MODULE_SUBSCRIBE_T="L-rtc_module_subscribe-T",e.L_RTC_MODULE_SUBSCRIBE_R="L-rtc_module_subscribe-R",e.L_RTC_MODULE_UNSUBSCRIBE_T="L-rtc_module_unsubscribe-T",e.L_RTC_MODULE_UNSUBSCRIBE_R="L-rtc_module_unsubscribe-R",e.L_RTC_MODULE_PUBLISH_T="L-rtc_module_publish-T",e.L_RTC_MODULE_PUBLISH_R="L-rtc_module_publish-R",e.L_RTC_MODULE_UNPUBLISH_T="L-rtc_module_unpublish-T",e.L_RTC_MODULE_UNPUBLISH_R="L-rtc_module_unpublish-R",e.L_RTC_MODULE_DESTROY_ALL_TRACKS_O="L-rtc_module_destroy_all_tracks-O",e.L_RTC_MODULE_SESSION_CONNECT_T="L-rtc_module_session_connect-T",e.L_RTC_MODULE_SESSION_CONNECT_P="L-rtc_module_session_connect-P",e.L_RTC_MODULE_SESSION_CONNECT_R="L-rtc_module_session_connect-R",e.L_RTC_MODULE_SESSION_CLOSE_T="L-rtc_module_session_close-T",e.L_RTC_MODULE_SESSION_CLOSE_P="L-rtc_module_session_close-P",e.L_RTC_MODULE_SESSION_CLOSE_R="L-rtc_module_session_close-R",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_T="L-rtc_module_create_video_track-T",e.L_RTC_MODULE_CREATE_VIDEO_TRACK_R="L-rtc_module_create_video_track-R",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_T="L-rtc_module_create_audio_track-T",e.L_RTC_MODULE_CREATE_AUDIO_TRACK_R="L-rtc_module_create_audio_track-R",e.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O="L-rtc_module_receive_track_publish-O",e.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O="L-rtc_module_receive_track_unpublish-O",e.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O="L-rtc_module_receive_track_enable_change-O",e.L_RTC_MODULE_RECEIVE_KICK_OFF_O="L-rtc_module_receive_kick_off-O",e.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O="L-rtc_module_receive_peerconnection_except_close-O",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T="L-rtc_module_change_media_type-T",e.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R="L-rtc_module_change_media_type-R",e.L_RTC_MODULE_JOIN_RTC_ROOM_T="L-rtc_module_join_rtc_room-T",e.L_RTC_MODULE_JOIN_RTC_ROOM_R="L-rtc_module_join_rtc_room-R",e.L_RTC_MODULE_QUIT_RTC_ROOM_T="L-rtc_module_quit_rtc_room-T",e.L_RTC_MODULE_QUIT_RTC_ROOM_R="L-rtc_module_quit_rtc_room-R",e.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P="L-rtc_module_create_call_media_tracks-P",e.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T="L-signal_transporter_single_call-T",e.L_SIGNAL_TRANSPORTER_GROUP_CALL_T="L-signal_transporter_group_call-T",e.L_SIGNAL_TRANSPORTER_INVITE_T="L-signal_transporter_invite-T",e.L_SIGNAL_TRANSPORTER_RING_T="L-signal_transporter_ring-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_T="L-signal_transporter_accept-T",e.L_SIGNAL_TRANSPORTER_ACCEPT_R="L-signal_transporter_accept-R",e.L_SIGNAL_TRANSPORTER_JOIN_CALL_T="L-signal_transporter_join_call-T",e.L_SIGNAL_TRANSPORTER_HANGUP_T="L-signal_transporter_hangup-T",e.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T="L-signal_transporter_call_status_up-T",e.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T="L-signal_transporter_call_event_up-T",e.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T="L-signal_transporter_call_dialog_up-T",e.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T="L-signal_transporter_delete_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T="L-signal_transporter_get_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T="L-signal_transporter_get_call_server_time-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T="L-signal_transporter_get_call_time_info-T",e.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T="L-signal_transporter_get_available_call_list-T",e.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T="L-signal_transporter_clear_call_record-T",e.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T="L-signal_transporter_get_call_info_by_callId-T",e.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T="L-signal_transporter_user_system_state_up-T",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O="L-signal_transporter_receive_call_signal_data-O",e.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O="L-signal_transporter_im_state_change-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O="L-signal_transporter_receive_invite-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O="L-signal_transporter_receive_call_status-O",e.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O="L-signal_transporter_receive_miss_message-O",e.L_CALL_ENGINE_UPDATE_USERS_STATE_O="L-call_engine_update_users_state-O",e.L_CALL_ENGINE_IM_STATE_CHANGE_O="L-call_engine_im_state_change-O",e.L_CALL_ENGINE_CALL_TIMEOUT_O="L-call_engine_call_timeout-O",e.L_CALL_ENGINE_START_CALL_TIMER_O="L-call_engine_start_call_timer-O",e.L_CALL_ENGINE_STOP_CALL_TIMER_O="L-call_engine_stop_call_timer-O",e.L_CALL_ENGINE_UP_ON_PHONE_END_T="L-call_engine_up_on_phone_end-T",e.L_CALL_ENGINE_UP_ON_PHONE_END_R="L-call_engine_up_on_phone_end-R",e.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O="L-call_engine_receive_first_frame_time-O",e.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O="L-call_engine_receive_mediatype_change-O",e.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O="L-call_engine_receive_close_session-O",e.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O="L-call_engine_receive_call_record-O",e.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O="L-call_engine_receive_complementary_data-O",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T="L-call_engine_create_session_by_server-T",e.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R="L-call_engine_create_session_by_server-R",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T="L-call_engine_up_first_frame_time-T",e.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R="L-call_engine_up_first_frame_time-R",e.L_TIME_CORRECT_START_O="L-time_correct_start-O",e.L_TIME_CORRECT_STOP_O="L-time_correct_stop-O",e.L_TIME_CORRECT_RESTART_O="L-time_correct_restart-O",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T="L-time_correct_get_call_client_time_by_server-T",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P="L-time_correct_get_call_client_time_by_server-P",e.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R="L-time_correct_get_call_client_time_by_server-R",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T="L-time_correct_calc_client_start_time-T",e.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R="L-time_correct_calc_client_start_time-R",e.L_TIME_CORRECT_SET_DELTA_TIME_O="L-time_correct_set_delta_time-O",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T="L-time_correct_loop_correct_client_time-T",e.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R="L-time_correct_loop_correct_client_time-R",e.L_INNER_SESSION_UPDATE_USER_STATE_O="L-inner_session_update_user_state-O",e.L_INNER_SESSION_SET_USER_DEVICE_ENABLE_O="L-inner_session_set_user_device_enable-O",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_T="L-callplus_session_get_create_time-T",e.L_CALLPLUS_SESSION_GET_CREATE_TIME_R="L-callplus_session_get_create_time-R",e.L_CALLPLUS_SESSION_GET_DURATION_T="L-callplus_session_get_duration-T",e.L_CALLPLUS_SESSION_GET_DURATION_R="L-callplus_session_get_duration-R",e.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O="L-callplus_set_android_push_config-O",e.L_ABNORMAL_ADD_CALL_ID_E="L-ABNORMAL_ADD_CALL_ID-E",e.L_ABNORMAL_REMOVE_CALL_IDS_E="L-ABNORMAL_REMOVE_CALL_IDS-E",e.L_ABNORMAL_GET_CALL_IDS_E="L-ABNORMAL_GET_CALL_IDS-E",e.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O="L-set_audio_output_device_id-O"}(v||(v={}));class H{constructor(e,t,i,_,r){Object.defineProperty(this,"_session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_startTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_duration",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),this._callId=this._session.getCallId()}getCallId(){return this._callId}getState(){return this._session.getSessionState()}getCallType(){return this._session.getCallType()}getMediaType(){return this._session.getMediaType()}getUserList(){return this._session.getUserList().map(e=>{const{userId:t,userState:i}=e;let _=null,r=null;return t===this._context.getCurrentId()?(_=this._rtcModule.getLocalVideoTrack(),r=this._rtcModule.getLocalAudioTrack()):(_=this._rtcModule.getRemoteTrack(t,D.VIDEO),r=this._rtcModule.getRemoteTrack(t,D.AUDIO)),{userId:t,state:i,cameraEnable:!!_&&!_.isOwnerMuted(),microphoneEnable:!!r&&!r.isOwnerMuted()}})}getCreatorUserId(){return this._session.getStartCallerId()}getInviterUserId(){return this._session.getCallerId()}getCreateTimestamp(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_SESSION_GET_CREATE_TIME_T,"",e),this._startTime)return{code:U.SUCCESS,startTime:this._startTime};const{code:t,clientStartTime:i}=yield this._callEngine.getCallStaringTime({callId:this._callId},e);return t!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,`errCode: ${t}`,e),{code:t}):(this._logger.info(v.L_CALLPLUS_SESSION_GET_CREATE_TIME_R,"success",e),this._startTime=i,{code:U.SUCCESS,startTime:this._startTime})})}getDuration(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_SESSION_GET_DURATION_T,"",e),this._duration)return this._logger.info(v.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${U.SUCCESS}, duration: ${this._duration}`,e),{code:U.SUCCESS,duration:this._duration};const{code:t,data:i}=yield this._callEngine.getCallTimeInfo(this._callId,e);return t!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${t}`,e),{code:t}):(this._logger.info(v.L_CALLPLUS_SESSION_GET_DURATION_R,`code: ${U.SUCCESS}, duration: ${i.duration}`,e),this._duration=i.duration,{code:U.SUCCESS,duration:this._duration})})}}!function(e){e[e.SINGLE=0]="SINGLE",e[e.MULTI=1]="MULTI"}(M||(M={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ONPHONE=301]="ONPHONE",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(P||(P={})),function(e){e[e.AUDIO=0]="AUDIO",e[e.AUDIO_VIDEO=1]="AUDIO_VIDEO",e[e.VIDEO=2]="VIDEO"}(D||(D={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ENDED=1e3]="ENDED",e[e.NOANSWER=1001]="NOANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELED=1003]="CANCELED",e[e.DECLINED=1004]="DECLINED",e[e.ERROR=2e3]="ERROR"}(y||(y={})),function(e){e[e.CANCEL_CHANGE_MEDIA_TYPE=0]="CANCEL_CHANGE_MEDIA_TYPE",e[e.REFUSE_CHANGE_MEDIA_TYPE=1]="REFUSE_CHANGE_MEDIA_TYPE",e[e.SERVER_ALLOW_MEDIA_TYPE=2]="SERVER_ALLOW_MEDIA_TYPE",e[e.CHANGE_MEDIA_TYPE_TIMEOUT=3]="CHANGE_MEDIA_TYPE_TIMEOUT"}(b||(b={})),function(e){e[e.IDLE=0]="IDLE",e[e.CALLING=100]="CALLING",e[e.INVITED=101]="INVITED",e[e.RINGING=102]="RINGING",e[e.BUSYLINE_RINGING=103]="BUSYLINE_RINGING",e[e.BUSYLINE_WAIT=104]="BUSYLINE_WAIT",e[e.CONNECTING=200]="CONNECTING",e[e.ONCALL=300]="ONCALL",e[e.ON_PHONE=301]="ON_PHONE",e[e.ON_PHONE_END=302]="ON_PHONE_END",e[e.ON_DEVICE_DISABLE=303]="ON_DEVICE_DISABLE",e[e.ON_DEVICE_ENABLE=304]="ON_DEVICE_ENABLE",e[e.ABNORMAL_END=999]="ABNORMAL_END",e[e.ENDED=1e3]="ENDED",e[e.NO_ANSWER=1001]="NO_ANSWER",e[e.MISSED=1002]="MISSED",e[e.CANCELLED=1003]="CANCELLED",e[e.DECLINED=1004]="DECLINED",e[e.OTHER_CLIENT_CALLING=1010]="OTHER_CLIENT_CALLING",e[e.OTHER_CLIENT_ACCEPT=1011]="OTHER_CLIENT_ACCEPT",e[e.JOIN_ROOM_ERR=1105]="JOIN_ROOM_ERR",e[e.PUBLISH_ERR=1106]="PUBLISH_ERR",e[e.SUBSCRIBE_ERR=1107]="SUBSCRIBE_ERR",e[e.ACCEPT_CARRIER=1108]="ACCEPT_CARRIER",e[e.KICKED_BY_SERVER=1109]="KICKED_BY_SERVER",e[e.CONNECTION_ERR=1110]="CONNECTION_ERR",e[e.LOGOUT=1111]="LOGOUT",e[e.OTHER_CLIENT_LOGIN=1112]="OTHER_CLIENT_LOGIN",e[e.OTHER_CLIENT_JOINED=1113]="OTHER_CLIENT_JOINED",e[e.OTHER_CLIENT_IN_ROOM=1114]="OTHER_CLIENT_IN_ROOM",e[e.OTHER_CLIENT_HANGUP=1151]="OTHER_CLIENT_HANGUP",e[e.REMOTE_JOIN_RTC_ERROR=1205]="REMOTE_JOIN_RTC_ERROR",e[e.REMOTE_PUBLISH_ERROR=1206]="REMOTE_PUBLISH_ERROR",e[e.REMOTE_SUBSCRIBE_ERROR=1207]="REMOTE_SUBSCRIBE_ERROR",e[e.REMOTE_KICKED_BY_SERVER=1209]="REMOTE_KICKED_BY_SERVER",e[e.REMOTE_CONNECTION_ERROR=1210]="REMOTE_CONNECTION_ERROR",e[e.REMOTE_LOGOUT=1211]="REMOTE_LOGOUT",e[e.REMOTE_OTHER_CLIENT_LOGIN=1212]="REMOTE_OTHER_CLIENT_LOGIN",e[e.REMOTE_OTHER_JOINED_RTC=1213]="REMOTE_OTHER_JOINED_RTC",e[e.REMOTE_OTHER_CLIENT_IN_RTC=1214]="REMOTE_OTHER_CLIENT_IN_RTC"}(G||(G={})),function(e){e[e.START=1]="START",e[e.END=2]="END"}(V||(V={}));class w{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}setDefaultMicrophoneId(e){return this._audioConfig.microphoneId=e,this}setBitrate(t,i){return!e(t)||!e(i)||i<=0||t<=0||i<t?(this._logger.error(v.L_CALLPLUS_AUDIO_CONFIG_SET_BITRATE_O,`params error -> max: ${i},min: ${t}, max and min is a number > 0, max should > min`),this):(this._audioConfig.minBitrate=t,this._audioConfig.maxBitrate=i,this)}setSampleRate(t){return e(t)?(this._audioConfig.sampleRate=t,this):(this._logger.error(v.L_CALLPLUS_AUDIO_CONFIG_SET_SAMPLE_RATE_O,`params error -> sampleRate: ${t}`),this)}build(){return this._audioConfig}}class k{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:h.W640_H480,frameRate:R.FPS_15}})}setFrameRate(e){return R[e]?(this._videoConfig.frameRate=e,this):(this._logger.error(v.L_CALLPLUS_VIDEO_CONFIG_SET_FRAME_RATE_O,`params error -> fps: ${e}`),this)}setVideoResolution(e){return h[e]?(this._videoConfig.resolution=e,this):(this._logger.error(v.L_CALLPLUS_VIDEO_CONFIG_SET_RESOLUTION_O,`params error -> resolution: ${e}`),this)}setDefaultCameraId(e){return this._videoConfig.cameraId=e,this}setBitrate(t,i){return!e(t)||!e(i)||i<=0||t<=0||i<t?(this._logger.error(v.L_CALLPLUS_VIDEO_CONFIG_SET_BITRATE_O,`params error -> max: ${i},min: ${t}, max and min is a number > 0, max should > min`),this):(this._videoConfig.minBitrate=t,this._videoConfig.maxBitrate=i,this)}build(){return this._videoConfig}}const $=e=>{const{callId:t,callType:i,callDir:_,mediaType:r,callingUserId:s,callUserIds:o,callStatus:n,sessionStatus:l,startTime:a,endTime:c,duration:L,syncTime:E,sysStatus:d,crtTime:C}=e;return{callId:t,callType:i,callDirection:_,mediaType:r,callerUserId:s,callUserIds:o,sessionState:n,userState:l,startTimestamp:a,endTimestamp:c,duration:L,syncTimestamp:E,systemState:d,createTimestamp:C}},B=e=>e&&e.nodeName&&"VIDEO"===e.nodeName.toUpperCase(),x=e=>{const{voipCallInfo:t}=e;if(!t)return!1;const{strategy:i}=JSON.parse(t);return 1===i},F=(t,i)=>!t&&0!==t||e(t)&&!(t<=0)?!i&&0!==i||e(i)&&!(i<=0)?t&&i&&i<t?{code:U.PARAM_ERROR,errorMsg:`params error -> maxBitrate: ${i}, minBitrate: ${t}, maxBitrate should > minBitrate`}:{code:U.SUCCESS}:{code:U.PARAM_ERROR,errorMsg:`params error -> maxBitrate: a number of > 0, value: ${i}`}:{code:U.PARAM_ERROR,errorMsg:`params error -> minBitrate: a number of > 0, value: ${t}`},j=e=>{const t=[];for(const i in e){const{videoView:_,isTiny:r}=e[i];t.push({userId:i,videoView:_.nodeName,isTiny:r})}return t},Y=(e,t={},i={})=>{const{threadId:_,apnsCollapseId:r,richMediaUri:s}=t,{channelIdMi:o,channelIdHW:n,channelIdOPPO:l,typeVivo:a,fcmChannelId:c,fcmCollapseKey:L,fcmImageUrl:E,importanceHW:d,categoryHW:C,imageUrlHW:T,categoryVivo:I,importanceHonor:S,imageUrlHonor:u}=i,g={};_&&(g["thread-id"]=_),g["apns-collapse-id"]=r||e,s&&(g.richMediaUri=s);const h={};n&&(h.channelId=n),T&&(h.image=T),C&&(h.category=C),h.importance=d||"NORMAL";const R=[{HW:h},{APNS:g}];let A,N,O,m;return(L||E||c)&&(A={},L&&(A.collapse_key=L),E&&(A.imageUrl=E),c&&(A.channelId=c),R[0].FCM=A),o&&(R[0].MI={channelId:o}),l&&(N={},N.channelId=l,R[0].OPPO=N),(a||I)&&(O={},a&&(O.classification=a),I&&(O.category=I),R[0].VIVO=O),(S||u)&&(m={},S&&(m.importance=S),u&&(m.image=u),R[0].HONOR=m),JSON.stringify(R)},J=(e,t)=>{const{pushTitle:_="",iOSConfig:r,androidConfig:s,disablePushTitle:o,templateId:n}=e,l={pushConfigs:Y(t,r,s)};return i(o)&&(l.disableTitle=o),_&&(l.title=_),n&&(l.templateId=n),JSON.stringify(l)},W=e=>{const r=["pushTitle","pushContent","iOSConfig","androidConfig","disablePushTitle","templateId"];if(!Object.keys(e).every(e=>r.includes(e)))return{code:U.PARAM_ERROR,errorMsg:`right key: ${r.join(",")}`};for(let s=0;s<r.length;s++){const o=r[s];if("disablePushTitle"===o){if(!t(e[o])&&!i(e[o]))return{code:U.PARAM_ERROR,errorMsg:`${o} type is boolean`}}else if(("pushTitle"===o||"templateId"===o||"pushContent"===o)&&e[o]&&!_(e[o]))return{code:U.PARAM_ERROR,errorMsg:`${o} type is string`}}const{iOSConfig:s,androidConfig:o}=e,n=K(s||{});if(n.code!==U.SUCCESS)return n;const l=Q(o||{});return l.code!==U.SUCCESS?l:{code:U.SUCCESS}},K=e=>{const{threadId:t,richMediaUri:i}=e||{};return t&&!_(t)?{code:U.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:i&&!_(i)?{code:U.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:U.SUCCESS}},Q=e=>{const t=["channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"];if(!Object.keys(e).every(e=>t.includes(e)))return{code:U.PARAM_ERROR,errorMsg:`right key: ${t.join(",")}`};for(let i=0;i<t.length;i++){const r=t[i];if("importanceHW"===r||"importanceHonor"===r){if(e[r]&&"LOW"!==e[r]&&"NORMAL"!==e[r])return{code:U.PARAM_ERROR,errorMsg:`androidConfig.${r} value is NORMAL|LOW`}}else if(e[r]&&!_(e[r]))return{code:U.PARAM_ERROR,errorMsg:`androidConfig.${r} type is string`}}return{code:U.SUCCESS}},q=(e,t="utf-8")=>{let i=0;return i="utf-16"===t?X(e):z(e),i},X=e=>{let t,i=0;for(let _=0,r=e.length;_<r;_++)t=e.charCodeAt(_),i+=t<=65535?2:4;return i},z=e=>{let t,i=0;for(let _=0,r=e.length;_<r;_++)t=e.charCodeAt(_),i+=t<127?1:t<=2047?2:t<=65535?3:4;return i},Z=/Electron/.test(navigator.userAgent);var ee,te,ie,_e,re,se;!function(e){e.L_QS_START_CALL_S="Call-start-S",e.L_QS_ACCEPT_CALL_S="Call-accept-S",e.L_QS_HANGUP_CALL_S="Call-hangup-S",e.L_QS_RECEIVE_CALL_S="Call-recv-S",e.L_QS_ABNORMAL_HANGUP_S="Call-interrupt-S"}(ee||(ee={}));class oe{constructor(e,t){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t})}reportStatisticsData(e,t,i,_,r,s,o){const n=+new Date,{mediaType:l,callType:a,callId:c}=_?{mediaType:_.getMediaType(),callType:_.getCallType(),callId:_.getCallId()}:o,L={cr:"unknown",net:"unknown",cod:t,mtp:l,ctp:a,cid:c,time:n,uid:this._context.getCurrentId()};r&&Object.assign(L,{ccid:r});let E=null;switch(e){case ee.L_QS_RECEIVE_CALL_S:E=Object.assign(Object.assign({},L),{rf:s});break;case ee.L_QS_ABNORMAL_HANGUP_S:E=Object.assign({},L);break;default:E=Object.assign(Object.assign({},L),{dur:n-i})}this._logger.__statistics(e,JSON.stringify(E))}}!function(e){e.REQUEST="request",e.ACCEPT="accept",e.REFUSE="refuse",e.CANCEL="cancel",e.NOTICE="notice",e.TIMEOUT="timeout"}(te||(te={})),function(e){e[e.SWITCH_MEDIA_TYPE=1]="SWITCH_MEDIA_TYPE"}(ie||(ie={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.SECRET=1]="SECRET"}(_e||(_e={})),function(e){e.INVITER="inviter",e.INVITEE="invitee"}(re||(re={}));class ne extends r{constructor(e,t,i,_,r,s,o,n){super(),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_callType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_startCallerId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_callerId",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_callUsers",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_reqMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_inviterTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_inviteeTimerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_oldDialogData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLocalClientHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1})}getCallId(){return this._callId}getSessionState(){return this._state}getCallType(){return this._callType}getMediaType(){return this._mediaType}getStartCallerId(){return this._startCallerId}getCallerId(){return this._callerId}getUserList(){return this._callUsers}getReqMediaType(){return this._reqMediaType}getInviterTimerId(){return this._inviterTimerId}getInviteeTimerId(){return this._inviteeTimerId}getAllTimerIds(){return[this._inviterTimerId,this._inviteeTimerId]}updateUserList(e,t){const i=[];return e.forEach(e=>{const{userState:t,stateTime:_,systemState:r,userId:s}=e,o=this._callUsers.findIndex(e=>e.userId===s);if(o<0)return this._callUsers.push(e),void i.push(e);const{stateTime:n,systemState:l,userState:a}=this._callUsers[o],c=((e,t)=>{let i=!1;const _=[G.INVITED,G.RINGING,G.BUSYLINE_RINGING,G.BUSYLINE_WAIT,G.CONNECTING,G.ONCALL];return e===G.ONCALL&&_.includes(t)&&(i=!0),i})(l,r),L=((e,t)=>{let i=!1;const _=[P.INVITED,P.RINGING,P.BUSYLINE_RINGING,P.BUSYLINE_WAIT,P.CONNECTING,P.ONCALL];return e===P.ONCALL&&_.includes(t)&&(i=!0),i})(a,t),E=r===G.ON_PHONE_END&&l!==G.ON_PHONE&&t!==P.IDLE;_&&n&&_<n||c&&L||(this._callUsers[o]=e,!E&&i.push(e))}),i}setOldDialogData(e){this._oldDialogData=e}updateSessionState(e){this._state=e}updateCallType(e){this._callType=e}updateMediaType(e){this._mediaType=e}updateReqMediaType(e){this._reqMediaType=e}updateTimerId(e,t){e===re.INVITER?this._inviterTimerId=t:this._inviteeTimerId=t}getOldDialogData(){return this._oldDialogData}setIsLocalClientHangup(e){this.isLocalClientHangup=e}getIsLocalClientHangup(){return this.isLocalClientHangup}}!function(e){e.START_SINGLE_CALL="startSingleCall",e.START_GROUP_CALL="startGroupCall",e.INVITE_CALL="inviteCall",e.PUB_INVITE_CALL="pubInviteCall",e.RINGING_CALL="ringCall",e.ACCEPT_CALL="acceptCall",e.JOIN_CALL="joinCall",e.HANGUP_CALL="hangupCall",e.STATUS_UP_CALL="statusUpCall",e.STATUS_DOWN_CALL="statusDownCall",e.EVENT_UP_CALL="eventUpCall",e.EVENT_DOWN_CALL="eventDownCall",e.DIALOG_UP_CALL="dialogUpCall",e.DIALOG_DOWN_CALL="dialogDownCall",e.GET_CALL_USER_SESSION_LIST="getCallUSerSessionList",e.SYNC_CALL_LOG="syncCallLog",e.PUB_CALL_LOG="pubCallLog",e.DEL_CALL_LOG="deleteCallLog",e.QRY_CALL_STATE="queryUserHasCall",e.QRY_SRV_TIMESTAMP="getCallSrvTimeStamp",e.GET_CALL_STATE_LIST="getUserCallStateList",e.CLEAR_CALL_LOG="cleanCallLog",e.GET_CALL_SESSION="getCallSession",e.GET_CALL_TIME_INFO="getCallTimeInfo",e.END_ABNORMAL_CALL="endUserAbnormalCalls",e.SYS_STATUS_UP="sysStatusUp",e.UP_CALL_LOG_READED="upCallLogReaded",e.PUB_CALL_LOG_READED="pubCallLogReaded",e.PUB_NACK_SEQ_ID="pubNACKSeqId",e.GET_USER_CALL_SESSION_ID_LIST="getUserCallSessionIdList"}(se||(se={}));const le=(e,t)=>setTimeout(e,t),ae=[s.RC_NET_CHANNEL_INVALID,s.RC_NET_UNAVAILABLE,s.RC_MSG_RESP_TIMEOUT,A.SIGNAL_DISCONNECTED,A.REQUEST_FAILED],ce=({asyncFn:e,fnArgs:t,currentRetryTime:i=Date.now(),maxDuration:_=6e4,intervals:r=[2e3,4e3,8e3,16e3,32e3,64e3],index:s=0,onError:o})=>f(void 0,void 0,void 0,function*(){const n=yield e(...t);return n.code===U.SUCCESS||!ae.includes(n.code)||Date.now()+2e3-i>_?n:(o&&o(n.code),yield(l=2e3,new Promise(e=>{setTimeout(e,l)})),ce({asyncFn:e,fnArgs:t,currentRetryTime:i,maxDuration:_,intervals:r,index:s,onError:o}));var l});var Le,Ee,de;!function(e){e.onBeforePublish="onBeforePublish",e.onPublishRes="onPublishRes",e.onPubInviteCall="onPubInviteCall",e.onPubInviteCallPullKv="onPubInviteCallPullKv",e.onPubInviteCallMiss="onPubInviteCallMiss"}(Le||(Le={})),function(e){e.NOT_CURRENT_DEVICEID="not current device id",e.SECRET_CALL="secret call",e.NOT_INVITEE="not an invitee"}(Ee||(Ee={})),function(e){e.PUB_INVITE="pubinvitecall",e.PULL_KV_INVITE="pullkv_invitecall",e.PUSH="system_pubsh"}(de||(de={}));const Ce=131072,Te="RC:CallPlusMiss",Ie="RC:CallGroupStatusMsg";class Se extends r{constructor(e,t,i,_,r,s){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_needRetryActions",{enumerable:!0,configurable:!0,writable:!0,value:[se.START_SINGLE_CALL,se.START_GROUP_CALL,se.ACCEPT_CALL,se.JOIN_CALL,se.EVENT_UP_CALL]}),Object.defineProperty(this,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:""}),this._context.onCallInfo=this._onRecvCallSignal.bind(this),this._context.onconnectionstatechange=this._onIMConnectionStateChange.bind(this),this._context.onmessage=this._onMessage.bind(this),this._sessionId=o()}_onMessage(e){return!![Te,Ie].includes(e.messageType)&&(e.messageType===Te?this._dealMissMessage(e):this._dealGroupCallMessage(e),!0)}_dealMissMessage(e){const{content:{callId:t,mediaType:i,startTime:_,callSessionUsers:r},targetId:s,senderUserId:o}=e,l=this._context.getCurrentId();if(!localStorage.getItem(`missMessageMap-${l}-${t}`)){const a={callId:t,callerUserId:o,targetId:s,mediaType:i,firstFrameTime:0,callStartTime:_-this._timeCorrectioner.getLocalDelayTime(),callEndTime:0,hangupReason:r.filter(({userId:e})=>e===l)[0].sessionStatus};this._logger.info(v.L_SIGNAL_TRANSPORTER_RECEIVE_MISS_MESSAGE_O,`receive miss message: ${JSON.stringify(e)}`);const c=Object.assign(e,{content:a,sentStatus:n.SENT});this._reportAppEventModule.onReceivedCallPlusSummaryMessage(c),localStorage.setItem(`missMessageMap-${l}-${t}`,t)}}_dealGroupCallMessage(e){this._reportAppEventModule.onReceivedGroupCallStatusMessage(e)}getSessionId(){return this._sessionId}getDeviceId(){return Z?this._context.getDeviceId():this._sessionId}registerListener(e){this._listener=e}startCall(e,t){return f(this,void 0,void 0,function*(){const{clientCallId:i,callType:_,toUsers:r,mediaType:s,secretChat:o,targetType:n,targetId:l,nickName:a,oldRoomId:c,pushExt:L,pushContent:E,extra:d}=e;return _===M.SINGLE?this.startSingleCall({clientCallId:i,toUserId:r[0].userId,mediaType:s,secretChat:o,targetType:n,targetId:l,oldRoomId:c,toOrgId:r[0].orgId||"",pushExt:L,pushContent:E,extra:d},t):this.startGroupCall({clientCallId:i,toUsers:r,mediaType:s,targetType:n,targetId:l,nickName:a,oldRoomId:c,pushExt:L,pushContent:E,extra:d},t)})}startSingleCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_SINGLE_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(this._context.getCurrentId(),se.START_SINGLE_CALL,e)})}startGroupCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_GROUP_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(this._context.getCurrentId(),se.START_GROUP_CALL,e)})}inviteCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_INVITE_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.INVITE_CALL,e)})}ringingCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_RING_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.RINGING_CALL,e)})}acceptCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_ACCEPT_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.ACCEPT_CALL,e)})}joinCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_JOIN_CALL_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.JOIN_CALL,e)})}hangupCall(e,t){return f(this,void 0,void 0,function*(){this._logger.info(v.L_SIGNAL_TRANSPORTER_HANGUP_T,`params: ${JSON.stringify(e)}`,t);const{code:i}=yield this._sendCallSignal(e.callId,se.HANGUP_CALL,e);return i===U.NOT_IN_CALL?{code:U.SUCCESS}:{code:i}})}statusUpCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_CALL_STATUS_UP_T,`call status up params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.STATUS_UP_CALL,e)})}eventUpCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_CALL_EVENT_UP_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.EVENT_UP_CALL,e)})}dialogUpCall(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_CALL_DIALOG_UP_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.DIALOG_UP_CALL,e)})}deleteCallRecord(e,t,i){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_DELETE_CALL_RECORD_T,`callIds: ${JSON.stringify(t)}`,i),this._sendCallSignal(e,se.DEL_CALL_LOG,{callIds:t})})}syncCallLog(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_GET_CALL_RECORD_T,`params: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.userId,se.SYNC_CALL_LOG,e)})}queryUserHasCall(){return f(this,void 0,void 0,function*(){const e=this._context.getCurrentId();return this._sendCallSignal(e,se.QRY_CALL_STATE,null)})}getCallServerTimestamp(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(v.L_SIGNAL_TRANSPORTER_GET_CALL_SERVER_TIME_T,`userId: ${t}`,e),this._sendCallSignal(t,se.QRY_SRV_TIMESTAMP,null)})}getCallTimeInfo(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_GET_CALL_TIME_INFO_T,`callId: ${e}`,t),this._sendCallSignal(e,se.GET_CALL_TIME_INFO,{callId:e})})}getUserCallStateList(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(v.L_SIGNAL_TRANSPORTER_GET_AVAILABLE_CALL_LIST_T,`userId: ${t}`,e),this._sendCallSignal(t,se.GET_CALL_STATE_LIST,null)})}clearCallRecord(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._logger.info(v.L_SIGNAL_TRANSPORTER_CLEAR_CALL_RECORD_T,`userId: ${t}`,e),this._sendCallSignal(t,se.CLEAR_CALL_LOG,null)})}getCallSession(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_GET_CALL_INFO_BY_CALLID_T,`callId: ${e.callId}`,t),this._sendCallSignal(e.callId,se.GET_CALL_SESSION,e)})}sysStatusUp(e,t){return f(this,void 0,void 0,function*(){return this._logger.info(v.L_SIGNAL_TRANSPORTER_USER_SYSTEM_STATE_UP_T,`opts: ${JSON.stringify(e)}`,t),this._sendCallSignal(e.callId,se.SYS_STATUS_UP,e)})}upCallLogReaded(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId();return this._sendCallSignal(t,se.UP_CALL_LOG_READED,e)})}endUserAbnormalCalls(e){return f(this,void 0,void 0,function*(){return this._sendCallSignal(this._context.getCurrentId(),se.END_ABNORMAL_CALL,e)})}_onIMConnectionStateChange(e){const t=this._logger.createTraceId();this._logger.info(v.L_SIGNAL_TRANSPORTER_IM_STATE_CHANGE_O,`state: ${e}`,t),this._listener.onIMStateChange(e),e===l.CONNECTED?this._timeCorrectioner.start(t):this._timeCorrectioner.stop(t)}_sendCallSignal(e,t,i){return f(this,void 0,void 0,function*(){let _,r="";i&&(r=Z?JSON.stringify(i):JSON.stringify(Object.assign(Object.assign({},i),{sessionId:this._sessionId}))),_=this._needRetryActions.includes(t)?yield ce({asyncFn:this._context.setCallInfo.bind(this._context),fnArgs:[e,t,r]}):yield this._context.setCallInfo(e,t,r);const{code:o,data:n}=_;if(o!==s.SUCCESS)return{code:o};const{value:l}=n,a=JSON.parse(l).data;return{code:U.SUCCESS,data:a}})}_onRecvCallSignal(e){const t=this._logger.createTraceId();this._logger.info(v.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_SIGNAL_DATA_O,`data: ${e}`,t);JSON.parse(e).list.forEach(e=>{const{key:i}=e,_=JSON.parse(e.value);switch(i){case se.PUB_INVITE_CALL:this._onPubInviteCall(_,t,!0);break;case se.STATUS_DOWN_CALL:this._onStatusDownCall(_,t);break;case se.EVENT_DOWN_CALL:this._onEventDownCall(_,t);break;case se.DIALOG_DOWN_CALL:this._onDialogDownCall(_,t);break;case se.PUB_CALL_LOG:this._onPubCallLog(_,t);break;case se.PUB_CALL_LOG_READED:case se.PUB_NACK_SEQ_ID:break;default:this._onConpensationData(_,t)}})}isValidData(e){if(a(e))return!0;const t=e===this.getDeviceId();return!(!_(e)||0!==(null==e?void 0:e.length)&&!t)}_onPubInviteCall(e,t,i=!0){try{const i=this._context.getCurrentId(),_=e.callSessionUsers.find(e=>e.userId===i),r=this._context.getConnectionStatus();this._logger.info(v.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`currentUser: ${JSON.stringify(_)}, currentUserId: ${i}, state: ${r}`,t)}catch(e){this._logger.error(v.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`error: ${e.message}`,t)}if(!this.isValidData(e.toDeviceId||"")){this._logger.warn(v.L_SIGNAL_TRANSPORTER_RECEIVE_INVITE_O,`not current deviceId -> deviceInfo: ${JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this._sessionId})}`,t);const _={extra:JSON.stringify(e),reason:Ee.NOT_CURRENT_DEVICEID,refer:i?de.PUB_INVITE:de.PULL_KV_INVITE};return void this.emit(Le.onPubInviteCallMiss,Object.assign(e,_))}this._listener.onInvite(e,i,t),i?this.emit(Le.onPubInviteCall,Object.assign(e,{extra:JSON.stringify(e)})):this.emit(Le.onPubInviteCallPullKv,Object.assign(e,{extra:JSON.stringify(e)}))}_onStatusDownCall(e,t){if(e.callSessionUsers=e.callSessionUsers.filter(e=>Boolean(e.changed)),this._logger.info(v.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,"",t),!this.isValidData(e.toDeviceId||""))return this._logger.warn(v.L_SIGNAL_TRANSPORTER_RECEIVE_CALL_STATUS_O,`not current deviceId -> deviceInfo: ${JSON.stringify({toDeviceId:e.toDeviceId,clientDeviceId:this._sessionId})}`,t),void this._listener.onOtherClientStatusDown(e,t);this._listener.onStatusDown(e,t,this._sessionId)}_onEventDownCall(e,t){this._listener.onEventDown(e,t)}_onDialogDownCall(e,t){const{dialogType:i}=e;i===ie.SWITCH_MEDIA_TYPE&&this._listener.onSwitchMediaType(e,t)}_onPubCallLog(e,t){this._logger.info(v.L_CALL_ENGINE_RECEIVE_CALL_RECORD_O,`call record: ${JSON.stringify(e)}`,t),this._listener.onRecvCallEndLog(e,t)}_onConpensationData(e,t){this._logger.info(v.L_CALL_ENGINE_RECEIVE_COMPLEMENTARY_DATA_O,"",t);const{callId:i,callType:_,mediaType:r,secretChat:s,duration:o,callStatus:n,callingUserId:l,callSessionUsers:a,toDeviceId:c,callDialogEntitys:L,extra:E}=e;a.some(e=>e.sessionStatus===P.INVITED&&e.userId===this._context.getCurrentId())?this._onPubInviteCall({callId:i,toDeviceId:c,callType:_,mediaType:r,inviteUserId:l,callingUserId:l,callSessionUsers:a,secretChat:s,extra:E},t,!0):this._onStatusDownCall({callId:i,toDeviceId:c,callStatus:n,duration:o,callSessionUsers:a},t),L.length>0&&L.forEach(e=>this._onDialogDownCall(e,t),this)}}const ue=()=>{let e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});return e=`${e.replace(/-/g,"")}0`,e=parseInt(e,16),e=(e=>{const t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),i=t.length+1;let _=+e;const r=[];do{const e=_%i;_=(_-e)/i,r.unshift(t[e])}while(_);return r.join("")})(e),e.length>22&&(e=e.slice(0,22)),e};class ge{constructor(e,t){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_localStore",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._localStore=e.localStorage}addAbnormallCallId(e,t){try{const i=JSON.parse(this._localStore.getItem(ge._STORAGE_KEY)||"{}");let _=i[e];_?_.push(t):_=[t],i[e]=_,this._localStore.setItem(ge._STORAGE_KEY,JSON.stringify(i))}catch(e){this._logger.error(v.L_ABNORMAL_ADD_CALL_ID_E,e.message),console.error(e)}}removeAbnormalCallIds(e,t){try{const i=JSON.parse(this._localStore.getItem(ge._STORAGE_KEY)||"{}");let _=i[e];_&&(_=_.filter(e=>!t.includes(e)),_.length>0?i[e]=_:delete i[e],this._localStore.setItem(ge._STORAGE_KEY,JSON.stringify(i)))}catch(e){this._logger.error(v.L_ABNORMAL_REMOVE_CALL_IDS_E,e.message),console.error(e)}}getAbnormalCallIds(e){let t=null;try{const i=JSON.parse(this._localStore.getItem(ge._STORAGE_KEY)||"{}")[e];i&&(t=i)}catch(e){this._logger.error(v.L_ABNORMAL_GET_CALL_IDS_E,e.message),console.error(e)}return Promise.resolve(t)}}var he,Re,Ae,Ne,Oe;Object.defineProperty(ge,"_STORAGE_KEY",{enumerable:!0,configurable:!0,writable:!0,value:"CallPlus_AbnormalCall"}),function(e){e[e.PROMPT=0]="PROMPT",e[e.CALL_DURATION=10]="CALL_DURATION",e[e.FIRST_FRAME=20]="FIRST_FRAME"}(he||(he={})),function(e){e[e.SUCCESS=0]="SUCCESS",e[e.INVALID_RESPONSE_TIME=80170]="INVALID_RESPONSE_TIME",e[e.NONOPTIMAL_RES_TIME=80171]="NONOPTIMAL_RES_TIME"}(Re||(Re={}));class me{constructor(e,t,i){Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_singleCallDurationEv",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_RTT",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_validMinRTT",{enumerable:!0,configurable:!0,writable:!0,value:200}),Object.defineProperty(this,"_validMaxRTT",{enumerable:!0,configurable:!0,writable:!0,value:1e3}),Object.defineProperty(this,"_deltaTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_timerId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_interval",{enumerable:!0,configurable:!0,writable:!0,value:2e3}),Object.defineProperty(this,"_maxRetryTimes",{enumerable:!0,configurable:!0,writable:!0,value:8}),Object.defineProperty(this,"_startTimes",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_retryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_maxRetryTimesInCall",{enumerable:!0,configurable:!0,writable:!0,value:3})}getCallClientTimeByServer(e,t){return f(this,void 0,void 0,function*(){this._logger.info(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_T,`callId: ${e}`,t),(!this._RTT||this._RTT>this._validMinRTT)&&(yield this._getDeltaTime(t)),this._RTT>this._validMaxRTT&&this._logger.error(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${Re.INVALID_RESPONSE_TIME}`,t);const{code:i,data:_}=yield this._callEngine.getCallTimeInfo(e,t);if(i!==U.SUCCESS)return this._logger.error(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${i}`,t),{code:i};const{startTime:r}=_,s=Math.floor(r-this._deltaTime);let o=(Date.now()+this._deltaTime-r)/1e3;return o<0&&(this._logger.warn(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_P,`invalid duration: ${o}`,t),o=0),o=Math.floor(o),this._RTT>this._validMinRTT&&this._RTT<=this._validMaxRTT&&this._logger.error(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,`code: ${Re.NONOPTIMAL_RES_TIME}`,t),this._logger.info(v.L_TIME_CORRECT_GET_CALL_CLIENT_TIME_BY_SERVER_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,serverStartTime:r,clientStartTime:s,duration:o}),t),{code:i,duration:o,clientStartTime:r?s:r}})}calcClientStartTime(e,t,i){if(this._logger.info(v.L_TIME_CORRECT_CALC_CLIENT_START_TIME_T,`callId: ${e}, startTime: ${t}`,i),this._RTT>this._validMaxRTT)return this._logger.error(v.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,`code: ${Re.INVALID_RESPONSE_TIME}`,i),this._loopCorrectClientTime(e,i),{code:Re.INVALID_RESPONSE_TIME};const _=Math.floor(t-this._deltaTime);return this._logger.info(v.L_TIME_CORRECT_CALC_CLIENT_START_TIME_R,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime,startT:t,clientStartTime:_}),i),this._RTT>this._validMinRTT&&(this._retryTimesInCall=0,this._loopCorrectClientTime(e,i)),{code:Re.SUCCESS,clientStartTime:_}}start(e){this._timerId||this._startTimes>=this._maxRetryTimes||(this._logger.info(v.L_TIME_CORRECT_START_O,`timerId: ${this._timerId}`),this._startTimes++,this._getDeltaTime(e),this._timerId=le(()=>{this._timerId=null,this.start(e)},this._interval))}stop(e){this._logger.info(v.L_TIME_CORRECT_STOP_O,`timerId: ${this._timerId}`,e),this._timerId&&clearTimeout(this._timerId),this._timerId=null,this._startTimes=0}restart(e){this._logger.info(v.L_TIME_CORRECT_RESTART_O,`legal rtt time, RTT: ${this._RTT}, validMinRTT: ${this._validMinRTT}`,e),this._RTT<this._validMinRTT||(this.stop(e),this.start(e))}getLocalDelayTime(){return Math.round(this._deltaTime)}getRTT(){return this._RTT}_getDeltaTime(e){return f(this,void 0,void 0,function*(){const t=Date.now(),{code:i,data:_}=yield this._callEngine.getCallServerTimestamp(e),r=Date.now();if(i!==U.SUCCESS)return{code:i};const s=r-t;return(s<this._RTT||0===this._RTT)&&s<=this._validMaxRTT&&(this._RTT=s),s<this._validMinRTT&&this.stop(e),this._deltaTime=_-t-this._RTT/2,this._logger.info(v.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({rtt:this._RTT,deltaT:this._deltaTime}),e),{code:i,delayTime:this._deltaTime}})}_getDeltaTimeInCall(e,t){return f(this,void 0,void 0,function*(){const i=Date.now(),{code:_,data:r}=yield this._callEngine.getCallTimeInfo(e,t),s=Date.now();if(_!==U.SUCCESS)return{code:_};const o=s-i;o<this._RTT&&(this._RTT=o),this._deltaTime=r.syncTime-i-this._RTT/2,this._logger.info(v.L_TIME_CORRECT_SET_DELTA_TIME_O,JSON.stringify({callId:e,rtt:this._RTT,deltaT:this._deltaTime}),t);const n=Math.floor(r.startTime-this._deltaTime),l=Math.floor(r.firstFrametime-this._deltaTime);return o<this._validMinRTT?{code:Re.SUCCESS,clientStartTime:n,clientFirstFrameTime:l}:{code:Re.INVALID_RESPONSE_TIME,clientStartTime:n,clientFirstFrameTime:l}})}_loopCorrectClientTime(e,t){return f(this,void 0,void 0,function*(){this.stop(t),this._logger.info(v.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_T,`callId: ${e}`,t);const{code:i,clientStartTime:_,clientFirstFrameTime:r}=yield this._getDeltaTimeInCall(e,t);return i===Re.SUCCESS?(this._logger.info(v.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,`code: ${U.SUCCESS}`,t),void this._singleCallDurationEv(e,_,r,t)):this._retryTimesInCall>this._maxRetryTimesInCall&&i===Re.INVALID_RESPONSE_TIME?(this._logger.info(v.L_TIME_CORRECT_LOOP_CORRECT_CLINET_TIME_R,`code: ${Re.INVALID_RESPONSE_TIME}`,t),void this._singleCallDurationEv(e,_,r,t)):void(this._retryTimesInCall>this._maxRetryTimesInCall||(this._retryTimesInCall++,setTimeout(()=>{this._loopCorrectClientTime(e,t)},this._interval)))})}}!function(e){e[e.SOON_AFETER=0]="SOON_AFETER",e[e.CURRENT=1]="CURRENT"}(Ae||(Ae={})),function(e){e[e.PUB_INVITE_CALL=0]="PUB_INVITE_CALL",e[e.PULL_KV_INVITE_CALL=1]="PULL_KV_INVITE_CALL",e[e.SYSTEM_PUSH=2]="SYSTEM_PUSH"}(Ne||(Ne={})),function(e){e[e.OUT=-1]="OUT",e[e.GROUP=0]="GROUP",e[e.IN=1]="IN"}(Oe||(Oe={}));class pe extends r{constructor(e,t,i,_,r){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_mainSession",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_holdSessions",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_signalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_abnormalModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isUpFirstFrameTime",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_callStartMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_timeCorrectioner",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._timeCorrectioner=new me(this,_,this._onRecvSinCallDuration.bind(this)),this._signalModule=new Se(e,t,i,this._timeCorrectioner,this._logger,this._reportAppEventModule),this._signalModule.registerListener({onInvite:this._onInvite.bind(this),onStatusDown:this._onStatusDown.bind(this),onOtherClientStatusDown:this._onOtherClientStatusDown.bind(this),onEventDown:this._onEventDown.bind(this),onSwitchMediaType:this._onSwitchMediaType.bind(this),onRecvCallEndLog:this._onRecvCallEndLog.bind(this),onIMStateChange:this._onIMStateChange.bind(this)}),this._abnormalModule=new ge(t,_)}startCall(e,t){return f(this,void 0,void 0,function*(){const i=this._context.getCurrentId(),{callType:_,mediaType:r,toUsers:s,targetId:o,targetType:n,oldRoomId:l,pushConfig:a,extra:c}=e;this._clientCallId=e.callId;const L=a?J(a,this._clientCallId):"",{code:E,data:d}=yield this._signalModule.startCall({clientCallId:this._clientCallId,callType:_,mediaType:r,toUsers:s,secretChat:_e.NORMAL,targetType:n,targetId:o,oldRoomId:l,pushExt:L,pushContent:(null==a?void 0:a.pushContent)||"",extra:c},t);if(E!==U.SUCCESS)return{code:E};const{callId:C,busylineUsers:T}=d;if(this._abnormalModule.addAbnormallCallId(i,C),this._mainSession=new ne(C,y.INVITED,_,r,i,i,[],this._logger),_===M.SINGLE){const e=this._startTimer(d.callId,P.NO_ANSWER,t);this._mainSession.updateTimerId(re.INVITER,e)}const I={userId:i,userState:P.CALLING,systemState:G.CALLING,targetType:n,targetId:o};let S=s.map(({userId:e,targetType:t,targetId:i})=>({userId:e,userState:P.INVITED,systemState:G.INVITED,targetType:t,targetId:i})),u=[];T&&(u=T.map(e=>{const{targetType:t,targetId:i}=S.find(t=>t.userId===e.userId);return{userId:e.userId,userState:e.sessionStatus,systemState:G.BUSYLINE_RINGING,targetType:t,targetId:i}}),S=S.filter(({userId:e})=>u.every(({userId:t})=>t!==e)));const g=this.updateUsersState(C,[I,...S,...u],t);return setTimeout(()=>{g.length>0&&this.reportRemoteUserStateChange(C,g,t)}),{code:E,data:d}})}invite(e,t){var i;return f(this,void 0,void 0,function*(){if(!this._mainSession)return{code:U.NOT_IN_CALL};const{toUsers:_,pushConfig:r,extra:s}=e,o=r?J(r,this._clientCallId):"",n=this._mainSession.getCallId(),{code:l,data:a}=yield this._signalModule.inviteCall({callId:n,toUsers:_,pushExt:o,pushContent:(null==r?void 0:r.pushContent)||"",extra:s},t);if(l===U.SUCCESS){this._mainSession.getCallType()===M.SINGLE&&(this._mainSession.updateCallType(M.MULTI),this._onCallTypeChange(this._mainSession.getCallId(),M.MULTI,t));let e=_.map(({userId:e,targetType:t,targetId:i})=>({userId:e,userState:P.INVITED,systemState:G.INVITED,targetType:t,targetId:i})),r=[];a.busylineUsers&&(r=null===(i=a.busylineUsers)||void 0===i?void 0:i.map(t=>{const{targetType:i,targetId:_}=e.find(e=>e.userId===t.userId);return{userId:t.userId,userState:t.sessionStatus,systemState:G.BUSYLINE_RINGING,targetType:i,targetId:_}}),e=e.filter(({userId:e})=>r.every(({userId:t})=>t!==e)));const s=this.updateUsersState(n,[...e,...r],t);s.length>0&&this.reportRemoteUserStateChange(n,s,t)}return{code:l,data:a}})}clearAllTimer(e,t){[this._mainSession,...this._holdSessions].forEach(i=>{i&&i.getCallId()===e&&i.getAllTimerIds().forEach(e=>this._stopTimer.bind(this)(e,t))})}hangup(e,t){return f(this,void 0,void 0,function*(){const{callId:i,systemState:_,pushConfig:r}=e,s=r?J(r,this._clientCallId):"",{code:o}=yield this._signalModule.hangupCall({callId:i,sysStatus:_,pushExt:s,pushContent:(null==r?void 0:r.pushContent)||""},t);return this.endCurrentSession(e.systemState,i,t),{code:o}})}accept(e,t){return f(this,void 0,void 0,function*(){if(!this._mainSession)return{code:U.NOT_IN_CALL};const{callId:i}=e,{code:_}=yield this._signalModule.acceptCall({callId:i},t);return this._stopTimer(this._mainSession.getInviteeTimerId(),t),_!==U.SUCCESS||(this._clearMobileOnPhone(e.callId,t),this._mainSession.updateSessionState(y.CONNECTING)),{code:_}})}joinCall(e,t){return f(this,void 0,void 0,function*(){const i=this._context.getCurrentId();this._mainSession&&this._stopTimer(this._mainSession.getInviteeTimerId(),t);const{code:_}=yield this._signalModule.joinCall({callId:e.callId},t);return _!==U.SUCCESS||(this._abnormalModule.addAbnormallCallId(i,e.callId),this._mainSession?this._clearMobileOnPhone(e.callId,t):yield this._createSessionByServer(e.callId,t,!0)),{code:_}})}requestChangeMediaType(e,t){return f(this,void 0,void 0,function*(){if(!this._mainSession)return{code:U.NOT_IN_CALL};const i={mediaType:e.mediaType};this._mainSession.updateReqMediaType(e.mediaType);const _=ue(),{code:r}=yield this._signalModule.dialogUpCall({transactionId:_,callId:this._mainSession.getCallId(),toUserIds:e.toUserIds,dialogType:ie.SWITCH_MEDIA_TYPE,action:te.REQUEST,extraKeyVal:i},t);return r!==U.SUCCESS?{code:r}:{code:U.SUCCESS,data:{transactionId:_}}})}responseChangeMediaType(e,t){return f(this,void 0,void 0,function*(){return this._mainSession?this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:ie.SWITCH_MEDIA_TYPE,action:e.agree?te.ACCEPT:te.REFUSE},t):{code:U.NOT_IN_CALL}})}cancelChangeMediaType(e,t){return f(this,void 0,void 0,function*(){return this._mainSession?this._signalModule.dialogUpCall({transactionId:e.transactionId,callId:this._mainSession.getCallId(),dialogType:ie.SWITCH_MEDIA_TYPE,action:te.CANCEL},t):{code:U.NOT_IN_CALL}})}getCallLogList(e,t){return f(this,void 0,void 0,function*(){const i=this._context.getCurrentId(),{timestamp:_,count:r,order:s}=e,{code:o,data:n}=yield this._signalModule.syncCallLog({userId:i,syncTime:_,count:r,order:s},t);if(o!==U.SUCCESS)return{code:o};const l=n.callLogList.map(e=>$(e));return{code:U.SUCCESS,data:{hasMore:Boolean(null==n?void 0:n.hasMore),syncTime:0===s?n.maxTime:n.minTime,list:l}}})}deleteCallLog(e,t){return f(this,void 0,void 0,function*(){const i=this._context.getCurrentId();return this._signalModule.deleteCallRecord(i,e,t)})}getCallServerTimestamp(e){return f(this,void 0,void 0,function*(){const{code:t,data:i}=yield this._signalModule.getCallServerTimestamp(e);return t!==U.SUCCESS?{code:t}:{code:t,data:i.syncTime}})}getCallTimeInfo(e,t){return f(this,void 0,void 0,function*(){return this._signalModule.getCallTimeInfo(e,t)})}getOpenCallList(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId(),{code:i,data:_}=yield this._signalModule.getUserCallStateList(e);if(i!==U.SUCCESS)return{code:i};return{code:i,data:_.callStateList.map(i=>{const{callId:_,callType:r,mediaType:s,callingUserId:o,callUserIds:n,callStatus:l,crtTime:a,userSessionStatus:c,startTime:L,syncTime:E}=i,d=o===t?Oe.OUT:Oe.IN,{clientStartTime:C=L}=this._timeCorrectioner.calcClientStartTime(_,L,e);return{callId:_,callType:r,callDirection:d,mediaType:s,callerUserId:o,callUserIds:n,sessionState:l,userState:c,startTimestamp:L,endTimestamp:0,duration:Math.floor((+new Date-C)/1e3),syncTimestamp:E,systemState:0,createTimestamp:a}})}})}removeAllCallLog(e){return f(this,void 0,void 0,function*(){const{code:t}=yield this._signalModule.clearCallRecord(e);return{code:t}})}getCallSession(e,t){return f(this,void 0,void 0,function*(){const{code:i,data:_}=yield this._signalModule.getCallSession(e,t);if(i!==U.SUCCESS)return{code:i};const{callId:r,callingUserId:s,callType:o,mediaType:n,callStatus:l,callSessionUsers:a,startTime:c,duration:L,syncTime:E}=_;return{code:i,data:{callId:r,startCallerId:s,callType:o,mediaType:n,sessionState:l,callSessionUsers:a.map(e=>{const{userId:t,sessionStatus:i,sysStatus:_,targetType:r,targetId:s}=e;return{userId:t,userState:i,systemState:_,targetType:r,targetId:s,cameraEnable:!1,microphoneEnable:!1}}),startTime:c,duration:L,syncTime:E}}})}getHoldSession(e){const t=this._holdSessions.find(t=>t&&t.getCallId()===e);return t?new H(t,this,this._logger,this._rtcModule,this._context):null}getLocalMainSession(){return this._mainSession?new H(this._mainSession,this,this._logger,this._rtcModule,this._context):null}updateMainSessionState(e){var t;null===(t=this._mainSession)||void 0===t||t.updateSessionState(e)}setIsLocalClientHangup(e){var t;null===(t=this._mainSession)||void 0===t||t.setIsLocalClientHangup(e)}updateUsersState(e,t,i){this._logger.info(v.L_CALL_ENGINE_UPDATE_USERS_STATE_O,`updateUsersState -> users: ${JSON.stringify(t)}`,i);const _=[this._mainSession,...this._holdSessions].find(t=>(null==t?void 0:t.getCallId())===e),r=[];return _?r.push(..._.updateUserList(t,i)):r.push(...t),r}getCallStaringTime(e,t){return f(this,void 0,void 0,function*(){return this._timeCorrectioner.getCallClientTimeByServer(e.callId,t)})}systemStatusUp(e,t){return f(this,void 0,void 0,function*(){return this._signalModule.sysStatusUp(e,t)})}upFirstFrameTime(e){return f(this,void 0,void 0,function*(){if(!this._mainSession||this._mainSession&&this._mainSession.getCallType()!==M.SINGLE||this._isUpFirstFrameTime)return{code:U.SUCCESS};const t=Date.now(),i=this._timeCorrectioner.getLocalDelayTime(),_=Math.floor(t+i);this._logger.info(v.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_T,`now: ${t}; delay: ${i}; streamReadyTime: ${_}`,e),this._isUpFirstFrameTime=!0;const r=this._mainSession.getCallId(),{code:s}=yield this._signalModule.eventUpCall({callId:r,eventType:he.FIRST_FRAME,eventArgs:{streamReadyTime:_},eventTime:Date.now()},e);return this._logger.info(v.L_CALL_ENGINE_UP_FIRST_FRAME_TIME_R,`code: ${s}`,e),{code:s}})}endCurrentSession(e,t,i){const _=this._context.getCurrentId();if(this._mainSession&&this._mainSession.getCallId()===t){const t=this._mainSession.getUserList().map(t=>{let{userId:i,systemState:r,targetType:s,targetId:o}=t;return i===_&&(r=e),{userId:i,sessionStatus:P.ENDED,statusTime:Date.now(),duration:0,changed:1,inviteUserId:this._mainSession.getStartCallerId(),sysStatus:r,targetType:s,targetId:o}}),r={callId:this._mainSession.getCallId(),toDeviceId:this._signalModule.getDeviceId(),callStatus:y.ENDED,duration:0,callSessionUsers:t};this._onStatusDown(r,i)}}startTimeCorrection(e){this._timeCorrectioner.restart(e)}getDelayTimeInfo(){return{delayTime:this._timeCorrectioner.getLocalDelayTime(),rtt:this._timeCorrectioner.getRTT()}}upgradeMainSession(e){var t;const i=this._holdSessions.findIndex(t=>t.getCallId()===e);this._mainSession=null===(t=this._holdSessions.splice(i,1))||void 0===t?void 0:t[0]}endCurrentUserAbnormalCalls(e){return f(this,void 0,void 0,function*(){const t=this._context.getCurrentId(),i=yield this._abnormalModule.getAbnormalCallIds(t);if(!i)return{code:U.SUCCESS};const _=i.filter(e=>{var t;return e!==(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId())}),{code:r}=yield this._signalModule.endUserAbnormalCalls({callIds:_,allDevice:e?1:0});return r===U.SUCCESS&&this._abnormalModule.removeAbnormalCallIds(t,_),{code:r}})}setRTCModule(e){this._rtcModule=e}_onIMStateChange(e){const t=this._logger.createTraceId();let i=0;e===l.DISCONNECTED&&this._mainSession&&this._mainSession.getSessionState()!==y.ONCALL&&(i=le(()=>{var e;this._logger.info(v.L_CALL_ENGINE_IM_STATE_CHANGE_O,"endCurrentSession, IM disconnected for more than 60s",t),this.endCurrentSession(G.CONNECTION_ERR,null===(e=this._mainSession)||void 0===e?void 0:e.getCallId(),t)},6e4)),e===l.CONNECTED&&(i&&clearTimeout(i),this._initOpts.isAllowNewCallWhenRinging&&this.endCurrentUserAbnormalCalls(!0))}_handleCallTimeout(e,t,i){this._logger.warn(v.L_CALL_ENGINE_CALL_TIMEOUT_O,`call timeout callId: ${e}, userState: ${t}`,i);const _=[this._mainSession,...this._holdSessions].find(t=>t&&t.getCallId()===e);if(!_)return void this._logger.warn(v.L_CALL_ENGINE_CALL_TIMEOUT_O,`handleCallTimeout without session, callId: ${e}`,i);const r=this._context.getCurrentId();this._onStatusDown({callId:e,toDeviceId:this._signalModule.getDeviceId(),callStatus:y.ENDED,duration:0,callSessionUsers:_.getUserList().map(e=>{const{userId:i,targetType:s,targetId:o,stateTime:n}=e;let l,a;return i===r?(l=t===P.MISSED?G.MISSED:G.NO_ANSWER,a=t===P.MISSED?P.MISSED:P.NO_ANSWER):(l=t===P.MISSED?G.NO_ANSWER:G.MISSED,a=t===P.MISSED?P.NO_ANSWER:P.MISSED),{userId:i,sessionStatus:a,statusTime:n?n+1:Date.now(),duration:0,changed:1,inviteUserId:_.getCallerId(),sysStatus:l,targetType:s,targetId:o}})},i)}_startTimer(e,t,i){const _=le(()=>{this._handleCallTimeout(e,t,i),this._signalModule.statusUpCall({callId:e,sessionStatus:t},i)},6e4);return this._logger.info(v.L_CALL_ENGINE_START_CALL_TIMER_O,`callId: ${e}, timerId: ${_}`,i),_}_stopTimer(e,t){clearTimeout(e),this._logger.info(v.L_CALL_ENGINE_STOP_CALL_TIMER_O,`timerId: ${e}`,t)}_onInvite(e,t,i){this._clientCallId=c();const _=this._context.getCurrentId(),{callSessionUsers:r,secretChat:s,extra:o="{}"}=e;if(s===_e.SECRET)return void this.emit(Le.onPubInviteCallMiss,Object.assign(e,{extra:JSON.stringify(e),reason:Ee.SECRET_CALL,refer:t?de.PUB_INVITE:de.PULL_KV_INVITE}));r.some(e=>e.userId===_)&&this._selfIsInviteeHandle(e,t,i,o),this._othersIsInviteeHandle(e,i)}_selfIsInviteeHandle(e,t,i,_){const{callId:r,inviteUserId:s,callType:o,mediaType:n,callSessionUsers:l}=e,a=this._context.getCurrentId();this._abnormalModule.addAbnormallCallId(a,r);const c=new ne(r,y.RINGING,o,n,s,s,[],this._logger);this._signalModule.ringingCall({callId:r},i);const L=this._startTimer(r,P.MISSED,i);c.updateTimerId(re.INVITEE,L),this._mainSession?(this._holdSessions.push(c),this._mainSession.updateSessionState(y.BUSYLINE_WAIT)):this._mainSession=c;const E=new H(c,this,this._logger,this._rtcModule,this._context),d=t?Ne.PUB_INVITE_CALL:Ne.PULL_KV_INVITE_CALL;this.emit(pe.__INNER_INVITE__,E,d);const C=l.map(({userId:e,sessionStatus:t,sysStatus:i,targetType:_,targetId:r,statusTime:s})=>({userId:e,userState:t,systemState:i,targetType:_,targetId:r,stateTime:s})),T=this.updateUsersState(r,C,i);this._reportAppEventModule.onReceivedCall(E,i,JSON.parse(_||"{}").extra),T.length>0&&this.reportRemoteUserStateChange(r,T,i)}_othersIsInviteeHandle(e,t){var i,_,r;const{callId:s,inviteUserId:o,callSessionUsers:n}=e,l=this._context.getCurrentId(),a=n.filter(e=>e.userId!==l&&e.userId!==o&&e.sessionStatus===P.INVITED);if(!a.length)return;(null===(i=this._mainSession)||void 0===i?void 0:i.getCallType())===M.SINGLE&&(null===(_=this._mainSession)||void 0===_?void 0:_.getCallId())===s&&(this._onCallTypeChange(this._mainSession.getCallId(),M.MULTI,t),null===(r=this._mainSession)||void 0===r||r.updateCallType(M.MULTI));const c=[],L=[];a.forEach(e=>{const{userId:t,sessionStatus:i,sysStatus:_}=e;c.push({callId:s,userId:t,userState:i}),L.push({userId:t,userState:i,systemState:_})}),this._onOtherMemberInvite(c);const E=this.updateUsersState(s,L,t);E.length>0&&this.reportRemoteUserStateChange(s,E,t)}_onHangup(e,t,i){this._mainSession&&e.forEach(e=>{e.callId===this._mainSession.getCallId()&&(e.userState===P.CANCELLED?this._stopTimer(this._mainSession.getInviteeTimerId(),i):this._stopTimer(this._mainSession.getInviterTimerId(),i))})}_onAccept(e,t){var i,_,r,s;const o=null===(i=this._mainSession)||void 0===i?void 0:i.getSessionState(),n=[y.CONNECTING,y.ONCALL,y.BUSYLINE_WAIT];if((null===(_=this._mainSession)||void 0===_?void 0:_.getCallType())===M.SINGLE&&o&&n.includes(o))return;const l=this._mainSession.getStartCallerId(),a=this._context.getCurrentId();if((null===(r=this._mainSession)||void 0===r?void 0:r.getCallType())===M.SINGLE&&l===a){e.filter(e=>e.fromUserId!==a)&&this.emit(pe.__INNER_SESSION_CONNECT__,this.getLocalMainSession().getCallId(),t)}null===(s=this._mainSession)||void 0===s||s.updateSessionState(y.CONNECTING),this._stopTimer(this._mainSession.getInviterTimerId(),t)}_onStatusDown(e,t){var i,_;return f(this,void 0,void 0,function*(){const{callStatus:r,startTime:s,callId:o}=e;if(o!==(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId()))return;if(this._callStartMap[o]=this._callStartMap[o]||{},!this._callStartMap[o].isReceiveCallStartTime&&r===y.ONCALL){this._callStartMap[o].isReceiveCallStartTime=!0;const{code:e,clientStartTime:i}=this._timeCorrectioner.calcClientStartTime(o,s,t);e===Re.SUCCESS&&(this._callStartMap[o].callStartTime=i,this._reportAppEventModule.onReceivedCallStartTime({callId:o,callStartTime:i},t))}let n=!1;const l=this._context.getCurrentId(),a=e.callSessionUsers.map(e=>([P.IDLE,P.DECLINED,P.MISSED,P.NO_ANSWER,P.CANCELLED].includes(e.sessionStatus)&&e.sysStatus!==G.CANCELLED&&e.userId===l&&(n=!0),{userId:e.userId,userState:e.sessionStatus,systemState:e.sysStatus,stateTime:e.statusTime}));if(a.length){const e=this.updateUsersState(o,a,t);e.length>0&&this.reportRemoteUserStateChange(o,e,t)}if(!this._mainSession&&!this._holdSessions.length)return;const{hangupData:c,acceptData:L,otherInvitedData:E}=(e=>{const{callId:t}=e,i=[],_=[],r=[],s=[];return e.callSessionUsers.forEach(e=>{const{userId:o,sessionStatus:n,sysStatus:l}=e;switch(n){case P.INVITED:s.push({callId:t,userId:o,userState:n});break;case P.RINGING:i.push({callId:t,fromUserId:o});break;case P.CONNECTING:r.push({fromUserId:o});break;case P.CANCELLED:case P.DECLINED:case P.ENDED:case P.IDLE:_.push({callId:t,fromUserId:o,userState:n,systemState:l})}}),{ringingData:i,hangupData:_,acceptData:r,otherInvitedData:s}})(e);c.length>0&&this._onHangup(c,e.callStatus,t),L.length>0&&this._onAccept(L,t),E.length>0&&(null===(_=this._mainSession)||void 0===_?void 0:_.getCallType())===M.MULTI&&this._onOtherMemberInvite(E),(e.callStatus===y.ENDED||n)&&this._onSessionClose(e,t,n)})}_onOtherClientStatusDown(e,t){var i,_,r;const{callId:s,callSessionUsers:o}=e,n=this._context.getCurrentId(),l=o.find(({userId:e})=>e===n);if(l&&(this._mainSession||this._holdSessions.length)){const{userId:o,sessionStatus:a,statusTime:c}=l;if(a===P.CONNECTING){const l=[P.ONCALL,P.CONNECTING],L=(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())===s,E=null===(r=null===(_=this._mainSession)||void 0===_?void 0:_.getUserList().find(e=>e.userId===n))||void 0===r?void 0:r.userState;if(!(L&&E&&l.includes(E))){const i=this.updateUsersState(s,[{userId:o,userState:a,systemState:G.OTHER_CLIENT_ACCEPT,stateTime:c}],t);i.length>0&&this.reportRemoteUserStateChange(s,i,t),this._onSessionClose(e,t,!1)}}}}_onEventDown(e,t){var i;return f(this,void 0,void 0,function*(){const{callId:_,eventArgs:r,eventType:s}=e;if(_===(null===(i=this._mainSession)||void 0===i?void 0:i.getCallId())&&this._mainSession.getSessionState()===y.ONCALL&&s===he.CALL_DURATION){const{firstFrameTime:e}=r,{code:i,clientStartTime:s}=this._timeCorrectioner.calcClientStartTime(_,e,t);this._logger.info(v.L_CALL_ENGINE_RECEIVE_FIRST_FRAME_TIME_O,`clientFirstFrameTime: ${s}`,t),i===Re.SUCCESS&&(this._callStartMap[_].firstFrameTime=s,this._reportAppEventModule.onReceivedCallFirstFrameTime(_,s,t))}})}_onRecvSinCallDuration(e,t,i,_){var r;(null===(r=this._mainSession)||void 0===r?void 0:r.getCallId())===e&&(this._callStartMap[e].callStartTime=t,this._callStartMap[e].firstFrameTime=i,this._reportAppEventModule.onReceivedCallStartTime(Object.assign({callId:e},{callStartTime:t}),_),this._reportAppEventModule.onReceivedCallFirstFrameTime(e,i,_))}_onSwitchMediaType(e,t){var i,_,r,s,o;const{callId:n,action:l,extraKeyVal:a,transactionId:c,promoterId:L}=e,{mediaType:E,reason:d}=a,C=null===(i=this._mainSession)||void 0===i?void 0:i.getCallId();if(n!==C)return void this._logger.info(v.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,`not current session callId: ${C}, recvCallId: ${n}`,t);const{transactionId:T,action:I,mediaType:S}=(null===(_=this._mainSession)||void 0===_?void 0:_.getOldDialogData())||{};if(T!==c||I!==l||S!==E){if(this._logger.info(v.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,`action: ${l}, reason: ${d}`,t),null===(r=this._mainSession)||void 0===r||r.setOldDialogData({transactionId:c,action:l,mediaType:E}),l===te.REQUEST)this._onRequestChangeMediaType({transactionId:c,userId:L,mediaType:E},t);else{let e=null;switch(d){case te.CANCEL:e=b.CANCEL_CHANGE_MEDIA_TYPE;break;case te.ACCEPT:e=b.SERVER_ALLOW_MEDIA_TYPE,null===(s=this._mainSession)||void 0===s||s.updateMediaType(this._mainSession.getReqMediaType()),null===(o=this._mainSession)||void 0===o||o.updateReqMediaType(null);break;case te.REFUSE:e=b.REFUSE_CHANGE_MEDIA_TYPE;break;case te.TIMEOUT:e=b.CHANGE_MEDIA_TYPE_TIMEOUT}b[e]&&this._receiveMediaTypeChangeResult({transactionId:c,userId:L,mediaType:E},e,t)}l!==te.NOTICE||E!==D.AUDIO||d||this._receiveMediaTypeChangeResult({transactionId:c,userId:L,mediaType:E},b.SERVER_ALLOW_MEDIA_TYPE,t)}else this._logger.info(v.L_CALL_ENGINE_RECEIVE_MEDIATYPE_CHANGE_O,"duplicate dialog data",t)}_onRecvCallEndLog(e,t){const i=$(e);this._reportAppEventModule.onReceivedCallRecord(i,t)}_onSessionClose(e,t,i){const{callId:_}=e,r=this._context.getCurrentId();this._abnormalModule.removeAbnormalCallIds(r,[_]);let s=[this._mainSession,...this._holdSessions].find(e=>e&&e.getCallId()===_);if(!s)return void this._logger.warn(v.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,`unexpect session callId -> ${_}`,t);this._logger.warn(v.L_CALL_ENGINE_RECEIVE_CLOSE_SESSION_O,`callId: ${_}`,t),this.emit(pe.__INNER_SESSION_CLOSE__,_,t);const o=s.getUserList().find(e=>e.userId===r);let n;n=i&&e.toDeviceId!==this._signalModule.getDeviceId()?s.getIsLocalClientHangup()?o.systemState:G.OTHER_CLIENT_HANGUP:o.systemState,this._reportAppEventModule.onCallEnded(new H(s,this,this._logger,this._rtcModule,this._context),n,t),this._reportCallPlusSummaryMessage(s,_,n),this._mainSession&&this._mainSession.getCallId()===_&&(this._mainSession.getAllTimerIds().forEach(e=>this._stopTimer.bind(this)(e,t)),s.getCallType()===M.SINGLE&&(this._isUpFirstFrameTime=!1),delete this._callStartMap[_]),this._removeSession(_)}_reportCallPlusSummaryMessage(e,t,i){var _,r,s;const o=this._context.getCurrentId(),l=e.getUserList().filter(({userId:e})=>e!==o)[0].userId,a=e.getStartCallerId();if(!localStorage.getItem(`missMessageMap-${o}-${t}`)){const c={callId:t,callerUserId:a,targetId:l,mediaType:e.getMediaType(),firstFrameTime:(null===(_=this._callStartMap[t])||void 0===_?void 0:_.firstFrameTime)||0,callStartTime:(null===(r=this._callStartMap[t])||void 0===r?void 0:r.callStartTime)||0,callEndTime:(null===(s=this._callStartMap[t])||void 0===s?void 0:s.callStartTime)?+new Date-this._timeCorrectioner.getLocalDelayTime():0,hangupReason:i};this._reportAppEventModule.onReceivedCallPlusSummaryMessage({messageType:"RC:CallPlusSummary",content:c,senderUserId:a,targetId:l,channelId:"",conversationType:L.PRIVATE,sentTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),receivedTime:+new Date-this._timeCorrectioner.getLocalDelayTime(),messageUId:t,messageDirection:a===o?E.SEND:E.RECEIVE,isPersited:!0,isCounted:!1,isOffLineMessage:!1,canIncludeExpansion:!1,receivedStatus:d.READ,isStatusMessage:!1,isMentioned:!1,expansion:null,disableNotification:!1,sentStatus:n.SENT}),localStorage.setItem(`missMessageMap-${o}-${t}`,t)}}_removeSession(e){var t;if(e===(null===(t=this._mainSession)||void 0===t?void 0:t.getCallId()))this._mainSession=null;else{const t=this._holdSessions.findIndex(t=>(null==t?void 0:t.getCallId())===e);this._holdSessions.splice(t,1)}}_createSessionByServer(e,t,i=!1){return f(this,void 0,void 0,function*(){this._logger.info(v.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_T,`callId: ${e}`,t);const{code:_,data:r}=yield this.getCallSession({callId:e},t);if(_!==U.SUCCESS)return void this._logger.error(v.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,`errcode: ${_}`,t);this._logger.info(v.L_CALL_ENGINE_CREATE_SESSION_BY_SERVER_R,`code: ${_}, data: ${JSON.stringify(r)}`,t);const{callType:s,mediaType:o,callSessionUsers:n,startCallerId:l}=r;this._mainSession=new ne(e,y.CONNECTING,s,o,l,l,[],this._logger),i&&this._clearMobileOnPhone(e,t);const a=this.updateUsersState(e,n,t);a.length>0&&this.reportRemoteUserStateChange(e,a,t)})}_clearMobileOnPhone(e,t){return f(this,void 0,void 0,function*(){const i=[this._mainSession,...this._holdSessions].find(t=>(null==t?void 0:t.getCallId())===e);if(i&&i.getCallType()===M.MULTI){this._logger.info(v.L_CALL_ENGINE_UP_ON_PHONE_END_T,`callId: ${e}`,t);const{code:i}=yield this.systemStatusUp({callId:e,sysStatus:G.ON_PHONE_END,forward:Ae.CURRENT},t);i===U.SUCCESS?this._logger.info(v.L_CALL_ENGINE_UP_ON_PHONE_END_R,`callId: ${e}`,t):this._logger.warn(v.L_CALL_ENGINE_UP_ON_PHONE_END_R,`callId: ${e}, errCode: ${i}`,t)}})}reportRemoteUserStateChange(e,t,i){const _=this._context.getCurrentId();t.forEach(t=>{const{userId:r,userState:s,systemState:o}=t;r!==_&&this._reportAppEventModule.onRemoteUserStateChanged({callId:e,userId:r,userState:s,reason:o},i)}),t.forEach(({userId:t,systemState:r})=>{t===_&&r===G.ABNORMAL_END&&this.emit(pe.__INNER_SESSION_CLOSE__,e,i)})}_onOtherMemberInvite(e){e.forEach(e=>{var t;const{userId:i,callId:_}=e,r=null===(t=this.getLocalMainSession())||void 0===t?void 0:t.getInviterUserId();this._reportAppEventModule.onRemoteUserInvited([i],r,_)})}_onRequestChangeMediaType(e,t){var i;const{userId:_,transactionId:r,mediaType:s}=e;null===(i=this._mainSession)||void 0===i||i.updateReqMediaType(s),this._reportAppEventModule.onReceivedChangeMediaTypeRequest(_,r,s,t)}_receiveMediaTypeChangeResult(e,t,i){t===b.SERVER_ALLOW_MEDIA_TYPE&&this.emit(pe.__INNER_CHANGE_MEDIA_TYPE__,e.mediaType,i),this._reportAppEventModule.onReceivedChangeMediaTypeResult(Object.assign(Object.assign({},e),{code:t}),i)}_onCallTypeChange(e,t,i){this._reportAppEventModule.onCallTypeChanged(t,e,i)}}var fe,Ue;Object.defineProperty(pe,"__INNER_SESSION_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-close"}),Object.defineProperty(pe,"__INNER_SESSION_CONNECT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-session-connect"}),Object.defineProperty(pe,"__INNER_CHANGE_MEDIA_TYPE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-change-media-type"}),Object.defineProperty(pe,"__INNER_INVITE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-invite"}),function(e){e.NORMAL="RongCloudRTC",e.SCREEN="ScreenShare"}(fe||(fe={}));class ve extends r{constructor(e,t,i,_,r,s){super(),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_room",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_callMediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:h.W640_H480,frameRate:R.FPS_15}}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_isPubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_audioOutputDeviceId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_videoConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_audioConfigIsChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_userViewMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_callPlusStatusReportListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_remoteAudioEnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"_preHangupCallId",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._rtcClient=null==i?void 0:i.rtcClient,this._isPubTiny=i.isPubTiny||!1}setCallPlusStatusReportListener(e){this._callPlusStatusReportListener=e}getCameraVideoTrack(e){return f(this,void 0,void 0,function*(){const t=this.getLocalVideoTrack(),{code:i,track:_}=t&&!this._videoConfigIsChange?{track:t,code:U.SUCCESS}:yield this._createVideoTrack(e);return this._videoConfigIsChange=!1,i!==U.SUCCESS?{code:i}:{code:U.SUCCESS,track:_}})}getMicrophoneAudioTrack(e){return f(this,void 0,void 0,function*(){const t=this.getLocalAudioTrack(),{code:i,track:_}=t&&!this._audioConfigIsChange?{track:t,code:U.SUCCESS}:yield this._createAudioTrack(e);return this._audioConfigIsChange=!1,i!==U.SUCCESS?{code:i}:{code:U.SUCCESS,track:_}})}createCallMediaTracks(e,t){return f(this,void 0,void 0,function*(){this._callMediaType=e;const{code:i}=yield this.getMicrophoneAudioTrack(t);if(i!==U.SUCCESS)return{code:i};if(e===D.AUDIO_VIDEO){const{code:e}=yield this.getCameraVideoTrack(t);e!==U.SUCCESS&&this._logger.warn(v.L_RTC_MODULE_CREATE_CALL_MEDIA_TRACKS_P,`get camera video track error code: ${e}`,t)}return{code:U.SUCCESS}})}setVideoConfig(e){this._videoConfigIsChange=!0,this._videoConfig=e}setAudioConfig(e){this._audioConfigIsChange=!0,this._audioConfig=e}setAudioOutputDeviceId(e){return f(this,void 0,void 0,function*(){if("string"!=typeof e||0===e.length)return{code:U.PARAM_ERROR};if(this._audioOutputDeviceId===e)return{code:U.SUCCESS};if(this._audioOutputDeviceId=e,this._room){this._room.getRemoteTracks().filter(e=>e.isAudioTrack()).forEach(t=>{t.isSubscribed()&&t.play(void 0,{audioDeviceId:e})})}return{code:U.SUCCESS}})}destroyAllTracks(e){this._logger.info(v.L_RTC_MODULE_DESTROY_ALL_TRACKS_O,"",e),this._localTracks.forEach(e=>{e.destroy()}),this._localTracks.length=0}setAllRemoteAudioEnable(e,t){if(this._logger.info(v.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_T,`enable: ${e}`,t),!i(e))return this._logger.error(v.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,`param error, enable: type is boolean, value: ${e}`),{code:U.PARAM_ERROR};if(this._remoteAudioEnable=e,!this._room)return{code:U.SUCCESS};return this._room.getRemoteTracks().filter(e=>e.isAudioTrack()).forEach(t=>{e?t.unmute():t.mute()}),this._logger.info(v.L_RTC_MODULE_SET_ALL_REMOTE_AUDIO_ENABLE_R,"success",t),{code:U.SUCCESS}}destroyTrack(e){return f(this,void 0,void 0,function*(){e.destroy();const t=this._localTracks.findIndex(t=>t.getTrackId()===e.getTrackId());this._localTracks.splice(t,1)})}sessionConnected(e,t){return f(this,void 0,void 0,function*(){if(this._preHangupCallId=null,this._logger.info(v.L_RTC_MODULE_SESSION_CONNECT_T,`callId: ${e}`,t),!this._room){const{code:i,room:_}=yield this.joinRTCRoom(e,t);if(i!==U.SUCCESS)return;if(this._room=_,this._preHangupCallId&&this._room.getRoomId()===this._preHangupCallId)return this._rtcClient.leaveRoom(this._room),void this._releaseStoredData();const r=this._room.getRemoteUserIds();this._onSelfJoined(e,r,t)}this._callId=e,this._regRTCListeners();let i=this._room.getRemoteTracks();if(i&&i.length&&this._onRemoteTrackPublish(i),this._localTracks.length>0){this.emit(Le.onBeforePublish);const e=this._isPubTiny?this._localTracks.map(e=>e.isVideoTrack()?{track:e,isPubTiny:!0}:e):this._localTracks,{code:i}=yield this.publish(e,t);this.emit(Le.onPublishRes,i)}else this._logger.warn(v.L_RTC_MODULE_SESSION_CONNECT_P,"sessionConnected local tracks is empty",t);this._logger.info(v.L_RTC_MODULE_SESSION_CONNECT_R,`code: ${U.SUCCESS}`,t)})}sessionClose(e,t){var i;return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_SESSION_CLOSE_T,`callId: ${e}`,t),this._preHangupCallId=e,this.destroyAllTracks(t);const _=null===(i=this._room)||void 0===i?void 0:i.getRoomId();if(this._room&&e===_){const{code:e}=yield this._rtcClient.leaveRoom(this._room);if(this._releaseStoredData(),e!==A.SUCCESS)return void this._logger.error(v.L_RTC_MODULE_SESSION_CLOSE_R,`leaveRoom failed, code: ${e}`,t);this._logger.info(v.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom success",t)}else this._logger.warn(v.L_RTC_MODULE_SESSION_CLOSE_R,"leaveRoom throw exception: not in room",t)})}disableVideoTrack(){return f(this,void 0,void 0,function*(){const e=this.getLocalVideoTrack();if(!e)return{code:U.CAMERA_CLOSED};return{code:yield e.mute(),track:e}})}enableVideoTrack(e){return f(this,void 0,void 0,function*(){const e=this.getLocalVideoTrack();if(!e)return{code:U.CAMERA_CLOSED};if(!e.isOwnerMuted())return{code:U.SUCCESS};return{code:yield e.unmute()}})}changeVideoDevice(e){return f(this,void 0,void 0,function*(){const t=[],i=[],{code:_,track:r}=yield this._rtcClient.createCameraVideoTrack(fe.NORMAL,this._videoConfig);if(_!==A.SUCCESS)return{code:_};const{minBitrate:s,maxBitrate:o}=this._videoConfig;let n;if((s||o)&&r.setBitrate(o,s),this._localTracks&&this._localTracks.forEach(e=>{e.isVideoTrack()?(e.destroy(),n=e):i.push(e)}),this._localTracks=this._localTracks.filter(e=>n&&e.getTrackId()!==n.getTrackId()),t.push(r),i.push(r),this._localTracks=i,this._onLocalTrackReady(t,e),this._room){const{code:e}=yield this._room.publish(t);if(e!==A.SUCCESS)return{code:e}}return{code:U.SUCCESS,track:r}})}changeAudioDevice(e){return f(this,void 0,void 0,function*(){const t=[],i=[],_=Object.assign(Object.assign({},this._audioConfig),{micphoneId:this._audioConfig.microphoneId}),{code:r,track:s}=yield this._rtcClient.createMicrophoneAudioTrack(fe.NORMAL,_);if(r!==A.SUCCESS)return{code:r};if(this._localTracks&&this._localTracks.forEach(e=>{e.isAudioTrack()||i.push(e)}),t.push(s),i.push(s),this._localTracks=i,this._onLocalTrackReady(t,e),this._room){const{code:e}=yield this._room.publish(t);if(e!==A.SUCCESS)return{code:e}}return{code:U.SUCCESS}})}disableAudioTrack(){return f(this,void 0,void 0,function*(){const e=this.getLocalAudioTrack();if(!e)return{code:U.MICROPHONE_CLOSED};return{code:yield e.mute(),track:e}})}changeMediaType(e,t){return f(this,void 0,void 0,function*(){let i;this._logger.info(v.L_RTC_MODULE_CHANGE_MEDIA_TYPE_T,`mediaType: ${e}`,t),i=e===D.AUDIO_VIDEO?yield this._upgradeMediaType(t):yield this._downgradeMediaType(t),i.code===U.SUCCESS&&this._logger.info(v.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,"success",t)})}_upgradeMediaType(e){return f(this,void 0,void 0,function*(){let t=this.getLocalVideoTrack();if(!t){const{code:i,track:_}=yield this._createVideoTrack(e);if(i!==U.SUCCESS)return this._logger.error(v.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`create video track errCode: ${i}`,e),{code:i};t=_;const{minBitrate:r,maxBitrate:s}=this._videoConfig;(r||s)&&t.setBitrate(s,r)}const i=this._isPubTiny?{track:t,isPubTiny:!0}:t,{code:_}=yield this.publish([i],e);return _!==U.SUCCESS&&this._logger.error(v.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`publish errCode: ${_}`,e),{code:_}})}_downgradeMediaType(e){return f(this,void 0,void 0,function*(){const t=this.getLocalVideoTrack();if(t){const{code:i}=yield this._room.unpublish([t]);if(i!==A.SUCCESS)return this._logger.error(v.L_RTC_MODULE_CHANGE_MEDIA_TYPE_R,`unpublish errCode: ${i}`,e),{code:i};this.destroyTrack(t)}return{code:U.SUCCESS}})}joinRTCRoom(e,t){return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_JOIN_RTC_ROOM_T,`call: ${e}`,t);const{code:i,room:_,tracks:r}=yield ce({asyncFn:this._rtcClient.joinRTCRoomWithOptions.bind(this._rtcClient),fnArgs:[e,{mode:C.CALL}]});return i!==A.SUCCESS?(this._logger.error(v.L_RTC_MODULE_JOIN_RTC_ROOM_R,`callId: ${e}, errCode: ${i}`,t),this._onRTCMethodFail(G.JOIN_ROOM_ERR,t),{code:i}):(this._logger.info(v.L_RTC_MODULE_JOIN_RTC_ROOM_R,"success",t),this._callId=e,{code:U.SUCCESS,room:_,tracks:r})})}subscribeTracks(e,t){return f(this,void 0,void 0,function*(){if(this._logger.info(v.L_RTC_MODULE_SUBSCRIBE_T,JSON.stringify({params:e.map(e=>{const{track:t,subTiny:i}=e;return{trackId:t.getTrackId(),subTiny:i}})}),t),!this._room)return{code:U.SUCCESS};const{code:i}=yield ce({asyncFn:this._room.subscribe.bind(this._room),fnArgs:[e],onError:e=>{}});return i!==A.SUCCESS?(this._reportAppEventModule.onFetchRemoteMediaError(e,i),this._onRTCMethodFail(G.SUBSCRIBE_ERR,t),this._logger.error(v.L_RTC_MODULE_SUBSCRIBE_R,`errorCode: ${i}`,t),{code:i}):(this._logger.info(v.L_RTC_MODULE_SUBSCRIBE_R,"success",t),{code:U.SUCCESS})})}unsubscribeTracks(e,t){return f(this,void 0,void 0,function*(){if(this._logger.info(v.L_RTC_MODULE_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map(e=>e.getTrackId())}),t),!this._room)return{code:U.SUCCESS};const{code:i}=yield this._room.unsubscribe(e);return i!==A.SUCCESS?(this._logger.error(v.L_RTC_MODULE_UNSUBSCRIBE_R,`errorCode: ${i}`,t),{code:i}):(this._logger.info(v.L_RTC_MODULE_UNSUBSCRIBE_R,"success",t),{code:U.SUCCESS})})}_releaseStoredData(){this._room=null,this._remoteAudioEnable=!0,this._userViewMap={},this._preHangupCallId=null}getRemoteTracks(){const e={};if(!this._room)return e;return this._room.getRemoteUserIds().forEach(t=>{e[t]=this._room.getRemoteTracksByUserId(t)}),e}getRemoteTrack(e,t){var i;return null===(i=this._room)||void 0===i?void 0:i.getRemoteTracksByUserId(e).find(e=>t===D.AUDIO?e.isAudioTrack():e.isVideoTrack())}getRTCSessionId(){return this._room?this._room.getSessionId():null}_regRTCListeners(){this._room.registerRoomEventListener({onKickOff:(e,t)=>{this._onKickOff(e,this._room.getRoomId(),t),this._releaseStoredData()},onUserJoin:e=>{const t=e.map(e=>({callId:this._callId,userId:e})),i=this._logger.createTraceId();this._onOtherMemJoined(t,i)},onUserLeave:e=>{e.forEach(e=>{delete this._userViewMap[e]})},onTrackPublish:this._onRemoteTrackPublish.bind(this),onTrackUnpublish:this._onTrackUnpublish.bind(this),onTrackReady:e=>{this._onRemoteTrackReady([e])},onVideoMuteChange:e=>{this._onVideoMuteChagne({fromUserId:e.getUserId(),muted:e.isOwnerMuted(),trackId:e.getTrackId()})},onAudioMuteChange:e=>{this._onAudioMuteChange({fromUserId:e.getUserId(),muted:e.isOwnerMuted(),trackId:e.getTrackId()})},onRTCPeerConnectionCloseByException:this._onRTCPeerConnectionCloseByException.bind(this)}),this._room.registerReportListener({onStateReport:this._onRTCStateReport.bind(this)}),this._room.onAudioLevelChange(e=>{this._reportAppEventModule.onUserAudioLevelChanged(e)})}_onLocalTrackReady(e,t){this._reportAppEventModule.onUserMediaAvailable(e,t)}_onRemoteTrackReady(e){this._reportAppEventModule.onUserMediaAvailable(e),this.emit(ve.__INNER_RECEIVE_FIRST_FRAME__)}_onKickOff(e,t,i,_){this._logger.info(v.L_RTC_MODULE_RECEIVE_KICK_OFF_O,`roonId: ${t}, byServer: ${e}, state: ${i}, kickExtra: ${JSON.stringify(_)}`);let r=G.CONNECTION_ERR;if(e)if(_)r=_.kickReasonCode;else switch(i){case N.SERVER_KICK:r=G.KICKED_BY_SERVER;break;case N.OTHER_KICK:r=G.OTHER_CLIENT_JOINED;break;case N.IM_DISCONNECTED:r=G.CONNECTION_ERR;break;case N.IM_LOGOUT:r=G.LOGOUT;break;case N.OTHER_CLIENT_IM_CONNECTED:r=G.OTHER_CLIENT_LOGIN}this.emit(ve.__INNER_ON_KICKOFF__,r,t)}_onRTCPeerConnectionCloseByException(){const e=this._logger.createTraceId();this._logger.info(v.L_RTC_MODULE_RECEIVE_PEERCONNECTION_EXCEPT_CLOSE_O,"",e),this.emit(ve.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,e)}_onSelfJoined(e,t,i){return f(this,void 0,void 0,function*(){this.emit(ve.__INNER_ON_SELF_JOINED__,e,t,i)})}_onRemoteTrackPublish(e){const t=this._logger.createTraceId();this._logger.info(v.L_RTC_MODULE_RECEIVE_TRACK_PUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map(e=>e.getTrackId())}),t);const i=[];e.forEach(e=>{var t;const _=e.getUserId();if(e.isAudioTrack())i.push({track:e,subTiny:!1}),this._reportAppEventModule.onRemoteMicrophoneStateChanged(this._callId,e);else if(this._reportAppEventModule.onRemoteCameraStateChanged(this._callId,e),null===(t=this._userViewMap[_])||void 0===t?void 0:t.videoView){const{isTiny:t}=this._userViewMap[_];i.push({track:e,subTiny:t})}}),i.length&&this.subscribeTracks(i,t)}_onTrackUnpublish(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();this._logger.info(v.L_RTC_MODULE_RECEIVE_TRACK_UNPUBLISH_O,JSON.stringify({callId:this._callId,trackIds:e.map(e=>e.getTrackId())}),t),yield this.unsubscribeTracks(e,t)})}_onAudioMuteChange(e){const t=this._logger.createTraceId();this._logger.info(v.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);const i=this._room.getRemoteTrack(e.trackId);this._reportAppEventModule.onRemoteMicrophoneStateChanged(this._callId,i)}_onVideoMuteChagne(e){const t=this._logger.createTraceId();this._logger.info(v.L_RTC_MODULE_RECEIVE_TRACK_ENABLE_CHANGE_O,JSON.stringify({info:e}),t);const i=this._room.getRemoteTrack(e.trackId);this._reportAppEventModule.onRemoteCameraStateChanged(this._callId,i)}_onRTCStateReport(e){const{senders:t,receivers:i}=e;t.forEach(e=>{var t;const{kind:i,packetsLostRate:_,rtt:r}=e;this._callMediaType===D.AUDIO_VIDEO&&"audio"===i||null===(t=this._callPlusStatusReportListener)||void 0===t||t.onSendPacketLoss(_||0,r||0)}),i.forEach(e=>{var t;const{trackId:i,kind:_,packetsLostRate:r,bitrate:s}=e;if(this._callMediaType===D.AUDIO_VIDEO&&"audio"===_)return;const{userId:o}=O.parseTrackId(i),n={};n[o]={packetLostRate:r||0,bitRate:s},null===(t=this._callPlusStatusReportListener)||void 0===t||t.onReceivePacketLoss(n)})}_onRTCMethodFail(e,t){this.emit(ve.__INNER_RTC_PROCESS_FAILED__,e,t)}_onOtherMemJoined(e,t){this.emit(ve.__INNER_ON_OTHER_JOINED__,e,t)}_createAudioTrack(e){return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_CREATE_AUDIO_TRACK_T,"",e);const t=Object.assign(this._audioConfig,{micphoneId:this._audioConfig.microphoneId}),{code:i,track:_}=yield this._rtcClient.createMicrophoneAudioTrack(fe.NORMAL,t);if(i!==A.SUCCESS)return this._logger.error(v.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,`errCode: ${i}`,e),{code:i};this._logger.info(v.L_RTC_MODULE_CREATE_AUDIO_TRACK_R,"success",e);const{minBitrate:r,maxBitrate:s}=this._audioConfig;return(r||s)&&_.setBitrate(s,r),this._localTracks.push(_),this._onLocalTrackReady([_],e),{code:U.SUCCESS,track:_}})}_createVideoTrack(e){return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_CREATE_VIDEO_TRACK_T,"",e);const{code:t,track:i}=yield this._rtcClient.createCameraVideoTrack(fe.NORMAL,this._videoConfig);if(t!==A.SUCCESS)return this._logger.error(v.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,`errCode: ${t}`,e),{code:t};this._logger.info(v.L_RTC_MODULE_CREATE_VIDEO_TRACK_R,"success",e);const{minBitrate:_,maxBitrate:r}=this._videoConfig;return(_||r)&&i.setBitrate(r,_),this._localTracks.push(i),this._onLocalTrackReady([i],e),{code:U.SUCCESS,track:i}})}getLocalVideoTrack(){let e;return this._localTracks&&([e]=this._localTracks.filter(e=>e.isVideoTrack())),e}getLocalAudioTrack(){let e;return this._localTracks&&([e]=this._localTracks.filter(e=>e.isAudioTrack())),e}publish(e,t){return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_PUBLISH_T,`tracksIds: ${e.map(e=>e instanceof m?e.getTrackId():e.track.getTrackId())}`,t);const{code:i}=yield ce({asyncFn:this._room.publish.bind(this._room),fnArgs:[e],onError:e=>{}});return i!==A.SUCCESS?(this._onRTCMethodFail(G.PUBLISH_ERR,t),this._logger.error(v.L_RTC_MODULE_PUBLISH_R,`errCode: ${i}`,t),{code:i}):(this._logger.info(v.L_RTC_MODULE_PUBLISH_R,`code: ${U.SUCCESS}`,t),{code:U.SUCCESS})})}publishVideoTrack(){const e=this.getLocalVideoTrack(),t=this._isPubTiny?{track:e,isPubTiny:!0}:e;return this._room.publish([t])}setVideoView(e,t){const i=[];e.forEach(e=>{const{userId:t,videoElement:_,isTiny:r=!1}=e;if(this._userViewMap[t]={videoView:_,isTiny:r},t===this._context.getCurrentId())return;if(!this._room)return;const s=(this.getRemoteTracks()[t]||[]).map(e=>({track:e,subTiny:r}));i.push(...s)}),this._logger.info(v.L_RTC_MODULE_SET_VIDEO_VIEW_O,JSON.stringify({userViewMap:j(this._userViewMap),needSubTrackIds:i.map(({track:e})=>e.getTrackId())}),t),i.length&&this.subscribeTracks(i,t)}removeVideoView(e,t){const i=[];e.forEach(e=>{const t=this.getRemoteTracks()[e];if(t&&t.length){const e=t.filter(e=>e.isVideoTrack());e.length&&i.push(e[0])}delete this._userViewMap[e]}),this._logger.info(v.L_RTC_MODULE_REMOVE_VIDEO_VIEW_O,JSON.stringify({userViewMap:j(this._userViewMap),unsubTracks:i.map(e=>e.getTrackId())}),t),i.length&&this.unsubscribeTracks(i,t)}getUserViewMap(){return this._userViewMap}playMedia(e,t,i,_){var r;return f(this,void 0,void 0,function*(){this._logger.info(v.L_RTC_MODULE_PLAY_MEDIA_T,`userId: ${e}, mediaType: ${t}, videoView: ${null==i?void 0:i.nodeName}`,_);const s=this._context.getCurrentId();if(e===s&&t===D.AUDIO)return this._logger.error(v.L_RTC_MODULE_PLAY_MEDIA_R,"please avoid playing local audio to prevent echoes.",_),{code:U.PLAY_MEDIA_FAILED};let o=null;if(o=e===s?t===D.AUDIO?null:this.getLocalVideoTrack():null===(r=this.getRemoteTracks()[e])||void 0===r?void 0:r.filter(e=>t===D.AUDIO?e.isAudioTrack():e.isVideoTrack())[0],!o)return this._logger.error(v.L_RTC_MODULE_PLAY_MEDIA_R,`error code: ${U.MEDIA_RESOURCE_INVALIED}`,_),{code:U.MEDIA_RESOURCE_INVALIED};try{const{code:e}=o.isAudioTrack()?yield o.play(void 0,{audioDeviceId:this._audioOutputDeviceId||void 0}):yield o.play(i);return o.isAudioTrack()&&!this._remoteAudioEnable&&o.mute(),e!==A.SUCCESS?(this._logger.error(v.L_RTC_MODULE_PLAY_MEDIA_R,`errCode: ${e}`,_),{code:e}):(this._logger.info(v.L_RTC_MODULE_PLAY_MEDIA_R,"success",_),{code:U.SUCCESS})}catch(e){return this._logger.error(v.L_RTC_MODULE_PLAY_MEDIA_R,`errCode: ${U.PLAY_MEDIA_FAILED}, message: ${e.message},`,_),{code:U.PLAY_MEDIA_FAILED}}})}}Object.defineProperty(ve,"__INNER_RTC_PROCESS_FAILED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-process-failed"}),Object.defineProperty(ve,"__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-rtc-peerconnection-abnormal-close"}),Object.defineProperty(ve,"__INNER_ON_SELF_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-self-joined"}),Object.defineProperty(ve,"__INNER_ON_OTHER_JOINED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-on-other-joined"}),Object.defineProperty(ve,"__INNER_RECEIVE_FIRST_FRAME__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-receive-first-frame"}),Object.defineProperty(ve,"__INNER_ON_KICKOFF__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-kickoff-frame"});class Me{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}registerEventListener(e){this._listener=e}_callAppListener(e,...t){var i;return f(this,void 0,void 0,function*(){const _=null===(i=this._listener)||void 0===i?void 0:i[e];if(_)try{yield _(...t)}catch(e){console.error(e),this._logger.error(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({name:e.name,message:e.message}))}})}onReceivedCall(e,t,i){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCall",callId:e.getCallId()}),t),this._callAppListener("onReceivedCall",e,i)}onRemoteUserInvited(e,t,i){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserInvited",inviteeUserList:e,inviterUserId:t,callId:i})),this._callAppListener("onRemoteUserInvited",e,t,i)}onCallConnected(e){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallConnected",callId:e.getCallId()})),this._callAppListener("onCallConnected",e)}onCallTypeChanged(e,t,i){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallTypeChanged",callId:t,callType:e}),i),this._callAppListener("onCallTypeChanged",e,t)}onRemoteUserStateChanged(e,t){const{callId:i,userId:_,userState:r,reason:s}=e;this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteUserStateChanged",callId:i,userId:_,userState:r,reason:s}),t),this._callAppListener("onRemoteUserStateChanged",i,_,r,s)}onCallEnded(e,t,i){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onCallEnded",callId:e.getCallId(),closeReason:t}),i),this._callAppListener("onCallEnded",e,t)}onRemoteCameraStateChanged(e,t){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteCameraStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));const i=null==t?void 0:t.getUserId();this._callAppListener("onRemoteCameraStateChanged",e,i,null==t?void 0:t.isOwnerMuted())}onRemoteMicrophoneStateChanged(e,t){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onRemoteMicrophoneStateChanged",callId:e,trackId:null==t?void 0:t.getTrackId(),enable:null==t?void 0:t.isOwnerMuted()}));const i=null==t?void 0:t.getUserId();this._callAppListener("onRemoteMicrophoneStateChanged",e,i,null==t?void 0:t.isOwnerMuted())}onReceivedCallRecord(e,t){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallRecord",record:e}),t),this._callAppListener("onReceivedCallRecord",e)}onReceivedChangeMediaTypeRequest(e,t,i,_){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeRequest",userId:e,transactionId:t}),_),this._callAppListener("onReceivedChangeMediaTypeRequest",e,t,i)}onReceivedChangeMediaTypeResult(e,t){const{userId:i,transactionId:_,mediaType:r,code:s}=e;this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedChangeMediaTypeResult",userId:i,mediaType:r}),t),this._callAppListener("onReceivedChangeMediaTypeResult",{userId:i,transactionId:_,mediaType:r,code:s})}onReceivedCallStartTime(e,t){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallStartTime",info:e}),t),this._callAppListener("onReceivedCallStartTime",e)}onReceivedCallFirstFrameTime(e,t,i){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onReceivedCallFirstFrameTime",callId:e,callFirstFrameTime:t}),i),this._callAppListener("onReceivedCallFirstFrameTime",e,t)}onUserMediaAvailable(e,t){this._logger.info(v.L_CALLPLUS_CLIENT_CALL_EVENT_LISTENER_O,JSON.stringify({eventType:"onUserMediaAvailable",trackIds:e.map(e=>e.getTrackId())}),t),e.forEach(e=>{const t=e.getUserId(),i=e.isAudioTrack()?D.AUDIO:D.VIDEO;this._callAppListener("onUserMediaAvailable",t,i)})}onFetchRemoteMediaError(e,t){e.forEach(({track:e})=>{const i=e.getUserId();this._callAppListener("onFetchRemoteMediaError",i,t)})}onUserAudioLevelChanged(e){e.forEach(({track:e,audioLevel:t})=>{const i=e.getUserId();this._callAppListener("onUserAudioLevelChanged",i,t)})}onReceivedCallPlusSummaryMessage(e){this._callAppListener("onReceivedCallPlusSummaryMessage",e)}onReceivedGroupCallStatusMessage(e){this._callAppListener("onReceivedGroupCallStatusMessage",e)}}!function(e){e[e.UNKNOW_ERR=41e3]="UNKNOW_ERR",e[e.DB_ERR=41001]="DB_ERR",e[e.JSON_ERR=41002]="JSON_ERR",e[e.INVALID_JSON_ERR=41003]="INVALID_JSON_ERR",e[e.MISSING_PARAMS=41004]="MISSING_PARAMS",e[e.PARAMS_REQUIRED=41005]="PARAMS_REQUIRED",e[e.DATA_FORMAT_ERR=41006]="DATA_FORMAT_ERR",e[e.METHOD_NOT_IMPLEMENTED=41007]="METHOD_NOT_IMPLEMENTED",e[e.CALL_NOT_EXIST=41010]="CALL_NOT_EXIST",e[e.SINGAL_EXCEED_TWO_INVITEE=41011]="SINGAL_EXCEED_TWO_INVITEE",e[e.GROUP_EXCEEDS_QUORUM=41012]="GROUP_EXCEEDS_QUORUM",e[e.OPERATION_EXPIRED=41013]="OPERATION_EXPIRED",e[e.DEVICE_IS_CALLING=41014]="DEVICE_IS_CALLING",e[e.REPORT_STREAM_READY_TIME_IS_INVALID=41018]="REPORT_STREAM_READY_TIME_IS_INVALID",e[e.NOT_CALL_YOURSELF=41019]="NOT_CALL_YOURSELF",e[e.SESSION_STATUS_NOT_EXIST=41020]="SESSION_STATUS_NOT_EXIST",e[e.HANGUP_NOT_ALLOW=41021]="HANGUP_NOT_ALLOW",e[e.ACCEPT_NOT_ALLOW=41022]="ACCEPT_NOT_ALLOW",e[e.OPERATION_NOT_ALLOW=41025]="OPERATION_NOT_ALLOW",e[e.TRANSACTION_ID_ERR=41100]="TRANSACTION_ID_ERR",e[e.UP_VIDEO_CANCELED=41050]="UP_VIDEO_CANCELED",e[e.CURRENT_CALL_IS_AUDIO=41051]="CURRENT_CALL_IS_AUDIO",e[e.CURRENT_CALL_IS_VIDEO=41052]="CURRENT_CALL_IS_VIDEO"}(Ue||(Ue={}));class Pe{constructor(e){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_androidPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}})}setChannelIdMi(e){return _(e)?(this._androidPushConfig.channelIdMi=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdMi type is string, value: ${e}`),this)}setMiLargeIconUrl(e){return this._logger.warn(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,"`setMiLargeIconUrl` has been deprecated."),this}setChannelIdHW(e){return _(e)?(this._androidPushConfig.channelIdHW=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdHW type is string, value: ${e}`),this)}setCategoryHW(e){return _(e)?(this._androidPushConfig.categoryHW=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: categoryHW type is string, value: ${e}`),this)}setImportanceHW(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: importanceHW value is NORMAL|LOW, value: ${e}`),this):(this._androidPushConfig.importanceHW=e,this)}setImageUrlHW(e){return _(e)?(this._androidPushConfig.imageUrlHW=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: imageUrlHW type is string, value: ${e}`),this)}setChannelIdOPPO(e){return _(e)?(this._androidPushConfig.channelIdOPPO=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: channelIdOPPO type is string, value: ${e}`),this)}setTypeVivo(e){return _(e)?(this._androidPushConfig.typeVivo=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: typeVivo type is string, value: ${e}`),this)}setCategoryVivo(e){return _(e)?(this._androidPushConfig.categoryVivo=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: categoryVivo type is string, value: ${e}`),this)}setFcmChannelId(e){return _(e)?(this._androidPushConfig.fcmChannelId=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmChannelId type is string, value: ${e}`),this)}setFcmCollapseKey(e){return _(e)?(this._androidPushConfig.fcmCollapseKey=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmCollapseKey type is string, value: ${e}`),this)}setFcmImageUrl(e){return _(e)?(this._androidPushConfig.fcmImageUrl=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: fcmImageUrl type is string, value: ${e}`),this)}setimportanceHonor(e){return"LOW"!==e&&"NORMAL"!==e?(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: importanceHonor value is NORMAL|LOW, value: ${e}`),this):(this._androidPushConfig.importanceHonor=e,this)}setimageUrlHonor(e){return _(e)?(this._androidPushConfig.imageUrlHonor=e,this):(this._logger.error(v.L_CALLPLUS_SET_ANDROID_PUSH_CONFIG_O,`errorMsg: imageUrlHonor type is string, value: ${e}`),this)}build(){return this._androidPushConfig}}class De{constructor(e,t,i,_){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_initOpts",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_videoConfig",{enumerable:!0,configurable:!0,writable:!0,value:{resolution:h.W640_H480,frameRate:R.FPS_15}}),Object.defineProperty(this,"_audioConfig",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_callPlusStatistics",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientCallId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_isLaunchHangup",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_needHangupCallId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rtcModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportAppEventModule",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._context.registerMessageType("RC:CallPlusMiss",!0,!1,[]),this._reportAppEventModule=new Me(t),this._callPlusStatistics=new oe(this._logger,this._context),this._callEngine=new pe(this._context,this._runtime,this._initOpts,this._logger,this._reportAppEventModule),this._rtcModule=new ve(this._context,this._runtime,this._initOpts,this._logger,this._callEngine,this._reportAppEventModule),this._callEngine.setRTCModule(this._rtcModule),this._rtcModule.on(ve.__INNER_RTC_PROCESS_FAILED__,this._rtcProcessFailHandle.bind(this)),this._rtcModule.on(ve.__INNER_RTC_PEERCONNECTION_ABNORMAL_CLOSE__,this._peerConnectionAbnormalClose.bind(this)),this._rtcModule.on(ve.__INNER_ON_SELF_JOINED__,this._selfJoinedHandle.bind(this)),this._rtcModule.on(ve.__INNER_ON_OTHER_JOINED__,this._otherJoinedHandle.bind(this)),this._rtcModule.on(ve.__INNER_RECEIVE_FIRST_FRAME__,this._receiveFirstFrameHandle.bind(this)),this._rtcModule.on(ve.__INNER_ON_KICKOFF__,this._kickoffHandle.bind(this)),this._callEngine.on(pe.__INNER_SESSION_CONNECT__,this._rtcModule.sessionConnected.bind(this._rtcModule)),this._callEngine.on(pe.__INNER_SESSION_CLOSE__,this._sessionCloseHandle.bind(this)),this._callEngine.on(pe.__INNER_CHANGE_MEDIA_TYPE__,this._rtcModule.changeMediaType.bind(this._rtcModule)),this._callEngine.on(pe.__INNER_INVITE__,(e,t)=>{this._callPlusStatistics.reportStatisticsData(ee.L_QS_RECEIVE_CALL_S,U.SUCCESS,+new Date,e,"",t)})}_rtcProcessFailHandle(e,t){const i=this._callEngine.getLocalMainSession();if(i){const _=i.getCallId();this._callEngine.systemStatusUp({callId:_,sysStatus:e,forward:Ae.CURRENT},t),this._callPlusStatistics.reportStatisticsData(ee.L_QS_ABNORMAL_HANGUP_S,U.SUCCESS,+new Date,i),this.__innerHangup({callId:_,systemState:e},t)}}_peerConnectionAbnormalClose(e){const t=this._callEngine.getLocalMainSession();t&&(this._callEngine.systemStatusUp({callId:t.getCallId(),sysStatus:G.CONNECTION_ERR,forward:Ae.CURRENT},e),this._callEngine.endCurrentSession(G.CONNECTION_ERR,t.getCallId(),e))}_selfJoinedHandle(e,t,i){return f(this,void 0,void 0,function*(){const _=this._context.getCurrentId(),r=this._callEngine.getLocalMainSession();((null==r?void 0:r.getCallType())===M.MULTI||t.length)&&this._callEngine.updateMainSessionState(y.ONCALL);const s=[_,...t].map(e=>({userId:e,userState:P.ONCALL,systemState:G.ONCALL})),o=this._callEngine.updateUsersState(e,s,i);this._reportAppEventModule.onCallConnected(r),o.length>0&&this._callEngine.reportRemoteUserStateChange(e,o,i),this._callEngine.startTimeCorrection(i)})}_otherJoinedHandle(e,t){var i;let _="";const r=e.map(e=>(_=e.callId,{userId:e.userId,userState:P.ONCALL,systemState:G.ONCALL})),s=this._callEngine.updateUsersState(_,r,t);s.length>0&&this._callEngine.reportRemoteUserStateChange(_,s,t),(null===(i=this._callEngine.getLocalMainSession())||void 0===i?void 0:i.getState())!==y.ONCALL&&this._callEngine.updateMainSessionState(y.ONCALL)}_receiveFirstFrameHandle(e){var t;(null===(t=this._callEngine.getLocalMainSession())||void 0===t?void 0:t.getState())!==y.ONCALL&&this._callEngine.updateMainSessionState(y.ONCALL),this._callEngine.upFirstFrameTime(e)}_kickoffHandle(e,t,i){if(e===G.CONNECTION_ERR)return void this._callEngine.endCurrentSession(e,t,i);const _=this._callEngine.getLocalMainSession();if(_){const r=_.getCallId();this._callPlusStatistics.reportStatisticsData(ee.L_QS_ABNORMAL_HANGUP_S,U.SUCCESS,+new Date,_,this._clientCallId),this._callEngine.systemStatusUp({callId:r,sysStatus:e,forward:Ae.CURRENT},i),this._callEngine.endCurrentSession(e,t,i)}}_sessionCloseHandle(e,t){this._isLaunchHangup||(this._clientCallId=""),this._isLaunchHangup=!1,this._rtcModule.sessionClose(e,t)}setCallPlusEventListener(e){this._logger.info(v.L_CALLPLUS_CLIENT_SET_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._reportAppEventModule.registerEventListener(e)}setStatusReportListener(e){this._logger.info(v.L_CALLPLUS_CLIENT_SET_STATUS_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._rtcModule.setCallPlusStatusReportListener(e)}setVideoView(e){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_T,JSON.stringify({list:e.map(e=>{const{userId:t,videoElement:i,isTiny:_}=e;return{userId:t,elementName:null==i?void 0:i.nodeName,isTiny:_}})}),t),!T(e))return this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, list: not empty array, value: ${JSON.stringify(e)}`,t),{code:U.PARAM_ERROR};for(const i of e){const{userId:e,videoElement:_}=i;if(!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, userId: not empty string, value: ${e}`,t),{code:U.PARAM_ERROR};if(!B(_))return this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,`params err, videoElement: need a video element, value: ${_ instanceof HTMLElement?_.nodeName:_}`,t),{code:U.PARAM_ERROR}}return this._logger.info(v.L_CALLPLUS_CLIENT_SET_VIDEO_VIEW_R,"succes",t),this._rtcModule.setVideoView(e,t),{code:U.SUCCESS}}removeVideoView(e){const t=this._logger.createTraceId();return this._logger.info(v.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_T,JSON.stringify({userIds:e}),t),T(e)&&e.every(e=>I(e))?(this._logger.info(v.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,"succes",t),this._rtcModule.removeVideoView(e,t),{code:U.SUCCESS}):(this._logger.error(v.L_CALLPLUS_CLIENT_REMOVE_VIDEO_VIEW_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(e)}`,t),{code:U.PARAM_ERROR})}playMedia(e,i){return f(this,void 0,void 0,function*(){const _=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_PLAY_MEDIA_T,JSON.stringify({userId:e,mediaType:i}),_),!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`params err, userId: not empty string, value: ${e}`,_),{code:U.PARAM_ERROR};if(t(D[i]))return this._logger.error(v.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`params err, mediaType is illegal, value: ${i}`,_),{code:U.PARAM_ERROR};if(i===D.AUDIO&&e===this._context.getCurrentId())return this._logger.info(v.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,"success",_),{code:U.SUCCESS};const{videoView:r}=this._rtcModule.getUserViewMap()[e]||{};return i===D.AUDIO||r?this._rtcModule.playMedia(e,i,r,_):(this._logger.error(v.L_CALLPLUS_CLIENT_PLAY_MEDIA_R,`errCode: ${U.VIDEO_VIEW_NOT_SET}, video view not set`,_),{code:U.VIDEO_VIEW_NOT_SET})})}createVideoConfigBuilder(){return new k(this._logger)}setVideoConfig(e){this._logger.info(v.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_T,JSON.stringify(e));const{frameRate:t,resolution:i,maxBitrate:_,minBitrate:r}=e;if(!R[t])return this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,`param error, frameRate is illegal, value: ${t}`),{code:U.PARAM_ERROR};if(!h[i])return this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,`param error, resolution is illegal, value: ${i}`),{code:U.PARAM_ERROR};const{code:s,errorMsg:o}=F(r,_);return s!==U.SUCCESS&&this._logger.error(v.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,o),this._logger.info(v.L_CALLPLUS_CLIENT_SET_VIDEO_CONFIG_R,"success"),this._videoConfig=Object.assign({},e),this._rtcModule.setVideoConfig(this._videoConfig),{code:U.SUCCESS}}createAudioConfigBuilder(){return new w(this._logger)}createAndroidPushConfigBuilder(){return new Pe(this._logger)}setAudioConfig(t){this._logger.info(v.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_T,JSON.stringify(t));const{sampleRate:i,minBitrate:_,maxBitrate:r}=t;if(i&&!e(i))return this._logger.error(v.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,`param error, sampleRate: type is number, value: ${i}`),{code:U.PARAM_ERROR};const{code:s,errorMsg:o}=F(_,r);return s!==U.SUCCESS&&this._logger.error(v.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,o),this._logger.info(v.L_CALLPLUS_CLIENT_SET_AUDIO_CONFIG_R,"success"),this._audioConfig=Object.assign({},t),this._rtcModule.setAudioConfig(this._audioConfig),{code:U.SUCCESS}}setAudioOutputDeviceId(e){return this._logger.info(v.L_CALLPLUS_CLIENT_SET_AUDIO_OUTPUT_DEVICE_ID_O,e),this._rtcModule.setAudioOutputDeviceId(e)}startCall(e,i=M.SINGLE,r=D.AUDIO_VIDEO,s,o,n){return f(this,void 0,void 0,function*(){this._clientCallId=c();const a=+new Date,L=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_START_CALL_T,`userIds: ${e.join(",")}, callType: ${i}, mediaType: ${r}, pushConfig: ${s}, extra: ${o}`,L),this._context.getConnectionStatus()!==l.CONNECTED)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${U.SIGNAL_DISCONNECTED}`,L),{code:U.SIGNAL_DISCONNECTED};const E=this._context.getNaviInfo();if(!E||!x(E))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${U.RTC_SERVICE_UNAVAILABLE}`,L),{code:U.RTC_SERVICE_UNAVAILABLE};if(!T(e)||!e.every(e=>I(e)))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(e)}`,L),{code:U.PARAM_ERROR};if(t(M[i]))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, callType is illegal, value: ${i}`,L),{code:U.PARAM_ERROR};if(t(D[r]))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, mediaType is illegal, value: ${r}`,L),{code:U.PARAM_ERROR};if(s){const e=W(s);if(e.code!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,L),{code:U.PARAM_ERROR}}if(o){if(!_(o))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, extra is illegal, type: string, value: ${o}`,L),{code:U.PARAM_ERROR};if(q(o)>Ce)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,"params err, extra max size is 128KB",L),{code:U.PARAM_ERROR}}if(e.length>1&&i===M.SINGLE)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, You can only call one person in a single call, userIds: ${e.join(",")}`,L),{code:U.PARAM_ERROR};if(n&&!_(n))return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`params err, targetId is illegal, type: string, value: ${n}`,L),{code:U.PARAM_ERROR};if(this._callEngine.getLocalMainSession())return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`errCode: ${U.SESSION_EXIST}, session exist`,L),{code:U.SESSION_EXIST};const{code:d}=yield this._rtcModule.createCallMediaTracks(r,L);if(d!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`create meida tracks error code: ${d}`,L),{code:d};const{code:C,data:S}=yield this._callEngine.startCall({toUsers:e.map(e=>({userId:e})),callType:i,mediaType:r,callId:this._clientCallId,pushConfig:s,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:o}),targetId:n},L);if(this._callPlusStatistics.reportStatisticsData(ee.L_QS_START_CALL_S,C,a,null,this._clientCallId,null,{mediaType:r,callType:i,callId:(null==S?void 0:S.callId)||""}),C!==U.SUCCESS)return this._rtcModule.destroyAllTracks(L),this._logger.error(v.L_CALLPLUS_CLIENT_START_CALL_R,`signal error code: ${C}`,L),{code:C};const{callId:u,clientCallId:g}=S;return this._needHangupCallId===g?(this._callEngine.clearAllTimer(u,L),this._callEngine.hangup({callId:u,systemState:G.CANCELLED},L),this._logger.info(v.L_CALLPLUS_CLIENT_START_CALL_R,`the ${u} call has been hangup`,L),{code:U.SUCCESS}):(i===M.MULTI&&this._rtcModule.sessionConnected(u,L),this._logger.info(v.L_CALLPLUS_CLIENT_START_CALL_R,JSON.stringify({data:S,code:C}),L),{code:U.SUCCESS,callId:u})})}joinMultiCall(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_T,`callId: ${e}`,t),this._context.getConnectionStatus()!==l.CONNECTED)return this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${U.SIGNAL_DISCONNECTED}`,t),{code:U.SIGNAL_DISCONNECTED};const i=this._context.getNaviInfo();if(!i||!x(i))return this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${U.RTC_SERVICE_UNAVAILABLE}`,t),{code:U.RTC_SERVICE_UNAVAILABLE};if(!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`params err, callId: not empty string, value: ${e}`,t),{code:U.PARAM_ERROR};const{code:_,data:r}=yield this._callEngine.getCallSession({callId:e},t);if(_!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`get call data error, code: ${_}`,t),{code:_};const{mediaType:s}=r,o=this._callEngine.getLocalMainSession();if(o&&o.getCallId()!==e)return{code:U.SESSION_EXIST};const{code:n}=yield this._rtcModule.createCallMediaTracks(s,t);if(n!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`create meida tracks error code: ${n}`,t),{code:n};const{code:a}=yield this._callEngine.joinCall({callId:e,mediaType:s},t);return a!==U.SUCCESS?(this._rtcModule.destroyAllTracks(t),this._logger.error(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`signal error code: ${a}`,t),{code:a}):(this._logger.info(v.L_CALLPLUS_CLIENT_JOIN_MULTI_CALL_R,`code: ${U.SUCCESS}`,t),yield this._rtcModule.sessionConnected(e,t),{code:U.SUCCESS})})}invite(e,t,i){var r;return f(this,void 0,void 0,function*(){const s=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_INVITE_T,`callId: ${e.join(",")}, pushConfig: ${t}, extra: ${i}`,s),!T(e)||!e.every(e=>I(e)))return this._logger.error(v.L_CALLPLUS_CLIENT_INVITE_R,`params err, userIds: not empty array, userId: not empty string, value: ${JSON.stringify(e)}`,s),{code:U.PARAM_ERROR};if(t){const e=W(t);if(e.code!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_INVITE_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,s),{code:U.PARAM_ERROR}}if(i){if(!_(i))return this._logger.error(v.L_CALLPLUS_CLIENT_INVITE_R,`params err, extra is illegal, value: ${i}`,s),{code:U.PARAM_ERROR};if(q(i)>Ce)return this._logger.error(v.L_CALLPLUS_CLIENT_INVITE_R,"params err, extra max size is 128KB",s),{code:U.PARAM_ERROR}}const{code:o,data:n}=yield this._callEngine.invite({toUsers:e.map(e=>({userId:e})),pushConfig:t,extra:JSON.stringify({userId:this._context.getCurrentId(),extra:i})},s);if(o!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_INVITE_R,`signal error code: ${o}`,s),{code:o};const l=[];return(null===(r=n.busylineUsers)||void 0===r?void 0:r.length)&&l.push(...n.busylineUsers.map(e=>({userId:e.userId,state:e.sessionStatus}))),this._logger.info(v.L_CALLPLUS_CLIENT_INVITE_R,`success busyUsers: ${JSON.stringify(l)}`,s),{code:U.SUCCESS,busyUsers:l}})}accept(e,t){return f(this,void 0,void 0,function*(){const i=+new Date,_=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_ACCEPT_T,`callId: ${e}, pushConfig: ${t}`,_),this._context.getConnectionStatus()!==l.CONNECTED)return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode: ${U.SIGNAL_DISCONNECTED}`,_),{code:U.SIGNAL_DISCONNECTED};const r=this._context.getNaviInfo();if(!r||!x(r))return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode: ${U.RTC_SERVICE_UNAVAILABLE}`,_),{code:U.RTC_SERVICE_UNAVAILABLE};if(!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`params err, callId: not empty string, value: ${e}`,_),{code:U.PARAM_ERROR};if(t){const e=W(t);if(e.code!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,_),{code:U.PARAM_ERROR}}let s=this._callEngine.getLocalMainSession();const o=this._callEngine.getHoldSession(e);if(!s&&!o)return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`errCode : ${U.NOT_IN_CALL}, session not exist`,_),{code:U.NOT_IN_CALL};if(e===(null==o?void 0:o.getCallId())){const{code:t}=yield this.hangup(s.getCallId());if(t!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`hangup mainSession error code: ${t}`,_),{code:t};this._callEngine.upgradeMainSession(e),s=this._callEngine.getLocalMainSession()}const n=s.getMediaType(),{code:a}=yield this._rtcModule.createCallMediaTracks(n,_);if(a!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`create meida tracks error code: ${a}`,_),{code:a};const{code:c}=yield this._callEngine.accept({callId:e},_);return this._callPlusStatistics.reportStatisticsData(ee.L_QS_ACCEPT_CALL_S,c,i,s),c!==U.SUCCESS?(this._rtcModule.destroyAllTracks(_),this._logger.error(v.L_CALLPLUS_CLIENT_ACCEPT_R,`signal error code: ${c}`,_),{code:c}):(this._logger.info(v.L_CALLPLUS_CLIENT_ACCEPT_R,"success",_),this._rtcModule.sessionConnected(e,_),{code:U.SUCCESS})})}__innerHangup(e,t){var i;return f(this,void 0,void 0,function*(){const{callId:_}=e;this._callEngine.setIsLocalClientHangup(!0),this._callEngine.clearAllTimer(_,t);const{code:r}=yield this._callEngine.hangup(e,t);return r===Ue.CALL_NOT_EXIST?{code:U.SUCCESS}:(r===U.SUCCESS&&_===(null===(i=this._callEngine.getLocalMainSession())||void 0===i?void 0:i.getCallId())&&(yield this._rtcModule.sessionClose(_,t)),{code:r})})}hangup(e,t){return f(this,void 0,void 0,function*(){const i=+new Date,r=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_HANGUP_T,`callId: ${e}, pushConfig: ${t}`,r);const s=this._callEngine.getLocalMainSession();if(!s)return{code:U.NOT_IN_CALL};if(e&&!_(e))return this._logger.error(v.L_CALLPLUS_CLIENT_HANGUP_R,`params err, callId: type is string, value: ${e}`,r),{code:U.PARAM_ERROR};if(t){const e=W(t);if(e.code!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_HANGUP_R,`params err, pushConfig is illegal, msg: ${e.errorMsg}`,r),{code:U.PARAM_ERROR}}const o=s.getCallId();if(e&&e!==o&&!this._callEngine.getHoldSession(e))return this._logger.error(v.L_CALLPLUS_CLIENT_HANGUP_R,`params err, callId is invalid, value: ${e}`,r),{code:U.CALL_ID_INVALID};this._isLaunchHangup=!0,this._needHangupCallId=e||o;const n=this._callEngine.getHoldSession(this._needHangupCallId)||s,l=this._context.getCurrentId(),a=((e,t)=>{let i;switch(e){case P.CALLING:i=G.CANCELLED;break;case P.RINGING:case P.INVITED:i=G.DECLINED;break;case P.CONNECTING:i=t?G.DECLINED:G.CANCELLED;break;case P.ONCALL:i=G.ENDED}return i})(s.getUserList().filter(e=>e.userId===l)[0].state,[s.getCreatorUserId(),s.getInviterUserId()].includes(l))||G.ENDED,{code:c}=yield this.__innerHangup({callId:this._needHangupCallId,systemState:a,pushConfig:t},r);return this._callPlusStatistics.reportStatisticsData(ee.L_QS_HANGUP_CALL_S,c,i,n,this._clientCallId),c!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_HANGUP_R,`signal error code : ${c}`,r),{code:c}):(this._needHangupCallId=null,this._logger.info(v.L_CALLPLUS_CLIENT_HANGUP_R,"success",r),{code:U.SUCCESS})})}requestChangeMediaType(e){return f(this,void 0,void 0,function*(){const i=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_T,`mediaType: ${e}`,i),t(D[e]))return this._logger.error(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`params err, mediaType is illegal, value: ${e}`,i),{code:U.PARAM_ERROR};const _=this.getCurrentCallSession(),r=null==_?void 0:_.getMediaType();if(e===r)return this._logger.error(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`error code: ${U.MEDIATYPE_INVALID}`,i),{code:U.MEDIATYPE_INVALID};if(!this._callEngine.getLocalMainSession())return this._logger.error(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`error code : ${U.NOT_IN_CALL}, session not exist`,i),{code:U.NOT_IN_CALL};const s=null==_?void 0:_.getUserList().filter(e=>e.userId!==this._context.getCurrentId()).map(e=>e.userId),{code:o,data:n}=yield this._callEngine.requestChangeMediaType({mediaType:e,toUserIds:s||[]},i);return o!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`signal error code: ${o}`,i),{code:o}):(this._logger.info(v.L_CALLPLUS_CLIENT_REQUEST_CHANGE_MEDIA_TYPE_R,`success transactionId: ${n.transactionId}`,i),{code:U.SUCCESS,transactionId:n.transactionId})})}cancelChangeMediaType(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_T,`transactionId: ${e}`,t),!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`param error, transactionId: not empty string, value: ${e}`,t),{code:U.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(v.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`error code : ${U.NOT_IN_CALL}, session not exist`,t),{code:U.NOT_IN_CALL};const{code:i}=yield this._callEngine.cancelChangeMediaType({transactionId:e},t);return i!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,`signal error code: ${i}`,t),{code:i}):(this._logger.info(v.L_CALLPLUS_CLIENT_CANCEL_CHANGE_MEDIA_TYPE_R,"success",t),{code:U.SUCCESS})})}replyChangeMediaType(e,t){return f(this,void 0,void 0,function*(){const _=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_T,`transactionId: ${e}`,_),!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`param error, transactionId: not empty string, value: ${e}`,_),{code:U.PARAM_ERROR};if(!i(t))return this._logger.error(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`param error, isAgree: type is boolean, value: ${t}`,_),{code:U.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`error code : ${U.NOT_IN_CALL}, session not exist`,_),{code:U.NOT_IN_CALL};const{code:r}=yield this._callEngine.responseChangeMediaType({transactionId:e,agree:t},_);return r!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,`signal error: ${r}`,_),{code:r}):(this._logger.info(v.L_CALLPLUS_CLIENT_REPLY_CHANGE_MEDIA_TYPE_R,"success",_),{code:U.SUCCESS})})}getCurrentCallSession(){return this._callEngine.getLocalMainSession()}getAvailableCallRecordsFromServer(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_T,"",e);const{code:t,data:i}=yield this._callEngine.getOpenCallList(e);return t!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(v.L_CALLPLUS_CLIENT_GET_AVAILABLE_CALL_RECORDS_FROM_SERVER_R,`success, data: ${JSON.stringify(i)}`,e),{code:U.SUCCESS,records:i})})}getCallRecords(t,i,_=0){return f(this,void 0,void 0,function*(){const r=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_T,`startTimestamp: ${t}, count: ${i}`,r),!(e(t)&&t>=0))return this._logger.error(v.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`params error, startTimestamp: is a number >= 0, value: ${t}`,r),{code:U.PARAM_ERROR};if(!(e(i)&&i>0))return this._logger.error(v.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`params error, count: is a number >= 0, value: ${i}`,r),{code:U.PARAM_ERROR};const{code:s,data:o}=yield this._callEngine.getCallLogList({timestamp:t,count:i,order:_},r);return s!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,`signal error code: ${s}`,r),{code:s}):(this._logger.info(v.L_CALLPLUS_CLIENT_GET_CALL_RECORDS_R,"success",r),{code:U.SUCCESS,result:o})})}deleteCallRecordsFromServer(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_T,`callIds: ${e.join(",")}`,t),!T(e)||!e.every(e=>I(e)))return this._logger.error(v.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,`params err, callIds: not empty array, callId: not empty string, callIds: ${JSON.stringify(e)}`,t),{code:U.PARAM_ERROR};const{code:i}=yield this._callEngine.deleteCallLog(e,t);return i!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,`signal error code: ${i}`,t),{code:i}):(this._logger.info(v.L_CALLPLUS_CLIENT_DELETE_CALL_RECORDS_BY_CALLID_R,"success",t),{code:U.SUCCESS})})}deleteAllCallRecordsFromServer(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_T,"",e);const{code:t}=yield this._callEngine.removeAllCallLog(e);return t!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(v.L_CALLPLUS_CLIENT_DELETE_ALL_CALL_RECORDS_FROM_SERVER_R,"success",e),{code:U.SUCCESS})})}startCamera(){var e;return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_START_CAMERA_T,"",t);const{code:i,track:_}=yield this._rtcModule.getCameraVideoTrack(t);if(i!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_START_CAMERA_R,`create video track error code: ${i}`,t),{code:i};if(!(null==_?void 0:_.isPublished())&&(null===(e=this._callEngine.getLocalMainSession())||void 0===e?void 0:e.getState())===y.ONCALL){const{code:e}=yield this._rtcModule.publishVideoTrack();return e!==A.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_START_CAMERA_R,`publish error code: ${e}`,t),{code:e}):(this._logger.info(v.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),{code:U.SUCCESS})}const{code:r}=yield this._rtcModule.enableVideoTrack(t);return r!==A.SUCCESS&&r!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_START_CAMERA_R,`signal error code: ${r}`,t),{code:r}):(this._logger.info(v.L_CALLPLUS_CLIENT_START_CAMERA_R,"success",t),{code:U.SUCCESS})})}stopCamera(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_STOP_CAMERA_T,"",e);const{code:t,track:i}=yield this._rtcModule.disableVideoTrack();return t!==U.SUCCESS&&t!==A.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_STOP_CAMERA_R,`error code: ${t}`,e),{code:t}):(this._rtcModule.destroyTrack(i),this._logger.info(v.L_CALLPLUS_CLIENT_STOP_CAMERA_R,"success",e),{code:U.SUCCESS})})}switchCamera(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_T,`cameraId: ${e}`,t),!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`param error, cameraId: not empty string, value: ${e}`,t),{code:U.PARAM_ERROR};const i=this._callEngine.getLocalMainSession();if(!i)return this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`errCode: ${U.NOT_IN_CALL}`,t),{code:U.NOT_IN_CALL};if(i.getMediaType()===D.AUDIO)return this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`errCode: ${U.NOT_VIDEO_CALL}`,t),{code:U.NOT_VIDEO_CALL};this._videoConfig.cameraId=e,this._rtcModule.setVideoConfig(this._videoConfig);const{code:_}=yield this._rtcModule.changeVideoDevice(t);return _!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,`call client changeVideoDevice error code: ${_}`,t),{code:_}):(this._logger.info(v.L_CALLPLUS_CLIENT_SWITCH_CAMERA_R,"success",t),{code:U.SUCCESS})})}startMicrophone(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_START_MICROPHONE_T,"",e);const{code:t,track:i}=yield this._rtcModule.getMicrophoneAudioTrack(e);if(t!==U.SUCCESS)return this._logger.error(v.L_CALLPLUS_CLIENT_START_MICROPHONE_R,`create microphone audio track error code: ${t}`,e),{code:t};if(!i.isOwnerMuted())return this._logger.info(v.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),{code:U.SUCCESS};const _=yield i.unmute();return _!==A.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_START_MICROPHONE_R,`signal error code: ${t}`,e),{code:_}):(this._logger.info(v.L_CALLPLUS_CLIENT_START_MICROPHONE_R,"success",e),{code:U.SUCCESS})})}stopMicrophone(){return f(this,void 0,void 0,function*(){const e=this._logger.createTraceId();this._logger.info(v.L_CALLPLUS_CLIENT_STOP_MICROPHONE_T,"",e);const{code:t}=yield this._rtcModule.disableAudioTrack();return t!==U.SUCCESS&&t!==A.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,`signal error code: ${t}`,e),{code:t}):(this._logger.info(v.L_CALLPLUS_CLIENT_STOP_MICROPHONE_R,"success",e),{code:U.SUCCESS})})}isMicrophoneEnabled(){const e=this._rtcModule.getLocalAudioTrack();return!!e&&!e.isOwnerMuted()}setAllRemoteAudioEnable(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();return this._rtcModule.setAllRemoteAudioEnable(e,t)})}getVersion(){return"2.32.0"}getCameras(){return f(this,void 0,void 0,function*(){return p.getCameras()})}getMicrophones(){return f(this,void 0,void 0,function*(){return p.getMicrophones()})}getSpeakers(){return f(this,void 0,void 0,function*(){return p.getSpeakers()})}getRTCSessionId(){return this._rtcModule.getRTCSessionId()}switchMicrophone(e){return f(this,void 0,void 0,function*(){const t=this._logger.createTraceId();if(this._logger.info(v.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_T,`microphoneId: ${e}`,t),!I(e))return this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`param error, microphoneId: not empty string, value: ${e}`,t),{code:U.PARAM_ERROR};if(!this._callEngine.getLocalMainSession())return this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`errCode: ${U.NOT_IN_CALL}`,t),{code:U.NOT_IN_CALL};this._audioConfig.microphoneId=e,this._rtcModule.setAudioConfig(this._audioConfig);const{code:i}=yield this._rtcModule.changeAudioDevice(t);return i!==U.SUCCESS?(this._logger.error(v.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,`call client changeAudioDevice error code: ${i}`,t),{code:i}):(this._logger.info(v.L_CALLPLUS_CLIENT_SWITCH_MICROPHONE_R,"success",t),{code:U.SUCCESS})})}}u.add("callplus","2.32.0");const ye={tag:"RCCallPlus",verify:e=>!!u.validEngine("5.32.0")||(console.error(`The current engine version '${u.getInfo().engine}' error, plugin-call-plus required engine version at least '5.32.0'.`),!1),setup(e,i,_){const r=(s=_)?S(s)?Object.keys(s).includes("rtcClient")?S(s.rtcClient)?{isLegal:!0}:{isLegal:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:{isLegal:!1,code:U.NOT_INSTALL_RTC_PLUGIN}:{isLegal:!1,msg:"Initialization options must be an object"}:{isLegal:!1,msg:"Initialization missing parameter -> options"};var s;if(!r.isLegal)throw new Error(`[CallPlusLib installer steup]${r.msg}`);t(_.isAllowNewCallWhenRinging)&&(_.isAllowNewCallWhenRinging=!0);const o=e.createLogger("CallPlus","RTC"),n=t(_.logOutputLevel)?g.WARN:_.logOutputLevel;return o.setOutputLevel(n),o.warn(v.L_INDEX_INSTALL_CALL_PLUS_PLUGIN_O,`CallPlus Version: 2.32.0, Commit: 5162038f2bfda260f4b4491bbb9f841d3cead761, isAllowNewCallWhenRinging: ${_.isAllowNewCallWhenRinging}`),new De(e,o,i,_)}};export{V as IGroupCallStatusMessageType,w as RCAudioConfigBuilder,Pe as RCCallPlusAndroidPushConfigBuilder,y as RCCallPlusCallState,De as RCCallPlusClient,U as RCCallPlusCode,D as RCCallPlusMediaType,b as RCCallPlusMediaTypeChangeResult,G as RCCallPlusReason,H as RCCallPlusSession,P as RCCallPlusSessionUserState,M as RCCallPlusType,k as RCVideoConfigBuilder,ye as installer};
|