@rongcloud/plugin-rtc 5.26.0 → 5.28.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/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{isNumber as e,EventEmitter as t,validate as r,isObject as n,ErrorCode as i,HttpMethod as o,RCConnectionStatus as a,notEmptyString as s,isString as c,isArray as u,RTCMode as l,assert as _,ConversationType as d,isHttpUrl as f,isBoolean as p,isUndefined as h,forEach as b,VersionManage as g,AssertRules as m}from"@rongcloud/engine";var v=function(e,t){return v=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])},v(e,t)};function R(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}v(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var O,E,I,S=function(){return S=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},S.apply(this,arguments)};function T(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function y(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function C(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function L(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function P(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,function(e){e[e.SUCCESS=1e4]="SUCCESS",e[e.PB_ERROR=40001]="PB_ERROR",e[e.SIGNAL_DISCONNECTED=5e4]="SIGNAL_DISCONNECTED",e[e.PARAMS_ERROR=50001]="PARAMS_ERROR",e[e.REPERT_JOIN_ROOM=50002]="REPERT_JOIN_ROOM",e[e.NOT_IN_ROOM=50003]="NOT_IN_ROOM",e[e.SERVICE_INVALID=50004]="SERVICE_INVALID",e[e.RTC_TOKEN_INVALID=50006]="RTC_TOKEN_INVALID",e[e.SIGNAL_ERROR=53001]="SIGNAL_ERROR",e[e.CREATE_OFFER_FAILED=53003]="CREATE_OFFER_FAILED",e[e.REQUEST_FAILED=53004]="REQUEST_FAILED",e[e.MCU_SERVER_NOT_FOUND=53005]="MCU_SERVER_NOT_FOUND",e[e.BROADCAST_SUB_LIST_NOT_EMPTY=53007]="BROADCAST_SUB_LIST_NOT_EMPTY",e[e.ROOM_HAS_BEEN_DESTROYED=53008]="ROOM_HAS_BEEN_DESTROYED",e[e.NOT_OPEN_VIDEO_AUDIO_SERVER=53009]="NOT_OPEN_VIDEO_AUDIO_SERVER",e[e.GET_USER_MEDIA_FAILED=53010]="GET_USER_MEDIA_FAILED",e[e.GET_DISPLAY_MEDIA_FAILED=53011]="GET_DISPLAY_MEDIA_FAILED",e[e.BROWSER_PERMISSION_DENIED=53012]="BROWSER_PERMISSION_DENIED",e[e.CREATE_CUSTOM_TRACK_FAILED=53013]="CREATE_CUSTOM_TRACK_FAILED",e[e.INVALID_TAGS=53014]="INVALID_TAGS",e[e.INVALID_USER_ID=53015]="INVALID_USER_ID",e[e.CREATE_FILE_TRACK_FAILED=53016]="CREATE_FILE_TRACK_FAILED",e[e.INVALID_FILE_INSTANCE=53017]="INVALID_FILE_INSTANCE",e[e.SET_REMOTE_DESCRIPTION_FAILED=53018]="SET_REMOTE_DESCRIPTION_FAILED",e[e.BROWSER_NOT_SUPPORT=53019]="BROWSER_NOT_SUPPORT",e[e.TRACK_NOT_READY=53020]="TRACK_NOT_READY",e[e.VIDEO_TRACK_MISS_MEDIA_ELEMENT=53021]="VIDEO_TRACK_MISS_MEDIA_ELEMENT",e[e.TRACK_PLAY_ERROR=53022]="TRACK_PLAY_ERROR",e[e.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED=53023]="SIGNAL_AUDIENCE_JOIN_ROOM_FAILED",e[e.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED=53024]="SIGNAL_ROOM_CHANGE_IDENTITY_FAILED",e[e.PACKAGE_ENVIRONMENT_ERROR=53025]="PACKAGE_ENVIRONMENT_ERROR",e[e.PUBLISH_TRACK_LIMIT_EXCEEDED=53026]="PUBLISH_TRACK_LIMIT_EXCEEDED",e[e.CDN_RESOURCE_IS_EMPTY=53027]="CDN_RESOURCE_IS_EMPTY",e[e.SIGNAL_JOIN_RTC_ROOM_REFUSED=53028]="SIGNAL_JOIN_RTC_ROOM_REFUSED",e[e.NO_PERMISSION_TO_USE_REQUESTED_DEVICE=53029]="NO_PERMISSION_TO_USE_REQUESTED_DEVICE",e[e.THE_FUNCTION_IS_DISABLED_IN_PKROOM=53030]="THE_FUNCTION_IS_DISABLED_IN_PKROOM",e[e.SOME_TRACKS_PUBLISH_FAILED=53031]="SOME_TRACKS_PUBLISH_FAILED",e[e.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO=53032]="MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO",e[e.JWT_TIME_OUT=1004]="JWT_TIME_OUT",e[e.SYSTEM_PERMISSION_DENIED=53033]="SYSTEM_PERMISSION_DENIED",e[e.PUBLISH_TRACKS_IS_INVALID=53034]="PUBLISH_TRACKS_IS_INVALID",e[e.TRACK_READYSTATE_IS_ENDED=53035]="TRACK_READYSTATE_IS_ENDED",e[e.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH=53036]="APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH",e[e.LOAD_3A_MODULE_FAILED=53037]="LOAD_3A_MODULE_FAILED"}(O||(O={})),function(e){e.L_INDEX_INSTALL_RTC_PLUGIN_O="L-index_install_rtc_plugin-O",e.L_RTC_CLIENT_IM_CONNECTION_STATE_S="L-rtc_client_im_connection_state-S",e.L_RTC_CLIENT_MESSAGE_O="L-rtc_client_message-O",e.L_RTC_CLIENT_DESTROY_S="L-rtc_client_destroy-S",e.L_RTC_CLIENT_JOIN_RTC_ROOM_T="L-rtc_client_join_rtc_room-T",e.L_RTC_CLIENT_JOIN_RTC_ROOM_O="L-rtc_client_join_rtc_room-O",e.L_RTC_CLIENT_JOIN_RTC_ROOM_R="L-rtc_client_join_rtc_room-R",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_T="L-rtc_client_join_living_room-T",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_R="L-rtc_client_join_living_room-R",e.L_RTC_CLIENT_GET_AUDIENCE_CLIENT_O="L-rtc_client_get_audience_client-O",e.L_RTC_CLIENT_LEAVE_ROOM_T="L-rtc_client_leave_room-T",e.L_RTC_CLIENT_LEAVE_ROOM_R="L-rtc_client_leave_room-R",e.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O="L-rtc_client_create_microphone_audio_track-O",e.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O="L-rtc_client_create_camera_video_track-O",e.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O="L-rtc_client_create_microphone_and_camera_tracks-O",e.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O="L-rtc_client_create_screen_video_track-O",e.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_AND_AUDIO_TRACKS_O="L-rtc_client_create_screen_video_and_audio_tracks-O",e.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O="L-rtc_client_create_local_audio_track-O",e.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O="L-rtc_client_create_local_video_track-O",e.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O="L-rtc_client_create_local_file_tracks-O",e.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O="L-rtc_client_create_local_tracks-O",e.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O="L-rtc_client_apply_video_aspect_ratio-O",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_T="L-rtc_client_join_living_room_as_audience-T",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R="L-rtc_client_join_living_room_as_audience_R",e.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_T="L-rtc_client_leave_living_room_as_audience-T",e.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R="L-rtc_client_leave_living_room_as_audience-R",e.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_T="L-rtc_client_upgrade_to_anchor_room-T",e.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R="L-rtc_client_upgrade_to_anchor_room-R",e.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_T="L-rtc_client_downgrade_to_audience_room-T",e.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R="L-rtc_client_downgrade_to_audience_room-R",e.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_T="L-rtc_client_get_joined_room_info-T",e.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R="L-rtc_client_get_joined_room_info-R",e.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O="L-audinence_client_call_onTrackReady-O",e.L_AUDIENCE_CLIENT_SUBSCRIBE_T="L-audinence_client_subscribe-T",e.L_AUDIENCE_CLIENT_SUBSCRIBE_R="L-audinence_client_subscribe-R",e.L_AUDIENCE_CLIENT_UNSUBSCRIBE_T="L-audinence_client_unsubscribe-T",e.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R="L-audinence_client_unsubscribe-R",e.L_PINGER_START_O="L-pinger_start-O",e.L_PINGER_STOP_O="L-pinger_stop-O",e.L_PINGER_SEND_RTCPING_E="L-pinger_send_rtcping-E",e.L_ABSTRACT_ROOM_SEND_MESSAGE_T="L-abstract_room_send_message-T",e.L_ABSTRACT_ROOM_SEND_MESSAGE_R="L-abstract_room_send_message-R",e.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_T="L-abstract_room_set_room_attribute-T",e.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R="L-abstract_room_set_room_attribute_R",e.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_T="L-abstract_room_delete_room_attribute_T",e.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R="L-abstract_room_delete_room_attribute_R",e.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_T="L-abstract_room_get_room_attribute_T",e.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_R="L-abstract_room_get_room_attribute_R",e.L_ABSTRACT_ROOM_PUBLISH_T="L-abstract_room_publish-T",e.L_ABSTRACT_ROOM_PUBLISH_R="L-abstract_room_publish-R",e.L_ABSTRACT_ROOM_PUBLISH_E="L-abstract_room_publish-E",e.L_ABSTRACT_ROOM_UNPUBLISH_T="L-abstract_room_unpublish-T",e.L_ABSTRACT_ROOM_UNPUBLISH_R="L-abstract_room_unpublish-R",e.L_ABSTRACT_ROOM_UNPUBLISH_E="L-abstract_room_unpublish-E",e.L_ABSTRACT_ROOM_UNPUBLISH_P="L-abstract_room_unpublish-P",e.L_ABSTRACT_ROOM_SUBSCRIBE_T="L-abstract_room_subscribe-T",e.L_ABSTRACT_ROOM_SUBSCRIBE_R="L-abstract_room_subscribe-R",e.L_ABSTRACT_ROOM_SUBSCRIBE_E="L-abstract_room_subscribe-E",e.L_ABSTRACT_ROOM_UNSUBSCRIBE_T="L-abstract_room_unsubscribe-T",e.L_ABSTRACT_ROOM_UNSUBSCRIBE_R="L-abstract_room_unsubscribe-R",e.L_ABSTRACT_ROOM_UNSUBSCRIBE_E="L-abstract_room_unsubscribe-E",e.L_APP_CALL_UNSUBSCRIBE_O="L-app_call_unsubscribe-O",e.L_USER_LEFT_UNSUBSCRIBE_O="L-user_left_unsubscribe-O",e.L_RES_UNPUB_UNSUBSCRIBE_O="L-res_unpub_unsubscribe-O",e.L_ABSTRACT_ROOM_REGISTER_ROOM_EVENT_LISTENER_O="L-abstract_room_register_room_event_listener-O",e.L_ABSTRACT_ROOM_REGISTER_REPORT_LISTENER_O="L-abstract_room_register_report_listener-O",e.L_ABSTRACT_ROOM_AUDIO_LEVEL_O="L-abstract_room_audio_level-O",e.L_ABSTRACT_ROOM_IM_RECONNECTED_T="L-abstract_room_im_reconnected-T",e.L_ABSTRACT_ROOM_IM_RECONNECTED_R="L-abstract_room_im_reconnected-R",e.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O="L-abstract_room_call_app_listener-O",e.L_ABSTRACT_ROOM_SETBITRATE_O="L-abstract_room_setBitrate-O",e.L_ABSTRACT_ROOM_ONTRACKREADY_O="L-abstract_room_onTrackReady-O",e.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O="L-abstract_room_receive_message-O",e.L_ABSTRACT_ROOM_ONKICKOFF_O="L-abstract_room_onKickoff-O",e.L_LIVING_ROOM_RECONNECTED_T="L-living_room_reconnected-T",e.L_LIVING_ROOM_RECONNECTED_R="L-living_room_reconnected-R",e.L_LIVING_ROOM_ENABLE_INNER_CDN_T="L-living_room_enable_inner_cdn-T",e.L_LIVING_ROOM_ENABLE_INNER_CDN_R="L-living_room_enable_inner_cdn-R",e.L_LIVING_ROOM_SPREAD_CDN_INFO_T="L-living_room_spread_cdn_info-T",e.L_LIVING_ROOM_SPREAD_CDN_INFO_R="L-living_room_spread_cdn_info-R",e.L_LIVING_ROOM_SET_ROOM_CDN_INFO_T="L-living_room_set_room_cdn_info-T",e.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R="L-living_room_set_room_cdn_info-R",e.L_LIVING_ROOM_JOINED_PK_ROOM_T="L-living_room_joined_pk_room-T",e.L_LIVING_ROOM_JOINED_PK_ROOM_R="L-living_room_joined_pk_room-R",e.L_LIVING_ROOM_LEAVE_PK_ROOM_T="L-living_room_leave_pk_room-T",e.L_LIVING_ROOM_LEAVE_PK_ROOM_R="L-living_room_leave_pk_room-R",e.L_APP_CALL_LEAVE_PK_ROOM_O="L-app_call_leave_pk_room-O",e.L_QUIT_PK_LEAVE_PK_ROOM_O="L-quit_pk_leave_pk_room-O",e.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O="L-living_room_get_room_pk_handler-O",e.L_LIVING_ROOM_GET_MCU_CONFIG_BUILDER_O="L-living_room_get_mcu_config_builder-O",e.L_LIVING_ROOM_QUIT_ALL_PK_ROOM_O="L-living_room_quit_all_pk_room-O",e.L_LIVING_PK_HANDLER_REGISTER_ROOM_PK_EVENT_LISTENER_O="L-living_pk_handler_register_room_pk_event_listener-O",e.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O="L-living_pk_handler_call_app_listener-O",e.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_T="L-living_pk_handler_request_join_other_room-T",e.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R="L-living_pk_handler_request_join_other_room-R",e.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_T="L-living_pk_handler_cancel_request_join_other_room-T",e.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R="L-living_pk_handler_cancel_request_join_other_room-R",e.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_T="L-living_pk_handler_response_join_other_room-T",e.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R="L-living_pk_handler_response_join_other_room-R",e.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_T="L-living_pk_handler_join_other_room-T",e.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R="L-living_pk_handler_join_other_room-R",e.L_LIVING_PK_HANDLER_LEAVE_OTHER_ROOM_T="L-living_pk_handler_leave_other_room-T",e.L_LIVING_PK_HANDLER_LEAVE_OTHER_ROOM_R="L-living_pk_handler_leave_other_room-R",e.L_QUIT_PK_T="L-quit_pk-T",e.L_QUIT_PK_R="L-quit_pk-R",e.L_EXCHANGE_WITH_PUSHOTHERROOM_T="L-exchange_with_pushotherroom-T",e.L_EXCHANGE_WITH_PUSHOTHERROOM_R="L-exchange_with_pushotherroom-R",e.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O="L-audience_living_room_call_app_listener-O",e.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_O="L-audience_living_room_pull_kvEntries-O",e.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T="L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T",e.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R="L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R",e.L_AUDIENCE_LIVING_ROOM_SINGAL_DATA_CHANGE_P="L-audience_living_room_singal_data_change-P",e.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_T="L-audience_living_room_get_cdn_play_url-T",e.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R="L-audience_living_room_get_cdn_play_url-R",e.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_T="L-audience_living_room_subscribe-T",e.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R="L-audience_living_room_subscribe-R",e.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_T="L-audience_living_room_unsubscribe-T",e.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R="L-audience_living_room_unsubscribe-R",e.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_T="L-audience_living_room_update_subscribeList-T",e.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R="L-audience_living_room_update_subscribeList-R",e.L_AUDIENCE_LIVING_ROOM_ONTRACKREADY_O="L-audience_living_room_onTrackReady-O",e.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R="L-audience_living_room_im_reconnected-R",e.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_T="L-audience_living_room_im_reconnected-T",e.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O="L-mcu_config_builder_set_host_video_track-O",e.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O="L-mcu_config_builder_set_mix_layout_mode-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O="L-mcu_config_builder_set_output_video_resolution-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O="L-mcu_config_builder_set_output_video_fps-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O="L-mcu_config_builder_set_output_video_bitrate-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O="L-mcu_config_builder_set_output_tiny_video_resolution-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O="L-mcu_config_builder_set_output_tiny_video_fps-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O="L-mcu_config_builder_set_output_tiny_video_bitrate-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O="L-mcu_config_builder_set_output_video_render_mode-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O="L-mcu_config_builder_set_output_audio_bitrate-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O="L-mcu_config_builder_set_output_background_color-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O="L-mcu_config_builder_add_output_background_picture-O",e.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O="L-mcu_config_builder_remove_output_background_picture-O",e.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O="L-mcu_config_builder_clear_output_background_picture-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O="L-mcu_config_builder_set_output_background_picture-fill-mode-O",e.L_MCU_CONFIG_BUILDER_ADD_PUBLISH_STREAM_URLS_O="L-mcu_config_builder_add_publish_stream_urls-O",e.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O="L-mcu_config_builder_remove_publish_stream_urls-O",e.L_MCU_CONFIG_BUILDER_CLEAR_PUBLISH_STREAM_URLS_O="L-mcu_config_builder_clear_publish_stream_urls-O",e.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O="L-mcu_config_builder_add_customize_layout_video-O",e.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O="L-mcu_config_builder_remove_customize_layout_video-O",e.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_LAYOUT_VIDEO_O="L-mcu_config_builder_clear_customize_layout_video-O",e.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_set_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_add_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_remove_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_clear_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_RESET_O="L-mcu_config_builder_reset-O",e.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O="L-mcu_config_builder_add_single_water_mark-O",e.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O="L-mcu_config_builder_remove_single_water_mark-O",e.L_MCU_CONFIG_BUILDER_CLEAR_SINGLE_WATER_MARK_O="L-mcu_config_builder_clear_single_water_mark-O",e.L_MEDIA_SERVICE_SET_MCU_CONFIG_T="L-media_service_set_mcu_config-T",e.L_MEDIA_SERVICE_SET_MCU_CONFIG_R="L-media_service_set_mcu_config-R",e.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_T="L-media_service_get_cnd_resource_info-T",e.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R="L-media_service_get_cnd_resource_info-R",e.L_MEDIA_SERVICE_MSLIST_CHANGE_O="L-media_service_msList_change-O",e.L_MEDIA_SERVICE_PARSE_NAVI_CALLVOIP_INFO_O="L-media_service_parse_navi_callvoip_info-O",e.L_MEDIA_SERVICE_REQUEST_T="L-media_service_request-T",e.L_MEDIA_SERVICE_REQUEST_R="L-media_service_request-R",e.L_LOCAL_TRACK_DESTROY_O="L-loacl_track_destroy-O",e.L_LOCAL_TRACK_SET_BITRATE_O="L-loacl_track_set_bitrate-O",e.L_LOCAL_TRACK_SET_LOCAL_MUTED_O="L-loacl_track_set_local_muted-O",e.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_T="L-loacl_track_set_local_muted_spread-T",e.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R="L-loacl_track_set_local_muted_spread-R",e.L_TRACK_PLAY_O="L-track_play-O",e.L_TRACK_PLAY_E="L-track_play-E",e.L_TRACK_LOAD_START_O="L-track_load_start-O",e.L_TRACK_DURATION_CHANGE_O="L-track_duration_change-O",e.L_TRACK_LOADED_META_DATA_O="L-track_loaded_meta_data-O",e.L_TRACK_LOADED_DATA_O="L-track_loaded_data-O",e.L_TRACK_ABORT_O="L-track_abort-O",e.L_TRACK_VOLUME_CHANGE_O="L-track_volume_change-O",e.L_TRACK_CANPLAY_O="L-track_canplay-O",e.L_ABSTRACT_STAT_PARSER_FORMAT_RTC_STATE_REPORT_O="L-abstract_stat_parser_format_rtc_state_report-O",e.L_A_SDP_STRATEGY_SET_SDP_SEMANTICS_O="L-a_sdp_strategy_set_sdp_semantics-O",e.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O="L-a_sdp_strategy_set_remote_answer-O",e.L_RTC_PEER_CONNECTION_ADD_LOCAL_TRACK_O="L-rtc_peer_connection_add_local_track-O",e.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_S="L-rtc_peer_connection_ice_connection_state-S",e.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_REPORT_R="L-rtc_peer_connection_ice_connection_state_report-R",e.L_RTC_PEER_CONNECTION_CONNECTION_STATE_S="L-rtc_peer_connection_connection_state-S",e.L_RTC_PEER_CONNECTION_SET_BITRATE_O="L-rtc_peer_connection_set_bitrate-O",e.L_RTC_PEER_CONNECTION_CREATE_OFFER_O="L-rtc_peer_connection_create_offer-O",e.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O="L-rtc_peer_connection_remove_local_track_by_id-O",e.L_RTC_PEER_CONNECTION_REMOVE_ALL_LOCAL_TRACK_O="L-rtc_peer_connection_remove_all_local_track-O",e.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_O="L-rtc_peer_connection_remove_local_track-O",e.L_RTC_PEER_CONNECTION_DESTROY_O="L-rtc_peer_connection_destroy-O",e.L_RTC_SET_RECOMMEND_BITRATE_O="L_rtc_set_recommend_bitrate_O",e.L_RTC_3ANOISE_NODE_O="L_RTC_AAAnoiseNode_O",e.L_RTC_3ANOISE_NODE_E="L_RTC_AAAnoiseNode_E",e.L_RTC_3ANOISE_NODE_STOP_O="L_RTC_AAAnoiseNode_Stop_O",e.L_QS_JOIN_ROOM_S="RTC-joinRoomRtc-S",e.L_QS_SUBSCRIBE_S="RTC-subscribe-S",e.L_QS_UNSUBSCRIBE_S="RTC-unsubscribe-S",e.L_QS_PUBLISH_S="RTC-publishRtc-S",e.L_QS_UNPUBLISH_S="RTC-unpublishRtc-S",e.L_QS_ICE_STATUS_S="RTC-iceStatus-S",e.L_QS_KICKED_S="RTC-forcedOffline-S",e.L_QS_PUB_ICE_STATUS_S="RTC-pubIceConnected-S",e.L_QS_SUB_ICE_STATUS_S="RTC-subIceConnected-S",e.L_QS_RECV_PUB_MSG_S="RTC-recvPubMsg-S",e.L_SET_ENCODER_PREFERENCES_S="RTC-set_Encoder_Preferences-S",e.L_RTCNTF_PULL_ROOM_STATUS_O="L-rtcntf_pull_room_status-O",e.L_RTCPING_PULL_ROOM_STATUS_O="L-rtcping_pull_room_status-O",e.L_PULL_ROOM_STATUS_T="L-pull_room_status-T",e.L_PULL_ROOM_STATUS_R="L-pull_room_status-R",e.L_OLD_DAILY_RECORD_O="L-old_daily_record-O",e.L_REMOTE_USER_JOINED_RESOURCES_O="L-remote_user_joined_resources-O",e.L_REMOTE_USER_STATE_HANDLE_O="L-remote_user_state_handle-O",e.L_UPDATE_SUBSCRIBELIST_COMMAND_T="L-update_subscribeList_command-T",e.L_UPDATE_SUBSCRIBELIST_COMMAND_P="L-update_subscribeList_command-P",e.L_UPDATE_SUBSCRIBELIST_COMMAND_R="L-update_subscribeList_command-R",e.L_RTC_CLIENT_NAVI_CHANGE_O="L-rtc_client_navi_change-O",e.L_UNPUBLISH_PREV_COMMAND_T="L-unpublish_prev_command-T",e.L_UNPUBLISH_PREV_COMMAND_R="L-unpublish_prev_command-R",e.L_RETRY_EXCHANGE_COMMAND_T="L-retry_exchange_command-T",e.L_RETRY_EXCHANGE_SPREAD_T="L-retry_exchange_spread-T",e.L_RETRY_EXCHANGE_SPREAD_R="L-retry_exchange_spread-R",e.L_PARSE_USERSTATE_COMMAND_R="L-parse_userstate_command-R",e.L_RESUB_REPUB_RES_R="L-resub_repub_res-R",e.L_PARSE_ROOMDATA_URIS_R="L-parse_roomdata_uris-R",e.L_SET_AUDIO_CONSTRAINTS_O="L-set_audio_constraints-O",e.L_FUNCTION_IS_UNAVAILABLE="L-function_is_unavailable",e.L_CLEAR_UNSUBSCRIBE_LIST_O="L-clear_unsubscribe_list-O",e.L_INVOKER_PUSH_O="L-invoker_push-O",e.L_INVOKER_EXECUTE_T="L-invoker_execute-T",e.L_INVOKER_EXECUTE_R="L-invoker_execute-R",e.L_INVOKER_DESTROY_O="L-invoker_destroy-R",e.L_PARSE_VOIP_SERVER_CONF_E="L_PARSE_VOIP_SERVER_CONF_E",e.L_GET_MEDIA_STREAM_E="L_GET_MEDIA_STREAM_E",e.L_INNER_SET_TRACK_O="L_INNER_SET_TRACK_O",e.A_APPLY_3A_NOISE_WORKLET_T="A-apply_3a_noise_worklet-T",e.A_APPLY_3A_NOISE_WORKLET_R="A-apply_3a_noise_worklet-R",e.L_ENCRYPTOR_ENCODE_E="L-encryptor_encode-E",e.L_ENCRYPTOR_DECODE_E="L-encryptor_decode-E"}(E||(E={})),function(e){e.FAILED="fail",e.SUCCESSED="success",e.TIMEOUT="timeout",e.INFO="info"}(I||(I={}));let A=!0,N=!0;function w(e,t,r){const n=e.match(t);return n&&n.length>=r&&parseInt(n[r],10)}function D(e,t,r){if(!e.RTCPeerConnection)return;const n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return i.apply(this,arguments);const o=e=>{const t=r(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(n,o),i.apply(this,[e,o])};const o=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(r))return o.apply(this,arguments);const n=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},Object.defineProperty(n,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function k(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(A=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function U(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(N=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function M(){if("object"==typeof window){if(A)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function j(e,t){N&&console.warn(e+" is deprecated, please use "+t+" instead.")}function B(e){return"[object Object]"===Object.prototype.toString.call(e)}function x(e){return B(e)?Object.keys(e).reduce((function(t,r){const n=B(e[r]),i=n?x(e[r]):e[r],o=n&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,{[r]:i})}),{}):e}function V(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach((n=>{n.endsWith("Id")?V(e,e.get(t[n]),r):n.endsWith("Ids")&&t[n].forEach((t=>{V(e,e.get(t),r)}))})))}function F(e,t,r){const n=r?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((r=>{r.type===n&&r.trackId===t.id&&V(e,r,i)}))})),i}const J=M;function G(e,t){const r=e&&e.navigator;if(!r.mediaDevices)return;const n=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((r=>{if("require"===r||"advanced"===r||"mediaSource"===r)return;const n="object"==typeof e[r]?e[r]:{ideal:e[r]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];let e={};"number"==typeof n.ideal?(e[i("min",r)]=n.ideal,t.optional.push(e),e={},e[i("max",r)]=n.ideal,t.optional.push(e)):(e[i("",r)]=n.ideal,t.optional.push(e))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",r)]=n.exact):["min","max"].forEach((e=>{void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,r)]=n[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});const a=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||a)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return r.mediaDevices.enumerateDevices().then((r=>{let a=(r=r.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!a&&r.length&&t.includes("back")&&(a=r[r.length-1]),a&&(e.video.deviceId=o.exact?{exact:a.deviceId}:{ideal:a.deviceId}),e.video=n(e.video),J("chrome: "+JSON.stringify(e)),i(e)}))}e.video=n(e.video)}return J("chrome: "+JSON.stringify(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(r.getUserMedia=function(e,t,n){i(e,(e=>{r.webkitGetUserMedia(e,t,(e=>{n&&n(o(e))}))}))}.bind(r),r.mediaDevices.getUserMedia){const e=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(t){return i(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(o(e))))))}}}function H(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function K(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(r=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===r.track.id)):{track:r.track};const i=new Event("track");i.track=r.track,i.receiver=n,i.transceiver={receiver:n},i.streams=[t.stream],this.dispatchEvent(i)})),t.stream.getTracks().forEach((r=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===r.id)):{track:r};const i=new Event("track");i.track=r,i.receiver=n,i.transceiver={receiver:n},i.streams=[t.stream],this.dispatchEvent(i)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else D(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function W(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){let i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};const n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function Y(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,r,n]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const i=function(e){const t={};return e.result().forEach((e=>{const r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{r[t]=e.stat(t)})),t[r.id]=r})),t},o=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const n=function(e){r(o(i(e)))};return t.apply(this,[n,e])}return new Promise(((e,r)=>{t.apply(this,[function(t){e(o(i(t)))},r])})).then(r,n)}}function z(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>F(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),D(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>F(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,r,n;return this.getSenders().forEach((r=>{r.track===e&&(t?n=!0:t=r)})),this.getReceivers().forEach((t=>(t.track===e&&(r?n=!0:r=t),t.track===e))),n||t&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function q(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const n=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===this._shimmedLocalStreams[r.id].indexOf(n)&&this._shimmedLocalStreams[r.id].push(n):this._shimmedLocalStreams[r.id]=[r,n],n};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();r.apply(this,arguments);const n=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(n)};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const r=this._shimmedLocalStreams[t].indexOf(e);-1!==r&&this._shimmedLocalStreams[t].splice(r,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),i.apply(this,arguments)}}function Q(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return q(e);const r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=r.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const r=new e.MediaStream(t.getTracks());this._streams[t.id]=r,this._reverseStreams[r.id]=t,t=r}n.apply(this,[t])};const i=e.RTCPeerConnection.prototype.removeStream;function o(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:r})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,r){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const n=[].slice.call(arguments,1);if(1!==n.length||!n[0].getTracks().find((e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find((e=>e.track===t)))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const i=this._streams[r.id];if(i)i.addTrack(t),Promise.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const n=new e.MediaStream([t]);this._streams[r.id]=n,this._reverseStreams[n.id]=r,this.addStream(n)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?r.apply(this,[t=>{const r=o(this,t);e[0].apply(null,[r])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):r.apply(this,arguments).then((e=>o(this,e)))}};e.RTCPeerConnection.prototype[t]=n[t]}));const a=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:r})}(this,arguments[0]),a.apply(this,arguments)):a.apply(this,arguments)};const s=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=s.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach((r=>{this._streams[r].getTracks().find((t=>e.track===t))&&(t=this._streams[r])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Z(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}))}function X(e,t){D(e,"negotiationneeded",(e=>{const r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var $=Object.freeze({__proto__:null,shimMediaStream:H,shimOnTrack:K,shimGetSendersWithDtmf:W,shimGetStats:Y,shimSenderReceiverGetStats:z,shimAddTrackRemoveTrackWithNative:q,shimAddTrackRemoveTrack:Q,shimPeerConnection:Z,fixNegotiationNeeded:X,shimGetUserMedia:G,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then((t=>{const n=r.video&&r.video.width,i=r.video&&r.video.height,o=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}});var ee,te,re=(ee=function(e){var t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},t.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},t.getDescription=function(e){var r=t.splitSections(e);return r&&r[0]},t.getMediaSections=function(e){var r=t.splitSections(e);return r.shift(),r},t.matchPrefix=function(e,r){return t.splitLines(e).filter((function(e){return 0===e.indexOf(r)}))},t.parseCandidate=function(e){for(var t,r={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},n=8;n<t.length;n+=2)switch(t[n]){case"raddr":r.relatedAddress=t[n+1];break;case"rport":r.relatedPort=parseInt(t[n+1],10);break;case"tcptype":r.tcpType=t[n+1];break;case"ufrag":r.ufrag=t[n+1],r.usernameFragment=t[n+1];break;default:r[t[n]]=t[n+1]}return r},t.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var r=e.type;return t.push("typ"),t.push(r),"host"!==r&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=parseInt(t[1],10),r.channels=3===t.length?parseInt(t[2],10):1,r.numChannels=r.channels,r},t.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\r\n"},t.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},t.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<n.length;i++)r[(t=n[i].trim().split("="))[0].trim()]=t[1];return r},t.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var n=[];Object.keys(e.parameters).forEach((function(t){e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)})),t+="a=fmtp:"+r+" "+n.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){var t="",r=e.payloadType;return void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){var t=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,t-7),10)},n=e.indexOf(":",t);return n>-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},t.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},t.getMid=function(e){var r=t.matchPrefix(e,"a=mid:")[0];if(r)return r.substr(6)},t.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},t.getDtlsParameters=function(e,r){return{role:"auto",fingerprints:t.matchPrefix(e+r,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),r},t.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,r){return t.matchPrefix(e+r,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,r){var n=t.matchPrefix(e+r,"a=ice-ufrag:")[0],i=t.matchPrefix(e+r,"a=ice-pwd:")[0];return n&&i?{usernameFragment:n.substr(12),password:i.substr(10)}:null},t.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},t.parseRtpParameters=function(e){for(var r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=t.splitLines(e)[0].split(" "),i=3;i<n.length;i++){var o=n[i],a=t.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(a){var s=t.parseRtpMap(a),c=t.matchPrefix(e,"a=fmtp:"+o+" ");switch(s.parameters=c.length?t.parseFmtp(c[0]):{},s.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(t.parseRtcpFb),r.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(s.name.toUpperCase())}}}return t.matchPrefix(e,"a=extmap:").forEach((function(e){r.headerExtensions.push(t.parseExtmap(e))})),r},t.writeRtpDescription=function(e,r){var n="";n+="m="+e+" ",n+=r.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=r.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",r.codecs.forEach((function(e){n+=t.writeRtpMap(e),n+=t.writeFmtp(e),n+=t.writeRtcpFb(e)}));var i=0;return r.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(n+="a=maxptime:"+i+"\r\n"),n+="a=rtcp-mux\r\n",r.headerExtensions&&r.headerExtensions.forEach((function(e){n+=t.writeExtmap(e)})),n},t.parseRtpEncodingParameters=function(e){var r,n=[],i=t.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),a=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=s.length>0&&s[0].ssrc,u=t.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substr(17).split(" ").map((function(e){return parseInt(e,10)}))}));u.length>0&&u[0].length>1&&u[0][0]===c&&(r=u[0][1]),i.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&r&&(t.rtx={ssrc:r}),n.push(t),o&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},n.push(t))}})),0===n.length&&c&&n.push({ssrc:c});var l=t.matchPrefix(e,"b=");return l.length&&(l=0===l[0].indexOf("b=TIAS:")?parseInt(l[0].substr(7),10):0===l[0].indexOf("b=AS:")?1e3*parseInt(l[0].substr(5),10)*.95-16e3:void 0,n.forEach((function(e){e.maxBitrate=l}))),n},t.parseRtcpParameters=function(e){var r={},n=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];n&&(r.cname=n.value,r.ssrc=n.ssrc);var i=t.matchPrefix(e,"a=rtcp-rsize");r.reducedSize=i.length>0,r.compound=0===i.length;var o=t.matchPrefix(e,"a=rtcp-mux");return r.mux=o.length>0,r},t.parseMsid=function(e){var r,n=t.matchPrefix(e,"a=msid:");if(1===n.length)return{stream:(r=n[0].substr(7).split(" "))[0],track:r[1]};var i=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return i.length>0?{stream:(r=i[0].value.split(" "))[0],track:r[1]}:void 0},t.parseSctpDescription=function(e){var r,n=t.parseMLine(e),i=t.matchPrefix(e,"a=max-message-size:");i.length>0&&(r=parseInt(i[0].substr(19),10)),isNaN(r)&&(r=65536);var o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:n.fmt,maxMessageSize:r};if(t.matchPrefix(e,"a=sctpmap:").length>0){var a=t.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(a[0],10),protocol:a[1],maxMessageSize:r}}},t.writeSctpDescription=function(e,t){var r=[];return r="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,r,n){var i=void 0!==r?r:2;return"v=0\r\no="+(n||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.writeMediaSection=function(e,r,n,i){var o=t.writeRtpDescription(e.kind,r);if(o+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":"active"),o+="a=mid:"+e.mid+"\r\n",e.direction?o+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?o+="a=sendrecv\r\n":e.rtpSender?o+="a=sendonly\r\n":e.rtpReceiver?o+="a=recvonly\r\n":o+="a=inactive\r\n",e.rtpSender){var a="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";o+="a="+a,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+"\r\n"),o},t.getDirection=function(e,r){for(var n=t.splitLines(e),i=0;i<n.length;i++)switch(n[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[i].substr(2)}return r?t.getDirection(r):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substr(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){var r=t.splitLines(e)[0].substr(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},t.parseOLine=function(e){var r=t.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var r=t.splitLines(e),n=0;n<r.length;n++)if(r[n].length<2||"="!==r[n].charAt(1))return!1;return!0},e.exports=t},ee(te={exports:{}},te.exports),te.exports);function ne(e,t,r,n,i){var o=re.writeRtpDescription(e.kind,t);if(o+=re.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=re.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":i||"active"),o+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?o+="a=sendrecv\r\n":e.rtpSender?o+="a=sendonly\r\n":e.rtpReceiver?o+="a=recvonly\r\n":o+="a=inactive\r\n",e.rtpSender){var a=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=a;var s="msid:"+(n?n.id:"-")+" "+a+"\r\n";o+="a="+s,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+s,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+s,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+re.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+re.localCName+"\r\n"),o}function ie(e,t){var r={codecs:[],headerExtensions:[],fecMechanisms:[]},n=function(e,t){e=parseInt(e,10);for(var r=0;r<t.length;r++)if(t[r].payloadType===e||t[r].preferredPayloadType===e)return t[r]},i=function(e,t,r,i){var o=n(e.parameters.apt,r),a=n(t.parameters.apt,i);return o&&a&&o.name.toLowerCase()===a.name.toLowerCase()};return e.codecs.forEach((function(n){for(var o=0;o<t.codecs.length;o++){var a=t.codecs[o];if(n.name.toLowerCase()===a.name.toLowerCase()&&n.clockRate===a.clockRate){if("rtx"===n.name.toLowerCase()&&n.parameters&&a.parameters.apt&&!i(n,a,e.codecs,t.codecs))continue;(a=JSON.parse(JSON.stringify(a))).numChannels=Math.min(n.numChannels,a.numChannels),r.codecs.push(a),a.rtcpFeedback=a.rtcpFeedback.filter((function(e){for(var t=0;t<n.rtcpFeedback.length;t++)if(n.rtcpFeedback[t].type===e.type&&n.rtcpFeedback[t].parameter===e.parameter)return!0;return!1}));break}}})),e.headerExtensions.forEach((function(e){for(var n=0;n<t.headerExtensions.length;n++){var i=t.headerExtensions[n];if(e.uri===i.uri){r.headerExtensions.push(i);break}}})),r}function oe(e,t,r){return-1!=={offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(r)}function ae(e,t){var r=e.getRemoteCandidates().find((function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type}));return r||e.addRemoteCandidate(t),!r}function se(e,t){var r=new Error(t);return r.name=e,r.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],r}var ce=function(e,t){function r(t,r){r.addTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function n(t,r,n,i){var o=new Event("track");o.track=r,o.receiver=n,o.transceiver={receiver:n},o.streams=i,e.setTimeout((function(){t._dispatchEvent("track",o)}))}var i=function(r){var n=this,i=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach((function(e){n[e]=i[e].bind(i)})),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",r=JSON.parse(JSON.stringify(r||{})),this.usingBundle="max-bundle"===r.bundlePolicy,"negotiate"===r.rtcpMuxPolicy)throw se("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(r.rtcpMuxPolicy||(r.rtcpMuxPolicy="require"),r.iceTransportPolicy){case"all":case"relay":break;default:r.iceTransportPolicy="all"}switch(r.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:r.bundlePolicy="balanced"}if(r.iceServers=function(e,t){var r=!1;return(e=JSON.parse(JSON.stringify(e))).filter((function(e){if(e&&(e.urls||e.url)){var n=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var i="string"==typeof n;return i&&(n=[n]),n=n.filter((function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||r?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(r=!0,!0)})),delete e.url,e.urls=i?n[0]:n,!!n.length}}))}(r.iceServers||[],t),this._iceGatherers=[],r.iceCandidatePoolSize)for(var o=r.iceCandidatePoolSize;o>0;o--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:r.iceServers,gatherPolicy:r.iceTransportPolicy}));else r.iceCandidatePoolSize=0;this._config=r,this.transceivers=[],this._sdpSessionId=re.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(i.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(i.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),i.prototype.onicecandidate=null,i.prototype.onaddstream=null,i.prototype.ontrack=null,i.prototype.onremovestream=null,i.prototype.onsignalingstatechange=null,i.prototype.oniceconnectionstatechange=null,i.prototype.onconnectionstatechange=null,i.prototype.onicegatheringstatechange=null,i.prototype.onnegotiationneeded=null,i.prototype.ondatachannel=null,i.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},i.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},i.prototype.getConfiguration=function(){return this._config},i.prototype.getLocalStreams=function(){return this.localStreams},i.prototype.getRemoteStreams=function(){return this.remoteStreams},i.prototype._createTransceiver=function(e,t){var r=this.transceivers.length>0,n={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&r)n.iceTransport=this.transceivers[0].iceTransport,n.dtlsTransport=this.transceivers[0].dtlsTransport;else{var i=this._createIceAndDtlsTransports();n.iceTransport=i.iceTransport,n.dtlsTransport=i.dtlsTransport}return t||this.transceivers.push(n),n},i.prototype.addTrack=function(t,r){if(this._isClosed)throw se("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var n;if(this.transceivers.find((function(e){return e.track===t})))throw se("InvalidAccessError","Track already exists.");for(var i=0;i<this.transceivers.length;i++)this.transceivers[i].track||this.transceivers[i].kind!==t.kind||(n=this.transceivers[i]);return n||(n=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(r)&&this.localStreams.push(r),n.track=t,n.stream=r,n.rtpSender=new e.RTCRtpSender(t,n.dtlsTransport),n.rtpSender},i.prototype.addStream=function(e){var r=this;if(t>=15025)e.getTracks().forEach((function(t){r.addTrack(t,e)}));else{var n=e.clone();e.getTracks().forEach((function(e,t){var r=n.getTracks()[t];e.addEventListener("enabled",(function(e){r.enabled=e.enabled}))})),n.getTracks().forEach((function(e){r.addTrack(e,n)}))}},i.prototype.removeTrack=function(t){if(this._isClosed)throw se("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var r=this.transceivers.find((function(e){return e.rtpSender===t}));if(!r)throw se("InvalidAccessError","Sender was not created by this connection.");var n=r.stream;r.rtpSender.stop(),r.rtpSender=null,r.track=null,r.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(n)&&this.localStreams.indexOf(n)>-1&&this.localStreams.splice(this.localStreams.indexOf(n),1),this._maybeFireNegotiationNeeded()},i.prototype.removeStream=function(e){var t=this;e.getTracks().forEach((function(e){var r=t.getSenders().find((function(t){return t.track===e}));r&&t.removeTrack(r)}))},i.prototype.getSenders=function(){return this.transceivers.filter((function(e){return!!e.rtpSender})).map((function(e){return e.rtpSender}))},i.prototype.getReceivers=function(){return this.transceivers.filter((function(e){return!!e.rtpReceiver})).map((function(e){return e.rtpReceiver}))},i.prototype._createIceGatherer=function(t,r){var n=this;if(r&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var r=!e.candidate||0===Object.keys(e.candidate).length;i.state=r?"completed":"gathering",null!==n.transceivers[t].bufferedCandidateEvents&&n.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},i.prototype._gather=function(t,r){var n=this,i=this.transceivers[r].iceGatherer;if(!i.onlocalcandidate){var o=this.transceivers[r].bufferedCandidateEvents;this.transceivers[r].bufferedCandidateEvents=null,i.removeEventListener("localcandidate",this.transceivers[r].bufferCandidates),i.onlocalcandidate=function(e){if(!(n.usingBundle&&r>0)){var o=new Event("icecandidate");o.candidate={sdpMid:t,sdpMLineIndex:r};var a=e.candidate,s=!a||0===Object.keys(a).length;if(s)"new"!==i.state&&"gathering"!==i.state||(i.state="completed");else{"new"===i.state&&(i.state="gathering"),a.component=1,a.ufrag=i.getLocalParameters().usernameFragment;var c=re.writeCandidate(a);o.candidate=Object.assign(o.candidate,re.parseCandidate(c)),o.candidate.candidate=c,o.candidate.toJSON=function(){return{candidate:o.candidate.candidate,sdpMid:o.candidate.sdpMid,sdpMLineIndex:o.candidate.sdpMLineIndex,usernameFragment:o.candidate.usernameFragment}}}var u=re.getMediaSections(n._localDescription.sdp);u[o.candidate.sdpMLineIndex]+=s?"a=end-of-candidates\r\n":"a="+o.candidate.candidate+"\r\n",n._localDescription.sdp=re.getDescription(n._localDescription.sdp)+u.join("");var l=n.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==n.iceGatheringState&&(n.iceGatheringState="gathering",n._emitGatheringStateChange()),s||n._dispatchEvent("icecandidate",o),l&&(n._dispatchEvent("icecandidate",new Event("icecandidate")),n.iceGatheringState="complete",n._emitGatheringStateChange())}},e.setTimeout((function(){o.forEach((function(e){i.onlocalcandidate(e)}))}),0)}},i.prototype._createIceAndDtlsTransports=function(){var t=this,r=new e.RTCIceTransport(null);r.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var n=new e.RTCDtlsTransport(r);return n.ondtlsstatechange=function(){t._updateConnectionState()},n.onerror=function(){Object.defineProperty(n,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:r,dtlsTransport:n}},i.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var r=this.transceivers[e].iceTransport;r&&(delete r.onicestatechange,delete this.transceivers[e].iceTransport);var n=this.transceivers[e].dtlsTransport;n&&(delete n.ondtlsstatechange,delete n.onerror,delete this.transceivers[e].dtlsTransport)},i.prototype._transceive=function(e,r,n){var i=ie(e.localCapabilities,e.remoteCapabilities);r&&e.rtpSender&&(i.encodings=e.sendEncodingParameters,i.rtcp={cname:re.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(i.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(i)),n&&e.rtpReceiver&&i.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach((function(e){delete e.rtx})),e.recvEncodingParameters.length?i.encodings=e.recvEncodingParameters:i.encodings=[{}],i.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(i.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(i.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(i))},i.prototype.setLocalDescription=function(e){var t,r,n=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(se("TypeError",'Unsupported type "'+e.type+'"'));if(!oe("setLocalDescription",e.type,n.signalingState)||n._isClosed)return Promise.reject(se("InvalidStateError","Can not set local "+e.type+" in state "+n.signalingState));if("offer"===e.type)t=re.splitSections(e.sdp),r=t.shift(),t.forEach((function(e,t){var r=re.parseRtpParameters(e);n.transceivers[t].localCapabilities=r})),n.transceivers.forEach((function(e,t){n._gather(e.mid,t)}));else if("answer"===e.type){t=re.splitSections(n._remoteDescription.sdp),r=t.shift();var i=re.matchPrefix(r,"a=ice-lite").length>0;t.forEach((function(e,t){var o=n.transceivers[t],a=o.iceGatherer,s=o.iceTransport,c=o.dtlsTransport,u=o.localCapabilities,l=o.remoteCapabilities;if(!(re.isRejected(e)&&0===re.matchPrefix(e,"a=bundle-only").length)&&!o.rejected){var _=re.getIceParameters(e,r),d=re.getDtlsParameters(e,r);i&&(d.role="server"),n.usingBundle&&0!==t||(n._gather(o.mid,t),"new"===s.state&&s.start(a,_,i?"controlling":"controlled"),"new"===c.state&&c.start(d));var f=ie(u,l);n._transceive(o,f.codecs.length>0,!1)}}))}return n._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?n._updateSignalingState("have-local-offer"):n._updateSignalingState("stable"),Promise.resolve()},i.prototype.setRemoteDescription=function(i){var o=this;if(-1===["offer","answer"].indexOf(i.type))return Promise.reject(se("TypeError",'Unsupported type "'+i.type+'"'));if(!oe("setRemoteDescription",i.type,o.signalingState)||o._isClosed)return Promise.reject(se("InvalidStateError","Can not set remote "+i.type+" in state "+o.signalingState));var a={};o.remoteStreams.forEach((function(e){a[e.id]=e}));var s=[],c=re.splitSections(i.sdp),u=c.shift(),l=re.matchPrefix(u,"a=ice-lite").length>0,_=re.matchPrefix(u,"a=group:BUNDLE ").length>0;o.usingBundle=_;var d=re.matchPrefix(u,"a=ice-options:")[0];return o.canTrickleIceCandidates=!!d&&d.substr(14).split(" ").indexOf("trickle")>=0,c.forEach((function(n,c){var d=re.splitLines(n),f=re.getKind(n),p=re.isRejected(n)&&0===re.matchPrefix(n,"a=bundle-only").length,h=d[0].substr(2).split(" ")[2],b=re.getDirection(n,u),g=re.parseMsid(n),m=re.getMid(n)||re.generateIdentifier();if(p||"application"===f&&("DTLS/SCTP"===h||"UDP/DTLS/SCTP"===h))o.transceivers[c]={mid:m,kind:f,protocol:h,rejected:!0};else{var v,R,O,E,I,S,T,y,C;!p&&o.transceivers[c]&&o.transceivers[c].rejected&&(o.transceivers[c]=o._createTransceiver(f,!0));var L,P,A=re.parseRtpParameters(n);p||(L=re.getIceParameters(n,u),(P=re.getDtlsParameters(n,u)).role="client"),T=re.parseRtpEncodingParameters(n);var N=re.parseRtcpParameters(n),w=re.matchPrefix(n,"a=end-of-candidates",u).length>0,D=re.matchPrefix(n,"a=candidate:").map((function(e){return re.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===i.type||"answer"===i.type)&&!p&&_&&c>0&&o.transceivers[c]&&(o._disposeIceAndDtlsTransports(c),o.transceivers[c].iceGatherer=o.transceivers[0].iceGatherer,o.transceivers[c].iceTransport=o.transceivers[0].iceTransport,o.transceivers[c].dtlsTransport=o.transceivers[0].dtlsTransport,o.transceivers[c].rtpSender&&o.transceivers[c].rtpSender.setTransport(o.transceivers[0].dtlsTransport),o.transceivers[c].rtpReceiver&&o.transceivers[c].rtpReceiver.setTransport(o.transceivers[0].dtlsTransport)),"offer"!==i.type||p){if("answer"===i.type&&!p){R=(v=o.transceivers[c]).iceGatherer,O=v.iceTransport,E=v.dtlsTransport,I=v.rtpReceiver,S=v.sendEncodingParameters,y=v.localCapabilities,o.transceivers[c].recvEncodingParameters=T,o.transceivers[c].remoteCapabilities=A,o.transceivers[c].rtcpParameters=N,D.length&&"new"===O.state&&(!l&&!w||_&&0!==c?D.forEach((function(e){ae(v.iceTransport,e)})):O.setRemoteCandidates(D)),_&&0!==c||("new"===O.state&&O.start(R,L,"controlling"),"new"===E.state&&E.start(P)),!ie(v.localCapabilities,v.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&v.sendEncodingParameters[0].rtx&&delete v.sendEncodingParameters[0].rtx,o._transceive(v,"sendrecv"===b||"recvonly"===b,"sendrecv"===b||"sendonly"===b),!I||"sendrecv"!==b&&"sendonly"!==b?delete v.rtpReceiver:(C=I.track,g?(a[g.stream]||(a[g.stream]=new e.MediaStream),r(C,a[g.stream]),s.push([C,I,a[g.stream]])):(a.default||(a.default=new e.MediaStream),r(C,a.default),s.push([C,I,a.default])))}}else{(v=o.transceivers[c]||o._createTransceiver(f)).mid=m,v.iceGatherer||(v.iceGatherer=o._createIceGatherer(c,_)),D.length&&"new"===v.iceTransport.state&&(!w||_&&0!==c?D.forEach((function(e){ae(v.iceTransport,e)})):v.iceTransport.setRemoteCandidates(D)),y=e.RTCRtpReceiver.getCapabilities(f),t<15019&&(y.codecs=y.codecs.filter((function(e){return"rtx"!==e.name}))),S=v.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var k,U=!1;if("sendrecv"===b||"sendonly"===b){if(U=!v.rtpReceiver,I=v.rtpReceiver||new e.RTCRtpReceiver(v.dtlsTransport,f),U)C=I.track,g&&"-"===g.stream||(g?(a[g.stream]||(a[g.stream]=new e.MediaStream,Object.defineProperty(a[g.stream],"id",{get:function(){return g.stream}})),Object.defineProperty(C,"id",{get:function(){return g.track}}),k=a[g.stream]):(a.default||(a.default=new e.MediaStream),k=a.default)),k&&(r(C,k),v.associatedRemoteMediaStreams.push(k)),s.push([C,I,k])}else v.rtpReceiver&&v.rtpReceiver.track&&(v.associatedRemoteMediaStreams.forEach((function(t){var r=t.getTracks().find((function(e){return e.id===v.rtpReceiver.track.id}));r&&function(t,r){r.removeTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(r,t)})),v.associatedRemoteMediaStreams=[]);v.localCapabilities=y,v.remoteCapabilities=A,v.rtpReceiver=I,v.rtcpParameters=N,v.sendEncodingParameters=S,v.recvEncodingParameters=T,o._transceive(o.transceivers[c],!1,U)}}})),void 0===o._dtlsRole&&(o._dtlsRole="offer"===i.type?"active":"passive"),o._remoteDescription={type:i.type,sdp:i.sdp},"offer"===i.type?o._updateSignalingState("have-remote-offer"):o._updateSignalingState("stable"),Object.keys(a).forEach((function(t){var r=a[t];if(r.getTracks().length){if(-1===o.remoteStreams.indexOf(r)){o.remoteStreams.push(r);var i=new Event("addstream");i.stream=r,e.setTimeout((function(){o._dispatchEvent("addstream",i)}))}s.forEach((function(e){var t=e[0],i=e[1];r.id===e[2].id&&n(o,t,i,[r])}))}})),s.forEach((function(e){e[2]||n(o,e[0],e[1],[])})),e.setTimeout((function(){o&&o.transceivers&&o.transceivers.forEach((function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))}))}),4e3),Promise.resolve()},i.prototype.close=function(){this.transceivers.forEach((function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()})),this._isClosed=!0,this._updateSignalingState("closed")},i.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},i.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout((function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}}),0))},i.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++})),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var r=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",r)}},i.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++)})),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var r=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",r)}},i.prototype.createOffer=function(){var r=this;if(r._isClosed)return Promise.reject(se("InvalidStateError","Can not call createOffer after close"));var n=r.transceivers.filter((function(e){return"audio"===e.kind})).length,i=r.transceivers.filter((function(e){return"video"===e.kind})).length,o=arguments[0];if(o){if(o.mandatory||o.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==o.offerToReceiveAudio&&(n=!0===o.offerToReceiveAudio?1:!1===o.offerToReceiveAudio?0:o.offerToReceiveAudio),void 0!==o.offerToReceiveVideo&&(i=!0===o.offerToReceiveVideo?1:!1===o.offerToReceiveVideo?0:o.offerToReceiveVideo)}for(r.transceivers.forEach((function(e){"audio"===e.kind?--n<0&&(e.wantReceive=!1):"video"===e.kind&&--i<0&&(e.wantReceive=!1)}));n>0||i>0;)n>0&&(r._createTransceiver("audio"),n--),i>0&&(r._createTransceiver("video"),i--);var a=re.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.transceivers.forEach((function(n,i){var o=n.track,a=n.kind,s=n.mid||re.generateIdentifier();n.mid=s,n.iceGatherer||(n.iceGatherer=r._createIceGatherer(i,r.usingBundle));var c=e.RTCRtpSender.getCapabilities(a);t<15019&&(c.codecs=c.codecs.filter((function(e){return"rtx"!==e.name}))),c.codecs.forEach((function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),n.remoteCapabilities&&n.remoteCapabilities.codecs&&n.remoteCapabilities.codecs.forEach((function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)}))})),c.headerExtensions.forEach((function(e){(n.remoteCapabilities&&n.remoteCapabilities.headerExtensions||[]).forEach((function(t){e.uri===t.uri&&(e.id=t.id)}))}));var u=n.sendEncodingParameters||[{ssrc:1001*(2*i+1)}];o&&t>=15019&&"video"===a&&!u[0].rtx&&(u[0].rtx={ssrc:u[0].ssrc+1}),n.wantReceive&&(n.rtpReceiver=new e.RTCRtpReceiver(n.dtlsTransport,a)),n.localCapabilities=c,n.sendEncodingParameters=u})),"max-compat"!==r._config.bundlePolicy&&(a+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),a+="a=ice-options:trickle\r\n",r.transceivers.forEach((function(e,t){a+=ne(e,e.localCapabilities,"offer",e.stream,r._dtlsRole),a+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===r.iceGatheringState||0!==t&&r.usingBundle||(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,a+="a="+re.writeCandidate(e)+"\r\n"})),"completed"===e.iceGatherer.state&&(a+="a=end-of-candidates\r\n"))}));var s=new e.RTCSessionDescription({type:"offer",sdp:a});return Promise.resolve(s)},i.prototype.createAnswer=function(){var r=this;if(r._isClosed)return Promise.reject(se("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==r.signalingState&&"have-local-pranswer"!==r.signalingState)return Promise.reject(se("InvalidStateError","Can not call createAnswer in signalingState "+r.signalingState));var n=re.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.usingBundle&&(n+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),n+="a=ice-options:trickle\r\n";var i=re.getMediaSections(r._remoteDescription.sdp).length;r.transceivers.forEach((function(e,o){if(!(o+1>i)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?n+="m=application 0 DTLS/SCTP 5000\r\n":n+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?n+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(n+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(n+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var a;if(e.stream)"audio"===e.kind?a=e.stream.getAudioTracks()[0]:"video"===e.kind&&(a=e.stream.getVideoTracks()[0]),a&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var s=ie(e.localCapabilities,e.remoteCapabilities);!s.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,n+=ne(e,s,"answer",e.stream,r._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(n+="a=rtcp-rsize\r\n")}}));var o=new e.RTCSessionDescription({type:"answer",sdp:n});return Promise.resolve(o)},i.prototype.addIceCandidate=function(e){var t,r=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise((function(n,i){if(!r._remoteDescription)return i(se("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var o=e.sdpMLineIndex;if(e.sdpMid)for(var a=0;a<r.transceivers.length;a++)if(r.transceivers[a].mid===e.sdpMid){o=a;break}var s=r.transceivers[o];if(!s)return i(se("OperationError","Can not add ICE candidate"));if(s.rejected)return n();var c=Object.keys(e.candidate).length>0?re.parseCandidate(e.candidate):{};if("tcp"===c.protocol&&(0===c.port||9===c.port))return n();if(c.component&&1!==c.component)return n();if((0===o||o>0&&s.iceTransport!==r.transceivers[0].iceTransport)&&!ae(s.iceTransport,c))return i(se("OperationError","Can not add ICE candidate"));var u=e.candidate.trim();0===u.indexOf("a=")&&(u=u.substr(2)),(t=re.getMediaSections(r._remoteDescription.sdp))[o]+="a="+(c.type?u:"end-of-candidates")+"\r\n",r._remoteDescription.sdp=re.getDescription(r._remoteDescription.sdp)+t.join("")}else for(var l=0;l<r.transceivers.length&&(r.transceivers[l].rejected||(r.transceivers[l].iceTransport.addRemoteCandidate({}),(t=re.getMediaSections(r._remoteDescription.sdp))[l]+="a=end-of-candidates\r\n",r._remoteDescription.sdp=re.getDescription(r._remoteDescription.sdp)+t.join(""),!r.usingBundle));l++);n()}))},i.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var r=null;if(this.transceivers.forEach((function(e){e.rtpSender&&e.rtpSender.track===t?r=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(r=e.rtpReceiver)})),!r)throw se("InvalidAccessError","Invalid selector.");return r.getStats()}var n=[];return this.transceivers.forEach((function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach((function(t){e[t]&&n.push(e[t].getStats())}))})),Promise.all(n).then((function(e){var t=new Map;return e.forEach((function(e){e.forEach((function(e){t.set(e.id,e)}))})),t}))};["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach((function(t){var r=e[t];if(r&&r.prototype&&r.prototype.getStats){var n=r.prototype.getStats;r.prototype.getStats=function(){return n.apply(this).then((function(e){var t=new Map;return Object.keys(e).forEach((function(r){var n;e[r].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(n=e[r]).type]||n.type,t.set(r,e[r])})),t}))}}}));var o=["createOffer","createAnswer"];return o.forEach((function(e){var t=i.prototype[e];i.prototype[e]=function(){var e=arguments;return"function"==typeof e[0]||"function"==typeof e[1]?t.apply(this,[arguments[2]]).then((function(t){"function"==typeof e[0]&&e[0].apply(null,[t])}),(function(t){"function"==typeof e[1]&&e[1].apply(null,[t])})):t.apply(this,arguments)}})),(o=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach((function(e){var t=i.prototype[e];i.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]||"function"==typeof e[2]?t.apply(this,arguments).then((function(){"function"==typeof e[1]&&e[1].apply(null)}),(function(t){"function"==typeof e[2]&&e[2].apply(null,[t])})):t.apply(this,arguments)}})),["getStats"].forEach((function(e){var t=i.prototype[e];i.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]?t.apply(this,arguments).then((function(){"function"==typeof e[1]&&e[1].apply(null)})):t.apply(this,arguments)}})),i};function ue(e){const t=e&&e.navigator,r=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return r(e).catch((e=>Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString(){return this.name}}}(e))))}}function le(e){"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)))}function _e(e,t){if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){const t=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(e){t.set.call(this,e);const r=new Event("enabled");r.enabled=e,this.dispatchEvent(r)}})}e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)&&Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);const r=ce(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=function(e){let t=!1;return(e=JSON.parse(JSON.stringify(e))).filter((e=>{if(e&&(e.urls||e.url)){let r=e.urls||e.url;e.url&&!e.urls&&j("RTCIceServer.url","RTCIceServer.urls");const n="string"==typeof r;return n&&(r=[r]),r=r.filter((e=>{if(0===e.indexOf("stun:"))return!1;const r=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return r&&!t?(t=!0,!0):r&&!t})),delete e.url,e.urls=n?r[0]:r,!!r.length}}))}(e.iceServers,t.version),M("ICE servers after filtering:",e.iceServers)),new r(e)},e.RTCPeerConnection.prototype=r.prototype}function de(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}var fe=Object.freeze({__proto__:null,shimPeerConnection:_e,shimReplaceTrack:de,shimGetUserMedia:ue,shimGetDisplayMedia:le});function pe(e,t){const r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){j("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){const e=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},t=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(r){return"object"==typeof r&&"object"==typeof r.audio&&(r=JSON.parse(JSON.stringify(r)),e(r.audio,"autoGainControl","mozAutoGainControl"),e(r.audio,"noiseSuppression","mozNoiseSuppression")),t(r)},n&&n.prototype.getSettings){const t=n.prototype.getSettings;n.prototype.getSettings=function(){const r=t.apply(this,arguments);return e(r,"mozAutoGainControl","autoGainControl"),e(r,"mozNoiseSuppression","noiseSuppression"),r}}if(n&&n.prototype.applyConstraints){const t=n.prototype.applyConstraints;n.prototype.applyConstraints=function(r){return"audio"===this.kind&&"object"==typeof r&&(r=JSON.parse(JSON.stringify(r)),e(r,"autoGainControl","mozAutoGainControl"),e(r,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[r])}}}}function he(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function be(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}));const r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,o]=arguments;return n.apply(this,[e||null]).then((e=>{if(t.version<53&&!i)try{e.forEach((e=>{e.type=r[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach(((t,n)=>{e.set(n,Object.assign({},t,{type:r[t.type]||t.type}))}))}return e})).then(i,o)}}function ge(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function me(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),D(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function ve(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){j("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function Re(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function Oe(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],r=e&&"sendEncodings"in e;r&&e.sendEncodings.forEach((e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));const n=t.apply(this,arguments);if(r){const{sender:t}=n,r=t.getParameters();(!("encodings"in r)||1===r.encodings.length&&0===Object.keys(r.encodings[0]).length)&&(r.encodings=e.sendEncodings,t.sendEncodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(r).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return n})}function Ee(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function Ie(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function Se(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}var Te=Object.freeze({__proto__:null,shimOnTrack:he,shimPeerConnection:be,shimSenderGetStats:ge,shimReceiverGetStats:me,shimRemoveStream:ve,shimRTCDataChannel:Re,shimAddTransceiver:Oe,shimGetParameters:Ee,shimCreateOffer:Ie,shimCreateAnswer:Se,shimGetUserMedia:pe,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}});function ye(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((r=>t.call(this,r,e))),e.getVideoTracks().forEach((r=>t.call(this,r,e)))},e.RTCPeerConnection.prototype.addTrack=function(e,...r){return r&&r.forEach((e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const r=e.getTracks();this.getSenders().forEach((e=>{r.includes(e.track)&&this.removeTrack(e)}))})}}function Ce(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach((e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)}))})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const r=new Event("addstream");r.stream=t,e.dispatchEvent(r)}))}),t.apply(e,arguments)}}}function Le(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i};let s=function(e,t,r){const n=i.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){const n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){const n=a.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=s}function Pe(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,r=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>r(Ae(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function Ae(e){return e&&void 0!==e.video?Object.assign({},e,{video:x(e.video)}):e}function Ne(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){const t=[];for(let r=0;r<e.iceServers.length;r++){let n=e.iceServers[r];!n.hasOwnProperty("urls")&&n.hasOwnProperty("url")?(j("RTCIceServer.url","RTCIceServer.urls"),n=JSON.parse(JSON.stringify(n)),n.urls=n.url,delete n.url,t.push(n)):t.push(e.iceServers[r])}e.iceServers=t}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function we(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function De(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find((e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const r=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveVideo||r||this.addTransceiver("video")}return t.apply(this,arguments)}}function ke(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var Ue=Object.freeze({__proto__:null,shimLocalStreamsAPI:ye,shimRemoteStreamsAPI:Ce,shimCallbacksAPI:Le,shimGetUserMedia:Pe,shimConstraints:Ae,shimRTCIceServerUrls:Ne,shimTrackEventTransceiver:we,shimCreateOfferLegacy:De,shimAudioContext:ke});function Me(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const r=new t(e),n=re.parseCandidate(e.candidate),i=Object.assign(r,n);return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,D(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function je(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;const t=re.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=re.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const r=parseInt(t[1],10);return r!=r?-1:r}(arguments[0]),r=function(e){let r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r}(e),n=function(e,r){let n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);const i=re.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n}(arguments[0],e);let i;i=0===r&&0===n?Number.POSITIVE_INFINITY:0===r||0===n?Math.max(r,n):Math.min(r,n);const o={};Object.defineProperty(o,"maxMessageSize",{get:()=>i}),this._sctp=o}return r.apply(this,arguments)}}function Be(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const r=e.send;e.send=function(){const n=arguments[0],i=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}const r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=r.apply(this,arguments);return t(e,this),e},D(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function xe(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((e=>{const r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}}))}function Ve(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const r=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==e.trim())).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:r}):t.sdp=r}return r.apply(this,arguments)}}function Fe(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var Je=Object.freeze({__proto__:null,shimRTCIceCandidate:Me,shimMaxMessageSize:je,shimSendThrowTypeError:Be,shimConnectionState:xe,removeExtmapAllowMixed:Ve,shimAddIceCandidateNullOrEmpty:Fe});const Ge=function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const r=M,n=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;const{navigator:r}=e;if(r.mozGetUserMedia)t.browser="firefox",t.version=w(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=w(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(r.mediaDevices&&r.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=w(r.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=w(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),i={browserDetails:n,commonShim:Je,extractVersion:w,disableLog:k,disableWarnings:U};switch(n.browser){case"chrome":if(!$||!Z||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),i;if(null===n.version)return r("Chrome shim can not determine version, not shimming."),i;r("adapter.js shimming chrome."),i.browserShim=$,Fe(e,n),G(e,n),H(e),Z(e,n),K(e),Q(e,n),W(e),Y(e),z(e),X(e,n),Me(e),xe(e),je(e,n),Be(e),Ve(e,n);break;case"firefox":if(!Te||!be||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),i;r("adapter.js shimming firefox."),i.browserShim=Te,Fe(e,n),pe(e,n),be(e,n),he(e),ve(e),ge(e),me(e),Re(e),Oe(e),Ee(e),Ie(e),Se(e),Me(e),xe(e),je(e,n),Be(e);break;case"edge":if(!fe||!_e||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),i;r("adapter.js shimming edge."),i.browserShim=fe,ue(e),le(e),_e(e,n),de(e),je(e,n),Be(e);break;case"safari":if(!Ue||!t.shimSafari)return r("Safari shim is not included in this adapter release."),i;r("adapter.js shimming safari."),i.browserShim=Ue,Fe(e,n),Ne(e),De(e),Le(e),ye(e),Ce(e),we(e),Pe(e),ke(e),Me(e),je(e,n),Be(e),Ve(e,n);break;default:r("Unsupported browser!")}return i}({window:"undefined"==typeof window?void 0:window});var He,Ke,We,Ye;!function(e){e.FPS_10="FPS_10",e.FPS_15="FPS_15",e.FPS_24="FPS_24",e.FPS_30="FPS_30"}(He||(He={})),function(e){e.W176_H132="W176_H132",e.W176_H144="W176_H144",e.W180_H180="W180_H180",e.W240_H180="W240_H180",e.W240_H240="W240_H240",e.W256_H144="W256_H144",e.W320_H180="W320_H180",e.W320_H240="W320_H240",e.W360_H360="W360_H360",e.W480_H360="W480_H360",e.W480_H480="W480_H480",e.W640_H360="W640_H360",e.W640_H480="W640_H480",e.W720_H480="W720_H480",e.W848_H480="W848_H480",e.W960_H720="W960_H720",e.W1280_H720="W1280_H720",e.W1920_H1080="W1920_H1080",e.W144_H176="W144_H176",e.W144_H256="W144_H256",e.W180_H240="W180_H240",e.W180_H320="W180_H320",e.W240_H320="W240_H320",e.W360_H480="W360_H480",e.W360_H640="W360_H640",e.W480_H640="W480_H640",e.W480_H720="W480_H720",e.W480_H848="W480_H848",e.W720_H1280="W720_H1280",e.W720_H960="W720_H960",e.W1080_H1920="W1080_H1920"}(Ke||(Ke={})),function(e){e[e.AUDIO_ONLY=0]="AUDIO_ONLY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(We||(We={}));var ze,qe=((Ye={})[Ke.W176_H132]={width:176,height:132,maxBitrate:150,minBitrate:80},Ye[Ke.W176_H144]={width:176,height:144,maxBitrate:150,minBitrate:80},Ye[Ke.W180_H180]={width:180,height:180,maxBitrate:200,minBitrate:100},Ye[Ke.W240_H180]={width:240,height:180,maxBitrate:240,minBitrate:120},Ye[Ke.W240_H240]={width:240,height:240,maxBitrate:280,minBitrate:120},Ye[Ke.W256_H144]={width:256,height:144,maxBitrate:240,minBitrate:120},Ye[Ke.W320_H180]={width:320,height:180,maxBitrate:280,minBitrate:120},Ye[Ke.W320_H240]={width:320,height:240,maxBitrate:400,minBitrate:120},Ye[Ke.W360_H360]={width:360,height:360,maxBitrate:520,minBitrate:140},Ye[Ke.W480_H360]={width:480,height:360,maxBitrate:650,minBitrate:150},Ye[Ke.W480_H480]={width:480,height:480,maxBitrate:800,minBitrate:180},Ye[Ke.W640_H360]={width:640,height:360,maxBitrate:800,minBitrate:180},Ye[Ke.W640_H480]={width:640,height:480,maxBitrate:900,minBitrate:200},Ye[Ke.W720_H480]={width:720,height:480,maxBitrate:1e3,minBitrate:200},Ye[Ke.W848_H480]={width:848,height:480,maxBitrate:1860,minBitrate:200},Ye[Ke.W960_H720]={width:960,height:720,maxBitrate:2e3,minBitrate:250},Ye[Ke.W1280_H720]={width:1280,height:720,maxBitrate:2200,minBitrate:250},Ye[Ke.W1920_H1080]={width:1920,height:1080,maxBitrate:4e3,minBitrate:400},Ye[Ke.W144_H176]={width:144,height:176,maxBitrate:150,minBitrate:80},Ye[Ke.W144_H256]={width:144,height:256,maxBitrate:240,minBitrate:120},Ye[Ke.W180_H240]={width:180,height:240,maxBitrate:240,minBitrate:120},Ye[Ke.W180_H320]={width:180,height:320,maxBitrate:280,minBitrate:120},Ye[Ke.W240_H320]={width:240,height:320,maxBitrate:400,minBitrate:120},Ye[Ke.W360_H480]={width:360,height:480,maxBitrate:650,minBitrate:150},Ye[Ke.W360_H640]={width:360,height:640,maxBitrate:800,minBitrate:180},Ye[Ke.W480_H640]={width:480,height:640,maxBitrate:900,minBitrate:200},Ye[Ke.W480_H720]={width:480,height:720,maxBitrate:1e3,minBitrate:200},Ye[Ke.W480_H848]={width:480,height:848,maxBitrate:1860,minBitrate:930},Ye[Ke.W720_H1280]={width:720,height:1280,maxBitrate:2200,minBitrate:250},Ye[Ke.W720_H960]={width:720,height:960,maxBitrate:2760,minBitrate:910},Ye[Ke.W1080_H1920]={width:1080,height:1920,maxBitrate:4e3,minBitrate:400},Ye),Qe=function(e){var t={192:180,368:360,1088:1080};return t[e]?t[e]:e},Ze=function(e,t){e=Qe(e),t=Qe(t);var r=qe["W".concat(e,"_H").concat(t)];if(r)return r;var n=e*t;return Object.keys(qe).map((function(e){return qe[e]})).sort((function(e,t){return e.height*e.width-t.width*t.height})).filter((function(e){return e.height*e.width>=n}))[0]||qe.W1920_H1080},Xe={10:1,15:1,24:1.5,30:1.5},$e=function(e){var t=Number.MAX_VALUE,r=1;for(var n in Xe){var i=Math.abs(e-parseInt(n));i<t&&(t=i,r=Xe[n])}return r},et={getCameras:function(){return T(void 0,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,navigator.mediaDevices.enumerateDevices()];case 1:return[2,e.sent().filter((function(e){return"videoinput"===e.kind}))]}}))}))},getMicrophones:function(){return T(void 0,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,navigator.mediaDevices.enumerateDevices()];case 1:return[2,e.sent().filter((function(e){return"audioinput"===e.kind}))]}}))}))},getSpeakers:function(){return T(void 0,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,navigator.mediaDevices.enumerateDevices()];case 1:return[2,e.sent().filter((function(e){return"audiooutput"===e.kind}))]}}))}))}};!function(e){e.AUDIO="audio",e.VIDEO="video"}(ze||(ze={}));var tt,rt,nt,it=function(t){function r(e,r,n,i,o,a){var s=t.call(this)||this;return Object.defineProperty(s,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(s,"_tag",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"_userId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(s,"_kind",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(s,"_isLocalTrack",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(s,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(s,"_localMuted",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(s,"_remoteMuted",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(s,"_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"_streamId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"_msTrack",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"_msStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"DataTrackId",{enumerable:!0,configurable:!0,writable:!0,value:"data-track-id"}),Object.defineProperty(s,"_element",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),s._streamId=[s._userId||s._roomId,s._tag].join("_"),s._id=[s._streamId,s.isAudioTrack()?0:1].join("_"),s}return R(r,t),Object.defineProperty(r.prototype,"getStreamId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._streamId}}),Object.defineProperty(r.prototype,"getTrackId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._id}}),Object.defineProperty(r.prototype,"getUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._userId}}),Object.defineProperty(r.prototype,"__innerGetMediaStreamTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._msTrack}}),Object.defineProperty(r.prototype,"streamTrack",{get:function(){return this._msTrack},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"getTag",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._tag}}),Object.defineProperty(r.prototype,"isLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isLocalTrack}}),Object.defineProperty(r.prototype,"isVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"video"===this._kind}}),Object.defineProperty(r.prototype,"isAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"audio"===this._kind}}),Object.defineProperty(r.prototype,"isReady",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return"live"===(null===(e=this._msTrack)||void 0===e?void 0:e.readyState)}}),Object.defineProperty(r.prototype,"__innerSetMediaStreamTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._msTrack=e,this._setLocalMuted(this._localMuted);var t=this._msStream=this._msStream||new MediaStream,r=t.getTracks()[0];r&&t.removeTrack(r),this._isLocalTrack||this._logger.warn(E.L_INNER_SET_TRACK_O,"trackId: ".concat(this._id,", track: ").concat(e?e.id:"undefined")),e?t.addTrack(e):this._element&&this._element.getAttribute(this.DataTrackId)===this.getTrackId()&&(this._element.pause(),this._element.srcObject=null)}}),Object.defineProperty(r.prototype,"_setLocalMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){return y(this,(function(t){return this._msTrack&&(this._msTrack.enabled=!e),this._localMuted=e,[2,O.SUCCESS]}))}))}}),Object.defineProperty(r.prototype,"mute",{enumerable:!1,configurable:!0,writable:!0,value:function(){return T(this,void 0,void 0,(function(){return y(this,(function(e){return[2,this._setLocalMuted(!0)]}))}))}}),Object.defineProperty(r.prototype,"unmute",{enumerable:!1,configurable:!0,writable:!0,value:function(){return T(this,void 0,void 0,(function(){return y(this,(function(e){return[2,this._setLocalMuted(!1)]}))}))}}),Object.defineProperty(r.prototype,"isLocalMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._localMuted}}),Object.defineProperty(r.prototype,"isMCUTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Boolean(this._roomId)}}),Object.defineProperty(r.prototype,"isOwnerMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._remoteMuted}}),Object.defineProperty(r.prototype,"_validateVolume",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(null==t?void 0:t.volume){if(!e(null==t?void 0:t.volume))return this._logger.error(E.L_TRACK_PLAY_E,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> options.volume not a number"})),{code:O.PARAMS_ERROR};(null==t?void 0:t.volume)<0&&(t.volume=0,this._logger.warn(E.L_TRACK_PLAY_E,JSON.stringify({status:I.FAILED,msg:"params error -> options.volume < 0",tips:"the valid range of options.volume is 0-100, the value of volume has been set 0"}))),(null==t?void 0:t.volume)>100&&(t.volume=100,this._logger.warn(E.L_TRACK_PLAY_E,JSON.stringify({status:I.FAILED,msg:"params error -> options.volume > 100",tips:"the valid range of options.volume is 0-100, the value of volume has been set 100"})))}}}),Object.defineProperty(r.prototype,"_validatePlayOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n;return y(this,(function(i){switch(i.label){case 0:return this._msTrack?("ended"===this._msTrack.readyState&&this._logger.warn(E.L_TRACK_PLAY_E,"track readyState is ended -> id: ".concat(this._id)),(r=this._validateVolume(t))?[2,r]:(null==t?void 0:t.audioDeviceId)?[4,et.getSpeakers()]:[3,2]):(this._logger.error(E.L_TRACK_PLAY_E,JSON.stringify({status:I.FAILED,code:O.TRACK_NOT_READY,kind:this._kind,msg:"the track is not ready to play -> id: ".concat(this._id)})),[2,{code:O.TRACK_NOT_READY}]);case 1:if(n=i.sent().map((function(e){return e.deviceId})),!n.includes(t.audioDeviceId))return this._logger.error(E.L_TRACK_PLAY_E,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> options.audioDeviceId"})),[2,{code:O.PARAMS_ERROR}];i.label=2;case 2:return!this.isVideoTrack()||e&&(e instanceof HTMLVideoElement||this._validateVideoNodeName(e))?[2]:(this._logger.error(E.L_TRACK_PLAY_E,JSON.stringify({status:I.FAILED,code:O.VIDEO_TRACK_MISS_MEDIA_ELEMENT,kind:this._kind,msg:"params element is not a HTMLVideoElement"})),[2,{code:O.VIDEO_TRACK_MISS_MEDIA_ELEMENT}])}}))}))}}),Object.defineProperty(r.prototype,"_setPlayAttrs",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return T(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return e&&(this._element.playsInline=!0,this._element.x5PlaysInline=!0,this._element.webkitPlaysInline=!0),!(null==t?void 0:t.audioDeviceId)||e?[3,2]:[4,this._element.setSinkId(t.audioDeviceId)];case 1:n.sent(),n.label=2;case 2:return e||!(null==t?void 0:t.volume)&&0!==(null==t?void 0:t.volume)||(this._element.volume=t.volume/100),null===(r=this._element)||void 0===r||r.setAttribute(this.DataTrackId,this.getTrackId()),[2]}}))}))}}),Object.defineProperty(r.prototype,"play",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n,i=this;return y(this,(function(o){switch(o.label){case 0:return this._logger.info(E.L_TRACK_PLAY_O,JSON.stringify({elementId:null==e?void 0:e.id,trackId:this._id,kind:this._kind,options:t?{volume:null==t?void 0:t.volume,audioDeviceId:t.audioDeviceId}:void 0})),[4,this._validatePlayOptions(e,t)];case 1:return(r=o.sent())?[2,r]:(n=this.isVideoTrack(),this._element=n?e:this._element||new Audio,this._localMuted&&this._setLocalMuted(!1),this._element.srcObject&&this._element.srcObject===this._msStream||this._element.pause(),this._element.onloadstart=function(e){var t;i._logger.info(E.L_TRACK_LOAD_START_O,JSON.stringify({status:I.INFO,kind:i._kind,msg:"HTMLMediaElement onloadstart -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(i._id)}))},this._element.ondurationchange=function(e){var t;i._logger.info(E.L_TRACK_DURATION_CHANGE_O,JSON.stringify({status:I.INFO,kind:i._kind,msg:"HTMLMediaElement ondurationchange -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(i._id)}))},this._element.onloadedmetadata=function(e){var t;i._logger.info(E.L_TRACK_LOADED_META_DATA_O,JSON.stringify({status:I.INFO,kind:i._kind,msg:"HTMLMediaElement onloadedmetadata -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(i._id)}))},this._element.onloadeddata=function(e){var t;i._logger.info(E.L_TRACK_LOADED_DATA_O,JSON.stringify({status:I.INFO,kind:i._kind,msg:"HTMLMediaElement onloadeddata -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(i._id)}))},this._element.onabort=function(e){var t;i._logger.info(E.L_TRACK_ABORT_O,JSON.stringify({status:I.INFO,kind:i._kind,msg:"HTMLMediaElement onabort -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(i._id)}))},this._element.oncanplay=function(e){return T(i,void 0,void 0,(function(){var r,i,o;return y(this,(function(a){switch(a.label){case 0:this._logger.info(E.L_TRACK_CANPLAY_O,JSON.stringify({status:I.INFO,kind:this._kind,msg:"HTMLMediaElement oncanplay -> id: ".concat(null===(i=e.target)||void 0===i?void 0:i.id,", trackId: ").concat(this._id)})),a.label=1;case 1:return a.trys.push([1,5,,6]),!(null==t?void 0:t.audioDeviceId)||n?[3,3]:[4,this._element.setSinkId(t.audioDeviceId)];case 2:a.sent(),a.label=3;case 3:return[4,null===(o=this._element)||void 0===o?void 0:o.play()];case 4:return a.sent(),[3,6];case 5:return"No permission to use requested device"===(r=a.sent()).message?(this._logger.error(E.L_TRACK_PLAY_E,JSON.stringify({status:I.FAILED,kind:this._kind,code:O.NO_PERMISSION_TO_USE_REQUESTED_DEVICE,msg:"setSinkId failed, error msg: ".concat(r.message)})),[2]):(this._logger.error(E.L_TRACK_PLAY_E,JSON.stringify({status:I.FAILED,code:O.TRACK_PLAY_ERROR,kind:this._kind,msg:"play error, error msg: ".concat(r.message)})),[3,6]);case 6:return[2]}}))}))},this._element.onvolumechange=function(e){var t,r,n=Math.floor(100*(null===(t=e.target)||void 0===t?void 0:t.volume));i._logger.info(E.L_TRACK_VOLUME_CHANGE_O,JSON.stringify({status:I.INFO,msg:"HTMLMediaElement onvolumechange -> id: ".concat(null===(r=e.target)||void 0===r?void 0:r.id,", volume: ").concat(n,", trackId: ").concat(i._id)}))},this._element.srcObject=this._msStream,this._element.autoplay=!0,[4,this._setPlayAttrs(n,t)]);case 2:return o.sent(),[2,{code:O.SUCCESS}]}}))}))}}),Object.defineProperty(r.prototype,"__innerDestroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.__innerSetMediaStreamTrack(void 0)}}),Object.defineProperty(r.prototype,"__releaseMediaElement",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._element&&this._element.getAttribute(this.DataTrackId)===this.getTrackId()&&(this._element.remove(),this._element.srcObject=null)}}),Object.defineProperty(r.prototype,"_validateVideoNodeName",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e&&e.nodeName&&"VIDEO"===e.nodeName.toUpperCase()}}),r}(t);!function(e){e.Speech="Speech",e.Music="Music",e.MusicHigh="MusicHigh"}(nt||(nt={}));var ot,at=((tt={})[nt.Music]={max:64,min:64},tt[nt.MusicHigh]={max:128,min:128},tt[nt.Speech]={max:32,min:32},tt);!function(e){e.LEVEL0="LEVEL0",e.LEVEL1="LEVEL1",e.LEVEL2="LEVEL2",e.LEVEL3="LEVEL3",e.LEVEL4="LEVEL4",e.LEVEL5="LEVEL5"}(ot||(ot={}));var st=((rt={})[ot.LEVEL0]={max:150,min:80},rt[ot.LEVEL1]={max:280,min:120},rt[ot.LEVEL2]={max:650,min:150},rt[ot.LEVEL3]={max:1e3,min:200},rt[ot.LEVEL4]={max:2200,min:250},rt[ot.LEVEL5]={max:4e3,min:400},rt),ct=function(){function e(){}return Object.defineProperty(e,"apply3ANoiseWorklet",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return T(this,void 0,void 0,(function(){var r,n,i,o,a,s;return y(this,(function(c){switch(c.label){case 0:r=new AudioContext({sampleRate:44100}),c.label=1;case 1:return c.trys.push([1,5,,6]),[4,r.audioWorklet.addModule(e.SCRIPT_URL)];case 2:return c.sent(),[4,fetch(e.WASM_URL,{cache:"force-cache",credentials:"same-origin"})];case 3:return[4,c.sent().arrayBuffer()];case 4:return n=c.sent(),[3,6];case 5:return c.sent(),[2,{code:O.LOAD_3A_MODULE_FAILED}];case 6:return i=r.createMediaStreamSource(new MediaStream([t])),o=new AudioWorkletNode(r,"process-worklet",{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{binary:n}}),a=r.createMediaStreamDestination(),i.connect(o).connect(a),s=a.stream.getAudioTracks()[0],e._maps.set(t.id,r),[2,{code:O.SUCCESS,track:s}]}}))}))}}),Object.defineProperty(e,"release3ANoiseWorklet",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=e._maps.get(t.id);r&&(r.close(),e._maps.delete(t.id))}}),Object.defineProperty(e,"WASM_URL",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(e,"SCRIPT_URL",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(e,"_maps",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),e}(),ut=function(t){function r(e,r,n,i,o){var a=t.call(this,e,r,n,i,!0)||this;return Object.defineProperty(a,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(a,"_isPublished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(a,"_bitrateInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),a.__innerSetMediaStreamTrack(o),o.onended=function(){o.onended=null,a._onTrackEnded()},a}return R(r,t),Object.defineProperty(r.prototype,"_onTrackEnded",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.emit(r.EVENT_LOCAL_TRACK_END,this),this.removeAll(r.EVENT_LOCAL_TRACK_END)}}),Object.defineProperty(r.prototype,"_setLocalMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=this;return new Promise((function(i){var o=n._localMuted!==e;t.prototype._setLocalMuted.call(n,e),n._remoteMuted=n._localMuted,o&&n._isPublished?n.emit(r.__INNER_EVENT_MUTED_CHANGE__,n,i):i(O.SUCCESS),n._logger.info(E.L_LOCAL_TRACK_SET_LOCAL_MUTED_O,JSON.stringify({enable:e,trackId:n._id}))}))}}),Object.defineProperty(r.prototype,"__innerSetPublished",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._isPublished=e}}),Object.defineProperty(r.prototype,"isPublished",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isPublished}}),Object.defineProperty(r.prototype,"destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;this._isDestroyed||(this._logger.info(E.L_LOCAL_TRACK_DESTROY_O,this._id),this._isDestroyed=!0,null===(e=this._msTrack)||void 0===e||e.stop(),t.prototype.__innerDestroy.call(this),this.isAudioTrack()&&t.prototype.__releaseMediaElement.call(this),this._isPublished&&this.emit(r.__INNER_EVENT_DESTROY__,this))}}),Object.defineProperty(r.prototype,"isDestroyed",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isDestroyed}}),Object.defineProperty(r.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n){void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),!e(t)||!e(r)||!e(n)||t<=0||r<=0||t<r?this._logger.error(E.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:I.FAILED,msg:"params error -> max: ".concat(t,",min: ").concat(r,", start: ").concat(n),trackId:this._id})):(this._logger.info(E.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:I.SUCCESSED,max:t,min:r,start:n,trackId:this._id})),this._bitrateInfo={max:t,min:r,start:n})}}),Object.defineProperty(r.prototype,"getBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t,r,n,i,o,a,s,c,u=0,l=0,_=0;return(null===(r=this._msTrack)||void 0===r?void 0:r.kind)===ze.VIDEO?(u=(e=Ct(this._msTrack)).min,l=e.max):(null===(n=this._msTrack)||void 0===n?void 0:n.kind)===ze.AUDIO&&(u=(t={min:32,max:32}).min,l=t.max),(null===(i=this._bitrateInfo)||void 0===i?void 0:i.max)&&(_=.7*(null===(o=this._bitrateInfo)||void 0===o?void 0:o.max)),{min:(null===(a=this._bitrateInfo)||void 0===a?void 0:a.min)||u,max:(null===(s=this._bitrateInfo)||void 0===s?void 0:s.max)||l,start:(null===(c=this._bitrateInfo)||void 0===c?void 0:c.start)||_}}}),Object.defineProperty(r,"EVENT_LOCAL_TRACK_END",{enumerable:!0,configurable:!0,writable:!0,value:"local-track-end"}),Object.defineProperty(r,"__INNER_EVENT_MUTED_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-muted-change"}),Object.defineProperty(r,"__INNER_EVENT_DESTROY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-destroy"}),r}(it),lt=function(e){function t(t,r,n,i){return e.call(this,t,r,n,"audio",i)||this}return R(t,e),Object.defineProperty(t.prototype,"setRecommendBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(r("audioBitrate",e,(function(e){return e in nt}))){var t=at[e];this.setBitrate(t.max,t.min,t.start||.7*t.max)}else this._logger.warn(E.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:I.FAILED,msg:"params error -> params type is RCAudioBitrate"}))}}),Object.defineProperty(t.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=L(r,2),o=i[0],a=void 0===o?1:o,s=i[1],c=void 0===s?.7*t||1:s;e.prototype.setBitrate.call(this,t,a,c)}}),t}(ut),_t=function(e){function t(t,r,n,i,o){void 0===o&&(o=!1);var a=e.call(this,t,r,n,"video",i)||this;return Object.defineProperty(a,"_isTiny",{enumerable:!0,configurable:!0,writable:!0,value:o}),a}return R(t,e),Object.defineProperty(t.prototype,"__isTiny",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isTiny}}),Object.defineProperty(t.prototype,"getStreamId",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=e.prototype.getStreamId.call(this);return this._isTiny?"".concat(t,"_tiny"):t}}),Object.defineProperty(t.prototype,"getTrackId",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=e.prototype.getTrackId.call(this);return this._isTiny?"".concat(t,"_tiny"):t}}),Object.defineProperty(t.prototype,"setRecommendBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(r("videoBitrate",e,(function(e){return e in ot}))){var t=st[e];this.setBitrate(t.max,t.min,t.start||.7*t.max)}else this._logger.warn(E.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:I.FAILED,msg:"params error -> params type is RCVideoBitrate"}))}}),Object.defineProperty(t.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){for(var r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=L(r,2),o=i[0],a=void 0===o?1:o,s=i[1],c=void 0===s?.7*t||1:s;e.prototype.setBitrate.call(this,t,a,c)}}),t}(ut),dt=function(e){function t(r,n,i,o,a,s){var c=e.call(this,r,n,i,o,a)||this;return Object.defineProperty(c,"_resource",{enumerable:!0,configurable:!0,writable:!0,value:s}),t._innerSetMapping(c.getTrackId(),s),c}return R(t,e),Object.defineProperty(t,"_innerSetMapping",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this._mapping.get(t)||[];r.push(e),this._mapping.set(t,r)}}),Object.defineProperty(t,"_innerRemoveMapping",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,n,i=null===(r=this._mapping.get(t))||void 0===r?void 0:r.filter((function(t){return t!==e}));i&&i.length>0?this._mapping.set(t,i):(this._mapping.delete(t),t.pause(),t.src="",null===(n=t.parentNode)||void 0===n||n.removeChild(t))}}),Object.defineProperty(t.prototype,"destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isAudioTrack()&&this.mute(),t._innerRemoveMapping(this.getTrackId(),this._resource),e.prototype.destroy.call(this)}}),Object.defineProperty(t,"_mapping",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),t}(ut),ft=function(e){function t(t,r,n,i,o){return e.call(this,t,r,n,"video",i,o)||this}return R(t,e),t}(dt),pt=function(e){function t(t,r,n,i,o){return e.call(this,t,r,n,"audio",i,o)||this}return R(t,e),Object.defineProperty(t.prototype,"_setLocalMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return T(this,void 0,void 0,(function(){return y(this,(function(r){return this._resource&&(this._resource.muted=t),[2,e.prototype._setLocalMuted.call(this,t)]}))}))}}),Object.defineProperty(t.prototype,"play",{enumerable:!1,configurable:!0,writable:!0,value:function(){return T(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,this._setLocalMuted(!1)];case 1:return[2,{code:e.sent()}]}}))}))}}),t}(dt),ht=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return Object.defineProperty(t,"_originTrack",{enumerable:!0,configurable:!0,writable:!0,value:null}),t}return R(t,e),Object.defineProperty(t.prototype,"apply3ANoiseWorklet",{enumerable:!1,configurable:!0,writable:!0,value:function(){return T(this,void 0,void 0,(function(){var e,t,r;return y(this,(function(n){switch(n.label){case 0:return this._logger.info(E.A_APPLY_3A_NOISE_WORKLET_T),this._originTrack?(this._logger.warn(E.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:I.FAILED,msg:"3A noise module already applied"})),[2,{code:O.SUCCESS}]):!this._msTrack||this.isDestroyed()?(this._logger.warn(E.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:I.FAILED,msg:"track not ready"})),[2,{code:O.TRACK_NOT_READY}]):this.isPublished()?(this._logger.warn(E.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:I.FAILED,msg:"track already published"})),[2,{code:O.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH}]):[4,ct.apply3ANoiseWorklet(this._msTrack)];case 1:return e=n.sent(),t=e.code,r=e.track,t===O.SUCCESS&&r?(this._originTrack=this._msTrack,this._msTrack=r,this._logger.info(E.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:I.SUCCESSED})),[2,{code:O.SUCCESS}]):(this._logger.warn(E.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:I.FAILED,msg:"apply 3A noise module failed: ".concat(t),SCRIPT_URL:ct.SCRIPT_URL,WASM_URL:ct.WASM_URL})),[2,{code:t}])}}))}))}}),Object.defineProperty(t.prototype,"__innerSetMediaStreamTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(t){!t&&this._originTrack&&(ct.release3ANoiseWorklet(this._originTrack),this._originTrack.stop(),this._originTrack=null),e.prototype.__innerSetMediaStreamTrack.call(this,t)}}),t}(lt),bt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return R(t,e),t}(_t),gt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return R(t,e),Object.defineProperty(t.prototype,"_onTrackEnded",{enumerable:!1,configurable:!0,writable:!0,value:function(){e.prototype._onTrackEnded.call(this),this.isPublished()&&this.emit(ut.__INNER_EVENT_DESTROY__,this)}}),t}(_t),mt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return R(t,e),Object.defineProperty(t.prototype,"_onTrackEnded",{enumerable:!1,configurable:!0,writable:!0,value:function(){e.prototype._onTrackEnded.call(this),this.isPublished()&&this.emit(ut.__INNER_EVENT_DESTROY__,this)}}),t}(lt),vt=function(e){function t(t,r,n,i,o){var a=e.call(this,t,r,n,i,!1,o)||this;return Object.defineProperty(a,"_isSubscribed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),a}return R(t,e),Object.defineProperty(t.prototype,"__innerSetRemoteMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._remoteMuted=e}}),Object.defineProperty(t.prototype,"__innerSetSubscribed",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._isSubscribed=e}}),Object.defineProperty(t.prototype,"isSubscribed",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isSubscribed}}),t}(it),Rt=function(e){function t(t,r,n,i){return e.call(this,t,r,n,"audio",i)||this}return R(t,e),Object.defineProperty(t.prototype,"_setLocalMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=Bt.browser,n=Bt.version;return this._element&&n&&/chrome/i.test(r)&&n>=130&&(this._element.muted=t),e.prototype._setLocalMuted.call(this,t)}}),Object.defineProperty(t.prototype,"getVolume",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return 100*((null===(e=this._element)||void 0===e?void 0:e.volume)||0)}}),t}(vt),Ot=function(e){function t(t,r,n,i){var o=e.call(this,t,r,n,"video",i)||this;return Object.defineProperty(o,"_isSubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),o}return R(t,e),Object.defineProperty(t.prototype,"__innerSetIsTinyTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._isSubTiny=e}}),Object.defineProperty(t.prototype,"isSubTiny",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isSubTiny}}),t}(vt),Et=function(e,t){return{name:e,content:JSON.stringify({uris:t,ignore:!0})}},It=function(e){return JSON.stringify(e)},St=function(e){return/^[a-zA-Z\d-=]+$/g.test(e)},Tt=function(t){if(void 0===t)return 0;if(e(t))return t;var r=t;return r.exact||r.ideal||r.max||0},yt=function(e){var t=e.getSettings(),r=e.getConstraints();return{width:Tt(r.width)||t.width||0,height:Tt(r.height)||t.height||0,frameRate:t.frameRate||Tt(r.frameRate)}},Ct=function(e){var t=yt(e),r=t.width,n=t.height,i=t.frameRate,o=Ze(r||1920,n||1080),a=$e(i);return{min:o.minBitrate*a,max:o.maxBitrate*a}},Lt=function(e){return[e.msid,e.mediaType].join("_")},Pt=function(e){var t=e.split("_");return{mediaType:parseInt(t.pop()),tag:t.pop(),userId:t.join("_")}},At=function(e,t){return[e,t].join("_")},Nt=function(e){return e.map((function(e){return S({},e)}))},wt=function(e,t,r){void 0===r&&(r=!1),e=e.slice();var n=[],i=[],o=[];return t.forEach((function(t){var i=Lt(t),a=e.findIndex((function(e){return Lt(e)===i}));if(r&&(a=e.findIndex((function(e){return e.uri===t.uri}))),-1!==a){var s=e[a];s.uri!==t.uri?n.push(t):s.state!==t.state&&o.push(t),e.splice(a,1)}else n.push(t)})),i.push.apply(i,P([],L(e),!1)),{publishedList:n,unpublishedList:i,modifiedList:o}},Dt=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,n=+e,i=[];do{var o=n%r;n=(n-o)/r,i.unshift(t[o])}while(n);return i.join("")}(e=parseInt(e,16))).length>22&&(e=e.slice(0,22)),e},kt=function(e){if(qe[e]){var t=qe[e];return{width:t.width,height:t.height}}var r=L(e.split("_").map((function(e){return parseInt(e.replace(/[^\d]/g,""))})),2);return{width:r[0],height:r[1]}},Ut=function(e){return!!Ke[e]},Mt=function(e){return!!He[e]},jt=function(e){return parseInt(e.replace("FPS_",""))},Bt=function(){var e=Ge.browserDetails;return{browser:e.browser,version:e.version,supportsUnifiedPlan:!1!==e.supportsUnifiedPlan}}();function xt(){return"captureStream"in HTMLMediaElement.prototype||"mozCaptureStream"in HTMLMediaElement.prototype}function Vt(){return"mediaDevices"in navigator&&"getDisplayMedia"in navigator.mediaDevices}var Ft,Jt,Gt=function(e){return"[object Null]"===Object.prototype.toString.call(e)},Ht=function(e){return 1===e.type},Kt=function(e,t,r,n){var i={},o=Object.keys(e.users);return o.length&&o.forEach((function(o){var a=[],s=e.users[o];if(s.extra){var c=JSON.parse(s.extra).roomId;if(t!==c)return}if(s.uris)try{a.push.apply(a,P([],L(JSON.parse(s.uris)),!1))}catch(e){r.warn(E.L_PARSE_ROOMDATA_URIS_R,"invalid user data -> userId: ".concat(o,", userData: ").concat(s),n)}i[o]=a})),i},Wt=function(e){return e instanceof it?e.getTrackId():e.track.getTrackId()},Yt=function(e){if(!n(e)||void 0===e.low||void 0===e.high)return e;var t=e.low;return t<0&&(t+=4294967296),t=t.toString(16),parseInt(e.high.toString(16)+"00000000".replace(new RegExp("0{".concat(t.length,"}$")),t),16)};!function(e){e.PUBLISH="RCRTC:PublishResource",e.UNPUBLISH="RCRTC:UnpublishResource",e.MODIFY="RCRTC:ModifyResource",e.TOTAL_CONTENT_RESOURCE="RCRTC:TotalContentResources",e.STATE="RCRTC:state",e.ROOM_NOTIFY="RCRTC:RoomNtf",e.USER_NOTIFY="RCRTC:UserNtf",e.KICK="RCRTC:kick",e.PK_INVITE="RCRTC:invite",e.PK_INVITE_TIMEOUT="RCRTC:inviteTimeout",e.PK_CANCEL_INVITE="RCRTC:cancelInvite",e.PK_INVITE_ANSWER="RCRTC:answerInvite",e.PK_END="RCRTC:endInvite",e.OTHER_ROOM_OFFLINE="RCRTC:otherRoomOffline",e.ROOM_TASK_FINISH="RCRTC:roomTaskFinish"}(Ft||(Ft={})),function(e){e.SUCCESS="Success",e.FAIL="Fail"}(Jt||(Jt={}));var zt=function(){function e(e,t,r,n){void 0===n&&(n=5e3),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_roomMode",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_gap",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_latestTimestamp",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFailed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onPingResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_started",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_timer",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._logger=this._context.logger}return Object.defineProperty(e.prototype,"start",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._started||(e<15e3&&(e=15e3),this._logger.info(E.L_PINGER_START_O,JSON.stringify({interval:this._gap,offlineKickTime:e})),this._started=!0,this._checkAlive(e))}}),Object.defineProperty(e.prototype,"_sendPing",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;return new Promise((function(t){e._context.rtcPing(e._roomId,e._roomMode).then(t),setTimeout(t,5e3,{code:i.TIMEOUT})}))}}),Object.defineProperty(e.prototype,"_checkAlive",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n,o,a,s,c=this;return y(this,(function(u){switch(u.label){case 0:return t=this._context.logger,r=t.createTraceId(),[4,this._sendPing()];case 1:return n=u.sent(),o=n.code,a=n.data,this._started?(s=Date.now(),o===i.SUCCESS?(this._latestTimestamp=s,this.onPingResult(Jt.SUCCESS,a.version),this._timer=setTimeout((function(){return c._checkAlive(e)}),this._gap),[2]):(t.error(E.L_PINGER_SEND_RTCPING_E,JSON.stringify({roomId:this._roomId,code:o}),r),this.onPingResult(Jt.FAIL),40003===o||s-this._latestTimestamp>e?(this.stop(),this.onFailed(40003===o),[2]):(this._timer=setTimeout((function(){return c._checkAlive(e)}),this._gap),[2]))):[2]}}))}))}}),Object.defineProperty(e.prototype,"stop",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._started&&(this._logger.info(E.L_PINGER_STOP_O),this._started=!1,this._timer&&(clearTimeout(this._timer),this._timer=null))}}),e}();function qt(e){let t=e.length;for(;--t>=0;)e[t]=0}const Qt=256,Zt=286,Xt=30,$t=15,er=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),tr=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),rr=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),nr=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ir=new Array(576);qt(ir);const or=new Array(60);qt(or);const ar=new Array(512);qt(ar);const sr=new Array(256);qt(sr);const cr=new Array(29);qt(cr);const ur=new Array(Xt);function lr(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}let _r,dr,fr;function pr(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}qt(ur);const hr=e=>e<256?ar[e]:ar[256+(e>>>7)],br=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},gr=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,br(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},mr=(e,t,r)=>{gr(e,r[2*t],r[2*t+1])},vr=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},Rr=(e,t,r)=>{const n=new Array(16);let i,o,a=0;for(i=1;i<=$t;i++)a=a+r[i-1]<<1,n[i]=a;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=vr(n[t]++,t))}},Or=e=>{let t;for(t=0;t<Zt;t++)e.dyn_ltree[2*t]=0;for(t=0;t<Xt;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},Er=e=>{e.bi_valid>8?br(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Ir=(e,t,r,n)=>{const i=2*t,o=2*r;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]},Sr=(e,t,r)=>{const n=e.heap[r];let i=r<<1;for(;i<=e.heap_len&&(i<e.heap_len&&Ir(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!Ir(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n},Tr=(e,t,r)=>{let n,i,o,a,s=0;if(0!==e.sym_next)do{n=255&e.pending_buf[e.sym_buf+s++],n+=(255&e.pending_buf[e.sym_buf+s++])<<8,i=e.pending_buf[e.sym_buf+s++],0===n?mr(e,i,t):(o=sr[i],mr(e,o+Qt+1,t),a=er[o],0!==a&&(i-=cr[o],gr(e,i,a)),n--,o=hr(n),mr(e,o,r),a=tr[o],0!==a&&(n-=ur[o],gr(e,n,a)))}while(s<e.sym_next);mr(e,256,t)},yr=(e,t)=>{const r=t.dyn_tree,n=t.stat_desc.static_tree,i=t.stat_desc.has_stree,o=t.stat_desc.elems;let a,s,c,u=-1;for(e.heap_len=0,e.heap_max=573,a=0;a<o;a++)0!==r[2*a]?(e.heap[++e.heap_len]=u=a,e.depth[a]=0):r[2*a+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=u<2?++u:0,r[2*c]=1,e.depth[c]=0,e.opt_len--,i&&(e.static_len-=n[2*c+1]);for(t.max_code=u,a=e.heap_len>>1;a>=1;a--)Sr(e,r,a);c=o;do{a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Sr(e,r,1),s=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=s,r[2*c]=r[2*a]+r[2*s],e.depth[c]=(e.depth[a]>=e.depth[s]?e.depth[a]:e.depth[s])+1,r[2*a+1]=r[2*s+1]=c,e.heap[1]=c++,Sr(e,r,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const r=t.dyn_tree,n=t.max_code,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length;let u,l,_,d,f,p,h=0;for(d=0;d<=$t;d++)e.bl_count[d]=0;for(r[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)l=e.heap[u],d=r[2*r[2*l+1]+1]+1,d>c&&(d=c,h++),r[2*l+1]=d,l>n||(e.bl_count[d]++,f=0,l>=s&&(f=a[l-s]),p=r[2*l],e.opt_len+=p*(d+f),o&&(e.static_len+=p*(i[2*l+1]+f)));if(0!==h){do{for(d=c-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[c]--,h-=2}while(h>0);for(d=c;0!==d;d--)for(l=e.bl_count[d];0!==l;)_=e.heap[--u],_>n||(r[2*_+1]!==d&&(e.opt_len+=(d-r[2*_+1])*r[2*_],r[2*_+1]=d),l--)}})(e,t),Rr(r,u,e.bl_count)},Cr=(e,t,r)=>{let n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++s<c&&i===a||(s<u?e.bl_tree[2*i]+=s:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))},Lr=(e,t,r)=>{let n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<c&&i===a)){if(s<u)do{mr(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(mr(e,i,e.bl_tree),s--),mr(e,16,e.bl_tree),gr(e,s-3,2)):s<=10?(mr(e,17,e.bl_tree),gr(e,s-3,3)):(mr(e,18,e.bl_tree),gr(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}};let Pr=!1;const Ar=(e,t,r,n)=>{gr(e,0+(n?1:0),3),Er(e),br(e,r),br(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r};var Nr=(e,t,r,n)=>{let i,o,a=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<Qt;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),yr(e,e.l_desc),yr(e,e.d_desc),a=(e=>{let t;for(Cr(e,e.dyn_ltree,e.l_desc.max_code),Cr(e,e.dyn_dtree,e.d_desc.max_code),yr(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*nr[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==t?Ar(e,t,r,n):4===e.strategy||o===i?(gr(e,2+(n?1:0),3),Tr(e,ir,or)):(gr(e,4+(n?1:0),3),((e,t,r,n)=>{let i;for(gr(e,t-257,5),gr(e,r-1,5),gr(e,n-4,4),i=0;i<n;i++)gr(e,e.bl_tree[2*nr[i]+1],3);Lr(e,e.dyn_ltree,t-1),Lr(e,e.dyn_dtree,r-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),Tr(e,e.dyn_ltree,e.dyn_dtree)),Or(e),n&&Er(e)},wr={_tr_init:e=>{Pr||((()=>{let e,t,r,n,i;const o=new Array(16);for(r=0,n=0;n<28;n++)for(cr[n]=r,e=0;e<1<<er[n];e++)sr[r++]=n;for(sr[r-1]=n,i=0,n=0;n<16;n++)for(ur[n]=i,e=0;e<1<<tr[n];e++)ar[i++]=n;for(i>>=7;n<Xt;n++)for(ur[n]=i<<7,e=0;e<1<<tr[n]-7;e++)ar[256+i++]=n;for(t=0;t<=$t;t++)o[t]=0;for(e=0;e<=143;)ir[2*e+1]=8,e++,o[8]++;for(;e<=255;)ir[2*e+1]=9,e++,o[9]++;for(;e<=279;)ir[2*e+1]=7,e++,o[7]++;for(;e<=287;)ir[2*e+1]=8,e++,o[8]++;for(Rr(ir,287,o),e=0;e<Xt;e++)or[2*e+1]=5,or[2*e]=vr(e,5);_r=new lr(ir,er,257,Zt,$t),dr=new lr(or,tr,0,Xt,$t),fr=new lr(new Array(0),rr,0,19,7)})(),Pr=!0),e.l_desc=new pr(e.dyn_ltree,_r),e.d_desc=new pr(e.dyn_dtree,dr),e.bl_desc=new pr(e.bl_tree,fr),e.bi_buf=0,e.bi_valid=0,Or(e)},_tr_stored_block:Ar,_tr_flush_block:Nr,_tr_tally:(e,t,r)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=r,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(sr[r]+Qt+1)]++,e.dyn_dtree[2*hr(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{gr(e,2,3),mr(e,256,ir),(e=>{16===e.bi_valid?(br(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Dr=(e,t,r,n)=>{let i=65535&e,o=e>>>16&65535,a=0;for(;0!==r;){a=r>2e3?2e3:r,r-=a;do{i=i+t[n++]|0,o=o+i|0}while(--a);i%=65521,o%=65521}return i|o<<16};const kr=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t})());var Ur=(e,t,r,n)=>{const i=kr,o=n+r;e^=-1;for(let r=n;r<o;r++)e=e>>>8^i[255&(e^t[r])];return~e},Mr={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},jr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Br,_tr_stored_block:xr,_tr_flush_block:Vr,_tr_tally:Fr,_tr_align:Jr}=wr,{Z_NO_FLUSH:Gr,Z_PARTIAL_FLUSH:Hr,Z_FULL_FLUSH:Kr,Z_FINISH:Wr,Z_BLOCK:Yr,Z_OK:zr,Z_STREAM_END:qr,Z_STREAM_ERROR:Qr,Z_DATA_ERROR:Zr,Z_BUF_ERROR:Xr,Z_DEFAULT_COMPRESSION:$r,Z_FILTERED:en,Z_HUFFMAN_ONLY:tn,Z_RLE:rn,Z_FIXED:nn,Z_DEFAULT_STRATEGY:on,Z_UNKNOWN:an,Z_DEFLATED:sn}=jr,cn=258,un=262,ln=42,_n=113,dn=666,fn=(e,t)=>(e.msg=Mr[t],t),pn=e=>2*e-(e>4?9:0),hn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},bn=e=>{let t,r,n,i=e.w_size;t=e.hash_size,n=t;do{r=e.head[--n],e.head[n]=r>=i?r-i:0}while(--t);t=i,n=t;do{r=e.prev[--n],e.prev[n]=r>=i?r-i:0}while(--t)};let gn=(e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask;const mn=e=>{const t=e.state;let r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))},vn=(e,t)=>{Vr(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,mn(e.strm)},Rn=(e,t)=>{e.pending_buf[e.pending++]=t},On=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},En=(e,t,r,n)=>{let i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),r),1===e.state.wrap?e.adler=Dr(e.adler,t,i,r):2===e.state.wrap&&(e.adler=Ur(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},In=(e,t)=>{let r,n,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match;const c=e.strstart>e.w_size-un?e.strstart-(e.w_size-un):0,u=e.window,l=e.w_mask,_=e.prev,d=e.strstart+cn;let f=u[o+a-1],p=u[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(r=t,u[r+a]===p&&u[r+a-1]===f&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<d);if(n=cn-(d-o),o=d-cn,n>a){if(e.match_start=t,a=n,n>=s)break;f=u[o+a-1],p=u[o+a]}}}while((t=_[t&l])>c&&0!=--i);return a<=e.lookahead?a:e.lookahead},Sn=e=>{const t=e.w_size;let r,n,i;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-un)&&(e.window.set(e.window.subarray(t,t+t-n),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),bn(e),n+=t),0===e.strm.avail_in)break;if(r=En(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=r,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=gn(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=gn(e,e.ins_h,e.window[i+3-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<un&&0!==e.strm.avail_in)},Tn=(e,t)=>{let r,n,i,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,a=0,s=e.strm.avail_in;do{if(r=65535,i=e.bi_valid+42>>3,e.strm.avail_out<i)break;if(i=e.strm.avail_out-i,n=e.strstart-e.block_start,r>n+e.strm.avail_in&&(r=n+e.strm.avail_in),r>i&&(r=i),r<o&&(0===r&&t!==Wr||t===Gr||r!==n+e.strm.avail_in))break;a=t===Wr&&r===n+e.strm.avail_in?1:0,xr(e,0,0,a),e.pending_buf[e.pending-4]=r,e.pending_buf[e.pending-3]=r>>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,mn(e.strm),n&&(n>r&&(n=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+n),e.strm.next_out),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n,e.block_start+=n,r-=n),r&&(En(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(0===a);return s-=e.strm.avail_in,s&&(s>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=s&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-s,e.strm.next_in),e.strstart),e.strstart+=s,e.insert+=s>e.w_size-e.insert?e.w_size-e.insert:s),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),a?4:t!==Gr&&t!==Wr&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(i=e.window_size-e.strstart,e.strm.avail_in>i&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,i+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),i>e.strm.avail_in&&(i=e.strm.avail_in),i&&(En(e.strm,e.window,e.strstart,i),e.strstart+=i,e.insert+=i>e.w_size-e.insert?e.w_size-e.insert:i),e.high_water<e.strstart&&(e.high_water=e.strstart),i=e.bi_valid+42>>3,i=e.pending_buf_size-i>65535?65535:e.pending_buf_size-i,o=i>e.w_size?e.w_size:i,n=e.strstart-e.block_start,(n>=o||(n||t===Wr)&&t!==Gr&&0===e.strm.avail_in&&n<=i)&&(r=n>i?i:n,a=t===Wr&&0===e.strm.avail_in&&r===n?1:0,xr(e,e.block_start,r,a),e.block_start+=r,mn(e.strm)),a?3:1)},yn=(e,t)=>{let r,n;for(;;){if(e.lookahead<un){if(Sn(e),e.lookahead<un&&t===Gr)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=gn(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-un&&(e.match_length=In(e,r)),e.match_length>=3)if(n=Fr(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=gn(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=gn(e,e.ins_h,e.window[e.strstart+1]);else n=Fr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(vn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Wr?(vn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(vn(e,!1),0===e.strm.avail_out)?1:2},Cn=(e,t)=>{let r,n,i;for(;;){if(e.lookahead<un){if(Sn(e),e.lookahead<un&&t===Gr)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=gn(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-un&&(e.match_length=In(e,r),e.match_length<=5&&(e.strategy===en||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=Fr(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=gn(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(vn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(n=Fr(e,0,e.window[e.strstart-1]),n&&vn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=Fr(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Wr?(vn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(vn(e,!1),0===e.strm.avail_out)?1:2};function Ln(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}const Pn=[new Ln(0,0,0,0,Tn),new Ln(4,4,8,4,yn),new Ln(4,5,16,8,yn),new Ln(4,6,32,32,yn),new Ln(4,4,16,16,Cn),new Ln(8,16,32,32,Cn),new Ln(8,16,128,128,Cn),new Ln(8,32,128,256,Cn),new Ln(32,128,258,1024,Cn),new Ln(32,258,258,4096,Cn)];function An(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=sn,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),hn(this.dyn_ltree),hn(this.dyn_dtree),hn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),hn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),hn(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Nn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==ln&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==_n&&t.status!==dn?1:0},wn=e=>{if(Nn(e))return fn(e,Qr);e.total_in=e.total_out=0,e.data_type=an;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?ln:_n,e.adler=2===t.wrap?0:1,t.last_flush=-2,Br(t),zr},Dn=e=>{const t=wn(e);var r;return t===zr&&((r=e.state).window_size=2*r.w_size,hn(r.head),r.max_lazy_match=Pn[r.level].max_lazy,r.good_match=Pn[r.level].good_length,r.nice_match=Pn[r.level].nice_length,r.max_chain_length=Pn[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=2,r.match_available=0,r.ins_h=0),t},kn=(e,t,r,n,i,o)=>{if(!e)return Qr;let a=1;if(t===$r&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>9||r!==sn||n<8||n>15||t<0||t>9||o<0||o>nn||8===n&&1!==a)return fn(e,Qr);8===n&&(n=9);const s=new An;return e.state=s,s.strm=e,s.status=ln,s.wrap=a,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+3-1)/3),s.window=new Uint8Array(2*s.w_size),s.head=new Uint16Array(s.hash_size),s.prev=new Uint16Array(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new Uint8Array(s.pending_buf_size),s.sym_buf=s.lit_bufsize,s.sym_end=3*(s.lit_bufsize-1),s.level=t,s.strategy=o,s.method=r,Dn(e)};var Un={deflateInit:(e,t)=>kn(e,t,sn,15,8,on),deflateInit2:kn,deflateReset:Dn,deflateResetKeep:wn,deflateSetHeader:(e,t)=>Nn(e)||2!==e.state.wrap?Qr:(e.state.gzhead=t,zr),deflate:(e,t)=>{if(Nn(e)||t>Yr||t<0)return e?fn(e,Qr):Qr;const r=e.state;if(!e.output||0!==e.avail_in&&!e.input||r.status===dn&&t!==Wr)return fn(e,0===e.avail_out?Xr:Qr);const n=r.last_flush;if(r.last_flush=t,0!==r.pending){if(mn(e),0===e.avail_out)return r.last_flush=-1,zr}else if(0===e.avail_in&&pn(t)<=pn(n)&&t!==Wr)return fn(e,Xr);if(r.status===dn&&0!==e.avail_in)return fn(e,Xr);if(r.status===ln&&0===r.wrap&&(r.status=_n),r.status===ln){let t=sn+(r.w_bits-8<<4)<<8,n=-1;if(n=r.strategy>=tn||r.level<2?0:r.level<6?1:6===r.level?2:3,t|=n<<6,0!==r.strstart&&(t|=32),t+=31-t%31,On(r,t),0!==r.strstart&&(On(r,e.adler>>>16),On(r,65535&e.adler)),e.adler=1,r.status=_n,mn(e),0!==r.pending)return r.last_flush=-1,zr}if(57===r.status)if(e.adler=0,Rn(r,31),Rn(r,139),Rn(r,8),r.gzhead)Rn(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Rn(r,255&r.gzhead.time),Rn(r,r.gzhead.time>>8&255),Rn(r,r.gzhead.time>>16&255),Rn(r,r.gzhead.time>>24&255),Rn(r,9===r.level?2:r.strategy>=tn||r.level<2?4:0),Rn(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(Rn(r,255&r.gzhead.extra.length),Rn(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Ur(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(Rn(r,0),Rn(r,0),Rn(r,0),Rn(r,0),Rn(r,0),Rn(r,9===r.level?2:r.strategy>=tn||r.level<2?4:0),Rn(r,3),r.status=_n,mn(e),0!==r.pending)return r.last_flush=-1,zr;if(69===r.status){if(r.gzhead.extra){let t=r.pending,n=(65535&r.gzhead.extra.length)-r.gzindex;for(;r.pending+n>r.pending_buf_size;){let i=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+i),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>t&&(e.adler=Ur(e.adler,r.pending_buf,r.pending-t,t)),r.gzindex+=i,mn(e),0!==r.pending)return r.last_flush=-1,zr;t=0,n-=i}let i=new Uint8Array(r.gzhead.extra);r.pending_buf.set(i.subarray(r.gzindex,r.gzindex+n),r.pending),r.pending+=n,r.gzhead.hcrc&&r.pending>t&&(e.adler=Ur(e.adler,r.pending_buf,r.pending-t,t)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){let t,n=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(e.adler=Ur(e.adler,r.pending_buf,r.pending-n,n)),mn(e),0!==r.pending)return r.last_flush=-1,zr;n=0}t=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,Rn(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>n&&(e.adler=Ur(e.adler,r.pending_buf,r.pending-n,n)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){let t,n=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(e.adler=Ur(e.adler,r.pending_buf,r.pending-n,n)),mn(e),0!==r.pending)return r.last_flush=-1,zr;n=0}t=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,Rn(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>n&&(e.adler=Ur(e.adler,r.pending_buf,r.pending-n,n))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(mn(e),0!==r.pending))return r.last_flush=-1,zr;Rn(r,255&e.adler),Rn(r,e.adler>>8&255),e.adler=0}if(r.status=_n,mn(e),0!==r.pending)return r.last_flush=-1,zr}if(0!==e.avail_in||0!==r.lookahead||t!==Gr&&r.status!==dn){let n=0===r.level?Tn(r,t):r.strategy===tn?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(Sn(e),0===e.lookahead)){if(t===Gr)return 1;break}if(e.match_length=0,r=Fr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(vn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Wr?(vn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(vn(e,!1),0===e.strm.avail_out)?1:2})(r,t):r.strategy===rn?((e,t)=>{let r,n,i,o;const a=e.window;for(;;){if(e.lookahead<=cn){if(Sn(e),e.lookahead<=cn&&t===Gr)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=e.strstart-1,n=a[i],n===a[++i]&&n===a[++i]&&n===a[++i])){o=e.strstart+cn;do{}while(n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&i<o);e.match_length=cn-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=Fr(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Fr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(vn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Wr?(vn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(vn(e,!1),0===e.strm.avail_out)?1:2})(r,t):Pn[r.level].func(r,t);if(3!==n&&4!==n||(r.status=dn),1===n||3===n)return 0===e.avail_out&&(r.last_flush=-1),zr;if(2===n&&(t===Hr?Jr(r):t!==Yr&&(xr(r,0,0,!1),t===Kr&&(hn(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),mn(e),0===e.avail_out))return r.last_flush=-1,zr}return t!==Wr?zr:r.wrap<=0?qr:(2===r.wrap?(Rn(r,255&e.adler),Rn(r,e.adler>>8&255),Rn(r,e.adler>>16&255),Rn(r,e.adler>>24&255),Rn(r,255&e.total_in),Rn(r,e.total_in>>8&255),Rn(r,e.total_in>>16&255),Rn(r,e.total_in>>24&255)):(On(r,e.adler>>>16),On(r,65535&e.adler)),mn(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?zr:qr)},deflateEnd:e=>{if(Nn(e))return Qr;const t=e.state.status;return e.state=null,t===_n?fn(e,Zr):zr},deflateSetDictionary:(e,t)=>{let r=t.length;if(Nn(e))return Qr;const n=e.state,i=n.wrap;if(2===i||1===i&&n.status!==ln||n.lookahead)return Qr;if(1===i&&(e.adler=Dr(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){0===i&&(hn(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(r-n.w_size,r),0),t=e,r=n.w_size}const o=e.avail_in,a=e.next_in,s=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,Sn(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do{n.ins_h=gn(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++}while(--t);n.strstart=e,n.lookahead=2,Sn(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=a,e.input=s,e.avail_in=o,n.wrap=i,zr},deflateInfo:"pako deflate (from Nodeca project)"};const Mn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var jn=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const t in r)Mn(r,t)&&(e[t]=r[t])}}return e},Bn=e=>{let t=0;for(let r=0,n=e.length;r<n;r++)t+=e[r].length;const r=new Uint8Array(t);for(let t=0,n=0,i=e.length;t<i;t++){let i=e[t];r.set(i,n),n+=i.length}return r};let xn=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){xn=!1}const Vn=new Uint8Array(256);for(let e=0;e<256;e++)Vn[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Vn[254]=Vn[254]=1;var Fn=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,r,n,i,o,a=e.length,s=0;for(i=0;i<a;i++)r=e.charCodeAt(i),55296==(64512&r)&&i+1<a&&(n=e.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),s+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(s),o=0,i=0;o<s;i++)r=e.charCodeAt(i),55296==(64512&r)&&i+1<a&&(n=e.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),r<128?t[o++]=r:r<2048?(t[o++]=192|r>>>6,t[o++]=128|63&r):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t},Jn=(e,t)=>{const r=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,i;const o=new Array(2*r);for(i=0,n=0;n<r;){let t=e[n++];if(t<128){o[i++]=t;continue}let a=Vn[t];if(a>4)o[i++]=65533,n+=a-1;else{for(t&=2===a?31:3===a?15:7;a>1&&n<r;)t=t<<6|63&e[n++],a--;a>1?o[i++]=65533:t<65536?o[i++]=t:(t-=65536,o[i++]=55296|t>>10&1023,o[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&xn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r})(o,i)},Gn=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+Vn[e[r]]>t?r:t};var Hn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Kn=Object.prototype.toString,{Z_NO_FLUSH:Wn,Z_SYNC_FLUSH:Yn,Z_FULL_FLUSH:zn,Z_FINISH:qn,Z_OK:Qn,Z_STREAM_END:Zn,Z_DEFAULT_COMPRESSION:Xn,Z_DEFAULT_STRATEGY:$n,Z_DEFLATED:ei}=jr;function ti(e){this.options=jn({level:Xn,method:ei,chunkSize:16384,windowBits:15,memLevel:8,strategy:$n},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Hn,this.strm.avail_out=0;let r=Un.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Qn)throw new Error(Mr[r]);if(t.header&&Un.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Fn(t.dictionary):"[object ArrayBuffer]"===Kn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,r=Un.deflateSetDictionary(this.strm,e),r!==Qn)throw new Error(Mr[r]);this._dict_set=!0}}function ri(e,t){const r=new ti(t);if(r.push(e,!0),r.err)throw r.msg||Mr[r.err];return r.result}ti.prototype.push=function(e,t){const r=this.strm,n=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?qn:Wn,"string"==typeof e?r.input=Fn(e):"[object ArrayBuffer]"===Kn.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(o===Yn||o===zn)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(i=Un.deflate(r,o),i===Zn)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=Un.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Qn;if(0!==r.avail_out){if(o>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},ti.prototype.onData=function(e){this.chunks.push(e)},ti.prototype.onEnd=function(e){e===Qn&&(this.result=Bn(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ni={Deflate:ti,deflate:ri,deflateRaw:function(e,t){return(t=t||{}).raw=!0,ri(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,ri(e,t)},constants:jr};const ii=16209;var oi=function(e,t){let r,n,i,o,a,s,c,u,l,_,d,f,p,h,b,g,m,v,R,O,E,I,S,T;const y=e.state;r=e.next_in,S=e.input,n=r+(e.avail_in-5),i=e.next_out,T=e.output,o=i-(t-e.avail_out),a=i+(e.avail_out-257),s=y.dmax,c=y.wsize,u=y.whave,l=y.wnext,_=y.window,d=y.hold,f=y.bits,p=y.lencode,h=y.distcode,b=(1<<y.lenbits)-1,g=(1<<y.distbits)-1;e:do{f<15&&(d+=S[r++]<<f,f+=8,d+=S[r++]<<f,f+=8),m=p[d&b];t:for(;;){if(v=m>>>24,d>>>=v,f-=v,v=m>>>16&255,0===v)T[i++]=65535&m;else{if(!(16&v)){if(64&v){if(32&v){y.mode=16191;break e}e.msg="invalid literal/length code",y.mode=ii;break e}m=p[(65535&m)+(d&(1<<v)-1)];continue t}for(R=65535&m,v&=15,v&&(f<v&&(d+=S[r++]<<f,f+=8),R+=d&(1<<v)-1,d>>>=v,f-=v),f<15&&(d+=S[r++]<<f,f+=8,d+=S[r++]<<f,f+=8),m=h[d&g];;){if(v=m>>>24,d>>>=v,f-=v,v=m>>>16&255,16&v){if(O=65535&m,v&=15,f<v&&(d+=S[r++]<<f,f+=8,f<v&&(d+=S[r++]<<f,f+=8)),O+=d&(1<<v)-1,O>s){e.msg="invalid distance too far back",y.mode=ii;break e}if(d>>>=v,f-=v,v=i-o,O>v){if(v=O-v,v>u&&y.sane){e.msg="invalid distance too far back",y.mode=ii;break e}if(E=0,I=_,0===l){if(E+=c-v,v<R){R-=v;do{T[i++]=_[E++]}while(--v);E=i-O,I=T}}else if(l<v){if(E+=c+l-v,v-=l,v<R){R-=v;do{T[i++]=_[E++]}while(--v);if(E=0,l<R){v=l,R-=v;do{T[i++]=_[E++]}while(--v);E=i-O,I=T}}}else if(E+=l-v,v<R){R-=v;do{T[i++]=_[E++]}while(--v);E=i-O,I=T}for(;R>2;)T[i++]=I[E++],T[i++]=I[E++],T[i++]=I[E++],R-=3;R&&(T[i++]=I[E++],R>1&&(T[i++]=I[E++]))}else{E=i-O;do{T[i++]=T[E++],T[i++]=T[E++],T[i++]=T[E++],R-=3}while(R>2);R&&(T[i++]=T[E++],R>1&&(T[i++]=T[E++]))}break}if(64&v){e.msg="invalid distance code",y.mode=ii;break e}m=h[(65535&m)+(d&(1<<v)-1)]}}break}}while(r<n&&i<a);R=f>>3,r-=R,f-=R<<3,d&=(1<<f)-1,e.next_in=r,e.next_out=i,e.avail_in=r<n?n-r+5:5-(r-n),e.avail_out=i<a?a-i+257:257-(i-a),y.hold=d,y.bits=f};const ai=15,si=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),ci=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),ui=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),li=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var _i=(e,t,r,n,i,o,a,s)=>{const c=s.bits;let u,l,_,d,f,p,h=0,b=0,g=0,m=0,v=0,R=0,O=0,E=0,I=0,S=0,T=null;const y=new Uint16Array(16),C=new Uint16Array(16);let L,P,A,N=null;for(h=0;h<=ai;h++)y[h]=0;for(b=0;b<n;b++)y[t[r+b]]++;for(v=c,m=ai;m>=1&&0===y[m];m--);if(v>m&&(v=m),0===m)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(g=1;g<m&&0===y[g];g++);for(v<g&&(v=g),E=1,h=1;h<=ai;h++)if(E<<=1,E-=y[h],E<0)return-1;if(E>0&&(0===e||1!==m))return-1;for(C[1]=0,h=1;h<ai;h++)C[h+1]=C[h]+y[h];for(b=0;b<n;b++)0!==t[r+b]&&(a[C[t[r+b]]++]=b);if(0===e?(T=N=a,p=20):1===e?(T=si,N=ci,p=257):(T=ui,N=li,p=0),S=0,b=0,h=g,f=o,R=v,O=0,_=-1,I=1<<v,d=I-1,1===e&&I>852||2===e&&I>592)return 1;for(;;){L=h-O,a[b]+1<p?(P=0,A=a[b]):a[b]>=p?(P=N[a[b]-p],A=T[a[b]-p]):(P=96,A=0),u=1<<h-O,l=1<<R,g=l;do{l-=u,i[f+(S>>O)+l]=L<<24|P<<16|A}while(0!==l);for(u=1<<h-1;S&u;)u>>=1;if(0!==u?(S&=u-1,S+=u):S=0,b++,0==--y[h]){if(h===m)break;h=t[r+a[b]]}if(h>v&&(S&d)!==_){for(0===O&&(O=v),f+=g,R=h-O,E=1<<R;R+O<m&&(E-=y[R+O],!(E<=0));)R++,E<<=1;if(I+=1<<R,1===e&&I>852||2===e&&I>592)return 1;_=S&d,i[_]=v<<24|R<<16|f-o}}return 0!==S&&(i[f+S]=h-O<<24|64<<16),s.bits=v,0};const{Z_FINISH:di,Z_BLOCK:fi,Z_TREES:pi,Z_OK:hi,Z_STREAM_END:bi,Z_NEED_DICT:gi,Z_STREAM_ERROR:mi,Z_DATA_ERROR:vi,Z_MEM_ERROR:Ri,Z_BUF_ERROR:Oi,Z_DEFLATED:Ei}=jr,Ii=16180,Si=16190,Ti=16191,yi=16192,Ci=16194,Li=16199,Pi=16200,Ai=16206,Ni=16209,wi=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Di(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const ki=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<Ii||t.mode>16211?1:0},Ui=e=>{if(ki(e))return mi;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Ii,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,hi},Mi=e=>{if(ki(e))return mi;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ui(e)},ji=(e,t)=>{let r;if(ki(e))return mi;const n=e.state;return t<0?(r=0,t=-t):(r=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?mi:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,Mi(e))},Bi=(e,t)=>{if(!e)return mi;const r=new Di;e.state=r,r.strm=e,r.window=null,r.mode=Ii;const n=ji(e,t);return n!==hi&&(e.state=null),n};let xi,Vi,Fi=!0;const Ji=e=>{if(Fi){xi=new Int32Array(512),Vi=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(_i(1,e.lens,0,288,xi,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;_i(2,e.lens,0,32,Vi,0,e.work,{bits:5}),Fi=!1}e.lencode=xi,e.lenbits=9,e.distcode=Vi,e.distbits=5},Gi=(e,t,r,n)=>{let i;const o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),n>=o.wsize?(o.window.set(t.subarray(r-o.wsize,r),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>n&&(i=n),o.window.set(t.subarray(r-n,r-n+i),o.wnext),(n-=i)?(o.window.set(t.subarray(r-n,r),0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0};var Hi={inflateReset:Mi,inflateReset2:ji,inflateResetKeep:Ui,inflateInit:e=>Bi(e,15),inflateInit2:Bi,inflate:(e,t)=>{let r,n,i,o,a,s,c,u,l,_,d,f,p,h,b,g,m,v,R,O,E,I,S=0;const T=new Uint8Array(4);let y,C;const L=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(ki(e)||!e.output||!e.input&&0!==e.avail_in)return mi;r=e.state,r.mode===Ti&&(r.mode=yi),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,l=r.bits,_=s,d=c,I=hi;e:for(;;)switch(r.mode){case Ii:if(0===r.wrap){r.mode=yi;break}for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(2&r.wrap&&35615===u){0===r.wbits&&(r.wbits=15),r.check=0,T[0]=255&u,T[1]=u>>>8&255,r.check=Ur(r.check,T,2,0),u=0,l=0,r.mode=16181;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=Ni;break}if((15&u)!==Ei){e.msg="unknown compression method",r.mode=Ni;break}if(u>>>=4,l-=4,E=8+(15&u),0===r.wbits&&(r.wbits=E),E>15||E>r.wbits){e.msg="invalid window size",r.mode=Ni;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=512&u?16189:Ti,u=0,l=0;break;case 16181:for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(r.flags=u,(255&r.flags)!==Ei){e.msg="unknown compression method",r.mode=Ni;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=Ni;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&4&r.wrap&&(T[0]=255&u,T[1]=u>>>8&255,r.check=Ur(r.check,T,2,0)),u=0,l=0,r.mode=16182;case 16182:for(;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.head&&(r.head.time=u),512&r.flags&&4&r.wrap&&(T[0]=255&u,T[1]=u>>>8&255,T[2]=u>>>16&255,T[3]=u>>>24&255,r.check=Ur(r.check,T,4,0)),u=0,l=0,r.mode=16183;case 16183:for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&4&r.wrap&&(T[0]=255&u,T[1]=u>>>8&255,r.check=Ur(r.check,T,2,0)),u=0,l=0,r.mode=16184;case 16184:if(1024&r.flags){for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&4&r.wrap&&(T[0]=255&u,T[1]=u>>>8&255,r.check=Ur(r.check,T,2,0)),u=0,l=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(f=r.length,f>s&&(f=s),f&&(r.head&&(E=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(o,o+f),E)),512&r.flags&&4&r.wrap&&(r.check=Ur(r.check,n,f,o)),s-=f,o+=f,r.length-=f),r.length))break e;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===s)break e;f=0;do{E=n[o+f++],r.head&&E&&r.length<65536&&(r.head.name+=String.fromCharCode(E))}while(E&&f<s);if(512&r.flags&&4&r.wrap&&(r.check=Ur(r.check,n,f,o)),s-=f,o+=f,E)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=16187;case 16187:if(4096&r.flags){if(0===s)break e;f=0;do{E=n[o+f++],r.head&&E&&r.length<65536&&(r.head.comment+=String.fromCharCode(E))}while(E&&f<s);if(512&r.flags&&4&r.wrap&&(r.check=Ur(r.check,n,f,o)),s-=f,o+=f,E)break e}else r.head&&(r.head.comment=null);r.mode=16188;case 16188:if(512&r.flags){for(;l<16;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(4&r.wrap&&u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=Ni;break}u=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=Ti;break;case 16189:for(;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}e.adler=r.check=wi(u),u=0,l=0,r.mode=Si;case Si:if(0===r.havedict)return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=l,gi;e.adler=r.check=1,r.mode=Ti;case Ti:if(t===fi||t===pi)break e;case yi:if(r.last){u>>>=7&l,l-=7&l,r.mode=Ai;break}for(;l<3;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}switch(r.last=1&u,u>>>=1,l-=1,3&u){case 0:r.mode=16193;break;case 1:if(Ji(r),r.mode=Li,t===pi){u>>>=2,l-=2;break e}break;case 2:r.mode=16196;break;case 3:e.msg="invalid block type",r.mode=Ni}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=Ni;break}if(r.length=65535&u,u=0,l=0,r.mode=Ci,t===pi)break e;case Ci:r.mode=16195;case 16195:if(f=r.length,f){if(f>s&&(f=s),f>c&&(f=c),0===f)break e;i.set(n.subarray(o,o+f),a),s-=f,o+=f,c-=f,a+=f,r.length-=f;break}r.mode=Ti;break;case 16196:for(;l<14;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(r.nlen=257+(31&u),u>>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Ni;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;l<3;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.lens[L[r.have++]]=7&u,u>>>=3,l-=3}for(;r.have<19;)r.lens[L[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,y={bits:r.lenbits},I=_i(0,r.lens,0,19,r.lencode,0,r.work,y),r.lenbits=y.bits,I){e.msg="invalid code lengths set",r.mode=Ni;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;S=r.lencode[u&(1<<r.lenbits)-1],b=S>>>24,g=S>>>16&255,m=65535&S,!(b<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(m<16)u>>>=b,l-=b,r.lens[r.have++]=m;else{if(16===m){for(C=b+2;l<C;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(u>>>=b,l-=b,0===r.have){e.msg="invalid bit length repeat",r.mode=Ni;break}E=r.lens[r.have-1],f=3+(3&u),u>>>=2,l-=2}else if(17===m){for(C=b+3;l<C;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}u>>>=b,l-=b,E=0,f=3+(7&u),u>>>=3,l-=3}else{for(C=b+7;l<C;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}u>>>=b,l-=b,E=0,f=11+(127&u),u>>>=7,l-=7}if(r.have+f>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Ni;break}for(;f--;)r.lens[r.have++]=E}}if(r.mode===Ni)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=Ni;break}if(r.lenbits=9,y={bits:r.lenbits},I=_i(1,r.lens,0,r.nlen,r.lencode,0,r.work,y),r.lenbits=y.bits,I){e.msg="invalid literal/lengths set",r.mode=Ni;break}if(r.distbits=6,r.distcode=r.distdyn,y={bits:r.distbits},I=_i(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,y),r.distbits=y.bits,I){e.msg="invalid distances set",r.mode=Ni;break}if(r.mode=Li,t===pi)break e;case Li:r.mode=Pi;case Pi:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=l,oi(e,d),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,l=r.bits,r.mode===Ti&&(r.back=-1);break}for(r.back=0;S=r.lencode[u&(1<<r.lenbits)-1],b=S>>>24,g=S>>>16&255,m=65535&S,!(b<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(g&&!(240&g)){for(v=b,R=g,O=m;S=r.lencode[O+((u&(1<<v+R)-1)>>v)],b=S>>>24,g=S>>>16&255,m=65535&S,!(v+b<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}u>>>=v,l-=v,r.back+=v}if(u>>>=b,l-=b,r.back+=b,r.length=m,0===g){r.mode=16205;break}if(32&g){r.back=-1,r.mode=Ti;break}if(64&g){e.msg="invalid literal/length code",r.mode=Ni;break}r.extra=15&g,r.mode=16201;case 16201:if(r.extra){for(C=r.extra;l<C;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=16202;case 16202:for(;S=r.distcode[u&(1<<r.distbits)-1],b=S>>>24,g=S>>>16&255,m=65535&S,!(b<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(!(240&g)){for(v=b,R=g,O=m;S=r.distcode[O+((u&(1<<v+R)-1)>>v)],b=S>>>24,g=S>>>16&255,m=65535&S,!(v+b<=l);){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}u>>>=v,l-=v,r.back+=v}if(u>>>=b,l-=b,r.back+=b,64&g){e.msg="invalid distance code",r.mode=Ni;break}r.offset=m,r.extra=15&g,r.mode=16203;case 16203:if(r.extra){for(C=r.extra;l<C;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Ni;break}r.mode=16204;case 16204:if(0===c)break e;if(f=d-c,r.offset>f){if(f=r.offset-f,f>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Ni;break}f>r.wnext?(f-=r.wnext,p=r.wsize-f):p=r.wnext-f,f>r.length&&(f=r.length),h=r.window}else h=i,p=a-r.offset,f=r.length;f>c&&(f=c),c-=f,r.length-=f;do{i[a++]=h[p++]}while(--f);0===r.length&&(r.mode=Pi);break;case 16205:if(0===c)break e;i[a++]=r.length,c--,r.mode=Pi;break;case Ai:if(r.wrap){for(;l<32;){if(0===s)break e;s--,u|=n[o++]<<l,l+=8}if(d-=c,e.total_out+=d,r.total+=d,4&r.wrap&&d&&(e.adler=r.check=r.flags?Ur(r.check,i,d,a-d):Dr(r.check,i,d,a-d)),d=c,4&r.wrap&&(r.flags?u:wi(u))!==r.check){e.msg="incorrect data check",r.mode=Ni;break}u=0,l=0}r.mode=16207;case 16207:if(r.wrap&&r.flags){for(;l<32;){if(0===s)break e;s--,u+=n[o++]<<l,l+=8}if(4&r.wrap&&u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=Ni;break}u=0,l=0}r.mode=16208;case 16208:I=bi;break e;case Ni:I=vi;break e;case 16210:return Ri;default:return mi}return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=l,(r.wsize||d!==e.avail_out&&r.mode<Ni&&(r.mode<Ai||t!==di))&&Gi(e,e.output,e.next_out,d-e.avail_out),_-=e.avail_in,d-=e.avail_out,e.total_in+=_,e.total_out+=d,r.total+=d,4&r.wrap&&d&&(e.adler=r.check=r.flags?Ur(r.check,i,d,e.next_out-d):Dr(r.check,i,d,e.next_out-d)),e.data_type=r.bits+(r.last?64:0)+(r.mode===Ti?128:0)+(r.mode===Li||r.mode===Ci?256:0),(0===_&&0===d||t===di)&&I===hi&&(I=Oi),I},inflateEnd:e=>{if(ki(e))return mi;let t=e.state;return t.window&&(t.window=null),e.state=null,hi},inflateGetHeader:(e,t)=>{if(ki(e))return mi;const r=e.state;return 2&r.wrap?(r.head=t,t.done=!1,hi):mi},inflateSetDictionary:(e,t)=>{const r=t.length;let n,i,o;return ki(e)?mi:(n=e.state,0!==n.wrap&&n.mode!==Si?mi:n.mode===Si&&(i=1,i=Dr(i,t,r,0),i!==n.check)?vi:(o=Gi(e,t,r,r),o?(n.mode=16210,Ri):(n.havedict=1,hi)))},inflateInfo:"pako inflate (from Nodeca project)"};var Ki=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Wi=Object.prototype.toString,{Z_NO_FLUSH:Yi,Z_FINISH:zi,Z_OK:qi,Z_STREAM_END:Qi,Z_NEED_DICT:Zi,Z_STREAM_ERROR:Xi,Z_DATA_ERROR:$i,Z_MEM_ERROR:eo}=jr;function to(e){this.options=jn({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Hn,this.strm.avail_out=0;let r=Hi.inflateInit2(this.strm,t.windowBits);if(r!==qi)throw new Error(Mr[r]);if(this.header=new Ki,Hi.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Fn(t.dictionary):"[object ArrayBuffer]"===Wi.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Hi.inflateSetDictionary(this.strm,t.dictionary),r!==qi)))throw new Error(Mr[r])}to.prototype.push=function(e,t){const r=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let o,a,s;if(this.ended)return!1;for(a=t===~~t?t:!0===t?zi:Yi,"[object ArrayBuffer]"===Wi.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),o=Hi.inflate(r,a),o===Zi&&i&&(o=Hi.inflateSetDictionary(r,i),o===qi?o=Hi.inflate(r,a):o===$i&&(o=Zi));r.avail_in>0&&o===Qi&&r.state.wrap>0&&0!==e[r.next_in];)Hi.inflateReset(r),o=Hi.inflate(r,a);switch(o){case Xi:case $i:case Zi:case eo:return this.onEnd(o),this.ended=!0,!1}if(s=r.avail_out,r.next_out&&(0===r.avail_out||o===Qi))if("string"===this.options.to){let e=Gn(r.output,r.next_out),t=r.next_out-e,i=Jn(r.output,e);r.next_out=t,r.avail_out=n-t,t&&r.output.set(r.output.subarray(e,e+t),0),this.onData(i)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(o!==qi||0!==s){if(o===Qi)return o=Hi.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},to.prototype.onData=function(e){this.chunks.push(e)},to.prototype.onEnd=function(e){e===qi&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Bn(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};const{Deflate:ro,deflate:no,deflateRaw:io,gzip:oo}=ni;var ao=oo;var so,co=-1,uo=function(){return"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)}))},lo=function(e,t,r){return T(void 0,void 0,void 0,(function(){var n,i;return y(this,(function(a){return n=[],i=r.jwt||"",[2,new Promise((function(r,a){e.forEach((function(e){return T(void 0,void 0,void 0,(function(){var a,s,c;return y(this,(function(u){switch(u.label){case 0:return a=e.detectorAddr.replace(/^(https?:\/\/)?/,"https://"),s="".concat(a,"/rtc/detector/ping?t=").concat((_=9999,(l=1e3)+Math.floor(Math.random()*(_-l)))),c={jwt:i},[4,t.httpReq({url:s,body:JSON.stringify(c),timeout:5e3,method:o.POST})];case 1:return 200===u.sent().status&&n.push(e.clusterId),r(n),[2]}var l,_}))}))}))}))]}))}))},_o=function(e,t){var r,n;if(!t)return"";try{n=JSON.parse(t.voipCallInfo||'{ "strategy": 0 }')}catch(r){return e.warn(E.L_MEDIA_SERVICE_PARSE_NAVI_CALLVOIP_INFO_O,"parse `voipCallInfo` of navi failed: ".concat(t.voipCallInfo)),""}if(0===n.strategy)return"";var i=null===(r=n.callEngine)||void 0===r?void 0:r.filter((function(e){return 4===e.engineType}));if(!i||0===i.length)return"";var o=i[0];return o.detectorManager?o.detectorManager:""},fo=function(e,t,r){return T(void 0,void 0,void 0,(function(){var n,i,a,s,c,u,l,_;return y(this,(function(d){switch(d.label){case 0:return n=_o(t,r),i=r.jwt||"",a=120,s=0,c=r.ipType||0,u={jwt:i,ipType:c},[4,e.httpReq({url:"".concat(n,"/rtc/detector/servers"),body:JSON.stringify(u),headers:{"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:"web|".concat(Bt.browser,"|").concat(Bt.version),ClientVersion:"5.26.0","Client-Session-Id":uo(),"Request-Id":Date.now().toString()},method:o.POST})];case 1:return l=d.sent(),_=l.data&&JSON.parse(l.data).detectorAddrs||[],a=l.data&&JSON.parse(l.data).clientDetectMinute,s=l.data&&JSON.parse(l.data).resultCode,[2,{detectoraddrs:_,clientDetectMinute:a,status:s}]}}))}))},po=function(){return{"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:"web|".concat(Bt.browser,"|").concat(Bt.version),ClientVersion:"5.26.0","Client-Session-Id":uo(),"Request-Id":Date.now().toString()}},ho=function(){function e(e,t,r,n){void 0===n&&(n=5e3),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_msUrl",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_timeout",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_failedMs",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_rtcFinger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clusterId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_configUrl",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_msList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_qualityMsList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._context.logger,t.getConnectionStatus()===a.CONNECTED&&this.isNededDetector()&&this.detectorMediaSever()}return Object.defineProperty(e.prototype,"isNededDetector",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this._context.getNaviInfo();if(!t)return!1;var r=_o(this._logger,t),n=t.jwt||"",i=Date.now(),o=!1;return 0===e.detectorTime?o=!1:e.detectValidMinute+e.detectorTime<i&&(o=!0),!(!r||!n||this._msUrl||o)}}),Object.defineProperty(e.prototype,"detectorMediaSever",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.clearMSList();var e=this._context.getNaviInfo();this._startDetector(e)}}),Object.defineProperty(e.prototype,"_startDetector",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return T(this,void 0,void 0,(function(){var r,n,i,o;return y(this,(function(a){switch(a.label){case 0:return[4,fo(this._runtime,this._logger,t)];case 1:return r=a.sent(),n=r.detectoraddrs,i=r.clientDetectMinute,r.status!==O.JWT_TIME_OUT?[3,3]:[4,this._context.getPluginContext().refetchNaviInfo()];case 2:return a.sent(),this.detectorMediaSever(),[2];case 3:return n.length?(o=e,[4,lo(n,this._runtime,t)]):[3,5];case 4:o.msInDetector=a.sent(),a.label=5;case 5:return e.detectorTime=Date.now(),e.detectValidMinute=60*i*1e3,[2]}}))}))}}),Object.defineProperty(e.prototype,"clearMSList",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._msList.length=0}}),Object.defineProperty(e.prototype,"getMsList",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._msUrl?[this._msUrl]:(this._sortMediaServiceList(),P([],L(this._msList),!1))}}),Object.defineProperty(e.prototype,"_sortMediaServiceList",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=e.msInDetector[0],r=e.msInDetector.slice(1),n=function(e,t){var r,n;if(!e)return[];try{n=JSON.parse(e.voipCallInfo||'{ "strategy": 0 }')}catch(r){return t.warn(E.L_PARSE_VOIP_SERVER_CONF_E,e.voipCallInfo),[]}if(0===n.strategy)return[];var i=null===(r=n.callEngine)||void 0===r?void 0:r.filter((function(e){return 4===e.engineType}));if(!i||0===i.length)return[];var o=i[0],a=[];return o.mediaServer&&a.push(o.mediaServer.replace(/^(https?:\/\/)?/,"https://")),o.backupMediaServer&&o.backupMediaServer.forEach((function(e){a.push(e.replace(/^(https?:\/\/)?/,"https://"))})),a}(this._context.getNaviInfo(),this._logger),i=n[0],o=n.slice(1),a=P(P([this._clusterId,t,i],L(r),!1),L(o),!1).filter((function(e){return!!e})).map((function(e){return e.replace(/^(https?:\/\/)?/,"https://")}));this._msList=P([],L(new Set(a)),!1),this._logger.info(E.L_MEDIA_SERVICE_MSLIST_CHANGE_O,"MediaServiceList msList -> ".concat(JSON.stringify(this._msList)))}}),Object.defineProperty(e.prototype,"_openGzip",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){for(var r=JSON.stringify(t),n=r.length,i=new Uint8Array(n),o=0;o<n;o++)i[o]=r.charCodeAt(o);var a;return{headers:e=S(S({},e),{"Content-Encoding":"gzip","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}),body:t=ao(i,a)}}}),Object.defineProperty(e.prototype,"_dealRequestSuccessResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=JSON.parse(e);return n.rtcFinger&&(this._rtcFinger=n.rtcFinger),n.clusterId&&(this._clusterId!==n.clusterId&&this.clearMSList(),this._clusterId=n.clusterId),this._logger.info(E.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:I.SUCCESSED,url:t}),r),{code:O.SUCCESS,data:n,qualityMsList:this._qualityMsList}}}),Object.defineProperty(e.prototype,"_request",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i){var a;return T(this,void 0,void 0,(function(){var s,c,u,l,_,d,f,p,h,b,g,m,v,R,T;return y(this,(function(y){switch(y.label){case 0:if(this._qualityMsList=[],s=(null===(a=this._context.getNaviInfo())||void 0===a?void 0:a.openGzip)||!1,c=s?this._openGzip(t,r):{headers:t,body:r},u=c.headers,l=c.body,0===(_=this.getMsList()).length)return this._logger.error(E.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:I.FAILED,code:O.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"have no valid service address"}),n),[2,{code:O.NOT_OPEN_VIDEO_AUDIO_SERVER}];this._rtcFinger&&(l.rtcFinger=this._rtcFinger),d=0,y.label=1;case 1:return d<_.length?(f=Date.now(),p="".concat(_[d]).concat(e),h=po(),b=S(S({},h),u),g=/x-www-form-urlencoded/.test(b["Content-Type"])?l:JSON.stringify(l),m=h["Request-Id"],this._logger.info(E.L_MEDIA_SERVICE_REQUEST_T,JSON.stringify({url:p,"Request-Id":m}),n),[4,this._runtime.httpReq({url:p,body:g,headers:b,method:o.POST,timeout:this._timeout})]):[3,4];case 2:if(v=y.sent(),R=v.status,T=v.data,i&&this._qualityMsList.push({rsdur:Date.now()-f,rsid:m,rscod:200===R?O.SUCCESS:O.REQUEST_FAILED,msa:p}),200===R)return[2,this._dealRequestSuccessResult(T,p,n)];this._logger.error(E.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:I.FAILED,msg:"request error -> Request-Id: ".concat(m,", status: ").concat(R,", url: ").concat(p),timeout:this._timeout}),n),y.label=3;case 3:return d+=1,[3,1];case 4:return[2,{code:O.REQUEST_FAILED,qualityMsList:this._qualityMsList}]}}))}))}}),Object.defineProperty(e.prototype,"exchange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i;return T(this,void 0,void 0,(function(){var o,a;return y(this,(function(s){switch(s.label){case 0:return[4,this._request("/exchange",e,t,r,n)];case 1:return(o=s.sent()).code===O.SUCCESS&&(null===(i=o.data)||void 0===i?void 0:i.resultCode)===O.SUCCESS&&(a=o.data.urls)&&(this._configUrl=a.configUrl),[2,o]}}))}))}}),Object.defineProperty(e.prototype,"exit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t;return y(this,(function(r){switch(r.label){case 0:return t=this._logger.createTraceId(),[4,this._request("/exit",e,{},t)];case 1:return[2,r.sent().code]}}))}))}}),Object.defineProperty(e.prototype,"broadcastSubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this._logger.createTraceId();return this._request("/broadcast/subscribe",e,t,r,!0)}}),Object.defineProperty(e.prototype,"broadcastExit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t;return y(this,(function(r){switch(r.label){case 0:return t=this._logger.createTraceId(),[4,this._request("/broadcast/exit",e,{},t,!0)];case 1:return[2,{code:r.sent().code}]}}))}))}}),Object.defineProperty(e.prototype,"setMcuConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n,i,a,s,c,u,l,_,d,f;return y(this,(function(p){switch(p.label){case 0:return r=this._logger.createTraceId(),this._logger.info(E.L_MEDIA_SERVICE_SET_MCU_CONFIG_T,JSON.stringify({body:t}),r),this._configUrl?(n="".concat(this._configUrl.replace(/^(https?:\/\/)?/,"https://"),"/server/mcu/config"),i=po(),a=S(S({},i),e),s=JSON.stringify(t),c=i["Request-Id"],[4,this._runtime.httpReq({url:n,headers:a,body:s,method:o.POST})]):(this._logger.error(E.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:I.FAILED,code:O.MCU_SERVER_NOT_FOUND,msg:"MCU server not found"}),r),[2,{code:O.MCU_SERVER_NOT_FOUND}]);case 1:return u=p.sent(),l=u.status,_=u.data,200===l?(d=JSON.parse(_),(f=d.resultCode)===O.SUCCESS?this._logger.info(E.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:I.SUCCESSED,"Request-Id":c}),r):this._logger.warn(E.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({code:f,"Request-Id":c}),r),[2,{code:f,res:d}]):(this._logger.error(E.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:I.FAILED,code:O.REQUEST_FAILED,msg:"request error -> Request-Id: ".concat(c,", status: ").concat(l,", url: ").concat(n)}),r),[2,{code:O.REQUEST_FAILED}])}}))}))}}),Object.defineProperty(e.prototype,"getCDNResourceInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,a,s,c,u,l;return y(this,(function(_){switch(_.label){case 0:return n=po(),i=S(S({},n),e),a=n["Request-Id"],this._logger.info(E.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_T,"Request-Id: ".concat(a,", url: ").concat(t),r),[4,this._runtime.httpReq({url:t,headers:i,method:o.GET})];case 1:return s=_.sent(),c=s.status,u=s.data,200===c?(l=JSON.parse(u),this._logger.info(E.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:I.SUCCESSED,cdnPlayerUrl:null==l?void 0:l.data.pull_url}),r),[2,{code:l.resultCode,res:l}]):(this._logger.info(E.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:I.FAILED,code:O.REQUEST_FAILED}),r),[2,{code:O.REQUEST_FAILED}])}}))}))}}),Object.defineProperty(e,"msInDetector",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(e,"detectorTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(e,"detectValidMinute",{enumerable:!0,configurable:!0,writable:!0,value:72e5}),e}();!function(e){e[e.NORMAL=1]="NORMAL",e[e.TINY=2]="TINY"}(so||(so={}));var bo,go=function(e,t){return Math.round(8*t/e)},mo=function(e,t){void 0===t&&(t=2);var r=Math.pow(10,t);return Math.round(e*r)/r},vo=function(e,t){void 0===t&&(t=2),e>1&&(e=1);var r=Math.pow(10,t);return Math.round(e*r)},Ro=function(e,t,r,n){if(0===t)return 0;if(!r||!n)return mo(e/t,3);var i=t-n;if(0===i)return 0;var o=e-r;return o<0||i<0?0:mo(o/i,3)},Oo=function(e){var t=e.jitter,r=e.rtt,n=e.packetsLostRate;return!Gt(t)||!Gt(r)||0!==n};!function(e){e.TRACK="track",e.STREAM="stream",e.MEDIASOURCE="media-source",e.INBOUNDRTP="inbound-rtp",e.OUTBOUNDRTP="outbound-rtp",e.REMOTEINBOUNDRTP="remote-inbound-rtp",e.PEERCONNECTION="peer-connection",e.TRANSPORT="transport",e.CERTIFICATE="certificate",e.CANDIDATEPAIR="candidate-pair",e.REMOTECANDIDATE="remote-candidate",e.LOCALCANDIDATE="local-candidate"}(bo||(bo={}));var Eo,Io=function(){function e(e,t,r,n,i,o){Object.defineProperty(this,"_sdpStrategy",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_rtcPeerConn",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_sdpSemantics",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_latestPacketsSent",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_latestBytesSent",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_latestBytesRecv",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_latestPacketsRecv",{enumerable:!0,configurable:!0,writable:!0,value:{}})}return Object.defineProperty(e.prototype,"getTrackIdByMid",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._sdpStrategy.getTrackIdByMid(e)}}),Object.defineProperty(e.prototype,"updateBytesSent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n,i;if(this._latestBytesSent[e]&&t<this._latestBytesSent[e].bytesSent&&this.clearLatestpacketsSent([e]),this._latestBytesSent[e]){var o=this._latestBytesSent[e];n=t-o.bytesSent,i=r-o.timestamp,this._latestBytesSent[e]={bytesSent:t,timestamp:r}}else n=t,i=1e3,this._latestBytesSent[e]={bytesSent:t,timestamp:r};return go(i,n)}}),Object.defineProperty(e.prototype,"updateBytesRecv",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n,i;if(this._latestBytesRecv[e]&&t<this._latestBytesRecv[e].bytesRecv&&this.clearLatestPacketsRecv([e]),this._latestBytesRecv[e]){var o=this._latestBytesRecv[e];n=t-o.bytesRecv,i=r-o.timestamp,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r}}else n=t,i=1e3,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r};return go(i,n)}}),Object.defineProperty(e.prototype,"updateSenderPacketsLost",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n;if(Object.prototype.hasOwnProperty.call(this._latestPacketsSent[e],"packetsSent")){var i=this._latestPacketsSent[e],o=i.packetsLost,a=i.packetsSent;n=Ro(t,r,o,a),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=o===t?a:r}else n=Ro(t,r),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=r;return n}}),Object.defineProperty(e.prototype,"updateReceiverPacketsLost",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n;if(this._latestPacketsRecv[e]){var i=this._latestPacketsRecv[e],o=i.packetsLost,a=i.packetsRecv;n=Ro(t,r+t,o,a+o)}else n=Ro(t,r);return this._latestPacketsRecv[e]={packetsLost:t,packetsRecv:r},n}}),Object.defineProperty(e.prototype,"clearLatestpacketsSent",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.forEach((function(e){if(parseInt(e.split("_").pop())===We.VIDEO_ONLY){var r="".concat(e,"_tiny");delete t._latestPacketsSent[r],delete t._latestBytesSent[r]}delete t._latestPacketsSent[e],delete t._latestBytesSent[e]}))}}),Object.defineProperty(e.prototype,"clearLatestPacketsRecv",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.forEach((function(e){delete t._latestPacketsRecv[e],delete t._latestBytesRecv[e]}))}}),Object.defineProperty(e.prototype,"parseRTCStatsReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,n={};try{for(var i=C(e.entries()),o=i.next();!o.done;o=i.next()){var a=L(o.value,2),s=a[0],c=a[1];/codec/gi.test(c)&&s.includes("RTCCodec_")||(n[s]=c)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return n}}),Object.defineProperty(e.prototype,"formatRCRTCStateReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={senders:[],receivers:[]};return this._logger.info(E.L_ABSTRACT_STAT_PARSER_FORMAT_RTC_STATE_REPORT_O,JSON.stringify({status:I.SUCCESSED,stats:e,reports:t})),t}}),Object.defineProperty(e.prototype,"isValidTranceiver",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,n,i="outbound-rtp"===t?null===(r=this._rtcPeerConn.currentLocalDescription)||void 0===r?void 0:r.sdp:null===(n=this._rtcPeerConn.currentRemoteDescription)||void 0===n?void 0:n.sdp,o=e.ssrc;return!(null==i?void 0:i.split("\r\nm=").some((function(e){return e.includes(o)&&e.includes("a=inactive")})))}}),Object.defineProperty(e.prototype,"formatStateData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return Object.values(e).reduce((function(e,t){return t.type===bo.REMOTEINBOUNDRTP?(e.remoteInbound.push(t),e):t.type===bo.INBOUNDRTP?(e.inbound.push(t),e):t.type===bo.OUTBOUNDRTP?(e.outbound.push(t),e):t.type===bo.TRANSPORT?(e.transport.push(t),e):t.type===bo.PEERCONNECTION?(e.connection.push(t),e):e}),{outbound:[],remoteInbound:[],inbound:[],transport:[],connection:[]})}}),e}(),So=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return R(t,e),Object.defineProperty(t.prototype,"formatRCRTCStateReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,n=this.formatStateData(e),i=n.outbound,o=n.remoteInbound,a=n.inbound,s=n.transport,c=n.connection,u={senders:[],receivers:[]},l=Math.floor(c[0].timestamp);u.timestamp=l;var _=0,d=0;_=(t=this.pickOutbound(i,e,_,l,d)).totalPacketsLost,d=t.bitrateSend,u.senders=t.senders,o.length>0&&u.senders.length>0&&this.pickRemoteInbound(o,u.senders,e);var f=0;if(_=(r=this.pickInbound(a,e,_,l,f)).totalPacketsLost,f=r.bitrateRecv,u.receivers=r.receivers,s.length>0){var p=s[0];this.pickRtcTransport(p,e,u,f,d,_)}return u}}),Object.defineProperty(t.prototype,"pickRtcTransport",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i,o){var a=e.selectedCandidatePairId;if(a){var s=t[a],c=s.availableOutgoingBitrate,u=s.availableIncomingBitrate,l=s.currentRoundTripTime,_=s.localCandidateId,d=s.remoteCandidateId,f=t[_],p=f.ip,h=f.port,b=f.networkType,g=t[d],m=g.ip,v=g.port,R=g.protocol;r.iceCandidatePair={IP:p,port:h,networkType:b,remoteIP:m,remotePort:v,protocol:R,bitrateRecv:n,bitrateSend:i,rtt:1e3*l,availableOutgoingBitrate:c,availableIncomingBitrate:u,totalPacketsLost:o},r.receivers.forEach((function(e){e.rtt=1e3*l}))}}}),Object.defineProperty(t.prototype,"pickRemoteInbound",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=this;e.forEach((function(e){var i,o=e.localId,a=e.jitter,s=e.roundTripTime,c=e.packetsLost,u=t.filter((function(e){return e.id===o}))[0];if(u&&!Oo(u)){var l=null===(i=n._store)||void 0===i?void 0:i.getTrackIdBySSRC(r[u.id].ssrc);u.jitter=Math.round(1e3*a),u.rtt=s;var _=n._latestPacketsSent[l].crtPacketsSent;u.packetsLostRate=n.updateSenderPacketsLost(l,c,_)}}))}}),Object.defineProperty(t.prototype,"_getOutboundVideoAttrs",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i){var o,a,s,c=e.framesPerSecond,u=e.frameWidth,l=e.frameHeight;return"video"!==r||u||l||c||(u=(null===(o=t[n])||void 0===o?void 0:o.frameWidth)||t[i].width,l=(null===(a=t[n])||void 0===a?void 0:a.frameHeight)||t[i].height,c=(null===(s=t[i])||void 0===s?void 0:s.framesPerSecond)||null),{frameRate:c,frameWidth:u,frameHeight:l}}}),Object.defineProperty(t.prototype,"pickOutbound",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i){var o=this,a=[];return e.forEach((function(e){var s;if("unified-plan"!==o._sdpSemantics||o.isValidTranceiver(e,"outbound-rtp")){var c=e.id,u=e.kind,l=e.mediaSourceId,_=e.remoteId,d=e.packetsSent,f=e.bytesSent,p=e.encoderImplementation,h=e.pliCount,b=e.nackCount,g=e.mid,m=e.trackId;if(void 0!==g&&(m=o.getTrackIdByMid(g)),m){var v=o._getOutboundVideoAttrs(e,t,u,m,l),R=v.frameRate,O=v.frameWidth,E=v.frameHeight,I=t[_],S=null,T=null,y=0;I&&(S=I.jitter,T=I.roundTripTime,y=I.packetsLost),r+=y;var C=null===(s=o._store)||void 0===s?void 0:s.getTrackIdBySSRC(e.ssrc);if(C){var L=l?t[l].audioLevel:t[m].audioLevel,P=0;!o._latestPacketsSent[C]&&(o._latestPacketsSent[C]={}),I?P=o.updateSenderPacketsLost(C,y,d):o._latestPacketsSent[C].crtPacketsSent=d;var A=o.updateBytesSent(C,f,n);A<0&&(A=0),i+=A,a.push({id:c,trackId:C,kind:u,packetsLostRate:P,remoteResource:!1,audioLevel:L||0===L?vo(L):null,frameWidth:O,frameHeight:E,frameRate:R,bitrate:A,jitter:S?Math.round(1e3*S):S,rtt:T?Math.round(1e3*T):T,encoderImplementation:p,pliCount:h,nackCount:b,googFirsSent:co,samplingRate:co,googRenderDelayMs:co,trackState:co})}}}})),{totalPacketsLost:r,bitrateSend:i,senders:a}}}),Object.defineProperty(t.prototype,"_getInboundMediaAttrs",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i){var o,a,s,c=e.frameWidth,u=e.frameHeight,l=e.audioLevel;return"video"===i?c||u||(c=(null===(o=t[r])||void 0===o?void 0:o.frameWidth)||t[n].width,u=(null===(a=t[r])||void 0===a?void 0:a.frameHeight)||t[n].height):l||(l=(null===(s=t[r])||void 0===s?void 0:s.audioLevel)||t[n].audioLevel),{frameWidth:c,frameHeight:u,audioLevel:l}}}),Object.defineProperty(t.prototype,"pickInbound",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i){var o=this,a=[];return e.forEach((function(e){var s;if("unified-plan"!==o._sdpSemantics||o.isValidTranceiver(e,"inbound-rtp")){var c=e.packetsLost,u=e.packetsReceived,l=e.jitter,_=e.bytesReceived,d=e.framesPerSecond,f=e.kind,p=e.codecImplementationName,h=e.nackCount,b=e.pliCount,g=e.mid,m=e.id,v=e.trackId;if(void 0!==g&&(v=o.getTrackIdByMid(g)),v){var R=o._getInboundMediaAttrs(e,t,v,m,f),O=R.frameWidth,E=R.frameHeight,I=R.audioLevel;r+=c;var S=null===(s=o._store)||void 0===s?void 0:s.getTrackIdBySSRC(e.ssrc),T=o.updateReceiverPacketsLost(S,c,u),y=o.updateBytesRecv(S,_,n);y<0&&(y=0),i+=y,a.push({trackId:S,kind:f,packetsLostRate:T,remoteResource:!0,audioLevel:I||0===I?vo(I):null,frameWidth:O,frameHeight:E,frameRate:d,bitrate:y,jitter:l?Math.round(1e3*l):0,codecImplementationName:p,nackCount:h,pliCount:b,rtt:null,samplingRate:co,googFirsReceived:co,googRenderDelayMs:co,trackState:co})}}})),{totalPacketsLost:r,bitrateRecv:i,receivers:a}}}),t}(Io),To=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return Object.defineProperty(t,"_reportsData",{enumerable:!0,configurable:!0,writable:!0,value:{senders:[],receivers:[],timestamp:+new Date}}),Object.defineProperty(t,"_totalPacketsLost",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(t,"_bitrateSend",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(t,"_bitrateRecv",{enumerable:!0,configurable:!0,writable:!0,value:0}),t}return R(t,e),Object.defineProperty(t.prototype,"_pickSenderData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n;if("unified-plan"!==this._sdpSemantics||this.isValidTranceiver(e,r)){var i=e.kind,o=e.bytesSent,a=e.packetsSent,s=e.bitrateMean,c=e.framerateMean,u=e.nackCount,l=e.pliCount,_=e.remoteId,d=_?t[_]:{jitter:null,roundTripTime:null,packetsLost:0},f=d.jitter,p=d.roundTripTime,h=d.packetsLost,b=null===(n=this._store)||void 0===n?void 0:n.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=h;var g=0;!this._latestPacketsSent[b]&&(this._latestPacketsSent[b]={}),_?g=this.updateSenderPacketsLost(b,h,a):this._latestPacketsSent[b].crtPacketsSent=a;var m=0;"video"===i?s&&(m=Math.floor(s/1e3)):m=this.updateBytesSent(b,o,this._reportsData.timestamp),m<0&&(m=0),this._bitrateSend+=m,this._reportsData.senders.push({trackId:b,kind:i,packetsLostRate:g,remoteResource:!1,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(c),bitrate:m,jitter:f?Math.round(1e3*f):null,rtt:p,encoderImplementation:null,pliCount:l,nackCount:u,googFirsSent:co,samplingRate:co,googRenderDelayMs:co,trackState:co})}}}),Object.defineProperty(t.prototype,"_addSenderData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,n=t.localId,i=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e[n].ssrc),o=this._reportsData.senders.filter((function(e){return e.trackId===i}))[0];o&&Oo(o)&&(o.jitter=Math.round(1e3*t.jitter),o.rtt=t.rtt,o.packetsLostRate=this.updateSenderPacketsLost(i,t.packetsLost,this._latestPacketsSent[i].crtPacketsSent))}}),Object.defineProperty(t.prototype,"_pickReceiverData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;if("unified-plan"!==this._sdpSemantics||this.isValidTranceiver(e,t)){var n=e.packetsLost,i=e.bytesReceived,o=e.packetsReceived,a=e.jitter,s=e.framerateMean,c=e.kind,u=e.bitrateMean,l=e.nackCount,_=e.pliCount,d=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=n;var f=this.updateReceiverPacketsLost(d,n,o),p=0;"video"===c?u&&(p=Math.floor(u/1e3)):p=this.updateBytesRecv(d,i,this._reportsData.timestamp),p<0&&(p=0),this._bitrateRecv+=p,this._reportsData.receivers.push({trackId:d,kind:c,packetsLostRate:f,remoteResource:!0,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(s),bitrate:p,jitter:a?Math.round(1e3*a):null,codecImplementationName:null,nackCount:l,pliCount:_,rtt:null,samplingRate:co,googFirsReceived:co,googRenderDelayMs:co,trackState:co})}}}),Object.defineProperty(t.prototype,"_pickIceCandidatePair",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e[t.localCandidateId],n=r.address,i=r.port,o=e[t.remoteCandidateId],a=o.address,s=o.port,c=o.protocol;this._reportsData.iceCandidatePair={IP:n,port:i,networkType:null,remoteIP:a,remotePort:s,protocol:c,bitrateRecv:this._bitrateRecv,bitrateSend:this._bitrateSend,rtt:null,availableOutgoingBitrate:null,availableIncomingBitrate:null,totalPacketsLost:this._totalPacketsLost}}}),Object.defineProperty(t.prototype,"formatRCRTCStateReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=+new Date;for(var r in this._reportsData={senders:[],receivers:[],timestamp:t},this._totalPacketsLost=0,this._bitrateRecv=0,this._bitrateSend=0,e){var n=e[r],i=n.type;"outbound-rtp"===i&&this._pickSenderData(n,e,i),"remote-inbound-rtp"===i&&this._addSenderData(e,n),"inbound-rtp"===i&&this._pickReceiverData(n,i),"candidate-pair"===i&&"succeeded"===n.state&&this._pickIceCandidatePair(e,n)}return this._reportsData}}),t}(Io),yo=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return Object.defineProperty(t,"_reportsData",{enumerable:!0,configurable:!0,writable:!0,value:{senders:[],receivers:[],timestamp:+new Date}}),Object.defineProperty(t,"_totalPacketsLost",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(t,"_bitrateSend",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(t,"_bitrateRecv",{enumerable:!0,configurable:!0,writable:!0,value:0}),t}return R(t,e),Object.defineProperty(t.prototype,"_pickReceiverData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;e.forEach((function(e){var t;if("unified-plan"!==r._sdpSemantics||r.isValidTranceiver(e,"inbound-rtp")){var n=e.packetsLost,i=e.packetsReceived,o=e.jitter,a=e.bytesReceived,s=e.kind,c=e.nackCount,u=e.pliCount,l=e.audioLevel,_=e.frameHeight,d=e.frameWidth,f=null===(t=r._store)||void 0===t?void 0:t.getTrackIdBySSRC(e.ssrc);if(f){r._totalPacketsLost+=n;var p=r.updateReceiverPacketsLost(f,n,i),h=r.updateBytesRecv(f,a,r._reportsData.timestamp);h<0&&(h=0),r._bitrateRecv+=h,r._reportsData.receivers.push({trackId:f,kind:s,packetsLostRate:p,remoteResource:!0,audioLevel:l||0===l?vo(l):null,frameWidth:d,frameHeight:_,frameRate:null,bitrate:h,jitter:o?Math.round(1e3*o):o,codecImplementationName:null,nackCount:c,pliCount:u,rtt:null,samplingRate:co,googFirsReceived:co,googRenderDelayMs:co,trackState:co})}}}))}}),Object.defineProperty(t.prototype,"_pickSenderData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;e.forEach((function(e){var n;if("unified-plan"!==r._sdpSemantics||r.isValidTranceiver(e,"outbound-rtp")){var i=null===(n=r._store)||void 0===n?void 0:n.getTrackIdBySSRC(e.ssrc),o=e.kind,a=e.bytesSent,s=e.pliCount,c=e.nackCount,u=e.audioLevel,l=e.frameHeight,_=e.frameWidth,d=e.codecId,f=e.remoteId,p=e.packetsSent;if(i){var h=t[f],b=null,g=null,m=0;h&&(b=h.jitter,g=h.roundTripTime,m=h.packetsLost),r._totalPacketsLost+=m;var v=0;!r._latestPacketsSent[i]&&(r._latestPacketsSent[i]={}),h?v=r.updateSenderPacketsLost(i,m,p):r._latestPacketsSent[i].crtPacketsSent=p;var R=r.updateBytesSent(i,a,r._reportsData.timestamp);R<0&&(R=0),r._bitrateSend+=R,r._reportsData.senders.push({trackId:i,kind:o,packetsLostRate:v,remoteResource:!1,audioLevel:u||0===u?vo(u):null,frameWidth:_,frameHeight:l,frameRate:null,bitrate:R,jitter:b?Math.round(1e3*b):b,rtt:g?Math.round(1e3*g):g,encoderImplementation:t[d].mimeType,pliCount:s,nackCount:c,googFirsSent:co,samplingRate:co,googRenderDelayMs:co,trackState:co})}}}))}}),Object.defineProperty(t.prototype,"_pickIceCandidatePair",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.selectedCandidatePairId;if(r){var n=t[r],i=n.availableOutgoingBitrate,o=n.availableIncomingBitrate,a=n.currentRoundTripTime,s=n.localCandidateId,c=n.remoteCandidateId,u=t[s],l=u.address,_=u.port,d=t[c],f=d.address,p=d.port,h=d.protocol;this._reportsData.iceCandidatePair={IP:l||null,port:_,networkType:null,remoteIP:f,remotePort:p,protocol:h,bitrateRecv:this._bitrateRecv,bitrateSend:this._bitrateSend,rtt:1e3*a,availableOutgoingBitrate:i,availableIncomingBitrate:o,totalPacketsLost:this._totalPacketsLost},this._reportsData.receivers.forEach((function(e){e.rtt=1e3*a}))}}}),Object.defineProperty(t.prototype,"formatRCRTCStateReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.formatStateData(e),r=t.outbound,n=t.inbound,i=t.transport,o=t.connection;this._reportsData={senders:[],receivers:[]};var a=Math.floor(o[0].timestamp);if(this._reportsData.timestamp=a,this._totalPacketsLost=0,this._bitrateSend=0,this._bitrateRecv=0,this._pickSenderData(r,e),this._pickReceiverData(n,e),i.length>0){var s=i[0];this._pickIceCandidatePair(s,e)}return this._reportsData}}),t}(Io),Co=function(){function e(e,t,r){Object.defineProperty(this,"SDP",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"SDPHeader",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"videoStreams",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"audioStreams",{enumerable:!0,configurable:!0,writable:!0,value:[]});var n=this.getStreamIndex();this.spliteStreams(n)}return Object.defineProperty(e.prototype,"videoSdps",{get:function(){return this.videoStreams.slice()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"audioSdps",{get:function(){return this.audioStreams.slice()},enumerable:!1,configurable:!0}),Object.defineProperty(e,"trimBlankLine",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.replace(/\n\r\s*\r\n/g,"\r\n").replace(/\s+\r\n/g,"\r\n")}}),Object.defineProperty(e.prototype,"getStreamIndex",{enumerable:!1,configurable:!0,writable:!0,value:function(){for(var e=/m=(?:video|audio)/gim,t=new Set([0]),r=e.exec(this.SDP);null!==r;)t.add(null==r?void 0:r.index),r=e.exec(this.SDP);return t.add(this.SDP.length),P([],L(t),!1)}}),Object.defineProperty(e.prototype,"spliteStreams",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.SDPHeader=this.SDP.substring(e[0],e[1]).replace(/\r\ns=-/g,"\r\ns=".concat((new Date).valueOf()));for(var t=1;t<e.length;t++){var r=this.SDP.substring(e[t],e[t+1]);/^\bm=video\b/.test(r)?this.videoStreams.push(r):this.audioStreams.push(r)}}}),Object.defineProperty(e,"clearInactiveOrRecvonly",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return/\ba=(recvonly|inactive)\b/.test(e)?e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,""):e}}),Object.defineProperty(e.prototype,"setHeaderBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.SDPHeader=this.SDPHeader.replace(/(\r\ns=[^\r\n]+)/gi,"$1\r\nc=IN IP4 0.0.0.0\r\nb=AS:".concat(t*e.KBitrate,"\r\nb=TIAS:").concat(t*e.KBitrate*850))}}),Object.defineProperty(e.prototype,"setAudiosBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.audioStreams=this.audioStreams.map((function(r){return t.setAudioItemBitrate(r,e)})),this}}),Object.defineProperty(e.prototype,"setAudioBitrateWithStreamId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return this.audioStreams=this.audioStreams.map((function(n){return new RegExp("\\bmsid:".concat(t,"\\b"),"ig").test(n)?r.setAudioItemBitrate(n,e):n})),this}}),Object.defineProperty(e.prototype,"setAudioBitrateWithMid",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return this.audioStreams=this.audioStreams.map((function(n){return new RegExp("\\bmid:".concat(t,"\\b"),"ig").test(n)?r.setAudioItemBitrate(n,e):n})),this}}),Object.defineProperty(e.prototype,"setAudioItemBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){if(0===r.max&&/\ba=inactive\b/gi.test(t))return t;if(!/\bmaxaveragebitrate\b/gi.test(t)){var n=["$1","maxaveragebitrate=".concat(r.max*e.KBitrate*1e3)];t=t.replace(/(\buseinbandfec=[^\r\n]+)/gi,n.join(";"))}return this.addAudioBlineAS(t,r)}}),Object.defineProperty(e.prototype,"addAudioBlineAS",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return/\bb=AS:\d+\b/gi.test(t)?t:t.replace(/(\bc=IN[^\r\n]+)/gi,"$1\r\nb=AS:".concat(r.max*e.KBitrate,"\r\nb=TIAS:").concat(r.max*e.KBitrate*850))}}),Object.defineProperty(e.prototype,"setVideosBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.videoStreams=this.videoStreams.map((function(r){return t.setVideoItemBitrate(r,e)})),this}}),Object.defineProperty(e.prototype,"setVideoBitrateWithStreamId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return this.videoStreams=this.videoStreams.map((function(n){return new RegExp("\\bmsid:".concat(t,"\\b"),"ig").test(n)?r.setVideoItemBitrate(n,e):n})),this}}),Object.defineProperty(e.prototype,"setVideoBitrateWithMid",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return this.videoStreams=this.videoStreams.map((function(n){return new RegExp("\\bmid:".concat(t,"\\b"),"ig").test(n)?r.setVideoItemBitrate(n,e):n})),this}}),Object.defineProperty(e.prototype,"setVideoItemBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){if(0===r.max&&/\ba=inactive\b/gi.test(t))return t;if(!/\bx-google-max-bitrate\b/.test(t)){var n=["$1","x-google-max-bitrate=".concat(r.max*e.KBitrate),"x-google-min-bitrate=".concat(r.min*e.KBitrate),"x-google-start-bitrate=".concat(r.start||r.max*e.KBitrate*.7)];t=t.replace(/(\bprofile-level-id=42[e0]01f\b)/gi,n.join(";"))}return this.addVideoBlineAS(t,r)}}),Object.defineProperty(e.prototype,"addVideoBlineAS",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return/\bb=AS:\d+\b/gi.test(t)?t:t.replace(/(\bc=IN[^\r\n]+)/gi,"$1\r\nb=AS:".concat(r.max*e.KBitrate,"\r\nb=TIAS:").concat(r.max*e.KBitrate*850))}}),Object.defineProperty(e.prototype,"clearnSsrcWithMid",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;return this.audioStreams=this.audioStreams.map((function(n){return new RegExp("\\bmid:".concat(e,"\\b"),"ig").test(n)?r.clearSSRC(n,t):n})),this.videoStreams=this.videoStreams.map((function(n){return new RegExp("\\bmid:".concat(e,"\\b"),"ig").test(n)?r.clearSSRC(n,t):n})),this}}),Object.defineProperty(e.prototype,"clearSSRC",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(t===Ao.SENDONLY&&/\ba=sendonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"");if(t===Ao.RECVONLY&&/\ba=recvonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"");if(t===Ao.INACTIVE&&/\ba=inactive\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"");return e}}),Object.defineProperty(e,"KBitrate",{enumerable:!0,configurable:!0,writable:!0,value:1}),e}(),Lo=function(){function e(){}return Object.defineProperty(e,"init",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._audioEncoder=e.encodeAudio,this._audioDecoder=e.decodeAudio,this._videoEncoder=e.encodeVideo,this._videoDecoder=e.decodeVideo,this._logger=t}}),Object.defineProperty(e,"isInit",{enumerable:!1,configurable:!0,writable:!0,value:function(){return!!(this._audioEncoder&&this._audioDecoder&&this._videoEncoder&&this._videoDecoder)}}),Object.defineProperty(e,"decodeAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(e){try{return this._audioDecoder(e)}catch(t){return this._logger.error(E.L_ENCRYPTOR_DECODE_E,null==t?void 0:t.message),console.error(t),e}}}),Object.defineProperty(e,"encodeAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(e){try{return this._audioEncoder(e)}catch(t){return this._logger.error(E.L_ENCRYPTOR_ENCODE_E,null==t?void 0:t.message),console.error(t),e}}}),Object.defineProperty(e,"decodeVideo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){try{return this._videoDecoder(e)}catch(t){return this._logger.error(E.L_ENCRYPTOR_DECODE_E,null==t?void 0:t.message),console.error(t),e}}}),Object.defineProperty(e,"encodeVideo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){try{return this._videoEncoder(e)}catch(t){return this._logger.error(E.L_ENCRYPTOR_ENCODE_E,null==t?void 0:t.message),console.error(t),e}}}),e}();!function(e){e[e.NB=0]="NB",e[e.MB=1]="MB",e[e.WB=2]="WB",e[e.SWB=3]="SWB",e[e.FB=4]="FB"}(Eo||(Eo={})),Eo.NB,Eo.NB,Eo.NB,Eo.NB,Eo.MB,Eo.MB,Eo.MB,Eo.MB,Eo.WB,Eo.WB,Eo.WB,Eo.WB,Eo.SWB,Eo.SWB,Eo.FB,Eo.FB,Eo.NB,Eo.NB,Eo.NB,Eo.NB,Eo.WB,Eo.WB,Eo.WB,Eo.WB,Eo.SWB,Eo.SWB,Eo.SWB,Eo.SWB,Eo.FB,Eo.FB,Eo.FB,Eo.FB;var Po,Ao,No=function(){function e(){}return Object.defineProperty(e,"splitSections",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.split("\nm=").map((function(e,t){var r=t>0?"m=".concat(e):e;return"".concat(r.trim(),"\r\n")}))}}),Object.defineProperty(e,"getMediaSections",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=e.splitSections(t);return r.shift(),r}}),Object.defineProperty(e,"parseExtmap",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}}}),Object.defineProperty(e,"splitLines",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.trim().split("\n").map((function(e){return e.trim()}))}}),Object.defineProperty(e,"parseMLine",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=e.splitLines(t)[0].substr(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}}}),Object.defineProperty(e,"matchPrefix",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return e.splitLines(t).filter((function(e){return 0===e.indexOf(r)}))}}),Object.defineProperty(e,"parseMsid",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r,n=e.matchPrefix(t,"a=msid:");if(1===n.length)return{stream:(r=n[0].substr(7).split(" "))[0],track:r[1]};var i=e.matchPrefix(t,"a=ssrc:").map((function(t){return e.parseSsrcMedia(t)})).filter((function(e){return"msid"===e.attribute}));return i.length>0&&i[0].value?{stream:(r=i[0].value.split(" "))[0],track:r[1]}:{stream:"",track:""}}}),Object.defineProperty(e,"parseSsrcMedia",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,t-7),10)},n=e.indexOf(":",t);return n>-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r}}),Object.defineProperty(e,"getMid",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=e.matchPrefix(t,"a=mid:")[0];if(r)return r.substr(6)}}),Object.defineProperty(e,"splitNaluData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=new Uint8Array(e),r=0;if(this.isIFrame(t)){var n=t.join(","),i=n.indexOf("0,0,0,1,101");-1===i&&(i=n.indexOf("0,0,0,1,37")),r=n.substring(0,i).split(",").length-1+4+8}else r=12;return{header:t.slice(0,r),payloadData:t.slice(r)}}}),Object.defineProperty(e,"deal0x03",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=[];return r="encode"===t?e.join(",").replaceAll(",0,0,1,",",0,0,3,1,").split(",").map((function(e){return Number(e)})):e.join(",").replaceAll(",0,0,3,1,",",0,0,1,").split(",").map((function(e){return Number(e)})),new Uint8Array(r)}}),Object.defineProperty(e,"isIFrame",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.join("").startsWith("0001103");return t||(t=e.join("").startsWith("000139")),t}}),Object.defineProperty(e,"parsePayloadTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=e.getMediaSections(t).find((function(t){return"audio"===e.parseMLine(t).kind}));if(r){var n=r.match(/a=rtpmap:(\d+)\s+(\S+)/g);n&&(e.payloadTypeCodecMap=n.map((function(e){var t=e.match(/a=rtpmap:(\d+)\s+(\w+)/);return t?{payloadType:Number(t[1]),codec:t[2]}:null})).filter((function(e){return!!e})))}}}),Object.defineProperty(e,"payloadTypeCodecMap",{enumerable:!0,configurable:!0,writable:!0,value:[]}),e}();!function(e){e.PLANB="plan-b",e.UNIFIEDPLAN="unified-plan"}(Po||(Po={})),function(e){e.SENDONLY="sendonly",e.RECVONLY="recvonly",e.INACTIVE="inactive"}(Ao||(Ao={}));var wo,Do,ko,Uo,Mo=function(){function e(e,t,r){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_peer",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_useEncrypt",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_outboundStreams",{enumerable:!0,configurable:!0,writable:!0,value:{}})}return Object.defineProperty(e,"setSdpSemantics",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=Bt.browser,n=Bt.version,i=Bt.supportsUnifiedPlan;if(t.info(E.L_A_SDP_STRATEGY_SET_SDP_SEMANTICS_O,JSON.stringify({sdpSemantics:e,supportsUnifiedPlan:i,browser:r,version:n})),i)return/chrome/i.test(r)?n?void(this._sdpSemantics=n>92?"unified-plan":n<72?"plan-b":e):void(this._sdpSemantics="unified-plan"):void(/firefox/i.test(r)?this._sdpSemantics="unified-plan":/safari/i.test(r)?this._sdpSemantics=n<12?"plan-b":"unified-plan":this._sdpSemantics="unified-plan");this._sdpSemantics="plan-b"}}),Object.defineProperty(e,"getSdpSemantics",{enumerable:!1,configurable:!0,writable:!0,value:function(){return e._sdpSemantics}}),Object.defineProperty(e.prototype,"getOutboundVideoInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[];for(var t in this._outboundStreams){var r=this._outboundStreams[t].getVideoTracks()[0];if(r){var n=/_tiny$/.test(t),i=yt(r),o=i.width,a=i.height;e.push({trackId:r.id,simulcast:n?so.TINY:so.NORMAL,resolution:"".concat(o,"x").concat(a)})}}return e}}),Object.defineProperty(e.prototype,"setRemoteAnswer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t;return y(this,(function(r){switch(r.label){case 0:e=Co.trimBlankLine(e),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._peer.setRemoteDescription({type:"answer",sdp:e})];case 2:return r.sent(),[3,4];case 3:return t=r.sent(),this._logger.info(E.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:I.FAILED,msg:t})),[2,O.SET_REMOTE_DESCRIPTION_FAILED];case 4:return this._logger.info(E.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:I.SUCCESSED,sdp:e})),[2,O.SUCCESS]}}))}))}}),Object.defineProperty(e.prototype,"getStatParsr",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return/chrome/i.test(Bt.browser)?new So(this,e,this._logger,t,r,n):/Firefox/i.test(Bt.browser)?new To(this,e,this._logger,t,r,n):/Safari/i.test(Bt.browser)?new yo(this,e,this._logger,t,r,n):null}}),Object.defineProperty(e.prototype,"getTrackIdByMid",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return null}}),Object.defineProperty(e.prototype,"resetSdp",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return Co.trimBlankLine(e)}}),Object.defineProperty(e.prototype,"_setupSenderTransform",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this._useEncrypt){var t=e.createEncodedStreams(),r=t.readable,n=t.writable,i=new TransformStream({transform:this._encodeRtpChunk.bind(this,e)});r.pipeThrough(i).pipeTo(n)}}}),Object.defineProperty(e.prototype,"_setupReceiverTransform",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this._useEncrypt){var t=e.createEncodedStreams(),r=t.readable,n=t.writable,i=new TransformStream({transform:this._decodeRtpChunk.bind(this,e)});r.pipeThrough(i).pipeTo(n)}}}),Object.defineProperty(e.prototype,"_encodeVideoFrame",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=No.splitNaluData(e),r=t.header,n=t.payloadData,i=Lo.encodeVideo(n),o=No.deal0x03(i,"encode");return new Uint8Array(P(P([],L(r),!1),L(o),!1)).buffer}}),Object.defineProperty(e.prototype,"_decodeVideoFrame",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=No.splitNaluData(e),r=t.header,n=t.payloadData,i=No.deal0x03(n,"decode"),o=Lo.decodeVideo(i);return new Uint8Array(P(P([],L(r),!1),L(o),!1)).buffer}}),Object.defineProperty(e.prototype,"_handleAudioREDFrame",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=function(e){for(var t=[],r=0;;){var n,i=!(e[r]>>7),o=127&e[r],a=void 0,s=void 0,c=void 0;if(i?(a=0,s=e.byteLength-(t.length>0?t.map((function(e){return 4+e.block.byteLength})).reduce((function(e,t){return e+t})):0)-1,c=e.slice(r,r+1),r+=1):(a=(e[r+1]<<6)+(e[r+2]>>2),s=((3&e[r+2])<<8)+e[r+3],c=e.slice(r,r+4),r+=4),n=new Uint8Array(s),t.push({timestampOffset:a,header:c,block:n,isPrimary:i,blockPType:o}),i)break}return t.forEach((function(t){var n=t.block.byteLength,i=e.slice(r,r+n);t.block.set(i),r+=n})),t}(new Uint8Array(e)),n=[],i=[],o=0;r.forEach((function(e){var r="decode"===t?Lo.decodeAudio(e.block):Lo.encodeAudio(e.block);if(r.byteLength!==e.block.byteLength&&!e.isPrimary){var a=L(e.header,4),s=a[2],c=a[3];s=(s>>2<<2)+r.byteLength>>8,c=255&r.byteLength,e.header=new Uint8Array([e.header[0],e.header[1],s,c])}e.block=r,o+=e.block.byteLength+e.header.byteLength,n.push(e.header),i.push(e.block)}));var a=new Uint8Array(o),s=0;return P(P([],L(n),!1),L(i),!1).forEach((function(e){a.set(e,s),s+=e.byteLength})),a.buffer}}),Object.defineProperty(e.prototype,"_handleOpusFrame",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=new Uint8Array(e);return("encode"===t?Lo.encodeAudio(r):Lo.decodeAudio(r)).buffer}}),Object.defineProperty(e.prototype,"_encodeRtpChunk",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._encodeVideoFrame(n);else{var i=t.getMetadata().payloadType,o=No.payloadTypeCodecMap.filter((function(e){return e.payloadType===i}))[0].codec;"red"===o?t.data=this._handleAudioREDFrame(n,"encode"):"opus"===o?t.data=this._handleOpusFrame(n,"encode"):console.error("Unsupport audio payloadType: ".concat(i,", codec: ").concat(o))}r.enqueue(t)}}),Object.defineProperty(e.prototype,"_decodeRtpChunk",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._decodeVideoFrame(n);else{var i=t.getMetadata().payloadType,o=No.payloadTypeCodecMap.filter((function(e){return e.payloadType===i}))[0].codec;"red"===o?t.data=this._handleAudioREDFrame(n,"decode"):"opus"===o?t.data=this._handleOpusFrame(n,"decode"):console.error("Unsupport audio payloadType: ".concat(i,", codec: ").concat(o))}r.enqueue(t)}}),e}(),jo=function(e){function t(t,r){var n=e.call(this,r,Po.PLANB,t)||this;return Object.defineProperty(n,"SDP",{enumerable:!0,configurable:!0,writable:!0,value:r}),n}return R(t,e),Object.defineProperty(t.prototype,"stringify",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[this.SDPHeader];P(P([],L(this.audioStreams),!1),L(this.videoStreams),!1).forEach((function(t){var r=t.match(/\ba=mid:(video|audio)\b/),n=Co.clearInactiveOrRecvonly(t);r&&r[1]===ze.AUDIO&&(e[1]=n),r&&r[1]===ze.VIDEO&&(e[2]=n)}));var t=e.join("");return Co.trimBlankLine(t)}}),Object.defineProperty(t.prototype,"setAudioBitrateWithStreamId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._logger.warn(E.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Audio Bitrate With Stream Id"),this}}),Object.defineProperty(t.prototype,"setVideoBitrateWithStreamId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._logger.warn(E.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Video Bitrate With Stream Id"),this}}),t}(Co),Bo=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return Object.defineProperty(t,"senders",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(t,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),t}return R(t,e),Object.defineProperty(t.prototype,"addLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._localTracks.every((function(t){return t.getTrackId()!==e.getTrackId()}))&&this._localTracks.push(e);var t=e.getStreamId(),r=e.__innerGetMediaStreamTrack(),n=this._outboundStreams[t]||(this._outboundStreams[t]=new MediaStream);n.getTracks().forEach((function(e){e.kind===r.kind&&n.removeTrack(e)})),n.addTrack(r);var i=e.getTrackId(),o=this.senders[i];o?o.replaceTrack(r):(this.senders[i]=this._peer.addTrack(r,n),Object.defineProperty(r,"trackId",{value:i,writable:!1,enumerable:!1,configurable:!1}))}}),Object.defineProperty(t.prototype,"removeLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._localTracks.findIndex((function(t){return t===e}));t>=0&&this._localTracks.splice(t,1);var r=e.getTrackId(),n=this.senders[r];n&&(n.replaceTrack(null),this._peer.removeTrack(n),delete this.senders[r])}}),Object.defineProperty(t.prototype,"updateSubRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){}}),Object.defineProperty(t.prototype,"updateRecvTransceiverMap",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){}}),Object.defineProperty(t.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){}}),Object.defineProperty(t.prototype,"createOffer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n;return y(this,(function(i){switch(i.label){case 0:return[4,this._peer.createOffer({iceRestart:e,offerToReceiveAudio:!0,offerToReceiveVideo:!0})];case 1:for(r in t=i.sent(),this._outboundStreams)n=this._outboundStreams[r].id,t.sdp=t.sdp.replace(new RegExp(n,"g"),r);return t.sdp&&(t.sdp=this.resetSdp(t.sdp)),[4,this._peer.setLocalDescription(t)];case 2:return i.sent(),[2,{type:"offer",semantics:"plan-b",sdp:t.sdp}]}}))}))}}),Object.defineProperty(t.prototype,"setRemoteAnswer",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t=this.resetSdp(t),e.prototype.setRemoteAnswer.call(this,t)}}),Object.defineProperty(t.prototype,"_getMaxRangeBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._localTracks.filter((function(t){return e===We.AUDIO_ONLY?t.isAudioTrack():t.isVideoTrack()})),r={max:0,min:0};return t.forEach((function(e){var t=e.getBitrate(),n=t.min,i=t.max,o=t.start;r.max=r.max<i?i:r.max,r.min=r.min>n?n:r.min,r.max===i?r.start=o:r.start=.7*r.max})),r}}),Object.defineProperty(t.prototype,"resetSdp",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=new jo(this._logger,e),r=this._getMaxRangeBitrate(We.VIDEO_ONLY),n=this._getMaxRangeBitrate(We.AUDIO_ONLY);return t.setAudiosBitrate(n),t.setVideosBitrate(r),t.stringify()}}),t}(Mo),xo=function(e){function t(t,r){return e.call(this,r,Po.UNIFIEDPLAN,t)||this}return R(t,e),Object.defineProperty(t.prototype,"stringify",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[this.SDPHeader];P(P([],L(this.audioStreams),!1),L(this.videoStreams),!1).forEach((function(t){var r=t.match(/\ba=mid:(\d+)\b/);r&&r[1]&&(e[+r[1]+1]=t)})),this.SDPHeader="",this.videoStreams=[],this.audioStreams=[];var t=e.join("");return Co.trimBlankLine(t)}}),t}(Co),Vo=function(){function e(){Object.defineProperty(this,"__streams",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}return Object.defineProperty(e,"getInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(){return e.instance||(e.instance=new e),e.instance}}),Object.defineProperty(e.prototype,"push",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.__streams.set(e,t),t}}),Object.defineProperty(e.prototype,"pickup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.__streams.get(e)}}),Object.defineProperty(e.prototype,"delete",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.__streams.delete(e)}}),Object.defineProperty(e.prototype,"streams",{get:function(){var e,t,r=new Map;try{for(var n=C(this.__streams.keys()),i=n.next();!i.done;i=n.next()){var o=i.value;r.set(o,this.pickup(o))}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},enumerable:!1,configurable:!0}),e}(),Fo=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return Object.defineProperty(t,"_sendTransceiver",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(t,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(t,"_recvAudio",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(t,"_recvVideo",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(t,"_recvTransceiver",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(t,"_subedTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(t,"midMsid",{enumerable:!0,configurable:!0,writable:!0,value:{}}),t}return R(t,e),Object.defineProperty(t.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.warn(E.L_FUNCTION_IS_UNAVAILABLE,"the interface named `setBitrate` is invalid while sdpSemantics value is `unified-plan`")}}),Object.defineProperty(t.prototype,"getTrackIdByMid",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t in this._sendTransceiver){if(this._sendTransceiver[t].mid===e)return t}for(var t in this._recvTransceiver){if(this._recvTransceiver[t].mid===e)return t}return null}}),Object.defineProperty(t.prototype,"addLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=e.getTrackId(),n=e.getStreamId(),i=e.__innerGetMediaStreamTrack();this._localTracks[r]=e;var o=this._outboundStreams[n]||(this._outboundStreams[n]=new MediaStream);o.getTracks().forEach((function(e){e.kind===i.kind&&o.removeTrack(e)})),o.addTrack(i);var a=this._sendTransceiver[r];if(a)a.sender.replaceTrack(i),a.direction="sendonly";else{var s=this._sendTransceiver[r]=this._peer.addTransceiver(i,{direction:"sendonly",streams:[o]});this._setupSenderTransform(s.sender)}Vo.getInstance().push(r,{msid:n,id:this._outboundStreams[n].id,kind:null===(t=e.streamTrack)||void 0===t?void 0:t.kind})}}),Object.defineProperty(t.prototype,"removeLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.getTrackId(),r=e.getStreamId();delete this._localTracks[t];var n=this._sendTransceiver[t];if(n){"closed"!==this._peer.connectionState&&(n.direction="inactive",this._peer.removeTrack(n.sender),n.sender.replaceTrack(null));var i=this._outboundStreams[r];(e.isAudioTrack()?i.getAudioTracks():i.getVideoTracks()).forEach((function(e){return i.removeTrack(e)}));var o=this._sendTransceiver["".concat(t,"_tiny")];if(o&&"inactive"!==o.direction&&"closed"!==this._peer.connectionState){o.direction="inactive";var a=o.sender,s=a.track;this._peer.removeTrack(a),a.replaceTrack(null),this._outboundStreams["".concat(r,"_tiny")].removeTrack(s),s.stop()}}}}),Object.defineProperty(t.prototype,"updateRecvTransceiverMap",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=Pt(e).mediaType;this._recvTransceiver[e]=t;var n=r===We.AUDIO_ONLY?this._recvAudio:this._recvVideo,i=n.findIndex((function(e){return e===t}));i>=0&&n.splice(i,1)}}),Object.defineProperty(t.prototype,"updateSubRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=e.slice(),n=this._subedTracks.slice();this._subedTracks=e.slice();for(var i=function(e){var t=r[e],i=n.findIndex((function(e){return e===t}));i>=0&&(r.splice(e,1),n.splice(i,1))},o=r.length-1;o>=0;o-=1)i(o);n.length&&n.forEach((function(e){var r=e.getTrackId();e.__innerSetMediaStreamTrack(void 0);var n=t._recvTransceiver[r];n&&(n.direction="inactive")}));var a={audio:0,video:0};r.length&&r.forEach((function(e){var r=e.isAudioTrack()?"audio":"video",n=t._recvTransceiver[e.getTrackId()];n?n.direction="recvonly":a[r]+=1}));for(o=this._recvAudio.length;o<a.audio;o+=1){var s=this._peer.addTransceiver("audio",{direction:"recvonly"});this._recvAudio.push(s),this._setupReceiverTransform(s.receiver)}for(o=this._recvVideo.length;o<a.video;o+=1){s=this._peer.addTransceiver("video",{direction:"recvonly"});this._recvVideo.push(s),this._setupReceiverTransform(s.receiver)}}}),Object.defineProperty(t.prototype,"createOffer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n,i;return y(this,(function(o){switch(o.label){case 0:return[4,this._peer.createOffer({iceRestart:e})];case 1:for(n in t=o.sent(),r=t.sdp,this._outboundStreams)i=this._outboundStreams[n].id,r=r.replace(new RegExp(i,"g"),n);return r=(r=this.resetOfferSdp(r)).replace(/(a=ice-options:trickle)/g,"$1\r\na=ice-options:renomination"),t.sdp=r,[4,this._peer.setLocalDescription(t)];case 2:return o.sent(),[2,{type:"offer",semantics:"unified-plan",sdp:r}]}}))}))}}),Object.defineProperty(t.prototype,"setRemoteAnswer",{enumerable:!1,configurable:!0,writable:!0,value:function(t){t=this.resetAnswerSdp(t);var r=/[\r\n]+\r\n[\r\n]+/g;return r.test(t)&&(t=t.replace(r,"\r\n")),e.prototype.setRemoteAnswer.call(this,t)}}),Object.defineProperty(t.prototype,"_genarateMid",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=null;return No.getMediaSections(e).forEach((function(e){No.parseExtmap(e);var i=No.parseMLine(e).kind,o=No.parseMsid(e).stream,a=No.getMid(e);"video"===r?/tiny$/.test(o)?o=o.replace(/tiny$/gi,"1_tiny"):o+="_1":o+="_0",o===t&&r===i&&a&&(n=a)})),n}}),Object.defineProperty(t.prototype,"_setSenderTransceiverBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=this._localTracks[t],o=null==i?void 0:i.getBitrate();n===ze.AUDIO&&o&&e.setAudioBitrateWithMid(o,r),n===ze.VIDEO&&o&&e.setVideoBitrateWithMid(o,r)}}),Object.defineProperty(t.prototype,"_resetSenderTransceiver",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;for(var n in this._sendTransceiver){var i=this._sendTransceiver[n],o=null===(r=i.sender.track)||void 0===r?void 0:r.kind,a=i.direction,s=i.mid;s||(s=this._genarateMid(e,n,o)),s&&(a===Ao.SENDONLY&&this._setSenderTransceiverBitrate(t,n,s,o),a===Ao.INACTIVE&&t.clearnSsrcWithMid(s,Ao.INACTIVE))}}}),Object.defineProperty(t.prototype,"_resetRecvTransceiver",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t in this._recvTransceiver){var r=this._recvTransceiver[t],n=r.direction,i=r.mid;i&&n===Ao.INACTIVE&&e.clearnSsrcWithMid(i,Ao.RECVONLY)}}}),Object.defineProperty(t.prototype,"resetOfferSdp",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=new xo(this._logger,e);return this._resetSenderTransceiver(e,t),this._resetRecvTransceiver(t),t.stringify()}}),Object.defineProperty(t.prototype,"resetAnswerSdp",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=new xo(this._logger,e);for(var n in this._sendTransceiver){var i=this._sendTransceiver[n],o=i.mid;if(o){var a=this._localTracks[n],s=null==a?void 0:a.getBitrate(),c=null===(t=i.sender.track)||void 0===t?void 0:t.kind;c===ze.AUDIO&&s&&r.setAudioBitrateWithMid(s,o),c===ze.VIDEO&&s&&r.setVideoBitrateWithMid(s,o)}}return r.stringify()}}),t}(Mo),Jo=function(e){function t(t,r,n,i,o,a,s){void 0===a&&(a=!1),void 0===s&&(s=!1);var c=e.call(this)||this;Object.defineProperty(c,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(c,"_reTryExchange",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(c,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(c,"_store",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(c,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(c,"_isRoomAudience",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(c,"_rtcPeerConn",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(c,"_sdpStrategy",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(c,"reportParser",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(c,"pubLocalTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(c,"_reTryExchangeTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(c,"_reportStatsTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(c,"_reportR3R4ToPolarisTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(c,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(c,"_formatStatsData",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(c,"_inRetry",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(c,"_firstConnectFromPub",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(c,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:null});var u=Mo.getSdpSemantics(),l="unified-plan"===u&&s&&"function"==typeof RTCRtpSender.prototype.createEncodedStreams&&"function"==typeof RTCRtpReceiver.prototype.createEncodedStreams&&Lo.isInit(),_=c._rtcPeerConn=new RTCPeerConnection({sdpSemantics:u,encodedInsertableStreams:l});return c._sdpStrategy="plan-b"===u?new Bo(c._logger,_,!1):new Fo(c._logger,_,l),c._rtcPeerConn.oniceconnectionstatechange=c._onICEConnectionStateChange.bind(c),c._rtcPeerConn.onconnectionstatechange=c._onConnectionStateChange.bind(c),c._rtcPeerConn.ontrack=c._onTrackReady.bind(c),c.reportParser=c._sdpStrategy.getStatParsr(c._rtcPeerConn,u,c._currentUserId,c._store),c}return R(t,e),Object.defineProperty(t.prototype,"getLocalTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Object.values(this.pubLocalTracks)}}),Object.defineProperty(t.prototype,"_onConnectionStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._logger.info(E.L_RTC_PEER_CONNECTION_CONNECTION_STATE_S,"state: ".concat(this._rtcPeerConn.connectionState))}}),Object.defineProperty(t.prototype,"startAutoExecute",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this.stopAutoExecute(),this._reportStatsTimer=setTimeout((function(){t._reportHandle(),t.startAutoExecute(e)}),e)}}),Object.defineProperty(t.prototype,"stopAutoExecute",{enumerable:!1,configurable:!0,writable:!0,value:function(){clearTimeout(this._reportStatsTimer)}}),Object.defineProperty(t.prototype,"_onICEConnectionStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,r;return T(this,void 0,void 0,(function(){var n,i,o;return y(this,(function(a){switch(a.label){case 0:return n=this._rtcPeerConn.iceConnectionState,this._logger.info(E.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_S,JSON.stringify({iceConnectionState:n})),[4,this._getStatsData()];case 1:i=a.sent(),o=i?this._createRCRTCStateReport(i).iceCandidatePair:null,this.emit(t.__INNER_ICE_STATE_CHANGE__,{status:n,time:Date.now(),iceCandidatePair:o}),"connected"===n?(this.emit(t.__INNER_ICE_CONNECTED__,this._firstConnectFromPub),this.startAutoExecute(1e3)):"failed"!==n&&"disconnected"!==n||this._handleRetry();try{null===(r=null===(e=this._reportListener)||void 0===e?void 0:e.onICEConnectionStateChange)||void 0===r||r.call(e,n)}catch(e){this._logger.error(E.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_REPORT_R,JSON.stringify({status:I.FAILED,mag:e}))}return[2]}}))}))}}),Object.defineProperty(t.prototype,"_handleRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(){return T(this,void 0,void 0,(function(){var e,t=this;return y(this,(function(r){switch(r.label){case 0:return this._inRetry?[2]:(this.clearReTryExchangeTimer(),this._inRetry=!0,[4,this._reTryExchange()]);case 1:return e=r.sent().code,this._inRetry=!1,e===O.SUCCESS?[2]:(this._reTryExchangeTimer=setTimeout((function(){return t._handleRetry()}),15e3),[2])}}))}))}}),Object.defineProperty(t.prototype,"_onTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.streams.length){var r=e.streams[0].id,n=e.receiver.track,i=[r,"audio"===n.kind?We.AUDIO_ONLY:We.VIDEO_ONLY].join("_");Object.defineProperty(n,"trackId",{value:i,writable:!1,enumerable:!1,configurable:!1}),this._updateRecvTransceiverMap(i,e.transceiver),this.emit(t.__INNER_EVENT_TRACK_READY__,e)}}}),Object.defineProperty(t.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){return y(this,(function(n){return this._sdpStrategy.setBitrate(e,t,r),this._logger.info(E.L_RTC_PEER_CONNECTION_SET_BITRATE_O,JSON.stringify({status:I.SUCCESSED,max:e,min:t,start:r})),[2]}))}))}}),Object.defineProperty(t.prototype,"createOffer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t;return y(this,(function(r){switch(r.label){case 0:return[4,this._sdpStrategy.createOffer(e)];case 1:return t=r.sent(),this._logger.info(E.L_RTC_PEER_CONNECTION_CREATE_OFFER_O,JSON.stringify({offerSDP:t.sdp,sdpDemantics:t.semantics})),[2,t]}}))}))}}),Object.defineProperty(t.prototype,"setRemoteAnswer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return void 0===t&&(t=!1),T(this,void 0,void 0,(function(){return y(this,(function(n){return No.parsePayloadTypes(null===(r=this._rtcPeerConn.localDescription)||void 0===r?void 0:r.sdp),this._firstConnectFromPub=t,[2,this._sdpStrategy.setRemoteAnswer(e)]}))}))}}),Object.defineProperty(t.prototype,"getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.pubLocalTracks[e]||null}}),Object.defineProperty(t.prototype,"addLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.pubLocalTracks[e.getTrackId()]=e,this._sdpStrategy.addLocalTrack(e),e.off(ut.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(ut.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.on(ut.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(ut.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),this._logger.info(E.L_RTC_PEER_CONNECTION_ADD_LOCAL_TRACK_O,"trackId: ".concat(e.getTrackId()))}}),Object.defineProperty(t.prototype,"removeLocalTrackById",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getLocalTrack(e);t?(this._logger.info(E.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:I.SUCCESSED,trackId:e})),this.removeLocalTrack(t)):this._logger.warn(E.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:I.FAILED,msg:"track not found",trackId:e}))}}),Object.defineProperty(t.prototype,"removeAllLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;Object.keys(this.pubLocalTracks).forEach((function(t){/_tiny$/.test(t)||e.removeLocalTrackById(t)}))}}),Object.defineProperty(t.prototype,"removeLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.getTrackId();delete this.pubLocalTracks[t],this._sdpStrategy.removeLocalTrack(e),e.__innerSetPublished(!1),e.off(ut.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(ut.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this);var r="".concat(t,"_tiny"),n=this.getLocalTrack(r);n&&(this._sdpStrategy.removeLocalTrack(n),delete this.pubLocalTracks[r],n.destroy()),this._logger.info(E.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_O,JSON.stringify({trackId:t}))}}),Object.defineProperty(t.prototype,"_updateRecvTransceiverMap",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._sdpStrategy.updateRecvTransceiverMap(e,t)}}),Object.defineProperty(t.prototype,"updateSubRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._sdpStrategy.updateSubRemoteTracks(e)}}),Object.defineProperty(t.prototype,"getOutboundVideoInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._sdpStrategy.getOutboundVideoInfo()}}),Object.defineProperty(t.prototype,"_onLocalTrackMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.getLocalTrack("".concat(e.getTrackId(),"_tiny"));r&&(r.__innerGetMediaStreamTrack().enabled=!e.isLocalMuted()),this.emit(ut.__INNER_EVENT_MUTED_CHANGE__,e,t)}}),Object.defineProperty(t.prototype,"_onLocalTrackDestroied",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.emit(ut.__INNER_EVENT_DESTROY__,e)}}),Object.defineProperty(t.prototype,"registerReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._reportListener=e}}),Object.defineProperty(t.prototype,"_createSenderReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.filter((function(e){return e.trackId})).map((function(e){var t={trackId:e.trackId,kind:e.kind,packetsLostRate:e.packetsLostRate,remoteResource:e.remoteResource,bitrate:e.bitrate,jitter:e.jitter,rtt:e.rtt};return(e.audioLevel||0===e.audioLevel)&&(t.audioLevel=e.audioLevel),e.frameWidth&&(t.frameWidth=e.frameWidth),e.frameHeight&&(t.frameHeight=e.frameHeight),e.frameRate&&(t.frameRate=e.frameRate),S({},t)}))}}),Object.defineProperty(t.prototype,"_createReceiverReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.filter((function(e){return e.trackId})).map((function(e){var t={trackId:e.trackId,kind:e.kind,packetsLostRate:e.packetsLostRate,remoteResource:e.remoteResource,bitrate:e.bitrate,jitter:e.jitter,rtt:e.rtt};return(e.audioLevel||0===e.audioLevel)&&(t.audioLevel=e.audioLevel),e.frameWidth&&(t.frameWidth=e.frameWidth),e.frameHeight&&(t.frameHeight=e.frameHeight),e.frameRate&&(t.frameRate=e.frameRate),S({},t)}))}}),Object.defineProperty(t.prototype,"_createRCRTCStateReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.timestamp,r=e.iceCandidatePair,n=e.senders,i=e.receivers;for(var o in(null==r?void 0:r.totalPacketsLost)&&(null==r||delete r.totalPacketsLost),r)Gt(r[o])&&delete r[o];return{timestamp:t,iceCandidatePair:r,senders:this._createSenderReport(n),receivers:this._createReceiverReport(i)}}}),Object.defineProperty(t.prototype,"_getStatsData",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t;return T(this,void 0,void 0,(function(){var r,n,i;return y(this,(function(o){switch(o.label){case 0:return this._formatStatsData=null,r=null,[4,this._rtcPeerConn.getStats()];case 1:return n=o.sent(),r=null===(e=this.reportParser)||void 0===e?void 0:e.parseRTCStatsReport(n),i=null===(t=this.reportParser)||void 0===t?void 0:t.formatRCRTCStateReport(r),this._formatStatsData=i,[2,i]}}))}))}}),Object.defineProperty(t.prototype,"_reportHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,r,n,i,o;return T(this,void 0,void 0,(function(){var a,s,c,u;return y(this,(function(l){switch(l.label){case 0:return[4,this._getStatsData()];case 1:if(!(a=l.sent()))return[2];s=this._createRCRTCStateReport(a);try{null===(r=null===(e=this._reportListener)||void 0===e?void 0:e.onStateReport)||void 0===r||r.call(e,JSON.parse(JSON.stringify(s)))}catch(e){this._logger.error(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}if(c=P(P([],L(a.receivers),!1),L(a.senders),!1).filter((function(e){return"audio"===e.kind})).map((function(e){return{trackId:e.trackId,audioLevel:e.audioLevel}})),this.emit(t.__INNER_AUDIOLEVEL_CHANGE__,c),this._isRoomAudience&&(null===(n=this._reportListener)||void 0===n?void 0:n.onReportLiveAudioStates)){u=this._getLiveAudioState();try{u.length&&(null===(o=null===(i=this._reportListener)||void 0===i?void 0:i.onReportLiveAudioStates)||void 0===o||o.call(i,u))}catch(e){this._logger.error(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}return[2]}}))}))}}),Object.defineProperty(t.prototype,"_getLiveAudioState",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=[];return this._rtcPeerConn.getReceivers().forEach((function(e){var r=e.getContributingSources();r.length&&t.push.apply(t,P([],L(r),!1))})),t.map((function(t){var r=t.source,n=t.audioLevel,i=e._store.getTrackIdBySSRC(r);if(!i)return{};var o=Pt(i).userId;return{audioLevel:vo(n),userId:o,trackId:i}})).filter((function(e){return!!e.userId}))}}),Object.defineProperty(t.prototype,"_sendR3R4Data",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t,r,n;return T(this,void 0,void 0,(function(){var i,o,a;return y(this,(function(s){switch(s.label){case 0:return(i=this._formatStatsData)?(o=i.senders,a=i.receivers,console.log("sendR3R4: senderTrackId: ".concat(null===(e=o[0])||void 0===e?void 0:e.trackId,", receiverTrackId: ").concat(null===(t=a[0])||void 0===t?void 0:t.trackId)),o.length?[4,null===(r=this._polarisReport)||void 0===r?void 0:r.sendR3Data(i)]:[3,2]):[2];case 1:s.sent(),s.label=2;case 2:return a.length?[4,null===(n=this._polarisReport)||void 0===n?void 0:n.sendR4Data(i)]:[3,4];case 3:s.sent(),s.label=4;case 4:return o.length=0,a.length=0,i=null,[2]}}))}))}}),Object.defineProperty(t.prototype,"__reportR3R4ToPolaris",{enumerable:!1,configurable:!0,writable:!0,value:function(){return T(this,void 0,void 0,(function(){var e=this;return y(this,(function(t){return this._isDestroyed||(clearTimeout(this._reportR3R4ToPolarisTimer),this._reportR3R4ToPolarisTimer=setTimeout((function(){return T(e,void 0,void 0,(function(){var e=this;return y(this,(function(t){return this._isDestroyed||this._sendR3R4Data().then((function(){e.__reportR3R4ToPolaris()})),[2]}))}))}),2e3)),[2]}))}))}}),Object.defineProperty(t.prototype,"getRTCPeerConn",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._rtcPeerConn}}),Object.defineProperty(t.prototype,"destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.clear(),this.clearReTryExchangeTimer(),clearTimeout(this._reportR3R4ToPolarisTimer),this.stopAutoExecute(),this.registerReportListener(null),this._rtcPeerConn.close(),this._isDestroyed=!0,this.reportParser=null,this._logger.info(E.L_RTC_PEER_CONNECTION_DESTROY_O,JSON.stringify({status:I.SUCCESSED}))}}),Object.defineProperty(t.prototype,"clearReTryExchangeTimer",{enumerable:!1,configurable:!0,writable:!0,value:function(){clearTimeout(this._reTryExchangeTimer),this._reTryExchangeTimer=null}}),Object.defineProperty(t.prototype,"isDestroyed",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isDestroyed}}),Object.defineProperty(t,"__INNER_EVENT_TRACK_READY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-track-ready"}),Object.defineProperty(t,"__INNER_AUDIOLEVEL_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-audio-level-change"}),Object.defineProperty(t,"__INNER_ICE_STATE_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-ice-state-change"}),Object.defineProperty(t,"__INNER_ICE_CONNECTED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-ice-connected"}),t}(t),Go=function(){function e(e,t){Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_peer",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_audioLevelChangeHandler",{enumerable:!0,configurable:!0,writable:!0,value:null})}return Object.defineProperty(e.prototype,"audioLevelReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;if(this._audioLevelChangeHandler){var r=[];e.forEach((function(e){var n=Pt(e.trackId).userId,i=t._store.crtUserId===n?t._peer.getLocalTrack(e.trackId):t._store.getRemoteTrack(e.trackId);i&&r.push({track:i,audioLevel:e.audioLevel||0})})),this._audioLevelChangeHandler(r)}}}),Object.defineProperty(e.prototype,"onAudioLevelChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._audioLevelChangeHandler=e}}),e}();!function(e){e[e.ANCHOR=1]="ANCHOR",e[e.AUDIENCE=2]="AUDIENCE"}(wo||(wo={})),function(e){e.UNPUBLISH_PREV="UnpublishPrevCommand",e.PULL_RTCROOM_STATUS="PullRTCRoomStatusCommand",e.JOINROOM="JoinRoomCommand",e.PARSE_REMOTERES="ParseRemoteResCommand",e.PARSE_USERSTATE="ParseUserStateCommand",e.LOCAL_TRACK_MUTE="LocalTrackMuteCommand",e.PUBLISH="PublishCommand",e.RETRY_EXCHANGE="RetryExchangeCommand",e.UNPUBLISH="UnpublishCommand",e.SUBSCRIBE="SubscribeCommand",e.UNSUBSCRIBE="UnsubscribeCommand",e.UPDATE_SUBSCRIBE_LIST="UpdateSubscribeListCommand",e.ON_SIGNAL_RECONNECTED="OnSignalReconnectedCommand",e.LEAVE_OTHER_ROOM="LeaveOtherRoomCommand",e.RTC_IDENTITY_CHANGE="RTCIdentityChangeCommand",e.ENABLE_INNER_CDN="EnableInnerCDNCommand",e.EXCHANGE_WITH_PUSH_OTHER_ROOM="ExchangeWithPushOtherRoomCommand",e.MCUCONFIG_FLUSH="MCUConfigFlushCommand",e.UNKNOWN="Unknown"}(Do||(Do={})),function(e){e[e.LOW=0]="LOW",e[e.NORMAL=1]="NORMAL",e[e.HIGH=2]="HIGH"}(ko||(ko={})),function(e){e[e.Destroy=40400]="Destroy"}(Uo||(Uo={}));var Ho,Ko=function(){function e(){}return Object.defineProperty(e.prototype,"priority",{get:function(){return ko.LOW},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"kind",{get:function(){return Do.UNKNOWN},enumerable:!1,configurable:!0}),e}(),Wo=function(){function e(e,t,r,n){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"abortCode",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_queue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_busy",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1})}return Object.defineProperty(e.prototype,"_next",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._busy=!1,this._execute()}}),Object.defineProperty(e.prototype,"_execute",{enumerable:!1,configurable:!0,writable:!0,value:function(){return T(this,void 0,void 0,(function(){var e,t,r,n,o,a,s;return y(this,(function(c){switch(c.label){case 0:if(this._isDestroyed||this._busy||0===this._queue.length)return[2];this._busy=!0,e=this._queue.shift(),t=e.command,r=e.resolve,o=this._logger.createTraceId(),c.label=1;case 1:return c.trys.push([1,3,,4]),this._logger.info(E.L_INVOKER_EXECUTE_T,"kind: ".concat(t.kind,", length: ").concat(this._queue.length),o),[4,t.execute(this._context,this._store,this)];case 2:return n=c.sent(),[3,4];case 3:return a=c.sent(),console.error(a),this._logger.error(E.L_INVOKER_EXECUTE_R,t.kind,o),this._next(),[2];case 4:return(s=n.code)!==O.SUCCESS&&s!==i.SUCCESS?this._logger.warn(E.L_INVOKER_EXECUTE_R,"code: ".concat(s,", kind: ").concat(t.kind),o):this._logger.info(E.L_INVOKER_EXECUTE_R,"kind: ".concat(t.kind,", Done"),o),r(n),this._next(),[2]}}))}))}}),Object.defineProperty(e.prototype,"push",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t=this;return y(this,(function(r){return[2,new Promise((function(r){if(t._logger.info(E.L_INVOKER_PUSH_O,JSON.stringify({isDestroyed:t._isDestroyed,kind:e.kind,length:t._queue.length})),t._isDestroyed)r({code:O.NOT_IN_ROOM});else{var n=e.priority;if(n===ko.LOW)t._queue.push({command:e,resolve:r});else{var i=t._queue.findIndex((function(e){return e.command.priority<n})),o=-1===i?t._queue.length-1:i;t._queue.splice(o,0,{command:e,resolve:r})}setTimeout((function(){t._execute()}),0)}}))]}))}))}}),Object.defineProperty(e.prototype,"isDestroyed",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isDestroyed}}),Object.defineProperty(e.prototype,"destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._isDestroyed||(this._logger.info(E.L_INVOKER_DESTROY_O),this._isDestroyed=!0,this._queue.forEach((function(t){t.resolve({code:e.abortCode})})),this._queue.length=0)}}),e}(),Yo=function(e){function t(t,r){return e.call(this,t.logger,t,r,O.ROOM_HAS_BEEN_DESTROYED)||this}return R(t,e),Object.defineProperty(t.prototype,"store",{get:function(){return this._context.store},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){e.prototype.destroy.call(this),this._store.removeRemoteTracks()}}),t}(Wo),zo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return R(t,e),Object.defineProperty(t.prototype,"_updateTrackIdSSRCMap",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;Object.values(this._roomResources).forEach((function(t){t.forEach((function(t){var r=JSON.parse(t.uri),n=r.ssrc,i=r.resourceId;e._trackIdSSRCMap.set(n,i)}))}))}}),Object.defineProperty(t.prototype,"setTrackIdSSRCMap",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._trackIdSSRCMap.set(e,t)}}),Object.defineProperty(t.prototype,"_initRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;for(var t in this._roomResources){var r=this._roomResources[t];t!==this.crtUserId&&0!==r.length&&r.forEach((function(t){var r=Lt(t),n=Pt(r),i=n.tag,o=n.userId,a=n.mediaType===We.AUDIO_ONLY?new Rt(e._logger,i,o):new Ot(e._logger,i,o);a.__innerSetRemoteMuted(0===t.state),e._remoteTracks[r]=a}))}}}),Object.defineProperty(t.prototype,"initWithRoomData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._sessionId=e.sessionId,this._token=e.token,this._roomStatusVersion=Yt(e.version),this._roomResources=Kt(e,this.roomId,this._logger,t),this._updateTrackIdSSRCMap(),this._initRemoteTracks(),this.setResourcesByUserId(this.crtUserId,this.getResourcesByUserId(this.crtUserId)||[]),this._logger.info(E.L_PARSE_ROOMDATA_URIS_R,"room data -> ".concat(JSON.stringify(this._roomResources)),t)}}),Object.defineProperty(t.prototype,"assignRoomData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){Object.assign(this._roomResources,e),this._updateTrackIdSSRCMap()}}),Object.defineProperty(t.prototype,"setResourcesByUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._roomResources[e]=t,this._updateTrackIdSSRCMap()}}),Object.defineProperty(t.prototype,"removeRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){delete this._remoteTracks[e]}}),Object.defineProperty(t.prototype,"removeResourcesByUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){delete this._roomResources[e],this._updateTrackIdSSRCMap()}}),Object.defineProperty(t.prototype,"addRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._remoteTracks[e.getTrackId()]=e}}),Object.defineProperty(t.prototype,"removeRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=Object.values(this._remoteTracks);e.length&&(e.forEach((function(e){e.isAudioTrack()&&e.__releaseMediaElement()})),this._remoteTracks={})}}),Object.defineProperty(t.prototype,"setCDNEnabel",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._CDNEnable=e}}),Object.defineProperty(t.prototype,"setCDNUris",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._CDNUris=e}}),Object.defineProperty(t.prototype,"resetSubscribedList",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;(t=this._subscribedList).splice.apply(t,P([0,this._subscribedList.length],L(e),!1)),this.resetCollectSubscribeList(e)}}),Object.defineProperty(t.prototype,"resetCollectSubscribeList",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;(t=this._collectSubscribeList).splice.apply(t,P([0,this._collectSubscribeList.length],L(e),!1))}}),Object.defineProperty(t.prototype,"setRoomStatusVersion",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._roomStatusVersion=Yt(e)}}),t}(function(){function e(e,t,r,n,i,o,a,s){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"appkey",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"roomMode",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"isUpgrade",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"isMainRoom",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_roomResources",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_remoteTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_subscribedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_collectSubscribeList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_token",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_CDNUris",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_CDNEnable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_trackIdSSRCMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_roomStatusVersion",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_supportNtf",{enumerable:!0,configurable:!0,writable:!0,value:!0})}return Object.defineProperty(e.prototype,"getResourcesByUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._roomResources[e]}}),Object.defineProperty(e.prototype,"getRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._remoteTracks[e]}}),Object.defineProperty(e.prototype,"getRemoteTracksByUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=[];for(var r in this._remoteTracks){var n=this._remoteTracks[r];n.getUserId()===e&&t.push(n)}return t}}),Object.defineProperty(e.prototype,"getRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._remoteTracks}}),Object.defineProperty(e.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._sessionId}}),Object.defineProperty(e.prototype,"getAllUserIds",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Object.keys(this._roomResources)}}),Object.defineProperty(e.prototype,"getRemoteUserIds",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;return this.getAllUserIds().filter((function(t){return t!==e.crtUserId}))}}),Object.defineProperty(e.prototype,"getSubscribedList",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subscribedList}}),Object.defineProperty(e.prototype,"getCollectSubscribeList",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._collectSubscribeList}}),Object.defineProperty(e.prototype,"getPublishedResourceByTrackId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=Pt(e).userId;return this._roomResources[t].find((function(t){return Lt(t)===e}))}}),Object.defineProperty(e.prototype,"getToken",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._token}}),Object.defineProperty(e.prototype,"getCDNEnable",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._CDNEnable}}),Object.defineProperty(e.prototype,"getCDNUris",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._CDNUris}}),Object.defineProperty(e.prototype,"getRoomStatusVersion",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._roomStatusVersion}}),Object.defineProperty(e.prototype,"getTrackIdBySSRC",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._trackIdSSRCMap.get(e)}}),Object.defineProperty(e.prototype,"getRTCRequestHeader",{enumerable:!1,configurable:!0,writable:!0,value:function(){return{"App-Key":this.appkey,RoomId:this.roomId,Token:this._token,RoomType:this.roomMode,UserId:this.crtUserId,"Client-Session-Id":this.clientSessionId}}}),Object.defineProperty(e.prototype,"getSupportNtf",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._supportNtf}}),e}()),qo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.UNPUBLISH_PREV},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n,o,a,s,c;return y(this,(function(u){switch(u.label){case 0:return r=e.logger,n=e.context,o=t.getResourcesByUserId(t.crtUserId),a=o.slice(),o.length=0,s=r.createTraceId(),r.info(E.L_UNPUBLISH_PREV_COMMAND_T,JSON.stringify({resource:a}),s),[4,n.setRTCTotalRes(t.roomId,[Et(Ft.UNPUBLISH,a)],It([]),Ft.TOTAL_CONTENT_RESOURCE,It([]))];case 1:return(c=u.sent())!==i.SUCCESS?r.error(E.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:I.FAILED,code:c}),s):r.info(E.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:I.SUCCESSED}),s),[2,{code:O.SUCCESS}]}}))}))}}),t}(Ko);!function(e){e[e.RTC=0]="RTC",e[e.LIVE=2]="LIVE",e[e.CROSS_MUTI=7]="CROSS_MUTI",e[e.SIP=4]="SIP",e[e.CALL=5]="CALL"}(Ho||(Ho={}));var Qo,Zo=function(e){function t(t,r,n,i,o,a,s){var c=e.call(this)||this;return Object.defineProperty(c,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(c,"roomType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(c,"joinType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(c,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(c,"innerUserDatas",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(c,"outerUserDatas",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(c,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:s}),c}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.JOINROOM},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_getResultTag",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=E.L_RTC_CLIENT_JOIN_RTC_ROOM_R;return this.roomType===Ho.LIVE&&(e=E.L_RTC_CLIENT_JOIN_LIVING_ROOM_R),e}}),Object.defineProperty(t.prototype,"_validateParams",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,i){var o=this;if(e.getConnectionStatus()!==a.CONNECTED)return t.error(i,JSON.stringify({status:I.FAILED,code:O.SIGNAL_DISCONNECTED,msg:"im not connected"}),this.traceId),{code:O.SIGNAL_DISCONNECTED};if(Ht(e.getNaviInfo()))return t.error(i,JSON.stringify({status:I.FAILED,code:O.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),this.traceId),{code:O.PACKAGE_ENVIRONMENT_ERROR};if(!r("roomId",this.roomId,s,!0))return t.error(i,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> roomId"}),this.traceId),{code:O.PARAMS_ERROR};if(!r("roomType",this.roomType,(function(e){return void 0!==Ho[e]})))return t.error(i,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> roomType"}),this.traceId),{code:O.PARAMS_ERROR};if(!r("outerUserDatas",this.outerUserDatas,n,!1))return t.error(i,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:O.PARAMS_ERROR};if(this.outerUserDatas&&!Object.keys(this.outerUserDatas).every((function(e){return r("outerUserDatas.".concat(e),o.outerUserDatas[e],c,!0)})))return t.error(i,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:O.PARAMS_ERROR};return{code:O.SUCCESS}}}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n;return T(this,void 0,void 0,(function(){var o,a,s,c,u,l,_,d,f,p,h,b,g;return y(this,(function(m){switch(m.label){case 0:return o=Date.now(),a=e.context,s=e.service,c=e.logger,u=e.reportMediaActionLogger,l=this._getResultTag(),(_=this._validateParams(a,c,l).code)!==O.SUCCESS?[2,{code:_}]:s.getMsList().length?(d=t.getSupportNtf(),[4,a.joinRTCRoom(this.roomId,this.roomType,this.livingType,this.joinType,this.innerUserDatas,this.outerUserDatas,d)]):(c.error(l,JSON.stringify({status:I.FAILED,code:O.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),this.traceId),[2,{code:O.NOT_OPEN_VIDEO_AUDIO_SERVER}]);case 1:return f=m.sent(),p=f.code,h=f.data,u.reportQualityJoinRoomData(o,p,this.roomType,null==h?void 0:h.sessionId),p===i.SUCCESS&&h?(t.initWithRoomData(h,this.traceId),t.getResourcesByUserId(t.crtUserId).length>0&&r.push(new qo),(g=null===(n=h.roomInfo.filter((function(e){return"cdn_uris"===e.key}))[0])||void 0===n?void 0:n.value)&&t.setCDNUris(JSON.parse(g)[0]),c.info(l,JSON.stringify({status:I.SUCCESSED,userId:t.crtUserId,roomId:this.roomId}),this.traceId),[2,{code:O.SUCCESS,data:h}]):(b=40032===p?O.SIGNAL_JOIN_RTC_ROOM_REFUSED:p,c.error(l,JSON.stringify({status:I.FAILED,code:b,msg:"joinRoom failed"}),this.traceId),[2,{code:b}])}}))}))}}),t}(Ko);!function(e){e[e.ROOM=1]="ROOM",e[e.PERSON=2]="PERSON"}(Qo||(Qo={}));var Xo,$o,ea,ta="PEER_CONNECTION_CLOSED_BY_EXCEPTION",ra="USER_JOIN",na="USER_LEAVE",ia="TRACKS_PUBLISH",oa="TRACKS_UNPUBLISH",aa="AUDIO_MUTE_CHANGE",sa="VIDEO_MUTE_CHANGE",ca="CDN_ENABLE_CHANGE",ua="USER_STATE_CHANGE",la=function(e){function t(t,r,n,i,o,a,s,c){var u=e.call(this)||this;return Object.defineProperty(u,"logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(u,"service",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(u,"context",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(u,"runtime",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(u,"peer",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(u,"store",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(u,"polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(u,"reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:c}),Object.defineProperty(u,"getPushOtherRooms",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),u}return R(t,e),t}(t);!function(e){e.PUBLISH="publish",e.SUBSCRIBE="subscribe"}(Xo||(Xo={})),function(e){e.BEGIN="begin",e.END="end"}($o||($o={})),function(e){e[e.SPREAD=0]="SPREAD",e[e.NO_SPREAD=-1]="NO_SPREAD"}(ea||(ea={}));var _a,da=function(e){function t(t,r,n){var i=e.call(this)||this;return Object.defineProperty(i,"reqBody",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"isNeedUpdateMsas",{enumerable:!0,configurable:!0,writable:!0,value:n}),i}return R(t,e),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n;return T(this,void 0,void 0,(function(){var r,i,o,a,s,c,u,l,_,d;return y(this,(function(f){switch(f.label){case 0:return r=e.service,i=e.context,[4,r.exchange(t.getRTCRequestHeader(),this.reqBody,this.traceId,this.isNeedUpdateMsas)];case 1:return o=f.sent(),a=o.code,s=o.data,c=o.qualityMsList,u={code:a,data:{data:s,qualityMsList:c}},l=null===(n=null==s?void 0:s.urls)||void 0===n?void 0:n.pull_url,t.roomMode===Ho.LIVE&&l&&(_=JSON.parse(l),t.setCDNUris(_),(null==_?void 0:_.broadcast)===ea.SPREAD&&(t.setCDNEnabel(!0),d=S(S({},_),{enableInnerCDN:!0}),ma(i,t.roomId,d))),[2,u]}}))}))}}),t}(Ko);!function(e){e.PUB="pub",e.UNPUB="unpub",e.SUB="sub",e.UNSUB="unsub"}(_a||(_a={}));var fa=function(e){function t(t,r,n,i,o){void 0===i&&(i=_a.SUB);var a=e.call(this)||this;return Object.defineProperty(a,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(a,"forceReq",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"fromCommand",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(a,"unsubTracks",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(a,"_actionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(a,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),a}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.UPDATE_SUBSCRIBE_LIST},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_dealSubscribeResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=null==n?void 0:n.map((function(e){return"".concat(e.msid,"_").concat(e.mediaType)})),o=r.filter((function(e){return null==i?void 0:i.includes(e.track.getTrackId())})),a=r.filter((function(e){return!(null==i?void 0:i.includes(e.track.getTrackId()))}));t.info(E.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:I.SUCCESSED,subSuccessTrackIds:i,failedList:a}),this.traceId);var s=e.getRemoteTracks(),c=function(e){var t=o.some((function(t){return t.track.getTrackId()===e}));s[e].__innerSetSubscribed(t);var r=o.some((function(t){return t.track.getTrackId()===e&&t.subTiny}));s[e].isVideoTrack()&&s[e].__innerSetIsTinyTrack(r)};for(var u in s)c(u);return e.resetSubscribedList(o),a}}),Object.defineProperty(t.prototype,"_getParams",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=this,i=r.map((function(e){return e instanceof vt?{track:e}:S({},e)})),o={};return i=i.filter((function(r){var i=r.track.getTrackId();return e.getRemoteTrack(i)?!o[i]&&(o[i]=!0,!0):(t.warn(E.L_UPDATE_SUBSCRIBELIST_COMMAND_P,"track cannot found in room -> trackId: ".concat(i),n.traceId),!1)})).map((function(e){return S({},e)}))}}),Object.defineProperty(t.prototype,"_validateParams",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return r("tracks",t,(function(){return u(t)&&t.every((function(e){return e instanceof vt||e.track instanceof vt}))}),!0)?{code:O.SUCCESS}:(e.warn(E.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"tracks is invalid"}),this.traceId),{code:O.PARAMS_ERROR})}}),Object.defineProperty(t.prototype,"_reportPubOrSubQualityData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){(null==r?void 0:r.length)&&e.reportPubOrSubQualityData(this.fromCommand,this._actionStartTime,r,t,this._trackMediaMap)}}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o,a,s,c,u,l,_,d,f,p,h,b,g,m,v,R,T,C,L,P,A=this;return y(this,(function(y){switch(y.label){case 0:if(n=e.logger,i=e.peer,o=e.reportMediaActionLogger,a=e.context,this._actionStartTime=Date.now(),c=(s=this).tracks,u=s.forceReq,l=t.roomId,n.info(E.L_UPDATE_SUBSCRIBELIST_COMMAND_T,"roomId: ".concat(l,", forceReq: ").concat(u,", trackIds: ").concat(c.map(Wt)),this.traceId),(_=this._validateParams(n,c).code)!==O.SUCCESS)return[2,{code:_}];if(d=this._getParams(t,n,c),f=t.getSubscribedList().map((function(e){return S({},e)})),!u){if(!Ta(d,f))return n.warn(E.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:I.SUCCESSED,msg:"subscribe list unchanged"}),this.traceId),[2,{code:O.SUCCESS}];f.length&&(p=f.map((function(e){return e.track})),n.warn(E.L_CLEAR_UNSUBSCRIBE_LIST_O,JSON.stringify({list:p.map((function(e){return e.getTrackId()}))}),this.traceId),h=t.getSubscribedList().filter((function(e){return p.every((function(t){return t.getTrackId()!==e.track.getTrackId()}))})),t.resetSubscribedList(h))}return i.__reportR3R4ToPolaris(),i.clearReTryExchangeTimer(),i.updateSubRemoteTracks(d.map((function(e){return e.track}))),[4,ba(d,!1,i,t,a)];case 1:return(b=y.sent()).pushOtherRooms=e.getPushOtherRooms(),[4,new da(b,this.traceId,!0).execute(e,t,r)];case 2:return g=y.sent(),c.forEach((function(e){var t=e instanceof vt?e.getTrackId():e.track.getTrackId();A._trackMediaMap[t]=g.data.qualityMsList||[]})),m=this.fromCommand===_a.SUB?c:this.unsubTracks,g.code!==O.SUCCESS?(this._reportPubOrSubQualityData(o,g.code,m),n.error(E.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:I.FAILED,code:g.code}),this.traceId),[2,{code:g.code}]):(v=g.data.data,R=v.sdp,T=v.resultCode,C=v.subscribedList,T!==O.SUCCESS?(this._reportPubOrSubQualityData(o,T,m),n.error(E.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:I.FAILED,code:T}),this.traceId),[2,{code:T}]):(o.setPubOrSubSuccessTime(Date.now()),[4,i.setRemoteAnswer(R.sdp)]));case 3:return L=y.sent(),this._reportPubOrSubQualityData(o,L,m),L!==O.SUCCESS?[2,{code:L}]:[2,(P=this._dealSubscribeResult(t,n,d,C)).length?{code:O.SUCCESS,data:P}:{code:O.SUCCESS}]}}))}))}}),t}(Ko),pa=function(e){function t(t,r){var n=e.call(this)||this;return Object.defineProperty(n,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),n}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.UNSUBSCRIBE},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return T(this,void 0,void 0,(function(){var i,o,a,s;return y(this,(function(c){return i=e.logger,o=e.polarisReport,a=this.tracks,r("tracks",a,(function(){return u(a)&&a.length>0&&a.every((function(e){return e instanceof vt}))}),!0)?(i.info(E.L_ABSTRACT_ROOM_UNSUBSCRIBE_T,JSON.stringify({unSubscribeTrackIds:a.map(Wt)}),this.traceId),s=t.getSubscribedList().map((function(e){return S({},e)})).filter((function(e){return a.every((function(t){return t.getTrackId()!==e.track.getTrackId()}))})),o.sendR2(Xo.SUBSCRIBE,$o.END,a.map((function(e){return e.getTrackId()}))),[2,new fa(s,!1,this.traceId,_a.UNSUB,this.tracks).execute(e,t,n)]):(i.warn(E.L_ABSTRACT_ROOM_UNSUBSCRIBE_E,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),[2,{code:O.PARAMS_ERROR}])}))}))}}),t}(Ko),ha=function(e){function t(t){var r=e.call(this)||this;return Object.defineProperty(r,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:t}),r}return R(t,e),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o;return y(this,(function(a){switch(a.label){case 0:return n=e.logger,i=this.tracks,o=n.createTraceId(),n.info(E.L_USER_LEFT_UNSUBSCRIBE_O,void 0,o),[4,new pa(i,o).execute(e,t,r)];case 1:return a.sent(),i.forEach((function(e){e.__innerDestroy(),t.removeRemoteTrack(e.getTrackId())})),e.emit(oa,i),[2,{code:O.SUCCESS}]}}))}))}}),t}(Ko);function ba(e,t,r,n,i){var o;return T(this,void 0,void 0,(function(){var a,s;return y(this,(function(c){switch(c.label){case 0:return a=(null===(o=i.getNaviInfo())||void 0===o?void 0:o.ipType)||0,[4,r.createOffer(t)];case 1:return s=c.sent(),[2,{ipType:a,sdp:s,extend:JSON.stringify({resolutionInfo:r.getOutboundVideoInfo()}),subscribeList:e.filter((function(e){var t=e.track.getTrackId(),r=Pt(t).userId,i=n.getResourcesByUserId(r);if(!i)return!1;var o=i.filter((function(e){return t==="".concat(e.msid,"_").concat(e.mediaType)})).length;return o})).map((function(e){return{simulcast:e.subTiny?so.TINY:so.NORMAL,resolution:"",uri:n.getPublishedResourceByTrackId(e.track.getTrackId()).uri}})),switchstream:!1}]}}))}))}function ga(e,t,r){return T(this,void 0,void 0,(function(){var n,o;return y(this,(function(a){switch(a.label){case 0:return n=e.logger.createTraceId(),e.logger.info(E.L_LIVING_ROOM_SPREAD_CDN_INFO_T,JSON.stringify({CDNUris:r}),n),[4,e.setRTCCDNUris(t,Ft.TOTAL_CONTENT_RESOURCE,JSON.stringify([r]))];case 1:return(o=a.sent())!==i.SUCCESS?(e.logger.error(E.L_LIVING_ROOM_SPREAD_CDN_INFO_R,"status: ".concat(I.FAILED,", code: ").concat(o),n),[2,{code:O.SIGNAL_ERROR}]):(e.logger.info(E.L_LIVING_ROOM_SPREAD_CDN_INFO_R,"status: ".concat(I.SUCCESSED),n),[2,{code:O.SUCCESS}])}}))}))}function ma(e,t,r){return T(this,void 0,void 0,(function(){var n,o;return y(this,(function(a){switch(a.label){case 0:return n=e.logger.createTraceId(),e.logger.info(E.L_LIVING_ROOM_SET_ROOM_CDN_INFO_T,"CDNUris: ".concat(r),n),[4,e.setRTCData(t,"cdn_uris",JSON.stringify([r]),!0,Qo.ROOM)];case 1:return(o=a.sent())!==i.SUCCESS?(e.logger.error(E.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,"status: ".concat(I.FAILED,", code: ").concat(o),n),[2,{code:O.SIGNAL_ERROR}]):(e.logger.info(E.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,"status: ".concat(I.SUCCESSED),n),[2,{code:O.SUCCESS}])}}))}))}function va(e,t){return T(this,void 0,void 0,(function(){var r,n,i;return y(this,(function(o){switch(o.label){case 0:return r=t.roomId,n=Object.assign({},t.getCDNUris(),{enableInnerCDN:t.getCDNEnable()}),[4,Promise.all([ga(e,r,n),ma(e,r,n)])];case 1:return i=o.sent(),[2,i.every((function(e){return e.code===O.SUCCESS}))?{code:O.SUCCESS}:{code:O.SIGNAL_ERROR}]}}))}))}var Ra=function(e,t,r,n){return T(void 0,void 0,void 0,(function(){var i,o,a,s,c,u,l;return y(this,(function(_){switch(_.label){case 0:for(a in i=e.crtUserId,o=[],n)o.push(a);s=0,_.label=1;case 1:return s<o.length?(c=o[s])===i?[3,3]:(u=n[c]).length?(l=u.map((function(t){return e.getRemoteTrack(Lt(t))})),[4,new ha(l).execute(t,e,r)]):[3,3]:[3,4];case 2:_.sent(),_.label=3;case 3:return s++,[3,1];case 4:return[2]}}))}))};function Oa(e,t,r,n,i,o){return T(this,void 0,void 0,(function(){var a,s,c,u,_,d,f,p,h,b,g,m,v,R,O,S,T,C,L;return y(this,(function(y){switch(y.label){case 0:for(a=r.logger,s=t.roomId,c=t.roomMode,u=[],_={},d={},f={},p=Kt(e,s,a,o),h=Object.keys(p),b=t.getAllUserIds(),g=h.length-1;g>=0;g-=1)m=h[g],-1!==(v=b.indexOf(m))?(R=t.getResourcesByUserId(m),O=p[m],S=wt(R,O,!0),T=S.publishedList,C=S.modifiedList,L=S.unpublishedList,_[m]=Nt(T),d[m]=Nt(L),f[m]=Nt(C),b.splice(v,1)):(u.push(m),_[m]=Nt(p[m]));return b.length&&b.forEach((function(e){t.removeResourcesByUserId(e)})),t.assignRoomData(p),b.length?[4,Ea(b,r,t,n,o)]:[3,2];case 1:y.sent(),r.emit(na,b),y.label=2;case 2:return u.length&&r.emit(ra,u),[4,Ra(t,r,n,d)];case 3:return y.sent(),function(e,t,r){var n=t.logger;Object.keys(r).forEach((function(i){var o=r[i];if(0!==o.length){var a=o.map((function(t){var r=Lt(t),i=Pt(r),o=i.userId,a=i.tag,s=i.mediaType===We.AUDIO_ONLY?new Rt(n,a,o):new Ot(n,a,o);return e.addRemoteTrack(s),s.__innerSetRemoteMuted(0===t.state),s}));a.length&&t.emit(ia,a)}}))}(t,r,_),function(e,t,r){Object.keys(r).forEach((function(n){r[n].forEach((function(r){var n=Lt(r),i=e.getRemoteTrack(n);i.__innerSetRemoteMuted(0===r.state),i.isAudioTrack()?t.emit(aa,i):t.emit(sa,i)}))}))}(t,r,f),c===l.LIVE&&function(e,t,r,n){var i;if(!n)return void r.warn(E.L_LIVING_ROOM_RECONNECTED_R,JSON.stringify({status:I.FAILED,code:"",msg:"cdn_uris not found"}));var o=JSON.parse(n),a=(null===(i=t.getCDNUris())||void 0===i?void 0:i.enableInnerCDN)!==o.enableInnerCDN;t.setCDNUris(o),a&&e.emit(ca,o.enableInnerCDN)}(r,t,a,i),[2]}}))}))}function Ea(e,t,r,n,i){return T(this,void 0,void 0,(function(){var o,a;return y(this,(function(s){switch(s.label){case 0:return o=[],a=[],e.forEach((function(e){o.push.apply(o,P([],L(r.getRemoteTracksByUserId(e)),!1)),a.push(e)})),o.length?[4,new pa(o,i).execute(t,r,n)]:[3,2];case 1:s.sent(),o.forEach((function(e){return r.removeRemoteTrack(e.getTrackId())})),s.label=2;case 2:return a.length&&a.forEach((function(e){return r.removeResourcesByUserId(e)})),[2]}}))}))}var Ia,Sa=function(e,t,r){var n=e.split("\r\nm"),i=r===We.AUDIO_ONLY?"audio":"video",o=n.filter((function(e){return e.includes("=".concat(i))&&e.includes(t)}))[0],a=new RegExp("a=ssrc:(.*?) msid:".concat(t)),s=o.match(a);return s?s[1]:""},Ta=function(e,t){var r=!1;return e.forEach((function(e){var n=t.findIndex((function(t){return t.track.getTrackId()===e.track.getTrackId()}));-1!==n?t.splice(n,1)[0].subTiny!==e.subTiny&&(r=!0):r=!0})),t.length&&(r=!0),r},ya=function(e){function t(t,r){var n=e.call(this)||this;return Object.defineProperty(n,"msgContent",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),n}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.PARSE_USERSTATE},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"priority",{get:function(){return ko.NORMAL},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_isPKRoomUser",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,n;try{for(var i=C(t),o=i.next();!o.done;o=i.next()){var a=o.value;if(a.extra&&a.extra.roomId!==e.roomId)return!0;if(1===Number(a.state)&&!e.getRemoteUserIds().includes(a.userId))return!0}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return!1}}),Object.defineProperty(t.prototype,"_dealAddUser",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i){var o=e.getResourcesByUserId(i);o||(n?r.upgrade.push(i):r.joined.push(i),t.info(E.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:i,msg:"user ".concat(n?"upgrade":"joined")}),this.traceId)),e.setResourcesByUserId(i,o||[])}}),Object.defineProperty(t.prototype,"_dealReduceUser",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i){e.info(E.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:i,msg:"user ".concat(n?"downgrade":"left")}),this.traceId),n?t.downgrade.push(i):1!==Number(r)?t.offline.push(i):t.left.push(i)}}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o,a,s=this;return y(this,(function(c){switch(c.label){case 0:return n=e.logger,i={joined:[],left:[],offline:[],upgrade:[],downgrade:[]},0===(o=this.msgContent.users).length?[2,{code:O.SUCCESS,data:i}]:this._isPKRoomUser(t,o)?[2,{code:O.SUCCESS,data:i}]:(o.forEach((function(e){var r=e.userId;0===Number(e.state)?s._dealAddUser(t,n,i,e.switchRoleType,r):s._dealReduceUser(n,i,e.state,e.switchRoleType,r)})),(a=P(P(P([],L(i.left),!1),L(i.downgrade),!1),L(i.offline),!1)).length?[4,Ea(a,e,t,r,this.traceId)]:[3,2]);case 1:c.sent(),c.label=2;case 2:return[2,{code:O.SUCCESS,data:i}]}}))}))}}),t}(Ko),Ca=function(e){function t(t,r,n,i,o){var a=e.call(this)||this;return Object.defineProperty(a,"msgContent",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(a,"messageType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"senderId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(a,"sentTime",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(a,"_publishedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(a,"_unpublishedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(a,"_modifiedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(a,"_nowResources",{enumerable:!0,configurable:!0,writable:!0,value:[]}),a}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.PARSE_REMOTERES},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"priority",{get:function(){return ko.NORMAL},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_dealPublishList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o,a,s,c,u,l=this;return y(this,(function(_){switch(_.label){case 0:return n=e.logger,i=e.reportMediaActionLogger,o=this._nowResources.map(Lt),a=[],s=[],this._publishedList.forEach((function(e){var r=Lt(e),i=o.indexOf(r),c=Pt(r),u=c.userId,_=c.tag,d=c.mediaType;i>-1?l._nowResources[i]=e:l._nowResources.push(e);var f=t.getRemoteTrack(r);f?f.isSubscribed()&&a.push(f):(f=d===We.AUDIO_ONLY?new Rt(n,_,u):new Ot(n,_,u),t.addRemoteTrack(f),s.push(f)),f.__innerSetRemoteMuted(0===e.state)})),a.length?(c=a.map((function(e){return e.getTrackId()})),[4,new fa(a,!0,this.traceId).execute(e,t,r)]):[3,2];case 1:(u=_.sent().code)!==O.SUCCESS&&n.error(E.L_RESUB_REPUB_RES_R,JSON.stringify({status:I.FAILED,trackIds:c,code:u}),this.traceId),_.label=2;case 2:return s.length&&e.emit(ia,s),i.reportQualityRecvPubMsgData(this.sentTime,this.senderId),[2]}}))}))}}),Object.defineProperty(t.prototype,"_dealUnpublishList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o,a;return y(this,(function(s){switch(s.label){case 0:for(n=this._unpublishedList.map(Lt),i=this._nowResources.length-1;i>=0;i-=1)o=this._nowResources[i],n.includes(Lt(o))&&this._nowResources.splice(i,1);return a=this._unpublishedList.map((function(e){var r=Lt(e);return t.getRemoteTrack(r)})),[4,new ha(a).execute(e,t,r)];case 1:return s.sent(),[2]}}))}))}}),Object.defineProperty(t.prototype,"_dealModifiedList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n,i,o,a,s,c,u,l;return y(this,(function(_){r=this._nowResources.map(Lt);try{for(n=C(this._modifiedList),i=n.next();!i.done;i=n.next())o=i.value,a=Lt(o),s=r.indexOf(a),this._nowResources[s].state=o.state,(c=t.getRemoteTrack(a)).__innerSetRemoteMuted(0===o.state),c.isAudioTrack()?e.emit(aa,c):e.emit(sa,c)}catch(e){u={error:e}}finally{try{i&&!i.done&&(l=n.return)&&l.call(n)}finally{if(u)throw u.error}}return[2]}))}))}}),Object.defineProperty(t.prototype,"_updateCDNUris",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,n,i=this.msgContent.cdn_uris[0],o=(null===(r=t.getCDNUris())||void 0===r?void 0:r.enableInnerCDN)!==i.enableInnerCDN;t.setCDNUris(i),o&&e.emit(ca,!!(null===(n=t.getCDNUris())||void 0===n?void 0:n.enableInnerCDN))}}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o,a,s,c,u,l,_,d;return y(this,(function(f){switch(f.label){case 0:if(n=this.msgContent.uris,this._publishedList=[],this._unpublishedList=[],this._modifiedList=[],o=this.senderId,a=this.messageType,!t.getRemoteUserIds().includes(o))return[2,{code:O.SUCCESS}];switch(this._nowResources=t.getResourcesByUserId(o)||[],a){case Ft.MODIFY:(s=this._modifiedList).push.apply(s,P([],L(n),!1));break;case Ft.PUBLISH:(c=this._publishedList).push.apply(c,P([],L(n),!1));break;case Ft.UNPUBLISH:(u=this._unpublishedList).push.apply(u,P([],L(n),!1));break;case Ft.TOTAL_CONTENT_RESOURCE:i=wt(this._nowResources,n),(l=this._publishedList).push.apply(l,P([],L(i.publishedList),!1)),(_=this._unpublishedList).push.apply(_,P([],L(i.unpublishedList),!1)),(d=this._modifiedList).push.apply(d,P([],L(i.modifiedList),!1))}return this._publishedList.length?[4,this._dealPublishList(e,t,r)]:[3,2];case 1:f.sent(),f.label=2;case 2:return this._unpublishedList.length?[4,this._dealUnpublishList(e,t,r)]:[3,4];case 3:f.sent(),f.label=4;case 4:return this._modifiedList.length?[4,this._dealModifiedList(e,t)]:[3,6];case 5:f.sent(),f.label=6;case 6:return t.setResourcesByUserId(o,this._nowResources),t.roomMode!==Ho.LIVE?[2,{code:O.SUCCESS}]:this.msgContent.cdn_uris?(this._updateCDNUris(e,t),[2,{code:O.SUCCESS}]):[2,{code:O.SUCCESS}]}}))}))}}),t}(Ko),La=function(e){function t(t,r,n){var i=e.call(this)||this;return Object.defineProperty(i,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"forceReq",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:n}),i}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.SUBSCRIBE},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return T(this,void 0,void 0,(function(){var i,o,a,s,c,l,_,d,f;return y(this,(function(p){return i=e.logger,o=e.polarisReport,s=(a=this).tracks,c=a.forceReq,r("tracks",s,(function(){return u(s)&&s.length>0&&s.every((function(e){return e instanceof vt||e.track instanceof vt}))}),!0)?(i.info(E.L_ABSTRACT_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:s.map(Wt),forceReq:c}),this.traceId),l=t.getSubscribedList().map((function(e){return S({},e)})),_=s.map((function(e){return e instanceof vt?{track:e}:e})),d=!1,f=[],_.forEach((function(e){var t=e.track.getTrackId();f.push(t);var r=l.find((function(e){return e.track.getTrackId()===t}));r&&r.subTiny===e.subTiny||(r?r.subTiny=e.subTiny:l.push(e),d=!0)})),d||c?(o.sendR2(Xo.SUBSCRIBE,$o.BEGIN,f),[2,new fa(l,!0,this.traceId).execute(e,t,n)]):(i.warn(E.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:I.SUCCESSED,msg:"repeat subscribe"}),this.traceId),[2,{code:O.SUCCESS}])):(i.error(E.L_ABSTRACT_ROOM_SUBSCRIBE_E,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),[2,{code:O.PARAMS_ERROR}])}))}))}}),t}(Ko),Pa=function(e){function t(t){var r=e.call(this)||this;return Object.defineProperty(r,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_actionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(r,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),r}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.PUBLISH},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_removePubFailedTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.forEach((function(e){var r=e instanceof ut?e:e.track;t.removeLocalTrackById(r.getTrackId())}))}}),Object.defineProperty(t.prototype,"_addLocalTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n,i,o,a,s,c,u,l,_,d,f,p,h,b,g,m,v,R;return y(this,(function(O){switch(O.label){case 0:r=[],O.label=1;case 1:O.trys.push([1,10,11,12]),n=C(e),i=n.next(),O.label=2;case 2:if(i.done)return[3,9];if(o=i.value,s=(a=o instanceof ut?{pubTiny:!1,track:o}:o).track,c=a.pubTiny,!s.isVideoTrack())return[3,7];if(!c)return[3,7];u=void 0,O.label=3;case 3:return O.trys.push([3,5,,6]),u=s.__innerGetMediaStreamTrack().clone(),l=c.frameRate||He.FPS_15,_=c.resolution||Ke.W176_H144,d=kt(_),f=d.width,p=d.height,h=jt(l),[4,u.applyConstraints({width:f,height:p,frameRate:h})];case 4:return O.sent(),[3,6];case 5:return b=O.sent(),null==u||u.stop(),this._logger.warn(E.L_ABSTRACT_ROOM_PUBLISH_E,"pubTiny failed -> id: ".concat(s.getTrackId(),", msg: ").concat(b.message),this._traceId),[3,9];case 6:return g=new _t(this._logger,s.getTag(),s.getUserId(),u,!0),r.push(g),t.addLocalTrack(g),[3,7];case 7:t.addLocalTrack(s),O.label=8;case 8:return i=n.next(),[3,2];case 9:return[3,12];case 10:return m=O.sent(),v={error:m},[3,12];case 11:try{i&&!i.done&&(R=n.return)&&R.call(n)}finally{if(v)throw v.error}return[7];case 12:return[2,r]}}))}))}}),Object.defineProperty(t.prototype,"__publish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return T(this,void 0,void 0,(function(){var i,o,a,s,c,u,l,_,d,f,p,h,b=this;return y(this,(function(g){switch(g.label){case 0:return i=e.peer,o=e.reportMediaActionLogger,a=e.context,t.roomId,s=[],r.forEach((function(e){var t=(e instanceof ut?{track:e}:e).track;s.push(t)})),r.sort((function(e,t){return(e instanceof ut?{track:e}:e).track.getBitrate().max-(t instanceof ut?{track:t}:t).track.getBitrate().max})),i.getLocalTracks().length+function(e,t){var r=0;return e.forEach((function(e){var n=e instanceof ut?e.getTrackId():e.track.getTrackId();t.getLocalTrack(n)||(e instanceof ut?r++:e.pubTiny&&e.track.isVideoTrack()&&(r+=2))})),r}(r,i)>10?(this._logger.error(E.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:I.FAILED,code:O.PUBLISH_TRACK_LIMIT_EXCEEDED,trackIds:r.map(Wt),msg:"publish track limit exceeded"}),this._traceId),[2,{code:O.PUBLISH_TRACK_LIMIT_EXCEEDED,tracks:s}]):[4,this._addLocalTracks(r,i)];case 1:return c=g.sent(),i.clearReTryExchangeTimer(),[4,ba(t.getSubscribedList(),!1,i,t,a)];case 2:return(u=g.sent()).pushOtherRooms=e.getPushOtherRooms(),[4,new da(u,this._traceId,!0).execute(e,t,n)];case 3:return l=g.sent(),s.forEach((function(e){var t=e.getTrackId();b._trackMediaMap[t]=l.data.qualityMsList||[]})),l.code!==O.SUCCESS?(o.reportPubOrSubQualityData(_a.PUB,this._actionStartTime,s,l.code,this._trackMediaMap),this._logger.error(E.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:I.FAILED,tracks:r.map(Wt),code:l.code,msg:"exchange failed"}),this._traceId),this._removePubFailedTracks(r,i),[2,{code:l.code,tracks:s}]):(_=l.data.data,d=_.sdp,f=_.resultCode,p=_.message,f!==O.SUCCESS?(o.reportPubOrSubQualityData(_a.PUB,this._actionStartTime,s,f,this._trackMediaMap),this._logger.error(E.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:I.FAILED,trackIds:r.map(Wt),code:f,msg:"exchange inner failed: ".concat(p)}),this._traceId),this._removePubFailedTracks(r,i),[2,{code:f,tracks:s}]):(o.setPubOrSubSuccessTime(Date.now()),[4,i.setRemoteAnswer(d.sdp,!0)]));case 4:return(h=g.sent())!==O.SUCCESS?(o.reportPubOrSubQualityData(_a.PUB,this._actionStartTime,s,h,this._trackMediaMap),this._logger.error(E.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:I.FAILED,trackIds:r.map(Wt),code:h,msg:"set remote answer error"}),this._traceId),[2,{code:h,tracks:s}]):(c.length&&this._updateTinyTrackIdSSRCMap(t,u.sdp.sdp,c),[2,S(S({code:f},l.data),{tracks:s})])}}))}))}}),Object.defineProperty(t.prototype,"_updateTinyTrackIdSSRCMap",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){r.forEach((function(r){var n=Sa(t,r.getStreamId(),We.VIDEO_ONLY);e.setTrackIdSSRCMap(Number(n),r.getTrackId())}))}}),Object.defineProperty(t.prototype,"_dealPublishRes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,o,a,s,c,u,l,_,d,f,p,h,b,g,m,v,R,T,C,A,N,w,D;return y(this,(function(y){switch(y.label){case 0:return n=r.polarisReport,o=r.context,a=r.peer,s=r.reportMediaActionLogger,c=t.crtUserId,u=t.roomId,l="",_=t.getResourcesByUserId(c),d=P([],L(_),!1),[],p=e.tracks,e.code!==O.SUCCESS?[2,{code:e.code}]:(h=e.data,b=h.publishList,g=h.urls,m=h.mcuPublishList,l=null==g?void 0:g.liveUrl,b.map((function(e){return S({tag:e.msid.split("_").pop(),state:a.getLocalTrack(Lt(e)).isLocalMuted()?0:1},e)})).forEach((function(e){var t=function(e,t){for(var r=!1,n=0,i=0;i<t.length;i++){var o=t[i];if("".concat(e.msid,"_").concat(e.mediaType)==="".concat(o.msid,"_").concat(o.mediaType)){r=!0,n=i;break}}return{isInclude:r,index:n}}(e,d),r=t.isInclude,n=t.index;r?d.splice(n,1,e):d.push(e)})),v=(null==m?void 0:m.map((function(e){return S({tag:e.msid.split("_").pop(),state:1},e)})))||[],f=v,R=wt(_,d).publishedList,T=S(S({},t.getCDNUris()),{enableInnerCDN:t.getCDNEnable()}),C=T&&T.broadcast===ea.SPREAD?JSON.stringify([T]):"",A=Date.now(),[4,o.setRTCTotalRes(u,[Et(Ft.PUBLISH,R)],It(d),Ft.TOTAL_CONTENT_RESOURCE,It(f),C)]);case 1:return N=y.sent(),s.reportPubOrSubQualityData(_a.PUB,this._actionStartTime,p,N,this._trackMediaMap,[{dur:Date.now()-A,cod:N}]),N!==i.SUCCESS?(this._logger.error(E.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:I.FAILED,code:N,msg:"send publish streams notification failed"}),this._traceId),[2,{code:O.SIGNAL_ERROR}]):(t.setResourcesByUserId(c,d),w=R.map((function(e){return Lt(e)})),n.sendR2(Xo.PUBLISH,$o.BEGIN,w),R.forEach((function(e){a.getLocalTrack("".concat(e.msid,"_").concat(e.mediaType)).__innerSetPublished(!0)})),D={code:O.SUCCESS},l&&(D.liveUrl=l),[2,D])}}))}))}}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return T(this,void 0,void 0,(function(){var i,o,a,s,c=this;return y(this,(function(l){switch(l.label){case 0:return i=e.logger,o=e.peer,this._traceId=i.createTraceId(),this._logger=i,this._actionStartTime=Date.now(),a=this.tracks,r("tracks",a,(function(){return u(a)&&a.length>0&&a.every((function(e){return e instanceof ut||e.track instanceof ut}))}),!0)?(this._logger.info(E.L_ABSTRACT_ROOM_PUBLISH_T,JSON.stringify({trackIds:a.map(Wt)})),(a=a.filter((function(e){var t=(e instanceof ut?{track:e}:e).track,r=t.isDestroyed();return r&&c._logger.warn(E.L_ABSTRACT_ROOM_PUBLISH_E,"track '".concat(t.getTrackId(),"' has beem destroyed"),c._traceId),!r}))).length?(o.__reportR3R4ToPolaris(),o.clearReTryExchangeTimer(),[4,this.__publish(e,t,a,n)]):(this._logger.error(E.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:I.FAILED,code:O.PUBLISH_TRACKS_IS_INVALID,msg:"params tracks is empty"}),this._traceId),[2,{code:O.PUBLISH_TRACKS_IS_INVALID}])):(this._logger.error(E.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> tracks"}),this._traceId),[2,{code:O.PARAMS_ERROR}]);case 1:return s=l.sent(),[4,this._dealPublishRes(s,t,e)];case 2:return[2,l.sent()]}}))}))}}),t}(Ko),Aa=function(e){function t(t){var r=e.call(this)||this;return Object.defineProperty(r,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"_actionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(r,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),r}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.UNPUBLISH},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"__unpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return T(this,void 0,void 0,(function(){var i,o,a,s,c,u,l,_,d,f,p,h,b=this;return y(this,(function(g){switch(g.label){case 0:return i=e.peer,o=e.polarisReport,a=e.logger,s=e.reportMediaActionLogger,c=e.context,u=n.map((function(e){return e.getTrackId()})),0===u.map(t.getPublishedResourceByTrackId.bind(t)).filter((function(e){return!!e})).length?[2,{code:O.SUCCESS,tracks:n}]:(u.forEach((function(e){return i.removeLocalTrackById(e)})),o.sendR2(Xo.PUBLISH,$o.END,u),i.clearReTryExchangeTimer(),[4,ba(t.getSubscribedList(),!1,i,t,c)]);case 1:return l=g.sent(),(_=e.getPushOtherRooms()).length&&(l.pushOtherRooms=_),[4,new da(l,this._traceId,!0).execute(e,t,r)];case 2:return d=g.sent(),n.forEach((function(e){var t=e.getTrackId();b._trackMediaMap[t]=d.data.qualityMsList||[]})),d.code!==O.SUCCESS?(s.reportPubOrSubQualityData(_a.UNPUB,this._actionStartTime,n,d.code,this._trackMediaMap),a.error(E.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:I.FAILED,code:d.code,trackIds:n.map(Wt),msg:"exchange failed"}),this._traceId),[2,{code:d.code,tracks:n}]):(f=d.data.data,p=f.resultCode,h=f.message,p!==O.SUCCESS?(s.reportPubOrSubQualityData(_a.UNPUB,this._actionStartTime,n,d.data.data.resultCode,this._trackMediaMap),a.error(E.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:I.FAILED,code:p,trackIds:n.map(Wt),msg:"exchange inner failed: ".concat(h)}),this._traceId),[2,{code:p,tracks:n}]):[2,S(S({code:d.code},d.data),{tracks:n})])}}))}))}}),Object.defineProperty(t.prototype,"_dealUnpublishRes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,o,a,s,c,u,l,_,d,f,p,h,b,g,m,v,R,T,C,A;return y(this,(function(y){switch(y.label){case 0:return n=e.context,o=e.logger,a=e.peer,s=e.reportMediaActionLogger,c=n.getCurrentId(),u=t.roomId,l=[],[],d=r.tracks,f=r.code,p=r.data,f!==O.SUCCESS?(o.error(E.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({code:f,msg:"unpublish failed"}),this._traceId),[2,{code:f}]):p?(h=p.mcuPublishList,b=d.map((function(e){return e.getTrackId()})),g=b.map(t.getPublishedResourceByTrackId.bind(t)).filter((function(e){return!!e})),l.push.apply(l,P([],L(g),!1)),m=h?h.map((function(e){return S({tag:e.msid.split("_").pop(),state:1},e)})):[],_=m,v=t.getResourcesByUserId(c),R=v.filter((function(e){return!l.includes(e)})),T=Date.now(),[4,n.setRTCTotalRes(u,[Et(Ft.UNPUBLISH,l)],It(R),Ft.TOTAL_CONTENT_RESOURCE,It(_))]):(o.info(E.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:I.SUCCESSED,msg:"unpublish list is empty "})),[2,{code:O.SUCCESS}]);case 1:return C=y.sent(),s.reportPubOrSubQualityData(_a.UNPUB,this._actionStartTime,d,C,this._trackMediaMap,[{dur:Date.now()-T,cod:C}]),C!==i.SUCCESS?(o.error(E.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:I.FAILED,code:C,msg:"send unpublish notification failed"}),this._traceId),[2,{code:O.SIGNAL_ERROR}]):(o.info(E.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:I.SUCCESSED,code:O.SUCCESS,msg:"unpublish success",unPubResourceIds:b}),this._traceId),A=r.data.sdp,[4,a.setRemoteAnswer(A.sdp)]);case 2:return y.sent(),t.setResourcesByUserId(c,R),[2,{code:O.SUCCESS}]}}))}))}}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return T(this,void 0,void 0,(function(){var i,o,a,s;return y(this,(function(c){switch(c.label){case 0:return i=e.logger,this._actionStartTime=Date.now(),o=t.crtUserId,a=this.tracks,this._traceId=i.createTraceId(),r("tracks",a,(function(){return a.every((function(e){return e.getUserId()===o&&e instanceof ut}))}),!0)?(i.info(E.L_ABSTRACT_ROOM_UNPUBLISH_T,JSON.stringify({trackIds:a.map(Wt)})),[4,this.__unpublish(e,t,n,a)]):(i.error(E.L_ABSTRACT_ROOM_UNPUBLISH_E,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> tracks"})),[2,{code:O.PARAMS_ERROR}]);case 1:return s=c.sent(),[4,this._dealUnpublishRes(e,t,s)];case 2:return[2,c.sent()]}}))}))}}),t}(Ko),Na=function(e){function t(t){var r=e.call(this)||this;return Object.defineProperty(r,"localTrack",{enumerable:!0,configurable:!0,writable:!0,value:t}),r}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.LOCAL_TRACK_MUTE},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var r,n,o,a,s,c,u,l,_,d,f,p,h,b,g,m,v,R;return y(this,(function(S){switch(S.label){case 0:r=e.logger,n=e.context,o=this.localTrack,a=o.getTrackId(),s=t.crtUserId,c=t.roomId,u=!o.isLocalMuted(),l=r.createTraceId(),r.info(E.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_T,JSON.stringify({enabled:u,trackId:this.localTrack.getTrackId()}),l),_=[{resourceId:a,enabled:u}],d=t.getResourcesByUserId(s),f=[],p=function(e){var t=Lt(e),r=_.findIndex((function(e){return e.resourceId===t}));if(r>=0){var n=_[r].enabled;return e.state=n?1:0,f.push(e),"break"}};try{for(h=C(d),b=h.next();!b.done&&(g=b.value,"break"!==p(g));b=h.next());}catch(e){v={error:e}}finally{try{b&&!b.done&&(R=h.return)&&R.call(h)}finally{if(v)throw v.error}}return[4,n.setRTCTotalRes(c,[Et(Ft.MODIFY,f)],It(d),Ft.TOTAL_CONTENT_RESOURCE)];case 1:return(m=S.sent())!==i.SUCCESS?(r.error(E.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:I.FAILED,code:m,msg:"signal error"}),l),[2,{code:m}]):(r.info(E.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:I.SUCCESSED}),l),[2,{code:O.SUCCESS}])}}))}))}}),t}(Ko),wa=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.RETRY_EXCHANGE},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"priority",{get:function(){return ko.HIGH},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o,a,s,c,u,l,_,d,f,p,h,b,g;return y(this,(function(m){switch(m.label){case 0:return n=e.logger,i=e.peer,o=e.context,a=n.createTraceId(),n.info(E.L_RETRY_EXCHANGE_COMMAND_T),s=o.getCurrentId(),[4,ba(t.getSubscribedList(),!0,i,t,o)];case 1:return(c=m.sent()).pushOtherRooms=e.getPushOtherRooms(),[4,new da(c,a).execute(e,t,r)];case 2:return(u=m.sent()).code!==O.SUCCESS?[2,{code:u.code}]:(l=u.data.data,_=l.sdp,(d=l.resultCode)!==O.SUCCESS?[2,{code:d}]:(i.clearReTryExchangeTimer(),[4,i.setRemoteAnswer(_.sdp)]));case 3:return(f=m.sent())!==O.SUCCESS?[2,{code:f}]:(p=u.data.data.publishList||[],h=this._diffPublishListChange(p,t,i,s),b=h.plus,g=h.minus,b.length||g.length?[4,this._spreadPublishListUri(e,s,b,g,a)]:[3,5]);case 4:m.sent(),m.label=5;case 5:return[2,{code:O.SUCCESS}]}}))}))}}),Object.defineProperty(t.prototype,"_diffPublishListChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i=t.getResourcesByUserId(n),o=JSON.parse(JSON.stringify(i));e.forEach((function(e){var t,n=e.mediaType,i=e.msid,a=o.findIndex((function(e){var t=e.mediaType,r=e.msid;return n===t&&i===r}));if(-1===a){var s=S({tag:i.split("_").pop(),state:(null===(t=r.getLocalTrack(Lt(e)))||void 0===t?void 0:t.isLocalMuted)?0:1},e);o.push(s)}else o[a].uri=e.uri}));var a=wt(i,o,!0),s=a.publishedList,c=a.unpublishedList;return t.setResourcesByUserId(n,o),{plus:s,minus:c}}}),Object.defineProperty(t.prototype,"_spreadPublishListUri",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,o){return T(this,void 0,void 0,(function(){var a,s,c,u;return y(this,(function(l){switch(l.label){case 0:return a=e.store,s=e.logger,c=a.getResourcesByUserId(t),s.info(E.L_RETRY_EXCHANGE_SPREAD_T,JSON.stringify({plus:r,minus:n,allPublishList:c}),o),u=[],n.length&&u.push(Et(Ft.UNPUBLISH,n)),r.length&&u.push(Et(Ft.PUBLISH,r)),[4,e.context.setRTCTotalRes(a.roomId,u,It(c),Ft.TOTAL_CONTENT_RESOURCE)];case 1:return l.sent()===i.SUCCESS?s.info(E.L_RETRY_EXCHANGE_SPREAD_R,"status: ".concat(I.SUCCESSED),o):s.error(E.L_RETRY_EXCHANGE_SPREAD_R,"status: ".concat(I.FAILED),o),[2]}}))}))}}),t}(Ko);!function(e){e[e.JOIN=0]="JOIN",e[e.LEAVE=1]="LEAVE",e[e.OFFLINE=2]="OFFLINE",e[e.RESOURCECHANGE=3]="RESOURCECHANGE"}(Ia||(Ia={}));var Da,ka,Ua=function(e){function t(t,r,n,i){var o=e.call(this)||this;return Object.defineProperty(o,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(o,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(o,"_context",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(o,"_targetPullVersion",{enumerable:!0,configurable:!0,writable:!0,value:i}),o}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.PULL_RTCROOM_STATUS},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,o,a,s,c,u,l,_,d,f,p,h,b,g,m,v,R,O,S,T,L,P,A;return y(this,(function(y){switch(y.label){case 0:return n=e.logger,o=t.getRoomStatusVersion(),n.info(E.L_PULL_ROOM_STATUS_T,JSON.stringify({roomId:this._roomId,localVersion:o}),this._traceId),this._targetPullVersion&&this._targetPullVersion<=o?(n.info(E.L_PULL_ROOM_STATUS_R,JSON.stringify({status:I.SUCCESSED,msg:"the roomData has been pulled",localVersion:o,targetPullVersion:this._targetPullVersion}),this._traceId),[2,{code:i.SUCCESS}]):[4,this._context.pullRTCRoomStatus(this._roomId,o)];case 1:return a=y.sent(),s=a.code,c=a.data,s!==i.SUCCESS?(n.info(E.L_PULL_ROOM_STATUS_R,JSON.stringify({status:I.FAILED,code:s}),this._traceId),[2,{code:s}]):(l=(u=c).bFullStatus,_=u.version,d=u.usersData,f=u.roomStatus,n.info(E.L_PULL_ROOM_STATUS_R,JSON.stringify({bFullStatus:l,version:Yt(_),usersData:d,roomStatus:f}),this._traceId),t.setRoomStatusVersion(_),l?(p=function(e){var t={users:{}},r="";return e.forEach((function(e){var n,i,o=e.userId,a=e.userData;t.users[o]={};var s=null===(n=a.filter((function(e){return"uris"===e.key}))[0])||void 0===n?void 0:n.value,c=null===(i=a.filter((function(e){return"cdn_uris"===e.key}))[0])||void 0===i?void 0:i.value;r=c||r,t.users[o]={uris:s}})),{urisData:t,CDNUris:r&&JSON.stringify(JSON.parse(r)[0])}}(d),h=p.urisData,b=p.CDNUris,[4,Oa(h,t,e,r,b,this._traceId)]):[3,3]);case 2:return y.sent(),[2,{code:s}];case 3:y.trys.push([3,10,11,12]),g=C(f),m=g.next(),y.label=4;case 4:return m.done?[3,9]:(v=m.value).event!==Ia.RESOURCECHANGE?[3,6]:(R=function(e){var t,r,n=e.userId,i=e.userData,o=function(e){return e.some((function(e){return"uris"===e.key||"cdn_uris"===e.key}))}(i);if(o){var a=null===(t=i.filter((function(e){return"uris"===e.key}))[0])||void 0===t?void 0:t.value,s=null===(r=i.filter((function(e){return"cdn_uris"===e.key}))[0])||void 0===r?void 0:r.value;return{userId:n,content:{uris:a?JSON.parse(a):[],cdn_uris:s&&JSON.parse(s)}}}}(v),R?(S=R.content,(O=R.userId)===t.crtUserId?[3,8]:[4,new Ca(S,Ft.TOTAL_CONTENT_RESOURCE,O,this._traceId).execute(e,t,r)]):[3,8]);case 5:return y.sent(),[3,8];case 6:return S=function(e){var t,r=e.userId,n=e.userData,i=e.event,o=e.switchRoleType;return{users:[{userId:r,extra:null===(t=n.filter((function(e){return"extra"===e.key}))[0])||void 0===t?void 0:t.value,state:i,switchRoleType:o}]}}(v),[4,new ya(S,this._traceId).execute(e,t,r)];case 7:T=y.sent().data,e.emit(ua,T),y.label=8;case 8:return m=g.next(),[3,4];case 9:return[3,12];case 10:return L=y.sent(),P={error:L},[3,12];case 11:try{m&&!m.done&&(A=g.return)&&A.call(g)}finally{if(P)throw P.error}return[7];case 12:return[2,{code:s}]}}))}))}}),t}(Ko),Ma=function(e){function t(t){var r=e.call(this)||this;return Object.defineProperty(r,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:t}),r}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.ON_SIGNAL_RECONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"priority",{get:function(){return ko.HIGH},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,o,a,s,c,u;return y(this,(function(l){switch(l.label){case 0:return n=e.logger,o=e.peer,a=e.context,s=t.roomId,c=t.roomMode,u=n.createTraceId(),n.info(E.L_ABSTRACT_ROOM_IM_RECONNECTED_T,void 0,u),"closed"===o.getRTCPeerConn().connectionState?(n.error(E.L_ABSTRACT_ROOM_IM_RECONNECTED_R,"RTCPeerConnection closed. Please rejoin room to restore services",u),e.emit(ta),[2,{code:O.SUCCESS}]):[4,a.rtcPing(s,c)];case 1:return 40001!==l.sent().code?[3,5]:[4,this._joinRoom(e,t,r,u)];case 2:return l.sent()!==i.SUCCESS?[3,4]:[4,this._restoreMediaServer(e,t,r)];case 3:l.sent(),l.label=4;case 4:return[3,7];case 5:return[4,new Ua(s,u,a).execute(e,t,r)];case 6:l.sent(),l.label=7;case 7:return[2,{code:O.SUCCESS}]}}))}))}}),Object.defineProperty(t.prototype,"_joinRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var o;return T(this,void 0,void 0,(function(){var a,s,c,u,l,_;return y(this,(function(d){switch(d.label){case 0:return a=e.context,s=e.logger,[4,a.joinRTCRoom(t.roomId,t.roomMode,this.livingType)];case 1:return c=d.sent(),u=c.code,l=c.data,u!==i.SUCCESS?(s.error(E.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:I.FAILED,code:u,msg:"im reconnect joinRTCRoom failed"}),n),[2]):l?(_=null===(o=l.roomInfo.filter((function(e){return"cdn_uris"===e.key}))[0])||void 0===o?void 0:o.value,[4,Oa(l,t,e,r,_,n)]):(s.info(E.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:I.FAILED,msg:"im reconnect joinRTCRoom, roomData is empty"}),n),[2]);case 2:return d.sent(),s.info(E.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:I.SUCCESSED,roomData:l}),n),[2,u]}}))}))}}),Object.defineProperty(t.prototype,"_restoreMediaServer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i;return y(this,(function(o){switch(o.label){case 0:return n=e.peer.getLocalTracks(),i=Object.values(t.getRemoteTracks()).filter((function(e){return!!e.isSubscribed()})),n.length?[4,new Pa(n).execute(e,t,r)]:[3,2];case 1:o.sent(),o.label=2;case 2:return n.length||!i.length?[3,4]:[4,new La(i,!0).execute(e,t,r)];case 3:o.sent(),o.label=4;case 4:return[2]}}))}))}}),t}(Ko),ja=1,Ba=5;!function(e){e[e.new=0]="new",e[e.checking=1]="checking",e[e.connected=2]="connected",e[e.completed=3]="completed",e[e.failed=4]="failed",e[e.disconnected=5]="disconnected",e[e.closed=6]="closed"}(Da||(Da={})),function(e){e[e.SERVER_KICK=1]="SERVER_KICK",e[e.OTHER_KICK=2]="OTHER_KICK",e[e.IM_DISCONNECTED=3]="IM_DISCONNECTED",e[e.IM_LOGOUT=4]="IM_LOGOUT",e[e.OTHER_CLIENT_IM_CONNECTED=5]="OTHER_CLIENT_IM_CONNECTED"}(ka||(ka={}));var xa,Va,Fa,Ja,Ga=function(){function e(e,t,r,n){var i=this;Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_userId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_baseReportData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_networkReportData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pubOrSubSuccessTime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_peerCStatus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reportQualityJoinRoomData",{enumerable:!0,configurable:!0,writable:!0,value:function(e,t,r,n){i._baseReportData=Object.assign(i._baseReportData,{snid:n});var o=S(S(S({},i._baseReportData),i._networkReportData),{cod:t,time:e,dur:Date.now()-e,rtp:r});i._logger.__statistics(E.L_QS_JOIN_ROOM_S,JSON.stringify(o))}}),this._baseReportData={rid:this._roomId,csnid:this._clientSessionId,snid:"",time:Date.now(),uid:this._userId},this._networkReportData={cr:"unknown",net:"unknown"}}return Object.defineProperty(e.prototype,"reportQualityKickedData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=S(S(S({},this._baseReportData),this._networkReportData),{time:Date.now(),cod:e===ka.OTHER_KICK?Ba:ja});this._logger.__statistics(E.L_QS_KICKED_S,JSON.stringify(t))}}),Object.defineProperty(e.prototype,"reportPubOrSubQualityData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i,o){var a=this;r.forEach((function(r){var s,c,u=r instanceof ut||r instanceof vt?r:r.track,l=u.getTrackId(),_=Pt(l).mediaType,d=!1;d=u instanceof ut?!!u.isVideoTrack()&&(null===(c=(s=u).__isTiny)||void 0===c?void 0:c.call(s)):r.subTiny||!1;var f=S(S(S({},a._baseReportData),a._networkReportData),{resid:l,mtp:_,smct:d?so.TINY:so.NORMAL,stp:"Rongcloud"!==u.getTag()?1:0,cod:n,msas:i?i[l]:[],sigs:o,time:Date.now(),dur:Date.now()-t});switch(e){case"pub":a._logger.__statistics(E.L_QS_PUBLISH_S,JSON.stringify(f));break;case"unpub":a._logger.__statistics(E.L_QS_UNPUBLISH_S,JSON.stringify(f));break;case"sub":a._logger.__statistics(E.L_QS_SUBSCRIBE_S,JSON.stringify(f));break;case"unsub":a._logger.__statistics(E.L_QS_UNSUBSCRIBE_S,JSON.stringify(f))}}))}}),Object.defineProperty(e.prototype,"reportQualityRecvPubMsgData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=S(S(S({},this._baseReportData),this._networkReportData),{puid:t,time:Date.now(),dur:Date.now()-e});this._logger.__statistics(E.L_QS_RECV_PUB_MSG_S,JSON.stringify(r))}}),Object.defineProperty(e.prototype,"setPubOrSubSuccessTime",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._pubOrSubSuccessTime=e}}),Object.defineProperty(e.prototype,"reportIceFirstConnectData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=S(S(S({},this._baseReportData),this._networkReportData),{time:this._pubOrSubSuccessTime,dur:Date.now()-this._pubOrSubSuccessTime}),r="pub"===e?E.L_QS_PUB_ICE_STATUS_S:E.L_QS_SUB_ICE_STATUS_S;this._logger.__statistics(r,JSON.stringify(t))}}),Object.defineProperty(e.prototype,"recordQualityIceStatusData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=this._peerCStatus||{},i=n.status,o=n.time;if(o){var a=e.IP,s=e.port,c=e.networkType,u=e.remoteIP,l=e.remotePort,_=S(S(S({},this._baseReportData),this._networkReportData),{dur:r-o,time:r,pices:Da[i],ices:Da[t],rcdts:[{ip:"".concat(u,":").concat(l)}],lcdts:[{ip:"".concat(a,":").concat(s),nttp:c}],cncdts:[]});console.log(E.L_QS_ICE_STATUS_S,_),this._logger.__statistics(E.L_QS_ICE_STATUS_S,JSON.stringify(_)),this._peerCStatus={status:t,time:r}}else this._peerCStatus={status:t,time:r}}}),e}();!function(e){e[e.DISABLE=0]="DISABLE",e[e.ENABLE=1]="ENABLE"}(xa||(xa={})),function(e){e[e.MeetingOrAnchor=1]="MeetingOrAnchor",e[e.Audience=2]="Audience"}(Va||(Va={})),function(e){e[e.NOT_REPORT=-1]="NOT_REPORT",e[e.REPORT_SUCCESS=1e4]="REPORT_SUCCESS",e[e.REPORT_FAIL=0]="REPORT_FAIL",e[e.PB_ERROR=40001]="PB_ERROR"}(Fa||(Fa={})),function(e){e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4"}(Ja||(Ja={}));var Ha,Ka,Wa,Ya,za=function(){function e(e,t,r,n,i){void 0===i&&(i=Va.MeetingOrAnchor),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,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_crtRTCRoom",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_userRole",{enumerable:!0,configurable:!0,writable:!0,value:i})}return Object.defineProperty(e.prototype,"_send",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){return y(this,(function(t){switch(t.label){case 0:return this._context.getConnectionStatus()!==a.CONNECTED?[2,Fa.NOT_REPORT]:[4,this._context.setRTCState(this._roomId,e)];case 1:return t.sent()===i.SUCCESS?[2,Fa.REPORT_SUCCESS]:[2,Fa.REPORT_FAIL]}}))}))}}),Object.defineProperty(e.prototype,"_getClientID",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e="uuid",t=this._runtime.localStorage.getItem(e);return t||(t=Dt(),this._runtime.localStorage.setItem(e,t)),t}}),Object.defineProperty(e.prototype,"_getRealResourceId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,r=e.indexOf("_tiny");return r>-1&&(t=e.slice(0,r)),t}}),Object.defineProperty(e.prototype,"_getPolarisTrackId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t="",r=e.split("_");if(e.includes("_tiny")){var n=r.pop(),i=parseInt(r.pop())===We.AUDIO_ONLY?"audio":"video",o=r.pop();t=[r.join("_"),o,n,i].join("_")}else{i=parseInt(r.pop())===We.AUDIO_ONLY?"audio":"video",o=r.pop();t=[r.join("_"),o,i].join("_")}return t}}),Object.defineProperty(e.prototype,"_getBaseData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return{bitrateSend:(null==e?void 0:e.bitrateSend)||co,bitrateRecv:(null==e?void 0:e.bitrateRecv)||co,networkType:(null==e?void 0:e.networkType)||"unknown",rtt:(null==e?void 0:e.rtt)||co,localAddress:"".concat((null==e?void 0:e.IP)||co,":").concat(null==e?void 0:e.port),remoteAddress:"".concat(null==e?void 0:e.remoteIP,":").concat(null==e?void 0:e.remotePort),receiveBand:(null==e?void 0:e.availableIncomingBitrate)||co,sendBand:(null==e?void 0:e.availableOutgoingBitrate)||co,packetsLost:(null==e?void 0:e.totalPacketsLost)||co,deviceId:this._context.getCurrentId()}}}),Object.defineProperty(e.prototype,"_getAudioLevel",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||0===e?e:co}}),Object.defineProperty(e.prototype,"_getBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||0===e?e:co}}),Object.defineProperty(e.prototype,"_getPacketsLostRate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||0===e?e:co}}),Object.defineProperty(e.prototype,"_getFrameRate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||co}}),Object.defineProperty(e.prototype,"_getResolution",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return e&&t?"".concat(e," * ").concat(t):"".concat(co)}}),Object.defineProperty(e.prototype,"_getJitter",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||co}}),Object.defineProperty(e.prototype,"_getNackCount",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||0===e?e:co}}),Object.defineProperty(e.prototype,"_getPliCount",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||0===e?e:co}}),Object.defineProperty(e.prototype,"_getRTT",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||co}}),Object.defineProperty(e.prototype,"_getTrackState",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e?this._crtRTCRoom.getLocalTrack(t):this._crtRTCRoom.getRemoteTrack(t);return(null==r?void 0:r.isLocalMuted())?xa.DISABLE:xa.ENABLE}}),Object.defineProperty(e.prototype,"sendR3Data",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n,i,o,a=this;return y(this,(function(s){switch(s.label){case 0:return t=e.iceCandidatePair,r=e.senders,n=this._getBaseData(t),i="R3\t".concat(n.bitrateSend,"\t-1\t-1\t-1\t").concat(n.networkType,"\t").concat(n.rtt,"\t").concat(n.localAddress,"\t").concat(n.receiveBand,"\t").concat(n.sendBand,"\t").concat(n.packetsLost,"\t").concat(n.deviceId,"\r"),o=r.map((function(e){var t=e.trackId,r=e.audioLevel,n=e.samplingRate,i=e.bitrate,o=e.packetsLostRate,s=e.frameRate,c=e.frameWidth,u=e.frameHeight,l=e.googRenderDelayMs,_=e.jitter,d=e.nackCount,f=e.pliCount,p=e.rtt,h=e.googFirsSent,b=e.encoderImplementation,g=a._getPolarisTrackId(t),m=a._getRealResourceId(t);return{trackId:g,googCodecName:b||String(co),audioLevel:a._getAudioLevel(r),bitrate:a._getBitrate(i),packetsLostRate:a._getPacketsLostRate(o),frameRate:a._getFrameRate(s),resolution:a._getResolution(c,u),jitter:a._getJitter(_),nackCount:a._getNackCount(d),pliCount:a._getPliCount(f),rtt:a._getRTT(p),googFirsSent:h,samplingRate:n,googRenderDelayMs:l,encoderImplementation:b||String(co),trackState:a._getTrackState(!0,m)}})),i+=o.map((function(e){return"".concat(e.trackId,"\t").concat(e.googCodecName,"\t").concat(e.audioLevel,"\t").concat(e.samplingRate,"\t").concat(e.bitrate,"\t").concat(e.packetsLostRate,"\t").concat(e.frameRate,"\t").concat(e.resolution,"\t").concat(e.googRenderDelayMs,"\t").concat(e.jitter,"\t").concat(e.nackCount,"\t").concat(e.pliCount,"\t").concat(e.rtt,"\t").concat(e.googFirsSent,"\t").concat(e.encoderImplementation,"\t").concat(e.trackState)})).join("\n"),[4,this._send("".concat(i,"\r").concat(this._userRole))];case 1:return s.sent()!==Fa.REPORT_SUCCESS?[2,Fa.REPORT_FAIL]:[2,Fa.REPORT_SUCCESS]}}))}))}}),Object.defineProperty(e.prototype,"sendR4Data",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n,i,o,a=this;return y(this,(function(s){switch(s.label){case 0:return t=e.iceCandidatePair,r=e.receivers,n=this._getBaseData(t),i="R4\t".concat(n.bitrateRecv,"\t-1\t-1\t-1\t").concat(n.networkType,"\t").concat(n.rtt,"\t").concat(n.localAddress,"\t").concat(n.receiveBand,"\t").concat(n.sendBand,"\t").concat(n.packetsLost,"\t").concat(n.deviceId,"\r"),o=r.filter((function(e){return!!e.trackId})).map((function(e){var t=e.trackId,r=e.audioLevel,n=e.samplingRate,i=e.bitrate,o=e.packetsLostRate,s=e.frameRate,c=e.frameWidth,u=e.frameHeight,l=e.googRenderDelayMs,_=e.jitter,d=e.nackCount,f=e.pliCount,p=e.rtt,h=e.googFirsReceived,b=e.codecImplementationName,g=a._getPolarisTrackId(t),m=a._getRealResourceId(t);return{trackId:g,googCodecName:b||String(co),audioLevel:a._getAudioLevel(r),bitrate:a._getBitrate(i),packetsLostRate:a._getPacketsLostRate(o),frameRate:a._getFrameRate(s),resolution:a._getResolution(c,u),jitter:a._getJitter(_),nackCount:a._getNackCount(d),pliCount:a._getPliCount(f),rtt:a._getRTT(p),googFirsReceived:h,samplingRate:n,googRenderDelayMs:l,codecImplementationName:b||String(co),trackState:a._getTrackState(!1,m)}})),i+=o.map((function(e){return"".concat(e.trackId,"\t").concat(e.googCodecName,"\t").concat(e.audioLevel,"\t").concat(e.samplingRate,"\t").concat(e.bitrate,"\t").concat(e.packetsLostRate,"\t").concat(e.frameRate,"\t").concat(e.resolution,"\t").concat(e.googRenderDelayMs,"\t").concat(e.jitter,"\t").concat(e.nackCount,"\t").concat(e.pliCount,"\t").concat(e.rtt,"\t").concat(e.googFirsReceived,"\t").concat(e.codecImplementationName,"\t").concat(e.trackState)})).join("\n"),[4,this._send("".concat(i,"\r").concat(this._userRole))];case 1:return s.sent()!==Fa.REPORT_SUCCESS?[2,Fa.REPORT_FAIL]:[2,Fa.REPORT_SUCCESS]}}))}))}}),Object.defineProperty(e.prototype,"sendR1",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t=this._context.getCoreVersion(),r=(null===(e=navigator.userAgentData)||void 0===e?void 0:e.platformn)||navigator.platform,n=Bt.browser,i=Bt.version,o=this._getClientID(),a="R1\t".concat("5.26.0","\t").concat(t,"\t").concat("web","\t").concat(r,"\t").concat(-1,"\t").concat(n,"\t").concat(i,"\t").concat(o,"\t").concat(this._userRole);this._send(a)}}),Object.defineProperty(e.prototype,"sendR2",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n=this._getClientID(),i="R2\t".concat(e,"\t").concat(t,"\t").concat(n,"\r").concat(r.join("\t"),"\r").concat(this._userRole);this._send(i)}}),e}(),qa="evt-leave",Qa=function(t){function r(e,r,n,i,o,a,s,c,u,l){void 0===u&&(u=uo()),void 0===l&&(l=!1);var _=t.call(this)||this;Object.defineProperty(_,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(_,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(_,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(_,"_service",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(_,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(_,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:u}),Object.defineProperty(_,"_pinger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_audioLevelReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_peerConnection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_executeCtx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(_,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(_,"_onRecvPKMsg",{enumerable:!0,configurable:!0,writable:!0,value:null});var d=_._logger=_._context.logger;_._reportMediaActionLogger=new Ga(d,_._roomId,_._clientSessionId,_._context.getCurrentId()),_._polarisReport=new za(_._context,_._runtime,_._roomId,_);var f=_._context.getCurrentId(),p=new zo(d,u,_._context.getAppkey(),n,f,i,s,c),h=_._peerConnection=new Jo(d,_._reTryExchange.bind(_),f,p,_._polarisReport,!1,l);_._setPeerConnectionListener();var b=_._executeCtx=new la(d,_._service,e,r,h,p,_._polarisReport,_._reportMediaActionLogger);return b.getPushOtherRooms=function(){return _._getPushOtherRoomsParams()},_.setCommandEventListener(),_._invoker=new Yo(b,p),_._store=_._invoker.store,_._audioLevelReport=new Go(_._store,h),h.on(Jo.__INNER_AUDIOLEVEL_CHANGE__,_._audioLevelReport.audioLevelReport,_._audioLevelReport),_._pinger=new zt(_._context,_._roomId,i,_._initOptions.pingGap),_._pinger.onFailed=_.__kickoff.bind(_),_._pinger.onPingResult=_._handlePingResult.bind(_),_._context.registerRTCSignalListener((function(e){return T(_,void 0,void 0,(function(){var t,r,n,i,o;return y(this,(function(a){return t=this._context.decodeRtcNotify(e),r=t.time,n=t.type,i=t.roomId,this._invoker.isDestroyed()?(this._logger.info(E.L_RTCNTF_PULL_ROOM_STATUS_O,JSON.stringify({isDestroyed:!0,type:n,time:r,roomId:i})),[2]):(2===n&&i===this._roomId&&(o=this._logger.createTraceId(),this._logger.info(E.L_RTCNTF_PULL_ROOM_STATUS_O,null,o),this._startPullRTCRoomStatus(i,o,r)),[2])}))}))})),_}return R(r,t),Object.defineProperty(r.prototype,"_setPeerConnectionListener",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=this._peerConnection;t.on(Jo.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),t.on(ut.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),t.on(ut.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),t.once(Jo.__INNER_ICE_CONNECTED__,(function(t){e._reportMediaActionLogger.reportIceFirstConnectData(t?"pub":"sub")}),this),t.on(Jo.__INNER_ICE_STATE_CHANGE__,(function(t){var r=t.status,n=t.time,i=t.iceCandidatePair;e._reportMediaActionLogger.recordQualityIceStatusData(i,r,n)}))}}),Object.defineProperty(r.prototype,"setCommandEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._executeCtx;e.on(ta,this._rtcpeerClosed,this),e.on(ra,this._callAppListener.bind(this,"onUserJoin"),this),e.on(na,this._callAppListener.bind(this,"onUserLeave"),this),e.on(ia,this._onTrackPublish,this),e.on(oa,this._onTrackUnpublish,this),e.on(aa,this._onAudioMuteChange,this),e.on(sa,this._onVideoMuteChange,this),e.on(ca,this._callAppListener.bind(this,"onCDNEnableChange"),this),e.on(ua,this._dealUserAppListener,this)}}),Object.defineProperty(r.prototype,"_startPullRTCRoomStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,this._invoker.push(new Ua(e,t,this._context,r))];case 1:return n.sent(),[2]}}))}))}}),Object.defineProperty(r.prototype,"__innerInit",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i,o){return T(this,void 0,void 0,(function(){var a,s,c;return y(this,(function(u){switch(u.label){case 0:return[4,this._invoker.push(new Zo(this._roomId,e,t,r,n,i,o))];case 1:return a=u.sent(),s=a.code,c=a.data,s!==O.SUCCESS?[2,{code:s}]:(this._initWithRoomData(c.offlineKickTime),[2,{code:s,data:c}])}}))}))}}),Object.defineProperty(r.prototype,"_initWithRoomData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._pinger.start(1e3*e),this._polarisReport.sendR1()}}),Object.defineProperty(r.prototype,"_handlePingResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(e===Jt.SUCCESS&&(t>this._store.getRoomStatusVersion()&&this._store.getSupportNtf())){var r=this._logger.createTraceId();this._logger.info(E.L_RTCPING_PULL_ROOM_STATUS_O,JSON.stringify({dataVersion:t}),r),this._startPullRTCRoomStatus(this._roomId,r,t)}this._callAppListener("onPing",e)}}),Object.defineProperty(r.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n){this._logger.warn(E.L_ABSTRACT_ROOM_SETBITRATE_O,"`RCAbstractRoom.setBitrate` will be deprecated, use `RCLocalTrack.setBitrate` instead."),_("max",t,(function(t){return e(t)&&t>Math.max(r||1,200)}),!0),_("min",r,(function(r){return e(r)&&r>=1&&(!e(t)||r<t)}),!0),_("start",n,(function(n){return e(n)&&n>r&&n<=t})),this._peerConnection.setBitrate(t,r,n)}}),Object.defineProperty(r.prototype,"_onTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.streams[0].id,r=e.receiver.track,n=[t,"audio"===r.kind?We.AUDIO_ONLY:We.VIDEO_ONLY].join("_"),i=this._store.getRemoteTrack(n);i?(i.__innerSetMediaStreamTrack(r),this._logger.info(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:I.SUCCESSED,eventType:"onTrackReady",trackId:i.getTrackId()})),this._callAppListener("onTrackReady",i)):this._logger.warn(E.L_ABSTRACT_ROOM_ONTRACKREADY_O,"cannot found remote track ".concat(r.id))}}),Object.defineProperty(r.prototype,"_callAppListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=null===(t=this._appListener)||void 0===t?void 0:t[e];if(i)try{i.apply(void 0,P([],L(r),!1))}catch(e){this._logger.error(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}}),Object.defineProperty(r.prototype,"_onTrackUnpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:I.SUCCESSED,eventType:"onTrackUnpublish",trackIds:null==e?void 0:e.map((function(e){return e.getTrackId()}))})),this._callAppListener("onTrackUnpublish",e)}}),Object.defineProperty(r.prototype,"__parseInnerMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.targetId;if(r===this._roomId){this._logger.info(E.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,"recv inner msg -> message: ".concat(JSON.stringify(e)," | roomid: ").concat(this._roomId),t);var n=e.content;switch(e.messageType){case Ft.KICK:this.__kickoff(!0,n);break;case Ft.STATE:this._stateHandle(n,t);break;case Ft.MODIFY:case Ft.PUBLISH:case Ft.UNPUBLISH:case Ft.TOTAL_CONTENT_RESOURCE:this._resourceHandle(n,e.messageType,e.senderUserId,e.sentTime,t);break;case Ft.ROOM_NOTIFY:this._logger.info(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:I.SUCCESSED,eventType:"onRoomAttributeChange",messageType:e.messageType,messageContent:e.content})),this._callAppListener("onRoomAttributeChange",e.messageType,e.content);break;case Ft.USER_NOTIFY:this._logger.warn(E.L_OLD_DAILY_RECORD_O,"TODO: ".concat(Ft.USER_NOTIFY));break;case Ft.PK_INVITE:case Ft.PK_CANCEL_INVITE:case Ft.PK_INVITE_TIMEOUT:case Ft.PK_INVITE_ANSWER:case Ft.PK_END:this._onRecvPKMsg&&this._onRecvPKMsg(e);break;case Ft.OTHER_ROOM_OFFLINE:break;default:this._logger.info(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:I.SUCCESSED,eventType:"onMessageReceive",messageType:e.messageType,messageContent:e.content,senderUserId:e.senderUserId,messageUId:e.messageUId})),this._callAppListener("onMessageReceive",e.messageType,n,e.senderUserId,e.messageUId)}}else this._logger.warn(E.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,JSON.stringify({status:I.FAILED,message:"roomId is different, msg roomId-> ".concat(r,", this._roomId-> ").concat(this._roomId," ")}),t)}}),Object.defineProperty(r.prototype,"__kickoff",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n,i=this;return y(this,(function(o){return this._invoker.isDestroyed()||(this._logger.warn(E.L_ABSTRACT_ROOM_ONKICKOFF_O,"onKickOff -> byServer: ".concat(e,", kickContent: ").concat(JSON.stringify(t))),this.emit(qa),this._leaveHandle(!e),e&&((null==t?void 0:t.users)||[]).forEach((function(e){e.userId===i._context.getCurrentId()&&(n=e.type,r=e.kickExtra,i._reportMediaActionLogger.reportQualityKickedData(n))})),this._logger.info(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:I.SUCCESSED,eventType:"onKickOff",byServer:e,kickType:n,kickExtra:r})),this._callAppListener("onKickOff",e,n,r)),[2]}))}))}}),Object.defineProperty(r.prototype,"_rtcpeerClosed",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.emit(qa),this._leaveHandle(!0),this._logger.info(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,"onRTCPeerConnectionCloseByException"),this._callAppListener("onRTCPeerConnectionCloseByException")}}),Object.defineProperty(r.prototype,"_resourceHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i){return T(this,void 0,void 0,(function(){var o;return y(this,(function(a){return o=e.uris,e.ignore||!o||this._invoker.push(new Ca(e,t,r,i,n)),[2]}))}))}}),Object.defineProperty(r.prototype,"_onTrackPublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:I.SUCCESSED,eventType:"onTrackPublish",trackIds:null==e?void 0:e.map((function(e){return e.getTrackId()}))})),this._callAppListener("onTrackPublish",e)}}),Object.defineProperty(r.prototype,"_stateHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n;return y(this,(function(i){switch(i.label){case 0:return[4,this._invoker.push(new ya(e,t))];case 1:return r=i.sent(),n=r.data,this._dealUserAppListener(n),[2]}}))}))}}),Object.defineProperty(r.prototype,"_dealUserAppListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,n=this,i=e.left,o=e.joined,a=e.upgrade,s=e.downgrade,c=e.offline,u=P([],L(o),!1),l=P([],L(i),!1);(null===(t=this._appListener)||void 0===t?void 0:t.onSwitchRole)?(null==a||a.forEach((function(e){n._logger.info(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:I.SUCCESSED,eventType:"onSwitchRole",userId:e,role:wo.ANCHOR})),n._callAppListener("onSwitchRole",e,wo.ANCHOR)})),null==s||s.forEach((function(e){n._logger.info(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:I.SUCCESSED,eventType:"onSwitchRole",userId:e,role:wo.AUDIENCE})),n._callAppListener("onSwitchRole",e,wo.AUDIENCE)}))):(u.push.apply(u,P([],L(a),!1)),l.push.apply(l,P([],L(s),!1))),c.length&&((null===(r=this._appListener)||void 0===r?void 0:r.onUserOffline)?(this._logger.info(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:I.SUCCESSED,eventType:"onUserOffline",offline:c})),this._callAppListener("onUserOffline",c)):l.push.apply(l,P([],L(c),!1))),u.length>0&&(this._logger.info(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:I.SUCCESSED,eventType:"onUserJoin",allJoined:u})),this._callAppListener("onUserJoin",u)),l.length>0&&(this._logger.info(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:I.SUCCESSED,eventType:"onUserLeave",allLeft:l})),this._callAppListener("onUserLeave",l))}}),Object.defineProperty(r.prototype,"getRoomId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._roomId}}),Object.defineProperty(r.prototype,"getCrtUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._context.getCurrentId()}}),Object.defineProperty(r.prototype,"getRemoteUserIds",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.getRemoteUserIds()}}),Object.defineProperty(r.prototype,"getRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=[];return this.getRemoteUserIds().forEach((function(r){t.push.apply(t,P([],L(e.getRemoteTracksByUserId(r)),!1))})),t}}),Object.defineProperty(r.prototype,"getRemoteTracksByUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._store.getRemoteTracksByUserId(e)}}),Object.defineProperty(r.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.getSessionId()}}),Object.defineProperty(r.prototype,"sendMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n;return y(this,(function(o){switch(o.label){case 0:return r=this._logger.createTraceId(),this._logger.info(E.L_ABSTRACT_ROOM_SEND_MESSAGE_T,JSON.stringify({name:e,content:t}),r),[4,this._context.sendMessage(d.RTC_ROOM,this._roomId,{messageType:e,content:t,isStatusMessage:!0})];case 1:return(n=o.sent().code)!==i.SUCCESS?(this._logger.error(E.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:I.FAILED,code:n}),r),[2,{code:O.SIGNAL_ERROR}]):(this._logger.info(E.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:I.SUCCESSED,name:e,content:t}),r),[2,{code:O.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"setRoomAttribute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return void 0===n&&(n=!1),T(this,void 0,void 0,(function(){var o,a;return y(this,(function(s){switch(s.label){case 0:return o=this._logger.createTraceId(),this._logger.info(E.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,key:e,value:t,message:r,isInner:n}),o),[4,this._context.setRTCData(this._roomId,e,t,n,Qo.ROOM,r)];case 1:return(a=s.sent())!==i.SUCCESS?(this._logger.error(E.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:I.FAILED,code:a}),o),[2,{code:O.SIGNAL_ERROR}]):(this._logger.info(E.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:I.SUCCESSED,roomId:this._roomId,key:e,value:t,message:r,isInner:n}),o),[2,{code:O.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"deleteRoomAttributes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return void 0===r&&(r=!1),T(this,void 0,void 0,(function(){var n,o;return y(this,(function(a){switch(a.label){case 0:return n=this._logger.createTraceId(),this._logger.info(E.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:e,message:t,isInner:r}),n),[4,this._context.removeRTCData(this._roomId,e,r,Qo.ROOM,t)];case 1:return(o=a.sent())!==i.SUCCESS?(this._logger.error(E.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:I.FAILED,code:o}),n),[2,{code:O.SIGNAL_ERROR}]):(this._logger.info(E.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:I.SUCCESSED,roomId:this._roomId,keys:e,message:t,isInner:r}),n),[2,{code:O.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"getRoomAttributes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=!1),T(this,void 0,void 0,(function(){var r,n,o,a;return y(this,(function(s){switch(s.label){case 0:return r=this._logger.createTraceId(),this._logger.info(E.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:e,isInner:t}),r),[4,this._context.getRTCData(this._roomId,e,t,Qo.ROOM)];case 1:return n=s.sent(),o=n.code,a=n.data,o!==i.SUCCESS?(this._logger.error(E.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_R,"GetRoomAttributes Failed: ".concat(o),r),[2,{code:O.SIGNAL_ERROR}]):(this._logger.info(E.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:I.SUCCESSED,data:a}),r),[2,{code:O.SUCCESS,data:a}])}}))}))}}),Object.defineProperty(r.prototype,"_setUserAttributeValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return this._context.setRTCData(this._roomId,e,t,!1,Qo.PERSON,r)}}),Object.defineProperty(r.prototype,"_deleteUserAttributes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._context.removeRTCData(this._roomId,e,!1,Qo.PERSON,t)}}),Object.defineProperty(r.prototype,"_getUserAttributes",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._context.getRTCData(this._roomId,e,!1,Qo.PERSON)}}),Object.defineProperty(r.prototype,"isDestroyed",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._invoker.isDestroyed()}}),Object.defineProperty(r.prototype,"__destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._leaveHandle(e)}}),Object.defineProperty(r.prototype,"_muteRemoteTracksBeforeQuit",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=Object.values(this._store.getRemoteTracks());e.length&&e.forEach((function(e){return e.mute()}))}}),Object.defineProperty(r.prototype,"_leaveHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){return y(this,(function(t){switch(t.label){case 0:return this._invoker.isDestroyed()?[2]:(this._invoker.destroy(),this._muteRemoteTracksBeforeQuit(),e?[4,this._context.quitRTCRoom(this._roomId)]:[3,2]);case 1:t.sent(),t.label=2;case 2:return this._store.isMainRoom?[4,this._quitAllPKRoom()]:[3,4];case 3:t.sent(),t.label=4;case 4:return this._pinger.stop(),[4,this._service.exit(this._store.getRTCRequestHeader())];case 5:return t.sent(),this._releasePCManager(),[2]}}))}))}}),Object.defineProperty(r.prototype,"_releasePCManager",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._peerConnection;e.removeAllLocalTrack(),e.destroy()}}),Object.defineProperty(r.prototype,"_onLocalTrackDestroied",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e instanceof _t&&e.__isTiny()||this.unpublish([e])}}),Object.defineProperty(r.prototype,"_onLocalTrackMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r;return y(this,(function(n){switch(n.label){case 0:return[4,this._invoker.push(new Na(e))];case 1:return r=n.sent().code,t(r),[2]}}))}))}}),Object.defineProperty(r.prototype,"publish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){return y(this,(function(t){return[2,this._invoker.push(new Pa(e))]}))}))}}),Object.defineProperty(r.prototype,"_getPushOtherRoomsParams",{enumerable:!1,configurable:!0,writable:!0,value:function(){return[]}}),Object.defineProperty(r.prototype,"_reTryExchange",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._invoker.push(new wa)}}),Object.defineProperty(r.prototype,"unpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){return y(this,(function(t){return[2,this._invoker.push(new Aa(e))]}))}))}}),Object.defineProperty(r.prototype,"_isValidResourceId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=Pt(e).userId;return!!(null===(t=this._store.getResourcesByUserId(r))||void 0===t?void 0:t.find((function(t){return Lt(t)===e})))}}),Object.defineProperty(r.prototype,"subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){return y(this,(function(t){return[2,this._invoker.push(new La(e,void 0,void 0))]}))}))}}),Object.defineProperty(r.prototype,"unsubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t;return y(this,(function(r){return t=this._logger.createTraceId(),this._logger.info(E.L_APP_CALL_UNSUBSCRIBE_O,void 0,t),[2,this._invoker.push(new pa(e,t))]}))}))}}),Object.defineProperty(r.prototype,"updateSubList",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){return y(this,(function(t){return[2,this._invoker.push(new fa(e,!0,this._logger.createTraceId()))]}))}))}}),Object.defineProperty(r.prototype,"getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._peerConnection.getLocalTrack(e)}}),Object.defineProperty(r.prototype,"getLocalTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._peerConnection.getLocalTracks()}}),Object.defineProperty(r.prototype,"getRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._store.getRemoteTrack(e)||null}}),Object.defineProperty(r.prototype,"subscribedTracks",{get:function(){return this._store.getSubscribedList().slice()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"registerRoomEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(E.L_ABSTRACT_ROOM_REGISTER_ROOM_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._appListener=e}}),Object.defineProperty(r.prototype,"registerReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(E.L_ABSTRACT_ROOM_REGISTER_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._peerConnection.registerReportListener(e)}}),Object.defineProperty(r.prototype,"onAudioLevelChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(E.L_ABSTRACT_ROOM_AUDIO_LEVEL_O),this._audioLevelReport.onAudioLevelChange(e)}}),Object.defineProperty(r.prototype,"__onReconnected",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._invoker.push(new Ma(e))}}),Object.defineProperty(r.prototype,"_onAudioMuteChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:I.SUCCESSED,eventType:"onAudioMuteChange",trackId:e.getTrackId()})),this._callAppListener("onAudioMuteChange",e)}}),Object.defineProperty(r.prototype,"_onVideoMuteChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(E.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:I.SUCCESSED,eventType:"onVideoMuteChange",trackId:e.getTrackId()})),this._callAppListener("onVideoMuteChange",e)}}),Object.defineProperty(r.prototype,"_registerPKMsgListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._onRecvPKMsg=e}}),Object.defineProperty(r.prototype,"_quitAllPKRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return T(this,void 0,void 0,(function(){return y(this,(function(e){return[2]}))}))}}),Object.defineProperty(r.prototype,"getClientSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.clientSessionId}}),r}(t),Za=function(e){function t(t,r){var n=e.call(this)||this;return Object.defineProperty(n,"data",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"cdnValues",{enumerable:!0,configurable:!0,writable:!0,value:r}),n}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.MCUCONFIG_FLUSH},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n,i,o,a;return T(this,void 0,void 0,(function(){var r,s,c,u,l,_,d;return y(this,(function(f){switch(f.label){case 0:return r=e.context,s=e.service,c={"App-Key":r.getAppkey(),Token:t.getToken(),RoomId:t.roomId,UserId:r.getCurrentId(),SessionId:t.getSessionId()},[4,s.setMcuConfig(c,this.data)];case 1:return u=f.sent(),l=u.code,_=u.res,l!==O.SUCCESS?[2,{code:l}]:(_.pull_url&&t.setCDNUris(JSON.parse(_.pull_url)),d=this.cdnValues,l===O.SUCCESS&&((null===(i=null===(n=d.output)||void 0===n?void 0:n.video.normal)||void 0===i?void 0:i.width)||(null===(a=null===(o=d.output)||void 0===o?void 0:o.video.normal)||void 0===a?void 0:a.fps))&&va(r,t),[2,{code:l,data:_}])}}))}))}}),t}(Ko);!function(e){e[e.CROP=1]="CROP",e[e.WHOLE=2]="WHOLE"}(Ha||(Ha={})),function(e){e[e.CUSTOMIZE=1]="CUSTOMIZE",e[e.SUSPENSION=2]="SUSPENSION",e[e.ADAPTATION=3]="ADAPTATION"}(Ka||(Ka={})),function(e){e[e.CROP=1]="CROP",e[e.WHOLE=2]="WHOLE"}(Wa||(Wa={})),function(e){e[e.AUDIO_VIDEO_ALL=0]="AUDIO_VIDEO_ALL",e[e.AUDIO_VIDEO_NO=1]="AUDIO_VIDEO_NO",e[e.AUDIO_ALL_VIDEO_NO=2]="AUDIO_ALL_VIDEO_NO",e[e.AUDIO_NO_VIDEO_ALL=3]="AUDIO_NO_VIDEO_ALL",e[e.AUDIO_VIDEO_INPUT=4]="AUDIO_VIDEO_INPUT",e[e.AUDIO_ALL_VIDEO_INPUT=5]="AUDIO_ALL_VIDEO_INPUT",e[e.AUDIO_NO_VIDEO_INPUT=6]="AUDIO_NO_VIDEO_INPUT",e[e.AUDIO_INPUT_VIDEO_ALL=7]="AUDIO_INPUT_VIDEO_ALL",e[e.AUDIO_INPUT_VIDEO_NO=8]="AUDIO_INPUT_VIDEO_NO",e[e.ROOM_AUDIO_VIDEO_APPEND=9]="ROOM_AUDIO_VIDEO_APPEND",e[e.ROOM_AUDIO_VIDEO_NOT_APPEND=10]="ROOM_AUDIO_VIDEO_NOT_APPEND",e[e.ROOM_AUDIO_APPEND=11]="ROOM_AUDIO_APPEND",e[e.ROOM_AUDIO_NOT_APPEND=12]="ROOM_AUDIO_NOT_APPEND",e[e.ROOM_VIDEO_APPEND=13]="ROOM_VIDEO_APPEND",e[e.ROOM_VIDEO_NOT_APPEND=14]="ROOM_VIDEO_NOT_APPEND"}(Ya||(Ya={}));var Xa,$a=function(){return{version:2,mode:Ka.SUSPENSION}},es=function(){function t(e,t,r){Object.defineProperty(this,"_executeCtx",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_isValidTrackId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_values",{enumerable:!0,configurable:!0,writable:!0,value:$a()}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._executeCtx.logger}return Object.defineProperty(t.prototype,"setHostVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._isValidTrackId(e))return this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:I.FAILED,msg:"videoTrackId: ".concat(e," is invalid")})),this;var t=Pt(e),r=t.mediaType,n=t.tag,i=t.userId;return r!==We.VIDEO_ONLY?(this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:I.FAILED,msg:"kind of ".concat(e," is not video")})),this):(this._values.host_stream_id=At(i,n),this._logger.info(E.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:I.SUCCESSED,videoTrackId:e})),this)}}),Object.defineProperty(t.prototype,"setMixLayoutMode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return[Ka.CUSTOMIZE,Ka.SUSPENSION,Ka.ADAPTATION].includes(e)?(this._values.mode=e,this._logger.info(E.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:I.SUCCESSED,mode:e})),this):(this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:I.SUCCESSED,msg:"mode: ".concat(e," is invalid")})),this)}}),Object.defineProperty(t.prototype,"_addOutputValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){void 0===r&&(r="normal");var n=this._values.output||(this._values.output={video:{normal:{width:640,height:480}}});if("cdn"!==e)if("audio"!==e){var i=n.video;if("normal"!==r&&"tiny"!==r)if("backgroundColor"!==r)if("exparams"!==r){if("backgroundPicture"===r){var o=i.backgroundPicture||(i.backgroundPicture={fillMode:Ha.CROP,picture:[]});Object.assign(o,t)}}else i.exparams={renderMode:t};else i.backgroundColor=t;else{var a=i[r]||(i[r]={});Object.assign(a,t)}}else n.audio={bitrate:t};else n.cdn=t}}),Object.defineProperty(t.prototype,"setOutputVideoResolution",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!Ut(e))return this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:I.FAILED,msg:"params error -> resolution: ".concat(e)})),this;var t=kt(e),r=t.width,n=t.height;return this._addOutputValue("video",{width:r,height:n},"normal"),this._logger.info(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:I.SUCCESSED,resolution:e})),this}}),Object.defineProperty(t.prototype,"setOutputVideoFPS",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!Mt(e))return this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:I.FAILED,msg:"params error -> fps: ".concat(e)})),this;var t=jt(e);return this._addOutputValue("video",{fps:t},"normal"),this._logger.info(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:I.SUCCESSED,fps:e})),this}}),Object.defineProperty(t.prototype,"setOutputVideoBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return!e(t)||t<=0?(this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:I.FAILED,msg:"params error -> bitrate: ".concat(t)})),this):(this._addOutputValue("video",{bitrate:t},"normal"),this._logger.info(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:I.SUCCESSED,bitrate:t})),this)}}),Object.defineProperty(t.prototype,"setOutputTinyVideoResolution",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!Ut(e))return this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:I.FAILED,msg:"params error -> resolution: ".concat(e)})),this;var t=kt(e),r=t.width,n=t.height;return this._addOutputValue("video",{width:r,height:n},"tiny"),this._logger.info(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:I.SUCCESSED,resolution:e})),this}}),Object.defineProperty(t.prototype,"setOutputTinyVideoFPS",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!Mt(e))return this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:I.FAILED,msg:"params error -> fps: ".concat(e)})),this;var t=jt(e);return this._addOutputValue("video",{fps:t},"tiny"),this._logger.info(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:I.SUCCESSED,fps:e})),this}}),Object.defineProperty(t.prototype,"setOutputTinyVideoBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return!e(t)||t<=0?(this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:I.FAILED,msg:"params error -> bitrate: ".concat(t)})),this):(this._addOutputValue("video",{bitrate:t},"tiny"),this._logger.info(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:I.SUCCESSED,bitrate:t})),this)}}),Object.defineProperty(t.prototype,"setOutputVideoRenderMode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return[Wa.CROP,Wa.WHOLE].includes(e)?(this._addOutputValue("video",e,"exparams"),this._logger.info(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:I.SUCCESSED,renderMode:e})),this):(this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:I.FAILED,msg:"params error -> renderMode: ".concat(e)})),this)}}),Object.defineProperty(t.prototype,"setOutputAudioBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e(t)&&t>0?(this._addOutputValue("audio",t),this._logger.info(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:I.SUCCESSED,bitrate:t})),this):(this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:I.FAILED,msg:"params error -> bitrate: ".concat(t)})),this)}}),Object.defineProperty(t.prototype,"setOutputBackgroundColor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return/^0x[a-fA-F0-9]{6}$/.test(e)?(this._addOutputValue("video",e,"backgroundColor"),this._logger.info(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:I.SUCCESSED,color:e})),this):(this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:I.FAILED,msg:"params error -> color: ".concat(e)})),this)}}),Object.defineProperty(t.prototype,"addOutputBackgroundPicture",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n,i,o){var a,s,c;if(!f(t))return this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:I.FAILED,msg:"params error -> uri: ".concat(t)})),this;if([r,n,i,o].some((function(t){return!e(t)||t<0||t>1})))return this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:I.FAILED,msg:"params of (x, y, w, h) error -> x: ".concat(r,", y: ").concat(n,", w: ").concat(i,", h: ").concat(o)})),this;var u=(null===(c=null===(s=null===(a=this._values.output)||void 0===a?void 0:a.video)||void 0===s?void 0:s.backgroundPicture)||void 0===c?void 0:c.picture)||[];return u.push({uri:t,w:i,h:o,x:r,y:n}),this._addOutputValue("video",{picture:u},"backgroundPicture"),this._logger.info(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:I.SUCCESSED,uri:t,x:r,y:n,w:i,h:o})),this}}),Object.defineProperty(t.prototype,"removeOutputBackgroundPicture",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,n;if(!f(e))return this._logger.error(E.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:I.FAILED,msg:"params error -> uri: ".concat(e)})),this;var i=null===(n=null===(r=null===(t=this._values.output)||void 0===t?void 0:t.video)||void 0===r?void 0:r.backgroundPicture)||void 0===n?void 0:n.picture;return i&&(i=i.filter((function(t){return t.uri!==e})),this._addOutputValue("video",{pictures:i},"backgroundPicture")),this._logger.info(E.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:I.SUCCESSED,uri:e})),this}}),Object.defineProperty(t.prototype,"clearOutputBackgroundPicture",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._addOutputValue("video",{pictures:[]},"backgroundPicture"),this._logger.info(E.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}}),Object.defineProperty(t.prototype,"setOutputBackgroundPictureFillMode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return[Ha.CROP,Ha.WHOLE].includes(e)?(this._addOutputValue("video",{fillMode:e},"backgroundPicture"),this._logger.info(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:I.SUCCESSED,fillMode:e})),this):(this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:I.FAILED,msg:"params error -> fillMode: ".concat(e)})),this)}}),Object.defineProperty(t.prototype,"addPublishStreamUrls",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,n=/^rtmp:\/\/.+/;if(!u(e)||0===e.length||e.some((function(e){return!n.test(e)})))return this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:I.FAILED,msg:"params error -> urls: ".concat(e.join(","))})),this;var i=(null===(r=null===(t=this._values.output)||void 0===t?void 0:t.cdn)||void 0===r?void 0:r.concat())||[],o=!1;return e.forEach((function(e){i.some((function(t){return t.pushurl===e}))||(o=!0,i.push({pushurl:e}))})),i.length>5?(this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:I.FAILED,msg:"params error -> publish stream urls no more than 5, length: ".concat(e.length)})),this):(o&&this._addOutputValue("cdn",i),this._logger.info(E.L_MCU_CONFIG_BUILDER_ADD_PUBLISH_STREAM_URLS_O,JSON.stringify({status:I.SUCCESSED,urls:e})),this)}}),Object.defineProperty(t.prototype,"removePublishStreamUrls",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,n=/^rtmp:\/\/.+/;if(!u(e)||0===e.length||e.some((function(e){return!n.test(e)})))return this._logger.error(E.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:I.FAILED,msg:"params error -> urls: ".concat(e.join(","))})),this;for(var i=(null===(r=null===(t=this._values.output)||void 0===t?void 0:t.cdn)||void 0===r?void 0:r.concat())||[],o=i.length-1;o>=0;o-=1){var a=i[o].pushurl,s=e.indexOf(a);s>=0&&(e.splice(s,1),i.splice(o,1))}return this._addOutputValue("cdn",i),this._logger.info(E.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:I.SUCCESSED,urls:e})),this}}),Object.defineProperty(t.prototype,"clearPublishStreamUrls",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._addOutputValue("cdn",[]),this._logger.info(E.L_MCU_CONFIG_BUILDER_CLEAR_PUBLISH_STREAM_URLS_O),this}}),Object.defineProperty(t.prototype,"addCustomizeLayoutVideo",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n,i,o){if(!s(t)||!this._isValidTrackId(t))return this._logger.error(E.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:I.FAILED,msg:"params error -> trackId: ".concat(t)})),this;if(!e(r)||!e(n))return this._logger.error(E.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:I.FAILED,msg:"params x or y is error -> x: ".concat(r,", y: ").concat(n)})),this;if([i,o].some((function(t){return!e(t)||t<0})))return this._logger.error(E.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:I.FAILED,msg:"params width or height error -> width: ".concat(i,", height: ").concat(o)})),this;var a=Pt(t),c=a.userId,u=a.tag;if(a.mediaType!==We.VIDEO_ONLY)return this._logger.error(E.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:I.FAILED,msg:"type of trackId: ".concat(t," is not video")})),this;var l=At(c,u),_=this._values.input||(this._values.input={}),d=_.video||(_.video=[]);return d.some((function(e){return e.height===o&&e.width===i&&e.stream_id===l&&e.user_id===c&&e.x===r&&e.y===n}))?(this._logger.warn(E.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:I.FAILED,msg:"Duplicate configuration item place ignored"})),this):(d.push({user_id:c,stream_id:l,x:r,y:n,width:i,height:o}),this._logger.info(E.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:I.SUCCESSED,trackId:t,x:r,y:n,width:i,height:o})),this)}}),Object.defineProperty(t.prototype,"removeCustomizeLayoutVideo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._isValidTrackId(e))return this._logger.error(E.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:I.FAILED,msg:"params error -> trackId: ".concat(e)})),this;var t=Pt(e),r=t.userId,n=t.tag;if(t.mediaType!==We.VIDEO_ONLY)return this._logger.error(E.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:I.FAILED,msg:"type of trackId: ".concat(e," is not video")})),this;var i=At(r,n),o=this._values.input;return(null==o?void 0:o.video)&&o.video.length>0&&(o.video=o.video.filter((function(e){return e.stream_id===i}))),this._logger.info(E.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:I.SUCCESSED,trackId:e})),this}}),Object.defineProperty(t.prototype,"clearCustomizeLayoutVideo",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._values.input;return null==e||delete e.video,this._logger.info(E.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_LAYOUT_VIDEO_O),this}}),Object.defineProperty(t.prototype,"setCustomizeInputAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return e.some((function(e){return t._isValidTrackId(e)}))?(this._logger.error(E.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:I.FAILED,msg:"trackIds contain invalid item -> trackIds: ".concat(e.join(","))})),this):((this._values.input||(this._values.input={})).audio=e.map((function(e){var t=Pt(e),r=t.userId,n=t.tag;return{stream_id:At(r,n),user_id:r}})),this._values.inputFilterMode=Ya.AUDIO_INPUT_VIDEO_ALL,this._logger.info(E.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:I.SUCCESSED,trackIds:e})),this)}}),Object.defineProperty(t.prototype,"addCustomizeInputAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._isValidTrackId(e))return this._logger.error(E.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:I.FAILED,msg:"params error -> trackId: ".concat(e)})),this;var t=this._values.input||(this._values.input={}),r=t.audio||(t.audio=[]),n=Pt(e),i=n.userId,o=n.tag,a=At(i,o);return r.some((function(e){return e.stream_id===a&&e.user_id===i}))?(this._logger.warn(E.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:I.FAILED,msg:"trackId: ".concat(e," is exist")})),this):(r.push({user_id:i,stream_id:a}),this._values.inputFilterMode=Ya.AUDIO_INPUT_VIDEO_ALL,this._logger.info(E.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:I.SUCCESSED,trackId:e})),this)}}),Object.defineProperty(t.prototype,"removeCustomizeInputAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._isValidTrackId(e))return this._logger.error(E.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:I.FAILED,msg:"params error -> trackId: ".concat(e)})),this;var t=this._values.input;if(!(null==t?void 0:t.audio)||0===t.audio.length)return this._logger.error(E.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:I.FAILED,msg:"type of trackId: ".concat(e," is not audio")})),this;var r=Pt(e),n=r.userId,i=r.tag,o=At(n,i);return t.audio=t.audio.filter((function(e){return n!==e.user_id||o!==e.stream_id})),this._logger.info(E.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:I.SUCCESSED,trackId:e})),this}}),Object.defineProperty(t.prototype,"clearCustomizeInputAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._values.input;return(null==e?void 0:e.audio)&&delete e.audio,this._values.inputFilterMode=Ya.AUDIO_VIDEO_ALL,this._logger.info(E.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_INPUT_AUDIO_O),this}}),Object.defineProperty(t.prototype,"addPictureWaterMark",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n,i,o,a){if(!this._isValidTrackId(t))return this._logger.error(E.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:I.FAILED,msg:"params error -> trackId: ".concat(t)})),this;if(!f(r))return this._logger.error(E.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:I.FAILED,msg:"params error -> uri: ".concat(r)})),this;if([n,i,o,a].some((function(t){return!e(t)||t<0||t>1}))||n+o>1||i+a>1)return this._logger.error(E.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:I.FAILED,msg:"some attrs of (x, y, w, h) is invalid -> x: ".concat(n,", y: ").concat(i,", w: ").concat(o,", h: ").concat(a)})),this;var s=Pt(t),c=s.userId,u=s.tag,l=At(c,u),_=(this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]})).singleScreen,d=_.filter((function(e){return e.streamId===l}))[0];return d?d.picture.push({uri:r,w:o,h:a,x:n,y:i}):_.push({streamId:l,picture:[{uri:r,w:o,h:a,x:n,y:i}]}),this._values.waterMark.singleScreen=_,this._logger.info(E.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:I.SUCCESSED,trackId:t,uri:r,x:n,y:i,w:o,h:a,singleScreen:_})),this}}),Object.defineProperty(t.prototype,"clearPictureWaterMark",{enumerable:!1,configurable:!0,writable:!0,value:function(){return(this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]})).singleScreen=[],this._logger.info(E.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}}),Object.defineProperty(t.prototype,"removePictureWaterMark",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!s(e)||!this._isValidTrackId(e))return this._logger.error(E.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:I.FAILED,msg:"params error -> trackId: ".concat(e)})),this;var r=Pt(e),n=r.userId,i=r.tag,o=At(n,i);return(this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]})).singleScreen.forEach((function(e){e.streamId===o&&(e.picture=e.picture.filter((function(e){return e.uri!==t})))})),this._logger.info(E.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:I.SUCCESSED,trackId:e,uri:t})),this}}),Object.defineProperty(t.prototype,"reset",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._values=$a(),this._logger.info(E.L_MCU_CONFIG_BUILDER_RESET_O),this}}),Object.defineProperty(t.prototype,"flush",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return void 0===e&&(e=!0),T(this,void 0,void 0,(function(){var t,r;return y(this,(function(n){switch(n.label){case 0:return t=JSON.parse(JSON.stringify(this._values)),[4,this._invoker.push(new Za(t,this._values))];case 1:return r=n.sent().code,e&&(this._values=$a()),[2,{code:r}]}}))}))}}),Object.defineProperty(t.prototype,"__innerGetValues",{enumerable:!1,configurable:!0,writable:!0,value:function(){return JSON.parse(JSON.stringify(this._values))}}),t}();!function(e){e[e.VIDEO=0]="VIDEO",e[e.AUDIO=1]="AUDIO"}(Xa||(Xa={}));var ts,rs=function(e){function t(t,r,n){var i=e.call(this)||this;return Object.defineProperty(i,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"roomPKHandler",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:n}),i}return R(t,e),Object.defineProperty(t.prototype,"_exchangeWithPushOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o,a,s,c,u,l,_,d;return y(this,(function(f){switch(f.label){case 0:return n=e.logger,i=e.peer,o=e.context,i.getLocalTracks().length?(a=i,[4,ba(t.getSubscribedList(),!1,a,t,o)]):(n.info(E.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:I.SUCCESSED,msg:"have not published resource"}),this.traceId),[2]);case 1:return s=f.sent(),c=e.getPushOtherRooms(),s.pushOtherRooms=c,[4,new da(s,this.traceId,!0).execute(e,t,r)];case 2:return(u=f.sent()).code!==O.SUCCESS?(n.error(E.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:I.FAILED,code:u.code,pushOtherRooms:c}),this.traceId),[2]):(l=u.data.data,_=l.sdp,(d=l.resultCode)!==O.SUCCESS?(n.error(E.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:I.FAILED,code:d,pushOtherRooms:c}),this.traceId),[2]):(n.info(E.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:I.SUCCESSED,pushOtherRooms:c}),this.traceId),a.setRemoteAnswer(_.sdp),[2]))}}))}))}}),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.EXCHANGE_WITH_PUSH_OTHER_ROOM},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i;return y(this,(function(o){switch(o.label){case 0:return n=e.logger,i=this.roomId,n.info(E.L_EXCHANGE_WITH_PUSHOTHERROOM_T,i),this.roomPKHandler?this.roomPKHandler.getPKInfo(i)?[4,this._exchangeWithPushOtherRoom(e,t,r)]:(n.warn(E.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:I.FAILED,msg:"PKInfo not exist"}),this.traceId),[2,{code:O.SUCCESS}]):(n.error(E.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:I.FAILED,msg:"_roomPKHandler not exist"}),this.traceId),[2,{code:O.SUCCESS}]);case 1:return o.sent(),[2,{code:O.SUCCESS}]}}))}))}}),t}(Ko),ns=function(e){function t(t,r,n,i,o,a){var s=e.call(this)||this;return Object.defineProperty(s,"pkHandler",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(s,"room",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"_PKInfo",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(s,"_joinedPKRooms",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(s,"isQuitPK",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(s,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:a}),s}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.LEAVE_OTHER_ROOM},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"quitRoomPK",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return T(this,void 0,void 0,(function(){var o,a,s,c,u,l,_,d,f,p;return y(this,(function(h){switch(h.label){case 0:return o=e.logger,a=e.context,o.info(E.L_QUIT_PK_T,"roomId: ".concat(t),n),this._PKInfo[t]?(s=this._PKInfo[t],c=s.inviterRoomId,u=s.inviteeRoomId,l=s.inviterUserId,_=s.inviteSessionId,d={inviteeRoomId:u,inviterRoomId:c,userId:r.crtUserId},f={roomId:r.roomId,endRoomId:t,sessionId:_,content:JSON.stringify(d),keys:["".concat(c,"|").concat(l)]},[4,a.endRoomPK(f)]):(o.warn(E.L_QUIT_PK_R,"status: ".concat(I.FAILED,", msg: pkinfo is empty"),n),[2]);case 1:return(p=h.sent())!==i.SUCCESS?(o.error(E.L_QUIT_PK_R,"status: ".concat(I.FAILED,", code: ").concat(p),n),[2,{code:O.SIGNAL_ERROR}]):(o.info(E.L_QUIT_PK_R,"status: ".concat(I.SUCCESSED),n),delete this._PKInfo[t],[2])}}))}))}}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o,a,s;return y(this,(function(c){switch(c.label){case 0:return n=e.logger,o=(i=this).room,a=i.isQuitPK,s=o.getRoomId(),n.info(E.L_LIVING_ROOM_LEAVE_PK_ROOM_T,JSON.stringify({roomId:s,isQuitPK:a}),this.traceId),[4,o.__destroy(!0)];case 1:return c.sent(),delete this._joinedPKRooms[s],[4,new rs(s,this.pkHandler,this.traceId).execute(e,t,r)];case 2:return c.sent(),a&&this.quitRoomPK(e,s,t,this.traceId),n.info(E.L_LIVING_ROOM_LEAVE_PK_ROOM_R,JSON.stringify({status:I.SUCCESSED}),this.traceId),[2,{code:O.SUCCESS}]}}))}))}}),t}(Ko),is=function(){function e(e,t,r,n,i,o,a,s,c,u){Object.defineProperty(this,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_PKInfo",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_mainLivingRoom",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_registerPKMsgListener",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_onJoinedPKRoom",{enumerable:!0,configurable:!0,writable:!0,value:c}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:u}),Object.defineProperty(this,"_inviteTimeout",{enumerable:!0,configurable:!0,writable:!0,value:30}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_mainRoomId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_joinedPKRooms",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._context.logger,this._registerPKMsgListener(this._onRecvPKMsg.bind(this)),this._mainRoomId=this._mainLivingRoom.getRoomId()}return Object.defineProperty(e.prototype,"_callAppListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=null===(t=this._appListener)||void 0===t?void 0:t[e];if(i)try{i.apply(void 0,P([],L(r),!1))}catch(e){this._logger.error(E.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify(e))}}}),Object.defineProperty(e.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.inviteInfo||{},r=t.inviterRoomId,n={inviterRoomId:r,inviterUserId:t.inviterUserId,extra:t.extra};this._PKInfo[r]=t,this._logger.info(E.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onRequestJoinOtherRoom",info:n})),this._callAppListener("onRequestJoinOtherRoom",n)}}),Object.defineProperty(e.prototype,"_onCancelInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.inviteInfo||{},r=t.inviterRoomId,n={inviterRoomId:r,inviterUserId:t.inviterUserId,extra:t.extra};delete this._PKInfo[r],this._logger.info(E.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCancelRequestOtherRoom",cancelInfo:n})),this._callAppListener("onCancelRequestOtherRoom",n)}}),Object.defineProperty(e.prototype,"_onInviteTimeout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){}}),Object.defineProperty(e.prototype,"_onInviteAnswer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.answerCode,r=e.inviteContent,n=r.inviteSessionId,i=r.inviterUserId,o=r.inviterRoomId,a=r.inviteeUserId,s=r.inviterUserAutoMix,c=r.inviteeUserAutoMix,u=r.inviteeRoomId,l={agree:1===t,inviterRoomId:o,inviterUserId:i,inviteeRoomId:u,inviteeUserId:a,extra:r.extra};this._PKInfo[u]=this._PKInfo[u]||{inviteSessionId:n,inviterRoomId:o,inviterUserId:i,inviterUserAutoMix:s,inviteeRoomId:u},this._PKInfo[u].inviteeUserAutoMix=c,this._logger.info(E.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onResponseJoinOtherRoom",answerInfo:l})),this._callAppListener("onResponseJoinOtherRoom",l)}}),Object.defineProperty(e.prototype,"createLeaveOtherRoomCommand",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return new ns(this,e,this._PKInfo,this._joinedPKRooms,t,r)}}),Object.defineProperty(e.prototype,"_onPKEnd",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n,i,o,a,s,c;return y(this,(function(u){switch(u.label){case 0:return t=e.inviteInfo,r=t.inviteeRoomId,n=t.inviterRoomId,i=t.userId,o=n===this._mainRoomId?r:n,a={endRoomId:o,endUserId:i},s=this._joinedPKRooms[o],c=this._logger.createTraceId(),this._logger.info(E.L_QUIT_PK_LEAVE_PK_ROOM_O,void 0,c),s?[4,this._invoker.push(this.createLeaveOtherRoomCommand(s,!0,c))]:[3,2];case 1:u.sent(),u.label=2;case 2:return delete this._PKInfo[o],this._logger.info(E.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onFinishOtherRoom",endInfo:a})),this._callAppListener("onFinishOtherRoom",a),[2]}}))}))}}),Object.defineProperty(e.prototype,"_onRecvPKMsg",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.content;switch(e.messageType){case Ft.PK_INVITE:this._onInvite(t);break;case Ft.PK_CANCEL_INVITE:this._onCancelInvite(t);break;case Ft.PK_INVITE_TIMEOUT:this._onInviteTimeout(t);break;case Ft.PK_INVITE_ANSWER:this._onInviteAnswer(t);break;case Ft.PK_END:this._onPKEnd(t)}}}),Object.defineProperty(e.prototype,"registerRoomPKEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(E.L_LIVING_PK_HANDLER_REGISTER_ROOM_PK_EVENT_LISTENER_O,JSON.stringify({listener:e&&Object.keys(e)})),this._appListener=e}}),Object.defineProperty(e.prototype,"requestJoinOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return T(this,void 0,void 0,(function(){var o,a,c,u,l,_;return y(this,(function(d){switch(d.label){case 0:return o=this._logger.createTraceId(),this._logger.info(E.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:e,inviteeUserId:t,options:n}),o),r("inviteeRoomId",e,s,!0)&&r("inviteeUserId",t,s,!0)?(a=uo(),c=!p(null==n?void 0:n.autoMix)||(null==n?void 0:n.autoMix),u={inviteSessionId:a,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:c,inviteeRoomId:e,inviteeUserId:t,inviteeTimeoutTime:this._inviteTimeout,extra:(null==n?void 0:n.extra)||""},l={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteTimeout:this._inviteTimeout,inviteInfo:JSON.stringify(u),inviteSessionId:a},[4,this._context.requestRoomPK(l)]):(this._logger.error(E.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),o),[2,{code:O.PARAMS_ERROR}]);case 1:return(_=d.sent())!==i.SUCCESS?(this._logger.error(E.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.FAILED,code:_}),o),[2,{code:_}]):(this._PKInfo[e]={inviteSessionId:a,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:c,inviteeRoomId:e},this._logger.info(E.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.SUCCESSED}),o),[2,{code:O.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"cancelRequestJoinOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return T(this,void 0,void 0,(function(){var o,a,c,u;return y(this,(function(l){switch(l.label){case 0:return o=this._logger.createTraceId(),this._logger.info(E.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:e,inviteeUserId:t,extra:n}),o),r("inviteeRoomId",e,s,!0)&&r("inviteeUserId",t,s,!0)?this._PKInfo[e]?(a={inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviteeRoomId:e,inviteeUserId:t,extra:n||""},c={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteSessionId:this._PKInfo[e].inviteSessionId,inviteInfo:JSON.stringify(a)},[4,this._context.cancelRoomPK(c)]):(this._logger.error(E.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"The request to connect with ".concat(t," user in room ").concat(e," is not initiated")}),o),[2,{code:O.PARAMS_ERROR}]):(this._logger.error(E.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),o),[2,{code:O.PARAMS_ERROR}]);case 1:return(u=l.sent())!==i.SUCCESS?(this._logger.error(E.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.FAILED,code:u}),o),[2,{code:u}]):(this._logger.info(E.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.SUCCESSED}),o),delete this._PKInfo[e],[2,{code:O.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"responseJoinOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,o){return T(this,void 0,void 0,(function(){var a,c,u,l,_,d,f,b,g,m;return y(this,(function(v){switch(v.label){case 0:return a=this._logger.createTraceId(),this._logger.info(E.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_T,JSON.stringify({inviterRoomId:e,inviterUserId:t,agree:n,options:o}),a),r("inviterRoomId",e,s,!0)&&r("inviterUserId",t,s,!0)?this._PKInfo[e]?(c=this._PKInfo[e],u=c.inviteSessionId,l=c.inviterUserAutoMix,_=!p(null==o?void 0:o.autoMix)||(null==o?void 0:o.autoMix),d={inviteSessionId:u,inviterRoomId:e,inviterUserId:t,inviterUserAutoMix:l,inviteeRoomId:this._mainRoomId,inviteeUserId:this._context.getCurrentId(),inviteeUserAutoMix:_},f=Object.assign(d,{inviterUserAutoMix:l}),b=n?Object.assign(d,{MultiRoomKey:"".concat(e,"|").concat(this._mainRoomId),MultiRoomValue:JSON.stringify(f)}):d,!h(null==o?void 0:o.extra)&&Object.assign(b,{extra:o.extra}),g={agree:n,roomId:this._mainRoomId,inviteSessionId:u,inviteRoomId:e,inviteUserId:t,content:JSON.stringify(b),key:"".concat(e,"|").concat(this._mainRoomId),value:JSON.stringify(d)},[4,this._context.responseRoomPK(g)]):(this._logger.error(E.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"User ".concat(t," in room ").concat(e," did not send a request for connection")}),a),[2,{code:O.PARAMS_ERROR}]):(this._logger.error(E.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> inviterRoomId or inviterUserId"}),a),[2,{code:O.PARAMS_ERROR}]);case 1:return(m=v.sent())!==i.SUCCESS?(this._logger.error(E.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.FAILED,code:m}),a),[2,{code:m}]):(this._logger.info(E.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.SUCCESSED}),a),this._PKInfo[e].inviteeUserAutoMix=_,[2,{code:O.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"joinOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,n,i,o,c;return y(this,(function(u){switch(u.label){case 0:return t=this._logger.createTraceId(),this._logger.info(E.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_T,JSON.stringify({roomId:e}),t),r("roomId",e,s,!0)?this._context.getConnectionStatus()!==a.CONNECTED?(this._logger.error(E.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.FAILED,code:O.SIGNAL_DISCONNECTED,msg:"IM disconnected"}),t),[2,{code:O.SIGNAL_DISCONNECTED}]):this._joinedPKRooms[e]?(this._logger.warn(E.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.FAILED,code:O.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),t),[2,{code:O.REPERT_JOIN_ROOM}]):(n=Xa.VIDEO,i={extra:'{"roomId": "'.concat(this._mainRoomId,'"}')},[4,(o=new ls(this._context,this._runtime,e,this._service,this._initOptions,n,!1,!1,this._clientSessionId)).__innerInit(Ho.LIVE,void 0,n,i)]):(this._logger.error(E.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> roomId"}),t),[2,{code:O.PARAMS_ERROR}]);case 1:return(c=u.sent().code)!==O.SUCCESS?(this._logger.error(E.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.FAILED,code:c}),t),[2,{code:c}]):(this._joinedPKRooms[e]=o,[4,this._onJoinedPKRoom(e,t)]);case 2:return u.sent(),this._logger.info(E.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:I.SUCCESSED}),t),[2,{room:o,code:O.SUCCESS,userIds:o.getRemoteUserIds(),tracks:o.getRemoteTracks()}]}}))}))}}),Object.defineProperty(e.prototype,"leaveOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r;return y(this,(function(n){return r=this._logger.createTraceId(),this._logger.info(E.L_APP_CALL_LEAVE_PK_ROOM_O,void 0,r),[2,this._invoker.push(this.createLeaveOtherRoomCommand(e,t,r))]}))}))}}),Object.defineProperty(e.prototype,"getPKInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._PKInfo[e]}}),Object.defineProperty(e.prototype,"getAllPKInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._PKInfo}}),Object.defineProperty(e.prototype,"getJoinedPKRooms",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._joinedPKRooms}}),e}();!function(e){e[e.OPEN=1]="OPEN",e[e.STOP=2]="STOP"}(ts||(ts={}));var os,as=function(e){function t(t,r){var n=e.call(this)||this;return Object.defineProperty(n,"cdnValues",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"enable",{enumerable:!0,configurable:!0,writable:!0,value:r}),n}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.ENABLE_INNER_CDN},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o,a,s,c,u;return y(this,(function(l){switch(l.label){case 0:return n=e.logger,i=e.context,o=this.enable,n.info(E.L_LIVING_ROOM_ENABLE_INNER_CDN_T,JSON.stringify({roomId:t.roomId,enable:o})),t.isMainRoom?p(o)?(t.setCDNEnabel(o),a={version:2,output:{inCDNModel:o?ts.OPEN:ts.STOP}},[4,new Za(a,this.cdnValues).execute(e,t,r)]):(n.error(E.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> enable"})),[2,{code:O.PARAMS_ERROR}]):(n.error(E.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:I.FAILED,code:O.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),[2,{code:O.THE_FUNCTION_IS_DISABLED_IN_PKROOM}]);case 1:return(s=l.sent().code)!==O.SUCCESS?(n.error(E.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:I.FAILED,code:s,msg:"signal error"})),[2,{code:O.SIGNAL_ERROR}]):(c=t.getCDNUris())&&c.broadcast!==ea.SPREAD?(n.info(E.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:I.SUCCESSED,enable:o})),[2,{code:O.SUCCESS}]):[4,va(i,t)];case 2:return(u=l.sent().code)===O.SUCCESS?(n.info(E.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:I.SUCCESSED,enable:o})),[2,{code:O.SUCCESS}]):(n.error(E.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:I.FAILED,code:u})),[2,{code:u}])}}))}))}}),t}(Ko);!function(e){e[e.AnchorToViewer=1]="AnchorToViewer",e[e.ViewerToAnchor=2]="ViewerToAnchor"}(os||(os={}));var ss,cs,us=function(e){function t(t,r){var n=e.call(this)||this;return Object.defineProperty(n,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),n}return R(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Do.RTC_IDENTITY_CHANGE},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n;return T(this,void 0,void 0,(function(){var o,a,s,c;return y(this,(function(u){switch(u.label){case 0:return[4,e.context.rtcIdentityChange(t.roomId,os.ViewerToAnchor,this.livingType)];case 1:return o=u.sent(),a=o.code,s=o.data,a===i.SUCCESS&&s?(t.initWithRoomData(s,this.traceId),t.getResourcesByUserId(t.crtUserId).length>0&&r.push(new qo),(c=null===(n=s.roomInfo.filter((function(e){return"cdn_uris"===e.key}))[0])||void 0===n?void 0:n.value)&&t.setCDNUris(JSON.parse(c)[0]),[2,{code:a,data:s}]):[2,{code:a}]}}))}))}}),t}(Ko),ls=function(e){function t(t,r,n,i,o,a,s,c,u){var l=e.call(this,t,r,n,Ho.LIVE,i,o,s,c,u)||this;return Object.defineProperty(l,"_livingType",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(l,"_mcuConfigBuilder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(l,"_roomPKHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),l._mcuConfigBuilder=new es(l._executeCtx,l._invoker,l._isValidResourceId.bind(l)),l}return R(t,e),Object.defineProperty(t.prototype,"_initRoomPKHandler",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(this._store.isMainRoom){var r=(n=this._roomId,i=t.roomInfo,o={},i.forEach((function(e){var t=JSON.parse(e.value),r=t.inviterRoomId,i=t.inviteeRoomId;o[n===r?i:r]=JSON.parse(e.value)})),o);this._roomPKHandler=new is(this._invoker,r,this._context,this._runtime,this._service,this._initOptions,this,e.prototype._registerPKMsgListener.bind(this),this._onJoinedPKRoom.bind(this),this._clientSessionId)}var n,i,o}}),Object.defineProperty(t.prototype,"__innerInit",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,o,a,s){return T(this,void 0,void 0,(function(){var c,u,l;return y(this,(function(_){switch(_.label){case 0:return r("livingType",i,(function(e){return e===Xa.AUDIO||e===Xa.VIDEO}))?[4,e.prototype.__innerInit.call(this,t,n,i,o,a,s)]:(this._logger.error(E.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> livingType"}),s),[2,{code:O.PARAMS_ERROR}]);case 1:return c=_.sent(),u=c.code,l=c.data,u===O.SUCCESS&&l&&this._initRoomPKHandler(l),[2,{code:u,data:l}]}}))}))}}),Object.defineProperty(t.prototype,"__innerInitByIdentityChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n;return y(this,(function(o){switch(o.label){case 0:return[4,this._invoker.push(new us(this._livingType,e))];case 1:return t=o.sent(),r=t.code,n=t.data,r===i.SUCCESS&&n?(this._initRoomPKHandler(n),this._initWithRoomData(n.offlineKickTime),this._logger.info(E.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:I.SUCCESSED,roomData:n}),e)):this._logger.error(E.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:I.FAILED,code:r}),e),[2,r]}}))}))}}),Object.defineProperty(t.prototype,"publish",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return T(this,void 0,void 0,(function(){return y(this,(function(r){return this._store.isMainRoom?[2,e.prototype.publish.call(this,t)]:(this._logger.error(E.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:I.FAILED,code:O.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),[2,{code:O.THE_FUNCTION_IS_DISABLED_IN_PKROOM}])}))}))}}),Object.defineProperty(t.prototype,"unpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return T(this,void 0,void 0,(function(){return y(this,(function(r){return this._store.isMainRoom?[2,e.prototype.unpublish.call(this,t)]:(this._logger.error(E.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:I.FAILED,code:O.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),[2,{code:O.THE_FUNCTION_IS_DISABLED_IN_PKROOM}])}))}))}}),Object.defineProperty(t.prototype,"_isValidResourceId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,n=Pt(e).userId,i=!!(null===(t=this._store.getResourcesByUserId(n))||void 0===t?void 0:t.find((function(t){return Lt(t)===e}))),o=this.getRoomPKHandler(),a=o.code,s=o.roomPKHandler;if(a!==O.SUCCESS||!s)return i;var c=s.getJoinedPKRooms(),u=[];return Object.values(c).forEach((function(e){u.push.apply(u,P([],L(e.getRemoteTracks()),!1))})),r=u.some((function(t){return e===t.getTrackId()})),i||r}}),Object.defineProperty(t.prototype,"getLivingType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._livingType}}),Object.defineProperty(t.prototype,"getMCUConfigBuilder",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.isMainRoom?this._mcuConfigBuilder:(this._logger.error(E.L_LIVING_ROOM_GET_MCU_CONFIG_BUILDER_O,"the `getMCUConfigBuilder` is disabled in PK room"),{code:O.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}}),Object.defineProperty(t.prototype,"enableInnerCDN",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){return y(this,(function(t){return[2,this._invoker.push(new as(this._mcuConfigBuilder.__innerGetValues(),e))]}))}))}}),Object.defineProperty(t.prototype,"_resourceHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n,i,o){return T(this,void 0,void 0,(function(){return y(this,(function(a){return e.prototype._resourceHandle.call(this,t,r,n,i,o),[2]}))}))}}),Object.defineProperty(t.prototype,"__getCDNEnable",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return!!(null===(e=this._store.getCDNUris())||void 0===e?void 0:e.enableInnerCDN)}}),Object.defineProperty(t.prototype,"__getCDNPushMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return null===(e=this._store.getCDNUris())||void 0===e?void 0:e.push_mode}}),Object.defineProperty(t.prototype,"_onJoinedPKRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){return y(this,(function(r){return this._invoker.push(new rs(e,this._roomPKHandler,t)),[2]}))}))}}),Object.defineProperty(t.prototype,"_getPushOtherRoomsParams",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[];if(!this.isMainRoom()||!this._roomPKHandler)return e;var t=this._roomPKHandler.getJoinedPKRooms();for(var r in t){var n=t[r].getSessionId(),i=this._roomPKHandler.getPKInfo(r);if(i){var o=i.inviterUserAutoMix,a=i.inviteeUserAutoMix,s=i.inviterUserId,c=this._context.getCurrentId()===s;e.push({roomId:r,sessionId:n,autoMix:c?!!o:!!a})}}return e}}),Object.defineProperty(t.prototype,"getRoomPKHandler",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.isMainRoom?(this._logger.info(E.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:I.SUCCESSED})),{code:O.SUCCESS,roomPKHandler:this._roomPKHandler}):(this._logger.error(E.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:I.SUCCESSED,code:O.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:O.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}}),Object.defineProperty(t.prototype,"_quitAllPKRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return T(this,void 0,void 0,(function(){var e,t;return y(this,(function(r){for(t in e=this._roomPKHandler.getJoinedPKRooms())this._roomPKHandler.leaveOtherRoom(e[t]);return this._logger.info(E.L_LIVING_ROOM_QUIT_ALL_PK_ROOM_O,JSON.stringify({status:I.SUCCESSED,roomIds:Object.keys(e)})),[2]}))}))}}),Object.defineProperty(t.prototype,"isMainRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.isMainRoom}}),t}(Qa),_s=function(e){function t(t,r,n,i,o,a,s){return void 0===a&&(a=Ho.RTC),void 0===s&&(s=!1),e.call(this,t,r,n,a,i,o,!1,!1,uo(),s)||this}return R(t,e),t}(Qa),ds=function(){function e(){Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"locked",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"taskCount",{enumerable:!0,configurable:!0,writable:!0,value:0})}return Object.defineProperty(e.prototype,"checkToStart",{enumerable:!1,configurable:!0,writable:!0,value:function(){return T(this,void 0,void 0,(function(){var e,t,r,n,i,o;return y(this,(function(a){switch(a.label){case 0:if(0===this.queue.length||this.locked)return[2];this.locked=!0,e=this.queue.shift(),t=e.resolve,r=e.task,n=e.reject,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r()];case 2:return i=a.sent(),t(i),[3,4];case 3:return o=a.sent(),n(o),[3,4];case 4:return this.locked=!1,this.checkToStart(),[2]}}))}))}}),Object.defineProperty(e.prototype,"push",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,n=new Promise((function(t,n){r.queue.push({resolve:t,task:e,reject:n})}));return this.checkToStart(),n}}),e}(),fs=new ds,ps=function(e,t){return void 0===t&&(t=""),fs.push(e,t)},hs=function(){function e(e,t,r){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_pc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rtcToken",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_liveUrl",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_subTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_subscribedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:uo()}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_livingType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_subTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_fromRetry",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._crtUserId=this._context.getCurrentId(),this._service=new ho(t,e,r.mediaServer),this._logger=this._context.logger,this._store=new zo(this._logger,this._clientSessionId,this._context.getAppkey(),this._crtUserId,this._crtUserId,Ho.LIVE)}return Object.defineProperty(e.prototype,"_getReqHeaders",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n,o;return y(this,(function(a){switch(a.label){case 0:return t=this._crtUserId,this._rtcToken?[3,2]:[4,this._context.getRTCToken(t,Ho.LIVE,e)];case 1:if(r=a.sent(),n=r.code,o=r.data,n!==i.SUCCESS)return[2,{code:O.SIGNAL_ERROR}];this._rtcToken=o.rtcToken,a.label=2;case 2:return[2,{code:O.SUCCESS,headers:{"App-Key":this._context.getAppkey(),UserId:this._crtUserId,RoomId:t,RoomType:Ho.LIVE,Token:this._rtcToken,"Client-Session-Id":this._clientSessionId}}]}}))}))}}),Object.defineProperty(e.prototype,"_clearSubscribeInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;this._liveUrl="",this._livingType=null,this._mediaType=null,this._subTiny=!1,this._subTracks.length=0,null===(e=this._pc)||void 0===e||e.destroy(),this._pc=null}}),Object.defineProperty(e.prototype,"_reTryExchange",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return T(this,void 0,void 0,(function(){var t;return y(this,(function(r){switch(r.label){case 0:return this._fromRetry=!0,[4,this.subscribe(this._liveUrl,this._livingType,this._mediaType,this._subTiny)];case 1:return(t=r.sent().code)===O.SUCCESS&&(null===(e=this._pc)||void 0===e||e.clearReTryExchangeTimer()),[2,{code:t}]}}))}))}}),Object.defineProperty(e.prototype,"subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return void 0===n&&(n=!1),T(this,void 0,void 0,(function(){var i=this;return y(this,(function(o){return[2,ps((function(){return i.__subscribe(e,t,r,n)}),"audience-client-sub")]}))}))}}),Object.defineProperty(e.prototype,"__subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i;return void 0===n&&(n=!1),T(this,void 0,void 0,(function(){var o,a,s,u,l,_,d,f,p,h,b,g,m,v=this;return y(this,(function(R){switch(R.label){case 0:return this._logger.info(E.L_AUDIENCE_CLIENT_SUBSCRIBE_T,JSON.stringify({liveUrl:e,livingType:t,mediaType:r,subTiny:n})),o=[],Ht(this._context.getNaviInfo())?(this._logger.error(E.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:I.FAILED,code:O.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"})),[2,{code:O.PACKAGE_ENVIRONMENT_ERROR,tracks:o}]):(!this._fromRetry&&(null===(i=this._pc)||void 0===i||i.clearReTryExchangeTimer()),this._fromRetry=!1,c(e)?[Xa.AUDIO,Xa.VIDEO].includes(t)?[We.AUDIO_ONLY,We.VIDEO_ONLY,We.AUDIO_VIDEO].includes(r)?this._liveUrl&&this._liveUrl!==e?(this._logger.error(E.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:I.FAILED,code:O.BROADCAST_SUB_LIST_NOT_EMPTY,msg:"repeat subscribe"})),[2,{code:O.BROADCAST_SUB_LIST_NOT_EMPTY,tracks:o}]):(this._pc||(this._pc=new Jo(this._logger,this._reTryExchange.bind(this),this._crtUserId,this._store,void 0,!1),this._pc.on(Jo.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),this._pc.registerReportListener(this._reportListener),this._pc.__reportR3R4ToPolaris()),this._liveUrl=e,[4,this._getReqHeaders(t)]):(this._logger.error(E.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> -> mediaType: ".concat(r)})),[2,{code:O.PARAMS_ERROR,tracks:o}]):(this._logger.error("livingType is invalid: ".concat(t)),this._logger.error(E.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> livingType: ".concat(t)})),[2,{code:O.PARAMS_ERROR,tracks:o}]):(this._logger.error(E.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> liveUrl: ".concat(e)})),[2,{code:O.PARAMS_ERROR,tracks:o}]));case 1:return a=R.sent(),s=a.code,u=a.headers,s!==O.SUCCESS?(this._logger.error(E.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:I.FAILED,code:s,msg:"getRTCToken failed"})),[2,{code:s,tracks:o}]):(l="rc_mcu_".concat(Date.now()),_="RongCloudRTC",0===this._subTracks.length&&(this._subTracks.push(new Rt(this._logger,_,l),new Ot(this._logger,_,l)),this._pc.updateSubRemoteTracks(this._subTracks.slice())),[4,this._pc.createOffer(!0)]);case 2:return d=R.sent(),f={sdp:d,liveUrl:e,mediaType:r,simulcast:n?so.TINY:so.NORMAL,switchstream:!1},[4,this._service.broadcastSubscribe(u,f)];case 3:return(p=R.sent()).code!==O.SUCCESS?(this._logger.error(E.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:I.FAILED,code:p.code})),[2,{code:p.code,tracks:o}]):(h=p.data).resultCode!==O.SUCCESS?(this._logger.error(E.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:I.FAILED,code:h.resultCode,msg:h.message})),[2,{code:h.resultCode,tracks:o}]):(this._livingType=t,this._mediaType=r,this._subTiny=n,b=h.sdp,g=h.subscribedList,this._subscribedList=g,m=[],g.forEach((function(e){var t=e.mediaType,r=v._subTracks[t];m.push(r),r.__innerSetRemoteMuted(!0)})),this._pc.setRemoteAnswer(b.sdp),m&&this._updateTrackIdSSRCMap(b.sdp,m),this._logger.info(E.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:I.SUCCESSED,liveUrl:e})),[2,{code:O.SUCCESS,tracks:m}])}}))}))}}),Object.defineProperty(e.prototype,"_updateTrackIdSSRCMap",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;t.forEach((function(t){var n=t.getTrackId(),i=Pt(n).mediaType,o=r._subscribedList.filter((function(e){return e.mediaType===i}))[0].msid,a=Sa(e,o,i);r._store.setTrackIdSSRCMap(Number(a),n)}))}}),Object.defineProperty(e.prototype,"unsubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return T(this,void 0,void 0,(function(){var e=this;return y(this,(function(t){return[2,ps((function(){return e.__unsubscribe()}),"audience-client-unsub")]}))}))}}),Object.defineProperty(e.prototype,"__unsubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return T(this,void 0,void 0,(function(){var t,r;return y(this,(function(n){switch(n.label){case 0:return this._logger.info(E.L_AUDIENCE_CLIENT_UNSUBSCRIBE_T,JSON.stringify({liveUrl:this._liveUrl})),null===(e=this._pc)||void 0===e||e.clearReTryExchangeTimer(),this._rtcToken&&this._liveUrl?[4,this._getReqHeaders()]:(this._logger.warn(E.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:I.FAILED,code:"",msg:"Address does not exist, without unsubscribe"})),[2,{code:O.SUCCESS}]);case 1:return t=n.sent().headers,[4,this._service.broadcastExit(t)];case 2:return(r=n.sent().code)!==O.SUCCESS?this._logger.error(E.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:I.FAILED,code:r})):(this._logger.info(E.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:I.SUCCESSED,liveUrl:this._liveUrl})),this._subscribedList=[]),this._clearSubscribeInfo(),[2,{code:r}]}}))}))}}),Object.defineProperty(e.prototype,"registerReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._reportListener=e}}),Object.defineProperty(e.prototype,"registerTrackEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._appListener=e}}),Object.defineProperty(e.prototype,"_onTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,n=e.receiver.track,i="audio"===n.kind?We.AUDIO_ONLY:We.VIDEO_ONLY,o=this._subTracks[i];o.__innerSetMediaStreamTrack(n);try{this._logger.info(E.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,"trackId: ".concat(o.getTrackId())),null===(r=null===(t=this._appListener)||void 0===t?void 0:t.onTrackReady)||void 0===r||r.call(t,o)}catch(e){this._logger.error(E.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,JSON.stringify(e))}}}),e}();!function(e){e.RTMP="rtmp",e.FLV="flv",e.HLS="hls"}(ss||(ss={})),function(e){e[e.NOT_HTTPS=0]="NOT_HTTPS",e[e.HTTPS=1]="HTTPS"}(cs||(cs={}));var bs,gs=S(S({},kt(Ke.W176_H144)),{frameRate:jt(He.FPS_15)}),ms=function(){function e(e,t,r,n,i,o,a){void 0===a&&(a=uo());var s=this;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,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_joinResData",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_roomAnchorList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_roomRes",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_roomAnchorRes",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_remoteTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_pc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subscribedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_audioLevelReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_CDNUris",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isPulling",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_pullTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._logger=this._context.logger,this._crtUserId=this._context.getCurrentId(),this._polarisReport=new za(this._context,this._runtime,this._roomId,this,Va.Audience),this._reportMediaActionLogger=new Ga(this._logger,this._roomId,this._clientSessionId,this._crtUserId),this._service=new ho(this._runtime,this._context,this._initOptions.mediaServer,this._initOptions.timeout);var c=this._store=new zo(this._logger,a,e.getAppkey(),n,this._crtUserId,Ho.LIVE),u=this._pc=new Jo(this._logger,this._reTryExchange.bind(this),this._crtUserId,c,this._polarisReport,!0);this._audioLevelReport=new Go(this._store,u),u.on(Jo.__INNER_AUDIOLEVEL_CHANGE__,this._audioLevelReport.audioLevelReport,this._audioLevelReport),this._polarisReport.sendR1(),this._context.registerRTCSignalListener((function(e){return T(s,void 0,void 0,(function(){var t,r,n,i;return y(this,(function(o){return t=this._context.decodeRtcNotify(e),r=t.time,n=t.type,i=t.roomId,1===n&&this._startPull(i,r),[2]}))}))})),this._setInitData()}return Object.defineProperty(e.prototype,"_startPull",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n,o,a,s;return y(this,(function(c){switch(c.label){case 0:return this._isPulling?[2]:(this._isPulling=!0,this._pullTime>t?(this._isPulling=!1,[2]):(r=this._logger.createTraceId(),this._logger.info(E.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T,"pullTime: ".concat(this._pullTime),r),[4,this._context.pullRTCRoomEntry(e)]));case 1:return n=c.sent(),o=n.code,a=n.data,o===i.SUCCESS&&(this._isPulling=!1,this._pullTime=(null==a?void 0:a.syncTime)||0,s=(null==a?void 0:a.kvEntries)||[],this._logger.info(E.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,"status: ".concat(I.SUCCESSED,", kvEntries: ").concat(JSON.stringify(s)),r),this.singalDataChange(s,e,r)),this._logger.info(E.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,"status: ".concat(I.FAILED,", code: ").concat(o),r),[2]}}))}))}}),Object.defineProperty(e.prototype,"_setInitData",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=function(e,t,r){var n=t.filter((function(e){return"RC_RTC_SESSIONID"===e.key}))[0],i=n?n.value:"",o=t.filter((function(e){return"RC_ANCHOR_LIST"===e.key})).map((function(e){return JSON.parse(e.value||"[]")}))[0],a=t.filter((function(e){return e.key.includes("RC_RES_")})).map((function(e){return JSON.parse(e.value||"{}")})),s=a.length?JSON.parse(a[0].mcu_uris||"[]"):[],c=[];s.forEach((function(t){var n=t.mediaType,i=t.tag,o=n===We.AUDIO_ONLY?new Rt(r,i,"",e):new Ot(r,i,"",e);c.push(o)}));var u=[],l=[];a.forEach((function(e){var t=JSON.parse(e.uris||"[]");u.push.apply(u,P([],L(t),!1)),t.forEach((function(e){var t=e.mediaType,n=e.tag,i=e.msid.split("_");i.pop();var o=i.join("_"),a=t===We.AUDIO_ONLY?new Rt(r,n,o):new Ot(r,n,o);l.push(a)}))}));var _=t.filter((function(e){return"RC_CDN"===e.key})).map((function(e){var t=JSON.parse(e.value||"[]");return JSON.parse(t.cdn_uris)[0]}))[0];return{sessionId:i,remoteUserIds:o||[],remoteRTCUris:u,remoteMUCUris:s,remoteRTCTracks:l,remoteMCUTracks:c,remoteTracks:P(P([],L(l),!1),L(c),!1),CDNUris:_||{}}}(this._roomId,this._joinResData.kvEntries,this._logger),r=t.sessionId,n=t.remoteUserIds,i=t.remoteRTCUris,o=t.remoteMUCUris,a=t.remoteTracks,s=t.CDNUris;this._sessionId=r,this._roomAnchorList=n,a.forEach((function(t){e._remoteTracks[t.getTrackId()]=t})),this._CDNUris=s,i.forEach((function(t){var r=t.msid.split("_")[0];e._roomAnchorRes[r]?e._roomAnchorRes[r].push(t):e._roomAnchorRes[r]=[t];var n=JSON.parse(t.uri),i=n.ssrc,o=n.resourceId;e._store.setTrackIdSSRCMap(i,o)})),o.forEach((function(t){var r=t.mediaType,n=t.tag,i=[e._roomId,n,r].join("_");e._roomRes[i]=t;var o=JSON.parse(t.uri).ssrc;e._store.setTrackIdSSRCMap(o,i)})),i.forEach((function(t){var r=Lt(t);e._roomRes[r]=t}))}}),Object.defineProperty(e.prototype,"_assertRoomDestroyed",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this._destroyed)return O.ROOM_HAS_BEEN_DESTROYED}}),Object.defineProperty(e.prototype,"singalDataChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n,i=this;if(t===this._roomId){var o=[],a=null===(n=e.filter((function(e){return"RC_CDN"===e.key}))[0])||void 0===n?void 0:n.value;a&&this._diffCDNUris(JSON.parse(JSON.parse(a).cdn_uris)[0],r),e.forEach((function(e){var t=e.key,n=e.value,a=e.uid;if(-1!==t.indexOf("RC_RES_")){var s=JSON.parse(n||"{}"),c=JSON.parse(s.mcu_uris||"[]"),u=JSON.parse(s.uris||"[]");return o.push.apply(o,P([],L(c),!1)),void i._diffAnchorResource(u,a,r)}if("RC_ANCHOR_LIST"===t){var l=JSON.parse(n||"[]");i._diffAnchorList(l,r)}})),this._diffRoomResource(o,r)}else this._logger.error(E.L_AUDIENCE_LIVING_ROOM_SINGAL_DATA_CHANGE_P,JSON.stringify({status:I.FAILED,msg:"roomId inconsistency -> params roomId:".concat(t,", current roomId:").concat(this._roomId)}),r)}}),Object.defineProperty(e.prototype,"_diffAnchorList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,n=e.filter((function(e){return r._roomAnchorList.indexOf(e)<0})),i=this._roomAnchorList.filter((function(t){return e.indexOf(t)<0}));n.length>0&&this._handleNewJoinedAnchor(n,t),i.length>0&&this._handleLeftedAnchor(i,t)}}),Object.defineProperty(e.prototype,"_handleNewJoinedAnchor",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;(r=this._roomAnchorList).push.apply(r,P([],L(e),!1)),this._logger.info(E.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorJoin",list:e}),t),this._callAppListener("onAnchorJoin",e)}}),Object.defineProperty(e.prototype,"_handleLeftedAnchor",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n=this;return y(this,(function(i){switch(i.label){case 0:return this._roomAnchorList=this._roomAnchorList.filter((function(t){return!e.includes(t)})),r=[],e.forEach((function(e){r.push.apply(r,P([],L(n.getRemoteTracksByUserId(e)),!1)),delete n._roomAnchorRes[e]})),r.length?[4,this.unsubscribe(r)]:[3,2];case 1:i.sent(),r.forEach((function(e){return delete n._remoteTracks[e.getTrackId()]})),i.label=2;case 2:return this._logger.info(E.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorLeave",list:e}),t),this._callAppListener("onAnchorLeave",e),[2]}}))}))}}),Object.defineProperty(e.prototype,"_diffRoomResource",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n,i,o=this;return y(this,(function(a){return r=[],n=[],i=[],e.forEach((function(e){var t=Lt(e),n=Pt(t),a=n.tag,s=n.mediaType,c=[o._roomId,a,s].join("_"),u=JSON.parse(e.uri).ssrc;if(o._store.setTrackIdSSRCMap(u,c),!o._remoteTracks[c]){var l=s===We.AUDIO_ONLY?new Rt(o._logger,a,"",o._roomId):new Ot(o._logger,a,"",o._roomId);r.push(l),o._remoteTracks[c]=l,o._roomRes[l.getTrackId()]=e}i.push(c)})),Object.keys(this._remoteTracks).forEach((function(e){i.indexOf(e)<0&&o._remoteTracks[e].isMCUTrack()&&n.push(o._remoteTracks[e])})),r.length>0&&(this._logger.info(E.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackPublish",trackIds:r.map((function(e){return e.getTrackId()}))}),t),this._callAppListener("onTrackPublish",r)),n.length>0&&this._onUserUnpublish(n,"onTrackUnpublish",t),[2]}))}))}}),Object.defineProperty(e.prototype,"_dealPublished",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o,a,s,c=this;return y(this,(function(u){switch(u.label){case 0:return n=e.map(Lt),i=[],o=[],t.forEach((function(t){var r=Lt(t),a=n.indexOf(r),s=Pt(r),u=s.userId,l=s.tag,_=s.mediaType,d=JSON.parse(t.uri).ssrc;c._store.setTrackIdSSRCMap(d,r),a>-1?e[a]=t:e.push(t);var f=c._remoteTracks[r];c._roomRes[r]=t,f?f.isSubscribed()&&i.push(f):(f=_===We.AUDIO_ONLY?new Rt(c._logger,l,u):new Ot(c._logger,l,u),c._remoteTracks[r]=f,o.push(f)),f.__innerSetRemoteMuted(0===t.state)})),i.length?(a=i.map((function(e){return e.getTrackId()})),[4,ps((function(){return c._subscribeHandle(i,!0)}))]):[3,2];case 1:(s=u.sent().code)!==O.SUCCESS&&this._logger.error(E.L_RESUB_REPUB_RES_R,JSON.stringify({status:I.FAILED,trackIds:a,code:s})),u.label=2;case 2:return this._logger.info(E.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorTrackPublish",trackIds:o.map((function(e){return e.getTrackId()}))}),r),this._callAppListener("onAnchorTrackPublish",o),[2]}}))}))}}),Object.defineProperty(e.prototype,"_dealUnpublished",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o,a,s=this;return y(this,(function(c){switch(c.label){case 0:for(n=t.map(Lt),i=e.length-1;i>=0;i-=1)o=e[i],n.includes(Lt(o))&&e.splice(i,1);return a=t.map((function(e){var t=Lt(e);return s._remoteTracks[t]})),[4,this._onUserUnpublish(a,"onAnchorTrackUnpublish",r)];case 1:return c.sent(),[2]}}))}))}}),Object.defineProperty(e.prototype,"_dealModified",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n,i,o=e.map(Lt);try{for(var a=C(t),s=a.next();!s.done;s=a.next()){var c=s.value,u=Lt(c);e[o.indexOf(u)].state=c.state;var l=this._remoteTracks[u];l.__innerSetRemoteMuted(0===c.state);var _=l.isAudioTrack()?"onAudioMuteChange":"onVideoMuteChange";this._logger.info(E.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:_,trackId:l.getTrackId()}),r),this._callAppListener(_,l)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}}}),Object.defineProperty(e.prototype,"_diffAnchorResource",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o,a,s;return y(this,(function(c){switch(c.label){case 0:return n=this._roomAnchorRes[t]||(this._roomAnchorRes[t]=[]),i=wt(n,e),o=i.publishedList,a=i.unpublishedList,s=i.modifiedList,o.length?[4,this._dealPublished(n,o,r)]:[3,2];case 1:c.sent(),c.label=2;case 2:return a.length?[4,this._dealUnpublished(n,a,r)]:[3,4];case 3:c.sent(),c.label=4;case 4:return s.length&&this._dealModified(n,s,r),[2]}}))}))}}),Object.defineProperty(e.prototype,"_onUserUnpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n=this;return y(this,(function(i){switch(i.label){case 0:return[4,this.unsubscribe(e)];case 1:return i.sent(),e.forEach((function(e){n._subscribedList=n._subscribedList.filter((function(t){return t.track.getTrackId()!==e.getTrackId()})),delete n._roomRes[e.getTrackId()],e.__innerDestroy(),delete n._remoteTracks[e.getTrackId()]})),this._logger.info(E.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:t,trackIds:e.map((function(e){return e.getTrackId()}))}),r),this._callAppListener(t,e),[2]}}))}))}}),Object.defineProperty(e.prototype,"_callAppListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=null===(t=this._appListener)||void 0===t?void 0:t[e];if(i)try{i.apply(void 0,P([],L(r),!1))}catch(e){this._logger.error(E.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify(e))}}}),Object.defineProperty(e.prototype,"_reTryExchange",{enumerable:!1,configurable:!0,writable:!0,value:function(){return T(this,void 0,void 0,(function(){var e=this;return y(this,(function(t){return[2,ps((function(){return T(e,void 0,void 0,(function(){var e,t,r,n,i,o,a,s,c,u;return y(this,(function(l){switch(l.label){case 0:return[4,this._createSubscribeParams(this._subscribedList,{},!0)];case 1:return e=l.sent().reqBody,[4,this._exchangeHandle(e)];case 2:return(t=l.sent()).code!==O.SUCCESS?[2,{code:t.code}]:(r=t.data,n=r.sdp,(i=r.resultCode)!==O.SUCCESS?[2,{code:i}]:(this._pc.clearReTryExchangeTimer(),(o=this._subscribedList.filter((function(e){return e.track.isMCUTrack()}))).length>0&&(a=o[0].track.getTrackId(),s=null===(u=this._roomRes[a])||void 0===u?void 0:u.msid,c=[this._roomId,"RongCloudRTC"].join("_"),n.sdp=n.sdp.replace(new RegExp(s,"g"),c)),[4,this._pc.setRemoteAnswer(n.sdp)]));case 3:return[2,{code:l.sent()}]}}))}))}),"audience-retry-exchange")]}))}))}}),Object.defineProperty(e.prototype,"_createSubscribeParams",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o,a=this;return y(this,(function(s){switch(s.label){case 0:return[4,this._pc.createOffer(r)];case 1:return n=s.sent(),i={resolutionInfo:[]},o={min:0,max:0},Object.keys(t).forEach((function(e){var r=t[e];[r.mediaStream,r.tinyStream].forEach((function(t,r){var a,s=1===r?[e,"tiny"].join("_"):e;n.sdp=null===(a=n.sdp)||void 0===a?void 0:a.replace(new RegExp(t.id,"g"),s);var c=t.getVideoTracks()[0];if(c){var u=0===r,l=u?yt(c):gs,_=l.width,d=l.height,f=l.frameRate;i.resolutionInfo.push({trackId:c.id,simulcast:u?so.NORMAL:so.TINY,resolution:"".concat(_,"x").concat(d)});var p=Ze(_,d),h=$e(f);o.min+=p.minBitrate*h,o.max+=p.maxBitrate*h}}))})),[2,{reqBody:{sdp:n,switchstream:!1,newVersionFlag:!0,subscribeList:e.map((function(e){return{simulcast:e.subTiny?so.TINY:so.NORMAL,resolution:"",uri:a._roomRes[e.track.getTrackId()].uri}}))},dynamicBitrate:o,offer:n}]}}))}))}}),Object.defineProperty(e.prototype,"_subscribeHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=!1),T(this,void 0,void 0,(function(){var i,o,a,s,c,l;return y(this,(function(_){return i=Date.now(),o=n?_a.SUB:void 0,a=this._logger.createTraceId(),this._logger.info(E.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:e.map(Wt),forceReq:t}),a),this._assertRoomDestroyed()?(this._logger.error(E.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:I.FAILED,code:O.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),a),this._reportPubOrSubQualityData(i,e,O.ROOM_HAS_BEEN_DESTROYED,o),[2,{code:O.ROOM_HAS_BEEN_DESTROYED}]):r("tracks",e,(function(){return u(e)&&e.length>0&&e.every((function(e){return e instanceof vt||e.track instanceof vt}))}),!0)?(this._pc.__reportR3R4ToPolaris(),this._pc.registerReportListener(this._reportListener),this._addPeerCEvent(),s=this._subscribedList.map((function(e){return S({},e)})),c=e.map((function(e){return e instanceof vt?{track:e}:e})),l=[],c.forEach((function(e){var t=e.track.getTrackId();l.push(t);var r=s.find((function(e){return e.track.getTrackId()===t}));r&&r.subTiny===e.subTiny||(r?r.subTiny=e.subTiny:s.push(e))})),this._polarisReport.sendR2(Xo.SUBSCRIBE,$o.BEGIN,l),[2,this._updateSubListHandle(s,a,i,o,!0)]):(this._logger.error(E.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> tracks"}),a),this._reportPubOrSubQualityData(i,e,O.PARAMS_ERROR,o),[2,{code:O.PARAMS_ERROR}])}))}))}}),Object.defineProperty(e.prototype,"_addPeerCEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._pc.on(Jo.__INNER_EVENT_TRACK_READY__,(function(t){var r=t.streams[0].id,n=t.receiver.track,i=[r,"audio"===n.kind?We.AUDIO_ONLY:We.VIDEO_ONLY].join("_"),o=e._remoteTracks[i];o?(o.__innerSetMediaStreamTrack(n),e._logger.info(E.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackReady",trackId:o.getTrackId()})),e._callAppListener("onTrackReady",o)):e._logger.warn(E.L_AUDIENCE_LIVING_ROOM_ONTRACKREADY_O,"cannot found RCRemoteTrack: ".concat(n.id))})),this._pc.once(Jo.__INNER_ICE_CONNECTED__,(function(){e._reportMediaActionLogger.reportIceFirstConnectData("sub")}),this),this._pc.on(Jo.__INNER_ICE_STATE_CHANGE__,(function(t){var r=t.status,n=t.time,i=t.iceCandidatePair;i&&e._reportMediaActionLogger.recordQualityIceStatusData(i,r,n)}))}}),Object.defineProperty(e.prototype,"_getReqHeaders",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._crtUserId;return{"App-Key":this._context.getAppkey(),RoomId:e,Token:this._joinResData.token,RoomType:Ho.LIVE,UserId:e,"Session-Id":this._sessionId,"Client-Session-Id":this._clientSessionId}}}),Object.defineProperty(e.prototype,"_exchangeHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._service.broadcastSubscribe(this._getReqHeaders(),e)}}),Object.defineProperty(e.prototype,"_dealSubscribeResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var n,i=this,o=null==t?void 0:t.map((function(e){return"".concat(e.msid,"_").concat(e.mediaType)})),a=e.filter((function(e){if(e.track.isMCUTrack()){var t=i._roomRes[e.track.getTrackId()],r="".concat(t.msid,"_").concat(t.mediaType);return o.includes(r)}return null==o?void 0:o.includes(e.track.getTrackId())})),s=null==a?void 0:a.map((function(e){return"".concat(e.track.getTrackId())})),c=e.filter((function(e){return!(null==s?void 0:s.includes(e.track.getTrackId()))})),u=function(e){var t=a.some((function(t){return t.track.getTrackId()===e}));l._remoteTracks[e].__innerSetSubscribed(t)},l=this;for(var _ in this._remoteTracks)u(_);return(n=this._subscribedList).splice.apply(n,P([0,this._subscribedList.length],L(a),!1)),this._logger.info(E.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:I.SUCCESSED,subSuccessTrackIds:o,failedList:c}),r),c}}),Object.defineProperty(e.prototype,"_getParams",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.map((function(e){return e instanceof vt?{track:e}:S({},e)})),r={};return t=t.filter((function(e){var t=e.track.getTrackId();return!r[t]&&(r[t]=!0,!0)})).map((function(e){return S({},e)}))}}),Object.defineProperty(e.prototype,"_reportPubOrSubQualityData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){n&&this._reportMediaActionLogger.reportPubOrSubQualityData(n,e,t,r,this._trackMediaMap)}}),Object.defineProperty(e.prototype,"_updateSubListHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i){var o;return void 0===i&&(i=!1),T(this,void 0,void 0,(function(){var a,s,c,u,l,_,d,f,p,h,b,g,m=this;return y(this,(function(v){switch(v.label){case 0:return this._logger.info(E.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_T,JSON.stringify({trackIds:e.map(Wt),forceReq:i}),t),a=this._getParams(e),s=this._subscribedList.map((function(e){return S({},e)})),i||Ta(a,s)?(this._pc.clearReTryExchangeTimer(),this._pc.updateSubRemoteTracks(a.map((function(e){return e.track}))),[4,this._createSubscribeParams(a,{},!1)]):(this._logger.info(E.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:I.SUCCESSED,msg:"repeat subscribe"}),t),[2,{code:O.SUCCESS}]);case 1:return c=v.sent().reqBody,[4,this._exchangeHandle(c)];case 2:return u=v.sent(),s.length&&(l=[],s.forEach((function(e){l.push(e.track.getTrackId())})),null===(o=this._pc.reportParser)||void 0===o||o.clearLatestPacketsRecv(l)),e.forEach((function(e){var t=e instanceof vt?e.getTrackId():e.track.getTrackId();m._trackMediaMap[t]=u.qualityMsList||[]})),u.code!==O.SUCCESS?(this._reportPubOrSubQualityData(r,e,u.code,n),this._logger.error(E.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:I.FAILED,code:u.code}),t),[2,{code:u.code}]):(_=u.data,d=_.sdp,f=_.resultCode,p=_.message,h=_.subscribedList,f!==O.SUCCESS?(this._reportPubOrSubQualityData(r,e,f,n),this._logger.error(E.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:I.FAILED,code:f,msg:p}),t),[2,{code:f}]):(a.forEach((function(e){var t=e.track;if(t.isMCUTrack()){var r=m._roomRes[t.getTrackId()].msid,n=Pt(t.getTrackId()),i=n.tag,o=[n.userId,i].join("_");d.sdp=d.sdp.replace(new RegExp(r,"g"),o)}})),[4,this._pc.setRemoteAnswer(d.sdp)]));case 3:return b=v.sent(),this._reportPubOrSubQualityData(r,e,b,n),b!==O.SUCCESS?(this._logger.error(E.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:I.FAILED,code:b,msg:"set remote answer error"}),t),[2,{code:b}]):[2,(g=this._dealSubscribeResult(a,h,t)).length?{code:O.SUCCESS,failedList:g}:{code:O.SUCCESS}]}}))}))}}),Object.defineProperty(e.prototype,"_diffCDNUris",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n,i;return y(this,(function(o){return this._CDNUris.url&&!e.url?(this._logger.info(E.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCDNInfoDisable"}),t),this._callAppListener("onCDNInfoDisable"),this._CDNUris=e,[2]):((!this._CDNUris||!this._CDNUris.url&&e.url)&&(this._logger.info(E.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCDNInfoEnable",resolution:"W".concat(e.w,"_H").concat(e.h),fps:"FPS_".concat(e.fps)}),t),this._callAppListener("onCDNInfoEnable",{resolution:"W".concat(e.w,"_H").concat(e.h),fps:"FPS_".concat(e.fps)})),r=this._CDNUris.w&&e.w&&this._CDNUris.w!==e.w,n=this._CDNUris.h&&e.h&&this._CDNUris.h!==e.h,i=this._CDNUris.fps&&e.fps&&this._CDNUris.fps!==e.fps,(r||n||i)&&(this._logger.info(E.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCDNInfoChange",resolution:"W".concat(e.w,"_H").concat(e.h),fps:"FPS_".concat(e.fps)}),t),this._callAppListener("onCDNInfoChange",{resolution:"W".concat(e.w,"_H").concat(e.h),fps:"FPS_".concat(e.fps)})),this._CDNUris=e,[2])}))}))}}),Object.defineProperty(e.prototype,"_getCDNPlayUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n,i,o,a,s,c,u,l,_,d,f,p,h,b,g;return y(this,(function(m){switch(m.label){case 0:return r=e.w,n=e.h,i=e.fps,o=this._initOptions.pullInnerCDNProtocol||ss.FLV,a=this._initOptions.pullInnerCDNUseHttps===cs.NOT_HTTPS?cs.NOT_HTTPS:cs.HTTPS,this._CDNUris.url?(s={"App-Key":this._context.getAppkey(),Token:this._joinResData.token,RoomId:this.getRoomId(),UserId:this._crtUserId,SessionId:this.getSessionId()},c=[],u=this._CDNUris,l=u.w,_=void 0===l?0:l,d=u.h,_/(void 0===d?1:d)>1?(r&&c.push("w=".concat(r)),n&&c.push("h=".concat(n))):(r&&c.push("h=".concat(r)),n&&c.push("w=".concat(n))),i&&c.push("fps=".concat(i)),c.push("kind=".concat(o)),c.push("is_https=".concat(a)),f=c.join("&"),p="".concat(this._CDNUris.url,"?"),f&&(p+=f),[4,this._service.getCDNResourceInfo(s,p,t)]):(this._logger.error(E.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:I.FAILED,code:O.CDN_RESOURCE_IS_EMPTY,msg:"cdn_uris url is empty, the anchor need to open or push CDN"}),t),[2,{code:O.CDN_RESOURCE_IS_EMPTY}]);case 1:return h=m.sent(),b=h.code,g=h.res,b!==O.SUCCESS?[2,{code:b}]:[2,{code:b,CDNPlayUrl:null==g?void 0:g.data.pull_url}]}}))}))}}),Object.defineProperty(e.prototype,"getCDNPlayUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n,i,o,a,s;return y(this,(function(c){return r=this._logger.createTraceId(),this._logger.info(E.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_T,JSON.stringify({resolution:e,fps:t}),r),e&&!Ut(e)?(this._logger.error(E.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> resolution"}),r),[2,{code:O.PARAMS_ERROR}]):t&&!Mt(t)?(this._logger.error(E.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> fps"}),r),[2,{code:O.PARAMS_ERROR}]):(n=e?kt(e):{width:null,height:null},i=n.width,o=n.height,a=t?jt(t):null,s={},i&&(s.w=i),o&&(s.h=o),a&&(s.fps=a),[2,this._getCDNPlayUrl(s,r)])}))}))}}),Object.defineProperty(e.prototype,"subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t=this;return y(this,(function(r){return[2,ps((function(){return t._subscribeHandle(e,!1,!0)}),"audience-sub")]}))}))}}),Object.defineProperty(e.prototype,"__unsubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,n,i,o;return y(this,(function(a){return t=Date.now(),n=_a.UNSUB,i=this._logger.createTraceId(),this._logger.info(E.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map((function(e){return e.getTrackId()}))}),i),this._assertRoomDestroyed()?(this._logger.error(E.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:I.FAILED,code:O.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),i),[2,{code:O.ROOM_HAS_BEEN_DESTROYED}]):r("tracks",e,(function(){return u(e)&&e.length>0&&e.every((function(e){return e instanceof vt}))}),!0)?(o=this._subscribedList.map((function(e){return S({},e)})).filter((function(t){return e.every((function(e){return e.getTrackId()!==t.track.getTrackId()}))})),this._polarisReport.sendR2(Xo.SUBSCRIBE,$o.END,e.map((function(e){return e.getTrackId()}))),[2,this._updateSubListHandle(o,i,t,n,!1)]):(this._logger.error(E.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> tracks"}),i),[2,{code:O.PARAMS_ERROR}])}))}))}}),Object.defineProperty(e.prototype,"unsubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t=this;return y(this,(function(r){return[2,ps((function(){return t.__unsubscribe(e)}),"audience-unsub")]}))}))}}),Object.defineProperty(e.prototype,"__destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;return T(this,void 0,void 0,(function(){return y(this,(function(r){switch(r.label){case 0:return this._destroyed?[2]:(this._destroyed=!0,e?[4,this._context.quitLivingRoomAsAudience(this._roomId)]:[3,2]);case 1:r.sent(),r.label=2;case 2:return[4,this._service.broadcastExit(this._getReqHeaders())];case 3:return r.sent(),null===(t=this._pc)||void 0===t||t.destroy(),this._context.registerRTCSignalListener(),[2]}}))}))}}),Object.defineProperty(e.prototype,"getRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._remoteTracks[e]}}),Object.defineProperty(e.prototype,"getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return{}}}),Object.defineProperty(e.prototype,"__onReconnected",{enumerable:!1,configurable:!0,writable:!0,value:function(){return T(this,void 0,void 0,(function(){var e;return y(this,(function(t){switch(t.label){case 0:return e=this._logger.createTraceId(),this._logger.info(E.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_T,void 0,e),[4,this._context.joinLivingRoomAsAudience(this._roomId,Ho.LIVE)];case 1:return t.sent().code!==i.SUCCESS&&this._logger.error(E.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,"status: ".concat(I.FAILED),e),this._logger.info(E.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,"status: ".concat(I.SUCCESSED),e),[2]}}))}))}}),Object.defineProperty(e.prototype,"registerRoomEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._appListener=e}}),Object.defineProperty(e.prototype,"onAudioLevelChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(E.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O),this._audioLevelReport.onAudioLevelChange(e)}}),Object.defineProperty(e.prototype,"registerReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._reportListener=e}}),Object.defineProperty(e.prototype,"getRoomId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._roomId}}),Object.defineProperty(e.prototype,"getCrtUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._crtUserId}}),Object.defineProperty(e.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._sessionId}}),Object.defineProperty(e.prototype,"getRemoteUserIds",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._roomAnchorList}}),Object.defineProperty(e.prototype,"getRemoteTracksByUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=[];for(var r in this._remoteTracks){var n=this._remoteTracks[r];n.getUserId()===e&&t.push(n)}return t}}),Object.defineProperty(e.prototype,"getRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=[],r=[];for(var n in this._remoteTracks){if(2===r.length)break;var i=this._remoteTracks[n];i.isMCUTrack()&&r.push(i)}return this._roomAnchorList.forEach((function(r){t.push.apply(t,P([],L(e.getRemoteTracksByUserId(r)),!1))})),P(P([],L(r),!1),L(t),!1)}}),Object.defineProperty(e.prototype,"getRemoteRTCTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[];for(var t in this._remoteTracks){var r=this._remoteTracks[t];r.isMCUTrack()||e.push(r)}return e}}),Object.defineProperty(e.prototype,"getRemoteMCUTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[];for(var t in this._remoteTracks){var r=this._remoteTracks[t];r.isMCUTrack()&&e.push(r)}return e}}),Object.defineProperty(e.prototype,"getCDNInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._CDNUris.w?{resolution:"W".concat(this._CDNUris.w,"_H").concat(this._CDNUris.h),fps:"FPS_".concat(this._CDNUris.fps),CDNEnable:this._CDNUris.enableInnerCDN}:{CDNEnable:!1}}}),Object.defineProperty(e.prototype,"getClientSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._clientSessionId}}),e}();!function(e){e[e.AUTOMATIC=0]="AUTOMATIC",e[e.MANUAL=1]="MANUAL"}(bs||(bs={}));var vs,Rs,Os=function(){function e(e){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isElectron",{enumerable:!0,configurable:!0,writable:!0,value:/Electron/.test(navigator.userAgent)}),this._logger=e.logger}return Object.defineProperty(e.prototype,"_getMediaStream",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===t&&(t="getUserMedia"),T(this,void 0,void 0,(function(){var r,n,i;return y(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),r=this.setConstraintsConfig(e),[4,navigator.mediaDevices[t](r)];case 1:return n=o.sent(),[2,{code:O.SUCCESS,stream:n}];case 2:return i=o.sent(),this._logger.error(E.L_GET_MEDIA_STREAM_E,JSON.stringify({name:i.name,message:i.message})),"Permission denied"===i.message?[2,{code:O.BROWSER_PERMISSION_DENIED}]:"Permission denied by system"===i.message?[2,{code:O.SYSTEM_PERMISSION_DENIED}]:[3,3];case 3:return[2,{code:"getUserMedia"===t?O.GET_USER_MEDIA_FAILED:O.GET_DISPLAY_MEDIA_FAILED}]}}))}))}}),Object.defineProperty(e.prototype,"_getMediaStreamErrorReason",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t="";return e===O.BROWSER_PERMISSION_DENIED&&(t="Permission denied"),e===O.SYSTEM_PERMISSION_DENIED&&(t="Permission denied by system"),t}}),Object.defineProperty(e.prototype,"setConstraintsConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r;if((null==e?void 0:e.audio)&&!this._isElectron){"boolean"==typeof e.audio&&(e.audio={});var n=null===(r=(t=navigator.mediaDevices).getSupportedConstraints)||void 0===r?void 0:r.call(t);(null==n?void 0:n.noiseSuppression)&&(e.audio.noiseSuppression=!!n.noiseSuppression),(null==n?void 0:n.autoGainControl)&&(e.audio.autoGainControl=!!n.autoGainControl),(null==n?void 0:n.echoCancellation)&&(e.audio.echoCancellation=!!n.echoCancellation),this._logger.info(E.L_SET_AUDIO_CONSTRAINTS_O,"browser supported -> ".concat(JSON.stringify(n)))}return e}}),Object.defineProperty(e.prototype,"createMicrophoneAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===e&&(e="RongCloudRTC"),T(this,void 0,void 0,(function(){var r,n,i,o,a,s;return y(this,(function(c){switch(c.label){case 0:return St(e)?(r=this._context.getCurrentId())?[4,this._getMediaStream({audio:{deviceId:null==t?void 0:t.micphoneId,sampleRate:null==t?void 0:t.sampleRate,noiseSuppression:null==t?void 0:t.noiseSuppression,echoCancellation:null==t?void 0:t.echoCancellation,autoGainControl:null==t?void 0:t.autoGainControl}})]:(this._logger.error(E.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:I.FAILED,code:O.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:O.INVALID_USER_ID}]):(this._logger.error(E.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:I.FAILED,code:O.INVALID_TAGS,msg:"invalid tag"})),[2,{code:O.INVALID_TAGS}]);case 1:return n=c.sent(),i=n.stream,(o=n.code)!==O.SUCCESS?(this._logger.error(E.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:I.FAILED,code:o,msg:this._getMediaStreamErrorReason(o)})),[2,{code:o}]):(a=i.getAudioTracks()[0],s=new ht(this._logger,e,r,a),this._logger.info(E.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:I.SUCCESSED,trackId:s.getTrackId()})),[2,{code:o,track:s}])}}))}))}}),Object.defineProperty(e.prototype,"createCameraVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===e&&(e="RongCloudRTC"),T(this,void 0,void 0,(function(){var r,n,i,o,a,s,c,u,l,_;return y(this,(function(d){switch(d.label){case 0:return St(e)?(r=this._context.getCurrentId())?(n=Ut(null==t?void 0:t.resolution)?t.resolution:Ke.W640_H480,i=kt(n),o=i.width,a=i.height,[4,this._getMediaStream({video:{deviceId:null==t?void 0:t.cameraId,frameRate:jt((null==t?void 0:t.frameRate)||He.FPS_15),width:{ideal:o,max:o},height:{ideal:a,max:a},facingMode:null==t?void 0:t.faceMode}})]):(this._logger.error(E.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:I.FAILED,code:O.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:O.INVALID_USER_ID}]):(this._logger.error(E.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:I.FAILED,code:O.INVALID_TAGS,msg:"invalid tag"})),[2,{code:O.INVALID_TAGS}]);case 1:return s=d.sent(),c=s.stream,(u=s.code)!==O.SUCCESS?(this._logger.error(E.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:I.FAILED,code:u,msg:this._getMediaStreamErrorReason(u)})),[2,{code:u}]):(l=c.getVideoTracks()[0],[4,this._applyVideoAspectRatio(l,o,a)]);case 2:return d.sent(),_=new bt(this._logger,e,r,l),this._logger.info(E.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:I.SUCCESSED,trackId:_.getTrackId()})),[2,{code:u,track:_}]}}))}))}}),Object.defineProperty(e.prototype,"createMicrophoneAndCameraTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,n,i,o;return void 0===e&&(e="RongCloudRTC"),T(this,void 0,void 0,(function(){var a,s,c,u,l,_,d,f,p,h,b,g,m;return y(this,(function(v){switch(v.label){case 0:return a=[],St(e)?(s=this._context.getCurrentId())?(c=Ut(null===(r=null==t?void 0:t.video)||void 0===r?void 0:r.resolution)?t.video.resolution:Ke.W640_H480,u=kt(c),l=u.width,_=u.height,d=null==t?void 0:t.audio,[4,this._getMediaStream({video:{deviceId:null===(n=null==t?void 0:t.video)||void 0===n?void 0:n.cameraId,frameRate:jt((null===(i=null==t?void 0:t.video)||void 0===i?void 0:i.frameRate)||He.FPS_15),width:{ideal:l,max:l},height:{ideal:_,max:_},facingMode:null===(o=null==t?void 0:t.video)||void 0===o?void 0:o.faceMode},audio:{deviceId:null==d?void 0:d.micphoneId,sampleRate:null==d?void 0:d.sampleRate,noiseSuppression:null==d?void 0:d.noiseSuppression,echoCancellation:null==d?void 0:d.echoCancellation,autoGainControl:null==d?void 0:d.autoGainControl}})]):(this._logger.error(E.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:I.FAILED,code:O.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:O.INVALID_USER_ID,tracks:a}]):(this._logger.error(E.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:I.FAILED,code:O.INVALID_TAGS,msg:"invalid tag"})),[2,{code:O.INVALID_TAGS,tracks:a}]);case 1:if(f=v.sent(),p=f.stream,(h=f.code)!==O.SUCCESS)return this._logger.error(E.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:I.FAILED,code:h,msg:this._getMediaStreamErrorReason(h)})),[2,{code:h,tracks:a}];b=p.getTracks(),g=0,v.label=2;case 2:return g<b.length?"video"!==(m=b[g]).kind?[3,4]:[4,this._applyVideoAspectRatio(m,l,_)]:[3,6];case 3:return v.sent(),a.push(new bt(this._logger,e,s,m)),[3,5];case 4:a.unshift(new ht(this._logger,e,s,m)),v.label=5;case 5:return g++,[3,2];case 6:return this._logger.info(E.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:I.SUCCESSED,trackIds:a.map((function(e){return e.getTrackId()}))})),[2,{code:h,tracks:a}]}}))}))}}),Object.defineProperty(e.prototype,"createScreenVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===e&&(e="screenshare"),T(this,void 0,void 0,(function(){var r;return y(this,(function(n){switch(n.label){case 0:return[4,this._createScreenTracks(e,!1,E.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,t)];case 1:return(r=n.sent()).code===O.SUCCESS?[2,{code:r.code,track:r.tracks[0]}]:[2,r]}}))}))}}),Object.defineProperty(e.prototype,"createScreenWithAudioTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===e&&(e="screenshare"),T(this,void 0,void 0,(function(){return y(this,(function(r){return[2,this._createScreenTracks(e,!0,E.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_AND_AUDIO_TRACKS_O,t)]}))}))}}),Object.defineProperty(e.prototype,"_createScreenTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return T(this,void 0,void 0,(function(){var i,o,a,s,c,u,l,_,d,f,p,h;return y(this,(function(b){switch(b.label){case 0:return St(e)?(i=this._context.getCurrentId())?Vt()?(o=/macintosh|mac os x/i.test(navigator.userAgent),a=(!this._isElectron||!o)&&t,s=Ut(null==n?void 0:n.resolution)?n.resolution:Ke.W1280_H720,this._isElectron?[4,this._createElectronScreenStream(t,r,s,null==n?void 0:n.chromeMediaSourceId)]:[3,2]):(this._logger.error(E.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,JSON.stringify({status:I.FAILED,code:O.BROWSER_NOT_SUPPORT,msg:"browser not support"})),[2,{code:O.BROWSER_NOT_SUPPORT}]):(this._logger.error(r,JSON.stringify({status:I.FAILED,code:O.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:O.INVALID_USER_ID}]):(this._logger.error(r,JSON.stringify({status:I.FAILED,code:O.INVALID_TAGS,msg:"invalid tag"})),[2,{code:O.INVALID_TAGS}]);case 1:return _=b.sent(),[3,4];case 2:return[4,this._createWebScreenStream(t,s,null==n?void 0:n.frameRate)];case 3:_=b.sent(),b.label=4;case 4:return u=(c=_).stream,(l=c.code)!==O.SUCCESS?(this._logger.error(r,JSON.stringify({status:I.FAILED,code:l,msg:this._getMediaStreamErrorReason(l)})),[2,{code:l}]):(d=u.getVideoTracks()[0],f=new gt(this._logger,e,i,d),p=[f],a&&(h=u.getAudioTracks()[0])&&p.push(new mt(this._logger,e,i,h)),this._logger.info(r,JSON.stringify({status:I.SUCCESSED,trackIds:p.map((function(e){return e.getTrackId()}))})),[2,{code:l,tracks:p}])}}))}))}}),Object.defineProperty(e.prototype,"_createElectronScreenStream",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i,o;return T(this,void 0,void 0,(function(){var a,s,u,l,_,d,f;return y(this,(function(p){return a=/macintosh|mac os x/i.test(navigator.userAgent),this._isElectron&&a&&e&&this._logger.warn(t,JSON.stringify({status:I.INFO,code:O.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO,msg:"mac in electron not support screen share with audio"})),s=(!this._isElectron||!a)&&e,!this._isElectron||h(n)||c(n)?(u=kt(r),l=u.width,_=u.height,d={mandatory:{chromeMediaSourceId:n,chromeMediaSource:"desktop",minWidth:l,maxWidth:l,minHeight:_,maxHeight:_}},!n&&this._isElectron&&(null===(i=d.mandatory)||void 0===i||delete i.chromeMediaSourceId),f=null,s&&this._isElectron&&(null===(o=d.mandatory)||void 0===o||delete o.chromeMediaSourceId,f={mandatory:{chromeMediaSource:"desktop"}}),[2,this._getMediaStream({video:d,audio:f||s},"getUserMedia")]):(this._logger.error(t,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> options.chromeMediaSourceId type is string"})),[2,{code:O.PARAMS_ERROR}])}))}))}}),Object.defineProperty(e.prototype,"_createWebScreenStream",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o,a;return y(this,(function(s){return n=kt(t),i=n.width,o=n.height,a={frameRate:jt(r||He.FPS_15),width:i,height:o},[2,this._getMediaStream({video:a,audio:e},"getDisplayMedia")]}))}))}}),Object.defineProperty(e.prototype,"createLocalAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n;return y(this,(function(i){return St(e)?t&&"[object MediaStreamTrack]"===t.toString()&&"audio"===t.kind?(r=this._context.getCurrentId())?(n=new lt(this._logger,e,r,t),this._logger.info(E.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:I.SUCCESSED,trackId:n.getTrackId()})),[2,{code:O.SUCCESS,track:n}]):(this._logger.error(E.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:I.FAILED,code:O.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:O.INVALID_USER_ID}]):(this._logger.error(E.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:I.FAILED,code:O.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not audio"})),[2,{code:O.CREATE_CUSTOM_TRACK_FAILED}]):(this._logger.error(E.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:I.FAILED,code:O.INVALID_TAGS,msg:"invalid tag"})),[2,{code:O.INVALID_TAGS}])}))}))}}),Object.defineProperty(e.prototype,"createLocalVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n;return y(this,(function(i){return St(e)?t&&t instanceof MediaStreamTrack&&"video"===t.kind?(r=this._context.getCurrentId())?(n=new _t(this._logger,e,r,t),this._logger.info(E.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:I.SUCCESSED,trackId:n.getTrackId()})),[2,{code:O.SUCCESS,track:n}]):(this._logger.error(E.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:I.FAILED,code:O.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:O.INVALID_USER_ID}]):(this._logger.error(E.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:I.FAILED,code:O.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not video"})),[2,{code:O.CREATE_CUSTOM_TRACK_FAILED}]):(this._logger.error(E.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:I.FAILED,code:O.INVALID_TAGS,msg:"invalid tag"})),[2,{code:O.INVALID_TAGS}])}))}))}}),Object.defineProperty(e.prototype,"_validateCreateLocalFileTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!St(e))return this._logger.error(E.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:I.FAILED,code:O.INVALID_TAGS,msg:"invalid tag"})),{code:O.INVALID_TAGS,tracks:[]};if(!xt())return this._logger.error(E.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:I.FAILED,code:O.BROWSER_NOT_SUPPORT,msg:"browser not support"})),{code:O.BROWSER_NOT_SUPPORT,tracks:[]};var r=t instanceof File?URL.createObjectURL(t):t;return f(r)||/^blob:/.test(r)?this._context.getCurrentId()?{code:O.SUCCESS,tracks:[],url:r}:(this._logger.error(E.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:I.FAILED,code:O.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:O.INVALID_USER_ID,tracks:[]}):(this._logger.error(E.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> file"})),{code:O.PARAMS_ERROR,tracks:[]})}}),Object.defineProperty(e.prototype,"createLocalFileTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n){return T(this,void 0,void 0,(function(){var i,o,a=this;return y(this,(function(s){return(i=this._validateCreateLocalFileTracks(t,r)).code!==O.SUCCESS?[2,i]:(o=this._context.getCurrentId(),[2,new Promise((function(r){var s=document.createElement("video");(null==n?void 0:n.withoutAudio)&&(s.muted=!0),s.onloadedmetadata=function(){var i,c=[];try{var u=s.mozCaptureStream?"mozCaptureStream":"captureStream";i=s[u]()}catch(e){a._logger.error(E.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:I.FAILED,code:O.CREATE_FILE_TRACK_FAILED,msg:"captureSteam error -> ".concat(JSON.stringify(e))})),r({code:O.CREATE_FILE_TRACK_FAILED,tracks:c})}var l=L(e.getTracksWithOptions(i,n),2),_=l[0],d=l[1];_&&c.push(new pt(a._logger,t,o,_,s)),d&&c.push(new ft(a._logger,t,o,d,s)),0===c.length&&(s.pause(),s.src=""),s.onerror=null,a._logger.info(E.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:I.SUCCESSED,trackIds:c.map((function(e){return e.getTrackId()}))})),r({code:O.SUCCESS,tracks:c})},s.onerror=function(){a._logger.error(E.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:I.FAILED,code:O.CREATE_FILE_TRACK_FAILED,msg:"Failed to create file stream, video onerror"})),r({code:O.CREATE_FILE_TRACK_FAILED,tracks:[]})},s.src=i.url,s.loop=!0,s.play()}))])}))}))}}),Object.defineProperty(e.prototype,"createLocalTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,n){return T(this,void 0,void 0,(function(){var i,o,a,s,c;return y(this,(function(u){return i=[],St(t)?r instanceof MediaStream?(o=this._context.getCurrentId())?(a=L(e.getTracksWithOptions(r,n),2),s=a[0],c=a[1],s&&i.push(new lt(this._logger,t,o,s)),c&&i.push(new _t(this._logger,t,o,c)),this._logger.info(E.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:I.SUCCESSED,trackIds:i.map((function(e){return e.getTrackId()}))})),[2,{code:O.SUCCESS,tracks:i}]):(this._logger.error(E.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:I.FAILED,code:O.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:O.INVALID_USER_ID,tracks:i}]):(this._logger.error(E.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> stream"})),[2,{code:O.PARAMS_ERROR,tracks:i}]):(this._logger.error(E.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:I.FAILED,code:O.INVALID_TAGS,msg:"invalid tag"})),[2,{code:O.INVALID_TAGS,tracks:i}])}))}))}}),Object.defineProperty(e,"getTracksWithOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=[];return r[0]=(null==t?void 0:t.withoutAudio)?void 0:e.getAudioTracks()[0],r[1]=(null==t?void 0:t.withoutVideo)?void 0:e.getVideoTracks()[0],r}}),Object.defineProperty(e.prototype,"_applyVideoAspectRatio",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,i,o,a,s;return y(this,(function(c){switch(c.label){case 0:if(n=e.getSettings(),i=n.width,o=n.height,i===t&&o===r)return[2];a=t/r>=1?{width:{ideal:i,max:i}}:{height:{ideal:o,max:o}},c.label=1;case 1:return c.trys.push([1,3,,4]),[4,e.applyConstraints(S(S({},a),{aspectRatio:{ideal:t/r}}))];case 2:return c.sent(),this._logger.info(E.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:I.SUCCESSED,msg:"apply aspectRatio success -> ".concat(t," / ").concat(r)})),[3,4];case 3:return s=c.sent(),this._logger.warn(E.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:I.FAILED,msg:"apply aspectRatio error -> ".concat(JSON.stringify(s))})),[3,4];case 4:return[2]}}))}))}}),e}(),Es=function(e){function t(t,r,n){var i=e.call(this,t)||this;return Object.defineProperty(i,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"_options",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"_crtRoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(i,"_audience",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(i,"_crtAudienceLivingRoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),Mo.setSdpSemantics(n.sdpSemantics||"unified-plan",i._logger),i._service=new ho(i._runtime,i._context,i._options.mediaServer,i._options.timeout),i._context.registerConnectionStateChangeListener(i._onIMStatusChange.bind(i)),i._context.registerDestroyListener(i._onIMUninit.bind(i)),i._context.registerMessageListener(i._handleMessage.bind(i)),i._context.getPluginContext().onnavidatachange=i.naviDataChange.bind(i),i}return R(t,e),Object.defineProperty(t.prototype,"_handleMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.conversationType!==d.RTC_ROOM)return!1;var t=this._logger.createTraceId();this._crtRoom instanceof ls&&this._getJoinedPKRoomList().forEach((function(r){r.__parseInnerMessage(e,t)}));return this._logger.info(E.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:I.SUCCESSED,message:e}),t),this._crtRoom?(this._crtRoom.__parseInnerMessage(e,t),!0):(this._logger.warn(E.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:I.FAILED,message:"the crtRoom is empty"}),t),!0)}}),Object.defineProperty(t.prototype,"naviDataChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(E.L_RTC_CLIENT_NAVI_CHANGE_O,"on navi change data => ".concat(JSON.stringify(e))),this._service.clearMSList(),this._service.isNededDetector()&&this._service.detectorMediaSever()}}),Object.defineProperty(t.prototype,"_getJoinedPKRoomList",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._crtRoom.getRoomPKHandler(),t=e.code,r=e.roomPKHandler;if(t===O.SUCCESS&&r){var n=r.getJoinedPKRooms()||{};return Object.values(n)}return[]}}),Object.defineProperty(t.prototype,"getCurrentId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._context.getCurrentId()}}),Object.defineProperty(t.prototype,"joinCrossRTCRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i){return void 0===i&&(i=Ho.CROSS_MUTI),T(this,void 0,void 0,(function(){return y(this,(function(n){return console.warn("joinCrossRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),[2,this.joinRTCRoomWithOptions(e,{joinType:t,userData:r,mode:Ho.CROSS_MUTI})]}))}))}}),Object.defineProperty(t.prototype,"joinRTCRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i){return void 0===i&&(i=Ho.RTC),T(this,void 0,void 0,(function(){return y(this,(function(n){return console.warn("joinRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),[2,this.joinRTCRoomWithOptions(e,{mode:i,joinType:t,userData:r})]}))}))}}),Object.defineProperty(t.prototype,"joinRTCRoomWithOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n,i,o=this;return y(this,(function(a){switch(a.label){case 0:return r=this._logger.createTraceId(),this._logger.info(E.L_RTC_CLIENT_JOIN_RTC_ROOM_T,JSON.stringify({roomId:e,options:t}),r),this._crtRoom?(this._logger.error(E.L_RTC_CLIENT_JOIN_RTC_ROOM_R,JSON.stringify({status:I.FAILED,code:O.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),r),[2,{code:O.REPERT_JOIN_ROOM}]):[4,(n=this._crtRoom=new _s(this._context,this._runtime,e,this._service,this._options,null==t?void 0:t.mode,null==t?void 0:t.encrypt)).__innerInit((null==t?void 0:t.mode)||Ho.RTC,null==t?void 0:t.joinType,void 0,void 0,null==t?void 0:t.userData,r)];case 1:return(i=a.sent().code)!==O.SUCCESS?(this._crtRoom=null,[2,{code:i}]):(n.once(qa,(function(){o._crtRoom=null})),[2,{code:i,room:n,userIds:n.getRemoteUserIds(),tracks:n.getRemoteTracks()}])}}))}))}}),Object.defineProperty(t.prototype,"joinLivingRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i){return T(this,void 0,void 0,(function(){var i,o,a,s,c=this;return y(this,(function(u){switch(u.label){case 0:return i=this._logger.createTraceId(),this._logger.info(E.L_RTC_CLIENT_JOIN_LIVING_ROOM_T,JSON.stringify({roomId:e,livingType:t,joinType:r,outerUserDatas:n}),i),this._crtRoom?(this._logger.error(E.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:I.FAILED,code:O.REPERT_JOIN_ROOM,msg:"Join the room repeatedly -> roomId: ".concat(e)}),i),[2,{code:O.REPERT_JOIN_ROOM}]):[4,(o=this._crtRoom=new ls(this._context,this._runtime,e,this._service,this._options,t,!1,!0)).__innerInit(Ho.LIVE,r,t,void 0,n,i)];case 1:return(a=u.sent().code)!==O.SUCCESS?(this._crtRoom=null,[2,{code:a}]):(o.once(qa,(function(){c._crtRoom=null})),s={code:a,room:o,userIds:o.getRemoteUserIds(),tracks:o.getRemoteTracks()},o.__getCDNPushMode()===bs.MANUAL&&Object.assign(s,{CDNEnable:o.__getCDNEnable()}),[2,s])}}))}))}}),Object.defineProperty(t.prototype,"getAudienceClient",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._audience||(this._audience=new hs(this._context,this._runtime,this._options)),this._logger.info(E.L_RTC_CLIENT_GET_AUDIENCE_CLIENT_O),this._audience}}),Object.defineProperty(t.prototype,"_onIMStatusChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._logger.info(E.L_RTC_CLIENT_IM_CONNECTION_STATE_S,JSON.stringify({status:e,code:t,desc:a[e]})),e===a.SUSPENDED&&t===i.RC_CONN_REDIRECTED&&this._service.clearMSList(),e===a.DISCONNECTED){if(this._crtRoom){var r=ka.IM_DISCONNECTED;t===i.RC_DISCONN_KICK?r=ka.OTHER_CLIENT_IM_CONNECTED:2===t&&(r=ka.IM_LOGOUT),this._crtRoom.__kickoff(!0,{users:[{userId:this._context.getCurrentId(),type:r}]})}}else if(e===a.CONNECTED){if(this._service.isNededDetector()&&this._service.detectorMediaSever(),this._crtRoom instanceof ls)this._getJoinedPKRoomList().forEach((function(e){e.__onReconnected()}));this._crtRoom&&this._crtRoom.__onReconnected()}}}),Object.defineProperty(t.prototype,"_onIMUninit",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;this._logger.info(E.L_RTC_CLIENT_DESTROY_S,JSON.stringify({msg:"TODO -> on IM client ondestroy"})),null===(e=this._crtRoom)||void 0===e||e.__destroy(!0)}}),Object.defineProperty(t.prototype,"leaveRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;return T(this,void 0,void 0,(function(){var r;return y(this,(function(n){switch(n.label){case 0:return r=this._logger.createTraceId(),this._logger.info(E.L_RTC_CLIENT_LEAVE_ROOM_T,JSON.stringify({roomId:e.getRoomId()}),r),this._crtRoom?[4,this._crtRoom.__destroy(!0)]:(this._logger.warn(E.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:I.FAILED,msg:"Room does not exist, without leave"}),r),[2,{code:O.SUCCESS}]);case 1:return n.sent(),this._service.isNededDetector()&&this._service.detectorMediaSever(),this._logger.info(E.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:I.SUCCESSED,roomId:null===(t=this._crtRoom)||void 0===t?void 0:t.getRoomId()}),r),this._crtRoom=null,[2,{code:O.SUCCESS}]}}))}))}}),Object.defineProperty(t.prototype,"joinLivingRoomAsAudience",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return T(this,void 0,void 0,(function(){var n,o,a,c,u,l;return y(this,(function(_){switch(_.label){case 0:return n=this._logger.createTraceId(),this._logger.info(E.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_T,JSON.stringify({roomId:e,livingType:t}),n),this._service.isNededDetector()&&this._service.detectorMediaSever(),Ht(this._context.getNaviInfo())?(this._logger.error(E.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:I.FAILED,code:O.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),n),[2,{code:O.PACKAGE_ENVIRONMENT_ERROR}]):r("roomId",e,s,!0)&&r("livingType",t,(function(e){return e===Xa.AUDIO||e===Xa.VIDEO}))?this._crtAudienceLivingRoom?(this._logger.error(E.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:I.FAILED,code:O.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),n),[2,{code:O.REPERT_JOIN_ROOM}]):this._service.getMsList().length?[4,this._context.joinLivingRoomAsAudience(e,Ho.LIVE,t)]:(this._logger.error(E.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:I.FAILED,code:O.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),n),[2,{code:O.NOT_OPEN_VIDEO_AUDIO_SERVER}]):(this._logger.error(E.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> roomId or livingType"}),n),[2,{code:O.PARAMS_ERROR}]);case 1:return o=_.sent(),a=o.code,c=o.data,a!==i.SUCCESS?(this._logger.error(E.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:I.FAILED,code:a,msg:"signal error -> audience join room"}),n),[2,{code:O.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED}]):(u=uo(),l=new ms(this._context,this._runtime,this._options,e,c,t,u),this._crtAudienceLivingRoom=l,this._logger.info(E.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:I.SUCCESSED,roomData:c}),n),[2,{room:l,code:O.SUCCESS,userIds:l.getRemoteUserIds(),RTCTracks:l.getRemoteRTCTracks(),MCUTracks:l.getRemoteMCUTracks(),CDNUris:l.getCDNInfo()}])}}))}))}}),Object.defineProperty(t.prototype,"leaveLivingRoomAsAudience",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t;return y(this,(function(r){switch(r.label){case 0:return t=this._logger.createTraceId(),this._logger.info(E.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_T,JSON.stringify({roomId:e.getRoomId(),userId:this._context.getCurrentId()}),t),this._crtAudienceLivingRoom?this._crtAudienceLivingRoom!==e?(this._logger.error(E.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> room"}),t),[2,{code:O.PARAMS_ERROR}]):[4,this._crtAudienceLivingRoom.__destroy(!0)]:(this._logger.warn(E.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:I.FAILED,msg:"Room does not exist, without leave"}),t),[2,{code:O.SUCCESS}]);case 1:return r.sent(),this._crtAudienceLivingRoom=null,this._logger.info(E.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:I.SUCCESSED}),t),[2,{code:O.SUCCESS}]}}))}))}}),Object.defineProperty(t.prototype,"upgradeToAnchorRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,n,o,a,s,c=this;return y(this,(function(u){switch(u.label){case 0:return t=this._logger.createTraceId(),this._logger.info(E.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_T,void 0,t),r("room",e,(function(){return e instanceof ms}),!0)?(n=e.getRoomId(),this._crtRoom?(this._logger.error(E.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:I.FAILED,code:O.REPERT_JOIN_ROOM,msg:"Join the room repeatedly",roomId:n}),t),[2,{code:O.REPERT_JOIN_ROOM}]):[4,(o=this._crtRoom=new ls(this._context,this._runtime,n,this._service,this._options,e.livingType,!0,!0,e.getClientSessionId())).__innerInitByIdentityChange(t)]):(this._logger.error(E.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> room"}),t),[2,{code:O.PARAMS_ERROR}]);case 1:return(a=u.sent())!==i.SUCCESS?(this._crtRoom=null,[2,{code:a}]):(o.once(qa,(function(){c._crtRoom=null})),[4,this._crtAudienceLivingRoom.__destroy(!1)]);case 2:return u.sent(),this._crtAudienceLivingRoom=null,s={room:o,code:O.SUCCESS,userIds:o.getRemoteUserIds(),tracks:o.getRemoteTracks()},o.__getCDNPushMode()===bs.MANUAL&&Object.assign(s,{CDNEnable:o.__getCDNEnable()}),[2,s]}}))}))}}),Object.defineProperty(t.prototype,"downgradeToAudienceRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,n,o,a,s,c;return y(this,(function(u){switch(u.label){case 0:return t=this._logger.createTraceId(),this._logger.info(E.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_T,JSON.stringify({roomId:e._roomId,userId:this._context.getCurrentId()}),t),e.isMainRoom()?r("room",e,(function(){return e instanceof ls}),!0)?this._crtAudienceLivingRoom?(this._logger.error(E.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:I.FAILED,code:O.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),t),[2,{code:O.REPERT_JOIN_ROOM}]):[4,this._context.rtcIdentityChange(e._roomId,os.AnchorToViewer,e.getLivingType())]:(this._logger.error(E.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:I.FAILED,code:O.PARAMS_ERROR,msg:"params error -> room"}),t),[2,{code:O.PARAMS_ERROR}]):(this._logger.error(E.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:I.FAILED,code:O.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"the `downgradeToAudienceRoom` is disabled in PK room"}),t),[2,{code:O.THE_FUNCTION_IS_DISABLED_IN_PKROOM}]);case 1:return n=u.sent(),o=n.code,a=n.data,o!==i.SUCCESS?(this._logger.error(E.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:I.FAILED,code:O.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}),t),[2,{code:O.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}]):(this._logger.info(E.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:I.SUCCESSED,roomData:a}),t),s=e.getClientSessionId(),c=new ms(this._context,this._runtime,this._options,e._roomId,a,e.getLivingType(),s),this._crtAudienceLivingRoom=c,this._crtRoom.__destroy(!1),this._crtRoom=null,[2,{room:c,code:O.SUCCESS,userIds:c.getRemoteUserIds(),RTCTracks:c.getRemoteRTCTracks(),MCUTracks:c.getRemoteMCUTracks(),CDNUris:c.getCDNInfo()}])}}))}))}}),Object.defineProperty(t.prototype,"getJoinedRoomInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return T(this,void 0,void 0,(function(){var e,t,r,n,o;return y(this,(function(a){switch(a.label){case 0:return e=this._logger.createTraceId(),t=this._context.getCurrentId(),this._logger.error(E.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_T,JSON.stringify({userId:t}),e),[4,this._context.getRTCJoinedUserInfo(t)];case 1:return r=a.sent(),n=r.code,o=r.data,n!==i.SUCCESS?(this._logger.error(E.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:I.FAILED,code:n}),e),[2,{code:n}]):(this._logger.info(E.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:I.SUCCESSED,roomInfo:o}),e),[2,{code:O.SUCCESS,data:o}])}}))}))}}),t}(Os);!function(e){e[e.KICK=0]="KICK",e[e.REFUSE=1]="REFUSE"}(vs||(vs={}));var Is,Ss="rtcRJoin_data",Ts="rtcRExit",ys="rtcRInfo",Cs="rtcUData",Ls="rtcUDel",Ps="rtcSetData",As="userSetData",Ns="rtcQryData",ws="rtcDelData",Ds="rtcToken",ks="rtcUserState",Us="rtcUList",Ms="viewerJoinR",js="viewerExitR",Bs="rtcPullKv",xs="rtcIdentityChange",Vs="rtcInvite",Fs="rtcCancelInvite",Js="rtcInviteAnswer",Gs="rtcEndInvite",Hs="rtcQueryJoined",Ks="rtcPullRoomStatus",Ws="reportsdk",Ys="rtcPing";!function(e){e.RtcInput="RtcInput",e.RtcOutput="RtcOutput",e.RtcUserListOutput="RtcUserListOutput",e.SetUserStatusInput="SetUserStatusInput",e.RtcSetDataInput="RtcSetDataInput",e.RtcUserSetDataInput="RtcUserSetDataInput",e.RtcDataInput="RtcDataInput",e.RtcSetOutDataInput="RtcSetOutDataInput",e.MCFollowInput="MCFollowInput",e.RtcTokenOutput="RtcTokenOutput",e.RtcQryOutput="RtcQryOutput",e.RtcQryUserOutDataInput="RtcQryUserOutDataInput",e.RtcUserOutDataOutput="RtcUserOutDataOutput",e.RtcQueryListInput="RtcQueryListInput",e.RtcRoomInfoOutput="RtcRoomInfoOutput",e.RtcValueInfo="RtcValueInfo",e.RtcKeyDeleteInput="RtcKeyDeleteInput",e.RtcNotifyMsg="RtcNotifyMsg",e.RtcPullKV="RtcPullKV",e.RtcKVOutput="RtcKVOutput",e.RtcQueryUserJoinedInput="RtcQueryUserJoinedInput",e.RtcQueryUserJoinedOutput="RtcQueryUserJoinedOutput",e.RtcViewerJoinedOutput="RtcViewerJoinedOutput",e.RtcInviteInput="RtcInviteInput",e.RtcCancelInviteInput="RtcCancelInviteInput",e.RtcInviteAnswerInput="RtcInviteAnswerInput",e.RtcEndInviteInput="RtcEndInviteInput",e.RtcRoomStatusInput="RtcRoomStatusInput",e.RtcRoomStatusOutput="RtcRoomStatusOutput",e.RtcReportSDKInput="RtcReportSDKInput",e.RtcPBPolaris="RCRTCPBPolaris",e.RtcPBR1Info="RCRTCPBR1Info",e.RtcPBR2Info="RCRTCPBR2Info",e.RtcPBR3Info="RCRTCPBR3Info",e.RtcPBR4Info="RCRTCPBR4Info",e.RtcPBStatusInfo="RCRTCPBStatusInfo",e.RtcPBStreamInfo="RCRTCPBStreamInfo"}(Is||(Is={}));var zs,qs=((Rs={})[Is.RtcInput]=["roomType","broadcastType","extraInnerData","needSysChatroom","identityChangeType","joinType","innerDatas","outerDatas","supportNtf"],Rs[Is.RtcOutput]=["version"],Rs[Is.RtcUserListOutput]=["users","token","sessionId","roomInfo","version"],Rs[Is.SetUserStatusInput]=["status"],Rs[Is.RtcSetDataInput]=["interior","target","key","value","objectName","content"],Rs[Is.RtcUserSetDataInput]=["valueInfo","objectName","content"],Rs[Is.RtcDataInput]=["interior","target","key","objectName","content"],Rs[Is.RtcSetOutDataInput]=["target","valueInfo","objectName","content"],Rs[Is.MCFollowInput]=["state"],Rs[Is.RtcTokenOutput]=["rtcToken"],Rs[Is.RtcQryOutput]=["outInfo"],Rs[Is.RtcQryUserOutDataInput]=["userId"],Rs[Is.RtcUserOutDataOutput]=["user"],Rs[Is.RtcQueryListInput]=["order"],Rs[Is.RtcRoomInfoOutput]=["roomId","roomData","userCount","list"],Rs[Is.RtcValueInfo]=["key","value"],Rs[Is.RtcKeyDeleteInput]=["key"],Rs[Is.RtcNotifyMsg]=["type","time","roomId"],Rs[Is.RtcPullKV]=["timestamp","roomId"],Rs[Is.RtcKVOutput]=["entries","bFullUpdate","syncTime"],Rs[Is.RtcQueryUserJoinedInput]=["userId"],Rs[Is.RtcQueryUserJoinedOutput]=["info"],Rs[Is.RtcInviteInput]=["invitedUserId","timeoutTime","invitedRoomId","inviteInfo","inviteSessionId"],Rs[Is.RtcCancelInviteInput]=["invitedUserId","invitedRoomId","inviteInfo","inviteSessionId"],Rs[Is.RtcInviteAnswerInput]=["inviteUserId","answerCode","inviteRoomId","inviteSessionId","content","key","value"],Rs[Is.RtcEndInviteInput]=["inviteRoomId","inviteSessionId","inviteContent","inviteRoomKeys"],Rs[Is.RtcRoomStatusInput]=["version"],Rs[Is.RtcRoomStatusOutput]=["bFullStatus","version","usersData","roomStatus"],Rs[Is.RtcReportSDKInput]=["sdkInfo"],Rs[Is.RtcPBPolaris]=["type","appKey","sessionId","roomId","roomCreateTime","userId","userRole","joinTime","signalDataCenter","r1Info","r2Info","r3Info","r4Info"],Rs[Is.RtcPBR1Info]=["joinTime","rtcVersion","imVersion","platform","device","os","browserName","browserVersion"],Rs[Is.RtcPBR2Info]=["joinTime","sendTime","rtcActionType","rtcActionStatus","trackId"],Rs[Is.RtcPBR3Info]=["info"],Rs[Is.RtcPBR4Info]=["info"],Rs[Is.RtcPBStatusInfo]=["joinTime","receiveTime","totalBitRate","appCPUUsage","systemCPUUsage","systemCPUFrequency","networkStatus","googleRTTNetwork","ipAddress","useReceiveBroadBand","useSendBroadBand","packetLossCount","streams"],Rs[Is.RtcPBStreamInfo]=["trackId","codeName","volume","samplingRate","bitRate","packetLossRate","frameRate","resolution","blockTime","jitterData","nAckCount","pliCount","googleRTTTotalTime","isReceiveFirstFrameRate","codeType","isEnabled"],Rs),Qs="\npackage Modules;\nmessage probuf {\n enum JoinType {\n KICK = 0; //踢前一个设备\n REFUSE = 1; //当前加入拒绝\n COEXIST = 2; //两个设备共存\n }\n enum targetType {\n ROOM =1 ;\n PERSON = 2;\n }\n message ".concat(Is.SetUserStatusInput,"\n {\n optional int32 status=1;\n }\n message ").concat(Is.MCFollowInput,"\n {\n required string state = 1;\n }\n message ").concat(Is.RtcQueryListInput,"{\n optional int32 order=1;\n }\n message ").concat(Is.RtcKeyDeleteInput,"{\n repeated string key=1;\n }\n message ").concat(Is.RtcValueInfo,"{\n required string key=1;\n required string value=2;\n }\n message RtcUserInfo{\n required string userId=1;\n repeated ").concat(Is.RtcValueInfo," userData=2; //用户资源信息\n }\n message ").concat(Is.RtcRoomStatusInput,"{ // rtc 和 living room 拉房间资源状态使用的参数\n required int64 version =1; //当前客户端最大的房间状态的version\n }\n message ").concat(Is.RtcRoomStatusOutput,"{ // rtc 和 living room 拉房间资源状态返回的数据\n required bool bFullStatus =1; //标识此次给的数据是否是全量数据\n required int64 version =2; //当前获取后房间的最大版本号\n repeated RtcUserInfo usersData=3;//如果是全量数据,这个不为空,给的是房间全部的人以及发布的资源\n repeated RtcRoomStatus roomStatus=4;//房间增量数据\n }\n message RtcRoomStatus{ //房间状态变动\n required string userId = 1;//用户ID\n required int32 event = 2;//房间状态变更的event(人员加入/退出/离线/发布资源) (0:加入;1:离开;2:离线;3:资源变动) \n required int64 time = 3;//本次变更的版本号\n repeated RtcValueInfo userData = 4;//用户变更的资源(event为0或者3时可能有值)\n optional int32 switchRoleType = 5;//如果是切换角色导致的加入房间或退出房间的类型\n optional string extra = 6;\n }\n message ").concat(Is.RtcUserListOutput,"{\n repeated RtcUserInfo users=1;\n optional string token=2;\n optional string sessionId=3;\n repeated RtcValueInfo roomInfo = 4; //房间key value\n repeated RtcKVEntity entries = 5;//直播KV属性对象集合\n optional int64 syncTime = 6;//所有属性的最大时间戳(下次拉取KV时用)。\n optional int32 offlineKickTime = 7;//server超时踢人时间,默认60s\n repeated string codeFormat = 8; //当前房间用户支持的编码交集\n optional int64 roomCreateTime = 9;//房间创建时间\n optional int64 userJoinTime = 10;//用户加入房间\n optional int64 version = 11;//当前房间的版本号\n }\n message RtcRoomInfoOutput{\n optional string roomId = 1;\n repeated ").concat(Is.RtcValueInfo," roomData = 2;\n optional int32 userCount = 3;\n repeated RtcUserInfo list=4;\n }\n message ").concat(Is.RtcInput,"{\n required int32 roomType=1;\n optional int32 broadcastType=2;\n optional RtcValueInfo extraInnerData = 3;\n optional bool needSysChatroom = 4; //是否需要同步聊天室\n optional IdentityChangeType identityChangeType = 5; //身份变更类型\n optional JoinType joinType = 6; // 加入房间类型\n repeated ").concat(Is.RtcValueInfo," innerDatas = 7; //用户内部inner数据,角色或者连麦信息等\n repeated ").concat(Is.RtcValueInfo," outerDatas = 8; //用户内部outer数据,自定义数据结构RtcInput。\n optional bool supportNtf = 9; //是否支持房间状态的变更通过通知拉取的方式获取\n }\n message ").concat(Is.RtcQryOutput,"{\n repeated ").concat(Is.RtcValueInfo," outInfo=1;\n }\n message ").concat(Is.RtcDataInput,"{\n required bool interior=1;\n required targetType target=2;\n repeated string key=3;\n optional string objectName=4;\n optional string content=5;\n }\n message ").concat(Is.RtcSetDataInput,"{\n required bool interior=1;\n required targetType target=2;\n required string key=3;\n required string value=4;\n optional string objectName=5;\n optional string content=6;\n }\n message ").concat(Is.RtcUserSetDataInput," {\n repeated ").concat(Is.RtcValueInfo," valueInfo = 1;\n required string objectName = 2;\n repeated ").concat(Is.RtcValueInfo," content = 3;\n }\n message RtcQryInput{\n required bool isInterior=1;\n required targetType target=2;\n repeated string key=3;\n }\n message RtcDelDataInput{\n repeated string key=1;\n required bool isInterior=2;\n required targetType target=3;\n }\n message RtcOutput\n {\n optional int32 nothing=1;\n optional int64 version=2;\n }\n message ").concat(Is.RtcTokenOutput,"{\n required string rtcToken=1;\n }\n message ").concat(Is.RtcSetOutDataInput,"{\n required targetType target=1;\n repeated ").concat(Is.RtcValueInfo," valueInfo=2;\n optional string objectName=3;\n optional string content=4;\n }\n message ").concat(Is.RtcQryUserOutDataInput,"{\n repeated string userId = 1;\n }\n message ").concat(Is.RtcUserOutDataOutput,"{\n repeated RtcUserInfo user = 1;\n }\n message ").concat(Is.RtcNotifyMsg," \n {\n required int32 type= 1; //(通知类型 1:rtc房间状态KV变更通知)\n optional int64 time= 2; //消息产生时间\n optional string roomId=3; //主播房间id\n }\n message ").concat(Is.RtcPullKV,"\n {\n required int64 timestamp = 1;\n required string roomId = 2;\n }\n message RtcKVEntity \n {\n required string key = 1;\n required string value = 2;\n optional int32 status = 3;\n optional int64 timestamp = 4;\n optional string uid = 5;\n }\n message ").concat(Is.RtcKVOutput,"\n {\n repeated RtcKVEntity entries = 1;\n optional bool bFullUpdate = 2;\n optional int64 syncTime = 3; \n }\n enum IdentityChangeType \n {\n AnchorToViewer = 1; //1为主播变观众\n ViewerToAnchor = 2; //2为观众变主播\n }\n message ").concat(Is.RtcQueryUserJoinedInput,"\n {\n required string userId = 1;\n }\n message RtcJoinedInfo\n {\n required string deviceId = 1; //设备ID\n required string roomId = 2; //加入的房间ID\n optional int64 joinTime = 3; //加入的时间\n }\n message ").concat(Is.RtcQueryUserJoinedOutput,"\n {\n repeated RtcJoinedInfo info = 1;\n }\n message ").concat(Is.RtcViewerJoinedOutput,"\n {\n required string rtcToken=1;\n repeated RtcKVEntity entries = 2;//KV属性对象集合\n optional int64 syncTime = 3;//所有属性的最大时间戳(下次拉取KV时用)。\n optional string sessionId=4;\n optional int64 roomCreateTime = 5;//房间创建时间\n optional int64 userJoinTime = 6;//用户加入房间\n }\n message ").concat(Is.RtcInviteInput,"\n {\n required string invitedUserId=1; //被邀请的人的uid\n optional int32 timeoutTime=2; //邀请超时时间(秒),默认三十秒\n required string invitedRoomId=3; //被邀请的房间\n required string inviteInfo=4; //邀请的信息(包含邀请人,被邀请人,各自userid)客户端定义好.协议栈和server透传\n required string inviteSessionId= 5; //客户端保证唯一性(建议roomid_userid_时间戳_随机数)\n }\n message ").concat(Is.RtcCancelInviteInput,"\n {\n required string invitedUserId=1; //被邀请的人的uid\n required string invitedRoomId=2; //被邀请的房间\n required string inviteInfo=3; //取消邀请的信息(包含邀请人,被邀请人,各自userid)客户端定义好.协议栈和server透传\n required string inviteSessionId=4; //邀请的sessionId,客户端发起邀请时产生\n }\n message ").concat(Is.RtcInviteAnswerInput,"\n {\n required string inviteUserId=1; //邀请的人的uid\n required int32 answerCode=2; //是否接受连麦邀请.0为拒绝,1为接受\n required string inviteRoomId=3; //邀请的房间\n required string inviteSessionId=4; //邀请的sessionId\n required string content=5; //需要转发的content\n optional string key=6; //如果接受的话,需要加这个字段,放在room级别的k和v,新加入房间的能拉取到\n optional string value=7; //如果接受的话,需要加这个字段,放在room级别的k和v,新加入房间的能拉取到\n }\n message ").concat(Is.RtcEndInviteInput,"\n {\n required string inviteRoomId=1; //邀请的房间\n required string inviteSessionId=2; //邀请的sessionId\n required string inviteContent=3; //结束连麦的信息(需要透传给房间内其他人)\n repeated string inviteRoomKeys=4; //需要删除连麦的信息的key\n }\n message ").concat(Is.RtcReportSDKInput,' {\n required string sdkInfo=1; // 用户集成的 sdk 信息,json 格式 {"web-rtc": "4.0.3.7"}\n }\n // ---- 北极星数据上报 -------\n message ').concat(Is.RtcPBPolaris," {\n required string type = 1;//上报数据类型 R1-R4\n required string appKey = 2;\n required string sessionId = 3;//房间通话id\n required string roomId = 4;\n required int64 roomCreateTime = 5;//房间创建时间\n required string userId = 6;\n required int32 userRole = 7;\n required int64 joinTime = 8;\n required string signalDataCenter = 9;//signal数据中心\n optional ").concat(Is.RtcPBR1Info," r1Info = 10;\n optional ").concat(Is.RtcPBR2Info," r2Info = 11;\n optional ").concat(Is.RtcPBR3Info," r3Info = 12;\n optional ").concat(Is.RtcPBR4Info," r4Info = 13;\n }\n message ").concat(Is.RtcPBR1Info," {\n required int64 joinTime = 1;//用户加入房间的时间\n required string rtcVersion = 2;//Rtc版本号\n required string imVersion = 3;//IM SDK 版本\n required string platform = 4;//平台(如:Android、iOS、Web)\n required string device = 5; //设备信息(手机名称+型号)\n required string os = 6;//系统版本(手机系统版本)\n optional string browserName = 7; //浏览器名称, 没有用 -1 表示\n optional string browserVersion = 8;//浏览器版本, 没有用 -1 表示\n optional int64 receiveTime = 9; // 发送数据的时间\n }\n message ").concat(Is.RtcPBR2Info," {\n required int64 joinTime = 1;\n required int64 sendTime = 2;\n required string rtcActionType = 3;//发布类型 subscribe : 订阅 publish : 发布\n required string rtcActionStatus = 4;//发布状态 begin : 开始 tend : 结束\n repeated string trackId = 5;\n optional int64 receiveTime = 6; // 发送数据的时间\n }\n message ").concat(Is.RtcPBR3Info," {\n required ").concat(Is.RtcPBStatusInfo," info = 1;\n }\n message ").concat(Is.RtcPBR4Info," {\n required ").concat(Is.RtcPBStatusInfo," info = 1;\n }\n message ").concat(Is.RtcPBStatusInfo," {\n optional int64 joinTime = 1;//用户加入房间的时间\n optional int64 receiveTime = 2;//用户发布数据流的时间(毫秒),暂时由客户端生成,后期如果有问题服务端做兜底处理\n optional int64 totalBitRate = 3;//总码率\n optional float appCPUUsage = 4;//APP CPU占用率\n optional float systemCPUUsage = 5;////系统 CPU占用率\n optional float systemCPUFrequency = 6;//系统CPU频率 (安卓8.0以上)\n optional string networkStatus = 7;//实时网络状态(2g、3g、4g、wifi)\n optional int32 googleRTTNetwork = 8;//Goog rtt 网络延迟\n optional string ipAddress = 9;//ip地址\n optional string useReceiveBroadBand = 10; //可接收带宽(单位: bit)\n optional string useSendBroadBand = 11;//可用发送带宽(单位: bit)\n optional string packetLossCount = 12;//丢包数\n repeated ").concat(Is.RtcPBStreamInfo," streams = 13;\n }\n message ").concat(Is.RtcPBStreamInfo," {\n required string trackId = 1;\n optional string codeName = 2;//编解码名称\n optional string volume = 3;//音频播放音量\n optional int32 samplingRate = 4; //音频采样率\n optional float bitRate = 5;//下行码率\n optional float packetLossRate = 6;\n optional int32 frameRate = 7;//视频接收帧率(单位:fps)\n optional string resolution = 8;//视频分辨率(格式:640*480)\n optional int64 blockTime = 9;//接收卡顿(间隔时间, 单位: ms)\n optional int32 jitterData = 10;//jitter数据抖动\n optional string nAckCount = 11;//nack数量\n optional string pliCount = 12; //PLI请求数\n optional int64 googleRTTTotalTime = 13; //googRtt往返时长\n optional int32 isReceiveFirstFrameRate = 14;//第一个关键帧是否正常收到\n optional string codeType = 15;//编码方式\n optional int32 isEnabled = 16; //当前流的状态是否可用\n }\n // ---- 北极星数据上报 -------\n}\n"),Zs=function(e,t,r,n,i,o,a){var s=i?Object.keys(i).map((function(t){return e.encode(Is.RtcValueInfo,{key:t,value:i[t]},!0)})):void 0,c=o?Object.keys(o).map((function(t){return e.encode(Is.RtcValueInfo,{key:t,value:o[t]},!0)})):void 0;return e.encode(Is.RtcInput,{roomType:t,broadcastType:r,joinType:n,innerDatas:s,outerDatas:c,supportNtf:a})},Xs=function(e,t){var r=e.decode(Is.RtcUserListOutput,t),n=r.users,i=r.token,o=r.sessionId,a=r.roomInfo,s=r.entries,c=r.offlineKickTime,u=void 0===c?60:c,l=r.codeFormat,_=r.roomCreateTime,d=r.userJoinTime,f=r.version,p={};return b(n,(function(e){var t=e.userId,r=e.userData,n={};b(r,(function(e){var t=e.key,r=e.value;n[t]=r})),p[t]=n})),{users:p,token:i,sessionId:o,roomInfo:a,kvEntries:s,offlineKickTime:u,codeFormat:l,roomCreateTime:Yt(_),userJoinTime:Yt(d),version:f}},$s=function(){function e(e,t,r){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,"codec",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"roomCreateTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"userJoinTime",{enumerable:!0,configurable:!0,writable:!0,value:0})}return Object.defineProperty(e.prototype,"joinRTCRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,o,a,s){return T(this,void 0,void 0,(function(){var c,u,l,_,d,f,p,h,b,g,m,v,R,O;return y(this,(function(E){switch(E.label){case 0:return c=Zs(this.codec,t,r,n,o,a,s),[4,this.context.rtcSignaling(e,Ss,!0,c)];case 1:return u=E.sent(),l=u.code,_=u.buffer,l===i.SUCCESS&&_?(d=Xs(this.codec,_),f=d.users,p=d.token,h=d.sessionId,b=d.roomInfo,g=d.kvEntries,m=d.offlineKickTime,v=d.roomCreateTime,R=d.userJoinTime,O=d.version,this.roomCreateTime=v,this.userJoinTime=R,[2,{code:l,data:{users:f,token:p,sessionId:h,roomInfo:b,kvEntries:g,offlineKickTime:m,version:O}}]):[2,{code:l,data:d}]}}))}))}}),Object.defineProperty(e.prototype,"quitRTCRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t;return y(this,(function(r){switch(r.label){case 0:return t=this.codec.encode(Is.SetUserStatusInput,{status:0}),[4,this.context.rtcSignaling(e,Ts,!0,t)];case 1:return[2,r.sent().code]}}))}))}}),Object.defineProperty(e.prototype,"getRTCRoomInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n,o,a;return y(this,(function(s){switch(s.label){case 0:return t=this.codec.encode(Is.RtcQueryListInput,{order:2}),[4,this.context.rtcSignaling(e,ys,!0,t)];case 1:return r=s.sent(),n=r.code,o=r.buffer,n===i.SUCCESS&&o&&(a=this.codec.decode(Is.RtcRoomInfoOutput,o)),[2,{code:n,data:a}]}}))}))}}),Object.defineProperty(e.prototype,"getRTCUserInfoList",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n,o,a,s;return y(this,(function(c){switch(c.label){case 0:return t=this.codec.encode(Is.RtcQueryListInput,{order:2}),[4,this.context.rtcSignaling(e,Cs,!0,t)];case 1:return r=c.sent(),n=r.code,o=r.buffer,n===i.SUCCESS&&o&&(s=Xs(this.codec,o),a={users:s.users}),[2,{code:n,data:a}]}}))}))}}),Object.defineProperty(e.prototype,"getRTCUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){throw new Error("Method not implemented.")}}),Object.defineProperty(e.prototype,"removeRTCUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r;return y(this,(function(n){switch(n.label){case 0:return r=this.codec.encode(Is.RtcKeyDeleteInput,{key:t}),[4,this.context.rtcSignaling(e,Ls,!1,r)];case 1:return[2,n.sent().code]}}))}))}}),Object.defineProperty(e.prototype,"setRTCData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i,o){return T(this,void 0,void 0,(function(){var a;return y(this,(function(s){switch(s.label){case 0:return a=this.codec.encode(Is.RtcSetDataInput,{interior:n,target:i,key:t,value:r,objectName:null==o?void 0:o.name,content:null==o?void 0:o.content}),[4,this.context.rtcSignaling(e,Ps,!1,a)];case 1:return[2,s.sent().code]}}))}))}}),Object.defineProperty(e.prototype,"setRTCTotalRes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i,o){return T(this,void 0,void 0,(function(){var a,s,c=this;return y(this,(function(u){switch(u.label){case 0:return a={objectName:n,content:[],valueInfo:[this.codec.encode(Is.RtcValueInfo,{key:"uris",value:r},!0)]},t.forEach((function(e){var t=c.codec.encode(Is.RtcValueInfo,{key:e.name,value:e.content},!0);a.content.push(t)})),i&&a.valueInfo.push(this.codec.encode(Is.RtcValueInfo,{key:"mcu_uris",value:i},!0)),o&&a.valueInfo.push(this.codec.encode(Is.RtcValueInfo,{key:"cdn_uris",value:o},!0)),s=this.codec.encode(Is.RtcUserSetDataInput,a),[4,this.context.rtcSignaling(e,As,!0,s)];case 1:return[2,u.sent().code]}}))}))}}),Object.defineProperty(e.prototype,"setRTCCDNUris",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n;return y(this,(function(i){switch(i.label){case 0:return n=this.codec.encode(Is.RtcUserSetDataInput,{objectName:t,valueInfo:this.codec.encode(Is.RtcValueInfo,{key:"cdn_uris",value:r},!0)}),[4,this.context.rtcSignaling(e,As,!0,n)];case 1:return[2,i.sent().code]}}))}))}}),Object.defineProperty(e.prototype,"getRTCData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return T(this,void 0,void 0,(function(){var o,a,s,c,u,l;return y(this,(function(_){switch(_.label){case 0:return o=this.codec.encode(Is.RtcDataInput,{interior:r,target:n,key:t}),[4,this.context.rtcSignaling(e,Ns,!0,o)];case 1:return a=_.sent(),s=a.code,c=a.buffer,s===i.SUCCESS&&c?(u=this.codec.decode(Is.RtcQryOutput,c).outInfo,l={},u.forEach((function(e){l[e.key]=e.value})),[2,{code:s,data:l}]):[2,{code:s}]}}))}))}}),Object.defineProperty(e.prototype,"removeRTCData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n,i){return T(this,void 0,void 0,(function(){var o;return y(this,(function(a){switch(a.label){case 0:return o=this.codec.encode(Is.RtcDataInput,{interior:r,target:n,key:t,objectName:(null==i?void 0:i.name)||"",content:(null==i?void 0:i.content)||""}),[4,this.context.rtcSignaling(e,ws,!1,o)];case 1:return[2,a.sent().code]}}))}))}}),Object.defineProperty(e.prototype,"setRTCOutData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){return T(this,void 0,void 0,(function(){return y(this,(function(e){throw new Error("JSEngine's method not implemented.")}))}))}}),Object.defineProperty(e.prototype,"getRTCOutData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){return y(this,(function(e){throw new Error("JSEngine's method not implemented.")}))}))}}),Object.defineProperty(e.prototype,"getRTCToken",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,o,a,s,c;return y(this,(function(u){switch(u.label){case 0:return n=Zs(this.codec,t,r),[4,this.context.rtcSignaling(e,Ds,!0,n)];case 1:return o=u.sent(),a=o.code,s=o.buffer,a===i.SUCCESS&&s?(c=this.codec.decode(Is.RtcTokenOutput,s).rtcToken,[2,{code:a,data:{rtcToken:c}}]):[2,{code:a}]}}))}))}}),Object.defineProperty(e.prototype,"setRTCState",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r;return y(this,(function(n){switch(n.label){case 0:return r=this.codec.encode(Is.MCFollowInput,{state:t}),[4,this.context.rtcSignaling(e,ks,!0,r)];case 1:return[2,n.sent().code]}}))}))}}),Object.defineProperty(e.prototype,"setRTCStateByHttp",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,n){var i;return T(this,void 0,void 0,(function(){var a,s,c;return y(this,(function(u){switch(u.label){case 0:a=function(e,t,r){var n=t.type,i=t.appKey,o=t.sessionId,a=t.roomId,s=t.roomCreateTime,c=t.userId,u=t.userRole,l=t.joinTime,_=t.signalDataCenter,d=t.r1Info,f=t.r2Info,p=t.r3Info,h=t.r4Info,b={type:n,appKey:i,sessionId:o,roomId:a,roomCreateTime:s,userId:c,userRole:u,joinTime:l,signalDataCenter:_};if(r===Ja.R1&&d){var g=e.encode(Is.RtcPBR1Info,d,!0);return e.encode(Is.RtcPBPolaris,S(S({},b),{r1Info:g}))}if(r===Ja.R2&&f){var m=e.encode(Is.RtcPBR2Info,f,!0);return e.encode(Is.RtcPBPolaris,S(S({},b),{r2Info:m}))}if(r===Ja.R3&&p){var v=(I=p.info).streams,R=Array.isArray(v)&&v.map((function(t){return t&&e.encode(Is.RtcPBStreamInfo,t,!0)})),O=e.encode(Is.RtcPBStatusInfo,S(S({},I),{streams:R}),!0),E=e.encode(Is.RtcPBR3Info,{info:O},!0);return e.encode(Is.RtcPBPolaris,S(S({},b),{r3Info:E}))}if(r===Ja.R4&&h){v=(I=h.info).streams,R=Array.isArray(v)&&v.map((function(t){return t&&e.encode(Is.RtcPBStreamInfo,t,!0)})),O=e.encode(Is.RtcPBStatusInfo,S(S({},I),{streams:R}),!0);var I,T=e.encode(Is.RtcPBR4Info,{info:O},!0);return e.encode(Is.RtcPBPolaris,S(S({},b),{r4Info:T}))}return{}}(this.codec,r,n),s=e,/^https:\/\//.test(e)||(s="https://".concat(e)),u.label=1;case 1:return u.trys.push([1,3,,4]),[4,t.httpReq({url:"".concat(s,"/rtc/logserver/polaris"),body:a,method:o.POST,headers:{jwt:(null===(i=this.context.getNaviInfo())||void 0===i?void 0:i.jwt)||""},timeout:2e3})];case 2:if(!(c=u.sent()).data)throw new Error("http request fail");return[2,JSON.parse(c.data).resultCode];case 3:return u.sent(),[2,Fa.REPORT_FAIL];case 4:return[2]}}))}))}}),Object.defineProperty(e.prototype,"getRTCUserList",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n,o,a;return y(this,(function(s){switch(s.label){case 0:return t=this.codec.encode(Is.RtcQueryListInput,{order:2}),[4,this.context.rtcSignaling(e,Us,!0,t)];case 1:return r=s.sent(),n=r.code,o=r.buffer,n===i.SUCCESS&&o?(a=Xs(this.codec,o),[2,{code:n,data:a}]):[2,{code:n}]}}))}))}}),Object.defineProperty(e.prototype,"joinLivingRoomAsAudience",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,o,a,s,c,u,l,_,d;return y(this,(function(f){switch(f.label){case 0:return n=Zs(this.codec,t,r),[4,this.context.rtcSignaling(e,Ms,!0,n)];case 1:return o=f.sent(),a=o.code,s=o.buffer,a===i.SUCCESS&&s?(c=this.codec.decode(Is.RtcViewerJoinedOutput,s),u=c.rtcToken,l=c.entries,_=c.roomCreateTime,d=c.userJoinTime,this.roomCreateTime=Yt(_),this.userJoinTime=Yt(d),[2,{code:a,data:{token:u,kvEntries:l}}]):[2,{code:a}]}}))}))}}),Object.defineProperty(e.prototype,"quitLivingRoomAsAudience",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t;return y(this,(function(r){switch(r.label){case 0:return t=this.codec.encode(Is.SetUserStatusInput,{status:0}),[4,this.context.rtcSignaling(e,js,!0,t)];case 1:return[2,r.sent().code]}}))}))}}),Object.defineProperty(e.prototype,"rtcIdentityChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,o,a,s,c;return y(this,(function(u){switch(u.label){case 0:return n=this.codec.encode(Is.RtcInput,{roomType:Ho.LIVE,broadcastType:r,identityChangeType:t,needSysChatroom:!1}),[4,this.context.rtcSignaling(e,xs,!0,n)];case 1:return o=u.sent(),a=o.code,s=o.buffer,a===i.SUCCESS&&s?(c=Xs(this.codec,s),[2,{code:a,data:c}]):[2,{code:a}]}}))}))}}),Object.defineProperty(e.prototype,"requestRoomPK",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n,i,o,a,s;return y(this,(function(c){switch(c.label){case 0:return t=e.invitedRoomId,r=e.invitedUserId,n=e.inviteSessionId,i=e.inviteTimeout,o=e.inviteInfo,a=e.roomId,s=this.codec.encode(Is.RtcInviteInput,{invitedRoomId:t,invitedUserId:r,inviteSessionId:n,timeoutTime:i,inviteInfo:o}),[4,this.context.rtcSignaling(a,Vs,!0,s)];case 1:return[2,c.sent().code]}}))}))}}),Object.defineProperty(e.prototype,"cancelRoomPK",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n,i,o,a;return y(this,(function(s){switch(s.label){case 0:return t=e.invitedRoomId,r=e.invitedUserId,n=e.inviteSessionId,i=e.inviteInfo,o=e.roomId,a=this.codec.encode(Is.RtcCancelInviteInput,{invitedRoomId:t,invitedUserId:r,inviteSessionId:n,inviteInfo:i}),[4,this.context.rtcSignaling(o,Fs,!0,a)];case 1:return[2,s.sent().code]}}))}))}}),Object.defineProperty(e.prototype,"responseRoomPK",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n,i,o,a,s,c,u;return y(this,(function(l){switch(l.label){case 0:return t=e.inviteUserId,r=e.inviteRoomId,n=e.inviteSessionId,i=e.content,o=e.key,a=e.value,s=e.agree,c=e.roomId,u=this.codec.encode(Is.RtcInviteAnswerInput,{inviteUserId:t,inviteRoomId:r,inviteSessionId:n,content:i,key:o,value:a,answerCode:s?1:0}),[4,this.context.rtcSignaling(c,Js,!0,u)];case 1:return[2,l.sent().code]}}))}))}}),Object.defineProperty(e.prototype,"endRoomPK",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n,i,o,a;return y(this,(function(s){switch(s.label){case 0:return t=e.endRoomId,r=e.sessionId,n=e.content,i=e.keys,o=e.roomId,a=this.codec.encode(Is.RtcEndInviteInput,{inviteRoomId:t,inviteSessionId:r,inviteContent:n,inviteRoomKeys:i}),[4,this.context.rtcSignaling(o,Gs,!0,a)];case 1:return[2,s.sent().code]}}))}))}}),Object.defineProperty(e.prototype,"getRTCJoinedUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n,o,a;return y(this,(function(s){switch(s.label){case 0:return t=this.codec.encode(Is.RtcQueryUserJoinedInput,{userId:e}),[4,this.context.rtcSignaling("",Hs,!0,t)];case 1:return r=s.sent(),n=r.code,o=r.buffer,n===i.SUCCESS&&o?(a=this.codec.decode(Is.RtcQueryUserJoinedOutput,o).info||[],[2,{code:n,data:a.map((function(e){return{deviceId:e.deviceId,roomId:e.roomId,joinTime:Yt(e.joinTime)}}))}]):[2,{code:n}]}}))}))}}),Object.defineProperty(e.prototype,"pullRTCRoomEntry",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return T(this,void 0,void 0,(function(){var t,r,n,o,a,s,c;return y(this,(function(u){switch(u.label){case 0:return t=this.codec.encode(Is.RtcPullKV,{timestamp:0,roomId:e}),[4,this.context.rtcSignaling(e,Bs,!0,t)];case 1:return r=u.sent(),n=r.code,o=r.buffer,n!==i.SUCCESS?[2,{code:n}]:(a=this.codec.decode(Is.RtcKVOutput,o),s=a.entries,c=a.syncTime,s=(s||[]).map((function(e){return S(S({},e),{timestamp:Yt(e.timestamp)})})),[2,{code:n,data:{kvEntries:s,syncTime:Yt(c)}}])}}))}))}}),Object.defineProperty(e.prototype,"pullRTCRoomStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return T(this,void 0,void 0,(function(){var r,n,o,a,s;return y(this,(function(c){switch(c.label){case 0:return r=this.codec.encode(Is.RtcRoomStatusInput,{version:t}),[4,this.context.rtcSignaling(e,Ks,!0,r)];case 1:return n=c.sent(),o=n.code,a=n.buffer,o!==i.SUCCESS?[2,{code:o}]:(s=this.codec.decode(Is.RtcRoomStatusOutput,a),[2,{code:o,data:s}])}}))}))}}),Object.defineProperty(e.prototype,"decodeRtcNotify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.codec.decode(Is.RtcNotifyMsg,e),r=t.time,n=t.type,i=t.roomId;return{time:Yt(r),type:n,roomId:i}}}),Object.defineProperty(e.prototype,"getCurrentId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context.getCurrentId()}}),Object.defineProperty(e.prototype,"getNaviInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context.getNaviInfo()}}),Object.defineProperty(e.prototype,"getConnectionStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context.getConnectionStatus()}}),Object.defineProperty(e.prototype,"getAppkey",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context.getAppkey()}}),Object.defineProperty(e.prototype,"webRtcPing",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return T(this,void 0,void 0,(function(){var n,o,a,s,c;return y(this,(function(u){switch(u.label){case 0:return n=this.codec.encode(Is.RtcInput,{roomType:t,broadcastType:r}),[4,this.context.rtcSignaling(e,Ys,!0,n)];case 1:return o=u.sent(),a=o.code,s=o.buffer,a!==i.SUCCESS?[2,{code:a}]:((c=this.codec.decode(Is.RtcOutput,s)).version=Yt(c.version),[2,{code:a,data:c}])}}))}))}}),Object.defineProperty(e.prototype,"rtcPing",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return/Electron/.test(navigator.userAgent)?this.context.rtcPingResVersion(e,t,r):this.webRtcPing(e,t,r)}}),Object.defineProperty(e.prototype,"sendMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return this.context.sendMessage(e,t,r)}}),Object.defineProperty(e.prototype,"registerRTCSignalListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.context.registerRTCSignalListener(e)}}),Object.defineProperty(e.prototype,"registerConnectionStateChangeListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.context.onconnectionstatechange=e}}),Object.defineProperty(e.prototype,"registerDisconnectListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.context.ondisconnect=e}}),Object.defineProperty(e.prototype,"registerDestroyListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.context.ondestroy=e}}),Object.defineProperty(e.prototype,"registerMessageListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.context.onmessage=e}}),Object.defineProperty(e.prototype,"getCoreVersion",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context.getCoreVersion()}}),Object.defineProperty(e.prototype,"getPluginContext",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context}}),Object.defineProperty(e.prototype,"reportSDKInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.codec.encode(Is.RtcReportSDKInput,{sdkInfo:JSON.stringify(e)});this.context.rtcSignaling("",Ws,!0,t)}}),e}();!function(e){e.RTC="RTC"}(zs||(zs={})),g.add("rtclib","5.26.0");var ec={tag:"RCRTC",verify:function(e){return"undefined"==typeof isSecureContext||isSecureContext?!!g.validEngine("5.26.1")||(console.error("The current engine version '".concat(g.getInfo().engine,"' error, plugin-rtc required engine version at least '").concat("5.26.1","'.")),!1):(console.error("Please use the https protocol or use `http://localhost` to open the page!"),!1)},setup:function(t,r,n){void 0===n&&(n={});var i=t.createLogger("RCRTC",zs.RTC);if(n.logLevel&&i.setOutputLevel(n.logLevel),i.warn(E.L_INDEX_INSTALL_RTC_PLUGIN_O,JSON.stringify({"RCRTC Version":"5.26.0",Commit:"8396a381fd49cfe6d89ee7a6c3c363ca765392d8","browserInfo.browser":Bt.browser,"browserInfo.supportsUnifiedPlan":Bt.supportsUnifiedPlan,"browserInfo.version":Bt.version})),_("options",n,m.OBJECT,!0),_("options.mediaServer",n.mediaServer,(function(e){return!(!f(e)||"https:"===location.protocol&&!/^https/.test(e))})),_("options.timeout",n.timeout,(function(t){return e(t)&&t>=5e3&&t<=3e4})),_("options.pingGap",n.pingGap,(function(t){return e(t)&&t>=3e3&&t<=1e4})),n.AAAWorklet){_("options.AAAWorklet",n.AAAWorklet,m.OBJECT,!0);var o=n.AAAWorklet,a=o.scriptUrl,s=o.wasmUrl;_("AAAWorklet.scriptUrl",a,m.STRING,!0),_("AAAWorklet.wasmUrl",s,m.STRING,!0),ct.SCRIPT_URL=a,ct.WASM_URL=s}return n.encryptor&&(_("options.encrypt",n.encryptor,m.OBJECT,!0),_("options.encrypt.decodeAudio",n.encryptor.decodeAudio,(function(e){return"function"==typeof e}),!0),_("options.encrypt.decodeVideo",n.encryptor.decodeVideo,(function(e){return"function"==typeof e}),!0),_("options.encrypt.encodeAudio",n.encryptor.encodeAudio,(function(e){return"function"==typeof e}),!0),_("options.encrypt.encodeVideo",n.encryptor.encodeVideo,(function(e){return"function"==typeof e}),!0),Lo.init(n.encryptor,i)),new Es(new $s(t,i,t.createCodec(qs,Qs)),r,n)}},tc={DEFAULT:"RongCloudRTC"},rc={transResolution:kt,transFrameRate:jt,parseTrackId:Pt,ifSupportLocalFileTrack:xt,ifSupportScreenShare:Vt};export{Ha as BackgroundPictureFillMode,Ka as MixLayoutMode,Wa as MixVideoRenderMode,Qa as RCAbstractRoom,hs as RCAudienceClient,ms as RCAudienceLivingRoom,nt as RCAudioBitrate,bt as RCCameraVideoTrack,He as RCFrameRate,cs as RCInnerCDNPullIsHttps,ss as RCInnerCDNPullKind,ka as RCKickReason,ls as RCLivingRoom,Xa as RCLivingType,lt as RCLocalAudioTrack,pt as RCLocalFileAudioTrack,dt as RCLocalFileTrack,ft as RCLocalFileVideoTrack,ut as RCLocalTrack,_t as RCLocalVideoTrack,es as RCMCUConfigBuilder,Os as RCMediaStreamCapture,We as RCMediaType,ht as RCMicphoneAudioTrack,Es as RCRTCClient,O as RCRTCCode,wo as RCRTCLiveRole,Jt as RCRTCPingResult,_s as RCRTCRoom,Rt as RCRemoteAudioTrack,vt as RCRemoteTrack,Ot as RCRemoteVideoTrack,Ke as RCResolution,mt as RCScreenAudioTrack,gt as RCScreenVideoTrack,tc as RCTag,it as RCTrack,ot as RCVideoBitrate,vs as RTCJoinType,Ho as RTCMode,et as device,rc as helper,ec as installer};
|
|
1
|
+
import{EventEmitter as e,isNumber as t,validate as r,isObject as i,ErrorCode as n,HttpMethod as s,RCConnectionStatus as o,notEmptyString as a,isString as c,isArray as _,RTCMode as d,assert as l,ConversationType as u,isHttpUrl as h,isBoolean as p,isUndefined as g,forEach as R,VersionManage as m,AssertRules as f}from"@rongcloud/engine";function E(e,t,r,i){return new(r||(r=Promise))((function(n,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}var I,S,O;"function"==typeof SuppressedError&&SuppressedError,function(e){e[e.SUCCESS=1e4]="SUCCESS",e[e.PB_ERROR=40001]="PB_ERROR",e[e.SIGNAL_DISCONNECTED=5e4]="SIGNAL_DISCONNECTED",e[e.PARAMS_ERROR=50001]="PARAMS_ERROR",e[e.REPERT_JOIN_ROOM=50002]="REPERT_JOIN_ROOM",e[e.NOT_IN_ROOM=50003]="NOT_IN_ROOM",e[e.SERVICE_INVALID=50004]="SERVICE_INVALID",e[e.RTC_TOKEN_INVALID=50006]="RTC_TOKEN_INVALID",e[e.SIGNAL_ERROR=53001]="SIGNAL_ERROR",e[e.CREATE_OFFER_FAILED=53003]="CREATE_OFFER_FAILED",e[e.REQUEST_FAILED=53004]="REQUEST_FAILED",e[e.MCU_SERVER_NOT_FOUND=53005]="MCU_SERVER_NOT_FOUND",e[e.BROADCAST_SUB_LIST_NOT_EMPTY=53007]="BROADCAST_SUB_LIST_NOT_EMPTY",e[e.ROOM_HAS_BEEN_DESTROYED=53008]="ROOM_HAS_BEEN_DESTROYED",e[e.NOT_OPEN_VIDEO_AUDIO_SERVER=53009]="NOT_OPEN_VIDEO_AUDIO_SERVER",e[e.GET_USER_MEDIA_FAILED=53010]="GET_USER_MEDIA_FAILED",e[e.GET_DISPLAY_MEDIA_FAILED=53011]="GET_DISPLAY_MEDIA_FAILED",e[e.BROWSER_PERMISSION_DENIED=53012]="BROWSER_PERMISSION_DENIED",e[e.CREATE_CUSTOM_TRACK_FAILED=53013]="CREATE_CUSTOM_TRACK_FAILED",e[e.INVALID_TAGS=53014]="INVALID_TAGS",e[e.INVALID_USER_ID=53015]="INVALID_USER_ID",e[e.CREATE_FILE_TRACK_FAILED=53016]="CREATE_FILE_TRACK_FAILED",e[e.INVALID_FILE_INSTANCE=53017]="INVALID_FILE_INSTANCE",e[e.SET_REMOTE_DESCRIPTION_FAILED=53018]="SET_REMOTE_DESCRIPTION_FAILED",e[e.BROWSER_NOT_SUPPORT=53019]="BROWSER_NOT_SUPPORT",e[e.TRACK_NOT_READY=53020]="TRACK_NOT_READY",e[e.VIDEO_TRACK_MISS_MEDIA_ELEMENT=53021]="VIDEO_TRACK_MISS_MEDIA_ELEMENT",e[e.TRACK_PLAY_ERROR=53022]="TRACK_PLAY_ERROR",e[e.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED=53023]="SIGNAL_AUDIENCE_JOIN_ROOM_FAILED",e[e.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED=53024]="SIGNAL_ROOM_CHANGE_IDENTITY_FAILED",e[e.PACKAGE_ENVIRONMENT_ERROR=53025]="PACKAGE_ENVIRONMENT_ERROR",e[e.PUBLISH_TRACK_LIMIT_EXCEEDED=53026]="PUBLISH_TRACK_LIMIT_EXCEEDED",e[e.CDN_RESOURCE_IS_EMPTY=53027]="CDN_RESOURCE_IS_EMPTY",e[e.SIGNAL_JOIN_RTC_ROOM_REFUSED=53028]="SIGNAL_JOIN_RTC_ROOM_REFUSED",e[e.NO_PERMISSION_TO_USE_REQUESTED_DEVICE=53029]="NO_PERMISSION_TO_USE_REQUESTED_DEVICE",e[e.THE_FUNCTION_IS_DISABLED_IN_PKROOM=53030]="THE_FUNCTION_IS_DISABLED_IN_PKROOM",e[e.SOME_TRACKS_PUBLISH_FAILED=53031]="SOME_TRACKS_PUBLISH_FAILED",e[e.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO=53032]="MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO",e[e.JWT_TIME_OUT=1004]="JWT_TIME_OUT",e[e.SYSTEM_PERMISSION_DENIED=53033]="SYSTEM_PERMISSION_DENIED",e[e.PUBLISH_TRACKS_IS_INVALID=53034]="PUBLISH_TRACKS_IS_INVALID",e[e.TRACK_READYSTATE_IS_ENDED=53035]="TRACK_READYSTATE_IS_ENDED",e[e.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH=53036]="APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH",e[e.LOAD_3A_MODULE_FAILED=53037]="LOAD_3A_MODULE_FAILED"}(I||(I={})),function(e){e.L_INDEX_INSTALL_RTC_PLUGIN_O="L-index_install_rtc_plugin-O",e.L_RTC_CLIENT_IM_CONNECTION_STATE_S="L-rtc_client_im_connection_state-S",e.L_RTC_CLIENT_MESSAGE_O="L-rtc_client_message-O",e.L_RTC_CLIENT_DESTROY_S="L-rtc_client_destroy-S",e.L_RTC_CLIENT_JOIN_RTC_ROOM_T="L-rtc_client_join_rtc_room-T",e.L_RTC_CLIENT_JOIN_RTC_ROOM_O="L-rtc_client_join_rtc_room-O",e.L_RTC_CLIENT_JOIN_RTC_ROOM_R="L-rtc_client_join_rtc_room-R",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_T="L-rtc_client_join_living_room-T",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_R="L-rtc_client_join_living_room-R",e.L_RTC_CLIENT_GET_AUDIENCE_CLIENT_O="L-rtc_client_get_audience_client-O",e.L_RTC_CLIENT_LEAVE_ROOM_T="L-rtc_client_leave_room-T",e.L_RTC_CLIENT_LEAVE_ROOM_R="L-rtc_client_leave_room-R",e.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O="L-rtc_client_create_microphone_audio_track-O",e.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O="L-rtc_client_create_camera_video_track-O",e.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O="L-rtc_client_create_microphone_and_camera_tracks-O",e.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O="L-rtc_client_create_screen_video_track-O",e.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_AND_AUDIO_TRACKS_O="L-rtc_client_create_screen_video_and_audio_tracks-O",e.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O="L-rtc_client_create_local_audio_track-O",e.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O="L-rtc_client_create_local_video_track-O",e.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O="L-rtc_client_create_local_file_tracks-O",e.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O="L-rtc_client_create_local_tracks-O",e.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O="L-rtc_client_apply_video_aspect_ratio-O",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_T="L-rtc_client_join_living_room_as_audience-T",e.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R="L-rtc_client_join_living_room_as_audience_R",e.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_T="L-rtc_client_leave_living_room_as_audience-T",e.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R="L-rtc_client_leave_living_room_as_audience-R",e.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_T="L-rtc_client_upgrade_to_anchor_room-T",e.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R="L-rtc_client_upgrade_to_anchor_room-R",e.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_T="L-rtc_client_downgrade_to_audience_room-T",e.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R="L-rtc_client_downgrade_to_audience_room-R",e.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_T="L-rtc_client_get_joined_room_info-T",e.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R="L-rtc_client_get_joined_room_info-R",e.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O="L-audinence_client_call_onTrackReady-O",e.L_AUDIENCE_CLIENT_SUBSCRIBE_T="L-audinence_client_subscribe-T",e.L_AUDIENCE_CLIENT_SUBSCRIBE_R="L-audinence_client_subscribe-R",e.L_AUDIENCE_CLIENT_UNSUBSCRIBE_T="L-audinence_client_unsubscribe-T",e.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R="L-audinence_client_unsubscribe-R",e.L_PINGER_START_O="L-pinger_start-O",e.L_PINGER_STOP_O="L-pinger_stop-O",e.L_PINGER_SEND_RTCPING_E="L-pinger_send_rtcping-E",e.L_ABSTRACT_ROOM_SEND_MESSAGE_T="L-abstract_room_send_message-T",e.L_ABSTRACT_ROOM_SEND_MESSAGE_R="L-abstract_room_send_message-R",e.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_T="L-abstract_room_set_room_attribute-T",e.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R="L-abstract_room_set_room_attribute_R",e.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_T="L-abstract_room_delete_room_attribute_T",e.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R="L-abstract_room_delete_room_attribute_R",e.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_T="L-abstract_room_get_room_attribute_T",e.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_R="L-abstract_room_get_room_attribute_R",e.L_ABSTRACT_ROOM_PUBLISH_T="L-abstract_room_publish-T",e.L_ABSTRACT_ROOM_PUBLISH_R="L-abstract_room_publish-R",e.L_ABSTRACT_ROOM_PUBLISH_E="L-abstract_room_publish-E",e.L_ABSTRACT_ROOM_UNPUBLISH_T="L-abstract_room_unpublish-T",e.L_ABSTRACT_ROOM_UNPUBLISH_R="L-abstract_room_unpublish-R",e.L_ABSTRACT_ROOM_UNPUBLISH_E="L-abstract_room_unpublish-E",e.L_ABSTRACT_ROOM_UNPUBLISH_P="L-abstract_room_unpublish-P",e.L_ABSTRACT_ROOM_SUBSCRIBE_T="L-abstract_room_subscribe-T",e.L_ABSTRACT_ROOM_SUBSCRIBE_R="L-abstract_room_subscribe-R",e.L_ABSTRACT_ROOM_SUBSCRIBE_E="L-abstract_room_subscribe-E",e.L_ABSTRACT_ROOM_UNSUBSCRIBE_T="L-abstract_room_unsubscribe-T",e.L_ABSTRACT_ROOM_UNSUBSCRIBE_R="L-abstract_room_unsubscribe-R",e.L_ABSTRACT_ROOM_UNSUBSCRIBE_E="L-abstract_room_unsubscribe-E",e.L_APP_CALL_UNSUBSCRIBE_O="L-app_call_unsubscribe-O",e.L_USER_LEFT_UNSUBSCRIBE_O="L-user_left_unsubscribe-O",e.L_RES_UNPUB_UNSUBSCRIBE_O="L-res_unpub_unsubscribe-O",e.L_ABSTRACT_ROOM_REGISTER_ROOM_EVENT_LISTENER_O="L-abstract_room_register_room_event_listener-O",e.L_ABSTRACT_ROOM_REGISTER_REPORT_LISTENER_O="L-abstract_room_register_report_listener-O",e.L_ABSTRACT_ROOM_AUDIO_LEVEL_O="L-abstract_room_audio_level-O",e.L_ABSTRACT_ROOM_IM_RECONNECTED_T="L-abstract_room_im_reconnected-T",e.L_ABSTRACT_ROOM_IM_RECONNECTED_R="L-abstract_room_im_reconnected-R",e.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O="L-abstract_room_call_app_listener-O",e.L_ABSTRACT_ROOM_SETBITRATE_O="L-abstract_room_setBitrate-O",e.L_ABSTRACT_ROOM_ONTRACKREADY_O="L-abstract_room_onTrackReady-O",e.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O="L-abstract_room_receive_message-O",e.L_ABSTRACT_ROOM_ONKICKOFF_O="L-abstract_room_onKickoff-O",e.L_LIVING_ROOM_RECONNECTED_T="L-living_room_reconnected-T",e.L_LIVING_ROOM_RECONNECTED_R="L-living_room_reconnected-R",e.L_LIVING_ROOM_ENABLE_INNER_CDN_T="L-living_room_enable_inner_cdn-T",e.L_LIVING_ROOM_ENABLE_INNER_CDN_R="L-living_room_enable_inner_cdn-R",e.L_LIVING_ROOM_SPREAD_CDN_INFO_T="L-living_room_spread_cdn_info-T",e.L_LIVING_ROOM_SPREAD_CDN_INFO_R="L-living_room_spread_cdn_info-R",e.L_LIVING_ROOM_SET_ROOM_CDN_INFO_T="L-living_room_set_room_cdn_info-T",e.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R="L-living_room_set_room_cdn_info-R",e.L_LIVING_ROOM_JOINED_PK_ROOM_T="L-living_room_joined_pk_room-T",e.L_LIVING_ROOM_JOINED_PK_ROOM_R="L-living_room_joined_pk_room-R",e.L_LIVING_ROOM_LEAVE_PK_ROOM_T="L-living_room_leave_pk_room-T",e.L_LIVING_ROOM_LEAVE_PK_ROOM_R="L-living_room_leave_pk_room-R",e.L_APP_CALL_LEAVE_PK_ROOM_O="L-app_call_leave_pk_room-O",e.L_QUIT_PK_LEAVE_PK_ROOM_O="L-quit_pk_leave_pk_room-O",e.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O="L-living_room_get_room_pk_handler-O",e.L_LIVING_ROOM_GET_MCU_CONFIG_BUILDER_O="L-living_room_get_mcu_config_builder-O",e.L_LIVING_ROOM_QUIT_ALL_PK_ROOM_O="L-living_room_quit_all_pk_room-O",e.L_LIVING_PK_HANDLER_REGISTER_ROOM_PK_EVENT_LISTENER_O="L-living_pk_handler_register_room_pk_event_listener-O",e.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O="L-living_pk_handler_call_app_listener-O",e.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_T="L-living_pk_handler_request_join_other_room-T",e.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R="L-living_pk_handler_request_join_other_room-R",e.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_T="L-living_pk_handler_cancel_request_join_other_room-T",e.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R="L-living_pk_handler_cancel_request_join_other_room-R",e.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_T="L-living_pk_handler_response_join_other_room-T",e.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R="L-living_pk_handler_response_join_other_room-R",e.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_T="L-living_pk_handler_join_other_room-T",e.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R="L-living_pk_handler_join_other_room-R",e.L_LIVING_PK_HANDLER_LEAVE_OTHER_ROOM_T="L-living_pk_handler_leave_other_room-T",e.L_LIVING_PK_HANDLER_LEAVE_OTHER_ROOM_R="L-living_pk_handler_leave_other_room-R",e.L_QUIT_PK_T="L-quit_pk-T",e.L_QUIT_PK_R="L-quit_pk-R",e.L_EXCHANGE_WITH_PUSHOTHERROOM_T="L-exchange_with_pushotherroom-T",e.L_EXCHANGE_WITH_PUSHOTHERROOM_R="L-exchange_with_pushotherroom-R",e.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O="L-audience_living_room_call_app_listener-O",e.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_O="L-audience_living_room_pull_kvEntries-O",e.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T="L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T",e.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R="L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R",e.L_AUDIENCE_LIVING_ROOM_SINGAL_DATA_CHANGE_P="L-audience_living_room_singal_data_change-P",e.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_T="L-audience_living_room_get_cdn_play_url-T",e.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R="L-audience_living_room_get_cdn_play_url-R",e.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_T="L-audience_living_room_subscribe-T",e.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R="L-audience_living_room_subscribe-R",e.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_T="L-audience_living_room_unsubscribe-T",e.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R="L-audience_living_room_unsubscribe-R",e.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_T="L-audience_living_room_update_subscribeList-T",e.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R="L-audience_living_room_update_subscribeList-R",e.L_AUDIENCE_LIVING_ROOM_ONTRACKREADY_O="L-audience_living_room_onTrackReady-O",e.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R="L-audience_living_room_im_reconnected-R",e.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_T="L-audience_living_room_im_reconnected-T",e.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O="L-mcu_config_builder_set_host_video_track-O",e.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O="L-mcu_config_builder_set_mix_layout_mode-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O="L-mcu_config_builder_set_output_video_resolution-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O="L-mcu_config_builder_set_output_video_fps-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O="L-mcu_config_builder_set_output_video_bitrate-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O="L-mcu_config_builder_set_output_tiny_video_resolution-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O="L-mcu_config_builder_set_output_tiny_video_fps-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O="L-mcu_config_builder_set_output_tiny_video_bitrate-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O="L-mcu_config_builder_set_output_video_render_mode-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O="L-mcu_config_builder_set_output_audio_bitrate-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O="L-mcu_config_builder_set_output_background_color-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O="L-mcu_config_builder_add_output_background_picture-O",e.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O="L-mcu_config_builder_remove_output_background_picture-O",e.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O="L-mcu_config_builder_clear_output_background_picture-O",e.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O="L-mcu_config_builder_set_output_background_picture-fill-mode-O",e.L_MCU_CONFIG_BUILDER_ADD_PUBLISH_STREAM_URLS_O="L-mcu_config_builder_add_publish_stream_urls-O",e.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O="L-mcu_config_builder_remove_publish_stream_urls-O",e.L_MCU_CONFIG_BUILDER_CLEAR_PUBLISH_STREAM_URLS_O="L-mcu_config_builder_clear_publish_stream_urls-O",e.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O="L-mcu_config_builder_add_customize_layout_video-O",e.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O="L-mcu_config_builder_remove_customize_layout_video-O",e.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_LAYOUT_VIDEO_O="L-mcu_config_builder_clear_customize_layout_video-O",e.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_set_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_add_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_remove_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_INPUT_AUDIO_O="L-mcu_config_builder_clear_customize_input_audio-O",e.L_MCU_CONFIG_BUILDER_RESET_O="L-mcu_config_builder_reset-O",e.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O="L-mcu_config_builder_add_single_water_mark-O",e.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O="L-mcu_config_builder_remove_single_water_mark-O",e.L_MCU_CONFIG_BUILDER_CLEAR_SINGLE_WATER_MARK_O="L-mcu_config_builder_clear_single_water_mark-O",e.L_MEDIA_SERVICE_SET_MCU_CONFIG_T="L-media_service_set_mcu_config-T",e.L_MEDIA_SERVICE_SET_MCU_CONFIG_R="L-media_service_set_mcu_config-R",e.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_T="L-media_service_get_cnd_resource_info-T",e.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R="L-media_service_get_cnd_resource_info-R",e.L_MEDIA_SERVICE_MSLIST_CHANGE_O="L-media_service_msList_change-O",e.L_MEDIA_SERVICE_PARSE_NAVI_CALLVOIP_INFO_O="L-media_service_parse_navi_callvoip_info-O",e.L_MEDIA_SERVICE_REQUEST_T="L-media_service_request-T",e.L_MEDIA_SERVICE_REQUEST_R="L-media_service_request-R",e.L_LOCAL_TRACK_DESTROY_O="L-loacl_track_destroy-O",e.L_LOCAL_TRACK_SET_BITRATE_O="L-loacl_track_set_bitrate-O",e.L_LOCAL_TRACK_SET_LOCAL_MUTED_O="L-loacl_track_set_local_muted-O",e.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_T="L-loacl_track_set_local_muted_spread-T",e.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R="L-loacl_track_set_local_muted_spread-R",e.L_TRACK_PLAY_O="L-track_play-O",e.L_TRACK_PLAY_E="L-track_play-E",e.L_TRACK_LOAD_START_O="L-track_load_start-O",e.L_TRACK_DURATION_CHANGE_O="L-track_duration_change-O",e.L_TRACK_LOADED_META_DATA_O="L-track_loaded_meta_data-O",e.L_TRACK_LOADED_DATA_O="L-track_loaded_data-O",e.L_TRACK_ABORT_O="L-track_abort-O",e.L_TRACK_VOLUME_CHANGE_O="L-track_volume_change-O",e.L_TRACK_CANPLAY_O="L-track_canplay-O",e.L_ABSTRACT_STAT_PARSER_FORMAT_RTC_STATE_REPORT_O="L-abstract_stat_parser_format_rtc_state_report-O",e.L_A_SDP_STRATEGY_SET_SDP_SEMANTICS_O="L-a_sdp_strategy_set_sdp_semantics-O",e.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O="L-a_sdp_strategy_set_remote_answer-O",e.L_RTC_PEER_CONNECTION_ADD_LOCAL_TRACK_O="L-rtc_peer_connection_add_local_track-O",e.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_S="L-rtc_peer_connection_ice_connection_state-S",e.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_REPORT_R="L-rtc_peer_connection_ice_connection_state_report-R",e.L_RTC_PEER_CONNECTION_CONNECTION_STATE_S="L-rtc_peer_connection_connection_state-S",e.L_RTC_PEER_CONNECTION_SET_BITRATE_O="L-rtc_peer_connection_set_bitrate-O",e.L_RTC_PEER_CONNECTION_CREATE_OFFER_O="L-rtc_peer_connection_create_offer-O",e.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O="L-rtc_peer_connection_remove_local_track_by_id-O",e.L_RTC_PEER_CONNECTION_REMOVE_ALL_LOCAL_TRACK_O="L-rtc_peer_connection_remove_all_local_track-O",e.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_O="L-rtc_peer_connection_remove_local_track-O",e.L_RTC_PEER_CONNECTION_DESTROY_O="L-rtc_peer_connection_destroy-O",e.L_RTC_SET_RECOMMEND_BITRATE_O="L_rtc_set_recommend_bitrate_O",e.L_RTC_3ANOISE_NODE_O="L_RTC_AAAnoiseNode_O",e.L_RTC_3ANOISE_NODE_E="L_RTC_AAAnoiseNode_E",e.L_RTC_3ANOISE_NODE_STOP_O="L_RTC_AAAnoiseNode_Stop_O",e.L_QS_JOIN_ROOM_S="RTC-joinRoomRtc-S",e.L_QS_SUBSCRIBE_S="RTC-subscribe-S",e.L_QS_UNSUBSCRIBE_S="RTC-unsubscribe-S",e.L_QS_PUBLISH_S="RTC-publishRtc-S",e.L_QS_UNPUBLISH_S="RTC-unpublishRtc-S",e.L_QS_ICE_STATUS_S="RTC-iceStatus-S",e.L_QS_KICKED_S="RTC-forcedOffline-S",e.L_QS_PUB_ICE_STATUS_S="RTC-pubIceConnected-S",e.L_QS_SUB_ICE_STATUS_S="RTC-subIceConnected-S",e.L_QS_RECV_PUB_MSG_S="RTC-recvPubMsg-S",e.L_SET_ENCODER_PREFERENCES_S="RTC-set_Encoder_Preferences-S",e.L_RTCNTF_PULL_ROOM_STATUS_O="L-rtcntf_pull_room_status-O",e.L_RTCPING_PULL_ROOM_STATUS_O="L-rtcping_pull_room_status-O",e.L_PULL_ROOM_STATUS_T="L-pull_room_status-T",e.L_PULL_ROOM_STATUS_R="L-pull_room_status-R",e.L_OLD_DAILY_RECORD_O="L-old_daily_record-O",e.L_REMOTE_USER_JOINED_RESOURCES_O="L-remote_user_joined_resources-O",e.L_REMOTE_USER_STATE_HANDLE_O="L-remote_user_state_handle-O",e.L_UPDATE_SUBSCRIBELIST_COMMAND_T="L-update_subscribeList_command-T",e.L_UPDATE_SUBSCRIBELIST_COMMAND_P="L-update_subscribeList_command-P",e.L_UPDATE_SUBSCRIBELIST_COMMAND_R="L-update_subscribeList_command-R",e.L_RTC_CLIENT_NAVI_CHANGE_O="L-rtc_client_navi_change-O",e.L_UNPUBLISH_PREV_COMMAND_T="L-unpublish_prev_command-T",e.L_UNPUBLISH_PREV_COMMAND_R="L-unpublish_prev_command-R",e.L_RETRY_EXCHANGE_COMMAND_T="L-retry_exchange_command-T",e.L_RETRY_EXCHANGE_SPREAD_T="L-retry_exchange_spread-T",e.L_RETRY_EXCHANGE_SPREAD_R="L-retry_exchange_spread-R",e.L_PARSE_USERSTATE_COMMAND_R="L-parse_userstate_command-R",e.L_RESUB_REPUB_RES_R="L-resub_repub_res-R",e.L_PARSE_ROOMDATA_URIS_R="L-parse_roomdata_uris-R",e.L_SET_AUDIO_CONSTRAINTS_O="L-set_audio_constraints-O",e.L_FUNCTION_IS_UNAVAILABLE="L-function_is_unavailable",e.L_CLEAR_UNSUBSCRIBE_LIST_O="L-clear_unsubscribe_list-O",e.L_INVOKER_PUSH_O="L-invoker_push-O",e.L_INVOKER_EXECUTE_T="L-invoker_execute-T",e.L_INVOKER_EXECUTE_R="L-invoker_execute-R",e.L_INVOKER_DESTROY_O="L-invoker_destroy-R",e.L_PARSE_VOIP_SERVER_CONF_E="L_PARSE_VOIP_SERVER_CONF_E",e.L_GET_MEDIA_STREAM_E="L_GET_MEDIA_STREAM_E",e.L_INNER_SET_TRACK_O="L_INNER_SET_TRACK_O",e.A_APPLY_3A_NOISE_WORKLET_T="A-apply_3a_noise_worklet-T",e.A_APPLY_3A_NOISE_WORKLET_R="A-apply_3a_noise_worklet-R",e.L_ENCRYPTOR_ENCODE_E="L-encryptor_encode-E",e.L_ENCRYPTOR_DECODE_E="L-encryptor_decode-E"}(S||(S={})),function(e){e.FAILED="fail",e.SUCCESSED="success",e.TIMEOUT="timeout",e.INFO="info"}(O||(O={}));let T=!0,C=!0;function v(e,t,r){const i=e.match(t);return i&&i.length>=r&&parseInt(i[r],10)}function b(e,t,r){if(!e.RTCPeerConnection)return;const i=e.RTCPeerConnection.prototype,n=i.addEventListener;i.addEventListener=function(e,i){if(e!==t)return n.apply(this,arguments);const s=e=>{const t=r(e);t&&(i.handleEvent?i.handleEvent(t):i(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(i,s),n.apply(this,[e,s])};const s=i.removeEventListener;i.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return s.apply(this,arguments);if(!this._eventMap[t].has(r))return s.apply(this,arguments);const i=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,s.apply(this,[e,i])},Object.defineProperty(i,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function L(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(T=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function y(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(C=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function N(){if("object"==typeof window){if(T)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function A(e,t){C&&console.warn(e+" is deprecated, please use "+t+" instead.")}function D(e){return"[object Object]"===Object.prototype.toString.call(e)}function P(e){return D(e)?Object.keys(e).reduce((function(t,r){const i=D(e[r]),n=i?P(e[r]):e[r],s=i&&!Object.keys(n).length;return void 0===n||s?t:Object.assign(t,{[r]:n})}),{}):e}function U(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach((i=>{i.endsWith("Id")?U(e,e.get(t[i]),r):i.endsWith("Ids")&&t[i].forEach((t=>{U(e,e.get(t),r)}))})))}function k(e,t,r){const i=r?"outbound-rtp":"inbound-rtp",n=new Map;if(null===t)return n;const s=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&s.push(e)})),s.forEach((t=>{e.forEach((r=>{r.type===i&&r.trackId===t.id&&U(e,r,n)}))})),n}const M=N;function w(e,t){const r=e&&e.navigator;if(!r.mediaDevices)return;const i=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((r=>{if("require"===r||"advanced"===r||"mediaSource"===r)return;const i="object"==typeof e[r]?e[r]:{ideal:e[r]};void 0!==i.exact&&"number"==typeof i.exact&&(i.min=i.max=i.exact);const n=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==i.ideal){t.optional=t.optional||[];let e={};"number"==typeof i.ideal?(e[n("min",r)]=i.ideal,t.optional.push(e),e={},e[n("max",r)]=i.ideal,t.optional.push(e)):(e[n("",r)]=i.ideal,t.optional.push(e))}void 0!==i.exact&&"number"!=typeof i.exact?(t.mandatory=t.mandatory||{},t.mandatory[n("",r)]=i.exact):["min","max"].forEach((e=>{void 0!==i[e]&&(t.mandatory=t.mandatory||{},t.mandatory[n(e,r)]=i[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},n=function(e,n){if(t.version>=61)return n(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=i(e.audio)}if(e&&"object"==typeof e.video){let s=e.video.facingMode;s=s&&("object"==typeof s?s:{ideal:s});const o=t.version<66;if(s&&("user"===s.exact||"environment"===s.exact||"user"===s.ideal||"environment"===s.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||o)){let t;if(delete e.video.facingMode,"environment"===s.exact||"environment"===s.ideal?t=["back","rear"]:"user"!==s.exact&&"user"!==s.ideal||(t=["front"]),t)return r.mediaDevices.enumerateDevices().then((r=>{let o=(r=r.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!o&&r.length&&t.includes("back")&&(o=r[r.length-1]),o&&(e.video.deviceId=s.exact?{exact:o.deviceId}:{ideal:o.deviceId}),e.video=i(e.video),M("chrome: "+JSON.stringify(e)),n(e)}))}e.video=i(e.video)}return M("chrome: "+JSON.stringify(e)),n(e)},s=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(r.getUserMedia=function(e,t,i){n(e,(e=>{r.webkitGetUserMedia(e,t,(e=>{i&&i(s(e))}))}))}.bind(r),r.mediaDevices.getUserMedia){const e=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(t){return n(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(s(e))))))}}}function B(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function x(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(r=>{let i;i=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===r.track.id)):{track:r.track};const n=new Event("track");n.track=r.track,n.receiver=i,n.transceiver={receiver:i},n.streams=[t.stream],this.dispatchEvent(n)})),t.stream.getTracks().forEach((r=>{let i;i=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===r.id)):{track:r};const n=new Event("track");n.track=r,n.receiver=i,n.transceiver={receiver:i},n.streams=[t.stream],this.dispatchEvent(n)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else b(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function V(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){let n=r.apply(this,arguments);return n||(n=t(this,e),this._senders.push(n)),n};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){i.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function j(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,r,i]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const n=function(e){const t={};return e.result().forEach((e=>{const r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{r[t]=e.stat(t)})),t[r.id]=r})),t},s=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const i=function(e){r(s(n(e)))};return t.apply(this,[i,e])}return new Promise(((e,r)=>{t.apply(this,[function(t){e(s(n(t)))},r])})).then(r,i)}}function F(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>k(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),b(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>k(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,r,i;return this.getSenders().forEach((r=>{r.track===e&&(t?i=!0:t=r)})),this.getReceivers().forEach((t=>(t.track===e&&(r?i=!0:r=t),t.track===e))),i||t&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function J(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const i=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===this._shimmedLocalStreams[r.id].indexOf(i)&&this._shimmedLocalStreams[r.id].push(i):this._shimmedLocalStreams[r.id]=[r,i],i};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();r.apply(this,arguments);const i=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(i)};const i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],i.apply(this,arguments)};const n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const r=this._shimmedLocalStreams[t].indexOf(e);-1!==r&&this._shimmedLocalStreams[t].splice(r,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),n.apply(this,arguments)}}function G(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return J(e);const r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=r.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const r=new e.MediaStream(t.getTracks());this._streams[t.id]=r,this._reverseStreams[r.id]=t,t=r}i.apply(this,[t])};const n=e.RTCPeerConnection.prototype.removeStream;function s(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const i=e._reverseStreams[t],n=e._streams[i.id];r=r.replace(new RegExp(n.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:r})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},n.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,r){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find((e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find((e=>e.track===t)))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const n=this._streams[r.id];if(n)n.addTrack(t),Promise.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const i=new e.MediaStream([t]);this._streams[r.id]=i,this._reverseStreams[i.id]=r,this.addStream(i)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],i={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?r.apply(this,[t=>{const r=s(this,t);e[0].apply(null,[r])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):r.apply(this,arguments).then((e=>s(this,e)))}};e.RTCPeerConnection.prototype[t]=i[t]}));const o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const i=e._reverseStreams[t],n=e._streams[i.id];r=r.replace(new RegExp(i.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:r})}(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};const a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=a.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach((r=>{this._streams[r].getTracks().find((t=>e.track===t))&&(t=this._streams[r])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function H(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=i[t]}))}function K(e,t){b(e,"negotiationneeded",(e=>{const r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var $=Object.freeze({__proto__:null,shimMediaStream:B,shimOnTrack:x,shimGetSendersWithDtmf:V,shimGetStats:j,shimSenderReceiverGetStats:F,shimAddTrackRemoveTrackWithNative:J,shimAddTrackRemoveTrack:G,shimPeerConnection:H,fixNegotiationNeeded:K,shimGetUserMedia:w,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then((t=>{const i=r.video&&r.video.width,n=r.video&&r.video.height,s=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:s||3}},i&&(r.video.mandatory.maxWidth=i),n&&(r.video.mandatory.maxHeight=n),e.navigator.mediaDevices.getUserMedia(r)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}});var W,Y,z=(W=function(e){var t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},t.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},t.getDescription=function(e){var r=t.splitSections(e);return r&&r[0]},t.getMediaSections=function(e){var r=t.splitSections(e);return r.shift(),r},t.matchPrefix=function(e,r){return t.splitLines(e).filter((function(e){return 0===e.indexOf(r)}))},t.parseCandidate=function(e){for(var t,r={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},i=8;i<t.length;i+=2)switch(t[i]){case"raddr":r.relatedAddress=t[i+1];break;case"rport":r.relatedPort=parseInt(t[i+1],10);break;case"tcptype":r.tcpType=t[i+1];break;case"ufrag":r.ufrag=t[i+1],r.usernameFragment=t[i+1];break;default:r[t[i]]=t[i+1]}return r},t.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var r=e.type;return t.push("typ"),t.push(r),"host"!==r&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=parseInt(t[1],10),r.channels=3===t.length?parseInt(t[2],10):1,r.numChannels=r.channels,r},t.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\r\n"},t.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},t.parseFmtp=function(e){for(var t,r={},i=e.substr(e.indexOf(" ")+1).split(";"),n=0;n<i.length;n++)r[(t=i[n].trim().split("="))[0].trim()]=t[1];return r},t.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var i=[];Object.keys(e.parameters).forEach((function(t){e.parameters[t]?i.push(t+"="+e.parameters[t]):i.push(t)})),t+="a=fmtp:"+r+" "+i.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){var t="",r=e.payloadType;return void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){var t=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,t-7),10)},i=e.indexOf(":",t);return i>-1?(r.attribute=e.substr(t+1,i-t-1),r.value=e.substr(i+1)):r.attribute=e.substr(t+1),r},t.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},t.getMid=function(e){var r=t.matchPrefix(e,"a=mid:")[0];if(r)return r.substr(6)},t.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},t.getDtlsParameters=function(e,r){return{role:"auto",fingerprints:t.matchPrefix(e+r,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),r},t.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,r){return t.matchPrefix(e+r,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,r){var i=t.matchPrefix(e+r,"a=ice-ufrag:")[0],n=t.matchPrefix(e+r,"a=ice-pwd:")[0];return i&&n?{usernameFragment:i.substr(12),password:n.substr(10)}:null},t.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},t.parseRtpParameters=function(e){for(var r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=t.splitLines(e)[0].split(" "),n=3;n<i.length;n++){var s=i[n],o=t.matchPrefix(e,"a=rtpmap:"+s+" ")[0];if(o){var a=t.parseRtpMap(o),c=t.matchPrefix(e,"a=fmtp:"+s+" ");switch(a.parameters=c.length?t.parseFmtp(c[0]):{},a.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+s+" ").map(t.parseRtcpFb),r.codecs.push(a),a.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(a.name.toUpperCase())}}}return t.matchPrefix(e,"a=extmap:").forEach((function(e){r.headerExtensions.push(t.parseExtmap(e))})),r},t.writeRtpDescription=function(e,r){var i="";i+="m="+e+" ",i+=r.codecs.length>0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=r.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",i+="c=IN IP4 0.0.0.0\r\n",i+="a=rtcp:9 IN IP4 0.0.0.0\r\n",r.codecs.forEach((function(e){i+=t.writeRtpMap(e),i+=t.writeFmtp(e),i+=t.writeRtcpFb(e)}));var n=0;return r.codecs.forEach((function(e){e.maxptime>n&&(n=e.maxptime)})),n>0&&(i+="a=maxptime:"+n+"\r\n"),i+="a=rtcp-mux\r\n",r.headerExtensions&&r.headerExtensions.forEach((function(e){i+=t.writeExtmap(e)})),i},t.parseRtpEncodingParameters=function(e){var r,i=[],n=t.parseRtpParameters(e),s=-1!==n.fecMechanisms.indexOf("RED"),o=-1!==n.fecMechanisms.indexOf("ULPFEC"),a=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=a.length>0&&a[0].ssrc,_=t.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substr(17).split(" ").map((function(e){return parseInt(e,10)}))}));_.length>0&&_[0].length>1&&_[0][0]===c&&(r=_[0][1]),n.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&r&&(t.rtx={ssrc:r}),i.push(t),s&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:o?"red+ulpfec":"red"},i.push(t))}})),0===i.length&&c&&i.push({ssrc:c});var d=t.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substr(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substr(5),10)*.95-16e3:void 0,i.forEach((function(e){e.maxBitrate=d}))),i},t.parseRtcpParameters=function(e){var r={},i=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];i&&(r.cname=i.value,r.ssrc=i.ssrc);var n=t.matchPrefix(e,"a=rtcp-rsize");r.reducedSize=n.length>0,r.compound=0===n.length;var s=t.matchPrefix(e,"a=rtcp-mux");return r.mux=s.length>0,r},t.parseMsid=function(e){var r,i=t.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(r=i[0].substr(7).split(" "))[0],track:r[1]};var n=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return n.length>0?{stream:(r=n[0].value.split(" "))[0],track:r[1]}:void 0},t.parseSctpDescription=function(e){var r,i=t.parseMLine(e),n=t.matchPrefix(e,"a=max-message-size:");n.length>0&&(r=parseInt(n[0].substr(19),10)),isNaN(r)&&(r=65536);var s=t.matchPrefix(e,"a=sctp-port:");if(s.length>0)return{port:parseInt(s[0].substr(12),10),protocol:i.fmt,maxMessageSize:r};if(t.matchPrefix(e,"a=sctpmap:").length>0){var o=t.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(o[0],10),protocol:o[1],maxMessageSize:r}}},t.writeSctpDescription=function(e,t){var r=[];return r="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,r,i){var n=void 0!==r?r:2;return"v=0\r\no="+(i||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.writeMediaSection=function(e,r,i,n){var s=t.writeRtpDescription(e.kind,r);if(s+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===i?"actpass":"active"),s+="a=mid:"+e.mid+"\r\n",e.direction?s+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?s+="a=sendrecv\r\n":e.rtpSender?s+="a=sendonly\r\n":e.rtpReceiver?s+="a=recvonly\r\n":s+="a=inactive\r\n",e.rtpSender){var o="msid:"+n.id+" "+e.rtpSender.track.id+"\r\n";s+="a="+o,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+"\r\n"),s},t.getDirection=function(e,r){for(var i=t.splitLines(e),n=0;n<i.length;n++)switch(i[n]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[n].substr(2)}return r?t.getDirection(r):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substr(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){var r=t.splitLines(e)[0].substr(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},t.parseOLine=function(e){var r=t.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var r=t.splitLines(e),i=0;i<r.length;i++)if(r[i].length<2||"="!==r[i].charAt(1))return!1;return!0},e.exports=t},W(Y={exports:{}},Y.exports),Y.exports);function q(e,t,r,i,n){var s=z.writeRtpDescription(e.kind,t);if(s+=z.writeIceParameters(e.iceGatherer.getLocalParameters()),s+=z.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":n||"active"),s+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?s+="a=sendrecv\r\n":e.rtpSender?s+="a=sendonly\r\n":e.rtpReceiver?s+="a=recvonly\r\n":s+="a=inactive\r\n",e.rtpSender){var o=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=o;var a="msid:"+(i?i.id:"-")+" "+o+"\r\n";s+="a="+a,s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,s+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return s+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+z.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(s+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+z.localCName+"\r\n"),s}function Q(e,t){var r={codecs:[],headerExtensions:[],fecMechanisms:[]},i=function(e,t){e=parseInt(e,10);for(var r=0;r<t.length;r++)if(t[r].payloadType===e||t[r].preferredPayloadType===e)return t[r]},n=function(e,t,r,n){var s=i(e.parameters.apt,r),o=i(t.parameters.apt,n);return s&&o&&s.name.toLowerCase()===o.name.toLowerCase()};return e.codecs.forEach((function(i){for(var s=0;s<t.codecs.length;s++){var o=t.codecs[s];if(i.name.toLowerCase()===o.name.toLowerCase()&&i.clockRate===o.clockRate){if("rtx"===i.name.toLowerCase()&&i.parameters&&o.parameters.apt&&!n(i,o,e.codecs,t.codecs))continue;(o=JSON.parse(JSON.stringify(o))).numChannels=Math.min(i.numChannels,o.numChannels),r.codecs.push(o),o.rtcpFeedback=o.rtcpFeedback.filter((function(e){for(var t=0;t<i.rtcpFeedback.length;t++)if(i.rtcpFeedback[t].type===e.type&&i.rtcpFeedback[t].parameter===e.parameter)return!0;return!1}));break}}})),e.headerExtensions.forEach((function(e){for(var i=0;i<t.headerExtensions.length;i++){var n=t.headerExtensions[i];if(e.uri===n.uri){r.headerExtensions.push(n);break}}})),r}function Z(e,t,r){return-1!=={offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(r)}function X(e,t){var r=e.getRemoteCandidates().find((function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type}));return r||e.addRemoteCandidate(t),!r}function ee(e,t){var r=new Error(t);return r.name=e,r.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],r}var te=function(e,t){function r(t,r){r.addTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function i(t,r,i,n){var s=new Event("track");s.track=r,s.receiver=i,s.transceiver={receiver:i},s.streams=n,e.setTimeout((function(){t._dispatchEvent("track",s)}))}var n=function(r){var i=this,n=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach((function(e){i[e]=n[e].bind(n)})),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",r=JSON.parse(JSON.stringify(r||{})),this.usingBundle="max-bundle"===r.bundlePolicy,"negotiate"===r.rtcpMuxPolicy)throw ee("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(r.rtcpMuxPolicy||(r.rtcpMuxPolicy="require"),r.iceTransportPolicy){case"all":case"relay":break;default:r.iceTransportPolicy="all"}switch(r.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:r.bundlePolicy="balanced"}if(r.iceServers=function(e,t){var r=!1;return(e=JSON.parse(JSON.stringify(e))).filter((function(e){if(e&&(e.urls||e.url)){var i=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var n="string"==typeof i;return n&&(i=[i]),i=i.filter((function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||r?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(r=!0,!0)})),delete e.url,e.urls=n?i[0]:i,!!i.length}}))}(r.iceServers||[],t),this._iceGatherers=[],r.iceCandidatePoolSize)for(var s=r.iceCandidatePoolSize;s>0;s--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:r.iceServers,gatherPolicy:r.iceTransportPolicy}));else r.iceCandidatePoolSize=0;this._config=r,this.transceivers=[],this._sdpSessionId=z.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(n.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(n.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),n.prototype.onicecandidate=null,n.prototype.onaddstream=null,n.prototype.ontrack=null,n.prototype.onremovestream=null,n.prototype.onsignalingstatechange=null,n.prototype.oniceconnectionstatechange=null,n.prototype.onconnectionstatechange=null,n.prototype.onicegatheringstatechange=null,n.prototype.onnegotiationneeded=null,n.prototype.ondatachannel=null,n.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},n.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},n.prototype.getConfiguration=function(){return this._config},n.prototype.getLocalStreams=function(){return this.localStreams},n.prototype.getRemoteStreams=function(){return this.remoteStreams},n.prototype._createTransceiver=function(e,t){var r=this.transceivers.length>0,i={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&r)i.iceTransport=this.transceivers[0].iceTransport,i.dtlsTransport=this.transceivers[0].dtlsTransport;else{var n=this._createIceAndDtlsTransports();i.iceTransport=n.iceTransport,i.dtlsTransport=n.dtlsTransport}return t||this.transceivers.push(i),i},n.prototype.addTrack=function(t,r){if(this._isClosed)throw ee("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var i;if(this.transceivers.find((function(e){return e.track===t})))throw ee("InvalidAccessError","Track already exists.");for(var n=0;n<this.transceivers.length;n++)this.transceivers[n].track||this.transceivers[n].kind!==t.kind||(i=this.transceivers[n]);return i||(i=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(r)&&this.localStreams.push(r),i.track=t,i.stream=r,i.rtpSender=new e.RTCRtpSender(t,i.dtlsTransport),i.rtpSender},n.prototype.addStream=function(e){var r=this;if(t>=15025)e.getTracks().forEach((function(t){r.addTrack(t,e)}));else{var i=e.clone();e.getTracks().forEach((function(e,t){var r=i.getTracks()[t];e.addEventListener("enabled",(function(e){r.enabled=e.enabled}))})),i.getTracks().forEach((function(e){r.addTrack(e,i)}))}},n.prototype.removeTrack=function(t){if(this._isClosed)throw ee("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var r=this.transceivers.find((function(e){return e.rtpSender===t}));if(!r)throw ee("InvalidAccessError","Sender was not created by this connection.");var i=r.stream;r.rtpSender.stop(),r.rtpSender=null,r.track=null,r.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(i)&&this.localStreams.indexOf(i)>-1&&this.localStreams.splice(this.localStreams.indexOf(i),1),this._maybeFireNegotiationNeeded()},n.prototype.removeStream=function(e){var t=this;e.getTracks().forEach((function(e){var r=t.getSenders().find((function(t){return t.track===e}));r&&t.removeTrack(r)}))},n.prototype.getSenders=function(){return this.transceivers.filter((function(e){return!!e.rtpSender})).map((function(e){return e.rtpSender}))},n.prototype.getReceivers=function(){return this.transceivers.filter((function(e){return!!e.rtpReceiver})).map((function(e){return e.rtpReceiver}))},n.prototype._createIceGatherer=function(t,r){var i=this;if(r&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var n=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(n,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var r=!e.candidate||0===Object.keys(e.candidate).length;n.state=r?"completed":"gathering",null!==i.transceivers[t].bufferedCandidateEvents&&i.transceivers[t].bufferedCandidateEvents.push(e)},n.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),n},n.prototype._gather=function(t,r){var i=this,n=this.transceivers[r].iceGatherer;if(!n.onlocalcandidate){var s=this.transceivers[r].bufferedCandidateEvents;this.transceivers[r].bufferedCandidateEvents=null,n.removeEventListener("localcandidate",this.transceivers[r].bufferCandidates),n.onlocalcandidate=function(e){if(!(i.usingBundle&&r>0)){var s=new Event("icecandidate");s.candidate={sdpMid:t,sdpMLineIndex:r};var o=e.candidate,a=!o||0===Object.keys(o).length;if(a)"new"!==n.state&&"gathering"!==n.state||(n.state="completed");else{"new"===n.state&&(n.state="gathering"),o.component=1,o.ufrag=n.getLocalParameters().usernameFragment;var c=z.writeCandidate(o);s.candidate=Object.assign(s.candidate,z.parseCandidate(c)),s.candidate.candidate=c,s.candidate.toJSON=function(){return{candidate:s.candidate.candidate,sdpMid:s.candidate.sdpMid,sdpMLineIndex:s.candidate.sdpMLineIndex,usernameFragment:s.candidate.usernameFragment}}}var _=z.getMediaSections(i._localDescription.sdp);_[s.candidate.sdpMLineIndex]+=a?"a=end-of-candidates\r\n":"a="+s.candidate.candidate+"\r\n",i._localDescription.sdp=z.getDescription(i._localDescription.sdp)+_.join("");var d=i.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),a||i._dispatchEvent("icecandidate",s),d&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout((function(){s.forEach((function(e){n.onlocalcandidate(e)}))}),0)}},n.prototype._createIceAndDtlsTransports=function(){var t=this,r=new e.RTCIceTransport(null);r.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var i=new e.RTCDtlsTransport(r);return i.ondtlsstatechange=function(){t._updateConnectionState()},i.onerror=function(){Object.defineProperty(i,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:r,dtlsTransport:i}},n.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var r=this.transceivers[e].iceTransport;r&&(delete r.onicestatechange,delete this.transceivers[e].iceTransport);var i=this.transceivers[e].dtlsTransport;i&&(delete i.ondtlsstatechange,delete i.onerror,delete this.transceivers[e].dtlsTransport)},n.prototype._transceive=function(e,r,i){var n=Q(e.localCapabilities,e.remoteCapabilities);r&&e.rtpSender&&(n.encodings=e.sendEncodingParameters,n.rtcp={cname:z.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(n.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(n)),i&&e.rtpReceiver&&n.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach((function(e){delete e.rtx})),e.recvEncodingParameters.length?n.encodings=e.recvEncodingParameters:n.encodings=[{}],n.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(n.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(n.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(n))},n.prototype.setLocalDescription=function(e){var t,r,i=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(ee("TypeError",'Unsupported type "'+e.type+'"'));if(!Z("setLocalDescription",e.type,i.signalingState)||i._isClosed)return Promise.reject(ee("InvalidStateError","Can not set local "+e.type+" in state "+i.signalingState));if("offer"===e.type)t=z.splitSections(e.sdp),r=t.shift(),t.forEach((function(e,t){var r=z.parseRtpParameters(e);i.transceivers[t].localCapabilities=r})),i.transceivers.forEach((function(e,t){i._gather(e.mid,t)}));else if("answer"===e.type){t=z.splitSections(i._remoteDescription.sdp),r=t.shift();var n=z.matchPrefix(r,"a=ice-lite").length>0;t.forEach((function(e,t){var s=i.transceivers[t],o=s.iceGatherer,a=s.iceTransport,c=s.dtlsTransport,_=s.localCapabilities,d=s.remoteCapabilities;if(!(z.isRejected(e)&&0===z.matchPrefix(e,"a=bundle-only").length)&&!s.rejected){var l=z.getIceParameters(e,r),u=z.getDtlsParameters(e,r);n&&(u.role="server"),i.usingBundle&&0!==t||(i._gather(s.mid,t),"new"===a.state&&a.start(o,l,n?"controlling":"controlled"),"new"===c.state&&c.start(u));var h=Q(_,d);i._transceive(s,h.codecs.length>0,!1)}}))}return i._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?i._updateSignalingState("have-local-offer"):i._updateSignalingState("stable"),Promise.resolve()},n.prototype.setRemoteDescription=function(n){var s=this;if(-1===["offer","answer"].indexOf(n.type))return Promise.reject(ee("TypeError",'Unsupported type "'+n.type+'"'));if(!Z("setRemoteDescription",n.type,s.signalingState)||s._isClosed)return Promise.reject(ee("InvalidStateError","Can not set remote "+n.type+" in state "+s.signalingState));var o={};s.remoteStreams.forEach((function(e){o[e.id]=e}));var a=[],c=z.splitSections(n.sdp),_=c.shift(),d=z.matchPrefix(_,"a=ice-lite").length>0,l=z.matchPrefix(_,"a=group:BUNDLE ").length>0;s.usingBundle=l;var u=z.matchPrefix(_,"a=ice-options:")[0];return s.canTrickleIceCandidates=!!u&&u.substr(14).split(" ").indexOf("trickle")>=0,c.forEach((function(i,c){var u=z.splitLines(i),h=z.getKind(i),p=z.isRejected(i)&&0===z.matchPrefix(i,"a=bundle-only").length,g=u[0].substr(2).split(" ")[2],R=z.getDirection(i,_),m=z.parseMsid(i),f=z.getMid(i)||z.generateIdentifier();if(p||"application"===h&&("DTLS/SCTP"===g||"UDP/DTLS/SCTP"===g))s.transceivers[c]={mid:f,kind:h,protocol:g,rejected:!0};else{var E,I,S,O,T,C,v,b,L;!p&&s.transceivers[c]&&s.transceivers[c].rejected&&(s.transceivers[c]=s._createTransceiver(h,!0));var y,N,A=z.parseRtpParameters(i);p||(y=z.getIceParameters(i,_),(N=z.getDtlsParameters(i,_)).role="client"),v=z.parseRtpEncodingParameters(i);var D=z.parseRtcpParameters(i),P=z.matchPrefix(i,"a=end-of-candidates",_).length>0,U=z.matchPrefix(i,"a=candidate:").map((function(e){return z.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===n.type||"answer"===n.type)&&!p&&l&&c>0&&s.transceivers[c]&&(s._disposeIceAndDtlsTransports(c),s.transceivers[c].iceGatherer=s.transceivers[0].iceGatherer,s.transceivers[c].iceTransport=s.transceivers[0].iceTransport,s.transceivers[c].dtlsTransport=s.transceivers[0].dtlsTransport,s.transceivers[c].rtpSender&&s.transceivers[c].rtpSender.setTransport(s.transceivers[0].dtlsTransport),s.transceivers[c].rtpReceiver&&s.transceivers[c].rtpReceiver.setTransport(s.transceivers[0].dtlsTransport)),"offer"!==n.type||p){if("answer"===n.type&&!p){I=(E=s.transceivers[c]).iceGatherer,S=E.iceTransport,O=E.dtlsTransport,T=E.rtpReceiver,C=E.sendEncodingParameters,b=E.localCapabilities,s.transceivers[c].recvEncodingParameters=v,s.transceivers[c].remoteCapabilities=A,s.transceivers[c].rtcpParameters=D,U.length&&"new"===S.state&&(!d&&!P||l&&0!==c?U.forEach((function(e){X(E.iceTransport,e)})):S.setRemoteCandidates(U)),l&&0!==c||("new"===S.state&&S.start(I,y,"controlling"),"new"===O.state&&O.start(N)),!Q(E.localCapabilities,E.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&E.sendEncodingParameters[0].rtx&&delete E.sendEncodingParameters[0].rtx,s._transceive(E,"sendrecv"===R||"recvonly"===R,"sendrecv"===R||"sendonly"===R),!T||"sendrecv"!==R&&"sendonly"!==R?delete E.rtpReceiver:(L=T.track,m?(o[m.stream]||(o[m.stream]=new e.MediaStream),r(L,o[m.stream]),a.push([L,T,o[m.stream]])):(o.default||(o.default=new e.MediaStream),r(L,o.default),a.push([L,T,o.default])))}}else{(E=s.transceivers[c]||s._createTransceiver(h)).mid=f,E.iceGatherer||(E.iceGatherer=s._createIceGatherer(c,l)),U.length&&"new"===E.iceTransport.state&&(!P||l&&0!==c?U.forEach((function(e){X(E.iceTransport,e)})):E.iceTransport.setRemoteCandidates(U)),b=e.RTCRtpReceiver.getCapabilities(h),t<15019&&(b.codecs=b.codecs.filter((function(e){return"rtx"!==e.name}))),C=E.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var k,M=!1;if("sendrecv"===R||"sendonly"===R){if(M=!E.rtpReceiver,T=E.rtpReceiver||new e.RTCRtpReceiver(E.dtlsTransport,h),M)L=T.track,m&&"-"===m.stream||(m?(o[m.stream]||(o[m.stream]=new e.MediaStream,Object.defineProperty(o[m.stream],"id",{get:function(){return m.stream}})),Object.defineProperty(L,"id",{get:function(){return m.track}}),k=o[m.stream]):(o.default||(o.default=new e.MediaStream),k=o.default)),k&&(r(L,k),E.associatedRemoteMediaStreams.push(k)),a.push([L,T,k])}else E.rtpReceiver&&E.rtpReceiver.track&&(E.associatedRemoteMediaStreams.forEach((function(t){var r=t.getTracks().find((function(e){return e.id===E.rtpReceiver.track.id}));r&&function(t,r){r.removeTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(r,t)})),E.associatedRemoteMediaStreams=[]);E.localCapabilities=b,E.remoteCapabilities=A,E.rtpReceiver=T,E.rtcpParameters=D,E.sendEncodingParameters=C,E.recvEncodingParameters=v,s._transceive(s.transceivers[c],!1,M)}}})),void 0===s._dtlsRole&&(s._dtlsRole="offer"===n.type?"active":"passive"),s._remoteDescription={type:n.type,sdp:n.sdp},"offer"===n.type?s._updateSignalingState("have-remote-offer"):s._updateSignalingState("stable"),Object.keys(o).forEach((function(t){var r=o[t];if(r.getTracks().length){if(-1===s.remoteStreams.indexOf(r)){s.remoteStreams.push(r);var n=new Event("addstream");n.stream=r,e.setTimeout((function(){s._dispatchEvent("addstream",n)}))}a.forEach((function(e){var t=e[0],n=e[1];r.id===e[2].id&&i(s,t,n,[r])}))}})),a.forEach((function(e){e[2]||i(s,e[0],e[1],[])})),e.setTimeout((function(){s&&s.transceivers&&s.transceivers.forEach((function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))}))}),4e3),Promise.resolve()},n.prototype.close=function(){this.transceivers.forEach((function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()})),this._isClosed=!0,this._updateSignalingState("closed")},n.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},n.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout((function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}}),0))},n.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++})),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var r=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",r)}},n.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++)})),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var r=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",r)}},n.prototype.createOffer=function(){var r=this;if(r._isClosed)return Promise.reject(ee("InvalidStateError","Can not call createOffer after close"));var i=r.transceivers.filter((function(e){return"audio"===e.kind})).length,n=r.transceivers.filter((function(e){return"video"===e.kind})).length,s=arguments[0];if(s){if(s.mandatory||s.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==s.offerToReceiveAudio&&(i=!0===s.offerToReceiveAudio?1:!1===s.offerToReceiveAudio?0:s.offerToReceiveAudio),void 0!==s.offerToReceiveVideo&&(n=!0===s.offerToReceiveVideo?1:!1===s.offerToReceiveVideo?0:s.offerToReceiveVideo)}for(r.transceivers.forEach((function(e){"audio"===e.kind?--i<0&&(e.wantReceive=!1):"video"===e.kind&&--n<0&&(e.wantReceive=!1)}));i>0||n>0;)i>0&&(r._createTransceiver("audio"),i--),n>0&&(r._createTransceiver("video"),n--);var o=z.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.transceivers.forEach((function(i,n){var s=i.track,o=i.kind,a=i.mid||z.generateIdentifier();i.mid=a,i.iceGatherer||(i.iceGatherer=r._createIceGatherer(n,r.usingBundle));var c=e.RTCRtpSender.getCapabilities(o);t<15019&&(c.codecs=c.codecs.filter((function(e){return"rtx"!==e.name}))),c.codecs.forEach((function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),i.remoteCapabilities&&i.remoteCapabilities.codecs&&i.remoteCapabilities.codecs.forEach((function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)}))})),c.headerExtensions.forEach((function(e){(i.remoteCapabilities&&i.remoteCapabilities.headerExtensions||[]).forEach((function(t){e.uri===t.uri&&(e.id=t.id)}))}));var _=i.sendEncodingParameters||[{ssrc:1001*(2*n+1)}];s&&t>=15019&&"video"===o&&!_[0].rtx&&(_[0].rtx={ssrc:_[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,o)),i.localCapabilities=c,i.sendEncodingParameters=_})),"max-compat"!==r._config.bundlePolicy&&(o+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),o+="a=ice-options:trickle\r\n",r.transceivers.forEach((function(e,t){o+=q(e,e.localCapabilities,"offer",e.stream,r._dtlsRole),o+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===r.iceGatheringState||0!==t&&r.usingBundle||(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,o+="a="+z.writeCandidate(e)+"\r\n"})),"completed"===e.iceGatherer.state&&(o+="a=end-of-candidates\r\n"))}));var a=new e.RTCSessionDescription({type:"offer",sdp:o});return Promise.resolve(a)},n.prototype.createAnswer=function(){var r=this;if(r._isClosed)return Promise.reject(ee("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==r.signalingState&&"have-local-pranswer"!==r.signalingState)return Promise.reject(ee("InvalidStateError","Can not call createAnswer in signalingState "+r.signalingState));var i=z.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.usingBundle&&(i+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),i+="a=ice-options:trickle\r\n";var n=z.getMediaSections(r._remoteDescription.sdp).length;r.transceivers.forEach((function(e,s){if(!(s+1>n)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?i+="m=application 0 DTLS/SCTP 5000\r\n":i+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?i+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(i+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(i+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var o;if(e.stream)"audio"===e.kind?o=e.stream.getAudioTracks()[0]:"video"===e.kind&&(o=e.stream.getVideoTracks()[0]),o&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var a=Q(e.localCapabilities,e.remoteCapabilities);!a.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,i+=q(e,a,"answer",e.stream,r._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(i+="a=rtcp-rsize\r\n")}}));var s=new e.RTCSessionDescription({type:"answer",sdp:i});return Promise.resolve(s)},n.prototype.addIceCandidate=function(e){var t,r=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise((function(i,n){if(!r._remoteDescription)return n(ee("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var s=e.sdpMLineIndex;if(e.sdpMid)for(var o=0;o<r.transceivers.length;o++)if(r.transceivers[o].mid===e.sdpMid){s=o;break}var a=r.transceivers[s];if(!a)return n(ee("OperationError","Can not add ICE candidate"));if(a.rejected)return i();var c=Object.keys(e.candidate).length>0?z.parseCandidate(e.candidate):{};if("tcp"===c.protocol&&(0===c.port||9===c.port))return i();if(c.component&&1!==c.component)return i();if((0===s||s>0&&a.iceTransport!==r.transceivers[0].iceTransport)&&!X(a.iceTransport,c))return n(ee("OperationError","Can not add ICE candidate"));var _=e.candidate.trim();0===_.indexOf("a=")&&(_=_.substr(2)),(t=z.getMediaSections(r._remoteDescription.sdp))[s]+="a="+(c.type?_:"end-of-candidates")+"\r\n",r._remoteDescription.sdp=z.getDescription(r._remoteDescription.sdp)+t.join("")}else for(var d=0;d<r.transceivers.length&&(r.transceivers[d].rejected||(r.transceivers[d].iceTransport.addRemoteCandidate({}),(t=z.getMediaSections(r._remoteDescription.sdp))[d]+="a=end-of-candidates\r\n",r._remoteDescription.sdp=z.getDescription(r._remoteDescription.sdp)+t.join(""),!r.usingBundle));d++);i()}))},n.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var r=null;if(this.transceivers.forEach((function(e){e.rtpSender&&e.rtpSender.track===t?r=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(r=e.rtpReceiver)})),!r)throw ee("InvalidAccessError","Invalid selector.");return r.getStats()}var i=[];return this.transceivers.forEach((function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach((function(t){e[t]&&i.push(e[t].getStats())}))})),Promise.all(i).then((function(e){var t=new Map;return e.forEach((function(e){e.forEach((function(e){t.set(e.id,e)}))})),t}))};["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach((function(t){var r=e[t];if(r&&r.prototype&&r.prototype.getStats){var i=r.prototype.getStats;r.prototype.getStats=function(){return i.apply(this).then((function(e){var t=new Map;return Object.keys(e).forEach((function(r){var i;e[r].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(i=e[r]).type]||i.type,t.set(r,e[r])})),t}))}}}));var s=["createOffer","createAnswer"];return s.forEach((function(e){var t=n.prototype[e];n.prototype[e]=function(){var e=arguments;return"function"==typeof e[0]||"function"==typeof e[1]?t.apply(this,[arguments[2]]).then((function(t){"function"==typeof e[0]&&e[0].apply(null,[t])}),(function(t){"function"==typeof e[1]&&e[1].apply(null,[t])})):t.apply(this,arguments)}})),(s=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach((function(e){var t=n.prototype[e];n.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]||"function"==typeof e[2]?t.apply(this,arguments).then((function(){"function"==typeof e[1]&&e[1].apply(null)}),(function(t){"function"==typeof e[2]&&e[2].apply(null,[t])})):t.apply(this,arguments)}})),["getStats"].forEach((function(e){var t=n.prototype[e];n.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]?t.apply(this,arguments).then((function(){"function"==typeof e[1]&&e[1].apply(null)})):t.apply(this,arguments)}})),n};function re(e){const t=e&&e.navigator,r=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return r(e).catch((e=>Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString(){return this.name}}}(e))))}}function ie(e){"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)))}function ne(e,t){if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){const t=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(e){t.set.call(this,e);const r=new Event("enabled");r.enabled=e,this.dispatchEvent(r)}})}e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)&&Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);const r=te(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=function(e){let t=!1;return(e=JSON.parse(JSON.stringify(e))).filter((e=>{if(e&&(e.urls||e.url)){let r=e.urls||e.url;e.url&&!e.urls&&A("RTCIceServer.url","RTCIceServer.urls");const i="string"==typeof r;return i&&(r=[r]),r=r.filter((e=>{if(0===e.indexOf("stun:"))return!1;const r=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return r&&!t?(t=!0,!0):r&&!t})),delete e.url,e.urls=i?r[0]:r,!!r.length}}))}(e.iceServers,t.version),N("ICE servers after filtering:",e.iceServers)),new r(e)},e.RTCPeerConnection.prototype=r.prototype}function se(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}var oe=Object.freeze({__proto__:null,shimPeerConnection:ne,shimReplaceTrack:se,shimGetUserMedia:re,shimGetDisplayMedia:ie});function ae(e,t){const r=e&&e.navigator,i=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,i){A("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,i)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){const e=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},t=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(r){return"object"==typeof r&&"object"==typeof r.audio&&(r=JSON.parse(JSON.stringify(r)),e(r.audio,"autoGainControl","mozAutoGainControl"),e(r.audio,"noiseSuppression","mozNoiseSuppression")),t(r)},i&&i.prototype.getSettings){const t=i.prototype.getSettings;i.prototype.getSettings=function(){const r=t.apply(this,arguments);return e(r,"mozAutoGainControl","autoGainControl"),e(r,"mozNoiseSuppression","noiseSuppression"),r}}if(i&&i.prototype.applyConstraints){const t=i.prototype.applyConstraints;i.prototype.applyConstraints=function(r){return"audio"===this.kind&&"object"==typeof r&&(r=JSON.parse(JSON.stringify(r)),e(r,"autoGainControl","mozAutoGainControl"),e(r,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[r])}}}}function ce(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function _e(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=i[t]}));const r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,n,s]=arguments;return i.apply(this,[e||null]).then((e=>{if(t.version<53&&!n)try{e.forEach((e=>{e.type=r[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach(((t,i)=>{e.set(i,Object.assign({},t,{type:r[t.type]||t.type}))}))}return e})).then(n,s)}}function de(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function le(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),b(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function ue(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){A("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function he(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function pe(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],r=e&&"sendEncodings"in e;r&&e.sendEncodings.forEach((e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));const i=t.apply(this,arguments);if(r){const{sender:t}=i,r=t.getParameters();(!("encodings"in r)||1===r.encodings.length&&0===Object.keys(r.encodings[0]).length)&&(r.encodings=e.sendEncodings,t.sendEncodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(r).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return i})}function ge(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function Re(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function me(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}var fe=Object.freeze({__proto__:null,shimOnTrack:ce,shimPeerConnection:_e,shimSenderGetStats:de,shimReceiverGetStats:le,shimRemoveStream:ue,shimRTCDataChannel:he,shimAddTransceiver:pe,shimGetParameters:ge,shimCreateOffer:Re,shimCreateAnswer:me,shimGetUserMedia:ae,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}});function Ee(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((r=>t.call(this,r,e))),e.getVideoTracks().forEach((r=>t.call(this,r,e)))},e.RTCPeerConnection.prototype.addTrack=function(e,...r){return r&&r.forEach((e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const r=e.getTracks();this.getSenders().forEach((e=>{r.includes(e.track)&&this.removeTrack(e)}))})}}function Ie(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach((e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)}))})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const r=new Event("addstream");r.stream=t,e.dispatchEvent(r)}))}),t.apply(e,arguments)}}}function Se(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,r=t.createOffer,i=t.createAnswer,n=t.setLocalDescription,s=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=function(e,t){const i=arguments.length>=2?arguments[2]:arguments[0],n=r.apply(this,[i]);return t?(n.then(e,t),Promise.resolve()):n},t.createAnswer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],n=i.apply(this,[r]);return t?(n.then(e,t),Promise.resolve()):n};let a=function(e,t,r){const i=n.apply(this,[e]);return r?(i.then(t,r),Promise.resolve()):i};t.setLocalDescription=a,a=function(e,t,r){const i=s.apply(this,[e]);return r?(i.then(t,r),Promise.resolve()):i},t.setRemoteDescription=a,a=function(e,t,r){const i=o.apply(this,[e]);return r?(i.then(t,r),Promise.resolve()):i},t.addIceCandidate=a}function Oe(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,r=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>r(Te(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,i){t.mediaDevices.getUserMedia(e).then(r,i)}.bind(t))}function Te(e){return e&&void 0!==e.video?Object.assign({},e,{video:P(e.video)}):e}function Ce(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){const t=[];for(let r=0;r<e.iceServers.length;r++){let i=e.iceServers[r];!i.hasOwnProperty("urls")&&i.hasOwnProperty("url")?(A("RTCIceServer.url","RTCIceServer.urls"),i=JSON.parse(JSON.stringify(i)),i.urls=i.url,delete i.url,t.push(i)):t.push(e.iceServers[r])}e.iceServers=t}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function ve(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function be(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find((e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const r=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveVideo||r||this.addTransceiver("video")}return t.apply(this,arguments)}}function Le(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var ye=Object.freeze({__proto__:null,shimLocalStreamsAPI:Ee,shimRemoteStreamsAPI:Ie,shimCallbacksAPI:Se,shimGetUserMedia:Oe,shimConstraints:Te,shimRTCIceServerUrls:Ce,shimTrackEventTransceiver:ve,shimCreateOfferLegacy:be,shimAudioContext:Le});function Ne(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const r=new t(e),i=z.parseCandidate(e.candidate),n=Object.assign(r,i);return n.toJSON=function(){return{candidate:n.candidate,sdpMid:n.sdpMid,sdpMLineIndex:n.sdpMLineIndex,usernameFragment:n.usernameFragment}},n}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,b(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function Ae(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;const t=z.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=z.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const r=parseInt(t[1],10);return r!=r?-1:r}(arguments[0]),r=function(e){let r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r}(e),i=function(e,r){let i=65536;"firefox"===t.browser&&57===t.version&&(i=65535);const n=z.matchPrefix(e.sdp,"a=max-message-size:");return n.length>0?i=parseInt(n[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(i=2147483637),i}(arguments[0],e);let n;n=0===r&&0===i?Number.POSITIVE_INFINITY:0===r||0===i?Math.max(r,i):Math.min(r,i);const s={};Object.defineProperty(s,"maxMessageSize",{get:()=>n}),this._sctp=s}return r.apply(this,arguments)}}function De(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const r=e.send;e.send=function(){const i=arguments[0],n=i.length||i.size||i.byteLength;if("open"===e.readyState&&t.sctp&&n>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}const r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=r.apply(this,arguments);return t(e,this),e},b(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function Pe(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((e=>{const r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}}))}function Ue(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const r=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==e.trim())).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:r}):t.sdp=r}return r.apply(this,arguments)}}function ke(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var Me=Object.freeze({__proto__:null,shimRTCIceCandidate:Ne,shimMaxMessageSize:Ae,shimSendThrowTypeError:De,shimConnectionState:Pe,removeExtmapAllowMixed:Ue,shimAddIceCandidateNullOrEmpty:ke});const we=function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const r=N,i=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;const{navigator:r}=e;if(r.mozGetUserMedia)t.browser="firefox",t.version=v(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=v(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(r.mediaDevices&&r.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=v(r.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=v(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),n={browserDetails:i,commonShim:Me,extractVersion:v,disableLog:L,disableWarnings:y};switch(i.browser){case"chrome":if(!$||!H||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),n;if(null===i.version)return r("Chrome shim can not determine version, not shimming."),n;r("adapter.js shimming chrome."),n.browserShim=$,ke(e,i),w(e,i),B(e),H(e,i),x(e),G(e,i),V(e),j(e),F(e),K(e,i),Ne(e),Pe(e),Ae(e,i),De(e),Ue(e,i);break;case"firefox":if(!fe||!_e||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),n;r("adapter.js shimming firefox."),n.browserShim=fe,ke(e,i),ae(e,i),_e(e,i),ce(e),ue(e),de(e),le(e),he(e),pe(e),ge(e),Re(e),me(e),Ne(e),Pe(e),Ae(e,i),De(e);break;case"edge":if(!oe||!ne||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),n;r("adapter.js shimming edge."),n.browserShim=oe,re(e),ie(e),ne(e,i),se(e),Ae(e,i),De(e);break;case"safari":if(!ye||!t.shimSafari)return r("Safari shim is not included in this adapter release."),n;r("adapter.js shimming safari."),n.browserShim=ye,ke(e,i),Ce(e),be(e),Se(e),Ee(e),Ie(e),ve(e),Oe(e),Le(e),Ne(e),Ae(e,i),De(e),Ue(e,i);break;default:r("Unsupported browser!")}return n}({window:"undefined"==typeof window?void 0:window});var Be,xe,Ve;!function(e){e.FPS_10="FPS_10",e.FPS_15="FPS_15",e.FPS_24="FPS_24",e.FPS_30="FPS_30"}(Be||(Be={})),function(e){e.W176_H132="W176_H132",e.W176_H144="W176_H144",e.W180_H180="W180_H180",e.W240_H180="W240_H180",e.W240_H240="W240_H240",e.W256_H144="W256_H144",e.W320_H180="W320_H180",e.W320_H240="W320_H240",e.W360_H360="W360_H360",e.W480_H360="W480_H360",e.W480_H480="W480_H480",e.W640_H360="W640_H360",e.W640_H480="W640_H480",e.W720_H480="W720_H480",e.W848_H480="W848_H480",e.W960_H720="W960_H720",e.W1280_H720="W1280_H720",e.W1920_H1080="W1920_H1080",e.W144_H176="W144_H176",e.W144_H256="W144_H256",e.W180_H240="W180_H240",e.W180_H320="W180_H320",e.W240_H320="W240_H320",e.W360_H480="W360_H480",e.W360_H640="W360_H640",e.W480_H640="W480_H640",e.W480_H720="W480_H720",e.W480_H848="W480_H848",e.W720_H1280="W720_H1280",e.W720_H960="W720_H960",e.W1080_H1920="W1080_H1920"}(xe||(xe={})),function(e){e[e.AUDIO_ONLY=0]="AUDIO_ONLY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(Ve||(Ve={}));const je={[xe.W176_H132]:{width:176,height:132,maxBitrate:150,minBitrate:80},[xe.W176_H144]:{width:176,height:144,maxBitrate:150,minBitrate:80},[xe.W180_H180]:{width:180,height:180,maxBitrate:200,minBitrate:100},[xe.W240_H180]:{width:240,height:180,maxBitrate:240,minBitrate:120},[xe.W240_H240]:{width:240,height:240,maxBitrate:280,minBitrate:120},[xe.W256_H144]:{width:256,height:144,maxBitrate:240,minBitrate:120},[xe.W320_H180]:{width:320,height:180,maxBitrate:280,minBitrate:120},[xe.W320_H240]:{width:320,height:240,maxBitrate:400,minBitrate:120},[xe.W360_H360]:{width:360,height:360,maxBitrate:520,minBitrate:140},[xe.W480_H360]:{width:480,height:360,maxBitrate:650,minBitrate:150},[xe.W480_H480]:{width:480,height:480,maxBitrate:800,minBitrate:180},[xe.W640_H360]:{width:640,height:360,maxBitrate:800,minBitrate:180},[xe.W640_H480]:{width:640,height:480,maxBitrate:900,minBitrate:200},[xe.W720_H480]:{width:720,height:480,maxBitrate:1e3,minBitrate:200},[xe.W848_H480]:{width:848,height:480,maxBitrate:1860,minBitrate:200},[xe.W960_H720]:{width:960,height:720,maxBitrate:2e3,minBitrate:250},[xe.W1280_H720]:{width:1280,height:720,maxBitrate:2200,minBitrate:250},[xe.W1920_H1080]:{width:1920,height:1080,maxBitrate:4e3,minBitrate:400},[xe.W144_H176]:{width:144,height:176,maxBitrate:150,minBitrate:80},[xe.W144_H256]:{width:144,height:256,maxBitrate:240,minBitrate:120},[xe.W180_H240]:{width:180,height:240,maxBitrate:240,minBitrate:120},[xe.W180_H320]:{width:180,height:320,maxBitrate:280,minBitrate:120},[xe.W240_H320]:{width:240,height:320,maxBitrate:400,minBitrate:120},[xe.W360_H480]:{width:360,height:480,maxBitrate:650,minBitrate:150},[xe.W360_H640]:{width:360,height:640,maxBitrate:800,minBitrate:180},[xe.W480_H640]:{width:480,height:640,maxBitrate:900,minBitrate:200},[xe.W480_H720]:{width:480,height:720,maxBitrate:1e3,minBitrate:200},[xe.W480_H848]:{width:480,height:848,maxBitrate:1860,minBitrate:930},[xe.W720_H1280]:{width:720,height:1280,maxBitrate:2200,minBitrate:250},[xe.W720_H960]:{width:720,height:960,maxBitrate:2760,minBitrate:910},[xe.W1080_H1920]:{width:1080,height:1920,maxBitrate:4e3,minBitrate:400}},Fe=e=>{const t={192:180,368:360,1088:1080};return t[e]?t[e]:e},Je=(e,t)=>{e=Fe(e),t=Fe(t);const r=je[`W${e}_H${t}`];if(r)return r;const i=e*t;return Object.keys(je).map((e=>je[e])).sort(((e,t)=>e.height*e.width-t.width*t.height)).filter((e=>e.height*e.width>=i))[0]||je.W1920_H1080},Ge={10:1,15:1,24:1.5,30:1.5},He=e=>{let t=Number.MAX_VALUE,r=1;for(const i in Ge){const n=Math.abs(e-parseInt(i));n<t&&(t=n,r=Ge[i])}return r},Ke={getCameras:()=>E(void 0,void 0,void 0,(function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter((e=>"videoinput"===e.kind))})),getMicrophones:()=>E(void 0,void 0,void 0,(function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter((e=>"audioinput"===e.kind))})),getSpeakers:()=>E(void 0,void 0,void 0,(function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter((e=>"audiooutput"===e.kind))}))};var $e,We;!function(e){e.AUDIO="audio",e.VIDEO="video"}($e||($e={}));class Ye extends e{constructor(e,t,r,i,n,s){super(),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_tag",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_userId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_kind",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_isLocalTrack",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_localMuted",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_remoteMuted",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_streamId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_msTrack",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_msStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"DataTrackId",{enumerable:!0,configurable:!0,writable:!0,value:"data-track-id"}),Object.defineProperty(this,"_element",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._streamId=[this._userId||this._roomId,this._tag].join("_"),this._id=[this._streamId,this.isAudioTrack()?0:1].join("_")}getStreamId(){return this._streamId}getTrackId(){return this._id}getUserId(){return this._userId}__innerGetMediaStreamTrack(){return this._msTrack}get streamTrack(){return this._msTrack}getTag(){return this._tag}isLocalTrack(){return this._isLocalTrack}isVideoTrack(){return"video"===this._kind}isAudioTrack(){return"audio"===this._kind}isReady(){var e;return"live"===(null===(e=this._msTrack)||void 0===e?void 0:e.readyState)}__innerSetMediaStreamTrack(e){this._msTrack=e,this._setLocalMuted(this._localMuted);const t=this._msStream=this._msStream||new MediaStream,r=t.getTracks()[0];r&&t.removeTrack(r),this._isLocalTrack||this._logger.warn(S.L_INNER_SET_TRACK_O,`trackId: ${this._id}, track: ${e?e.id:"undefined"}`),e?t.addTrack(e):this._element&&this._element.getAttribute(this.DataTrackId)===this.getTrackId()&&(this._element.pause(),this._element.srcObject=null)}_setLocalMuted(e){return E(this,void 0,void 0,(function*(){return this._msTrack&&(this._msTrack.enabled=!e),this._localMuted=e,I.SUCCESS}))}mute(){return E(this,void 0,void 0,(function*(){return this._setLocalMuted(!0)}))}unmute(){return E(this,void 0,void 0,(function*(){return this._setLocalMuted(!1)}))}isLocalMuted(){return this._localMuted}isMCUTrack(){return Boolean(this._roomId)}isOwnerMuted(){return this._remoteMuted}_validateVolume(e){if(null==e?void 0:e.volume){if(!t(null==e?void 0:e.volume))return this._logger.error(S.L_TRACK_PLAY_E,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> options.volume not a number"})),{code:I.PARAMS_ERROR};(null==e?void 0:e.volume)<0&&(e.volume=0,this._logger.warn(S.L_TRACK_PLAY_E,JSON.stringify({status:O.FAILED,msg:"params error -> options.volume < 0",tips:"the valid range of options.volume is 0-100, the value of volume has been set 0"}))),(null==e?void 0:e.volume)>100&&(e.volume=100,this._logger.warn(S.L_TRACK_PLAY_E,JSON.stringify({status:O.FAILED,msg:"params error -> options.volume > 100",tips:"the valid range of options.volume is 0-100, the value of volume has been set 100"})))}}_validatePlayOptions(e,t){return E(this,void 0,void 0,(function*(){if(!this._msTrack)return this._logger.error(S.L_TRACK_PLAY_E,JSON.stringify({status:O.FAILED,code:I.TRACK_NOT_READY,kind:this._kind,msg:`the track is not ready to play -> id: ${this._id}`})),{code:I.TRACK_NOT_READY};"ended"===this._msTrack.readyState&&this._logger.warn(S.L_TRACK_PLAY_E,`track readyState is ended -> id: ${this._id}`);const r=this._validateVolume(t);if(r)return r;if(null==t?void 0:t.audioDeviceId){if(!(yield Ke.getSpeakers()).map((e=>e.deviceId)).includes(t.audioDeviceId))return this._logger.error(S.L_TRACK_PLAY_E,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> options.audioDeviceId"})),{code:I.PARAMS_ERROR}}return!this.isVideoTrack()||e&&(e instanceof HTMLVideoElement||this._validateVideoNodeName(e))?void 0:(this._logger.error(S.L_TRACK_PLAY_E,JSON.stringify({status:O.FAILED,code:I.VIDEO_TRACK_MISS_MEDIA_ELEMENT,kind:this._kind,msg:"params element is not a HTMLVideoElement"})),{code:I.VIDEO_TRACK_MISS_MEDIA_ELEMENT})}))}_setPlayAttrs(e,t){var r;return E(this,void 0,void 0,(function*(){e&&(this._element.playsInline=!0,this._element.x5PlaysInline=!0,this._element.webkitPlaysInline=!0),(null==t?void 0:t.audioDeviceId)&&!e&&(yield this._element.setSinkId(t.audioDeviceId)),e||!(null==t?void 0:t.volume)&&0!==(null==t?void 0:t.volume)||(this._element.volume=t.volume/100),null===(r=this._element)||void 0===r||r.setAttribute(this.DataTrackId,this.getTrackId())}))}play(e,t){return E(this,void 0,void 0,(function*(){this._logger.info(S.L_TRACK_PLAY_O,JSON.stringify({elementId:null==e?void 0:e.id,trackId:this._id,kind:this._kind,options:t?{volume:null==t?void 0:t.volume,audioDeviceId:t.audioDeviceId}:void 0}));const r=yield this._validatePlayOptions(e,t);if(r)return r;const i=this.isVideoTrack();return this._element=i?e:this._element||new Audio,this._localMuted&&this._setLocalMuted(!1),this._element.srcObject&&this._element.srcObject===this._msStream||this._element.pause(),this._element.onloadstart=e=>{var t;this._logger.info(S.L_TRACK_LOAD_START_O,JSON.stringify({status:O.INFO,kind:this._kind,msg:`HTMLMediaElement onloadstart -> id: ${null===(t=e.target)||void 0===t?void 0:t.id}, trackId: ${this._id}`}))},this._element.ondurationchange=e=>{var t;this._logger.info(S.L_TRACK_DURATION_CHANGE_O,JSON.stringify({status:O.INFO,kind:this._kind,msg:`HTMLMediaElement ondurationchange -> id: ${null===(t=e.target)||void 0===t?void 0:t.id}, trackId: ${this._id}`}))},this._element.onloadedmetadata=e=>{var t;this._logger.info(S.L_TRACK_LOADED_META_DATA_O,JSON.stringify({status:O.INFO,kind:this._kind,msg:`HTMLMediaElement onloadedmetadata -> id: ${null===(t=e.target)||void 0===t?void 0:t.id}, trackId: ${this._id}`}))},this._element.onloadeddata=e=>{var t;this._logger.info(S.L_TRACK_LOADED_DATA_O,JSON.stringify({status:O.INFO,kind:this._kind,msg:`HTMLMediaElement onloadeddata -> id: ${null===(t=e.target)||void 0===t?void 0:t.id}, trackId: ${this._id}`}))},this._element.onabort=e=>{var t;this._logger.info(S.L_TRACK_ABORT_O,JSON.stringify({status:O.INFO,kind:this._kind,msg:`HTMLMediaElement onabort -> id: ${null===(t=e.target)||void 0===t?void 0:t.id}, trackId: ${this._id}`}))},this._element.oncanplay=e=>E(this,void 0,void 0,(function*(){var r,n;this._logger.info(S.L_TRACK_CANPLAY_O,JSON.stringify({status:O.INFO,kind:this._kind,msg:`HTMLMediaElement oncanplay -> id: ${null===(r=e.target)||void 0===r?void 0:r.id}, trackId: ${this._id}`}));try{(null==t?void 0:t.audioDeviceId)&&!i&&(yield this._element.setSinkId(t.audioDeviceId)),yield null===(n=this._element)||void 0===n?void 0:n.play()}catch(e){if("No permission to use requested device"===e.message)return void this._logger.error(S.L_TRACK_PLAY_E,JSON.stringify({status:O.FAILED,kind:this._kind,code:I.NO_PERMISSION_TO_USE_REQUESTED_DEVICE,msg:`setSinkId failed, error msg: ${e.message}`}));this._logger.error(S.L_TRACK_PLAY_E,JSON.stringify({status:O.FAILED,code:I.TRACK_PLAY_ERROR,kind:this._kind,msg:`play error, error msg: ${e.message}`}))}})),this._element.onvolumechange=e=>{var t,r;const i=Math.floor(100*(null===(t=e.target)||void 0===t?void 0:t.volume));this._logger.info(S.L_TRACK_VOLUME_CHANGE_O,JSON.stringify({status:O.INFO,msg:`HTMLMediaElement onvolumechange -> id: ${null===(r=e.target)||void 0===r?void 0:r.id}, volume: ${i}, trackId: ${this._id}`}))},this._element.srcObject=this._msStream,this._element.autoplay=!0,yield this._setPlayAttrs(i,t),{code:I.SUCCESS}}))}__innerDestroy(){this.__innerSetMediaStreamTrack(void 0)}__releaseMediaElement(){this._element&&this._element.getAttribute(this.DataTrackId)===this.getTrackId()&&(this._element.remove(),this._element.srcObject=null)}_validateVideoNodeName(e){return e&&e.nodeName&&"VIDEO"===e.nodeName.toUpperCase()}}!function(e){e.Speech="Speech",e.Music="Music",e.MusicHigh="MusicHigh"}(We||(We={}));const ze={[We.Music]:{max:64,min:64},[We.MusicHigh]:{max:128,min:128},[We.Speech]:{max:32,min:32}};var qe;!function(e){e.LEVEL0="LEVEL0",e.LEVEL1="LEVEL1",e.LEVEL2="LEVEL2",e.LEVEL3="LEVEL3",e.LEVEL4="LEVEL4",e.LEVEL5="LEVEL5"}(qe||(qe={}));const Qe={[qe.LEVEL0]:{max:150,min:80},[qe.LEVEL1]:{max:280,min:120},[qe.LEVEL2]:{max:650,min:150},[qe.LEVEL3]:{max:1e3,min:200},[qe.LEVEL4]:{max:2200,min:250},[qe.LEVEL5]:{max:4e3,min:400}};class Ze{static apply3ANoiseWorklet(e){return E(this,void 0,void 0,(function*(){const t=new AudioContext({sampleRate:44100});let r;try{yield t.audioWorklet.addModule(Ze.SCRIPT_URL);const e=yield fetch(Ze.WASM_URL,{cache:"force-cache",credentials:"same-origin"});r=yield e.arrayBuffer()}catch(e){return{code:I.LOAD_3A_MODULE_FAILED}}const i=t.createMediaStreamSource(new MediaStream([e])),n=new AudioWorkletNode(t,"process-worklet",{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{binary:r}}),s=t.createMediaStreamDestination();i.connect(n).connect(s);const o=s.stream.getAudioTracks()[0];return Ze._maps.set(e.id,t),{code:I.SUCCESS,track:o}}))}static release3ANoiseWorklet(e){const t=Ze._maps.get(e.id);t&&(t.close(),Ze._maps.delete(e.id))}}Object.defineProperty(Ze,"WASM_URL",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(Ze,"SCRIPT_URL",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(Ze,"_maps",{enumerable:!0,configurable:!0,writable:!0,value:new Map});class Xe extends Ye{constructor(e,t,r,i,n){super(e,t,r,i,!0),Object.defineProperty(this,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_isPublished",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_bitrateInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.__innerSetMediaStreamTrack(n),n.onended=()=>{n.onended=null,this._onTrackEnded()}}_onTrackEnded(){this.emit(Xe.EVENT_LOCAL_TRACK_END,this),this.removeAll(Xe.EVENT_LOCAL_TRACK_END)}_setLocalMuted(e){return new Promise((t=>{const r=this._localMuted!==e;super._setLocalMuted(e),this._remoteMuted=this._localMuted,r&&this._isPublished?this.emit(Xe.__INNER_EVENT_MUTED_CHANGE__,this,t):t(I.SUCCESS),this._logger.info(S.L_LOCAL_TRACK_SET_LOCAL_MUTED_O,JSON.stringify({enable:e,trackId:this._id}))}))}__innerSetPublished(e){this._isPublished=e}isPublished(){return this._isPublished}destroy(){var e;this._isDestroyed||(this._logger.info(S.L_LOCAL_TRACK_DESTROY_O,this._id),this._isDestroyed=!0,null===(e=this._msTrack)||void 0===e||e.stop(),super.__innerDestroy(),this.isAudioTrack()&&super.__releaseMediaElement(),this._isPublished&&this.emit(Xe.__INNER_EVENT_DESTROY__,this))}isDestroyed(){return this._isDestroyed}setBitrate(e=0,r=0,i=0){!t(e)||!t(r)||!t(i)||e<=0||r<=0||e<r?this._logger.error(S.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:O.FAILED,msg:`params error -> max: ${e},min: ${r}, start: ${i}`,trackId:this._id})):(this._logger.info(S.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:O.SUCCESSED,max:e,min:r,start:i,trackId:this._id})),this._bitrateInfo={max:e,min:r,start:i})}getBitrate(){var e,t,r,i,n,s,o;let{min:a,max:c,start:_}={min:0,max:0,start:0};return(null===(e=this._msTrack)||void 0===e?void 0:e.kind)===$e.VIDEO?({min:a,max:c}=mt(this._msTrack)):(null===(t=this._msTrack)||void 0===t?void 0:t.kind)===$e.AUDIO&&({min:a,max:c}={min:32,max:32}),(null===(r=this._bitrateInfo)||void 0===r?void 0:r.max)&&(_=.7*(null===(i=this._bitrateInfo)||void 0===i?void 0:i.max)),{min:(null===(n=this._bitrateInfo)||void 0===n?void 0:n.min)||a,max:(null===(s=this._bitrateInfo)||void 0===s?void 0:s.max)||c,start:(null===(o=this._bitrateInfo)||void 0===o?void 0:o.start)||_}}}Object.defineProperty(Xe,"EVENT_LOCAL_TRACK_END",{enumerable:!0,configurable:!0,writable:!0,value:"local-track-end"}),Object.defineProperty(Xe,"__INNER_EVENT_MUTED_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-muted-change"}),Object.defineProperty(Xe,"__INNER_EVENT_DESTROY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-destroy"});class et extends Xe{constructor(e,t,r,i){super(e,t,r,"audio",i)}setRecommendBitrate(e){if(!r("audioBitrate",e,(e=>e in We)))return void this._logger.warn(S.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:O.FAILED,msg:"params error -> params type is RCAudioBitrate"}));const t=ze[e];this.setBitrate(t.max,t.min,t.start||.7*t.max)}setBitrate(e,...t){const[r=1,i=.7*e||1]=t;super.setBitrate(e,r,i)}}class tt extends Xe{constructor(e,t,r,i,n=!1){super(e,t,r,"video",i),Object.defineProperty(this,"_isTiny",{enumerable:!0,configurable:!0,writable:!0,value:n})}__isTiny(){return this._isTiny}getStreamId(){const e=super.getStreamId();return this._isTiny?`${e}_tiny`:e}getTrackId(){const e=super.getTrackId();return this._isTiny?`${e}_tiny`:e}setRecommendBitrate(e){if(!r("videoBitrate",e,(e=>e in qe)))return void this._logger.warn(S.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:O.FAILED,msg:"params error -> params type is RCVideoBitrate"}));const t=Qe[e];this.setBitrate(t.max,t.min,t.start||.7*t.max)}setBitrate(e,...t){const[r=1,i=.7*e||1]=t;super.setBitrate(e,r,i)}}class rt extends Xe{constructor(e,t,r,i,n,s){super(e,t,r,i,n),Object.defineProperty(this,"_resource",{enumerable:!0,configurable:!0,writable:!0,value:s}),rt._innerSetMapping(this.getTrackId(),s)}static _innerSetMapping(e,t){const r=this._mapping.get(t)||[];r.push(e),this._mapping.set(t,r)}static _innerRemoveMapping(e,t){var r,i;const n=null===(r=this._mapping.get(t))||void 0===r?void 0:r.filter((t=>t!==e));n&&n.length>0?this._mapping.set(t,n):(this._mapping.delete(t),t.pause(),t.src="",null===(i=t.parentNode)||void 0===i||i.removeChild(t))}destroy(){this.isAudioTrack()&&this.mute(),rt._innerRemoveMapping(this.getTrackId(),this._resource),super.destroy()}}Object.defineProperty(rt,"_mapping",{enumerable:!0,configurable:!0,writable:!0,value:new Map});class it extends rt{constructor(e,t,r,i,n){super(e,t,r,"video",i,n)}}class nt extends rt{constructor(e,t,r,i,n){super(e,t,r,"audio",i,n)}_setLocalMuted(e){const t=Object.create(null,{_setLocalMuted:{get:()=>super._setLocalMuted}});return E(this,void 0,void 0,(function*(){return this._resource&&(this._resource.muted=e),t._setLocalMuted.call(this,e)}))}play(){return E(this,void 0,void 0,(function*(){return{code:yield this._setLocalMuted(!1)}}))}}class st extends et{constructor(){super(...arguments),Object.defineProperty(this,"_originTrack",{enumerable:!0,configurable:!0,writable:!0,value:null})}apply3ANoiseWorklet(){return E(this,void 0,void 0,(function*(){if(this._logger.info(S.A_APPLY_3A_NOISE_WORKLET_T),this._originTrack)return this._logger.warn(S.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:O.FAILED,msg:"3A noise module already applied"})),{code:I.SUCCESS};if(!this._msTrack||this.isDestroyed())return this._logger.warn(S.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:O.FAILED,msg:"track not ready"})),{code:I.TRACK_NOT_READY};if(this.isPublished())return this._logger.warn(S.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:O.FAILED,msg:"track already published"})),{code:I.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH};const{code:e,track:t}=yield Ze.apply3ANoiseWorklet(this._msTrack);return e===I.SUCCESS&&t?(this._originTrack=this._msTrack,this._msTrack=t,this._logger.info(S.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:O.SUCCESSED})),{code:I.SUCCESS}):(this._logger.warn(S.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:O.FAILED,msg:`apply 3A noise module failed: ${e}`,SCRIPT_URL:Ze.SCRIPT_URL,WASM_URL:Ze.WASM_URL})),{code:e})}))}__innerSetMediaStreamTrack(e){!e&&this._originTrack&&(Ze.release3ANoiseWorklet(this._originTrack),this._originTrack.stop(),this._originTrack=null),super.__innerSetMediaStreamTrack(e)}}class ot extends tt{}class at extends tt{_onTrackEnded(){super._onTrackEnded(),this.isPublished()&&this.emit(Xe.__INNER_EVENT_DESTROY__,this)}}class ct extends et{_onTrackEnded(){super._onTrackEnded(),this.isPublished()&&this.emit(Xe.__INNER_EVENT_DESTROY__,this)}}class _t extends Ye{constructor(e,t,r,i,n){super(e,t,r,i,!1,n),Object.defineProperty(this,"_isSubscribed",{enumerable:!0,configurable:!0,writable:!0,value:!1})}__innerSetRemoteMuted(e){this._remoteMuted=e}__innerSetSubscribed(e){this._isSubscribed=e}isSubscribed(){return this._isSubscribed}}class dt extends _t{constructor(e,t,r,i){super(e,t,r,"audio",i)}_setLocalMuted(e){const{browser:t,version:r}=yt;return this._element&&r&&/chrome/i.test(t)&&r>=130&&(this._element.muted=e),super._setLocalMuted(e)}getVolume(){var e;return 100*((null===(e=this._element)||void 0===e?void 0:e.volume)||0)}}class lt extends _t{constructor(e,t,r,i){super(e,t,r,"video",i),Object.defineProperty(this,"_isSubTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1})}__innerSetIsTinyTrack(e){this._isSubTiny=e}isSubTiny(){return this._isSubTiny}}const ut=(e,t)=>({name:e,content:JSON.stringify({uris:t,ignore:!0})}),ht=e=>JSON.stringify(e),pt=e=>/^[a-zA-Z\d-=]+$/g.test(e),gt=e=>{if(void 0===e)return 0;if(t(e))return e;const r=e;return r.exact||r.ideal||r.max||0},Rt=e=>{const t=e.getSettings(),r=e.getConstraints();return{width:gt(r.width)||t.width||0,height:gt(r.height)||t.height||0,frameRate:t.frameRate||gt(r.frameRate)}},mt=e=>{const{width:t,height:r,frameRate:i}=Rt(e),n=Je(t||1920,r||1080),s=He(i);return{min:n.minBitrate*s,max:n.maxBitrate*s}},ft=e=>[e.msid,e.mediaType].join("_"),Et=e=>{const t=e.split("_");return{mediaType:parseInt(t.pop()),tag:t.pop(),userId:t.join("_")}},It=(e,t)=>[e,t].join("_"),St=e=>e.map((e=>Object.assign({},e))),Ot=(e,t,r=!1)=>{e=e.slice();const i=[],n=[],s=[];return t.forEach((t=>{const n=ft(t);let o=e.findIndex((e=>ft(e)===n));if(r&&(o=e.findIndex((e=>e.uri===t.uri))),-1===o)return void i.push(t);const a=e[o];a.uri!==t.uri?i.push(t):a.state!==t.state&&s.push(t),e.splice(o,1)})),n.push(...e),{publishedList:i,unpublishedList:n,modifiedList:s}},Tt=()=>{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(""),r=t.length+1;let i=+e;const n=[];do{const e=i%r;i=(i-e)/r,n.unshift(t[e])}while(i);return n.join("")})(e),e.length>22&&(e=e.slice(0,22)),e},Ct=e=>{if(je[e]){const{width:t,height:r}=je[e];return{width:t,height:r}}const[t,r]=e.split("_").map((e=>parseInt(e.replace(/[^\d]/g,""))));return{width:t,height:r}},vt=e=>!!xe[e],bt=e=>!!Be[e],Lt=e=>parseInt(e.replace("FPS_","")),yt=(()=>{const{browser:e,version:t,supportsUnifiedPlan:r}=we.browserDetails;return{browser:e,version:t,supportsUnifiedPlan:!1!==r}})();function Nt(){return"captureStream"in HTMLMediaElement.prototype||"mozCaptureStream"in HTMLMediaElement.prototype}function At(){return"mediaDevices"in navigator&&"getDisplayMedia"in navigator.mediaDevices}const Dt=e=>"[object Null]"===Object.prototype.toString.call(e),Pt=e=>1===e.type,Ut=(e,t,r,i)=>{const n={},s=Object.keys(e.users);return s.length&&s.forEach((s=>{const o=[],a=e.users[s];if(a.extra){const{roomId:e}=JSON.parse(a.extra);if(t!==e)return}if(a.uris)try{o.push(...JSON.parse(a.uris))}catch(e){r.warn(S.L_PARSE_ROOMDATA_URIS_R,`invalid user data -> userId: ${s}, userData: ${a}`,i)}n[s]=o})),n},kt=e=>e instanceof Ye?e.getTrackId():e.track.getTrackId(),Mt=e=>{if(!i(e)||void 0===e.low||void 0===e.high)return e;let{low:t}=e;t<0&&(t+=4294967296),t=t.toString(16);return parseInt(e.high.toString(16)+"00000000".replace(new RegExp(`0{${t.length}}$`),t),16)};var wt,Bt;!function(e){e.PUBLISH="RCRTC:PublishResource",e.UNPUBLISH="RCRTC:UnpublishResource",e.MODIFY="RCRTC:ModifyResource",e.TOTAL_CONTENT_RESOURCE="RCRTC:TotalContentResources",e.STATE="RCRTC:state",e.ROOM_NOTIFY="RCRTC:RoomNtf",e.USER_NOTIFY="RCRTC:UserNtf",e.KICK="RCRTC:kick",e.PK_INVITE="RCRTC:invite",e.PK_INVITE_TIMEOUT="RCRTC:inviteTimeout",e.PK_CANCEL_INVITE="RCRTC:cancelInvite",e.PK_INVITE_ANSWER="RCRTC:answerInvite",e.PK_END="RCRTC:endInvite",e.OTHER_ROOM_OFFLINE="RCRTC:otherRoomOffline",e.ROOM_TASK_FINISH="RCRTC:roomTaskFinish"}(wt||(wt={})),function(e){e.SUCCESS="Success",e.FAIL="Fail"}(Bt||(Bt={}));class xt{constructor(e,t,r,i=5e3){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_roomMode",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_gap",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_latestTimestamp",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFailed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onPingResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_started",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_timer",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._logger=this._context.logger}start(e){this._started||(e<15e3&&(e=15e3),this._logger.info(S.L_PINGER_START_O,JSON.stringify({interval:this._gap,offlineKickTime:e})),this._started=!0,this._checkAlive(e))}_sendPing(){return new Promise((e=>{this._context.rtcPing(this._roomId,this._roomMode).then(e),setTimeout(e,5e3,{code:n.TIMEOUT})}))}_checkAlive(e){return E(this,void 0,void 0,(function*(){const{logger:t}=this._context,r=t.createTraceId(),{code:i,data:s}=yield this._sendPing();if(!this._started)return;const o=Date.now();return i===n.SUCCESS?(this._latestTimestamp=o,this.onPingResult(Bt.SUCCESS,s.version),void(this._timer=setTimeout((()=>this._checkAlive(e)),this._gap))):(t.error(S.L_PINGER_SEND_RTCPING_E,JSON.stringify({roomId:this._roomId,code:i}),r),this.onPingResult(Bt.FAIL),40003===i||o-this._latestTimestamp>e?(this.stop(),void this.onFailed(40003===i)):void(this._timer=setTimeout((()=>this._checkAlive(e)),this._gap)))}))}stop(){this._started&&(this._logger.info(S.L_PINGER_STOP_O),this._started=!1,this._timer&&(clearTimeout(this._timer),this._timer=null))}}
|
|
2
|
+
/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function Vt(e){let t=e.length;for(;--t>=0;)e[t]=0}const jt=256,Ft=286,Jt=30,Gt=15,Ht=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Kt=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),$t=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Wt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Yt=new Array(576);Vt(Yt);const zt=new Array(60);Vt(zt);const qt=new Array(512);Vt(qt);const Qt=new Array(256);Vt(Qt);const Zt=new Array(29);Vt(Zt);const Xt=new Array(Jt);function er(e,t,r,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}let tr,rr,ir;function nr(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Vt(Xt);const sr=e=>e<256?qt[e]:qt[256+(e>>>7)],or=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},ar=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,or(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},cr=(e,t,r)=>{ar(e,r[2*t],r[2*t+1])},_r=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},dr=(e,t,r)=>{const i=new Array(16);let n,s,o=0;for(n=1;n<=Gt;n++)o=o+r[n-1]<<1,i[n]=o;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=_r(i[t]++,t))}},lr=e=>{let t;for(t=0;t<Ft;t++)e.dyn_ltree[2*t]=0;for(t=0;t<Jt;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},ur=e=>{e.bi_valid>8?or(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},hr=(e,t,r,i)=>{const n=2*t,s=2*r;return e[n]<e[s]||e[n]===e[s]&&i[t]<=i[r]},pr=(e,t,r)=>{const i=e.heap[r];let n=r<<1;for(;n<=e.heap_len&&(n<e.heap_len&&hr(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!hr(t,i,e.heap[n],e.depth));)e.heap[r]=e.heap[n],r=n,n<<=1;e.heap[r]=i},gr=(e,t,r)=>{let i,n,s,o,a=0;if(0!==e.sym_next)do{i=255&e.pending_buf[e.sym_buf+a++],i+=(255&e.pending_buf[e.sym_buf+a++])<<8,n=e.pending_buf[e.sym_buf+a++],0===i?cr(e,n,t):(s=Qt[n],cr(e,s+jt+1,t),o=Ht[s],0!==o&&(n-=Zt[s],ar(e,n,o)),i--,s=sr(i),cr(e,s,r),o=Kt[s],0!==o&&(i-=Xt[s],ar(e,i,o)))}while(a<e.sym_next);cr(e,256,t)},Rr=(e,t)=>{const r=t.dyn_tree,i=t.stat_desc.static_tree,n=t.stat_desc.has_stree,s=t.stat_desc.elems;let o,a,c,_=-1;for(e.heap_len=0,e.heap_max=573,o=0;o<s;o++)0!==r[2*o]?(e.heap[++e.heap_len]=_=o,e.depth[o]=0):r[2*o+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=_<2?++_:0,r[2*c]=1,e.depth[c]=0,e.opt_len--,n&&(e.static_len-=i[2*c+1]);for(t.max_code=_,o=e.heap_len>>1;o>=1;o--)pr(e,r,o);c=s;do{o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],pr(e,r,1),a=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=a,r[2*c]=r[2*o]+r[2*a],e.depth[c]=(e.depth[o]>=e.depth[a]?e.depth[o]:e.depth[a])+1,r[2*o+1]=r[2*a+1]=c,e.heap[1]=c++,pr(e,r,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const r=t.dyn_tree,i=t.max_code,n=t.stat_desc.static_tree,s=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,c=t.stat_desc.max_length;let _,d,l,u,h,p,g=0;for(u=0;u<=Gt;u++)e.bl_count[u]=0;for(r[2*e.heap[e.heap_max]+1]=0,_=e.heap_max+1;_<573;_++)d=e.heap[_],u=r[2*r[2*d+1]+1]+1,u>c&&(u=c,g++),r[2*d+1]=u,d>i||(e.bl_count[u]++,h=0,d>=a&&(h=o[d-a]),p=r[2*d],e.opt_len+=p*(u+h),s&&(e.static_len+=p*(n[2*d+1]+h)));if(0!==g){do{for(u=c-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[c]--,g-=2}while(g>0);for(u=c;0!==u;u--)for(d=e.bl_count[u];0!==d;)l=e.heap[--_],l>i||(r[2*l+1]!==u&&(e.opt_len+=(u-r[2*l+1])*r[2*l],r[2*l+1]=u),d--)}})(e,t),dr(r,_,e.bl_count)},mr=(e,t,r)=>{let i,n,s=-1,o=t[1],a=0,c=7,_=4;for(0===o&&(c=138,_=3),t[2*(r+1)+1]=65535,i=0;i<=r;i++)n=o,o=t[2*(i+1)+1],++a<c&&n===o||(a<_?e.bl_tree[2*n]+=a:0!==n?(n!==s&&e.bl_tree[2*n]++,e.bl_tree[32]++):a<=10?e.bl_tree[34]++:e.bl_tree[36]++,a=0,s=n,0===o?(c=138,_=3):n===o?(c=6,_=3):(c=7,_=4))},fr=(e,t,r)=>{let i,n,s=-1,o=t[1],a=0,c=7,_=4;for(0===o&&(c=138,_=3),i=0;i<=r;i++)if(n=o,o=t[2*(i+1)+1],!(++a<c&&n===o)){if(a<_)do{cr(e,n,e.bl_tree)}while(0!=--a);else 0!==n?(n!==s&&(cr(e,n,e.bl_tree),a--),cr(e,16,e.bl_tree),ar(e,a-3,2)):a<=10?(cr(e,17,e.bl_tree),ar(e,a-3,3)):(cr(e,18,e.bl_tree),ar(e,a-11,7));a=0,s=n,0===o?(c=138,_=3):n===o?(c=6,_=3):(c=7,_=4)}};let Er=!1;const Ir=(e,t,r,i)=>{ar(e,0+(i?1:0),3),ur(e),or(e,r),or(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r};var Sr=(e,t,r,i)=>{let n,s,o=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<jt;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),Rr(e,e.l_desc),Rr(e,e.d_desc),o=(e=>{let t;for(mr(e,e.dyn_ltree,e.l_desc.max_code),mr(e,e.dyn_dtree,e.d_desc.max_code),Rr(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Wt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),n=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=n&&(n=s)):n=s=r+5,r+4<=n&&-1!==t?Ir(e,t,r,i):4===e.strategy||s===n?(ar(e,2+(i?1:0),3),gr(e,Yt,zt)):(ar(e,4+(i?1:0),3),((e,t,r,i)=>{let n;for(ar(e,t-257,5),ar(e,r-1,5),ar(e,i-4,4),n=0;n<i;n++)ar(e,e.bl_tree[2*Wt[n]+1],3);fr(e,e.dyn_ltree,t-1),fr(e,e.dyn_dtree,r-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),gr(e,e.dyn_ltree,e.dyn_dtree)),lr(e),i&&ur(e)},Or={_tr_init:e=>{Er||((()=>{let e,t,r,i,n;const s=new Array(16);for(r=0,i=0;i<28;i++)for(Zt[i]=r,e=0;e<1<<Ht[i];e++)Qt[r++]=i;for(Qt[r-1]=i,n=0,i=0;i<16;i++)for(Xt[i]=n,e=0;e<1<<Kt[i];e++)qt[n++]=i;for(n>>=7;i<Jt;i++)for(Xt[i]=n<<7,e=0;e<1<<Kt[i]-7;e++)qt[256+n++]=i;for(t=0;t<=Gt;t++)s[t]=0;for(e=0;e<=143;)Yt[2*e+1]=8,e++,s[8]++;for(;e<=255;)Yt[2*e+1]=9,e++,s[9]++;for(;e<=279;)Yt[2*e+1]=7,e++,s[7]++;for(;e<=287;)Yt[2*e+1]=8,e++,s[8]++;for(dr(Yt,287,s),e=0;e<Jt;e++)zt[2*e+1]=5,zt[2*e]=_r(e,5);tr=new er(Yt,Ht,257,Ft,Gt),rr=new er(zt,Kt,0,Jt,Gt),ir=new er(new Array(0),$t,0,19,7)})(),Er=!0),e.l_desc=new nr(e.dyn_ltree,tr),e.d_desc=new nr(e.dyn_dtree,rr),e.bl_desc=new nr(e.bl_tree,ir),e.bi_buf=0,e.bi_valid=0,lr(e)},_tr_stored_block:Ir,_tr_flush_block:Sr,_tr_tally:(e,t,r)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=r,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(Qt[r]+jt+1)]++,e.dyn_dtree[2*sr(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{ar(e,2,3),cr(e,256,Yt),(e=>{16===e.bi_valid?(or(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Tr=(e,t,r,i)=>{let n=65535&e,s=e>>>16&65535,o=0;for(;0!==r;){o=r>2e3?2e3:r,r-=o;do{n=n+t[i++]|0,s=s+n|0}while(--o);n%=65521,s%=65521}return n|s<<16};const Cr=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t})());var vr=(e,t,r,i)=>{const n=Cr,s=i+r;e^=-1;for(let r=i;r<s;r++)e=e>>>8^n[255&(e^t[r])];return~e},br={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Lr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:yr,_tr_stored_block:Nr,_tr_flush_block:Ar,_tr_tally:Dr,_tr_align:Pr}=Or,{Z_NO_FLUSH:Ur,Z_PARTIAL_FLUSH:kr,Z_FULL_FLUSH:Mr,Z_FINISH:wr,Z_BLOCK:Br,Z_OK:xr,Z_STREAM_END:Vr,Z_STREAM_ERROR:jr,Z_DATA_ERROR:Fr,Z_BUF_ERROR:Jr,Z_DEFAULT_COMPRESSION:Gr,Z_FILTERED:Hr,Z_HUFFMAN_ONLY:Kr,Z_RLE:$r,Z_FIXED:Wr,Z_DEFAULT_STRATEGY:Yr,Z_UNKNOWN:zr,Z_DEFLATED:qr}=Lr,Qr=258,Zr=262,Xr=42,ei=113,ti=666,ri=(e,t)=>(e.msg=br[t],t),ii=e=>2*e-(e>4?9:0),ni=e=>{let t=e.length;for(;--t>=0;)e[t]=0},si=e=>{let t,r,i,n=e.w_size;t=e.hash_size,i=t;do{r=e.head[--i],e.head[i]=r>=n?r-n:0}while(--t);t=n,i=t;do{r=e.prev[--i],e.prev[i]=r>=n?r-n:0}while(--t)};let oi=(e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask;const ai=e=>{const t=e.state;let r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))},ci=(e,t)=>{Ar(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,ai(e.strm)},_i=(e,t)=>{e.pending_buf[e.pending++]=t},di=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},li=(e,t,r,i)=>{let n=e.avail_in;return n>i&&(n=i),0===n?0:(e.avail_in-=n,t.set(e.input.subarray(e.next_in,e.next_in+n),r),1===e.state.wrap?e.adler=Tr(e.adler,t,n,r):2===e.state.wrap&&(e.adler=vr(e.adler,t,n,r)),e.next_in+=n,e.total_in+=n,n)},ui=(e,t)=>{let r,i,n=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match;const c=e.strstart>e.w_size-Zr?e.strstart-(e.w_size-Zr):0,_=e.window,d=e.w_mask,l=e.prev,u=e.strstart+Qr;let h=_[s+o-1],p=_[s+o];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do{if(r=t,_[r+o]===p&&_[r+o-1]===h&&_[r]===_[s]&&_[++r]===_[s+1]){s+=2,r++;do{}while(_[++s]===_[++r]&&_[++s]===_[++r]&&_[++s]===_[++r]&&_[++s]===_[++r]&&_[++s]===_[++r]&&_[++s]===_[++r]&&_[++s]===_[++r]&&_[++s]===_[++r]&&s<u);if(i=Qr-(u-s),s=u-Qr,i>o){if(e.match_start=t,o=i,i>=a)break;h=_[s+o-1],p=_[s+o]}}}while((t=l[t&d])>c&&0!=--n);return o<=e.lookahead?o:e.lookahead},hi=e=>{const t=e.w_size;let r,i,n;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Zr)&&(e.window.set(e.window.subarray(t,t+t-i),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),si(e),i+=t),0===e.strm.avail_in)break;if(r=li(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=3)for(n=e.strstart-e.insert,e.ins_h=e.window[n],e.ins_h=oi(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=oi(e,e.ins_h,e.window[n+3-1]),e.prev[n&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=n,n++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<Zr&&0!==e.strm.avail_in)},pi=(e,t)=>{let r,i,n,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(r=65535,n=e.bi_valid+42>>3,e.strm.avail_out<n)break;if(n=e.strm.avail_out-n,i=e.strstart-e.block_start,r>i+e.strm.avail_in&&(r=i+e.strm.avail_in),r>n&&(r=n),r<s&&(0===r&&t!==wr||t===Ur||r!==i+e.strm.avail_in))break;o=t===wr&&r===i+e.strm.avail_in?1:0,Nr(e,0,0,o),e.pending_buf[e.pending-4]=r,e.pending_buf[e.pending-3]=r>>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,ai(e.strm),i&&(i>r&&(i=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,r-=i),r&&(li(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(0===o);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),o?4:t!==Ur&&t!==wr&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(n=e.window_size-e.strstart,e.strm.avail_in>n&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,n+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),n>e.strm.avail_in&&(n=e.strm.avail_in),n&&(li(e.strm,e.window,e.strstart,n),e.strstart+=n,e.insert+=n>e.w_size-e.insert?e.w_size-e.insert:n),e.high_water<e.strstart&&(e.high_water=e.strstart),n=e.bi_valid+42>>3,n=e.pending_buf_size-n>65535?65535:e.pending_buf_size-n,s=n>e.w_size?e.w_size:n,i=e.strstart-e.block_start,(i>=s||(i||t===wr)&&t!==Ur&&0===e.strm.avail_in&&i<=n)&&(r=i>n?n:i,o=t===wr&&0===e.strm.avail_in&&r===i?1:0,Nr(e,e.block_start,r,o),e.block_start+=r,ai(e.strm)),o?3:1)},gi=(e,t)=>{let r,i;for(;;){if(e.lookahead<Zr){if(hi(e),e.lookahead<Zr&&t===Ur)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=oi(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-Zr&&(e.match_length=ui(e,r)),e.match_length>=3)if(i=Dr(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=oi(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=oi(e,e.ins_h,e.window[e.strstart+1]);else i=Dr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(ci(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===wr?(ci(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ci(e,!1),0===e.strm.avail_out)?1:2},Ri=(e,t)=>{let r,i,n;for(;;){if(e.lookahead<Zr){if(hi(e),e.lookahead<Zr&&t===Ur)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=oi(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-Zr&&(e.match_length=ui(e,r),e.match_length<=5&&(e.strategy===Hr||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-3,i=Dr(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=oi(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,i&&(ci(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Dr(e,0,e.window[e.strstart-1]),i&&ci(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=Dr(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===wr?(ci(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ci(e,!1),0===e.strm.avail_out)?1:2};function mi(e,t,r,i,n){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=i,this.func=n}const fi=[new mi(0,0,0,0,pi),new mi(4,4,8,4,gi),new mi(4,5,16,8,gi),new mi(4,6,32,32,gi),new mi(4,4,16,16,Ri),new mi(8,16,32,32,Ri),new mi(8,16,128,128,Ri),new mi(8,32,128,256,Ri),new mi(32,128,258,1024,Ri),new mi(32,258,258,4096,Ri)];function Ei(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=qr,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),ni(this.dyn_ltree),ni(this.dyn_dtree),ni(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),ni(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ni(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Ii=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Xr&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==ei&&t.status!==ti?1:0},Si=e=>{if(Ii(e))return ri(e,jr);e.total_in=e.total_out=0,e.data_type=zr;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?Xr:ei,e.adler=2===t.wrap?0:1,t.last_flush=-2,yr(t),xr},Oi=e=>{const t=Si(e);var r;return t===xr&&((r=e.state).window_size=2*r.w_size,ni(r.head),r.max_lazy_match=fi[r.level].max_lazy,r.good_match=fi[r.level].good_length,r.nice_match=fi[r.level].nice_length,r.max_chain_length=fi[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=2,r.match_available=0,r.ins_h=0),t},Ti=(e,t,r,i,n,s)=>{if(!e)return jr;let o=1;if(t===Gr&&(t=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),n<1||n>9||r!==qr||i<8||i>15||t<0||t>9||s<0||s>Wr||8===i&&1!==o)return ri(e,jr);8===i&&(i=9);const a=new Ei;return e.state=a,a.strm=e,a.status=Xr,a.wrap=o,a.gzhead=null,a.w_bits=i,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=n+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<n+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=t,a.strategy=s,a.method=r,Oi(e)};var Ci={deflateInit:(e,t)=>Ti(e,t,qr,15,8,Yr),deflateInit2:Ti,deflateReset:Oi,deflateResetKeep:Si,deflateSetHeader:(e,t)=>Ii(e)||2!==e.state.wrap?jr:(e.state.gzhead=t,xr),deflate:(e,t)=>{if(Ii(e)||t>Br||t<0)return e?ri(e,jr):jr;const r=e.state;if(!e.output||0!==e.avail_in&&!e.input||r.status===ti&&t!==wr)return ri(e,0===e.avail_out?Jr:jr);const i=r.last_flush;if(r.last_flush=t,0!==r.pending){if(ai(e),0===e.avail_out)return r.last_flush=-1,xr}else if(0===e.avail_in&&ii(t)<=ii(i)&&t!==wr)return ri(e,Jr);if(r.status===ti&&0!==e.avail_in)return ri(e,Jr);if(r.status===Xr&&0===r.wrap&&(r.status=ei),r.status===Xr){let t=qr+(r.w_bits-8<<4)<<8,i=-1;if(i=r.strategy>=Kr||r.level<2?0:r.level<6?1:6===r.level?2:3,t|=i<<6,0!==r.strstart&&(t|=32),t+=31-t%31,di(r,t),0!==r.strstart&&(di(r,e.adler>>>16),di(r,65535&e.adler)),e.adler=1,r.status=ei,ai(e),0!==r.pending)return r.last_flush=-1,xr}if(57===r.status)if(e.adler=0,_i(r,31),_i(r,139),_i(r,8),r.gzhead)_i(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),_i(r,255&r.gzhead.time),_i(r,r.gzhead.time>>8&255),_i(r,r.gzhead.time>>16&255),_i(r,r.gzhead.time>>24&255),_i(r,9===r.level?2:r.strategy>=Kr||r.level<2?4:0),_i(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(_i(r,255&r.gzhead.extra.length),_i(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=vr(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(_i(r,0),_i(r,0),_i(r,0),_i(r,0),_i(r,0),_i(r,9===r.level?2:r.strategy>=Kr||r.level<2?4:0),_i(r,3),r.status=ei,ai(e),0!==r.pending)return r.last_flush=-1,xr;if(69===r.status){if(r.gzhead.extra){let t=r.pending,i=(65535&r.gzhead.extra.length)-r.gzindex;for(;r.pending+i>r.pending_buf_size;){let n=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+n),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>t&&(e.adler=vr(e.adler,r.pending_buf,r.pending-t,t)),r.gzindex+=n,ai(e),0!==r.pending)return r.last_flush=-1,xr;t=0,i-=n}let n=new Uint8Array(r.gzhead.extra);r.pending_buf.set(n.subarray(r.gzindex,r.gzindex+i),r.pending),r.pending+=i,r.gzhead.hcrc&&r.pending>t&&(e.adler=vr(e.adler,r.pending_buf,r.pending-t,t)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){let t,i=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(e.adler=vr(e.adler,r.pending_buf,r.pending-i,i)),ai(e),0!==r.pending)return r.last_flush=-1,xr;i=0}t=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,_i(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>i&&(e.adler=vr(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){let t,i=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>i&&(e.adler=vr(e.adler,r.pending_buf,r.pending-i,i)),ai(e),0!==r.pending)return r.last_flush=-1,xr;i=0}t=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,_i(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>i&&(e.adler=vr(e.adler,r.pending_buf,r.pending-i,i))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(ai(e),0!==r.pending))return r.last_flush=-1,xr;_i(r,255&e.adler),_i(r,e.adler>>8&255),e.adler=0}if(r.status=ei,ai(e),0!==r.pending)return r.last_flush=-1,xr}if(0!==e.avail_in||0!==r.lookahead||t!==Ur&&r.status!==ti){let i=0===r.level?pi(r,t):r.strategy===Kr?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(hi(e),0===e.lookahead)){if(t===Ur)return 1;break}if(e.match_length=0,r=Dr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(ci(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===wr?(ci(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ci(e,!1),0===e.strm.avail_out)?1:2})(r,t):r.strategy===$r?((e,t)=>{let r,i,n,s;const o=e.window;for(;;){if(e.lookahead<=Qr){if(hi(e),e.lookahead<=Qr&&t===Ur)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=e.strstart-1,i=o[n],i===o[++n]&&i===o[++n]&&i===o[++n])){s=e.strstart+Qr;do{}while(i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&n<s);e.match_length=Qr-(s-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=Dr(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Dr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(ci(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===wr?(ci(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ci(e,!1),0===e.strm.avail_out)?1:2})(r,t):fi[r.level].func(r,t);if(3!==i&&4!==i||(r.status=ti),1===i||3===i)return 0===e.avail_out&&(r.last_flush=-1),xr;if(2===i&&(t===kr?Pr(r):t!==Br&&(Nr(r,0,0,!1),t===Mr&&(ni(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),ai(e),0===e.avail_out))return r.last_flush=-1,xr}return t!==wr?xr:r.wrap<=0?Vr:(2===r.wrap?(_i(r,255&e.adler),_i(r,e.adler>>8&255),_i(r,e.adler>>16&255),_i(r,e.adler>>24&255),_i(r,255&e.total_in),_i(r,e.total_in>>8&255),_i(r,e.total_in>>16&255),_i(r,e.total_in>>24&255)):(di(r,e.adler>>>16),di(r,65535&e.adler)),ai(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?xr:Vr)},deflateEnd:e=>{if(Ii(e))return jr;const t=e.state.status;return e.state=null,t===ei?ri(e,Fr):xr},deflateSetDictionary:(e,t)=>{let r=t.length;if(Ii(e))return jr;const i=e.state,n=i.wrap;if(2===n||1===n&&i.status!==Xr||i.lookahead)return jr;if(1===n&&(e.adler=Tr(e.adler,t,r,0)),i.wrap=0,r>=i.w_size){0===n&&(ni(i.head),i.strstart=0,i.block_start=0,i.insert=0);let e=new Uint8Array(i.w_size);e.set(t.subarray(r-i.w_size,r),0),t=e,r=i.w_size}const s=e.avail_in,o=e.next_in,a=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,hi(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=oi(i,i.ins_h,i.window[e+3-1]),i.prev[e&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=e,e++}while(--t);i.strstart=e,i.lookahead=2,hi(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,e.next_in=o,e.input=a,e.avail_in=s,i.wrap=n,xr},deflateInfo:"pako deflate (from Nodeca project)"};const vi=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var bi=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const t in r)vi(r,t)&&(e[t]=r[t])}}return e},Li=e=>{let t=0;for(let r=0,i=e.length;r<i;r++)t+=e[r].length;const r=new Uint8Array(t);for(let t=0,i=0,n=e.length;t<n;t++){let n=e[t];r.set(n,i),i+=n.length}return r};let yi=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){yi=!1}const Ni=new Uint8Array(256);for(let e=0;e<256;e++)Ni[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Ni[254]=Ni[254]=1;var Ai=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,r,i,n,s,o=e.length,a=0;for(n=0;n<o;n++)r=e.charCodeAt(n),55296==(64512&r)&&n+1<o&&(i=e.charCodeAt(n+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),n++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(a),s=0,n=0;s<a;n++)r=e.charCodeAt(n),55296==(64512&r)&&n+1<o&&(i=e.charCodeAt(n+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),n++)),r<128?t[s++]=r:r<2048?(t[s++]=192|r>>>6,t[s++]=128|63&r):r<65536?(t[s++]=224|r>>>12,t[s++]=128|r>>>6&63,t[s++]=128|63&r):(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63,t[s++]=128|r>>>6&63,t[s++]=128|63&r);return t},Di=(e,t)=>{const r=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let i,n;const s=new Array(2*r);for(n=0,i=0;i<r;){let t=e[i++];if(t<128){s[n++]=t;continue}let o=Ni[t];if(o>4)s[n++]=65533,i+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&i<r;)t=t<<6|63&e[i++],o--;o>1?s[n++]=65533:t<65536?s[n++]=t:(t-=65536,s[n++]=55296|t>>10&1023,s[n++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&yi)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let i=0;i<t;i++)r+=String.fromCharCode(e[i]);return r})(s,n)},Pi=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+Ni[e[r]]>t?r:t};var Ui=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const ki=Object.prototype.toString,{Z_NO_FLUSH:Mi,Z_SYNC_FLUSH:wi,Z_FULL_FLUSH:Bi,Z_FINISH:xi,Z_OK:Vi,Z_STREAM_END:ji,Z_DEFAULT_COMPRESSION:Fi,Z_DEFAULT_STRATEGY:Ji,Z_DEFLATED:Gi}=Lr;function Hi(e){this.options=bi({level:Fi,method:Gi,chunkSize:16384,windowBits:15,memLevel:8,strategy:Ji},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ui,this.strm.avail_out=0;let r=Ci.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Vi)throw new Error(br[r]);if(t.header&&Ci.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Ai(t.dictionary):"[object ArrayBuffer]"===ki.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,r=Ci.deflateSetDictionary(this.strm,e),r!==Vi)throw new Error(br[r]);this._dict_set=!0}}function Ki(e,t){const r=new Hi(t);if(r.push(e,!0),r.err)throw r.msg||br[r.err];return r.result}Hi.prototype.push=function(e,t){const r=this.strm,i=this.options.chunkSize;let n,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?xi:Mi,"string"==typeof e?r.input=Ai(e):"[object ArrayBuffer]"===ki.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),(s===wi||s===Bi)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(n=Ci.deflate(r,s),n===ji)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),n=Ci.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Vi;if(0!==r.avail_out){if(s>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},Hi.prototype.onData=function(e){this.chunks.push(e)},Hi.prototype.onEnd=function(e){e===Vi&&(this.result=Li(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var $i={Deflate:Hi,deflate:Ki,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Ki(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Ki(e,t)},constants:Lr};const Wi=16209;var Yi=function(e,t){let r,i,n,s,o,a,c,_,d,l,u,h,p,g,R,m,f,E,I,S,O,T,C,v;const b=e.state;r=e.next_in,C=e.input,i=r+(e.avail_in-5),n=e.next_out,v=e.output,s=n-(t-e.avail_out),o=n+(e.avail_out-257),a=b.dmax,c=b.wsize,_=b.whave,d=b.wnext,l=b.window,u=b.hold,h=b.bits,p=b.lencode,g=b.distcode,R=(1<<b.lenbits)-1,m=(1<<b.distbits)-1;e:do{h<15&&(u+=C[r++]<<h,h+=8,u+=C[r++]<<h,h+=8),f=p[u&R];t:for(;;){if(E=f>>>24,u>>>=E,h-=E,E=f>>>16&255,0===E)v[n++]=65535&f;else{if(!(16&E)){if(64&E){if(32&E){b.mode=16191;break e}e.msg="invalid literal/length code",b.mode=Wi;break e}f=p[(65535&f)+(u&(1<<E)-1)];continue t}for(I=65535&f,E&=15,E&&(h<E&&(u+=C[r++]<<h,h+=8),I+=u&(1<<E)-1,u>>>=E,h-=E),h<15&&(u+=C[r++]<<h,h+=8,u+=C[r++]<<h,h+=8),f=g[u&m];;){if(E=f>>>24,u>>>=E,h-=E,E=f>>>16&255,16&E){if(S=65535&f,E&=15,h<E&&(u+=C[r++]<<h,h+=8,h<E&&(u+=C[r++]<<h,h+=8)),S+=u&(1<<E)-1,S>a){e.msg="invalid distance too far back",b.mode=Wi;break e}if(u>>>=E,h-=E,E=n-s,S>E){if(E=S-E,E>_&&b.sane){e.msg="invalid distance too far back",b.mode=Wi;break e}if(O=0,T=l,0===d){if(O+=c-E,E<I){I-=E;do{v[n++]=l[O++]}while(--E);O=n-S,T=v}}else if(d<E){if(O+=c+d-E,E-=d,E<I){I-=E;do{v[n++]=l[O++]}while(--E);if(O=0,d<I){E=d,I-=E;do{v[n++]=l[O++]}while(--E);O=n-S,T=v}}}else if(O+=d-E,E<I){I-=E;do{v[n++]=l[O++]}while(--E);O=n-S,T=v}for(;I>2;)v[n++]=T[O++],v[n++]=T[O++],v[n++]=T[O++],I-=3;I&&(v[n++]=T[O++],I>1&&(v[n++]=T[O++]))}else{O=n-S;do{v[n++]=v[O++],v[n++]=v[O++],v[n++]=v[O++],I-=3}while(I>2);I&&(v[n++]=v[O++],I>1&&(v[n++]=v[O++]))}break}if(64&E){e.msg="invalid distance code",b.mode=Wi;break e}f=g[(65535&f)+(u&(1<<E)-1)]}}break}}while(r<i&&n<o);I=h>>3,r-=I,h-=I<<3,u&=(1<<h)-1,e.next_in=r,e.next_out=n,e.avail_in=r<i?i-r+5:5-(r-i),e.avail_out=n<o?o-n+257:257-(n-o),b.hold=u,b.bits=h};const zi=15,qi=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Qi=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Zi=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Xi=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var en=(e,t,r,i,n,s,o,a)=>{const c=a.bits;let _,d,l,u,h,p,g=0,R=0,m=0,f=0,E=0,I=0,S=0,O=0,T=0,C=0,v=null;const b=new Uint16Array(16),L=new Uint16Array(16);let y,N,A,D=null;for(g=0;g<=zi;g++)b[g]=0;for(R=0;R<i;R++)b[t[r+R]]++;for(E=c,f=zi;f>=1&&0===b[f];f--);if(E>f&&(E=f),0===f)return n[s++]=20971520,n[s++]=20971520,a.bits=1,0;for(m=1;m<f&&0===b[m];m++);for(E<m&&(E=m),O=1,g=1;g<=zi;g++)if(O<<=1,O-=b[g],O<0)return-1;if(O>0&&(0===e||1!==f))return-1;for(L[1]=0,g=1;g<zi;g++)L[g+1]=L[g]+b[g];for(R=0;R<i;R++)0!==t[r+R]&&(o[L[t[r+R]]++]=R);if(0===e?(v=D=o,p=20):1===e?(v=qi,D=Qi,p=257):(v=Zi,D=Xi,p=0),C=0,R=0,g=m,h=s,I=E,S=0,l=-1,T=1<<E,u=T-1,1===e&&T>852||2===e&&T>592)return 1;for(;;){y=g-S,o[R]+1<p?(N=0,A=o[R]):o[R]>=p?(N=D[o[R]-p],A=v[o[R]-p]):(N=96,A=0),_=1<<g-S,d=1<<I,m=d;do{d-=_,n[h+(C>>S)+d]=y<<24|N<<16|A}while(0!==d);for(_=1<<g-1;C&_;)_>>=1;if(0!==_?(C&=_-1,C+=_):C=0,R++,0==--b[g]){if(g===f)break;g=t[r+o[R]]}if(g>E&&(C&u)!==l){for(0===S&&(S=E),h+=m,I=g-S,O=1<<I;I+S<f&&(O-=b[I+S],!(O<=0));)I++,O<<=1;if(T+=1<<I,1===e&&T>852||2===e&&T>592)return 1;l=C&u,n[l]=E<<24|I<<16|h-s}}return 0!==C&&(n[h+C]=g-S<<24|64<<16),a.bits=E,0};const{Z_FINISH:tn,Z_BLOCK:rn,Z_TREES:nn,Z_OK:sn,Z_STREAM_END:on,Z_NEED_DICT:an,Z_STREAM_ERROR:cn,Z_DATA_ERROR:_n,Z_MEM_ERROR:dn,Z_BUF_ERROR:ln,Z_DEFLATED:un}=Lr,hn=16180,pn=16190,gn=16191,Rn=16192,mn=16194,fn=16199,En=16200,In=16206,Sn=16209,On=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Tn(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Cn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<hn||t.mode>16211?1:0},vn=e=>{if(Cn(e))return cn;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=hn,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,sn},bn=e=>{if(Cn(e))return cn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,vn(e)},Ln=(e,t)=>{let r;if(Cn(e))return cn;const i=e.state;return t<0?(r=0,t=-t):(r=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?cn:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,bn(e))},yn=(e,t)=>{if(!e)return cn;const r=new Tn;e.state=r,r.strm=e,r.window=null,r.mode=hn;const i=Ln(e,t);return i!==sn&&(e.state=null),i};let Nn,An,Dn=!0;const Pn=e=>{if(Dn){Nn=new Int32Array(512),An=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(en(1,e.lens,0,288,Nn,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;en(2,e.lens,0,32,An,0,e.work,{bits:5}),Dn=!1}e.lencode=Nn,e.lenbits=9,e.distcode=An,e.distbits=5},Un=(e,t,r,i)=>{let n;const s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),i>=s.wsize?(s.window.set(t.subarray(r-s.wsize,r),0),s.wnext=0,s.whave=s.wsize):(n=s.wsize-s.wnext,n>i&&(n=i),s.window.set(t.subarray(r-i,r-i+n),s.wnext),(i-=n)?(s.window.set(t.subarray(r-i,r),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=n))),0};var kn={inflateReset:bn,inflateReset2:Ln,inflateResetKeep:vn,inflateInit:e=>yn(e,15),inflateInit2:yn,inflate:(e,t)=>{let r,i,n,s,o,a,c,_,d,l,u,h,p,g,R,m,f,E,I,S,O,T,C=0;const v=new Uint8Array(4);let b,L;const y=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Cn(e)||!e.output||!e.input&&0!==e.avail_in)return cn;r=e.state,r.mode===gn&&(r.mode=Rn),o=e.next_out,n=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,_=r.hold,d=r.bits,l=a,u=c,T=sn;e:for(;;)switch(r.mode){case hn:if(0===r.wrap){r.mode=Rn;break}for(;d<16;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(2&r.wrap&&35615===_){0===r.wbits&&(r.wbits=15),r.check=0,v[0]=255&_,v[1]=_>>>8&255,r.check=vr(r.check,v,2,0),_=0,d=0,r.mode=16181;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&_)<<8)+(_>>8))%31){e.msg="incorrect header check",r.mode=Sn;break}if((15&_)!==un){e.msg="unknown compression method",r.mode=Sn;break}if(_>>>=4,d-=4,O=8+(15&_),0===r.wbits&&(r.wbits=O),O>15||O>r.wbits){e.msg="invalid window size",r.mode=Sn;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=512&_?16189:gn,_=0,d=0;break;case 16181:for(;d<16;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(r.flags=_,(255&r.flags)!==un){e.msg="unknown compression method",r.mode=Sn;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=Sn;break}r.head&&(r.head.text=_>>8&1),512&r.flags&&4&r.wrap&&(v[0]=255&_,v[1]=_>>>8&255,r.check=vr(r.check,v,2,0)),_=0,d=0,r.mode=16182;case 16182:for(;d<32;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}r.head&&(r.head.time=_),512&r.flags&&4&r.wrap&&(v[0]=255&_,v[1]=_>>>8&255,v[2]=_>>>16&255,v[3]=_>>>24&255,r.check=vr(r.check,v,4,0)),_=0,d=0,r.mode=16183;case 16183:for(;d<16;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}r.head&&(r.head.xflags=255&_,r.head.os=_>>8),512&r.flags&&4&r.wrap&&(v[0]=255&_,v[1]=_>>>8&255,r.check=vr(r.check,v,2,0)),_=0,d=0,r.mode=16184;case 16184:if(1024&r.flags){for(;d<16;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}r.length=_,r.head&&(r.head.extra_len=_),512&r.flags&&4&r.wrap&&(v[0]=255&_,v[1]=_>>>8&255,r.check=vr(r.check,v,2,0)),_=0,d=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(h=r.length,h>a&&(h=a),h&&(r.head&&(O=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(i.subarray(s,s+h),O)),512&r.flags&&4&r.wrap&&(r.check=vr(r.check,i,h,s)),a-=h,s+=h,r.length-=h),r.length))break e;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===a)break e;h=0;do{O=i[s+h++],r.head&&O&&r.length<65536&&(r.head.name+=String.fromCharCode(O))}while(O&&h<a);if(512&r.flags&&4&r.wrap&&(r.check=vr(r.check,i,h,s)),a-=h,s+=h,O)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=16187;case 16187:if(4096&r.flags){if(0===a)break e;h=0;do{O=i[s+h++],r.head&&O&&r.length<65536&&(r.head.comment+=String.fromCharCode(O))}while(O&&h<a);if(512&r.flags&&4&r.wrap&&(r.check=vr(r.check,i,h,s)),a-=h,s+=h,O)break e}else r.head&&(r.head.comment=null);r.mode=16188;case 16188:if(512&r.flags){for(;d<16;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(4&r.wrap&&_!==(65535&r.check)){e.msg="header crc mismatch",r.mode=Sn;break}_=0,d=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=gn;break;case 16189:for(;d<32;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}e.adler=r.check=On(_),_=0,d=0,r.mode=pn;case pn:if(0===r.havedict)return e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,r.hold=_,r.bits=d,an;e.adler=r.check=1,r.mode=gn;case gn:if(t===rn||t===nn)break e;case Rn:if(r.last){_>>>=7&d,d-=7&d,r.mode=In;break}for(;d<3;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}switch(r.last=1&_,_>>>=1,d-=1,3&_){case 0:r.mode=16193;break;case 1:if(Pn(r),r.mode=fn,t===nn){_>>>=2,d-=2;break e}break;case 2:r.mode=16196;break;case 3:e.msg="invalid block type",r.mode=Sn}_>>>=2,d-=2;break;case 16193:for(_>>>=7&d,d-=7&d;d<32;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if((65535&_)!=(_>>>16^65535)){e.msg="invalid stored block lengths",r.mode=Sn;break}if(r.length=65535&_,_=0,d=0,r.mode=mn,t===nn)break e;case mn:r.mode=16195;case 16195:if(h=r.length,h){if(h>a&&(h=a),h>c&&(h=c),0===h)break e;n.set(i.subarray(s,s+h),o),a-=h,s+=h,c-=h,o+=h,r.length-=h;break}r.mode=gn;break;case 16196:for(;d<14;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(r.nlen=257+(31&_),_>>>=5,d-=5,r.ndist=1+(31&_),_>>>=5,d-=5,r.ncode=4+(15&_),_>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Sn;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;d<3;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}r.lens[y[r.have++]]=7&_,_>>>=3,d-=3}for(;r.have<19;)r.lens[y[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,b={bits:r.lenbits},T=en(0,r.lens,0,19,r.lencode,0,r.work,b),r.lenbits=b.bits,T){e.msg="invalid code lengths set",r.mode=Sn;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;C=r.lencode[_&(1<<r.lenbits)-1],R=C>>>24,m=C>>>16&255,f=65535&C,!(R<=d);){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(f<16)_>>>=R,d-=R,r.lens[r.have++]=f;else{if(16===f){for(L=R+2;d<L;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(_>>>=R,d-=R,0===r.have){e.msg="invalid bit length repeat",r.mode=Sn;break}O=r.lens[r.have-1],h=3+(3&_),_>>>=2,d-=2}else if(17===f){for(L=R+3;d<L;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}_>>>=R,d-=R,O=0,h=3+(7&_),_>>>=3,d-=3}else{for(L=R+7;d<L;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}_>>>=R,d-=R,O=0,h=11+(127&_),_>>>=7,d-=7}if(r.have+h>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Sn;break}for(;h--;)r.lens[r.have++]=O}}if(r.mode===Sn)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=Sn;break}if(r.lenbits=9,b={bits:r.lenbits},T=en(1,r.lens,0,r.nlen,r.lencode,0,r.work,b),r.lenbits=b.bits,T){e.msg="invalid literal/lengths set",r.mode=Sn;break}if(r.distbits=6,r.distcode=r.distdyn,b={bits:r.distbits},T=en(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,b),r.distbits=b.bits,T){e.msg="invalid distances set",r.mode=Sn;break}if(r.mode=fn,t===nn)break e;case fn:r.mode=En;case En:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,r.hold=_,r.bits=d,Yi(e,u),o=e.next_out,n=e.output,c=e.avail_out,s=e.next_in,i=e.input,a=e.avail_in,_=r.hold,d=r.bits,r.mode===gn&&(r.back=-1);break}for(r.back=0;C=r.lencode[_&(1<<r.lenbits)-1],R=C>>>24,m=C>>>16&255,f=65535&C,!(R<=d);){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(m&&!(240&m)){for(E=R,I=m,S=f;C=r.lencode[S+((_&(1<<E+I)-1)>>E)],R=C>>>24,m=C>>>16&255,f=65535&C,!(E+R<=d);){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}_>>>=E,d-=E,r.back+=E}if(_>>>=R,d-=R,r.back+=R,r.length=f,0===m){r.mode=16205;break}if(32&m){r.back=-1,r.mode=gn;break}if(64&m){e.msg="invalid literal/length code",r.mode=Sn;break}r.extra=15&m,r.mode=16201;case 16201:if(r.extra){for(L=r.extra;d<L;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}r.length+=_&(1<<r.extra)-1,_>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=16202;case 16202:for(;C=r.distcode[_&(1<<r.distbits)-1],R=C>>>24,m=C>>>16&255,f=65535&C,!(R<=d);){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(!(240&m)){for(E=R,I=m,S=f;C=r.distcode[S+((_&(1<<E+I)-1)>>E)],R=C>>>24,m=C>>>16&255,f=65535&C,!(E+R<=d);){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}_>>>=E,d-=E,r.back+=E}if(_>>>=R,d-=R,r.back+=R,64&m){e.msg="invalid distance code",r.mode=Sn;break}r.offset=f,r.extra=15&m,r.mode=16203;case 16203:if(r.extra){for(L=r.extra;d<L;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}r.offset+=_&(1<<r.extra)-1,_>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Sn;break}r.mode=16204;case 16204:if(0===c)break e;if(h=u-c,r.offset>h){if(h=r.offset-h,h>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Sn;break}h>r.wnext?(h-=r.wnext,p=r.wsize-h):p=r.wnext-h,h>r.length&&(h=r.length),g=r.window}else g=n,p=o-r.offset,h=r.length;h>c&&(h=c),c-=h,r.length-=h;do{n[o++]=g[p++]}while(--h);0===r.length&&(r.mode=En);break;case 16205:if(0===c)break e;n[o++]=r.length,c--,r.mode=En;break;case In:if(r.wrap){for(;d<32;){if(0===a)break e;a--,_|=i[s++]<<d,d+=8}if(u-=c,e.total_out+=u,r.total+=u,4&r.wrap&&u&&(e.adler=r.check=r.flags?vr(r.check,n,u,o-u):Tr(r.check,n,u,o-u)),u=c,4&r.wrap&&(r.flags?_:On(_))!==r.check){e.msg="incorrect data check",r.mode=Sn;break}_=0,d=0}r.mode=16207;case 16207:if(r.wrap&&r.flags){for(;d<32;){if(0===a)break e;a--,_+=i[s++]<<d,d+=8}if(4&r.wrap&&_!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=Sn;break}_=0,d=0}r.mode=16208;case 16208:T=on;break e;case Sn:T=_n;break e;case 16210:return dn;default:return cn}return e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,r.hold=_,r.bits=d,(r.wsize||u!==e.avail_out&&r.mode<Sn&&(r.mode<In||t!==tn))&&Un(e,e.output,e.next_out,u-e.avail_out),l-=e.avail_in,u-=e.avail_out,e.total_in+=l,e.total_out+=u,r.total+=u,4&r.wrap&&u&&(e.adler=r.check=r.flags?vr(r.check,n,u,e.next_out-u):Tr(r.check,n,u,e.next_out-u)),e.data_type=r.bits+(r.last?64:0)+(r.mode===gn?128:0)+(r.mode===fn||r.mode===mn?256:0),(0===l&&0===u||t===tn)&&T===sn&&(T=ln),T},inflateEnd:e=>{if(Cn(e))return cn;let t=e.state;return t.window&&(t.window=null),e.state=null,sn},inflateGetHeader:(e,t)=>{if(Cn(e))return cn;const r=e.state;return 2&r.wrap?(r.head=t,t.done=!1,sn):cn},inflateSetDictionary:(e,t)=>{const r=t.length;let i,n,s;return Cn(e)?cn:(i=e.state,0!==i.wrap&&i.mode!==pn?cn:i.mode===pn&&(n=1,n=Tr(n,t,r,0),n!==i.check)?_n:(s=Un(e,t,r,r),s?(i.mode=16210,dn):(i.havedict=1,sn)))},inflateInfo:"pako inflate (from Nodeca project)"};var Mn=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const wn=Object.prototype.toString,{Z_NO_FLUSH:Bn,Z_FINISH:xn,Z_OK:Vn,Z_STREAM_END:jn,Z_NEED_DICT:Fn,Z_STREAM_ERROR:Jn,Z_DATA_ERROR:Gn,Z_MEM_ERROR:Hn}=Lr;function Kn(e){this.options=bi({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ui,this.strm.avail_out=0;let r=kn.inflateInit2(this.strm,t.windowBits);if(r!==Vn)throw new Error(br[r]);if(this.header=new Mn,kn.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Ai(t.dictionary):"[object ArrayBuffer]"===wn.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=kn.inflateSetDictionary(this.strm,t.dictionary),r!==Vn)))throw new Error(br[r])}Kn.prototype.push=function(e,t){const r=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?xn:Bn,"[object ArrayBuffer]"===wn.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),s=kn.inflate(r,o),s===Fn&&n&&(s=kn.inflateSetDictionary(r,n),s===Vn?s=kn.inflate(r,o):s===Gn&&(s=Fn));r.avail_in>0&&s===jn&&r.state.wrap>0&&0!==e[r.next_in];)kn.inflateReset(r),s=kn.inflate(r,o);switch(s){case Jn:case Gn:case Fn:case Hn:return this.onEnd(s),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||s===jn))if("string"===this.options.to){let e=Pi(r.output,r.next_out),t=r.next_out-e,n=Di(r.output,e);r.next_out=t,r.avail_out=i-t,t&&r.output.set(r.output.subarray(e,e+t),0),this.onData(n)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(s!==Vn||0!==a){if(s===jn)return s=kn.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},Kn.prototype.onData=function(e){this.chunks.push(e)},Kn.prototype.onEnd=function(e){e===Vn&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Li(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};const{Deflate:$n,deflate:Wn,deflateRaw:Yn,gzip:zn}=$i;var qn=zn;const Qn=-1,Zn=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),Xn=(e,t,r)=>E(void 0,void 0,void 0,(function*(){const i=[],n=r.jwt||"";return new Promise(((r,o)=>{e.forEach((e=>E(void 0,void 0,void 0,(function*(){const o=`${e.detectorAddr.replace(/^(https?:\/\/)?/,"https://")}/rtc/detector/ping?t=${a=1e3,c=9999,a+Math.floor(Math.random()*(c-a))}`;var a,c;const _={jwt:n};200===(yield t.httpReq({url:o,body:JSON.stringify(_),timeout:5e3,method:s.POST})).status&&i.push(e.clusterId),r(i)}))))}))})),es=(e,t)=>{var r;if(!t)return"";let i;try{i=JSON.parse(t.voipCallInfo||'{ "strategy": 0 }')}catch(r){return e.warn(S.L_MEDIA_SERVICE_PARSE_NAVI_CALLVOIP_INFO_O,`parse \`voipCallInfo\` of navi failed: ${t.voipCallInfo}`),""}if(0===i.strategy)return"";const n=null===(r=i.callEngine)||void 0===r?void 0:r.filter((e=>4===e.engineType));if(!n||0===n.length)return"";const s=n[0];return s.detectorManager?s.detectorManager:""},ts=()=>({"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:`web|${yt.browser}|${yt.version}`,ClientVersion:"5.28.0","Client-Session-Id":Zn(),"Request-Id":Date.now().toString()});class rs{constructor(e,t,r,i=5e3){Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_msUrl",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_timeout",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_failedMs",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_rtcFinger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clusterId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_configUrl",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_msList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_qualityMsList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._context.logger,t.getConnectionStatus()===o.CONNECTED&&this.isNededDetector()&&this.detectorMediaSever()}isNededDetector(){const e=this._context.getNaviInfo();if(!e)return!1;const t=es(this._logger,e),r=e.jwt||"",i=Date.now();let n=!1;return 0===rs.detectorTime?n=!1:rs.detectValidMinute+rs.detectorTime<i&&(n=!0),!(!t||!r||this._msUrl||n)}detectorMediaSever(){this.clearMSList();const e=this._context.getNaviInfo();this._startDetector(e)}_startDetector(e){return E(this,void 0,void 0,(function*(){const{detectoraddrs:t,clientDetectMinute:r,status:i}=yield((e,t,r)=>E(void 0,void 0,void 0,(function*(){const i=es(t,r);let n=120,o=0;const a={jwt:r.jwt||"",ipType:r.ipType||0},c=yield e.httpReq({url:`${i}/rtc/detector/servers`,body:JSON.stringify(a),headers:{"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:`web|${yt.browser}|${yt.version}`,ClientVersion:"5.28.0","Client-Session-Id":Zn(),"Request-Id":Date.now().toString()},method:s.POST}),_=c.data&&JSON.parse(c.data).detectorAddrs||[];return n=c.data&&JSON.parse(c.data).clientDetectMinute,o=c.data&&JSON.parse(c.data).resultCode,{detectoraddrs:_,clientDetectMinute:n,status:o}})))(this._runtime,this._logger,e);if(i===I.JWT_TIME_OUT){const e=this._context.getPluginContext();return yield e.refetchNaviInfo(),void this.detectorMediaSever()}t.length&&(rs.msInDetector=yield Xn(t,this._runtime,e)),rs.detectorTime=Date.now(),rs.detectValidMinute=60*r*1e3}))}clearMSList(){this._msList.length=0}getMsList(){return this._msUrl?[this._msUrl]:(this._sortMediaServiceList(),[...this._msList])}_sortMediaServiceList(){let e=rs.msInDetector[0];const t=rs.msInDetector.slice(1),r=((e,t)=>{var r;if(!e)return[];let i;try{i=JSON.parse(e.voipCallInfo||'{ "strategy": 0 }')}catch(r){return t.warn(S.L_PARSE_VOIP_SERVER_CONF_E,e.voipCallInfo),[]}if(0===i.strategy)return[];const n=null===(r=i.callEngine)||void 0===r?void 0:r.filter((e=>4===e.engineType));if(!n||0===n.length)return[];const s=n[0],o=[];return s.mediaServer&&o.push(s.mediaServer.replace(/^(https?:\/\/)?/,"https://")),s.backupMediaServer&&s.backupMediaServer.forEach((e=>{o.push(e.replace(/^(https?:\/\/)?/,"https://"))})),o})(this._context.getNaviInfo(),this._logger),i=r[0],n=r.slice(1);const s=[this._clusterId,e,i,...t,...n].filter((e=>!!e)).map((e=>e.replace(/^(https?:\/\/)?/,"https://")));this._msList=[...new Set(s)],this._logger.info(S.L_MEDIA_SERVICE_MSLIST_CHANGE_O,`MediaServiceList msList -> ${JSON.stringify(this._msList)}`)}_openGzip(e,t){const r=JSON.stringify(t),i=r.length,n=new Uint8Array(i);for(let e=0;e<i;e++)n[e]=r.charCodeAt(e);var s;return{headers:e=Object.assign(Object.assign({},e),{"Content-Encoding":"gzip","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}),body:t=qn(n,s)}}_dealRequestSuccessResult(e,t,r){const i=JSON.parse(e);return i.rtcFinger&&(this._rtcFinger=i.rtcFinger),i.clusterId&&(this._clusterId!==i.clusterId&&this.clearMSList(),this._clusterId=i.clusterId),this._logger.info(S.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:O.SUCCESSED,url:t}),r),{code:I.SUCCESS,data:i,qualityMsList:this._qualityMsList}}_request(e,t,r,i,n){var o;return E(this,void 0,void 0,(function*(){this._qualityMsList=[];const a=(null===(o=this._context.getNaviInfo())||void 0===o?void 0:o.openGzip)||!1,{headers:c,body:_}=a?this._openGzip(t,r):{headers:t,body:r},d=this.getMsList();if(0===d.length)return this._logger.error(S.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:O.FAILED,code:I.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"have no valid service address"}),i),{code:I.NOT_OPEN_VIDEO_AUDIO_SERVER};this._rtcFinger&&(_.rtcFinger=this._rtcFinger);for(let t=0;t<d.length;t+=1){const r=Date.now(),o=`${d[t]}${e}`,a=ts(),l=Object.assign(Object.assign({},a),c),u=/x-www-form-urlencoded/.test(l["Content-Type"])?_:JSON.stringify(_),h=a["Request-Id"];this._logger.info(S.L_MEDIA_SERVICE_REQUEST_T,JSON.stringify({url:o,"Request-Id":h}),i);const{status:p,data:g}=yield this._runtime.httpReq({url:o,body:u,headers:l,method:s.POST,timeout:this._timeout});if(n&&this._qualityMsList.push({rsdur:Date.now()-r,rsid:h,rscod:200===p?I.SUCCESS:I.REQUEST_FAILED,msa:o}),200===p)return this._dealRequestSuccessResult(g,o,i);this._logger.error(S.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:O.FAILED,msg:`request error -> Request-Id: ${h}, status: ${p}, url: ${o}`,timeout:this._timeout}),i)}return{code:I.REQUEST_FAILED,qualityMsList:this._qualityMsList}}))}exchange(e,t,r,i){var n;return E(this,void 0,void 0,(function*(){const s=yield this._request("/exchange",e,t,r,i);if(s.code===I.SUCCESS&&(null===(n=s.data)||void 0===n?void 0:n.resultCode)===I.SUCCESS){const{urls:e}=s.data;e&&(this._configUrl=e.configUrl)}return s}))}exit(e){return E(this,void 0,void 0,(function*(){const t=this._logger.createTraceId(),{code:r}=yield this._request("/exit",e,{},t);return r}))}broadcastSubscribe(e,t){const r=this._logger.createTraceId();return this._request("/broadcast/subscribe",e,t,r,!0)}broadcastExit(e){return E(this,void 0,void 0,(function*(){const t=this._logger.createTraceId(),{code:r}=yield this._request("/broadcast/exit",e,{},t,!0);return{code:r}}))}setMcuConfig(e,t){return E(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();if(this._logger.info(S.L_MEDIA_SERVICE_SET_MCU_CONFIG_T,JSON.stringify({body:t}),r),!this._configUrl)return this._logger.error(S.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:O.FAILED,code:I.MCU_SERVER_NOT_FOUND,msg:"MCU server not found"}),r),{code:I.MCU_SERVER_NOT_FOUND};const i=`${this._configUrl.replace(/^(https?:\/\/)?/,"https://")}/server/mcu/config`,n=ts(),o=Object.assign(Object.assign({},n),e),a=JSON.stringify(t),c=n["Request-Id"],{status:_,data:d}=yield this._runtime.httpReq({url:i,headers:o,body:a,method:s.POST});if(200===_){const e=JSON.parse(d),t=e.resultCode;return t===I.SUCCESS?this._logger.info(S.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:O.SUCCESSED,"Request-Id":c}),r):this._logger.warn(S.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({code:t,"Request-Id":c}),r),{code:t,res:e}}return this._logger.error(S.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:O.FAILED,code:I.REQUEST_FAILED,msg:`request error -> Request-Id: ${c}, status: ${_}, url: ${i}`}),r),{code:I.REQUEST_FAILED}}))}getCDNResourceInfo(e,t,r){return E(this,void 0,void 0,(function*(){const i=ts(),n=Object.assign(Object.assign({},i),e),o=i["Request-Id"];this._logger.info(S.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_T,`Request-Id: ${o}, url: ${t}`,r);const{status:a,data:c}=yield this._runtime.httpReq({url:t,headers:n,method:s.GET});if(200===a){const e=JSON.parse(c);return this._logger.info(S.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:O.SUCCESSED,cdnPlayerUrl:null==e?void 0:e.data.pull_url}),r),{code:e.resultCode,res:e}}return this._logger.info(S.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:O.FAILED,code:I.REQUEST_FAILED}),r),{code:I.REQUEST_FAILED}}))}}var is;Object.defineProperty(rs,"msInDetector",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(rs,"detectorTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(rs,"detectValidMinute",{enumerable:!0,configurable:!0,writable:!0,value:72e5}),function(e){e[e.NORMAL=1]="NORMAL",e[e.TINY=2]="TINY"}(is||(is={}));const ns=(e,t)=>Math.round(8*t/e),ss=(e,t=2)=>{const r=10**t;return Math.round(e*r)/r},os=(e,t=2)=>{e>1&&(e=1);const r=10**t;return Math.round(e*r)},as=(e,t,r,i)=>{if(0===t)return 0;if(!r||!i)return ss(e/t,3);const n=t-i;if(0===n)return 0;const s=e-r;return s<0||n<0?0:ss(s/n,3)},cs=e=>{const{jitter:t,rtt:r,packetsLostRate:i}=e;return!Dt(t)||!Dt(r)||0!==i};var _s,ds,ls,us,hs,ps,gs,Rs,ms,fs;!function(e){e.TRACK="track",e.STREAM="stream",e.MEDIASOURCE="media-source",e.INBOUNDRTP="inbound-rtp",e.OUTBOUNDRTP="outbound-rtp",e.REMOTEINBOUNDRTP="remote-inbound-rtp",e.PEERCONNECTION="peer-connection",e.TRANSPORT="transport",e.CERTIFICATE="certificate",e.CANDIDATEPAIR="candidate-pair",e.REMOTECANDIDATE="remote-candidate",e.LOCALCANDIDATE="local-candidate"}(_s||(_s={}));class Es{constructor(e,t,r,i,n,s){Object.defineProperty(this,"_sdpStrategy",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_rtcPeerConn",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_sdpSemantics",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_latestPacketsSent",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_latestBytesSent",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_latestBytesRecv",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_latestPacketsRecv",{enumerable:!0,configurable:!0,writable:!0,value:{}})}getTrackIdByMid(e){return this._sdpStrategy.getTrackIdByMid(e)}updateBytesSent(e,t,r){let i,n;if(this._latestBytesSent[e]&&t<this._latestBytesSent[e].bytesSent&&this.clearLatestpacketsSent([e]),this._latestBytesSent[e]){const{bytesSent:s,timestamp:o}=this._latestBytesSent[e];i=t-s,n=r-o,this._latestBytesSent[e]={bytesSent:t,timestamp:r}}else i=t,n=1e3,this._latestBytesSent[e]={bytesSent:t,timestamp:r};return ns(n,i)}updateBytesRecv(e,t,r){let i,n;if(this._latestBytesRecv[e]&&t<this._latestBytesRecv[e].bytesRecv&&this.clearLatestPacketsRecv([e]),this._latestBytesRecv[e]){const{bytesRecv:s,timestamp:o}=this._latestBytesRecv[e];i=t-s,n=r-o,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r}}else i=t,n=1e3,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r};return ns(n,i)}updateSenderPacketsLost(e,t,r){let i;if(Object.prototype.hasOwnProperty.call(this._latestPacketsSent[e],"packetsSent")){const{packetsLost:n,packetsSent:s}=this._latestPacketsSent[e];i=as(t,r,n,s),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=n===t?s:r}else i=as(t,r),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=r;return i}updateReceiverPacketsLost(e,t,r){let i;if(this._latestPacketsRecv[e]){const{packetsLost:n,packetsRecv:s}=this._latestPacketsRecv[e];i=as(t,r+t,n,s+n)}else i=as(t,r);return this._latestPacketsRecv[e]={packetsLost:t,packetsRecv:r},i}clearLatestpacketsSent(e){e.forEach((e=>{if(parseInt(e.split("_").pop())===Ve.VIDEO_ONLY){const t=`${e}_tiny`;delete this._latestPacketsSent[t],delete this._latestBytesSent[t]}delete this._latestPacketsSent[e],delete this._latestBytesSent[e]}))}clearLatestPacketsRecv(e){e.forEach((e=>{delete this._latestPacketsRecv[e],delete this._latestBytesRecv[e]}))}parseRTCStatsReport(e){const t={};for(const[r,i]of e.entries())/codec/gi.test(i)&&r.includes("RTCCodec_")||(t[r]=i);return t}formatRCRTCStateReport(e){const t={senders:[],receivers:[]};return this._logger.info(S.L_ABSTRACT_STAT_PARSER_FORMAT_RTC_STATE_REPORT_O,JSON.stringify({status:O.SUCCESSED,stats:e,reports:t})),t}isValidTranceiver(e,t){var r,i;const n="outbound-rtp"===t?null===(r=this._rtcPeerConn.currentLocalDescription)||void 0===r?void 0:r.sdp:null===(i=this._rtcPeerConn.currentRemoteDescription)||void 0===i?void 0:i.sdp,{ssrc:s}=e;return!(null==n?void 0:n.split("\r\nm=").some((e=>e.includes(s)&&e.includes("a=inactive"))))}formatStateData(e){return Object.values(e).reduce(((e,t)=>t.type===_s.REMOTEINBOUNDRTP?(e.remoteInbound.push(t),e):t.type===_s.INBOUNDRTP?(e.inbound.push(t),e):t.type===_s.OUTBOUNDRTP?(e.outbound.push(t),e):t.type===_s.TRANSPORT?(e.transport.push(t),e):t.type===_s.PEERCONNECTION?(e.connection.push(t),e):e),{outbound:[],remoteInbound:[],inbound:[],transport:[],connection:[]})}}class Is extends Es{formatRCRTCStateReport(e){const{outbound:t,remoteInbound:r,inbound:i,transport:n,connection:s}=this.formatStateData(e),o={senders:[],receivers:[]},a=Math.floor(s[0].timestamp);o.timestamp=a;let c=0,_=0;({totalPacketsLost:c,bitrateSend:_,senders:o.senders}=this.pickOutbound(t,e,c,a,_)),r.length>0&&o.senders.length>0&&this.pickRemoteInbound(r,o.senders,e);let d=0;if(({totalPacketsLost:c,bitrateRecv:d,receivers:o.receivers}=this.pickInbound(i,e,c,a,d)),n.length>0){const t=n[0];this.pickRtcTransport(t,e,o,d,_,c)}return o}pickRtcTransport(e,t,r,i,n,s){const{selectedCandidatePairId:o}=e;if(o){const e=t[o],{availableOutgoingBitrate:a,availableIncomingBitrate:c,currentRoundTripTime:_,localCandidateId:d,remoteCandidateId:l}=e,u=t[d],{ip:h,port:p,networkType:g}=u,R=t[l],{ip:m,port:f,protocol:E}=R;r.iceCandidatePair={IP:h,port:p,networkType:g,remoteIP:m,remotePort:f,protocol:E,bitrateRecv:i,bitrateSend:n,rtt:1e3*_,availableOutgoingBitrate:a,availableIncomingBitrate:c,totalPacketsLost:s},r.receivers.forEach((e=>{e.rtt=1e3*_}))}}pickRemoteInbound(e,t,r){e.forEach((e=>{var i;const{localId:n,jitter:s,roundTripTime:o,packetsLost:a}=e,c=t.filter((e=>e.id===n))[0];if(c&&!cs(c)){const e=null===(i=this._store)||void 0===i?void 0:i.getTrackIdBySSRC(r[c.id].ssrc);c.jitter=Math.round(1e3*s),c.rtt=o;const t=this._latestPacketsSent[e].crtPacketsSent;c.packetsLostRate=this.updateSenderPacketsLost(e,a,t)}}))}_getOutboundVideoAttrs(e,t,r,i,n){var s,o,a;let{framesPerSecond:c,frameWidth:_,frameHeight:d}=e;return"video"!==r||_||d||c||(_=(null===(s=t[i])||void 0===s?void 0:s.frameWidth)||t[n].width,d=(null===(o=t[i])||void 0===o?void 0:o.frameHeight)||t[n].height,c=(null===(a=t[n])||void 0===a?void 0:a.framesPerSecond)||null),{frameRate:c,frameWidth:_,frameHeight:d}}pickOutbound(e,t,r,i,n){const s=[];return e.forEach((e=>{var o;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"outbound-rtp"))return;const{id:a,kind:c,mediaSourceId:_,remoteId:d,packetsSent:l,bytesSent:u,encoderImplementation:h,pliCount:p,nackCount:g,mid:R}=e;let{trackId:m}=e;if(void 0!==R&&(m=this.getTrackIdByMid(R)),!m)return;const{frameRate:f,frameWidth:E,frameHeight:I}=this._getOutboundVideoAttrs(e,t,c,m,_),S=t[d];let O=null,T=null,C=0;S&&(O=S.jitter,T=S.roundTripTime,C=S.packetsLost),r+=C;const v=null===(o=this._store)||void 0===o?void 0:o.getTrackIdBySSRC(e.ssrc);if(!v)return;const b=_?t[_].audioLevel:t[m].audioLevel;let L=0;!this._latestPacketsSent[v]&&(this._latestPacketsSent[v]={}),S?L=this.updateSenderPacketsLost(v,C,l):this._latestPacketsSent[v].crtPacketsSent=l;let y=this.updateBytesSent(v,u,i);y<0&&(y=0),n+=y,s.push({id:a,trackId:v,kind:c,packetsLostRate:L,remoteResource:!1,audioLevel:b||0===b?os(b):null,frameWidth:E,frameHeight:I,frameRate:f,bitrate:y,jitter:O?Math.round(1e3*O):O,rtt:T?Math.round(1e3*T):T,encoderImplementation:h,pliCount:p,nackCount:g,googFirsSent:Qn,samplingRate:Qn,googRenderDelayMs:Qn,trackState:Qn})})),{totalPacketsLost:r,bitrateSend:n,senders:s}}_getInboundMediaAttrs(e,t,r,i,n){var s,o,a;let{frameWidth:c,frameHeight:_,audioLevel:d}=e;return"video"===n?c||_||(c=(null===(s=t[r])||void 0===s?void 0:s.frameWidth)||t[i].width,_=(null===(o=t[r])||void 0===o?void 0:o.frameHeight)||t[i].height):d||(d=(null===(a=t[r])||void 0===a?void 0:a.audioLevel)||t[i].audioLevel),{frameWidth:c,frameHeight:_,audioLevel:d}}pickInbound(e,t,r,i,n){let s=[];return e.forEach((e=>{var o;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"inbound-rtp"))return;const{packetsLost:a,packetsReceived:c,jitter:_,bytesReceived:d,framesPerSecond:l,kind:u,codecImplementationName:h,nackCount:p,pliCount:g,mid:R,id:m}=e;let{trackId:f}=e;if(void 0!==R&&(f=this.getTrackIdByMid(R)),!f)return;const{frameWidth:E,frameHeight:I,audioLevel:S}=this._getInboundMediaAttrs(e,t,f,m,u);r+=a;const O=null===(o=this._store)||void 0===o?void 0:o.getTrackIdBySSRC(e.ssrc),T=this.updateReceiverPacketsLost(O,a,c);let C=this.updateBytesRecv(O,d,i);C<0&&(C=0),n+=C,s.push({trackId:O,kind:u,packetsLostRate:T,remoteResource:!0,audioLevel:S||0===S?os(S):null,frameWidth:E,frameHeight:I,frameRate:l,bitrate:C,jitter:_?Math.round(1e3*_):0,codecImplementationName:h,nackCount:p,pliCount:g,rtt:null,samplingRate:Qn,googFirsReceived:Qn,googRenderDelayMs:Qn,trackState:Qn})})),{totalPacketsLost:r,bitrateRecv:n,receivers:s}}}class Ss extends Es{constructor(){super(...arguments),Object.defineProperty(this,"_reportsData",{enumerable:!0,configurable:!0,writable:!0,value:{senders:[],receivers:[],timestamp:+new Date}}),Object.defineProperty(this,"_totalPacketsLost",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_bitrateSend",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_bitrateRecv",{enumerable:!0,configurable:!0,writable:!0,value:0})}_pickSenderData(e,t,r){var i;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,r))return;const{kind:n,bytesSent:s,packetsSent:o,bitrateMean:a,framerateMean:c,nackCount:_,pliCount:d,remoteId:l}=e,{jitter:u,roundTripTime:h,packetsLost:p}=l?t[l]:{jitter:null,roundTripTime:null,packetsLost:0},g=null===(i=this._store)||void 0===i?void 0:i.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=p;let R=0;!this._latestPacketsSent[g]&&(this._latestPacketsSent[g]={}),l?R=this.updateSenderPacketsLost(g,p,o):this._latestPacketsSent[g].crtPacketsSent=o;let m=0;"video"===n?a&&(m=Math.floor(a/1e3)):m=this.updateBytesSent(g,s,this._reportsData.timestamp),m<0&&(m=0),this._bitrateSend+=m,this._reportsData.senders.push({trackId:g,kind:n,packetsLostRate:R,remoteResource:!1,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(c),bitrate:m,jitter:u?Math.round(1e3*u):null,rtt:h,encoderImplementation:null,pliCount:d,nackCount:_,googFirsSent:Qn,samplingRate:Qn,googRenderDelayMs:Qn,trackState:Qn})}_addSenderData(e,t){var r;const{localId:i}=t,n=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e[i].ssrc),s=this._reportsData.senders.filter((e=>e.trackId===n))[0];s&&cs(s)&&(s.jitter=Math.round(1e3*t.jitter),s.rtt=t.rtt,s.packetsLostRate=this.updateSenderPacketsLost(n,t.packetsLost,this._latestPacketsSent[n].crtPacketsSent))}_pickReceiverData(e,t){var r;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,t))return;const{packetsLost:i,bytesReceived:n,packetsReceived:s,jitter:o,framerateMean:a,kind:c,bitrateMean:_,nackCount:d,pliCount:l}=e,u=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=i;const h=this.updateReceiverPacketsLost(u,i,s);let p=0;"video"===c?_&&(p=Math.floor(_/1e3)):p=this.updateBytesRecv(u,n,this._reportsData.timestamp),p<0&&(p=0),this._bitrateRecv+=p,this._reportsData.receivers.push({trackId:u,kind:c,packetsLostRate:h,remoteResource:!0,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(a),bitrate:p,jitter:o?Math.round(1e3*o):null,codecImplementationName:null,nackCount:d,pliCount:l,rtt:null,samplingRate:Qn,googFirsReceived:Qn,googRenderDelayMs:Qn,trackState:Qn})}_pickIceCandidatePair(e,t){const r=e[t.localCandidateId],{address:i,port:n}=r,s=e[t.remoteCandidateId],{address:o,port:a,protocol:c}=s;this._reportsData.iceCandidatePair={IP:i,port:n,networkType:null,remoteIP:o,remotePort:a,protocol:c,bitrateRecv:this._bitrateRecv,bitrateSend:this._bitrateSend,rtt:null,availableOutgoingBitrate:null,availableIncomingBitrate:null,totalPacketsLost:this._totalPacketsLost}}formatRCRTCStateReport(e){const t=+new Date;this._reportsData={senders:[],receivers:[],timestamp:t},this._totalPacketsLost=0,this._bitrateRecv=0,this._bitrateSend=0;for(const t in e){const r=e[t],{type:i}=r;"outbound-rtp"===i&&this._pickSenderData(r,e,i),"remote-inbound-rtp"===i&&this._addSenderData(e,r),"inbound-rtp"===i&&this._pickReceiverData(r,i),"candidate-pair"===i&&"succeeded"===r.state&&this._pickIceCandidatePair(e,r)}return this._reportsData}}class Os extends Es{constructor(){super(...arguments),Object.defineProperty(this,"_reportsData",{enumerable:!0,configurable:!0,writable:!0,value:{senders:[],receivers:[],timestamp:+new Date}}),Object.defineProperty(this,"_totalPacketsLost",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_bitrateSend",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_bitrateRecv",{enumerable:!0,configurable:!0,writable:!0,value:0})}_pickReceiverData(e,t){e.forEach((e=>{var t;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"inbound-rtp"))return;const{packetsLost:r,packetsReceived:i,jitter:n,bytesReceived:s,kind:o,nackCount:a,pliCount:c,audioLevel:_,frameHeight:d,frameWidth:l}=e,u=null===(t=this._store)||void 0===t?void 0:t.getTrackIdBySSRC(e.ssrc);if(!u)return;this._totalPacketsLost+=r;const h=this.updateReceiverPacketsLost(u,r,i);let p=this.updateBytesRecv(u,s,this._reportsData.timestamp);p<0&&(p=0),this._bitrateRecv+=p,this._reportsData.receivers.push({trackId:u,kind:o,packetsLostRate:h,remoteResource:!0,audioLevel:_||0===_?os(_):null,frameWidth:l,frameHeight:d,frameRate:null,bitrate:p,jitter:n?Math.round(1e3*n):n,codecImplementationName:null,nackCount:a,pliCount:c,rtt:null,samplingRate:Qn,googFirsReceived:Qn,googRenderDelayMs:Qn,trackState:Qn})}))}_pickSenderData(e,t){e.forEach((e=>{var r;if("unified-plan"===this._sdpSemantics&&!this.isValidTranceiver(e,"outbound-rtp"))return;const i=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e.ssrc),{kind:n,bytesSent:s,pliCount:o,nackCount:a,audioLevel:c,frameHeight:_,frameWidth:d,codecId:l,remoteId:u,packetsSent:h}=e;if(!i)return;const p=t[u];let g=null,R=null,m=0;p&&(g=p.jitter,R=p.roundTripTime,m=p.packetsLost),this._totalPacketsLost+=m;let f=0;!this._latestPacketsSent[i]&&(this._latestPacketsSent[i]={}),p?f=this.updateSenderPacketsLost(i,m,h):this._latestPacketsSent[i].crtPacketsSent=h;let E=this.updateBytesSent(i,s,this._reportsData.timestamp);E<0&&(E=0),this._bitrateSend+=E,this._reportsData.senders.push({trackId:i,kind:n,packetsLostRate:f,remoteResource:!1,audioLevel:c||0===c?os(c):null,frameWidth:d,frameHeight:_,frameRate:null,bitrate:E,jitter:g?Math.round(1e3*g):g,rtt:R?Math.round(1e3*R):R,encoderImplementation:t[l].mimeType,pliCount:o,nackCount:a,googFirsSent:Qn,samplingRate:Qn,googRenderDelayMs:Qn,trackState:Qn})}))}_pickIceCandidatePair(e,t){const{selectedCandidatePairId:r}=e;if(r){const e=t[r],{availableOutgoingBitrate:i,availableIncomingBitrate:n,currentRoundTripTime:s,localCandidateId:o,remoteCandidateId:a}=e,c=t[o],{address:_,port:d}=c,l=t[a],{address:u,port:h,protocol:p}=l;this._reportsData.iceCandidatePair={IP:_||null,port:d,networkType:null,remoteIP:u,remotePort:h,protocol:p,bitrateRecv:this._bitrateRecv,bitrateSend:this._bitrateSend,rtt:1e3*s,availableOutgoingBitrate:i,availableIncomingBitrate:n,totalPacketsLost:this._totalPacketsLost},this._reportsData.receivers.forEach((e=>{e.rtt=1e3*s}))}}formatRCRTCStateReport(e){const{outbound:t,inbound:r,transport:i,connection:n}=this.formatStateData(e);this._reportsData={senders:[],receivers:[]};const s=Math.floor(n[0].timestamp);if(this._reportsData.timestamp=s,this._totalPacketsLost=0,this._bitrateSend=0,this._bitrateRecv=0,this._pickSenderData(t,e),this._pickReceiverData(r,e),i.length>0){const t=i[0];this._pickIceCandidatePair(t,e)}return this._reportsData}}class Ts{constructor(e,t,r){Object.defineProperty(this,"SDP",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"SDPHeader",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"videoStreams",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"audioStreams",{enumerable:!0,configurable:!0,writable:!0,value:[]});const i=this.getStreamIndex();this.spliteStreams(i)}get videoSdps(){return this.videoStreams.slice()}get audioSdps(){return this.audioStreams.slice()}static trimBlankLine(e){return e.replace(/\n\r\s*\r\n/g,"\r\n").replace(/\s+\r\n/g,"\r\n")}getStreamIndex(){const e=/m=(?:video|audio)/gim,t=new Set([0]);let r=e.exec(this.SDP);for(;null!==r;)t.add(null==r?void 0:r.index),r=e.exec(this.SDP);return t.add(this.SDP.length),[...t]}spliteStreams(e){this.SDPHeader=this.SDP.substring(e[0],e[1]).replace(/\r\ns=-/g,`\r\ns=${(new Date).valueOf()}`);for(let t=1;t<e.length;t++){const r=this.SDP.substring(e[t],e[t+1]);/^\bm=video\b/.test(r)?this.videoStreams.push(r):this.audioStreams.push(r)}}static clearInactiveOrRecvonly(e){return/\ba=(recvonly|inactive)\b/.test(e)?e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,""):e}setHeaderBitrate(e){this.SDPHeader=this.SDPHeader.replace(/(\r\ns=[^\r\n]+)/gi,`$1\r\nc=IN IP4 0.0.0.0\r\nb=AS:${e*Ts.KBitrate}\r\nb=TIAS:${e*Ts.KBitrate*850}`)}setAudiosBitrate(e){return this.audioStreams=this.audioStreams.map((t=>this.setAudioItemBitrate(t,e))),this}setAudioBitrateWithStreamId(e,t){return this.audioStreams=this.audioStreams.map((r=>new RegExp(`\\bmsid:${t}\\b`,"ig").test(r)?this.setAudioItemBitrate(r,e):r)),this}setAudioBitrateWithMid(e,t){return this.audioStreams=this.audioStreams.map((r=>new RegExp(`\\bmid:${t}\\b`,"ig").test(r)?this.setAudioItemBitrate(r,e):r)),this}setAudioItemBitrate(e,t){if(0===t.max&&/\ba=inactive\b/gi.test(e))return e;if(!/\bmaxaveragebitrate\b/gi.test(e)){const r=["$1","maxaveragebitrate="+t.max*Ts.KBitrate*1e3];e=e.replace(/(\buseinbandfec=[^\r\n]+)/gi,r.join(";"))}return this.addAudioBlineAS(e,t)}addAudioBlineAS(e,t){return/\bb=AS:\d+\b/gi.test(e)?e:e.replace(/(\bc=IN[^\r\n]+)/gi,`$1\r\nb=AS:${t.max*Ts.KBitrate}\r\nb=TIAS:${t.max*Ts.KBitrate*850}`)}setVideosBitrate(e){return this.videoStreams=this.videoStreams.map((t=>this.setVideoItemBitrate(t,e))),this}setVideoBitrateWithStreamId(e,t){return this.videoStreams=this.videoStreams.map((r=>new RegExp(`\\bmsid:${t}\\b`,"ig").test(r)?this.setVideoItemBitrate(r,e):r)),this}setVideoBitrateWithMid(e,t){return this.videoStreams=this.videoStreams.map((r=>new RegExp(`\\bmid:${t}\\b`,"ig").test(r)?this.setVideoItemBitrate(r,e):r)),this}setVideoItemBitrate(e,t){if(0===t.max&&/\ba=inactive\b/gi.test(e))return e;if(!/\bx-google-max-bitrate\b/.test(e)){const r=["$1","x-google-max-bitrate="+t.max*Ts.KBitrate,"x-google-min-bitrate="+t.min*Ts.KBitrate,`x-google-start-bitrate=${t.start||t.max*Ts.KBitrate*.7}`];e=e.replace(/(\bprofile-level-id=42[e0]01f\b)/gi,r.join(";"))}return this.addVideoBlineAS(e,t)}addVideoBlineAS(e,t){return/\bb=AS:\d+\b/gi.test(e)?e:e.replace(/(\bc=IN[^\r\n]+)/gi,`$1\r\nb=AS:${t.max*Ts.KBitrate}\r\nb=TIAS:${t.max*Ts.KBitrate*850}`)}clearnSsrcWithMid(e,t){return this.audioStreams=this.audioStreams.map((r=>new RegExp(`\\bmid:${e}\\b`,"ig").test(r)?this.clearSSRC(r,t):r)),this.videoStreams=this.videoStreams.map((r=>new RegExp(`\\bmid:${e}\\b`,"ig").test(r)?this.clearSSRC(r,t):r)),this}clearSSRC(e,t){if(t===us.SENDONLY){if(/\ba=sendonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"")}if(t===us.RECVONLY){if(/\ba=recvonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"")}if(t===us.INACTIVE){if(/\ba=inactive\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"")}return e}}Object.defineProperty(Ts,"KBitrate",{enumerable:!0,configurable:!0,writable:!0,value:1});class Cs{static init(e,t){this._audioEncoder=e.encodeAudio,this._audioDecoder=e.decodeAudio,this._videoEncoder=e.encodeVideo,this._videoDecoder=e.decodeVideo,this._logger=t}static isInit(){return!!(this._audioEncoder&&this._audioDecoder&&this._videoEncoder&&this._videoDecoder)}static decodeAudio(e){try{return this._audioDecoder(e)}catch(t){return this._logger.error(S.L_ENCRYPTOR_DECODE_E,null==t?void 0:t.message),console.error(t),e}}static encodeAudio(e){try{return this._audioEncoder(e)}catch(t){return this._logger.error(S.L_ENCRYPTOR_ENCODE_E,null==t?void 0:t.message),console.error(t),e}}static decodeVideo(e){try{return this._videoDecoder(e)}catch(t){return this._logger.error(S.L_ENCRYPTOR_DECODE_E,null==t?void 0:t.message),console.error(t),e}}static encodeVideo(e){try{return this._videoEncoder(e)}catch(t){return this._logger.error(S.L_ENCRYPTOR_ENCODE_E,null==t?void 0:t.message),console.error(t),e}}}!function(e){e[e.NB=0]="NB",e[e.MB=1]="MB",e[e.WB=2]="WB",e[e.SWB=3]="SWB",e[e.FB=4]="FB"}(ds||(ds={})),ds.NB,ds.NB,ds.NB,ds.NB,ds.MB,ds.MB,ds.MB,ds.MB,ds.WB,ds.WB,ds.WB,ds.WB,ds.SWB,ds.SWB,ds.FB,ds.FB,ds.NB,ds.NB,ds.NB,ds.NB,ds.WB,ds.WB,ds.WB,ds.WB,ds.SWB,ds.SWB,ds.SWB,ds.SWB,ds.FB,ds.FB,ds.FB,ds.FB;class vs{static splitSections(e){return e.split("\nm=").map(((e,t)=>`${(t>0?`m=${e}`:e).trim()}\r\n`))}static getMediaSections(e){const t=vs.splitSections(e);return t.shift(),t}static parseExtmap(e){const t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}}static splitLines(e){return e.trim().split("\n").map((e=>e.trim()))}static parseMLine(e){const t=vs.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:parseInt(t[1],10),protocol:t[2],fmt:t.slice(3).join(" ")}}static matchPrefix(e,t){return vs.splitLines(e).filter((e=>0===e.indexOf(t)))}static parseMsid(e){let t;const r=vs.matchPrefix(e,"a=msid:");if(1===r.length)return t=r[0].substr(7).split(" "),{stream:t[0],track:t[1]};const i=vs.matchPrefix(e,"a=ssrc:").map((e=>vs.parseSsrcMedia(e))).filter((e=>"msid"===e.attribute));return i.length>0&&i[0].value?(t=i[0].value.split(" "),{stream:t[0],track:t[1]}):{stream:"",track:""}}static parseSsrcMedia(e){const t=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,t-7),10)},i=e.indexOf(":",t);return i>-1?(r.attribute=e.substr(t+1,i-t-1),r.value=e.substr(i+1)):r.attribute=e.substr(t+1),r}static getMid(e){const t=vs.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)}static splitNaluData(e){const t=new Uint8Array(e);let r=0;if(this.isIFrame(t)){const e=t.join(",");let i=e.indexOf("0,0,0,1,101");-1===i&&(i=e.indexOf("0,0,0,1,37"));r=e.substring(0,i).split(",").length-1+4+8}else r=12;return{header:t.slice(0,r),payloadData:t.slice(r)}}static deal0x03(e,t){let r=[];return r="encode"===t?e.join(",").replaceAll(",0,0,1,",",0,0,3,1,").split(",").map((e=>Number(e))):e.join(",").replaceAll(",0,0,3,1,",",0,0,1,").split(",").map((e=>Number(e))),new Uint8Array(r)}static isIFrame(e){let t=e.join("").startsWith("0001103");return t||(t=e.join("").startsWith("000139")),t}static parsePayloadTypes(e){const t=vs.getMediaSections(e).find((e=>"audio"===vs.parseMLine(e).kind));if(!t)return;const r=t.match(/a=rtpmap:(\d+)\s+(\S+)/g);r&&(vs.payloadTypeCodecMap=r.map((e=>{const t=e.match(/a=rtpmap:(\d+)\s+(\w+)/);return t?{payloadType:Number(t[1]),codec:t[2]}:null})).filter((e=>!!e)))}}Object.defineProperty(vs,"payloadTypeCodecMap",{enumerable:!0,configurable:!0,writable:!0,value:[]}),function(e){e.PLANB="plan-b",e.UNIFIEDPLAN="unified-plan"}(ls||(ls={})),function(e){e.SENDONLY="sendonly",e.RECVONLY="recvonly",e.INACTIVE="inactive"}(us||(us={}));class bs{constructor(e,t,r){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_peer",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_useEncrypt",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_outboundStreams",{enumerable:!0,configurable:!0,writable:!0,value:{}})}static setSdpSemantics(e,t){const{browser:r,version:i,supportsUnifiedPlan:n}=yt;if(t.info(S.L_A_SDP_STRATEGY_SET_SDP_SEMANTICS_O,JSON.stringify({sdpSemantics:e,supportsUnifiedPlan:n,browser:r,version:i})),n)return/chrome/i.test(r)?i?void(this._sdpSemantics=i>92?"unified-plan":i<72?"plan-b":e):void(this._sdpSemantics="unified-plan"):void(/firefox/i.test(r)?this._sdpSemantics="unified-plan":/safari/i.test(r)?this._sdpSemantics=i<12?"plan-b":"unified-plan":this._sdpSemantics="unified-plan");this._sdpSemantics="plan-b"}static getSdpSemantics(){return bs._sdpSemantics}getOutboundVideoInfo(){const e=[];for(const t in this._outboundStreams){const r=this._outboundStreams[t].getVideoTracks()[0];if(!r)continue;const i=/_tiny$/.test(t),{width:n,height:s}=Rt(r);e.push({trackId:r.id,simulcast:i?is.TINY:is.NORMAL,resolution:`${n}x${s}`})}return e}setRemoteAnswer(e){return E(this,void 0,void 0,(function*(){e=Ts.trimBlankLine(e);try{yield this._peer.setRemoteDescription({type:"answer",sdp:e})}catch(e){return this._logger.info(S.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:O.FAILED,msg:e})),I.SET_REMOTE_DESCRIPTION_FAILED}return this._logger.info(S.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:O.SUCCESSED,sdp:e})),I.SUCCESS}))}getStatParsr(e,t,r,i){return/chrome/i.test(yt.browser)?new Is(this,e,this._logger,t,r,i):/Firefox/i.test(yt.browser)?new Ss(this,e,this._logger,t,r,i):/Safari/i.test(yt.browser)?new Os(this,e,this._logger,t,r,i):null}getTrackIdByMid(e){return null}resetSdp(e){return Ts.trimBlankLine(e)}_setupSenderTransform(e){if(!this._useEncrypt)return;const t=e.createEncodedStreams(),{readable:r,writable:i}=t,n=new TransformStream({transform:this._encodeRtpChunk.bind(this,e)});r.pipeThrough(n).pipeTo(i)}_setupReceiverTransform(e){if(!this._useEncrypt)return;const t=e.createEncodedStreams(),{readable:r,writable:i}=t,n=new TransformStream({transform:this._decodeRtpChunk.bind(this,e)});r.pipeThrough(n).pipeTo(i)}_encodeVideoFrame(e){const{header:t,payloadData:r}=vs.splitNaluData(e),i=Cs.encodeVideo(r),n=vs.deal0x03(i,"encode");return new Uint8Array([...t,...n]).buffer}_decodeVideoFrame(e){const{header:t,payloadData:r}=vs.splitNaluData(e),i=vs.deal0x03(r,"decode"),n=Cs.decodeVideo(i);return new Uint8Array([...t,...n]).buffer}_handleAudioREDFrame(e,t){const r=function(e){const t=[];let r=0;for(;;){let i,n,s,o,a=!(e[r]>>7),c=127&e[r];if(a?(i=0,n=e.byteLength-(t.length>0?t.map((e=>4+e.block.byteLength)).reduce(((e,t)=>e+t)):0)-1,s=e.slice(r,r+1),r+=1):(i=(e[r+1]<<6)+(e[r+2]>>2),n=((3&e[r+2])<<8)+e[r+3],s=e.slice(r,r+4),r+=4),o=new Uint8Array(n),t.push({timestampOffset:i,header:s,block:o,isPrimary:a,blockPType:c}),a)break}return t.forEach((t=>{const i=t.block.byteLength,n=e.slice(r,r+i);t.block.set(n),r+=i})),t}(new Uint8Array(e)),i=[],n=[];let s=0;r.forEach((e=>{const r="decode"===t?Cs.decodeAudio(e.block):Cs.encodeAudio(e.block);if(r.byteLength!==e.block.byteLength&&!e.isPrimary){let[,,t,i]=e.header;t=(t>>2<<2)+r.byteLength>>8,i=255&r.byteLength,e.header=new Uint8Array([e.header[0],e.header[1],t,i])}e.block=r,s+=e.block.byteLength+e.header.byteLength,i.push(e.header),n.push(e.block)}));const o=new Uint8Array(s);let a=0;return[...i,...n].forEach((e=>{o.set(e,a),a+=e.byteLength})),o.buffer}_handleOpusFrame(e,t){const r=new Uint8Array(e);return("encode"===t?Cs.encodeAudio(r):Cs.decodeAudio(r)).buffer}_encodeRtpChunk(e,t,r){const i=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._encodeVideoFrame(i);else{const{payloadType:e}=t.getMetadata(),{codec:r}=vs.payloadTypeCodecMap.filter((t=>t.payloadType===e))[0];"red"===r?t.data=this._handleAudioREDFrame(i,"encode"):"opus"===r?t.data=this._handleOpusFrame(i,"encode"):console.error(`Unsupport audio payloadType: ${e}, codec: ${r}`)}r.enqueue(t)}_decodeRtpChunk(e,t,r){const i=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._decodeVideoFrame(i);else{const{payloadType:e}=t.getMetadata(),{codec:r}=vs.payloadTypeCodecMap.filter((t=>t.payloadType===e))[0];"red"===r?t.data=this._handleAudioREDFrame(i,"decode"):"opus"===r?t.data=this._handleOpusFrame(i,"decode"):console.error(`Unsupport audio payloadType: ${e}, codec: ${r}`)}r.enqueue(t)}}class Ls extends Ts{constructor(e,t){super(t,ls.PLANB,e),Object.defineProperty(this,"SDP",{enumerable:!0,configurable:!0,writable:!0,value:t})}stringify(){const e=[this.SDPHeader];[...this.audioStreams,...this.videoStreams].forEach((t=>{const r=t.match(/\ba=mid:(video|audio)\b/),i=Ts.clearInactiveOrRecvonly(t);r&&r[1]===$e.AUDIO&&(e[1]=i),r&&r[1]===$e.VIDEO&&(e[2]=i)}));const t=e.join("");return Ts.trimBlankLine(t)}setAudioBitrateWithStreamId(e,t){return this._logger.warn(S.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Audio Bitrate With Stream Id"),this}setVideoBitrateWithStreamId(e,t){return this._logger.warn(S.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Video Bitrate With Stream Id"),this}}class ys extends bs{constructor(){super(...arguments),Object.defineProperty(this,"senders",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]})}addLocalTrack(e){this._localTracks.every((t=>t.getTrackId()!==e.getTrackId()))&&this._localTracks.push(e);const t=e.getStreamId(),r=e.__innerGetMediaStreamTrack(),i=this._outboundStreams[t]||(this._outboundStreams[t]=new MediaStream);i.getTracks().forEach((e=>{e.kind===r.kind&&i.removeTrack(e)})),i.addTrack(r);const n=e.getTrackId(),s=this.senders[n];s?s.replaceTrack(r):(this.senders[n]=this._peer.addTrack(r,i),Object.defineProperty(r,"trackId",{value:n,writable:!1,enumerable:!1,configurable:!1}))}removeLocalTrack(e){const t=this._localTracks.findIndex((t=>t===e));t>=0&&this._localTracks.splice(t,1);const r=e.getTrackId(),i=this.senders[r];i&&(i.replaceTrack(null),this._peer.removeTrack(i),delete this.senders[r])}updateSubRemoteTracks(e){}updateRecvTransceiverMap(e,t){}setBitrate(e,t,r){}createOffer(e){return E(this,void 0,void 0,(function*(){const t=yield this._peer.createOffer({iceRestart:e,offerToReceiveAudio:!0,offerToReceiveVideo:!0});for(const e in this._outboundStreams){const r=this._outboundStreams[e].id;t.sdp=t.sdp.replace(new RegExp(r,"g"),e)}return t.sdp&&(t.sdp=this.resetSdp(t.sdp)),yield this._peer.setLocalDescription(t),{type:"offer",semantics:"plan-b",sdp:t.sdp}}))}setRemoteAnswer(e){return e=this.resetSdp(e),super.setRemoteAnswer(e)}_getMaxRangeBitrate(e){const t=this._localTracks.filter((t=>e===Ve.AUDIO_ONLY?t.isAudioTrack():t.isVideoTrack())),r={max:0,min:0};return t.forEach((e=>{const{min:t,max:i,start:n}=e.getBitrate();r.max=r.max<i?i:r.max,r.min=r.min>t?t:r.min,r.max===i?r.start=n:r.start=.7*r.max})),r}resetSdp(e){const t=new Ls(this._logger,e),r=this._getMaxRangeBitrate(Ve.VIDEO_ONLY),i=this._getMaxRangeBitrate(Ve.AUDIO_ONLY);return t.setAudiosBitrate(i),t.setVideosBitrate(r),t.stringify()}}class Ns extends Ts{constructor(e,t){super(t,ls.UNIFIEDPLAN,e)}stringify(){const e=[this.SDPHeader];[...this.audioStreams,...this.videoStreams].forEach((t=>{const r=t.match(/\ba=mid:(\d+)\b/);r&&r[1]&&(e[+r[1]+1]=t)})),this.SDPHeader="",this.videoStreams=[],this.audioStreams=[];const t=e.join("");return Ts.trimBlankLine(t)}}class As{constructor(){Object.defineProperty(this,"__streams",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}static getInstance(){return As.instance||(As.instance=new As),As.instance}push(e,t){return this.__streams.set(e,t),t}pickup(e){return this.__streams.get(e)}delete(e){return this.__streams.delete(e)}get streams(){const e=new Map;for(const t of this.__streams.keys())e.set(t,this.pickup(t));return e}}class Ds extends bs{constructor(){super(...arguments),Object.defineProperty(this,"_sendTransceiver",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_localTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_recvAudio",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_recvVideo",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_recvTransceiver",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_subedTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"midMsid",{enumerable:!0,configurable:!0,writable:!0,value:{}})}setBitrate(e,t,r){this._logger.warn(S.L_FUNCTION_IS_UNAVAILABLE,"the interface named `setBitrate` is invalid while sdpSemantics value is `unified-plan`")}getTrackIdByMid(e){for(let t in this._sendTransceiver){if(this._sendTransceiver[t].mid===e)return t}for(let t in this._recvTransceiver){if(this._recvTransceiver[t].mid===e)return t}return null}addLocalTrack(e){var t;const r=e.getTrackId(),i=e.getStreamId(),n=e.__innerGetMediaStreamTrack();this._localTracks[r]=e;const s=this._outboundStreams[i]||(this._outboundStreams[i]=new MediaStream);s.getTracks().forEach((e=>{e.kind===n.kind&&s.removeTrack(e)})),s.addTrack(n);const o=this._sendTransceiver[r];if(o)o.sender.replaceTrack(n),o.direction="sendonly";else{const e=this._sendTransceiver[r]=this._peer.addTransceiver(n,{direction:"sendonly",streams:[s]});this._setupSenderTransform(e.sender)}As.getInstance().push(r,{msid:i,id:this._outboundStreams[i].id,kind:null===(t=e.streamTrack)||void 0===t?void 0:t.kind})}removeLocalTrack(e){const t=e.getTrackId(),r=e.getStreamId();delete this._localTracks[t];const i=this._sendTransceiver[t];if(!i)return;"closed"!==this._peer.connectionState&&(i.direction="inactive",this._peer.removeTrack(i.sender),i.sender.replaceTrack(null));const n=this._outboundStreams[r];(e.isAudioTrack()?n.getAudioTracks():n.getVideoTracks()).forEach((e=>n.removeTrack(e)));const s=this._sendTransceiver[`${t}_tiny`];if(s&&"inactive"!==s.direction&&"closed"!==this._peer.connectionState){s.direction="inactive";const{sender:e}=s,t=e.track;this._peer.removeTrack(e),e.replaceTrack(null);this._outboundStreams[`${r}_tiny`].removeTrack(t),t.stop()}}updateRecvTransceiverMap(e,t){const{mediaType:r}=Et(e);this._recvTransceiver[e]=t;const i=r===Ve.AUDIO_ONLY?this._recvAudio:this._recvVideo,n=i.findIndex((e=>e===t));n>=0&&i.splice(n,1)}updateSubRemoteTracks(e){const t=e.slice(),r=this._subedTracks.slice();this._subedTracks=e.slice();for(let e=t.length-1;e>=0;e-=1){const i=t[e],n=r.findIndex((e=>e===i));n>=0&&(t.splice(e,1),r.splice(n,1))}r.length&&r.forEach((e=>{const t=e.getTrackId();e.__innerSetMediaStreamTrack(void 0);const r=this._recvTransceiver[t];r&&(r.direction="inactive")}));const i={audio:0,video:0};t.length&&t.forEach((e=>{const t=e.isAudioTrack()?"audio":"video",r=this._recvTransceiver[e.getTrackId()];r?r.direction="recvonly":i[t]+=1}));for(let e=this._recvAudio.length;e<i.audio;e+=1){const e=this._peer.addTransceiver("audio",{direction:"recvonly"});this._recvAudio.push(e),this._setupReceiverTransform(e.receiver)}for(let e=this._recvVideo.length;e<i.video;e+=1){const e=this._peer.addTransceiver("video",{direction:"recvonly"});this._recvVideo.push(e),this._setupReceiverTransform(e.receiver)}}createOffer(e){return E(this,void 0,void 0,(function*(){const t=yield this._peer.createOffer({iceRestart:e});let r=t.sdp;for(const e in this._outboundStreams){const t=this._outboundStreams[e].id;r=r.replace(new RegExp(t,"g"),e)}return r=this.resetOfferSdp(r),r=r.replace(/(a=ice-options:trickle)/g,"$1\r\na=ice-options:renomination"),t.sdp=r,yield this._peer.setLocalDescription(t),{type:"offer",semantics:"unified-plan",sdp:r}}))}setRemoteAnswer(e){e=this.resetAnswerSdp(e);const t=/[\r\n]+\r\n[\r\n]+/g;return t.test(e)&&(e=e.replace(t,"\r\n")),super.setRemoteAnswer(e)}_genarateMid(e,t,r){let i=null;return vs.getMediaSections(e).forEach((e=>{vs.parseExtmap(e);const{kind:n}=vs.parseMLine(e);let{stream:s}=vs.parseMsid(e);const o=vs.getMid(e);"video"===r?/tiny$/.test(s)?s=s.replace(/tiny$/gi,"1_tiny"):s+="_1":s+="_0",s===t&&r===n&&o&&(i=o)})),i}_setSenderTransceiverBitrate(e,t,r,i){const n=this._localTracks[t],s=null==n?void 0:n.getBitrate();i===$e.AUDIO&&s&&e.setAudioBitrateWithMid(s,r),i===$e.VIDEO&&s&&e.setVideoBitrateWithMid(s,r)}_resetSenderTransceiver(e,t){var r;for(const i in this._sendTransceiver){const n=this._sendTransceiver[i],s=null===(r=n.sender.track)||void 0===r?void 0:r.kind;let{direction:o,mid:a}=n;a||(a=this._genarateMid(e,i,s)),a&&(o===us.SENDONLY&&this._setSenderTransceiverBitrate(t,i,a,s),o===us.INACTIVE&&t.clearnSsrcWithMid(a,us.INACTIVE))}}_resetRecvTransceiver(e){for(const t in this._recvTransceiver){const r=this._recvTransceiver[t],{direction:i,mid:n}=r;n&&i===us.INACTIVE&&e.clearnSsrcWithMid(n,us.RECVONLY)}}resetOfferSdp(e){const t=new Ns(this._logger,e);return this._resetSenderTransceiver(e,t),this._resetRecvTransceiver(t),t.stringify()}resetAnswerSdp(e){var t;const r=new Ns(this._logger,e);for(const e in this._sendTransceiver){const i=this._sendTransceiver[e],{mid:n}=i;if(n){const s=this._localTracks[e],o=null==s?void 0:s.getBitrate(),a=null===(t=i.sender.track)||void 0===t?void 0:t.kind;a===$e.AUDIO&&o&&r.setAudioBitrateWithMid(o,n),a===$e.VIDEO&&o&&r.setVideoBitrateWithMid(o,n)}}return r.stringify()}}class Ps extends e{constructor(e,t,r,i,n,s=!1,o=!1){super(),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_reTryExchange",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_isRoomAudience",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_rtcPeerConn",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_sdpStrategy",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reportParser",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pubLocalTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_reTryExchangeTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_reportStatsTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_reportR3R4ToPolarisTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_formatStatsData",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_inRetry",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_firstConnectFromPub",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:null});const a=bs.getSdpSemantics(),c="unified-plan"===a&&o&&"function"==typeof RTCRtpSender.prototype.createEncodedStreams&&"function"==typeof RTCRtpReceiver.prototype.createEncodedStreams&&Cs.isInit(),_=this._rtcPeerConn=new RTCPeerConnection({sdpSemantics:a,encodedInsertableStreams:c});this._sdpStrategy="plan-b"===a?new ys(this._logger,_,!1):new Ds(this._logger,_,c),this._rtcPeerConn.oniceconnectionstatechange=this._onICEConnectionStateChange.bind(this),this._rtcPeerConn.onconnectionstatechange=this._onConnectionStateChange.bind(this),this._rtcPeerConn.ontrack=this._onTrackReady.bind(this),this.reportParser=this._sdpStrategy.getStatParsr(this._rtcPeerConn,a,this._currentUserId,this._store)}getLocalTracks(){return Object.values(this.pubLocalTracks)}_onConnectionStateChange(){this._logger.info(S.L_RTC_PEER_CONNECTION_CONNECTION_STATE_S,`state: ${this._rtcPeerConn.connectionState}`)}startAutoExecute(e){this.stopAutoExecute(),this._reportStatsTimer=setTimeout((()=>{this._reportHandle(),this.startAutoExecute(e)}),e)}stopAutoExecute(){clearTimeout(this._reportStatsTimer)}_onICEConnectionStateChange(){var e,t;return E(this,void 0,void 0,(function*(){const{iceConnectionState:r}=this._rtcPeerConn;this._logger.info(S.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_S,JSON.stringify({iceConnectionState:r}));const i=yield this._getStatsData(),n=i?this._createRCRTCStateReport(i).iceCandidatePair:null;this.emit(Ps.__INNER_ICE_STATE_CHANGE__,{status:r,time:Date.now(),iceCandidatePair:n}),"connected"===r?(this.emit(Ps.__INNER_ICE_CONNECTED__,this._firstConnectFromPub),this.startAutoExecute(1e3)):"failed"!==r&&"disconnected"!==r||this._handleRetry();try{null===(t=null===(e=this._reportListener)||void 0===e?void 0:e.onICEConnectionStateChange)||void 0===t||t.call(e,r)}catch(e){this._logger.error(S.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_REPORT_R,JSON.stringify({status:O.FAILED,mag:e}))}}))}_handleRetry(){return E(this,void 0,void 0,(function*(){if(this._inRetry)return;this.clearReTryExchangeTimer(),this._inRetry=!0;const{code:e}=yield this._reTryExchange();this._inRetry=!1,e!==I.SUCCESS&&(this._reTryExchangeTimer=setTimeout((()=>this._handleRetry()),15e3))}))}_onTrackReady(e){if(!e.streams.length)return;const t=e.streams[0].id,{track:r}=e.receiver,i=[t,"audio"===r.kind?Ve.AUDIO_ONLY:Ve.VIDEO_ONLY].join("_");Object.defineProperty(r,"trackId",{value:i,writable:!1,enumerable:!1,configurable:!1}),this._updateRecvTransceiverMap(i,e.transceiver),this.emit(Ps.__INNER_EVENT_TRACK_READY__,e)}setBitrate(e,t,r){return E(this,void 0,void 0,(function*(){this._sdpStrategy.setBitrate(e,t,r),this._logger.info(S.L_RTC_PEER_CONNECTION_SET_BITRATE_O,JSON.stringify({status:O.SUCCESSED,max:e,min:t,start:r}))}))}createOffer(e){return E(this,void 0,void 0,(function*(){const t=yield this._sdpStrategy.createOffer(e);return this._logger.info(S.L_RTC_PEER_CONNECTION_CREATE_OFFER_O,JSON.stringify({offerSDP:t.sdp,sdpDemantics:t.semantics})),t}))}setRemoteAnswer(e,t=!1){var r;return E(this,void 0,void 0,(function*(){return vs.parsePayloadTypes(null===(r=this._rtcPeerConn.localDescription)||void 0===r?void 0:r.sdp),this._firstConnectFromPub=t,this._sdpStrategy.setRemoteAnswer(e)}))}getLocalTrack(e){return this.pubLocalTracks[e]||null}addLocalTrack(e){this.pubLocalTracks[e.getTrackId()]=e,this._sdpStrategy.addLocalTrack(e),e.off(Xe.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(Xe.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.on(Xe.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(Xe.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),this._logger.info(S.L_RTC_PEER_CONNECTION_ADD_LOCAL_TRACK_O,`trackId: ${e.getTrackId()}`)}removeLocalTrackById(e){const t=this.getLocalTrack(e);t?(this._logger.info(S.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:O.SUCCESSED,trackId:e})),this.removeLocalTrack(t)):this._logger.warn(S.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:O.FAILED,msg:"track not found",trackId:e}))}removeAllLocalTrack(){Object.keys(this.pubLocalTracks).forEach((e=>{/_tiny$/.test(e)||this.removeLocalTrackById(e)}))}removeLocalTrack(e){const t=e.getTrackId();delete this.pubLocalTracks[t],this._sdpStrategy.removeLocalTrack(e),e.__innerSetPublished(!1),e.off(Xe.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(Xe.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this);const r=`${t}_tiny`,i=this.getLocalTrack(r);i&&(this._sdpStrategy.removeLocalTrack(i),delete this.pubLocalTracks[r],i.destroy()),this._logger.info(S.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_O,JSON.stringify({trackId:t}))}_updateRecvTransceiverMap(e,t){this._sdpStrategy.updateRecvTransceiverMap(e,t)}updateSubRemoteTracks(e){this._sdpStrategy.updateSubRemoteTracks(e)}getOutboundVideoInfo(){return this._sdpStrategy.getOutboundVideoInfo()}_onLocalTrackMuted(e,t){const r=this.getLocalTrack(`${e.getTrackId()}_tiny`);r&&(r.__innerGetMediaStreamTrack().enabled=!e.isLocalMuted()),this.emit(Xe.__INNER_EVENT_MUTED_CHANGE__,e,t)}_onLocalTrackDestroied(e){this.emit(Xe.__INNER_EVENT_DESTROY__,e)}registerReportListener(e){this._reportListener=e}_createSenderReport(e){return e.filter((e=>e.trackId)).map((e=>{const{trackId:t,kind:r,packetsLostRate:i,remoteResource:n,bitrate:s,jitter:o,rtt:a}=e,c={trackId:t,kind:r,packetsLostRate:i,remoteResource:n,bitrate:s,jitter:o,rtt:a};return(e.audioLevel||0===e.audioLevel)&&(c.audioLevel=e.audioLevel),e.frameWidth&&(c.frameWidth=e.frameWidth),e.frameHeight&&(c.frameHeight=e.frameHeight),e.frameRate&&(c.frameRate=e.frameRate),Object.assign({},c)}))}_createReceiverReport(e){return e.filter((e=>e.trackId)).map((e=>{const{trackId:t,kind:r,packetsLostRate:i,remoteResource:n,bitrate:s,jitter:o,rtt:a}=e,c={trackId:t,kind:r,packetsLostRate:i,remoteResource:n,bitrate:s,jitter:o,rtt:a};return(e.audioLevel||0===e.audioLevel)&&(c.audioLevel=e.audioLevel),e.frameWidth&&(c.frameWidth=e.frameWidth),e.frameHeight&&(c.frameHeight=e.frameHeight),e.frameRate&&(c.frameRate=e.frameRate),Object.assign({},c)}))}_createRCRTCStateReport(e){const{timestamp:t,iceCandidatePair:r,senders:i,receivers:n}=e;(null==r?void 0:r.totalPacketsLost)&&(null==r||delete r.totalPacketsLost);for(const e in r)Dt(r[e])&&delete r[e];return{timestamp:t,iceCandidatePair:r,senders:this._createSenderReport(i),receivers:this._createReceiverReport(n)}}_getStatsData(){var e,t;return E(this,void 0,void 0,(function*(){this._formatStatsData=null;let r=null;const i=yield this._rtcPeerConn.getStats();r=null===(e=this.reportParser)||void 0===e?void 0:e.parseRTCStatsReport(i);const n=null===(t=this.reportParser)||void 0===t?void 0:t.formatRCRTCStateReport(r);return this._formatStatsData=n,n}))}_reportHandle(){var e,t,r,i,n;return E(this,void 0,void 0,(function*(){const s=yield this._getStatsData();if(!s)return;const o=this._createRCRTCStateReport(s);try{null===(t=null===(e=this._reportListener)||void 0===e?void 0:e.onStateReport)||void 0===t||t.call(e,JSON.parse(JSON.stringify(o)))}catch(e){this._logger.error(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}const a=[...s.receivers,...s.senders].filter((e=>"audio"===e.kind)).map((e=>({trackId:e.trackId,audioLevel:e.audioLevel})));if(this.emit(Ps.__INNER_AUDIOLEVEL_CHANGE__,a),this._isRoomAudience&&(null===(r=this._reportListener)||void 0===r?void 0:r.onReportLiveAudioStates)){const e=this._getLiveAudioState();try{e.length&&(null===(n=null===(i=this._reportListener)||void 0===i?void 0:i.onReportLiveAudioStates)||void 0===n||n.call(i,e))}catch(e){this._logger.error(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}}))}_getLiveAudioState(){const e=[];return this._rtcPeerConn.getReceivers().forEach((t=>{const r=t.getContributingSources();r.length&&e.push(...r)})),e.map((e=>{const{source:t,audioLevel:r}=e,i=this._store.getTrackIdBySSRC(t);if(!i)return{};const{userId:n}=Et(i);return{audioLevel:os(r),userId:n,trackId:i}})).filter((e=>!!e.userId))}_sendR3R4Data(){var e,t,r,i;return E(this,void 0,void 0,(function*(){let n=this._formatStatsData;if(!n)return;const{senders:s,receivers:o}=n;console.log(`sendR3R4: senderTrackId: ${null===(e=s[0])||void 0===e?void 0:e.trackId}, receiverTrackId: ${null===(t=o[0])||void 0===t?void 0:t.trackId}`),s.length&&(yield null===(r=this._polarisReport)||void 0===r?void 0:r.sendR3Data(n)),o.length&&(yield null===(i=this._polarisReport)||void 0===i?void 0:i.sendR4Data(n)),s.length=0,o.length=0,n=null}))}__reportR3R4ToPolaris(){return E(this,void 0,void 0,(function*(){this._isDestroyed||(clearTimeout(this._reportR3R4ToPolarisTimer),this._reportR3R4ToPolarisTimer=setTimeout((()=>E(this,void 0,void 0,(function*(){this._isDestroyed||this._sendR3R4Data().then((()=>{this.__reportR3R4ToPolaris()}))}))),2e3))}))}getRTCPeerConn(){return this._rtcPeerConn}destroy(){this.clear(),this.clearReTryExchangeTimer(),clearTimeout(this._reportR3R4ToPolarisTimer),this.stopAutoExecute(),this.registerReportListener(null),this._rtcPeerConn.close(),this._isDestroyed=!0,this.reportParser=null,this._logger.info(S.L_RTC_PEER_CONNECTION_DESTROY_O,JSON.stringify({status:O.SUCCESSED}))}clearReTryExchangeTimer(){clearTimeout(this._reTryExchangeTimer),this._reTryExchangeTimer=null}isDestroyed(){return this._isDestroyed}}Object.defineProperty(Ps,"__INNER_EVENT_TRACK_READY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-track-ready"}),Object.defineProperty(Ps,"__INNER_AUDIOLEVEL_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-audio-level-change"}),Object.defineProperty(Ps,"__INNER_ICE_STATE_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-ice-state-change"}),Object.defineProperty(Ps,"__INNER_ICE_CONNECTED__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-ice-connected"});class Us{constructor(e,t){Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_peer",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_audioLevelChangeHandler",{enumerable:!0,configurable:!0,writable:!0,value:null})}audioLevelReport(e){if(!this._audioLevelChangeHandler)return;const t=[];e.forEach((e=>{const{userId:r}=Et(e.trackId),i=this._store.crtUserId===r?this._peer.getLocalTrack(e.trackId):this._store.getRemoteTrack(e.trackId);i&&t.push({track:i,audioLevel:e.audioLevel||0})})),this._audioLevelChangeHandler(t)}onAudioLevelChange(e){this._audioLevelChangeHandler=e}}!function(e){e[e.ANCHOR=1]="ANCHOR",e[e.AUDIENCE=2]="AUDIENCE"}(hs||(hs={})),function(e){e.UNPUBLISH_PREV="UnpublishPrevCommand",e.PULL_RTCROOM_STATUS="PullRTCRoomStatusCommand",e.JOINROOM="JoinRoomCommand",e.PARSE_REMOTERES="ParseRemoteResCommand",e.PARSE_USERSTATE="ParseUserStateCommand",e.LOCAL_TRACK_MUTE="LocalTrackMuteCommand",e.PUBLISH="PublishCommand",e.RETRY_EXCHANGE="RetryExchangeCommand",e.UNPUBLISH="UnpublishCommand",e.SUBSCRIBE="SubscribeCommand",e.UNSUBSCRIBE="UnsubscribeCommand",e.UPDATE_SUBSCRIBE_LIST="UpdateSubscribeListCommand",e.ON_SIGNAL_RECONNECTED="OnSignalReconnectedCommand",e.LEAVE_OTHER_ROOM="LeaveOtherRoomCommand",e.RTC_IDENTITY_CHANGE="RTCIdentityChangeCommand",e.ENABLE_INNER_CDN="EnableInnerCDNCommand",e.EXCHANGE_WITH_PUSH_OTHER_ROOM="ExchangeWithPushOtherRoomCommand",e.MCUCONFIG_FLUSH="MCUConfigFlushCommand",e.UNKNOWN="Unknown"}(ps||(ps={})),function(e){e[e.LOW=0]="LOW",e[e.NORMAL=1]="NORMAL",e[e.HIGH=2]="HIGH"}(gs||(gs={})),function(e){e[e.Destroy=40400]="Destroy"}(Rs||(Rs={}));class ks{get priority(){return gs.LOW}get kind(){return ps.UNKNOWN}}class Ms{constructor(e,t,r,i){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"abortCode",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_queue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_busy",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1})}_next(){this._busy=!1,this._execute()}_execute(){return E(this,void 0,void 0,(function*(){if(this._isDestroyed||this._busy||0===this._queue.length)return;this._busy=!0;const{command:e,resolve:t}=this._queue.shift();let r;const i=this._logger.createTraceId();try{this._logger.info(S.L_INVOKER_EXECUTE_T,`kind: ${e.kind}, length: ${this._queue.length}`,i),r=yield e.execute(this._context,this._store,this)}catch(t){return console.error(t),this._logger.error(S.L_INVOKER_EXECUTE_R,e.kind,i),void this._next()}const{code:s}=r;s!==I.SUCCESS&&s!==n.SUCCESS?this._logger.warn(S.L_INVOKER_EXECUTE_R,`code: ${s}, kind: ${e.kind}`,i):this._logger.info(S.L_INVOKER_EXECUTE_R,`kind: ${e.kind}, Done`,i),t(r),this._next()}))}push(e){return E(this,void 0,void 0,(function*(){return new Promise((t=>{if(this._logger.info(S.L_INVOKER_PUSH_O,JSON.stringify({isDestroyed:this._isDestroyed,kind:e.kind,length:this._queue.length})),this._isDestroyed)return void t({code:I.NOT_IN_ROOM});const{priority:r}=e;if(r===gs.LOW)this._queue.push({command:e,resolve:t});else{const i=this._queue.findIndex((e=>e.command.priority<r)),n=-1===i?this._queue.length-1:i;this._queue.splice(n,0,{command:e,resolve:t})}setTimeout((()=>{this._execute()}),0)}))}))}isDestroyed(){return this._isDestroyed}destroy(){this._isDestroyed||(this._logger.info(S.L_INVOKER_DESTROY_O),this._isDestroyed=!0,this._queue.forEach((e=>{e.resolve({code:this.abortCode})})),this._queue.length=0)}}class ws extends Ms{constructor(e,t){super(e.logger,e,t,I.ROOM_HAS_BEEN_DESTROYED)}get store(){return this._context.store}destroy(){super.destroy(),this._store.removeRemoteTracks()}}class Bs{constructor(e,t,r,i,n,s,o,a){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"appkey",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"roomMode",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"isUpgrade",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"isMainRoom",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_roomResources",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_remoteTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_subscribedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_collectSubscribeList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_token",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_CDNUris",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_CDNEnable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_trackIdSSRCMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"_roomStatusVersion",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_supportNtf",{enumerable:!0,configurable:!0,writable:!0,value:!0})}getResourcesByUserId(e){return this._roomResources[e]}getRemoteTrack(e){return this._remoteTracks[e]}getRemoteTracksByUserId(e){const t=[];for(const r in this._remoteTracks){const i=this._remoteTracks[r];i.getUserId()===e&&t.push(i)}return t}getRemoteTracks(){return this._remoteTracks}getSessionId(){return this._sessionId}getAllUserIds(){return Object.keys(this._roomResources)}getRemoteUserIds(){return this.getAllUserIds().filter((e=>e!==this.crtUserId))}getSubscribedList(){return this._subscribedList}getCollectSubscribeList(){return this._collectSubscribeList}getPublishedResourceByTrackId(e){const{userId:t}=Et(e);return this._roomResources[t].find((t=>ft(t)===e))}getToken(){return this._token}getCDNEnable(){return this._CDNEnable}getCDNUris(){return this._CDNUris}getRoomStatusVersion(){return this._roomStatusVersion}getTrackIdBySSRC(e){return this._trackIdSSRCMap.get(e)}getRTCRequestHeader(){return{"App-Key":this.appkey,RoomId:this.roomId,Token:this._token,RoomType:this.roomMode,UserId:this.crtUserId,"Client-Session-Id":this.clientSessionId}}getSupportNtf(){return this._supportNtf}}class xs extends Bs{_updateTrackIdSSRCMap(){Object.values(this._roomResources).forEach((e=>{e.forEach((e=>{const{ssrc:t,resourceId:r}=JSON.parse(e.uri);this._trackIdSSRCMap.set(t,r)}))}))}setTrackIdSSRCMap(e,t){this._trackIdSSRCMap.set(e,t)}_initRemoteTracks(){for(const e in this._roomResources){const t=this._roomResources[e];e!==this.crtUserId&&0!==t.length&&t.forEach((e=>{const t=ft(e),{tag:r,userId:i,mediaType:n}=Et(t),s=n===Ve.AUDIO_ONLY?new dt(this._logger,r,i):new lt(this._logger,r,i);s.__innerSetRemoteMuted(0===e.state),this._remoteTracks[t]=s}))}}initWithRoomData(e,t){this._sessionId=e.sessionId,this._token=e.token,this._roomStatusVersion=Mt(e.version),this._roomResources=Ut(e,this.roomId,this._logger,t),this._updateTrackIdSSRCMap(),this._initRemoteTracks(),this.setResourcesByUserId(this.crtUserId,this.getResourcesByUserId(this.crtUserId)||[]),this._logger.info(S.L_PARSE_ROOMDATA_URIS_R,`room data -> ${JSON.stringify(this._roomResources)}`,t)}assignRoomData(e){Object.assign(this._roomResources,e),this._updateTrackIdSSRCMap()}setResourcesByUserId(e,t){this._roomResources[e]=t,this._updateTrackIdSSRCMap()}removeRemoteTrack(e){delete this._remoteTracks[e]}removeResourcesByUserId(e){delete this._roomResources[e],this._updateTrackIdSSRCMap()}addRemoteTrack(e){this._remoteTracks[e.getTrackId()]=e}removeRemoteTracks(){const e=Object.values(this._remoteTracks);e.length&&(e.forEach((e=>{e.isAudioTrack()&&e.__releaseMediaElement()})),this._remoteTracks={})}setCDNEnabel(e){this._CDNEnable=e}setCDNUris(e){this._CDNUris=e}resetSubscribedList(e){this._subscribedList.splice(0,this._subscribedList.length,...e),this.resetCollectSubscribeList(e)}resetCollectSubscribeList(e){this._collectSubscribeList.splice(0,this._collectSubscribeList.length,...e)}setRoomStatusVersion(e){this._roomStatusVersion=Mt(e)}}class Vs extends ks{get kind(){return ps.UNPUBLISH_PREV}execute(e,t){return E(this,void 0,void 0,(function*(){const{logger:r,context:i}=e,s=t.getResourcesByUserId(t.crtUserId),o=s.slice();s.length=0;const a=r.createTraceId();r.info(S.L_UNPUBLISH_PREV_COMMAND_T,JSON.stringify({resource:o}),a);const c=yield i.setRTCTotalRes(t.roomId,[ut(wt.UNPUBLISH,o)],ht([]),wt.TOTAL_CONTENT_RESOURCE,ht([]));return c!==n.SUCCESS?r.error(S.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:O.FAILED,code:c}),a):r.info(S.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:O.SUCCESSED}),a),{code:I.SUCCESS}}))}}!function(e){e[e.RTC=0]="RTC",e[e.LIVE=2]="LIVE",e[e.CROSS_MUTI=7]="CROSS_MUTI",e[e.SIP=4]="SIP",e[e.CALL=5]="CALL"}(ms||(ms={}));class js extends ks{constructor(e,t,r,i,n,s,o){super(),Object.defineProperty(this,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"roomType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"joinType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"innerUserDatas",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"outerUserDatas",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:o})}get kind(){return ps.JOINROOM}_getResultTag(){let e=S.L_RTC_CLIENT_JOIN_RTC_ROOM_R;return this.roomType===ms.LIVE&&(e=S.L_RTC_CLIENT_JOIN_LIVING_ROOM_R),e}_validateParams(e,t,n){if(e.getConnectionStatus()!==o.CONNECTED)return t.error(n,JSON.stringify({status:O.FAILED,code:I.SIGNAL_DISCONNECTED,msg:"im not connected"}),this.traceId),{code:I.SIGNAL_DISCONNECTED};if(Pt(e.getNaviInfo()))return t.error(n,JSON.stringify({status:O.FAILED,code:I.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),this.traceId),{code:I.PACKAGE_ENVIRONMENT_ERROR};if(!r("roomId",this.roomId,a,!0))return t.error(n,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> roomId"}),this.traceId),{code:I.PARAMS_ERROR};if(!r("roomType",this.roomType,(e=>void 0!==ms[e])))return t.error(n,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> roomType"}),this.traceId),{code:I.PARAMS_ERROR};if(!r("outerUserDatas",this.outerUserDatas,i,!1))return t.error(n,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:I.PARAMS_ERROR};if(this.outerUserDatas){if(!Object.keys(this.outerUserDatas).every((e=>r(`outerUserDatas.${e}`,this.outerUserDatas[e],c,!0))))return t.error(n,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:I.PARAMS_ERROR}}return{code:I.SUCCESS}}execute(e,t,r){var i;return E(this,void 0,void 0,(function*(){const s=Date.now(),{context:o,service:a,logger:c,reportMediaActionLogger:_}=e,d=this._getResultTag(),{code:l}=this._validateParams(o,c,d);if(l!==I.SUCCESS)return{code:l};if(!a.getMsList().length)return c.error(d,JSON.stringify({status:O.FAILED,code:I.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),this.traceId),{code:I.NOT_OPEN_VIDEO_AUDIO_SERVER};const u=t.getSupportNtf(),{code:h,data:p}=yield o.joinRTCRoom(this.roomId,this.roomType,this.livingType,this.joinType,this.innerUserDatas,this.outerUserDatas,u);if(_.reportQualityJoinRoomData(s,h,this.roomType,null==p?void 0:p.sessionId),h!==n.SUCCESS||!p){const e=40032===h?I.SIGNAL_JOIN_RTC_ROOM_REFUSED:h;return c.error(d,JSON.stringify({status:O.FAILED,code:e,msg:"joinRoom failed"}),this.traceId),{code:e}}t.initWithRoomData(p,this.traceId);t.getResourcesByUserId(t.crtUserId).length>0&&r.push(new Vs);const g=null===(i=p.roomInfo.filter((e=>"cdn_uris"===e.key))[0])||void 0===i?void 0:i.value;return g&&t.setCDNUris(JSON.parse(g)[0]),c.info(d,JSON.stringify({status:O.SUCCESSED,userId:t.crtUserId,roomId:this.roomId}),this.traceId),{code:I.SUCCESS,data:p}}))}}!function(e){e[e.ROOM=1]="ROOM",e[e.PERSON=2]="PERSON"}(fs||(fs={}));const Fs="PEER_CONNECTION_CLOSED_BY_EXCEPTION",Js="USER_JOIN",Gs="USER_LEAVE",Hs="TRACKS_PUBLISH",Ks="TRACKS_UNPUBLISH",$s="AUDIO_MUTE_CHANGE",Ws="VIDEO_MUTE_CHANGE",Ys="CDN_ENABLE_CHANGE",zs="USER_STATE_CHANGE";class qs extends e{constructor(e,t,r,i,n,s,o,a){super(),Object.defineProperty(this,"logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"service",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"context",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"runtime",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"peer",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"store",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"getPushOtherRooms",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}}var Qs,Zs,Xs,eo;!function(e){e.PUBLISH="publish",e.SUBSCRIBE="subscribe"}(Qs||(Qs={})),function(e){e.BEGIN="begin",e.END="end"}(Zs||(Zs={})),function(e){e[e.SPREAD=0]="SPREAD",e[e.NO_SPREAD=-1]="NO_SPREAD"}(Xs||(Xs={}));class to extends ks{constructor(e,t,r){super(),Object.defineProperty(this,"reqBody",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"isNeedUpdateMsas",{enumerable:!0,configurable:!0,writable:!0,value:r})}execute(e,t,r){var i;return E(this,void 0,void 0,(function*(){const{service:r,context:n}=e,s=yield r.exchange(t.getRTCRequestHeader(),this.reqBody,this.traceId,this.isNeedUpdateMsas),{code:o,data:a,qualityMsList:c}=s,_={code:o,data:{data:a,qualityMsList:c}},d=null===(i=null==a?void 0:a.urls)||void 0===i?void 0:i.pull_url;if(t.roomMode===ms.LIVE&&d){const e=JSON.parse(d);if(t.setCDNUris(e),(null==e?void 0:e.broadcast)===Xs.SPREAD){t.setCDNEnabel(!0);const r=Object.assign(Object.assign({},e),{enableInnerCDN:!0});ao(n,t.roomId,r)}}return _}))}}!function(e){e.PUB="pub",e.UNPUB="unpub",e.SUB="sub",e.UNSUB="unsub"}(eo||(eo={}));class ro extends ks{constructor(e,t,r,i=eo.SUB,n){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"forceReq",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"fromCommand",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"unsubTracks",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_actionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(this,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}})}get kind(){return ps.UPDATE_SUBSCRIBE_LIST}_dealSubscribeResult(e,t,r,i){const n=null==i?void 0:i.map((e=>`${e.msid}_${e.mediaType}`)),s=r.filter((e=>null==n?void 0:n.includes(e.track.getTrackId()))),o=r.filter((e=>!(null==n?void 0:n.includes(e.track.getTrackId()))));t.info(S.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:O.SUCCESSED,subSuccessTrackIds:n,failedList:o}),this.traceId);const a=e.getRemoteTracks();for(const e in a){const t=s.some((t=>t.track.getTrackId()===e));a[e].__innerSetSubscribed(t);const r=s.some((t=>t.track.getTrackId()===e&&t.subTiny));a[e].isVideoTrack()&&a[e].__innerSetIsTinyTrack(r)}return e.resetSubscribedList(s),o}_getParams(e,t,r){let i=r.map((e=>e instanceof _t?{track:e}:Object.assign({},e)));const n={};return i=i.filter((r=>{const i=r.track.getTrackId();return e.getRemoteTrack(i)?!n[i]&&(n[i]=!0,!0):(t.warn(S.L_UPDATE_SUBSCRIBELIST_COMMAND_P,`track cannot found in room -> trackId: ${i}`,this.traceId),!1)})).map((e=>Object.assign({},e))),i}_validateParams(e,t){return r("tracks",t,(()=>_(t)&&t.every((e=>e instanceof _t||e.track instanceof _t))),!0)?{code:I.SUCCESS}:(e.warn(S.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"tracks is invalid"}),this.traceId),{code:I.PARAMS_ERROR})}_reportPubOrSubQualityData(e,t,r){(null==r?void 0:r.length)&&e.reportPubOrSubQualityData(this.fromCommand,this._actionStartTime,r,t,this._trackMediaMap)}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i,peer:n,reportMediaActionLogger:s,context:o}=e;this._actionStartTime=Date.now();const{tracks:a,forceReq:c}=this,{roomId:_}=t;i.info(S.L_UPDATE_SUBSCRIBELIST_COMMAND_T,`roomId: ${_}, forceReq: ${c}, trackIds: ${a.map(kt)}`,this.traceId);const{code:d}=this._validateParams(i,a);if(d!==I.SUCCESS)return{code:d};const l=this._getParams(t,i,a),u=t.getSubscribedList().map((e=>Object.assign({},e)));if(!c){if(!go(l,u))return i.warn(S.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:O.SUCCESSED,msg:"subscribe list unchanged"}),this.traceId),{code:I.SUCCESS};if(u.length){const e=u.map((e=>e.track));i.warn(S.L_CLEAR_UNSUBSCRIBE_LIST_O,JSON.stringify({list:e.map((e=>e.getTrackId()))}),this.traceId);const r=t.getSubscribedList().filter((t=>e.every((e=>e.getTrackId()!==t.track.getTrackId()))));t.resetSubscribedList(r)}}n.__reportR3R4ToPolaris(),n.clearReTryExchangeTimer(),n.updateSubRemoteTracks(l.map((e=>e.track)));const h=yield so(l,!1,n,t,o);h.pushOtherRooms=e.getPushOtherRooms();const p=yield new to(h,this.traceId,!0).execute(e,t,r);a.forEach((e=>{const t=e instanceof _t?e.getTrackId():e.track.getTrackId();this._trackMediaMap[t]=p.data.qualityMsList||[]}));const g=this.fromCommand===eo.SUB?a:this.unsubTracks;if(p.code!==I.SUCCESS)return this._reportPubOrSubQualityData(s,p.code,g),i.error(S.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:O.FAILED,code:p.code}),this.traceId),{code:p.code};const{sdp:R,resultCode:m,subscribedList:f}=p.data.data;if(m!==I.SUCCESS)return this._reportPubOrSubQualityData(s,m,g),i.error(S.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:O.FAILED,code:m}),this.traceId),{code:m};s.setPubOrSubSuccessTime(Date.now());const E=yield n.setRemoteAnswer(R.sdp);if(this._reportPubOrSubQualityData(s,E,g),E!==I.SUCCESS)return{code:E};const T=this._dealSubscribeResult(t,i,l,f);return T.length?{code:I.SUCCESS,data:T}:{code:I.SUCCESS}}))}}class io extends ks{constructor(e,t){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:t})}get kind(){return ps.UNSUBSCRIBE}execute(e,t,i){return E(this,void 0,void 0,(function*(){const{logger:n,polarisReport:s}=e,{tracks:o}=this;if(!r("tracks",o,(()=>_(o)&&o.length>0&&o.every((e=>e instanceof _t))),!0))return n.warn(S.L_ABSTRACT_ROOM_UNSUBSCRIBE_E,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),{code:I.PARAMS_ERROR};n.info(S.L_ABSTRACT_ROOM_UNSUBSCRIBE_T,JSON.stringify({unSubscribeTrackIds:o.map(kt)}),this.traceId);const a=t.getSubscribedList().map((e=>Object.assign({},e))).filter((e=>o.every((t=>t.getTrackId()!==e.track.getTrackId()))));return s.sendR2(Qs.SUBSCRIBE,Zs.END,o.map((e=>e.getTrackId()))),new ro(a,!1,this.traceId,eo.UNSUB,this.tracks).execute(e,t,i)}))}}class no extends ks{constructor(e){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e})}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i}=e,{tracks:n}=this,s=i.createTraceId();return i.info(S.L_USER_LEFT_UNSUBSCRIBE_O,void 0,s),yield new io(n,s).execute(e,t,r),n.forEach((e=>{e.__innerDestroy(),t.removeRemoteTrack(e.getTrackId())})),e.emit(Ks,n),{code:I.SUCCESS}}))}}function so(e,t,r,i,n){var s;return E(this,void 0,void 0,(function*(){return{ipType:(null===(s=n.getNaviInfo())||void 0===s?void 0:s.ipType)||0,sdp:yield r.createOffer(t),extend:JSON.stringify({resolutionInfo:r.getOutboundVideoInfo()}),subscribeList:e.filter((e=>{const t=e.track.getTrackId(),{userId:r}=Et(t),n=i.getResourcesByUserId(r);if(!n)return!1;const s=n.filter((e=>t===`${e.msid}_${e.mediaType}`)).length;return s})).map((e=>({simulcast:e.subTiny?is.TINY:is.NORMAL,resolution:"",uri:i.getPublishedResourceByTrackId(e.track.getTrackId()).uri}))),switchstream:!1}}))}function oo(e,t,r){return E(this,void 0,void 0,(function*(){const i=e.logger.createTraceId();e.logger.info(S.L_LIVING_ROOM_SPREAD_CDN_INFO_T,JSON.stringify({CDNUris:r}),i);const s=yield e.setRTCCDNUris(t,wt.TOTAL_CONTENT_RESOURCE,JSON.stringify([r]));return s!==n.SUCCESS?(e.logger.error(S.L_LIVING_ROOM_SPREAD_CDN_INFO_R,`status: ${O.FAILED}, code: ${s}`,i),{code:I.SIGNAL_ERROR}):(e.logger.info(S.L_LIVING_ROOM_SPREAD_CDN_INFO_R,`status: ${O.SUCCESSED}`,i),{code:I.SUCCESS})}))}function ao(e,t,r){return E(this,void 0,void 0,(function*(){const i=e.logger.createTraceId();e.logger.info(S.L_LIVING_ROOM_SET_ROOM_CDN_INFO_T,`CDNUris: ${r}`,i);const s=yield e.setRTCData(t,"cdn_uris",JSON.stringify([r]),!0,fs.ROOM);return s!==n.SUCCESS?(e.logger.error(S.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,`status: ${O.FAILED}, code: ${s}`,i),{code:I.SIGNAL_ERROR}):(e.logger.info(S.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,`status: ${O.SUCCESSED}`,i),{code:I.SUCCESS})}))}function co(e,t){return E(this,void 0,void 0,(function*(){const{roomId:r}=t,i=Object.assign({},t.getCDNUris(),{enableInnerCDN:t.getCDNEnable()});return(yield Promise.all([oo(e,r,i),ao(e,r,i)])).every((e=>e.code===I.SUCCESS))?{code:I.SUCCESS}:{code:I.SIGNAL_ERROR}}))}function _o(e,t,r,i,n,s){return E(this,void 0,void 0,(function*(){const{logger:o}=r,{roomId:a,roomMode:c}=t,_=[],l={},u={},h={},p=Ut(e,a,o,s),g=Object.keys(p),R=t.getAllUserIds();for(let e=g.length-1;e>=0;e-=1){const r=g[e],i=R.indexOf(r);if(-1===i){_.push(r),l[r]=St(p[r]);continue}const n=t.getResourcesByUserId(r),s=p[r],{publishedList:o,modifiedList:a,unpublishedList:c}=Ot(n,s,!0);l[r]=St(o),u[r]=St(c),h[r]=St(a),R.splice(i,1)}R.length&&R.forEach((e=>{t.removeResourcesByUserId(e)})),t.assignRoomData(p),R.length&&(yield lo(R,r,t,i,s),r.emit(Gs,R)),_.length&&r.emit(Js,_),yield((e,t,r,i)=>E(void 0,void 0,void 0,(function*(){const{crtUserId:n}=e;for(const s in i){if(s===n)continue;const o=i[s];if(o.length){const i=o.map((t=>e.getRemoteTrack(ft(t))));yield new no(i).execute(t,e,r)}}})))(t,r,i,u),((e,t,r)=>{const{logger:i}=t;Object.keys(r).forEach((n=>{const s=r[n];if(0===s.length)return;const o=s.map((t=>{const r=ft(t),{userId:n,tag:s,mediaType:o}=Et(r),a=o===Ve.AUDIO_ONLY?new dt(i,s,n):new lt(i,s,n);return e.addRemoteTrack(a),a.__innerSetRemoteMuted(0===t.state),a}));o.length&&t.emit(Hs,o)}))})(t,r,l),((e,t,r)=>{Object.keys(r).forEach((i=>{r[i].forEach((r=>{const i=ft(r),n=e.getRemoteTrack(i);n.__innerSetRemoteMuted(0===r.state),n.isAudioTrack()?t.emit($s,n):t.emit(Ws,n)}))}))})(t,r,h),c===d.LIVE&&function(e,t,r,i){var n;if(!i)return void r.warn(S.L_LIVING_ROOM_RECONNECTED_R,JSON.stringify({status:O.FAILED,code:"",msg:"cdn_uris not found"}));const s=JSON.parse(i),o=(null===(n=t.getCDNUris())||void 0===n?void 0:n.enableInnerCDN)!==s.enableInnerCDN;t.setCDNUris(s),o&&e.emit(Ys,s.enableInnerCDN)}(r,t,o,n)}))}function lo(e,t,r,i,n){return E(this,void 0,void 0,(function*(){const s=[],o=[];e.forEach((e=>{s.push(...r.getRemoteTracksByUserId(e)),o.push(e)})),s.length&&(yield new io(s,n).execute(t,r,i),s.forEach((e=>r.removeRemoteTrack(e.getTrackId())))),o.length&&o.forEach((e=>r.removeResourcesByUserId(e)))}))}function uo(e){var t;const{userId:r,userData:i,event:n,switchRoleType:s}=e;return{users:[{userId:r,extra:null===(t=i.filter((e=>"extra"===e.key))[0])||void 0===t?void 0:t.value,state:n,switchRoleType:s}]}}function ho(e){var t,r;const{userId:i,userData:n}=e,s=(e=>e.some((e=>"uris"===e.key||"cdn_uris"===e.key)))(n);if(!s)return;const o=null===(t=n.filter((e=>"uris"===e.key))[0])||void 0===t?void 0:t.value,a=null===(r=n.filter((e=>"cdn_uris"===e.key))[0])||void 0===r?void 0:r.value;return{userId:i,content:{uris:o?JSON.parse(o):[],cdn_uris:a&&JSON.parse(a)}}}const po=(e,t,r)=>{const i=e.split("\r\nm"),n=r===Ve.AUDIO_ONLY?"audio":"video",s=i.filter((e=>e.includes(`=${n}`)&&e.includes(t)))[0];let o=new RegExp(`a=ssrc:(.*?) msid:${t}`);const a=s.match(o);return a?a[1]:""},go=(e,t)=>{let r=!1;return e.forEach((e=>{const i=t.findIndex((t=>t.track.getTrackId()===e.track.getTrackId()));if(-1===i)return void(r=!0);t.splice(i,1)[0].subTiny!==e.subTiny&&(r=!0)})),t.length&&(r=!0),r};class Ro extends ks{constructor(e,t){super(),Object.defineProperty(this,"msgContent",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:t})}get kind(){return ps.PARSE_USERSTATE}get priority(){return gs.NORMAL}_isPKRoomUser(e,t){for(const r of t){if(r.extra&&r.extra.roomId!==e.roomId)return!0;if(1===Number(r.state)&&!e.getRemoteUserIds().includes(r.userId))return!0}return!1}_dealAddUser(e,t,r,i,n){const s=e.getResourcesByUserId(n);s||(i?r.upgrade.push(n):r.joined.push(n),t.info(S.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:n,msg:"user "+(i?"upgrade":"joined")}),this.traceId)),e.setResourcesByUserId(n,s||[])}_dealReduceUser(e,t,r,i,n){e.info(S.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:n,msg:"user "+(i?"downgrade":"left")}),this.traceId),i?t.downgrade.push(n):1!==Number(r)?t.offline.push(n):t.left.push(n)}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i}=e,n={joined:[],left:[],offline:[],upgrade:[],downgrade:[]},{users:s}=this.msgContent;if(0===s.length)return{code:I.SUCCESS,data:n};if(this._isPKRoomUser(t,s))return{code:I.SUCCESS,data:n};s.forEach((e=>{const{userId:r}=e;0===Number(e.state)?this._dealAddUser(t,i,n,e.switchRoleType,r):this._dealReduceUser(i,n,e.state,e.switchRoleType,r)}));const o=[...n.left,...n.downgrade,...n.offline];return o.length&&(yield lo(o,e,t,r,this.traceId)),{code:I.SUCCESS,data:n}}))}}class mo extends ks{constructor(e,t,r,i,n){super(),Object.defineProperty(this,"msgContent",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"messageType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"senderId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"sentTime",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_publishedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_unpublishedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_modifiedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_nowResources",{enumerable:!0,configurable:!0,writable:!0,value:[]})}get kind(){return ps.PARSE_REMOTERES}get priority(){return gs.NORMAL}_dealPublishList(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i,reportMediaActionLogger:n}=e,s=this._nowResources.map(ft),o=[],a=[];if(this._publishedList.forEach((e=>{const r=ft(e),n=s.indexOf(r),{userId:c,tag:_,mediaType:d}=Et(r);n>-1?this._nowResources[n]=e:this._nowResources.push(e);let l=t.getRemoteTrack(r);l?l.isSubscribed()&&o.push(l):(l=d===Ve.AUDIO_ONLY?new dt(i,_,c):new lt(i,_,c),t.addRemoteTrack(l),a.push(l)),l.__innerSetRemoteMuted(0===e.state)})),o.length){const n=o.map((e=>e.getTrackId())),{code:s}=yield new ro(o,!0,this.traceId).execute(e,t,r);s!==I.SUCCESS&&i.error(S.L_RESUB_REPUB_RES_R,JSON.stringify({status:O.FAILED,trackIds:n,code:s}),this.traceId)}a.length&&e.emit(Hs,a),n.reportQualityRecvPubMsgData(this.sentTime,this.senderId)}))}_dealUnpublishList(e,t,r){return E(this,void 0,void 0,(function*(){const i=this._unpublishedList.map(ft);for(let e=this._nowResources.length-1;e>=0;e-=1){const t=this._nowResources[e];i.includes(ft(t))&&this._nowResources.splice(e,1)}const n=this._unpublishedList.map((e=>{const r=ft(e);return t.getRemoteTrack(r)}));yield new no(n).execute(e,t,r)}))}_dealModifiedList(e,t){return E(this,void 0,void 0,(function*(){const r=this._nowResources.map(ft);for(const i of this._modifiedList){const n=ft(i),s=r.indexOf(n);this._nowResources[s].state=i.state;const o=t.getRemoteTrack(n);o.__innerSetRemoteMuted(0===i.state),o.isAudioTrack()?e.emit($s,o):e.emit(Ws,o)}}))}_updateCDNUris(e,t){var r,i;const n=this.msgContent.cdn_uris[0],s=(null===(r=t.getCDNUris())||void 0===r?void 0:r.enableInnerCDN)!==n.enableInnerCDN;t.setCDNUris(n),s&&e.emit(Ys,!!(null===(i=t.getCDNUris())||void 0===i?void 0:i.enableInnerCDN))}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{uris:i}=this.msgContent;let n;this._publishedList=[],this._unpublishedList=[],this._modifiedList=[];const s=this.senderId,{messageType:o}=this;if(!t.getRemoteUserIds().includes(s))return{code:I.SUCCESS};switch(this._nowResources=t.getResourcesByUserId(s)||[],o){case wt.MODIFY:this._modifiedList.push(...i);break;case wt.PUBLISH:this._publishedList.push(...i);break;case wt.UNPUBLISH:this._unpublishedList.push(...i);break;case wt.TOTAL_CONTENT_RESOURCE:n=Ot(this._nowResources,i),this._publishedList.push(...n.publishedList),this._unpublishedList.push(...n.unpublishedList),this._modifiedList.push(...n.modifiedList)}if(this._publishedList.length&&(yield this._dealPublishList(e,t,r)),this._unpublishedList.length&&(yield this._dealUnpublishList(e,t,r)),this._modifiedList.length&&(yield this._dealModifiedList(e,t)),t.setResourcesByUserId(s,this._nowResources),t.roomMode!==ms.LIVE)return{code:I.SUCCESS};return this.msgContent.cdn_uris?(this._updateCDNUris(e,t),{code:I.SUCCESS}):{code:I.SUCCESS}}))}}class fo extends ks{constructor(e,t,r){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"forceReq",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r})}get kind(){return ps.SUBSCRIBE}execute(e,t,i){return E(this,void 0,void 0,(function*(){const{logger:n,polarisReport:s}=e,{tracks:o,forceReq:a}=this;if(!r("tracks",o,(()=>_(o)&&o.length>0&&o.every((e=>e instanceof _t||e.track instanceof _t))),!0))return n.error(S.L_ABSTRACT_ROOM_SUBSCRIBE_E,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),{code:I.PARAMS_ERROR};n.info(S.L_ABSTRACT_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:o.map(kt),forceReq:a}),this.traceId);const c=t.getSubscribedList().map((e=>Object.assign({},e))),d=o.map((e=>e instanceof _t?{track:e}:e));let l=!1;const u=[];return d.forEach((e=>{const t=e.track.getTrackId();u.push(t);const r=c.find((e=>e.track.getTrackId()===t));r&&r.subTiny===e.subTiny||(r?r.subTiny=e.subTiny:c.push(e),l=!0)})),l||a?(s.sendR2(Qs.SUBSCRIBE,Zs.BEGIN,u),new ro(c,!0,this.traceId).execute(e,t,i)):(n.warn(S.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:O.SUCCESSED,msg:"repeat subscribe"}),this.traceId),{code:I.SUCCESS})}))}}class Eo extends ks{constructor(e){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_actionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(this,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}})}get kind(){return ps.PUBLISH}_removePubFailedTracks(e,t){e.forEach((e=>{const r=e instanceof Xe?e:e.track;t.removeLocalTrackById(r.getTrackId())}))}_addLocalTracks(e,t){return E(this,void 0,void 0,(function*(){const r=[];for(const i of e){const{track:e,pubTiny:n}=i instanceof Xe?{pubTiny:!1,track:i}:i;if(e.isVideoTrack()&&n){let i;try{i=e.__innerGetMediaStreamTrack().clone();const t=n.frameRate||Be.FPS_15,r=n.resolution||xe.W176_H144,{width:s,height:o}=Ct(r),a=Lt(t);yield i.applyConstraints({width:s,height:o,frameRate:a})}catch(t){null==i||i.stop(),this._logger.warn(S.L_ABSTRACT_ROOM_PUBLISH_E,`pubTiny failed -> id: ${e.getTrackId()}, msg: ${t.message}`,this._traceId);break}const s=new tt(this._logger,e.getTag(),e.getUserId(),i,!0);r.push(s),t.addLocalTrack(s)}t.addLocalTrack(e)}return r}))}__publish(e,t,r,i){return E(this,void 0,void 0,(function*(){const{peer:n,reportMediaActionLogger:s,context:o}=e,a=[];r.forEach((e=>{const{track:t}=e instanceof Xe?{track:e}:e;a.push(t)})),r.sort(((e,t)=>{const{track:r}=e instanceof Xe?{track:e}:e,{max:i}=r.getBitrate(),{track:n}=t instanceof Xe?{track:t}:t,{max:s}=n.getBitrate();return i-s}));if(n.getLocalTracks().length+((e,t)=>{let r=0;return e.forEach((e=>{const i=e instanceof Xe?e.getTrackId():e.track.getTrackId();t.getLocalTrack(i)||(e instanceof Xe?r++:e.pubTiny&&e.track.isVideoTrack()&&(r+=2))})),r})(r,n)>10)return this._logger.error(S.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:O.FAILED,code:I.PUBLISH_TRACK_LIMIT_EXCEEDED,trackIds:r.map(kt),msg:"publish track limit exceeded"}),this._traceId),{code:I.PUBLISH_TRACK_LIMIT_EXCEEDED,tracks:a};const c=yield this._addLocalTracks(r,n);n.clearReTryExchangeTimer();const _=t.getSubscribedList(),d=yield so(_,!1,n,t,o);d.pushOtherRooms=e.getPushOtherRooms();const l=yield new to(d,this._traceId,!0).execute(e,t,i);if(a.forEach((e=>{const t=e.getTrackId();this._trackMediaMap[t]=l.data.qualityMsList||[]})),l.code!==I.SUCCESS)return s.reportPubOrSubQualityData(eo.PUB,this._actionStartTime,a,l.code,this._trackMediaMap),this._logger.error(S.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:O.FAILED,tracks:r.map(kt),code:l.code,msg:"exchange failed"}),this._traceId),this._removePubFailedTracks(r,n),{code:l.code,tracks:a};const{sdp:u,resultCode:h,message:p}=l.data.data;if(h!==I.SUCCESS)return s.reportPubOrSubQualityData(eo.PUB,this._actionStartTime,a,h,this._trackMediaMap),this._logger.error(S.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:O.FAILED,trackIds:r.map(kt),code:h,msg:`exchange inner failed: ${p}`}),this._traceId),this._removePubFailedTracks(r,n),{code:h,tracks:a};s.setPubOrSubSuccessTime(Date.now());const g=yield n.setRemoteAnswer(u.sdp,!0);return g!==I.SUCCESS?(s.reportPubOrSubQualityData(eo.PUB,this._actionStartTime,a,g,this._trackMediaMap),this._logger.error(S.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:O.FAILED,trackIds:r.map(kt),code:g,msg:"set remote answer error"}),this._traceId),{code:g,tracks:a}):(c.length&&this._updateTinyTrackIdSSRCMap(t,d.sdp.sdp,c),Object.assign(Object.assign({code:h},l.data),{tracks:a}))}))}_updateTinyTrackIdSSRCMap(e,t,r){r.forEach((r=>{const i=po(t,r.getStreamId(),Ve.VIDEO_ONLY);e.setTrackIdSSRCMap(Number(i),r.getTrackId())}))}_dealPublishRes(e,t,r){return E(this,void 0,void 0,(function*(){const{polarisReport:i,context:s,peer:o,reportMediaActionLogger:a}=r,c=t.crtUserId,{roomId:_}=t;let d="";const l=t.getResourcesByUserId(c),u=[...l];let h=[];const{tracks:p}=e;if(e.code!==I.SUCCESS)return{code:e.code};const{publishList:g,urls:R,mcuPublishList:m}=e.data;d=null==R?void 0:R.liveUrl;g.map((e=>Object.assign({tag:e.msid.split("_").pop(),state:o.getLocalTrack(ft(e)).isLocalMuted()?0:1},e))).forEach((e=>{const{isInclude:t,index:r}=((e,t)=>{let r=!1,i=0;for(let n=0;n<t.length;n++){const s=t[n];if(`${e.msid}_${e.mediaType}`==`${s.msid}_${s.mediaType}`){r=!0,i=n;break}}return{isInclude:r,index:i}})(e,u);t?u.splice(r,1,e):u.push(e)}));h=(null==m?void 0:m.map((e=>Object.assign({tag:e.msid.split("_").pop(),state:1},e))))||[];const{publishedList:f}=Ot(l,u),E=Object.assign(Object.assign({},t.getCDNUris()),{enableInnerCDN:t.getCDNEnable()}),T=E&&E.broadcast===Xs.SPREAD?JSON.stringify([E]):"",C=Date.now(),v=yield s.setRTCTotalRes(_,[ut(wt.PUBLISH,f)],ht(u),wt.TOTAL_CONTENT_RESOURCE,ht(h),T);if(a.reportPubOrSubQualityData(eo.PUB,this._actionStartTime,p,v,this._trackMediaMap,[{dur:Date.now()-C,cod:v}]),v!==n.SUCCESS)return this._logger.error(S.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:O.FAILED,code:v,msg:"send publish streams notification failed"}),this._traceId),{code:I.SIGNAL_ERROR};t.setResourcesByUserId(c,u);const b=f.map((e=>ft(e)));i.sendR2(Qs.PUBLISH,Zs.BEGIN,b),f.forEach((e=>{o.getLocalTrack(`${e.msid}_${e.mediaType}`).__innerSetPublished(!0)}));const L={code:I.SUCCESS};return d&&(L.liveUrl=d),L}))}execute(e,t,i){return E(this,void 0,void 0,(function*(){const{logger:n,peer:s}=e;this._traceId=n.createTraceId(),this._logger=n,this._actionStartTime=Date.now();let{tracks:o}=this;if(!r("tracks",o,(()=>_(o)&&o.length>0&&o.every((e=>e instanceof Xe||e.track instanceof Xe))),!0))return this._logger.error(S.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> tracks"}),this._traceId),{code:I.PARAMS_ERROR};if(this._logger.info(S.L_ABSTRACT_ROOM_PUBLISH_T,JSON.stringify({trackIds:o.map(kt)})),o=o.filter((e=>{const{track:t}=e instanceof Xe?{track:e}:e,r=t.isDestroyed();return r&&this._logger.warn(S.L_ABSTRACT_ROOM_PUBLISH_E,`track '${t.getTrackId()}' has beem destroyed`,this._traceId),!r})),!o.length)return this._logger.error(S.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:O.FAILED,code:I.PUBLISH_TRACKS_IS_INVALID,msg:"params tracks is empty"}),this._traceId),{code:I.PUBLISH_TRACKS_IS_INVALID};s.__reportR3R4ToPolaris(),s.clearReTryExchangeTimer();const a=yield this.__publish(e,t,o,i);return yield this._dealPublishRes(a,t,e)}))}}class Io extends ks{constructor(e){super(),Object.defineProperty(this,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_actionStartTime",{enumerable:!0,configurable:!0,writable:!0,value:Date.now()}),Object.defineProperty(this,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}})}get kind(){return ps.UNPUBLISH}__unpublish(e,t,r,i){return E(this,void 0,void 0,(function*(){const{peer:n,polarisReport:s,logger:o,reportMediaActionLogger:a,context:c}=e,_=i.map((e=>e.getTrackId()));if(0===_.map(t.getPublishedResourceByTrackId.bind(t)).filter((e=>!!e)).length)return{code:I.SUCCESS,tracks:i};_.forEach((e=>n.removeLocalTrackById(e))),s.sendR2(Qs.PUBLISH,Zs.END,_),n.clearReTryExchangeTimer();const d=t.getSubscribedList(),l=yield so(d,!1,n,t,c),u=e.getPushOtherRooms();u.length&&(l.pushOtherRooms=u);const h=yield new to(l,this._traceId,!0).execute(e,t,r);if(i.forEach((e=>{const t=e.getTrackId();this._trackMediaMap[t]=h.data.qualityMsList||[]})),h.code!==I.SUCCESS)return a.reportPubOrSubQualityData(eo.UNPUB,this._actionStartTime,i,h.code,this._trackMediaMap),o.error(S.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:O.FAILED,code:h.code,trackIds:i.map(kt),msg:"exchange failed"}),this._traceId),{code:h.code,tracks:i};const{resultCode:p,message:g}=h.data.data;return p!==I.SUCCESS?(a.reportPubOrSubQualityData(eo.UNPUB,this._actionStartTime,i,h.data.data.resultCode,this._trackMediaMap),o.error(S.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:O.FAILED,code:p,trackIds:i.map(kt),msg:`exchange inner failed: ${g}`}),this._traceId),{code:p,tracks:i}):Object.assign(Object.assign({code:h.code},h.data),{tracks:i})}))}_dealUnpublishRes(e,t,r){return E(this,void 0,void 0,(function*(){const{context:i,logger:s,peer:o,reportMediaActionLogger:a}=e,c=i.getCurrentId(),{roomId:_}=t,d=[];let l=[];const{tracks:u,code:h,data:p}=r;if(h!==I.SUCCESS)return s.error(S.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({code:h,msg:"unpublish failed"}),this._traceId),{code:h};if(!p)return s.info(S.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:O.SUCCESSED,msg:"unpublish list is empty "})),{code:I.SUCCESS};const{mcuPublishList:g}=p,R=u.map((e=>e.getTrackId())),m=R.map(t.getPublishedResourceByTrackId.bind(t)).filter((e=>!!e));d.push(...m);l=g?g.map((e=>Object.assign({tag:e.msid.split("_").pop(),state:1},e))):[];const f=t.getResourcesByUserId(c).filter((e=>!d.includes(e))),E=Date.now(),T=yield i.setRTCTotalRes(_,[ut(wt.UNPUBLISH,d)],ht(f),wt.TOTAL_CONTENT_RESOURCE,ht(l));if(a.reportPubOrSubQualityData(eo.UNPUB,this._actionStartTime,u,T,this._trackMediaMap,[{dur:Date.now()-E,cod:T}]),T!==n.SUCCESS)return s.error(S.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:O.FAILED,code:T,msg:"send unpublish notification failed"}),this._traceId),{code:I.SIGNAL_ERROR};s.info(S.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:O.SUCCESSED,code:I.SUCCESS,msg:"unpublish success",unPubResourceIds:R}),this._traceId);const{sdp:C}=r.data;return yield o.setRemoteAnswer(C.sdp),t.setResourcesByUserId(c,f),{code:I.SUCCESS}}))}execute(e,t,i){return E(this,void 0,void 0,(function*(){const{logger:n}=e;this._actionStartTime=Date.now();const{crtUserId:s}=t,{tracks:o}=this;this._traceId=n.createTraceId();if(!r("tracks",o,(()=>o.every((e=>e.getUserId()===s&&e instanceof Xe))),!0))return n.error(S.L_ABSTRACT_ROOM_UNPUBLISH_E,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> tracks"})),{code:I.PARAMS_ERROR};n.info(S.L_ABSTRACT_ROOM_UNPUBLISH_T,JSON.stringify({trackIds:o.map(kt)}));const a=yield this.__unpublish(e,t,i,o);return yield this._dealUnpublishRes(e,t,a)}))}}class So extends ks{constructor(e){super(),Object.defineProperty(this,"localTrack",{enumerable:!0,configurable:!0,writable:!0,value:e})}get kind(){return ps.LOCAL_TRACK_MUTE}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:r,context:i}=e,{localTrack:s}=this,o=s.getTrackId(),{crtUserId:a,roomId:c}=t,_=!s.isLocalMuted(),d=r.createTraceId();r.info(S.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_T,JSON.stringify({enabled:_,trackId:this.localTrack.getTrackId()}),d);const l=[{resourceId:o,enabled:_}],u=t.getResourcesByUserId(a),h=[];for(const e of u){const t=ft(e),r=l.findIndex((e=>e.resourceId===t));if(r>=0){const{enabled:t}=l[r];e.state=t?1:0,h.push(e);break}}const p=yield i.setRTCTotalRes(c,[ut(wt.MODIFY,h)],ht(u),wt.TOTAL_CONTENT_RESOURCE);return p!==n.SUCCESS?(r.error(S.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:O.FAILED,code:p,msg:"signal error"}),d),{code:p}):(r.info(S.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:O.SUCCESSED}),d),{code:I.SUCCESS})}))}}class Oo extends ks{get kind(){return ps.RETRY_EXCHANGE}get priority(){return gs.HIGH}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i,peer:n,context:s}=e,o=i.createTraceId();i.info(S.L_RETRY_EXCHANGE_COMMAND_T);const a=s.getCurrentId(),c=t.getSubscribedList(),_=yield so(c,!0,n,t,s);_.pushOtherRooms=e.getPushOtherRooms();const d=yield new to(_,o).execute(e,t,r);if(d.code!==I.SUCCESS)return{code:d.code};const{sdp:l,resultCode:u}=d.data.data;if(u!==I.SUCCESS)return{code:u};n.clearReTryExchangeTimer();const h=yield n.setRemoteAnswer(l.sdp);if(h!==I.SUCCESS)return{code:h};const p=d.data.data.publishList||[],{plus:g,minus:R}=this._diffPublishListChange(p,t,n,a);return(g.length||R.length)&&(yield this._spreadPublishListUri(e,a,g,R,o)),{code:I.SUCCESS}}))}_diffPublishListChange(e,t,r,i){const n=t.getResourcesByUserId(i);let s=JSON.parse(JSON.stringify(n));e.forEach((e=>{var t;const{mediaType:i,msid:n}=e,o=s.findIndex((e=>{const{mediaType:t,msid:r}=e;return i===t&&n===r}));if(-1===o){const i=Object.assign({tag:n.split("_").pop(),state:(null===(t=r.getLocalTrack(ft(e)))||void 0===t?void 0:t.isLocalMuted)?0:1},e);s.push(i)}else s[o].uri=e.uri}));const{publishedList:o,unpublishedList:a}=Ot(n,s,!0);return t.setResourcesByUserId(i,s),{plus:o,minus:a}}_spreadPublishListUri(e,t,r,i,s){return E(this,void 0,void 0,(function*(){const{store:o,logger:a}=e,c=o.getResourcesByUserId(t);a.info(S.L_RETRY_EXCHANGE_SPREAD_T,JSON.stringify({plus:r,minus:i,allPublishList:c}),s);const _=[];i.length&&_.push(ut(wt.UNPUBLISH,i)),r.length&&_.push(ut(wt.PUBLISH,r));(yield e.context.setRTCTotalRes(o.roomId,_,ht(c),wt.TOTAL_CONTENT_RESOURCE))===n.SUCCESS?a.info(S.L_RETRY_EXCHANGE_SPREAD_R,`status: ${O.SUCCESSED}`,s):a.error(S.L_RETRY_EXCHANGE_SPREAD_R,`status: ${O.FAILED}`,s)}))}}var To;!function(e){e[e.JOIN=0]="JOIN",e[e.LEAVE=1]="LEAVE",e[e.OFFLINE=2]="OFFLINE",e[e.RESOURCECHANGE=3]="RESOURCECHANGE"}(To||(To={}));class Co extends ks{constructor(e,t,r,i){super(),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_targetPullVersion",{enumerable:!0,configurable:!0,writable:!0,value:i})}get kind(){return ps.PULL_RTCROOM_STATUS}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i}=e,s=t.getRoomStatusVersion();if(i.info(S.L_PULL_ROOM_STATUS_T,JSON.stringify({roomId:this._roomId,localVersion:s}),this._traceId),this._targetPullVersion&&this._targetPullVersion<=s)return i.info(S.L_PULL_ROOM_STATUS_R,JSON.stringify({status:O.SUCCESSED,msg:"the roomData has been pulled",localVersion:s,targetPullVersion:this._targetPullVersion}),this._traceId),{code:n.SUCCESS};const{code:o,data:a}=yield this._context.pullRTCRoomStatus(this._roomId,s);if(o!==n.SUCCESS)return i.info(S.L_PULL_ROOM_STATUS_R,JSON.stringify({status:O.FAILED,code:o}),this._traceId),{code:o};const{bFullStatus:c,version:_,usersData:d,roomStatus:l}=a;if(i.info(S.L_PULL_ROOM_STATUS_R,JSON.stringify({bFullStatus:c,version:Mt(_),usersData:d,roomStatus:l}),this._traceId),t.setRoomStatusVersion(_),c){const{urisData:i,CDNUris:n}=function(e){const t={users:{}};let r="";return e.forEach((e=>{var i,n;const{userId:s,userData:o}=e;t.users[s]={};const a=null===(i=o.filter((e=>"uris"===e.key))[0])||void 0===i?void 0:i.value,c=null===(n=o.filter((e=>"cdn_uris"===e.key))[0])||void 0===n?void 0:n.value;r=c||r,t.users[s]={uris:a}})),{urisData:t,CDNUris:r&&JSON.stringify(JSON.parse(r)[0])}}(d);return yield _o(i,t,e,r,n,this._traceId),{code:o}}for(const i of l)if(i.event===To.RESOURCECHANGE){const n=ho(i);if(!n)continue;const{content:s,userId:o}=n;if(o===t.crtUserId)continue;yield new mo(s,wt.TOTAL_CONTENT_RESOURCE,o,this._traceId).execute(e,t,r)}else{const n=uo(i),{data:s}=yield new Ro(n,this._traceId).execute(e,t,r);e.emit(zs,s)}return{code:o}}))}}class vo extends ks{constructor(e){super(),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:e})}get kind(){return ps.ON_SIGNAL_RECONNECTED}get priority(){return gs.HIGH}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i,peer:s,context:o}=e,{roomId:a,roomMode:c}=t,_=i.createTraceId();if(i.info(S.L_ABSTRACT_ROOM_IM_RECONNECTED_T,void 0,_),"closed"===s.getRTCPeerConn().connectionState)return i.error(S.L_ABSTRACT_ROOM_IM_RECONNECTED_R,"RTCPeerConnection closed. Please rejoin room to restore services",_),e.emit(Fs),{code:I.SUCCESS};const{code:d}=yield o.rtcPing(a,c);if(40001===d){(yield this._joinRoom(e,t,r,_))===n.SUCCESS&&(yield this._restoreMediaServer(e,t,r))}else yield new Co(a,_,o).execute(e,t,r);return{code:I.SUCCESS}}))}_joinRoom(e,t,r,i){var s;return E(this,void 0,void 0,(function*(){const{context:o,logger:a}=e,{code:c,data:_}=yield o.joinRTCRoom(t.roomId,t.roomMode,this.livingType);if(c!==n.SUCCESS)return void a.error(S.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:O.FAILED,code:c,msg:"im reconnect joinRTCRoom failed"}),i);if(!_)return void a.info(S.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:O.FAILED,msg:"im reconnect joinRTCRoom, roomData is empty"}),i);const d=null===(s=_.roomInfo.filter((e=>"cdn_uris"===e.key))[0])||void 0===s?void 0:s.value;return yield _o(_,t,e,r,d,i),a.info(S.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:O.SUCCESSED,roomData:_}),i),c}))}_restoreMediaServer(e,t,r){return E(this,void 0,void 0,(function*(){const i=e.peer.getLocalTracks(),n=Object.values(t.getRemoteTracks()).filter((e=>!!e.isSubscribed()));i.length&&(yield new Eo(i).execute(e,t,r)),!i.length&&n.length&&(yield new fo(n,!0).execute(e,t,r))}))}}const bo=1,Lo=5;var yo,No,Ao,Do,Po,Uo;!function(e){e[e.new=0]="new",e[e.checking=1]="checking",e[e.connected=2]="connected",e[e.completed=3]="completed",e[e.failed=4]="failed",e[e.disconnected=5]="disconnected",e[e.closed=6]="closed"}(yo||(yo={})),function(e){e[e.SERVER_KICK=1]="SERVER_KICK",e[e.OTHER_KICK=2]="OTHER_KICK",e[e.IM_DISCONNECTED=3]="IM_DISCONNECTED",e[e.IM_LOGOUT=4]="IM_LOGOUT",e[e.OTHER_CLIENT_IM_CONNECTED=5]="OTHER_CLIENT_IM_CONNECTED"}(No||(No={}));class ko{constructor(e,t,r,i){Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_userId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_baseReportData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_networkReportData",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pubOrSubSuccessTime",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_peerCStatus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reportQualityJoinRoomData",{enumerable:!0,configurable:!0,writable:!0,value:(e,t,r,i)=>{this._baseReportData=Object.assign(this._baseReportData,{snid:i});const n=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{cod:t,time:e,dur:Date.now()-e,rtp:r});this._logger.__statistics(S.L_QS_JOIN_ROOM_S,JSON.stringify(n))}}),this._baseReportData={rid:this._roomId,csnid:this._clientSessionId,snid:"",time:Date.now(),uid:this._userId},this._networkReportData={cr:"unknown",net:"unknown"}}reportQualityKickedData(e){const t=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{time:Date.now(),cod:e===No.OTHER_KICK?Lo:bo});this._logger.__statistics(S.L_QS_KICKED_S,JSON.stringify(t))}reportPubOrSubQualityData(e,t,r,i,n,s){r.forEach((r=>{var o,a;const c=r instanceof Xe||r instanceof _t?r:r.track,_=c.getTrackId(),{mediaType:d}=Et(_);let l=!1;l=c instanceof Xe?!!c.isVideoTrack()&&(null===(a=(o=c).__isTiny)||void 0===a?void 0:a.call(o)):r.subTiny||!1;const u=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{resid:_,mtp:d,smct:l?is.TINY:is.NORMAL,stp:"Rongcloud"!==c.getTag()?1:0,cod:i,msas:n?n[_]:[],sigs:s,time:Date.now(),dur:Date.now()-t});switch(e){case"pub":this._logger.__statistics(S.L_QS_PUBLISH_S,JSON.stringify(u));break;case"unpub":this._logger.__statistics(S.L_QS_UNPUBLISH_S,JSON.stringify(u));break;case"sub":this._logger.__statistics(S.L_QS_SUBSCRIBE_S,JSON.stringify(u));break;case"unsub":this._logger.__statistics(S.L_QS_UNSUBSCRIBE_S,JSON.stringify(u))}}))}reportQualityRecvPubMsgData(e,t){const r=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{puid:t,time:Date.now(),dur:Date.now()-e});this._logger.__statistics(S.L_QS_RECV_PUB_MSG_S,JSON.stringify(r))}setPubOrSubSuccessTime(e){this._pubOrSubSuccessTime=e}reportIceFirstConnectData(e){const t=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{time:this._pubOrSubSuccessTime,dur:Date.now()-this._pubOrSubSuccessTime}),r="pub"===e?S.L_QS_PUB_ICE_STATUS_S:S.L_QS_SUB_ICE_STATUS_S;this._logger.__statistics(r,JSON.stringify(t))}recordQualityIceStatusData(e,t,r){const{status:i,time:n}=this._peerCStatus||{};if(!n)return void(this._peerCStatus={status:t,time:r});const{IP:s,port:o,networkType:a,remoteIP:c,remotePort:_}=e,d=Object.assign(Object.assign(Object.assign({},this._baseReportData),this._networkReportData),{dur:r-n,time:r,pices:yo[i],ices:yo[t],rcdts:[{ip:`${c}:${_}`}],lcdts:[{ip:`${s}:${o}`,nttp:a}],cncdts:[]});console.log(S.L_QS_ICE_STATUS_S,d),this._logger.__statistics(S.L_QS_ICE_STATUS_S,JSON.stringify(d)),this._peerCStatus={status:t,time:r}}}!function(e){e[e.DISABLE=0]="DISABLE",e[e.ENABLE=1]="ENABLE"}(Ao||(Ao={})),function(e){e[e.MeetingOrAnchor=1]="MeetingOrAnchor",e[e.Audience=2]="Audience"}(Do||(Do={})),function(e){e[e.NOT_REPORT=-1]="NOT_REPORT",e[e.REPORT_SUCCESS=1e4]="REPORT_SUCCESS",e[e.REPORT_FAIL=0]="REPORT_FAIL",e[e.PB_ERROR=40001]="PB_ERROR"}(Po||(Po={})),function(e){e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4"}(Uo||(Uo={}));class Mo{constructor(e,t,r,i,n=Do.MeetingOrAnchor){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,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_crtRTCRoom",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_userRole",{enumerable:!0,configurable:!0,writable:!0,value:n})}_send(e){return E(this,void 0,void 0,(function*(){if(this._context.getConnectionStatus()!==o.CONNECTED)return Po.NOT_REPORT;return(yield this._context.setRTCState(this._roomId,e))===n.SUCCESS?Po.REPORT_SUCCESS:Po.REPORT_FAIL}))}_getClientID(){const e="uuid";let t=this._runtime.localStorage.getItem(e);return t||(t=Tt(),this._runtime.localStorage.setItem(e,t)),t}_getRealResourceId(e){let t=e;const r=e.indexOf("_tiny");return r>-1&&(t=e.slice(0,r)),t}_getPolarisTrackId(e){let t="";const r=e.split("_");if(e.includes("_tiny")){const e=r.pop(),i=parseInt(r.pop())===Ve.AUDIO_ONLY?"audio":"video",n=r.pop();t=[r.join("_"),n,e,i].join("_")}else{const e=parseInt(r.pop())===Ve.AUDIO_ONLY?"audio":"video",i=r.pop();t=[r.join("_"),i,e].join("_")}return t}_getBaseData(e){return{bitrateSend:(null==e?void 0:e.bitrateSend)||Qn,bitrateRecv:(null==e?void 0:e.bitrateRecv)||Qn,networkType:(null==e?void 0:e.networkType)||"unknown",rtt:(null==e?void 0:e.rtt)||Qn,localAddress:`${(null==e?void 0:e.IP)||Qn}:${null==e?void 0:e.port}`,remoteAddress:`${null==e?void 0:e.remoteIP}:${null==e?void 0:e.remotePort}`,receiveBand:(null==e?void 0:e.availableIncomingBitrate)||Qn,sendBand:(null==e?void 0:e.availableOutgoingBitrate)||Qn,packetsLost:(null==e?void 0:e.totalPacketsLost)||Qn,deviceId:this._context.getCurrentId()}}_getAudioLevel(e){return e||0===e?e:Qn}_getBitrate(e){return e||0===e?e:Qn}_getPacketsLostRate(e){return e||0===e?e:Qn}_getFrameRate(e){return e||Qn}_getResolution(e,t){return e&&t?`${e} * ${t}`:"-1"}_getJitter(e){return e||Qn}_getNackCount(e){return e||0===e?e:Qn}_getPliCount(e){return e||0===e?e:Qn}_getRTT(e){return e||Qn}_getTrackState(e,t){const r=e?this._crtRTCRoom.getLocalTrack(t):this._crtRTCRoom.getRemoteTrack(t);return(null==r?void 0:r.isLocalMuted())?Ao.DISABLE:Ao.ENABLE}sendR3Data(e){return E(this,void 0,void 0,(function*(){const{iceCandidatePair:t,senders:r}=e,i=this._getBaseData(t);let n=`R3\t${i.bitrateSend}\t-1\t-1\t-1\t${i.networkType}\t${i.rtt}\t${i.localAddress}\t${i.receiveBand}\t${i.sendBand}\t${i.packetsLost}\t${i.deviceId}\r`;n+=r.map((e=>{const{trackId:t,audioLevel:r,samplingRate:i,bitrate:n,packetsLostRate:s,frameRate:o,frameWidth:a,frameHeight:c,googRenderDelayMs:_,jitter:d,nackCount:l,pliCount:u,rtt:h,googFirsSent:p,encoderImplementation:g}=e,R=this._getPolarisTrackId(t),m=this._getRealResourceId(t);return{trackId:R,googCodecName:g||String(Qn),audioLevel:this._getAudioLevel(r),bitrate:this._getBitrate(n),packetsLostRate:this._getPacketsLostRate(s),frameRate:this._getFrameRate(o),resolution:this._getResolution(a,c),jitter:this._getJitter(d),nackCount:this._getNackCount(l),pliCount:this._getPliCount(u),rtt:this._getRTT(h),googFirsSent:p,samplingRate:i,googRenderDelayMs:_,encoderImplementation:g||String(Qn),trackState:this._getTrackState(!0,m)}})).map((e=>`${e.trackId}\t${e.googCodecName}\t${e.audioLevel}\t${e.samplingRate}\t${e.bitrate}\t${e.packetsLostRate}\t${e.frameRate}\t${e.resolution}\t${e.googRenderDelayMs}\t${e.jitter}\t${e.nackCount}\t${e.pliCount}\t${e.rtt}\t${e.googFirsSent}\t${e.encoderImplementation}\t${e.trackState}`)).join("\n");return(yield this._send(`${n}\r${this._userRole}`))!==Po.REPORT_SUCCESS?Po.REPORT_FAIL:Po.REPORT_SUCCESS}))}sendR4Data(e){return E(this,void 0,void 0,(function*(){const{iceCandidatePair:t,receivers:r}=e,i=this._getBaseData(t);let n=`R4\t${i.bitrateRecv}\t-1\t-1\t-1\t${i.networkType}\t${i.rtt}\t${i.localAddress}\t${i.receiveBand}\t${i.sendBand}\t${i.packetsLost}\t${i.deviceId}\r`;n+=r.filter((e=>!!e.trackId)).map((e=>{const{trackId:t,audioLevel:r,samplingRate:i,bitrate:n,packetsLostRate:s,frameRate:o,frameWidth:a,frameHeight:c,googRenderDelayMs:_,jitter:d,nackCount:l,pliCount:u,rtt:h,googFirsReceived:p,codecImplementationName:g}=e,R=this._getPolarisTrackId(t),m=this._getRealResourceId(t);return{trackId:R,googCodecName:g||String(Qn),audioLevel:this._getAudioLevel(r),bitrate:this._getBitrate(n),packetsLostRate:this._getPacketsLostRate(s),frameRate:this._getFrameRate(o),resolution:this._getResolution(a,c),jitter:this._getJitter(d),nackCount:this._getNackCount(l),pliCount:this._getPliCount(u),rtt:this._getRTT(h),googFirsReceived:p,samplingRate:i,googRenderDelayMs:_,codecImplementationName:g||String(Qn),trackState:this._getTrackState(!1,m)}})).map((e=>`${e.trackId}\t${e.googCodecName}\t${e.audioLevel}\t${e.samplingRate}\t${e.bitrate}\t${e.packetsLostRate}\t${e.frameRate}\t${e.resolution}\t${e.googRenderDelayMs}\t${e.jitter}\t${e.nackCount}\t${e.pliCount}\t${e.rtt}\t${e.googFirsReceived}\t${e.codecImplementationName}\t${e.trackState}`)).join("\n");return(yield this._send(`${n}\r${this._userRole}`))!==Po.REPORT_SUCCESS?Po.REPORT_FAIL:Po.REPORT_SUCCESS}))}sendR1(){var e;const t=this._context.getCoreVersion(),r=(null===(e=navigator.userAgentData)||void 0===e?void 0:e.platformn)||navigator.platform,i=`R1\t5.28.0\t${t}\tweb\t${r}\t-1\t${yt.browser}\t${yt.version}\t${this._getClientID()}\t${this._userRole}`;this._send(i)}sendR2(e,t,r){const i=`R2\t${e}\t${t}\t${this._getClientID()}\r${r.join("\t")}\r${this._userRole}`;this._send(i)}}const wo="evt-leave";class Bo extends e{constructor(e,t,r,i,n,s,o,a,c=Zn(),_=!1){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,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:c}),Object.defineProperty(this,"_pinger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_audioLevelReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_peerConnection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_executeCtx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_onRecvPKMsg",{enumerable:!0,configurable:!0,writable:!0,value:null});const d=this._logger=this._context.logger;this._reportMediaActionLogger=new ko(d,this._roomId,this._clientSessionId,this._context.getCurrentId()),this._polarisReport=new Mo(this._context,this._runtime,this._roomId,this);const l=this._context.getCurrentId(),u=new xs(d,c,this._context.getAppkey(),r,l,i,o,a),h=this._peerConnection=new Ps(d,this._reTryExchange.bind(this),l,u,this._polarisReport,!1,_);this._setPeerConnectionListener();const p=this._executeCtx=new qs(d,this._service,e,t,h,u,this._polarisReport,this._reportMediaActionLogger);p.getPushOtherRooms=()=>this._getPushOtherRoomsParams(),this.setCommandEventListener(),this._invoker=new ws(p,u),this._store=this._invoker.store,this._audioLevelReport=new Us(this._store,h),h.on(Ps.__INNER_AUDIOLEVEL_CHANGE__,this._audioLevelReport.audioLevelReport,this._audioLevelReport),this._pinger=new xt(this._context,this._roomId,i,this._initOptions.pingGap),this._pinger.onFailed=this.__kickoff.bind(this),this._pinger.onPingResult=this._handlePingResult.bind(this),this._context.registerRTCSignalListener((e=>E(this,void 0,void 0,(function*(){const{time:t,type:r,roomId:i}=this._context.decodeRtcNotify(e);if(this._invoker.isDestroyed())this._logger.info(S.L_RTCNTF_PULL_ROOM_STATUS_O,JSON.stringify({isDestroyed:!0,type:r,time:t,roomId:i}));else if(2===r&&i===this._roomId){const e=this._logger.createTraceId();this._logger.info(S.L_RTCNTF_PULL_ROOM_STATUS_O,null,e),this._startPullRTCRoomStatus(i,e,t)}}))))}_setPeerConnectionListener(){const e=this._peerConnection;e.on(Ps.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),e.on(Xe.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(Xe.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.once(Ps.__INNER_ICE_CONNECTED__,(e=>{this._reportMediaActionLogger.reportIceFirstConnectData(e?"pub":"sub")}),this),e.on(Ps.__INNER_ICE_STATE_CHANGE__,(e=>{const{status:t,time:r,iceCandidatePair:i}=e;this._reportMediaActionLogger.recordQualityIceStatusData(i,t,r)}))}setCommandEventListener(){const e=this._executeCtx;e.on(Fs,this._rtcpeerClosed,this),e.on(Js,this._callAppListener.bind(this,"onUserJoin"),this),e.on(Gs,this._callAppListener.bind(this,"onUserLeave"),this),e.on(Hs,this._onTrackPublish,this),e.on(Ks,this._onTrackUnpublish,this),e.on($s,this._onAudioMuteChange,this),e.on(Ws,this._onVideoMuteChange,this),e.on(Ys,this._callAppListener.bind(this,"onCDNEnableChange"),this),e.on(zs,this._dealUserAppListener,this)}_startPullRTCRoomStatus(e,t,r){return E(this,void 0,void 0,(function*(){yield this._invoker.push(new Co(e,t,this._context,r))}))}__innerInit(e,t,r,i,n,s){return E(this,void 0,void 0,(function*(){const{code:o,data:a}=yield this._invoker.push(new js(this._roomId,e,t,r,i,n,s));return o!==I.SUCCESS?{code:o}:(this._initWithRoomData(a.offlineKickTime),{code:o,data:a})}))}_initWithRoomData(e){this._pinger.start(1e3*e),this._polarisReport.sendR1()}_handlePingResult(e,t){if(e===Bt.SUCCESS){if(t>this._store.getRoomStatusVersion()&&this._store.getSupportNtf()){const e=this._logger.createTraceId();this._logger.info(S.L_RTCPING_PULL_ROOM_STATUS_O,JSON.stringify({dataVersion:t}),e),this._startPullRTCRoomStatus(this._roomId,e,t)}}this._callAppListener("onPing",e)}setBitrate(e,r,i){this._logger.warn(S.L_ABSTRACT_ROOM_SETBITRATE_O,"`RCAbstractRoom.setBitrate` will be deprecated, use `RCLocalTrack.setBitrate` instead."),l("max",e,(e=>t(e)&&e>Math.max(r||1,200)),!0),l("min",r,(r=>t(r)&&r>=1&&(!t(e)||r<e)),!0),l("start",i,(i=>t(i)&&i>r&&i<=e)),this._peerConnection.setBitrate(e,r,i)}_onTrackReady(e){const t=e.streams[0].id,{track:r}=e.receiver,i=[t,"audio"===r.kind?Ve.AUDIO_ONLY:Ve.VIDEO_ONLY].join("_"),n=this._store.getRemoteTrack(i);n?(n.__innerSetMediaStreamTrack(r),this._logger.info(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onTrackReady",trackId:n.getTrackId()})),this._callAppListener("onTrackReady",n)):this._logger.warn(S.L_ABSTRACT_ROOM_ONTRACKREADY_O,`cannot found remote track ${r.id}`)}_callAppListener(e,...t){var r;const i=null===(r=this._appListener)||void 0===r?void 0:r[e];if(i)try{i(...t)}catch(e){this._logger.error(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}_onTrackUnpublish(e){this._logger.info(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onTrackUnpublish",trackIds:null==e?void 0:e.map((e=>e.getTrackId()))})),this._callAppListener("onTrackUnpublish",e)}__parseInnerMessage(e,t){const{targetId:r}=e;if(r!==this._roomId)return void this._logger.warn(S.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,JSON.stringify({status:O.FAILED,message:`roomId is different, msg roomId-> ${r}, this._roomId-> ${this._roomId} `}),t);this._logger.info(S.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,`recv inner msg -> message: ${JSON.stringify(e)} | roomid: ${this._roomId}`,t);const{content:i}=e;switch(e.messageType){case wt.KICK:this.__kickoff(!0,i);break;case wt.STATE:this._stateHandle(i,t);break;case wt.MODIFY:case wt.PUBLISH:case wt.UNPUBLISH:case wt.TOTAL_CONTENT_RESOURCE:this._resourceHandle(i,e.messageType,e.senderUserId,e.sentTime,t);break;case wt.ROOM_NOTIFY:this._logger.info(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onRoomAttributeChange",messageType:e.messageType,messageContent:e.content})),this._callAppListener("onRoomAttributeChange",e.messageType,e.content);break;case wt.USER_NOTIFY:this._logger.warn(S.L_OLD_DAILY_RECORD_O,`TODO: ${wt.USER_NOTIFY}`);break;case wt.PK_INVITE:case wt.PK_CANCEL_INVITE:case wt.PK_INVITE_TIMEOUT:case wt.PK_INVITE_ANSWER:case wt.PK_END:this._onRecvPKMsg&&this._onRecvPKMsg(e);break;case wt.OTHER_ROOM_OFFLINE:break;default:this._logger.info(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onMessageReceive",messageType:e.messageType,messageContent:e.content,senderUserId:e.senderUserId,messageUId:e.messageUId})),this._callAppListener("onMessageReceive",e.messageType,i,e.senderUserId,e.messageUId)}}__kickoff(e,t){return E(this,void 0,void 0,(function*(){if(this._invoker.isDestroyed())return;let r,i;this._logger.warn(S.L_ABSTRACT_ROOM_ONKICKOFF_O,`onKickOff -> byServer: ${e}, kickContent: ${JSON.stringify(t)}`),this.emit(wo),this._leaveHandle(!e),e&&((null==t?void 0:t.users)||[]).forEach((e=>{e.userId===this._context.getCurrentId()&&(i=e.type,r=e.kickExtra,this._reportMediaActionLogger.reportQualityKickedData(i))})),this._logger.info(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onKickOff",byServer:e,kickType:i,kickExtra:r})),this._callAppListener("onKickOff",e,i,r)}))}_rtcpeerClosed(){this.emit(wo),this._leaveHandle(!0),this._logger.info(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,"onRTCPeerConnectionCloseByException"),this._callAppListener("onRTCPeerConnectionCloseByException")}_resourceHandle(e,t,r,i,n){return E(this,void 0,void 0,(function*(){const{uris:s,ignore:o}=e;!o&&s&&this._invoker.push(new mo(e,t,r,n,i))}))}_onTrackPublish(e,t,r){this._logger.info(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onTrackPublish",trackIds:null==e?void 0:e.map((e=>e.getTrackId()))})),this._callAppListener("onTrackPublish",e)}_stateHandle(e,t){return E(this,void 0,void 0,(function*(){const r=(yield this._invoker.push(new Ro(e,t))).data;this._dealUserAppListener(r)}))}_dealUserAppListener(e){var t,r;const{left:i,joined:n,upgrade:s,downgrade:o,offline:a}=e,c=[...n],_=[...i];(null===(t=this._appListener)||void 0===t?void 0:t.onSwitchRole)?(null==s||s.forEach((e=>{this._logger.info(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onSwitchRole",userId:e,role:hs.ANCHOR})),this._callAppListener("onSwitchRole",e,hs.ANCHOR)})),null==o||o.forEach((e=>{this._logger.info(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onSwitchRole",userId:e,role:hs.AUDIENCE})),this._callAppListener("onSwitchRole",e,hs.AUDIENCE)}))):(c.push(...s),_.push(...o)),a.length&&((null===(r=this._appListener)||void 0===r?void 0:r.onUserOffline)?(this._logger.info(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onUserOffline",offline:a})),this._callAppListener("onUserOffline",a)):_.push(...a)),c.length>0&&(this._logger.info(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onUserJoin",allJoined:c})),this._callAppListener("onUserJoin",c)),_.length>0&&(this._logger.info(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onUserLeave",allLeft:_})),this._callAppListener("onUserLeave",_))}getRoomId(){return this._roomId}getCrtUserId(){return this._context.getCurrentId()}getRemoteUserIds(){return this._store.getRemoteUserIds()}getRemoteTracks(){const e=[];return this.getRemoteUserIds().forEach((t=>{e.push(...this.getRemoteTracksByUserId(t))})),e}getRemoteTracksByUserId(e){return this._store.getRemoteTracksByUserId(e)}getSessionId(){return this._store.getSessionId()}sendMessage(e,t){return E(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();this._logger.info(S.L_ABSTRACT_ROOM_SEND_MESSAGE_T,JSON.stringify({name:e,content:t}),r);const{code:i}=yield this._context.sendMessage(u.RTC_ROOM,this._roomId,{messageType:e,content:t,isStatusMessage:!0});return i!==n.SUCCESS?(this._logger.error(S.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:O.FAILED,code:i}),r),{code:I.SIGNAL_ERROR}):(this._logger.info(S.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:O.SUCCESSED,name:e,content:t}),r),{code:I.SUCCESS})}))}setRoomAttribute(e,t,r,i=!1){return E(this,void 0,void 0,(function*(){const s=this._logger.createTraceId();this._logger.info(S.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,key:e,value:t,message:r,isInner:i}),s);const o=yield this._context.setRTCData(this._roomId,e,t,i,fs.ROOM,r);return o!==n.SUCCESS?(this._logger.error(S.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:O.FAILED,code:o}),s),{code:I.SIGNAL_ERROR}):(this._logger.info(S.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:O.SUCCESSED,roomId:this._roomId,key:e,value:t,message:r,isInner:i}),s),{code:I.SUCCESS})}))}deleteRoomAttributes(e,t,r=!1){return E(this,void 0,void 0,(function*(){const i=this._logger.createTraceId();this._logger.info(S.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:e,message:t,isInner:r}),i);const s=yield this._context.removeRTCData(this._roomId,e,r,fs.ROOM,t);return s!==n.SUCCESS?(this._logger.error(S.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:O.FAILED,code:s}),i),{code:I.SIGNAL_ERROR}):(this._logger.info(S.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:O.SUCCESSED,roomId:this._roomId,keys:e,message:t,isInner:r}),i),{code:I.SUCCESS})}))}getRoomAttributes(e=[],t=!1){return E(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();this._logger.info(S.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:e,isInner:t}),r);const{code:i,data:s}=yield this._context.getRTCData(this._roomId,e,t,fs.ROOM);return i!==n.SUCCESS?(this._logger.error(S.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_R,`GetRoomAttributes Failed: ${i}`,r),{code:I.SIGNAL_ERROR}):(this._logger.info(S.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:O.SUCCESSED,data:s}),r),{code:I.SUCCESS,data:s})}))}_setUserAttributeValue(e,t,r){return this._context.setRTCData(this._roomId,e,t,!1,fs.PERSON,r)}_deleteUserAttributes(e,t){return this._context.removeRTCData(this._roomId,e,!1,fs.PERSON,t)}_getUserAttributes(e){return this._context.getRTCData(this._roomId,e,!1,fs.PERSON)}isDestroyed(){return this._invoker.isDestroyed()}__destroy(e){return this._leaveHandle(e)}_muteRemoteTracksBeforeQuit(){const e=Object.values(this._store.getRemoteTracks());e.length&&e.forEach((e=>e.mute()))}_leaveHandle(e){return E(this,void 0,void 0,(function*(){this._invoker.isDestroyed()||(this._invoker.destroy(),this._muteRemoteTracksBeforeQuit(),e&&(yield this._context.quitRTCRoom(this._roomId)),this._store.isMainRoom&&(yield this._quitAllPKRoom()),this._pinger.stop(),yield this._service.exit(this._store.getRTCRequestHeader()),this._releasePCManager())}))}_releasePCManager(){const e=this._peerConnection;e.removeAllLocalTrack(),e.destroy()}_onLocalTrackDestroied(e){e instanceof tt&&e.__isTiny()||this.unpublish([e])}_onLocalTrackMuted(e,t){return E(this,void 0,void 0,(function*(){const{code:r}=yield this._invoker.push(new So(e));t(r)}))}publish(e){return E(this,void 0,void 0,(function*(){return this._invoker.push(new Eo(e))}))}_getPushOtherRoomsParams(){return[]}_reTryExchange(){return this._invoker.push(new Oo)}unpublish(e){return E(this,void 0,void 0,(function*(){return this._invoker.push(new Io(e))}))}_isValidResourceId(e){var t;const{userId:r}=Et(e);return!!(null===(t=this._store.getResourcesByUserId(r))||void 0===t?void 0:t.find((t=>ft(t)===e)))}subscribe(e){return E(this,void 0,void 0,(function*(){return this._invoker.push(new fo(e,void 0,void 0))}))}unsubscribe(e){return E(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();return this._logger.info(S.L_APP_CALL_UNSUBSCRIBE_O,void 0,t),this._invoker.push(new io(e,t))}))}updateSubList(e){return E(this,void 0,void 0,(function*(){return this._invoker.push(new ro(e,!0,this._logger.createTraceId()))}))}getLocalTrack(e){return this._peerConnection.getLocalTrack(e)}getLocalTracks(){return this._peerConnection.getLocalTracks()}getRemoteTrack(e){return this._store.getRemoteTrack(e)||null}get subscribedTracks(){return this._store.getSubscribedList().slice()}registerRoomEventListener(e){this._logger.info(S.L_ABSTRACT_ROOM_REGISTER_ROOM_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._appListener=e}registerReportListener(e){this._logger.info(S.L_ABSTRACT_ROOM_REGISTER_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._peerConnection.registerReportListener(e)}onAudioLevelChange(e,t){this._logger.info(S.L_ABSTRACT_ROOM_AUDIO_LEVEL_O),this._audioLevelReport.onAudioLevelChange(e)}__onReconnected(e){this._invoker.push(new vo(e))}_onAudioMuteChange(e){this._logger.info(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onAudioMuteChange",trackId:e.getTrackId()})),this._callAppListener("onAudioMuteChange",e)}_onVideoMuteChange(e){this._logger.info(S.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:O.SUCCESSED,eventType:"onVideoMuteChange",trackId:e.getTrackId()})),this._callAppListener("onVideoMuteChange",e)}_registerPKMsgListener(e){this._onRecvPKMsg=e}_quitAllPKRoom(){return E(this,void 0,void 0,(function*(){}))}getClientSessionId(){return this._store.clientSessionId}}class xo extends ks{constructor(e,t){super(),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"cdnValues",{enumerable:!0,configurable:!0,writable:!0,value:t})}get kind(){return ps.MCUCONFIG_FLUSH}execute(e,t,r){var i,n,s,o;return E(this,void 0,void 0,(function*(){const{context:r,service:a}=e,c={"App-Key":r.getAppkey(),Token:t.getToken(),RoomId:t.roomId,UserId:r.getCurrentId(),SessionId:t.getSessionId()},{code:_,res:d}=yield a.setMcuConfig(c,this.data);if(_!==I.SUCCESS)return{code:_};d.pull_url&&t.setCDNUris(JSON.parse(d.pull_url));const l=this.cdnValues;return _===I.SUCCESS&&((null===(n=null===(i=l.output)||void 0===i?void 0:i.video.normal)||void 0===n?void 0:n.width)||(null===(o=null===(s=l.output)||void 0===s?void 0:s.video.normal)||void 0===o?void 0:o.fps))&&co(r,t),{code:_,data:d}}))}}var Vo,jo,Fo,Jo;!function(e){e[e.CROP=1]="CROP",e[e.WHOLE=2]="WHOLE"}(Vo||(Vo={})),function(e){e[e.CUSTOMIZE=1]="CUSTOMIZE",e[e.SUSPENSION=2]="SUSPENSION",e[e.ADAPTATION=3]="ADAPTATION"}(jo||(jo={})),function(e){e[e.CROP=1]="CROP",e[e.WHOLE=2]="WHOLE"}(Fo||(Fo={})),function(e){e[e.AUDIO_VIDEO_ALL=0]="AUDIO_VIDEO_ALL",e[e.AUDIO_VIDEO_NO=1]="AUDIO_VIDEO_NO",e[e.AUDIO_ALL_VIDEO_NO=2]="AUDIO_ALL_VIDEO_NO",e[e.AUDIO_NO_VIDEO_ALL=3]="AUDIO_NO_VIDEO_ALL",e[e.AUDIO_VIDEO_INPUT=4]="AUDIO_VIDEO_INPUT",e[e.AUDIO_ALL_VIDEO_INPUT=5]="AUDIO_ALL_VIDEO_INPUT",e[e.AUDIO_NO_VIDEO_INPUT=6]="AUDIO_NO_VIDEO_INPUT",e[e.AUDIO_INPUT_VIDEO_ALL=7]="AUDIO_INPUT_VIDEO_ALL",e[e.AUDIO_INPUT_VIDEO_NO=8]="AUDIO_INPUT_VIDEO_NO",e[e.ROOM_AUDIO_VIDEO_APPEND=9]="ROOM_AUDIO_VIDEO_APPEND",e[e.ROOM_AUDIO_VIDEO_NOT_APPEND=10]="ROOM_AUDIO_VIDEO_NOT_APPEND",e[e.ROOM_AUDIO_APPEND=11]="ROOM_AUDIO_APPEND",e[e.ROOM_AUDIO_NOT_APPEND=12]="ROOM_AUDIO_NOT_APPEND",e[e.ROOM_VIDEO_APPEND=13]="ROOM_VIDEO_APPEND",e[e.ROOM_VIDEO_NOT_APPEND=14]="ROOM_VIDEO_NOT_APPEND"}(Jo||(Jo={}));const Go=()=>({version:2,mode:jo.SUSPENSION});class Ho{constructor(e,t,r){Object.defineProperty(this,"_executeCtx",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_isValidTrackId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_values",{enumerable:!0,configurable:!0,writable:!0,value:Go()}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._executeCtx.logger}setHostVideoTrack(e){if(!this._isValidTrackId(e))return this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,msg:`videoTrackId: ${e} is invalid`})),this;const{mediaType:t,tag:r,userId:i}=Et(e);return t!==Ve.VIDEO_ONLY?(this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,msg:`kind of ${e} is not video`})),this):(this._values.host_stream_id=It(i,r),this._logger.info(S.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:O.SUCCESSED,videoTrackId:e})),this)}setMixLayoutMode(e){return[jo.CUSTOMIZE,jo.SUSPENSION,jo.ADAPTATION].includes(e)?(this._values.mode=e,this._logger.info(S.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:O.SUCCESSED,mode:e})),this):(this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:O.SUCCESSED,msg:`mode: ${e} is invalid`})),this)}_addOutputValue(e,t,r="normal"){const i=this._values.output||(this._values.output={video:{normal:{width:640,height:480}}});if("cdn"===e)return void(i.cdn=t);if("audio"===e)return void(i.audio={bitrate:t});const{video:n}=i;if("normal"!==r&&"tiny"!==r)if("backgroundColor"!==r)if("exparams"!==r){if("backgroundPicture"===r){const e=n.backgroundPicture||(n.backgroundPicture={fillMode:Vo.CROP,picture:[]});Object.assign(e,t)}}else n.exparams={renderMode:t};else n.backgroundColor=t;else{const e=n[r]||(n[r]={});Object.assign(e,t)}}setOutputVideoResolution(e){if(!vt(e))return this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:O.FAILED,msg:`params error -> resolution: ${e}`})),this;const{width:t,height:r}=Ct(e);return this._addOutputValue("video",{width:t,height:r},"normal"),this._logger.info(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:O.SUCCESSED,resolution:e})),this}setOutputVideoFPS(e){if(!bt(e))return this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:O.FAILED,msg:`params error -> fps: ${e}`})),this;const t=Lt(e);return this._addOutputValue("video",{fps:t},"normal"),this._logger.info(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:O.SUCCESSED,fps:e})),this}setOutputVideoBitrate(e){return!t(e)||e<=0?(this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:O.FAILED,msg:`params error -> bitrate: ${e}`})),this):(this._addOutputValue("video",{bitrate:e},"normal"),this._logger.info(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:O.SUCCESSED,bitrate:e})),this)}setOutputTinyVideoResolution(e){if(!vt(e))return this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:O.FAILED,msg:`params error -> resolution: ${e}`})),this;const{width:t,height:r}=Ct(e);return this._addOutputValue("video",{width:t,height:r},"tiny"),this._logger.info(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:O.SUCCESSED,resolution:e})),this}setOutputTinyVideoFPS(e){if(!bt(e))return this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:O.FAILED,msg:`params error -> fps: ${e}`})),this;const t=Lt(e);return this._addOutputValue("video",{fps:t},"tiny"),this._logger.info(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:O.SUCCESSED,fps:e})),this}setOutputTinyVideoBitrate(e){return!t(e)||e<=0?(this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:O.FAILED,msg:`params error -> bitrate: ${e}`})),this):(this._addOutputValue("video",{bitrate:e},"tiny"),this._logger.info(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:O.SUCCESSED,bitrate:e})),this)}setOutputVideoRenderMode(e){return[Fo.CROP,Fo.WHOLE].includes(e)?(this._addOutputValue("video",e,"exparams"),this._logger.info(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:O.SUCCESSED,renderMode:e})),this):(this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:O.FAILED,msg:`params error -> renderMode: ${e}`})),this)}setOutputAudioBitrate(e){return t(e)&&e>0?(this._addOutputValue("audio",e),this._logger.info(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:O.SUCCESSED,bitrate:e})),this):(this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:O.FAILED,msg:`params error -> bitrate: ${e}`})),this)}setOutputBackgroundColor(e){return/^0x[a-fA-F0-9]{6}$/.test(e)?(this._addOutputValue("video",e,"backgroundColor"),this._logger.info(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:O.SUCCESSED,color:e})),this):(this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:O.FAILED,msg:`params error -> color: ${e}`})),this)}addOutputBackgroundPicture(e,r,i,n,s){var o,a,c;if(!h(e))return this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:O.FAILED,msg:`params error -> uri: ${e}`})),this;if([r,i,n,s].some((e=>!t(e)||e<0||e>1)))return this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:O.FAILED,msg:`params of (x, y, w, h) error -> x: ${r}, y: ${i}, w: ${n}, h: ${s}`})),this;const _=(null===(c=null===(a=null===(o=this._values.output)||void 0===o?void 0:o.video)||void 0===a?void 0:a.backgroundPicture)||void 0===c?void 0:c.picture)||[];return _.push({uri:e,w:n,h:s,x:r,y:i}),this._addOutputValue("video",{picture:_},"backgroundPicture"),this._logger.info(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:O.SUCCESSED,uri:e,x:r,y:i,w:n,h:s})),this}removeOutputBackgroundPicture(e){var t,r,i;if(!h(e))return this._logger.error(S.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:O.FAILED,msg:`params error -> uri: ${e}`})),this;let n=null===(i=null===(r=null===(t=this._values.output)||void 0===t?void 0:t.video)||void 0===r?void 0:r.backgroundPicture)||void 0===i?void 0:i.picture;return n&&(n=n.filter((t=>t.uri!==e)),this._addOutputValue("video",{pictures:n},"backgroundPicture")),this._logger.info(S.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:O.SUCCESSED,uri:e})),this}clearOutputBackgroundPicture(){return this._addOutputValue("video",{pictures:[]},"backgroundPicture"),this._logger.info(S.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}setOutputBackgroundPictureFillMode(e){return[Vo.CROP,Vo.WHOLE].includes(e)?(this._addOutputValue("video",{fillMode:e},"backgroundPicture"),this._logger.info(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:O.SUCCESSED,fillMode:e})),this):(this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:O.FAILED,msg:`params error -> fillMode: ${e}`})),this)}addPublishStreamUrls(e){var t,r;const i=/^rtmp:\/\/.+/;if(!_(e)||0===e.length||e.some((e=>!i.test(e))))return this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:O.FAILED,msg:`params error -> urls: ${e.join(",")}`})),this;const n=(null===(r=null===(t=this._values.output)||void 0===t?void 0:t.cdn)||void 0===r?void 0:r.concat())||[];let s=!1;return e.forEach((e=>{n.some((t=>t.pushurl===e))||(s=!0,n.push({pushurl:e}))})),n.length>5?(this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:O.FAILED,msg:`params error -> publish stream urls no more than 5, length: ${e.length}`})),this):(s&&this._addOutputValue("cdn",n),this._logger.info(S.L_MCU_CONFIG_BUILDER_ADD_PUBLISH_STREAM_URLS_O,JSON.stringify({status:O.SUCCESSED,urls:e})),this)}removePublishStreamUrls(e){var t,r;const i=/^rtmp:\/\/.+/;if(!_(e)||0===e.length||e.some((e=>!i.test(e))))return this._logger.error(S.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:O.FAILED,msg:`params error -> urls: ${e.join(",")}`})),this;const n=(null===(r=null===(t=this._values.output)||void 0===t?void 0:t.cdn)||void 0===r?void 0:r.concat())||[];for(let t=n.length-1;t>=0;t-=1){const{pushurl:r}=n[t],i=e.indexOf(r);i>=0&&(e.splice(i,1),n.splice(t,1))}return this._addOutputValue("cdn",n),this._logger.info(S.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:O.SUCCESSED,urls:e})),this}clearPublishStreamUrls(){return this._addOutputValue("cdn",[]),this._logger.info(S.L_MCU_CONFIG_BUILDER_CLEAR_PUBLISH_STREAM_URLS_O),this}addCustomizeLayoutVideo(e,r,i,n,s){if(!a(e)||!this._isValidTrackId(e))return this._logger.error(S.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.FAILED,msg:`params error -> trackId: ${e}`})),this;if(!t(r)||!t(i))return this._logger.error(S.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.FAILED,msg:`params x or y is error -> x: ${r}, y: ${i}`})),this;if([n,s].some((e=>!t(e)||e<0)))return this._logger.error(S.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.FAILED,msg:`params width or height error -> width: ${n}, height: ${s}`})),this;const{userId:o,tag:c,mediaType:_}=Et(e);if(_!==Ve.VIDEO_ONLY)return this._logger.error(S.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.FAILED,msg:`type of trackId: ${e} is not video`})),this;const d=It(o,c),l=this._values.input||(this._values.input={}),u=l.video||(l.video=[]);return u.some((e=>e.height===s&&e.width===n&&e.stream_id===d&&e.user_id===o&&e.x===r&&e.y===i))?(this._logger.warn(S.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.FAILED,msg:"Duplicate configuration item place ignored"})),this):(u.push({user_id:o,stream_id:d,x:r,y:i,width:n,height:s}),this._logger.info(S.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.SUCCESSED,trackId:e,x:r,y:i,width:n,height:s})),this)}removeCustomizeLayoutVideo(e){if(!this._isValidTrackId(e))return this._logger.error(S.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.FAILED,msg:`params error -> trackId: ${e}`})),this;const{userId:t,tag:r,mediaType:i}=Et(e);if(i!==Ve.VIDEO_ONLY)return this._logger.error(S.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.FAILED,msg:`type of trackId: ${e} is not video`})),this;const n=It(t,r),{input:s}=this._values;return(null==s?void 0:s.video)&&s.video.length>0&&(s.video=s.video.filter((e=>e.stream_id===n))),this._logger.info(S.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:O.SUCCESSED,trackId:e})),this}clearCustomizeLayoutVideo(){const{input:e}=this._values;return null==e||delete e.video,this._logger.info(S.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_LAYOUT_VIDEO_O),this}setCustomizeInputAudio(e){if(e.some((e=>this._isValidTrackId(e))))return this._logger.error(S.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.FAILED,msg:`trackIds contain invalid item -> trackIds: ${e.join(",")}`})),this;return(this._values.input||(this._values.input={})).audio=e.map((e=>{const{userId:t,tag:r}=Et(e);return{stream_id:It(t,r),user_id:t}})),this._values.inputFilterMode=Jo.AUDIO_INPUT_VIDEO_ALL,this._logger.info(S.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.SUCCESSED,trackIds:e})),this}addCustomizeInputAudio(e){if(!this._isValidTrackId(e))return this._logger.error(S.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.FAILED,msg:`params error -> trackId: ${e}`})),this;const t=this._values.input||(this._values.input={}),r=t.audio||(t.audio=[]),{userId:i,tag:n}=Et(e),s=It(i,n);return r.some((e=>e.stream_id===s&&e.user_id===i))?(this._logger.warn(S.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.FAILED,msg:`trackId: ${e} is exist`})),this):(r.push({user_id:i,stream_id:s}),this._values.inputFilterMode=Jo.AUDIO_INPUT_VIDEO_ALL,this._logger.info(S.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.SUCCESSED,trackId:e})),this)}removeCustomizeInputAudio(e){if(!this._isValidTrackId(e))return this._logger.error(S.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.FAILED,msg:`params error -> trackId: ${e}`})),this;const{input:t}=this._values;if(!(null==t?void 0:t.audio)||0===t.audio.length)return this._logger.error(S.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.FAILED,msg:`type of trackId: ${e} is not audio`})),this;const{userId:r,tag:i}=Et(e),n=It(r,i);return t.audio=t.audio.filter((e=>r!==e.user_id||n!==e.stream_id)),this._logger.info(S.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:O.SUCCESSED,trackId:e})),this}clearCustomizeInputAudio(){const{input:e}=this._values;return(null==e?void 0:e.audio)&&delete e.audio,this._values.inputFilterMode=Jo.AUDIO_VIDEO_ALL,this._logger.info(S.L_MCU_CONFIG_BUILDER_CLEAR_CUSTOMIZE_INPUT_AUDIO_O),this}addPictureWaterMark(e,r,i,n,s,o){if(!this._isValidTrackId(e))return this._logger.error(S.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:O.FAILED,msg:`params error -> trackId: ${e}`})),this;if(!h(r))return this._logger.error(S.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:O.FAILED,msg:`params error -> uri: ${r}`})),this;if([i,n,s,o].some((e=>!t(e)||e<0||e>1))||i+s>1||n+o>1)return this._logger.error(S.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:O.FAILED,msg:`some attrs of (x, y, w, h) is invalid -> x: ${i}, y: ${n}, w: ${s}, h: ${o}`})),this;const{userId:a,tag:c}=Et(e),_=It(a,c),d=this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]}),{singleScreen:l}=d,u=l.filter((e=>e.streamId===_))[0];return u?u.picture.push({uri:r,w:s,h:o,x:i,y:n}):l.push({streamId:_,picture:[{uri:r,w:s,h:o,x:i,y:n}]}),this._values.waterMark.singleScreen=l,this._logger.info(S.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:O.SUCCESSED,trackId:e,uri:r,x:i,y:n,w:s,h:o,singleScreen:l})),this}clearPictureWaterMark(){return(this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]})).singleScreen=[],this._logger.info(S.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}removePictureWaterMark(e,t){if(!a(e)||!this._isValidTrackId(e))return this._logger.error(S.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:O.FAILED,msg:`params error -> trackId: ${e}`})),this;const{userId:r,tag:i}=Et(e),n=It(r,i),s=this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]}),{singleScreen:o}=s;return o.forEach((e=>{e.streamId===n&&(e.picture=e.picture.filter((e=>e.uri!==t)))})),this._logger.info(S.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:O.SUCCESSED,trackId:e,uri:t})),this}reset(){return this._values=Go(),this._logger.info(S.L_MCU_CONFIG_BUILDER_RESET_O),this}flush(e=!0){return E(this,void 0,void 0,(function*(){const t=JSON.parse(JSON.stringify(this._values)),{code:r}=yield this._invoker.push(new xo(t,this._values));return e&&(this._values=Go()),{code:r}}))}__innerGetValues(){return JSON.parse(JSON.stringify(this._values))}}var Ko,$o,Wo;!function(e){e[e.VIDEO=0]="VIDEO",e[e.AUDIO=1]="AUDIO"}(Ko||(Ko={}));class Yo extends ks{constructor(e,t,r){super(),Object.defineProperty(this,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"roomPKHandler",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r})}_exchangeWithPushOtherRoom(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i,peer:n,context:s}=e;if(!n.getLocalTracks().length)return void i.info(S.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:O.SUCCESSED,msg:"have not published resource"}),this.traceId);const o=n,a=t.getSubscribedList(),c=yield so(a,!1,o,t,s),_=e.getPushOtherRooms();c.pushOtherRooms=_;const d=yield new to(c,this.traceId,!0).execute(e,t,r);if(d.code!==I.SUCCESS)return void i.error(S.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:O.FAILED,code:d.code,pushOtherRooms:_}),this.traceId);const{sdp:l,resultCode:u}=d.data.data;u===I.SUCCESS?(i.info(S.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:O.SUCCESSED,pushOtherRooms:_}),this.traceId),o.setRemoteAnswer(l.sdp)):i.error(S.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:O.FAILED,code:u,pushOtherRooms:_}),this.traceId)}))}get kind(){return ps.EXCHANGE_WITH_PUSH_OTHER_ROOM}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i}=e,{roomId:n}=this;if(i.info(S.L_EXCHANGE_WITH_PUSHOTHERROOM_T,n),!this.roomPKHandler)return i.error(S.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:O.FAILED,msg:"_roomPKHandler not exist"}),this.traceId),{code:I.SUCCESS};return this.roomPKHandler.getPKInfo(n)?(yield this._exchangeWithPushOtherRoom(e,t,r),{code:I.SUCCESS}):(i.warn(S.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:O.FAILED,msg:"PKInfo not exist"}),this.traceId),{code:I.SUCCESS})}))}}class zo extends ks{constructor(e,t,r,i,n,s){super(),Object.defineProperty(this,"pkHandler",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"room",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_PKInfo",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_joinedPKRooms",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"isQuitPK",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:s})}get kind(){return ps.LEAVE_OTHER_ROOM}quitRoomPK(e,t,r,i){return E(this,void 0,void 0,(function*(){const{logger:s,context:o}=e;if(s.info(S.L_QUIT_PK_T,`roomId: ${t}`,i),!this._PKInfo[t])return void s.warn(S.L_QUIT_PK_R,`status: ${O.FAILED}, msg: pkinfo is empty`,i);const{inviterRoomId:a,inviteeRoomId:c,inviterUserId:_,inviteSessionId:d}=this._PKInfo[t],l={inviteeRoomId:c,inviterRoomId:a,userId:r.crtUserId},u={roomId:r.roomId,endRoomId:t,sessionId:d,content:JSON.stringify(l),keys:[`${a}|${_}`]},h=yield o.endRoomPK(u);if(h!==n.SUCCESS)return s.error(S.L_QUIT_PK_R,`status: ${O.FAILED}, code: ${h}`,i),{code:I.SIGNAL_ERROR};s.info(S.L_QUIT_PK_R,`status: ${O.SUCCESSED}`,i),delete this._PKInfo[t]}))}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i}=e,{room:n,isQuitPK:s}=this,o=n.getRoomId();return i.info(S.L_LIVING_ROOM_LEAVE_PK_ROOM_T,JSON.stringify({roomId:o,isQuitPK:s}),this.traceId),yield n.__destroy(!0),delete this._joinedPKRooms[o],yield new Yo(o,this.pkHandler,this.traceId).execute(e,t,r),s&&this.quitRoomPK(e,o,t,this.traceId),i.info(S.L_LIVING_ROOM_LEAVE_PK_ROOM_R,JSON.stringify({status:O.SUCCESSED}),this.traceId),{code:I.SUCCESS}}))}}class qo{constructor(e,t,r,i,n,s,o,a,c,_){Object.defineProperty(this,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_PKInfo",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_mainLivingRoom",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_registerPKMsgListener",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_onJoinedPKRoom",{enumerable:!0,configurable:!0,writable:!0,value:c}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(this,"_inviteTimeout",{enumerable:!0,configurable:!0,writable:!0,value:30}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_mainRoomId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_joinedPKRooms",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger=this._context.logger,this._registerPKMsgListener(this._onRecvPKMsg.bind(this)),this._mainRoomId=this._mainLivingRoom.getRoomId()}_callAppListener(e,...t){var r;const i=null===(r=this._appListener)||void 0===r?void 0:r[e];if(i)try{i(...t)}catch(e){this._logger.error(S.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify(e))}}_onInvite(e){const t=e.inviteInfo||{},{inviterRoomId:r,inviterUserId:i,extra:n}=t,s={inviterRoomId:r,inviterUserId:i,extra:n};this._PKInfo[r]=t,this._logger.info(S.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onRequestJoinOtherRoom",info:s})),this._callAppListener("onRequestJoinOtherRoom",s)}_onCancelInvite(e){const{inviterRoomId:t,inviterUserId:r,extra:i}=e.inviteInfo||{},n={inviterRoomId:t,inviterUserId:r,extra:i};delete this._PKInfo[t],this._logger.info(S.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCancelRequestOtherRoom",cancelInfo:n})),this._callAppListener("onCancelRequestOtherRoom",n)}_onInviteTimeout(e){}_onInviteAnswer(e){const{answerCode:t,inviteContent:r}=e,{inviteSessionId:i,inviterUserId:n,inviterRoomId:s,inviteeUserId:o,inviterUserAutoMix:a,inviteeUserAutoMix:c,inviteeRoomId:_,extra:d}=r,l={agree:1===t,inviterRoomId:s,inviterUserId:n,inviteeRoomId:_,inviteeUserId:o,extra:d};this._PKInfo[_]=this._PKInfo[_]||{inviteSessionId:i,inviterRoomId:s,inviterUserId:n,inviterUserAutoMix:a,inviteeRoomId:_},this._PKInfo[_].inviteeUserAutoMix=c,this._logger.info(S.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onResponseJoinOtherRoom",answerInfo:l})),this._callAppListener("onResponseJoinOtherRoom",l)}createLeaveOtherRoomCommand(e,t,r){return new zo(this,e,this._PKInfo,this._joinedPKRooms,t,r)}_onPKEnd(e){return E(this,void 0,void 0,(function*(){const{inviteeRoomId:t,inviterRoomId:r,userId:i}=e.inviteInfo,n=r===this._mainRoomId?t:r,s={endRoomId:n,endUserId:i},o=this._joinedPKRooms[n],a=this._logger.createTraceId();this._logger.info(S.L_QUIT_PK_LEAVE_PK_ROOM_O,void 0,a),o&&(yield this._invoker.push(this.createLeaveOtherRoomCommand(o,!0,a))),delete this._PKInfo[n],this._logger.info(S.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onFinishOtherRoom",endInfo:s})),this._callAppListener("onFinishOtherRoom",s)}))}_onRecvPKMsg(e){const{content:t,messageType:r}=e;switch(r){case wt.PK_INVITE:this._onInvite(t);break;case wt.PK_CANCEL_INVITE:this._onCancelInvite(t);break;case wt.PK_INVITE_TIMEOUT:this._onInviteTimeout(t);break;case wt.PK_INVITE_ANSWER:this._onInviteAnswer(t);break;case wt.PK_END:this._onPKEnd(t)}}registerRoomPKEventListener(e){this._logger.info(S.L_LIVING_PK_HANDLER_REGISTER_ROOM_PK_EVENT_LISTENER_O,JSON.stringify({listener:e&&Object.keys(e)})),this._appListener=e}requestJoinOtherRoom(e,t,i){return E(this,void 0,void 0,(function*(){const s=this._logger.createTraceId();if(this._logger.info(S.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:e,inviteeUserId:t,options:i}),s),!r("inviteeRoomId",e,a,!0)||!r("inviteeUserId",t,a,!0))return this._logger.error(S.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),s),{code:I.PARAMS_ERROR};const o=Zn(),c=!p(null==i?void 0:i.autoMix)||(null==i?void 0:i.autoMix),_={inviteSessionId:o,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:c,inviteeRoomId:e,inviteeUserId:t,inviteeTimeoutTime:this._inviteTimeout,extra:(null==i?void 0:i.extra)||""},d={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteTimeout:this._inviteTimeout,inviteInfo:JSON.stringify(_),inviteSessionId:o},l=yield this._context.requestRoomPK(d);return l!==n.SUCCESS?(this._logger.error(S.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:l}),s),{code:l}):(this._PKInfo[e]={inviteSessionId:o,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:c,inviteeRoomId:e},this._logger.info(S.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.SUCCESSED}),s),{code:I.SUCCESS})}))}cancelRequestJoinOtherRoom(e,t,i){return E(this,void 0,void 0,(function*(){const s=this._logger.createTraceId();if(this._logger.info(S.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:e,inviteeUserId:t,extra:i}),s),!r("inviteeRoomId",e,a,!0)||!r("inviteeUserId",t,a,!0))return this._logger.error(S.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),s),{code:I.PARAMS_ERROR};if(!this._PKInfo[e])return this._logger.error(S.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:`The request to connect with ${t} user in room ${e} is not initiated`}),s),{code:I.PARAMS_ERROR};const o={inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviteeRoomId:e,inviteeUserId:t,extra:i||""},c={roomId:this._mainRoomId,invitedRoomId:e,invitedUserId:t,inviteSessionId:this._PKInfo[e].inviteSessionId,inviteInfo:JSON.stringify(o)},_=yield this._context.cancelRoomPK(c);return _!==n.SUCCESS?(this._logger.error(S.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:_}),s),{code:_}):(this._logger.info(S.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.SUCCESSED}),s),delete this._PKInfo[e],{code:I.SUCCESS})}))}responseJoinOtherRoom(e,t,i,s){return E(this,void 0,void 0,(function*(){const o=this._logger.createTraceId();if(this._logger.info(S.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_T,JSON.stringify({inviterRoomId:e,inviterUserId:t,agree:i,options:s}),o),!r("inviterRoomId",e,a,!0)||!r("inviterUserId",t,a,!0))return this._logger.error(S.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> inviterRoomId or inviterUserId"}),o),{code:I.PARAMS_ERROR};if(!this._PKInfo[e])return this._logger.error(S.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:`User ${t} in room ${e} did not send a request for connection`}),o),{code:I.PARAMS_ERROR};const{inviteSessionId:c,inviterUserAutoMix:_}=this._PKInfo[e],d=!p(null==s?void 0:s.autoMix)||(null==s?void 0:s.autoMix),l={inviteSessionId:c,inviterRoomId:e,inviterUserId:t,inviterUserAutoMix:_,inviteeRoomId:this._mainRoomId,inviteeUserId:this._context.getCurrentId(),inviteeUserAutoMix:d},u=Object.assign(l,{inviterUserAutoMix:_}),h=i?Object.assign(l,{MultiRoomKey:`${e}|${this._mainRoomId}`,MultiRoomValue:JSON.stringify(u)}):l;!g(null==s?void 0:s.extra)&&Object.assign(h,{extra:s.extra});const R={agree:i,roomId:this._mainRoomId,inviteSessionId:c,inviteRoomId:e,inviteUserId:t,content:JSON.stringify(h),key:`${e}|${this._mainRoomId}`,value:JSON.stringify(l)},m=yield this._context.responseRoomPK(R);return m!==n.SUCCESS?(this._logger.error(S.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:m}),o),{code:m}):(this._logger.info(S.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.SUCCESSED}),o),this._PKInfo[e].inviteeUserAutoMix=d,{code:I.SUCCESS})}))}joinOtherRoom(e){return E(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();if(this._logger.info(S.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_T,JSON.stringify({roomId:e}),t),!r("roomId",e,a,!0))return this._logger.error(S.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> roomId"}),t),{code:I.PARAMS_ERROR};if(this._context.getConnectionStatus()!==o.CONNECTED)return this._logger.error(S.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.SIGNAL_DISCONNECTED,msg:"IM disconnected"}),t),{code:I.SIGNAL_DISCONNECTED};if(this._joinedPKRooms[e])return this._logger.warn(S.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:I.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),t),{code:I.REPERT_JOIN_ROOM};const i=Ko.VIDEO,n={extra:`{"roomId": "${this._mainRoomId}"}`},s=new Xo(this._context,this._runtime,e,this._service,this._initOptions,i,!1,!1,this._clientSessionId),{code:c}=yield s.__innerInit(ms.LIVE,void 0,i,n);return c!==I.SUCCESS?(this._logger.error(S.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.FAILED,code:c}),t),{code:c}):(this._joinedPKRooms[e]=s,yield this._onJoinedPKRoom(e,t),this._logger.info(S.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:O.SUCCESSED}),t),{room:s,code:I.SUCCESS,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()})}))}leaveOtherRoom(e,t){return E(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();return this._logger.info(S.L_APP_CALL_LEAVE_PK_ROOM_O,void 0,r),this._invoker.push(this.createLeaveOtherRoomCommand(e,t,r))}))}getPKInfo(e){return this._PKInfo[e]}getAllPKInfo(){return this._PKInfo}getJoinedPKRooms(){return this._joinedPKRooms}}!function(e){e[e.OPEN=1]="OPEN",e[e.STOP=2]="STOP"}($o||($o={}));class Qo extends ks{constructor(e,t){super(),Object.defineProperty(this,"cdnValues",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"enable",{enumerable:!0,configurable:!0,writable:!0,value:t})}get kind(){return ps.ENABLE_INNER_CDN}execute(e,t,r){return E(this,void 0,void 0,(function*(){const{logger:i,context:n}=e,{enable:s}=this;if(i.info(S.L_LIVING_ROOM_ENABLE_INNER_CDN_T,JSON.stringify({roomId:t.roomId,enable:s})),!t.isMainRoom)return i.error(S.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:O.FAILED,code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(!p(s))return i.error(S.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> enable"})),{code:I.PARAMS_ERROR};t.setCDNEnabel(s);const o={version:2,output:{inCDNModel:s?$o.OPEN:$o.STOP}},{code:a}=yield new xo(o,this.cdnValues).execute(e,t,r);if(a!==I.SUCCESS)return i.error(S.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:O.FAILED,code:a,msg:"signal error"})),{code:I.SIGNAL_ERROR};const c=t.getCDNUris();if(c&&c.broadcast!==Xs.SPREAD)return i.info(S.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:O.SUCCESSED,enable:s})),{code:I.SUCCESS};const{code:_}=yield co(n,t);return _===I.SUCCESS?(i.info(S.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:O.SUCCESSED,enable:s})),{code:I.SUCCESS}):(i.error(S.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:O.FAILED,code:_})),{code:_})}))}}!function(e){e[e.AnchorToViewer=1]="AnchorToViewer",e[e.ViewerToAnchor=2]="ViewerToAnchor"}(Wo||(Wo={}));class Zo extends ks{constructor(e,t){super(),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:t})}get kind(){return ps.RTC_IDENTITY_CHANGE}execute(e,t,r){var i;return E(this,void 0,void 0,(function*(){const{context:s}=e,{code:o,data:a}=yield s.rtcIdentityChange(t.roomId,Wo.ViewerToAnchor,this.livingType);if(o!==n.SUCCESS||!a)return{code:o};t.initWithRoomData(a,this.traceId);t.getResourcesByUserId(t.crtUserId).length>0&&r.push(new Vs);const c=null===(i=a.roomInfo.filter((e=>"cdn_uris"===e.key))[0])||void 0===i?void 0:i.value;return c&&t.setCDNUris(JSON.parse(c)[0]),{code:o,data:a}}))}}class Xo extends Bo{constructor(e,t,r,i,n,s,o,a,c){super(e,t,r,ms.LIVE,i,n,o,a,c),Object.defineProperty(this,"_livingType",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_mcuConfigBuilder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_roomPKHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._mcuConfigBuilder=new Ho(this._executeCtx,this._invoker,this._isValidResourceId.bind(this))}_initRoomPKHandler(e){if(this._store.isMainRoom){const t=((e,t)=>{const r={};return t.forEach((t=>{const i=JSON.parse(t.value),{inviterRoomId:n,inviteeRoomId:s}=i;r[e===n?s:n]=JSON.parse(t.value)})),r})(this._roomId,e.roomInfo);this._roomPKHandler=new qo(this._invoker,t,this._context,this._runtime,this._service,this._initOptions,this,super._registerPKMsgListener.bind(this),this._onJoinedPKRoom.bind(this),this._clientSessionId)}}__innerInit(e,t,i,n,s,o){const a=Object.create(null,{__innerInit:{get:()=>super.__innerInit}});return E(this,void 0,void 0,(function*(){if(!r("livingType",i,(e=>e===Ko.AUDIO||e===Ko.VIDEO)))return this._logger.error(S.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> livingType"}),o),{code:I.PARAMS_ERROR};const{code:c,data:_}=yield a.__innerInit.call(this,e,t,i,n,s,o);return c===I.SUCCESS&&_&&this._initRoomPKHandler(_),{code:c,data:_}}))}__innerInitByIdentityChange(e){return E(this,void 0,void 0,(function*(){const{code:t,data:r}=yield this._invoker.push(new Zo(this._livingType,e));return t===n.SUCCESS&&r?(this._initRoomPKHandler(r),this._initWithRoomData(r.offlineKickTime),this._logger.info(S.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:O.SUCCESSED,roomData:r}),e)):this._logger.error(S.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:O.FAILED,code:t}),e),t}))}publish(e){const t=Object.create(null,{publish:{get:()=>super.publish}});return E(this,void 0,void 0,(function*(){return this._store.isMainRoom?t.publish.call(this,e):(this._logger.error(S.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:O.FAILED,code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}))}unpublish(e){const t=Object.create(null,{unpublish:{get:()=>super.unpublish}});return E(this,void 0,void 0,(function*(){return this._store.isMainRoom?t.unpublish.call(this,e):(this._logger.error(S.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:O.FAILED,code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}))}_isValidResourceId(e){var t;const{userId:r}=Et(e),i=!!(null===(t=this._store.getResourcesByUserId(r))||void 0===t?void 0:t.find((t=>ft(t)===e)));let n=!1;const{code:s,roomPKHandler:o}=this.getRoomPKHandler();if(s!==I.SUCCESS||!o)return i;const a=o.getJoinedPKRooms(),c=[];return Object.values(a).forEach((e=>{c.push(...e.getRemoteTracks())})),n=c.some((t=>e===t.getTrackId())),i||n}getLivingType(){return this._livingType}getMCUConfigBuilder(){return this._store.isMainRoom?this._mcuConfigBuilder:(this._logger.error(S.L_LIVING_ROOM_GET_MCU_CONFIG_BUILDER_O,"the `getMCUConfigBuilder` is disabled in PK room"),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}enableInnerCDN(e){return E(this,void 0,void 0,(function*(){return this._invoker.push(new Qo(this._mcuConfigBuilder.__innerGetValues(),e))}))}_resourceHandle(e,t,r,i,n){const s=Object.create(null,{_resourceHandle:{get:()=>super._resourceHandle}});return E(this,void 0,void 0,(function*(){s._resourceHandle.call(this,e,t,r,i,n)}))}__getCDNEnable(){var e;return!!(null===(e=this._store.getCDNUris())||void 0===e?void 0:e.enableInnerCDN)}__getCDNPushMode(){var e;return null===(e=this._store.getCDNUris())||void 0===e?void 0:e.push_mode}_onJoinedPKRoom(e,t){return E(this,void 0,void 0,(function*(){this._invoker.push(new Yo(e,this._roomPKHandler,t))}))}_getPushOtherRoomsParams(){const e=[];if(!this.isMainRoom()||!this._roomPKHandler)return e;const t=this._roomPKHandler.getJoinedPKRooms();for(const r in t){const i=t[r].getSessionId(),n=this._roomPKHandler.getPKInfo(r);if(!n)continue;const{inviterUserAutoMix:s,inviteeUserAutoMix:o,inviterUserId:a}=n,c=this._context.getCurrentId()===a;e.push({roomId:r,sessionId:i,autoMix:c?!!s:!!o})}return e}getRoomPKHandler(){return this._store.isMainRoom?(this._logger.info(S.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:O.SUCCESSED})),{code:I.SUCCESS,roomPKHandler:this._roomPKHandler}):(this._logger.error(S.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:O.SUCCESSED,code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}_quitAllPKRoom(){return E(this,void 0,void 0,(function*(){const e=this._roomPKHandler.getJoinedPKRooms();for(const t in e)this._roomPKHandler.leaveOtherRoom(e[t]);this._logger.info(S.L_LIVING_ROOM_QUIT_ALL_PK_ROOM_O,JSON.stringify({status:O.SUCCESSED,roomIds:Object.keys(e)}))}))}isMainRoom(){return this._store.isMainRoom}}class ea extends Bo{constructor(e,t,r,i,n,s=ms.RTC,o=!1){super(e,t,r,s,i,n,!1,!1,Zn(),o)}}const ta=new class{constructor(){Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"locked",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"taskCount",{enumerable:!0,configurable:!0,writable:!0,value:0})}checkToStart(){return E(this,void 0,void 0,(function*(){if(0===this.queue.length||this.locked)return;this.locked=!0;const{resolve:e,task:t,reject:r}=this.queue.shift();let i;try{i=yield t(),e(i)}catch(e){r(e)}this.locked=!1,this.checkToStart()}))}push(e,t=""){const r=new Promise(((t,r)=>{this.queue.push({resolve:t,task:e,reject:r})}));return this.checkToStart(),r}},ra=(e,t="")=>ta.push(e,t);class ia{constructor(e,t,r){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_pc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_rtcToken",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_liveUrl",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_subTracks",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_subscribedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:Zn()}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_livingType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_subTiny",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_fromRetry",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._crtUserId=this._context.getCurrentId(),this._service=new rs(t,e,r.mediaServer),this._logger=this._context.logger,this._store=new xs(this._logger,this._clientSessionId,this._context.getAppkey(),this._crtUserId,this._crtUserId,ms.LIVE)}_getReqHeaders(e){return E(this,void 0,void 0,(function*(){const t=this._crtUserId;if(!this._rtcToken){const{code:r,data:i}=yield this._context.getRTCToken(t,ms.LIVE,e);if(r!==n.SUCCESS)return{code:I.SIGNAL_ERROR};this._rtcToken=i.rtcToken}return{code:I.SUCCESS,headers:{"App-Key":this._context.getAppkey(),UserId:this._crtUserId,RoomId:t,RoomType:ms.LIVE,Token:this._rtcToken,"Client-Session-Id":this._clientSessionId}}}))}_clearSubscribeInfo(){var e;this._liveUrl="",this._livingType=null,this._mediaType=null,this._subTiny=!1,this._subTracks.length=0,null===(e=this._pc)||void 0===e||e.destroy(),this._pc=null}_reTryExchange(){var e;return E(this,void 0,void 0,(function*(){this._fromRetry=!0;const{code:t}=yield this.subscribe(this._liveUrl,this._livingType,this._mediaType,this._subTiny);return t===I.SUCCESS&&(null===(e=this._pc)||void 0===e||e.clearReTryExchangeTimer()),{code:t}}))}subscribe(e,t,r,i=!1){return E(this,void 0,void 0,(function*(){return ra((()=>this.__subscribe(e,t,r,i)),"audience-client-sub")}))}__subscribe(e,t,r,i=!1){var n;return E(this,void 0,void 0,(function*(){this._logger.info(S.L_AUDIENCE_CLIENT_SUBSCRIBE_T,JSON.stringify({liveUrl:e,livingType:t,mediaType:r,subTiny:i}));const s=[];if(Pt(this._context.getNaviInfo()))return this._logger.error(S.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"})),{code:I.PACKAGE_ENVIRONMENT_ERROR,tracks:s};if(!this._fromRetry&&(null===(n=this._pc)||void 0===n||n.clearReTryExchangeTimer()),this._fromRetry=!1,!c(e))return this._logger.error(S.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:`params error -> liveUrl: ${e}`})),{code:I.PARAMS_ERROR,tracks:s};if(![Ko.AUDIO,Ko.VIDEO].includes(t))return this._logger.error(`livingType is invalid: ${t}`),this._logger.error(S.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:`params error -> livingType: ${t}`})),{code:I.PARAMS_ERROR,tracks:s};if(![Ve.AUDIO_ONLY,Ve.VIDEO_ONLY,Ve.AUDIO_VIDEO].includes(r))return this._logger.error(S.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:`params error -> -> mediaType: ${r}`})),{code:I.PARAMS_ERROR,tracks:s};if(this._liveUrl&&this._liveUrl!==e)return this._logger.error(S.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.BROADCAST_SUB_LIST_NOT_EMPTY,msg:"repeat subscribe"})),{code:I.BROADCAST_SUB_LIST_NOT_EMPTY,tracks:s};this._pc||(this._pc=new Ps(this._logger,this._reTryExchange.bind(this),this._crtUserId,this._store,void 0,!1),this._pc.on(Ps.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),this._pc.registerReportListener(this._reportListener),this._pc.__reportR3R4ToPolaris()),this._liveUrl=e;const{code:o,headers:a}=yield this._getReqHeaders(t);if(o!==I.SUCCESS)return this._logger.error(S.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:o,msg:"getRTCToken failed"})),{code:o,tracks:s};const _=`rc_mcu_${Date.now()}`,d="RongCloudRTC";0===this._subTracks.length&&(this._subTracks.push(new dt(this._logger,d,_),new lt(this._logger,d,_)),this._pc.updateSubRemoteTracks(this._subTracks.slice()));const l={sdp:yield this._pc.createOffer(!0),liveUrl:e,mediaType:r,simulcast:i?is.TINY:is.NORMAL,switchstream:!1},u=yield this._service.broadcastSubscribe(a,l);if(u.code!==I.SUCCESS)return this._logger.error(S.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:u.code})),{code:u.code,tracks:s};const h=u.data;if(h.resultCode!==I.SUCCESS)return this._logger.error(S.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:h.resultCode,msg:h.message})),{code:h.resultCode,tracks:s};this._livingType=t,this._mediaType=r,this._subTiny=i;const{sdp:p,subscribedList:g}=h;this._subscribedList=g;const R=[];return g.forEach((e=>{const{mediaType:t}=e,r=this._subTracks[t];R.push(r),r.__innerSetRemoteMuted(!0)})),this._pc.setRemoteAnswer(p.sdp),R&&this._updateTrackIdSSRCMap(p.sdp,R),this._logger.info(S.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:O.SUCCESSED,liveUrl:e})),{code:I.SUCCESS,tracks:R}}))}_updateTrackIdSSRCMap(e,t){t.forEach((t=>{const r=t.getTrackId(),{mediaType:i}=Et(r),{msid:n}=this._subscribedList.filter((e=>e.mediaType===i))[0],s=po(e,n,i);this._store.setTrackIdSSRCMap(Number(s),r)}))}unsubscribe(){return E(this,void 0,void 0,(function*(){return ra((()=>this.__unsubscribe()),"audience-client-unsub")}))}__unsubscribe(){var e;return E(this,void 0,void 0,(function*(){if(this._logger.info(S.L_AUDIENCE_CLIENT_UNSUBSCRIBE_T,JSON.stringify({liveUrl:this._liveUrl})),null===(e=this._pc)||void 0===e||e.clearReTryExchangeTimer(),!this._rtcToken||!this._liveUrl)return this._logger.warn(S.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:"",msg:"Address does not exist, without unsubscribe"})),{code:I.SUCCESS};const{headers:t}=yield this._getReqHeaders(),{code:r}=yield this._service.broadcastExit(t);return r!==I.SUCCESS?this._logger.error(S.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:r})):(this._logger.info(S.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:O.SUCCESSED,liveUrl:this._liveUrl})),this._subscribedList=[]),this._clearSubscribeInfo(),{code:r}}))}registerReportListener(e){this._reportListener=e}registerTrackEventListener(e){this._appListener=e}_onTrackReady(e){var t,r;const{track:i}=e.receiver,n="audio"===i.kind?Ve.AUDIO_ONLY:Ve.VIDEO_ONLY,s=this._subTracks[n];s.__innerSetMediaStreamTrack(i);try{this._logger.info(S.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,`trackId: ${s.getTrackId()}`),null===(r=null===(t=this._appListener)||void 0===t?void 0:t.onTrackReady)||void 0===r||r.call(t,s)}catch(e){this._logger.error(S.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,JSON.stringify(e))}}}var na,sa;!function(e){e.RTMP="rtmp",e.FLV="flv",e.HLS="hls"}(na||(na={})),function(e){e[e.NOT_HTTPS=0]="NOT_HTTPS",e[e.HTTPS=1]="HTTPS"}(sa||(sa={}));const oa=Object.assign(Object.assign({},Ct(xe.W176_H144)),{frameRate:Lt(Be.FPS_15)});class aa{constructor(e,t,r,i,n,s,o=Zn()){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,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_joinResData",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_roomAnchorList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_roomRes",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_roomAnchorRes",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_remoteTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_pc",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subscribedList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_sessionId",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_audioLevelReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_CDNUris",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isPulling",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_pullTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_trackMediaMap",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._logger=this._context.logger,this._crtUserId=this._context.getCurrentId(),this._polarisReport=new Mo(this._context,this._runtime,this._roomId,this,Do.Audience),this._reportMediaActionLogger=new ko(this._logger,this._roomId,this._clientSessionId,this._crtUserId),this._service=new rs(this._runtime,this._context,this._initOptions.mediaServer,this._initOptions.timeout);const a=this._store=new xs(this._logger,o,e.getAppkey(),i,this._crtUserId,ms.LIVE),c=this._pc=new Ps(this._logger,this._reTryExchange.bind(this),this._crtUserId,a,this._polarisReport,!0);this._audioLevelReport=new Us(this._store,c),c.on(Ps.__INNER_AUDIOLEVEL_CHANGE__,this._audioLevelReport.audioLevelReport,this._audioLevelReport),this._polarisReport.sendR1(),this._context.registerRTCSignalListener((e=>E(this,void 0,void 0,(function*(){const{time:t,type:r,roomId:i}=this._context.decodeRtcNotify(e);1===r&&this._startPull(i,t)})))),this._setInitData()}_startPull(e,t){return E(this,void 0,void 0,(function*(){if(this._isPulling)return;this._isPulling=!0;if(this._pullTime>t)return void(this._isPulling=!1);const r=this._logger.createTraceId();this._logger.info(S.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T,`pullTime: ${this._pullTime}`,r);const{code:i,data:s}=yield this._context.pullRTCRoomEntry(e);if(i===n.SUCCESS){this._isPulling=!1,this._pullTime=(null==s?void 0:s.syncTime)||0;const t=(null==s?void 0:s.kvEntries)||[];this._logger.info(S.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,`status: ${O.SUCCESSED}, kvEntries: ${JSON.stringify(t)}`,r),this.singalDataChange(t,e,r)}this._logger.info(S.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,`status: ${O.FAILED}, code: ${i}`,r)}))}_setInitData(){const{sessionId:e,remoteUserIds:t,remoteRTCUris:r,remoteMUCUris:i,remoteTracks:n,CDNUris:s}=((e,t,r)=>{const i=t.filter((e=>"RC_RTC_SESSIONID"===e.key))[0],n=i?i.value:"",s=t.filter((e=>"RC_ANCHOR_LIST"===e.key)).map((e=>JSON.parse(e.value||"[]")))[0],o=t.filter((e=>e.key.includes("RC_RES_"))).map((e=>JSON.parse(e.value||"{}"))),a=o.length?JSON.parse(o[0].mcu_uris||"[]"):[],c=[];a.forEach((t=>{const{mediaType:i,tag:n}=t,s=i===Ve.AUDIO_ONLY?new dt(r,n,"",e):new lt(r,n,"",e);c.push(s)}));const _=[],d=[];o.forEach((e=>{const t=JSON.parse(e.uris||"[]");_.push(...t),t.forEach((e=>{const{mediaType:t,tag:i,msid:n}=e,s=n.split("_");s.pop();const o=s.join("_"),a=t===Ve.AUDIO_ONLY?new dt(r,i,o):new lt(r,i,o);d.push(a)}))}));const l=t.filter((e=>"RC_CDN"===e.key)).map((e=>{const t=JSON.parse(e.value||"[]");return JSON.parse(t.cdn_uris)[0]}))[0];return{sessionId:n,remoteUserIds:s||[],remoteRTCUris:_,remoteMUCUris:a,remoteRTCTracks:d,remoteMCUTracks:c,remoteTracks:[...d,...c],CDNUris:l||{}}})(this._roomId,this._joinResData.kvEntries,this._logger);this._sessionId=e,this._roomAnchorList=t,n.forEach((e=>{this._remoteTracks[e.getTrackId()]=e})),this._CDNUris=s,r.forEach((e=>{const t=e.msid.split("_")[0];this._roomAnchorRes[t]?this._roomAnchorRes[t].push(e):this._roomAnchorRes[t]=[e];const{ssrc:r,resourceId:i}=JSON.parse(e.uri);this._store.setTrackIdSSRCMap(r,i)})),i.forEach((e=>{const{mediaType:t,tag:r}=e,i=[this._roomId,r,t].join("_");this._roomRes[i]=e;const{ssrc:n}=JSON.parse(e.uri);this._store.setTrackIdSSRCMap(n,i)})),r.forEach((e=>{const t=ft(e);this._roomRes[t]=e}))}_assertRoomDestroyed(){if(this._destroyed)return I.ROOM_HAS_BEEN_DESTROYED}singalDataChange(e,t,r){var i;if(t!==this._roomId)return void this._logger.error(S.L_AUDIENCE_LIVING_ROOM_SINGAL_DATA_CHANGE_P,JSON.stringify({status:O.FAILED,msg:`roomId inconsistency -> params roomId:${t}, current roomId:${this._roomId}`}),r);const n=[],s=null===(i=e.filter((e=>"RC_CDN"===e.key))[0])||void 0===i?void 0:i.value;s&&this._diffCDNUris(JSON.parse(JSON.parse(s).cdn_uris)[0],r),e.forEach((e=>{const{key:t,value:i,uid:s}=e;if(-1!==t.indexOf("RC_RES_")){const e=JSON.parse(i||"{}"),t=JSON.parse(e.mcu_uris||"[]"),o=JSON.parse(e.uris||"[]");return n.push(...t),void this._diffAnchorResource(o,s,r)}if("RC_ANCHOR_LIST"===t){const e=JSON.parse(i||"[]");this._diffAnchorList(e,r)}})),this._diffRoomResource(n,r)}_diffAnchorList(e,t){const r=e.filter((e=>this._roomAnchorList.indexOf(e)<0)),i=this._roomAnchorList.filter((t=>e.indexOf(t)<0));r.length>0&&this._handleNewJoinedAnchor(r,t),i.length>0&&this._handleLeftedAnchor(i,t)}_handleNewJoinedAnchor(e,t){this._roomAnchorList.push(...e),this._logger.info(S.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorJoin",list:e}),t),this._callAppListener("onAnchorJoin",e)}_handleLeftedAnchor(e,t){return E(this,void 0,void 0,(function*(){this._roomAnchorList=this._roomAnchorList.filter((t=>!e.includes(t)));const r=[];e.forEach((e=>{r.push(...this.getRemoteTracksByUserId(e)),delete this._roomAnchorRes[e]})),r.length&&(yield this.unsubscribe(r),r.forEach((e=>delete this._remoteTracks[e.getTrackId()]))),this._logger.info(S.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorLeave",list:e}),t),this._callAppListener("onAnchorLeave",e)}))}_diffRoomResource(e,t){return E(this,void 0,void 0,(function*(){const r=[],i=[],n=[];e.forEach((e=>{const t=ft(e),{tag:i,mediaType:s}=Et(t),o=[this._roomId,i,s].join("_"),{ssrc:a}=JSON.parse(e.uri);if(this._store.setTrackIdSSRCMap(a,o),!this._remoteTracks[o]){const t=s===Ve.AUDIO_ONLY?new dt(this._logger,i,"",this._roomId):new lt(this._logger,i,"",this._roomId);r.push(t),this._remoteTracks[o]=t,this._roomRes[t.getTrackId()]=e}n.push(o)})),Object.keys(this._remoteTracks).forEach((e=>{n.indexOf(e)<0&&this._remoteTracks[e].isMCUTrack()&&i.push(this._remoteTracks[e])})),r.length>0&&(this._logger.info(S.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackPublish",trackIds:r.map((e=>e.getTrackId()))}),t),this._callAppListener("onTrackPublish",r)),i.length>0&&this._onUserUnpublish(i,"onTrackUnpublish",t)}))}_dealPublished(e,t,r){return E(this,void 0,void 0,(function*(){const i=e.map(ft),n=[],s=[];if(t.forEach((t=>{const r=ft(t),o=i.indexOf(r),{userId:a,tag:c,mediaType:_}=Et(r),{ssrc:d}=JSON.parse(t.uri);this._store.setTrackIdSSRCMap(d,r),o>-1?e[o]=t:e.push(t);let l=this._remoteTracks[r];this._roomRes[r]=t,l?l.isSubscribed()&&n.push(l):(l=_===Ve.AUDIO_ONLY?new dt(this._logger,c,a):new lt(this._logger,c,a),this._remoteTracks[r]=l,s.push(l)),l.__innerSetRemoteMuted(0===t.state)})),n.length){const e=n.map((e=>e.getTrackId())),{code:t}=yield ra((()=>this._subscribeHandle(n,!0)));t!==I.SUCCESS&&this._logger.error(S.L_RESUB_REPUB_RES_R,JSON.stringify({status:O.FAILED,trackIds:e,code:t}))}this._logger.info(S.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorTrackPublish",trackIds:s.map((e=>e.getTrackId()))}),r),this._callAppListener("onAnchorTrackPublish",s)}))}_dealUnpublished(e,t,r){return E(this,void 0,void 0,(function*(){const i=t.map(ft);for(let t=e.length-1;t>=0;t-=1){const r=e[t];i.includes(ft(r))&&e.splice(t,1)}const n=t.map((e=>{const t=ft(e);return this._remoteTracks[t]}));yield this._onUserUnpublish(n,"onAnchorTrackUnpublish",r)}))}_dealModified(e,t,r){const i=e.map(ft);for(const n of t){const t=ft(n);e[i.indexOf(t)].state=n.state;const s=this._remoteTracks[t];s.__innerSetRemoteMuted(0===n.state);const o=s.isAudioTrack()?"onAudioMuteChange":"onVideoMuteChange";this._logger.info(S.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:o,trackId:s.getTrackId()}),r),this._callAppListener(o,s)}}_diffAnchorResource(e,t,r){return E(this,void 0,void 0,(function*(){const i=this._roomAnchorRes[t]||(this._roomAnchorRes[t]=[]),{publishedList:n,unpublishedList:s,modifiedList:o}=Ot(i,e);n.length&&(yield this._dealPublished(i,n,r)),s.length&&(yield this._dealUnpublished(i,s,r)),o.length&&this._dealModified(i,o,r)}))}_onUserUnpublish(e,t,r){return E(this,void 0,void 0,(function*(){yield this.unsubscribe(e),e.forEach((e=>{this._subscribedList=this._subscribedList.filter((t=>t.track.getTrackId()!==e.getTrackId())),delete this._roomRes[e.getTrackId()],e.__innerDestroy(),delete this._remoteTracks[e.getTrackId()]})),this._logger.info(S.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:t,trackIds:e.map((e=>e.getTrackId()))}),r),this._callAppListener(t,e)}))}_callAppListener(e,...t){var r;const i=null===(r=this._appListener)||void 0===r?void 0:r[e];if(i)try{i(...t)}catch(e){this._logger.error(S.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify(e))}}_reTryExchange(){return E(this,void 0,void 0,(function*(){return ra((()=>E(this,void 0,void 0,(function*(){var e;const{reqBody:t}=yield this._createSubscribeParams(this._subscribedList,{},!0),r=yield this._exchangeHandle(t);if(r.code!==I.SUCCESS)return{code:r.code};const{sdp:i,resultCode:n}=r.data;if(n!==I.SUCCESS)return{code:n};this._pc.clearReTryExchangeTimer();const s=this._subscribedList.filter((e=>e.track.isMCUTrack()));if(s.length>0){const t=s[0].track.getTrackId(),r=null===(e=this._roomRes[t])||void 0===e?void 0:e.msid,n=[this._roomId,"RongCloudRTC"].join("_");i.sdp=i.sdp.replace(new RegExp(r,"g"),n)}return{code:yield this._pc.setRemoteAnswer(i.sdp)}}))),"audience-retry-exchange")}))}_createSubscribeParams(e,t,r){return E(this,void 0,void 0,(function*(){const i=yield this._pc.createOffer(r),n={resolutionInfo:[]},s={min:0,max:0};Object.keys(t).forEach((e=>{const{mediaStream:r,tinyStream:o}=t[e];[r,o].forEach(((t,r)=>{var o;const a=1===r?[e,"tiny"].join("_"):e;i.sdp=null===(o=i.sdp)||void 0===o?void 0:o.replace(new RegExp(t.id,"g"),a);const c=t.getVideoTracks()[0];if(!c)return;const _=0===r,{width:d,height:l,frameRate:u}=_?Rt(c):oa;n.resolutionInfo.push({trackId:c.id,simulcast:_?is.NORMAL:is.TINY,resolution:`${d}x${l}`});const h=Je(d,l),p=He(u);s.min+=h.minBitrate*p,s.max+=h.maxBitrate*p}))}));return{reqBody:{sdp:i,switchstream:!1,newVersionFlag:!0,subscribeList:e.map((e=>({simulcast:e.subTiny?is.TINY:is.NORMAL,resolution:"",uri:this._roomRes[e.track.getTrackId()].uri})))},dynamicBitrate:s,offer:i}}))}_subscribeHandle(e,t=!1,i=!1){return E(this,void 0,void 0,(function*(){const n=Date.now(),s=i?eo.SUB:void 0,o=this._logger.createTraceId();this._logger.info(S.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:e.map(kt),forceReq:t}),o);if(this._assertRoomDestroyed())return this._logger.error(S.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),o),this._reportPubOrSubQualityData(n,e,I.ROOM_HAS_BEEN_DESTROYED,s),{code:I.ROOM_HAS_BEEN_DESTROYED};if(!r("tracks",e,(()=>_(e)&&e.length>0&&e.every((e=>e instanceof _t||e.track instanceof _t))),!0))return this._logger.error(S.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> tracks"}),o),this._reportPubOrSubQualityData(n,e,I.PARAMS_ERROR,s),{code:I.PARAMS_ERROR};this._pc.__reportR3R4ToPolaris(),this._pc.registerReportListener(this._reportListener),this._addPeerCEvent();const a=this._subscribedList.map((e=>Object.assign({},e))),c=e.map((e=>e instanceof _t?{track:e}:e)),d=[];return c.forEach((e=>{const t=e.track.getTrackId();d.push(t);const r=a.find((e=>e.track.getTrackId()===t));r&&r.subTiny===e.subTiny||(r?r.subTiny=e.subTiny:a.push(e))})),this._polarisReport.sendR2(Qs.SUBSCRIBE,Zs.BEGIN,d),this._updateSubListHandle(a,o,n,s,!0)}))}_addPeerCEvent(){this._pc.on(Ps.__INNER_EVENT_TRACK_READY__,(e=>{const t=e.streams[0].id,{track:r}=e.receiver,i=[t,"audio"===r.kind?Ve.AUDIO_ONLY:Ve.VIDEO_ONLY].join("_"),n=this._remoteTracks[i];n?(n.__innerSetMediaStreamTrack(r),this._logger.info(S.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackReady",trackId:n.getTrackId()})),this._callAppListener("onTrackReady",n)):this._logger.warn(S.L_AUDIENCE_LIVING_ROOM_ONTRACKREADY_O,`cannot found RCRemoteTrack: ${r.id}`)})),this._pc.once(Ps.__INNER_ICE_CONNECTED__,(()=>{this._reportMediaActionLogger.reportIceFirstConnectData("sub")}),this),this._pc.on(Ps.__INNER_ICE_STATE_CHANGE__,(e=>{const{status:t,time:r,iceCandidatePair:i}=e;i&&this._reportMediaActionLogger.recordQualityIceStatusData(i,t,r)}))}_getReqHeaders(){const e=this._crtUserId;return{"App-Key":this._context.getAppkey(),RoomId:e,Token:this._joinResData.token,RoomType:ms.LIVE,UserId:e,"Session-Id":this._sessionId,"Client-Session-Id":this._clientSessionId}}_exchangeHandle(e){return this._service.broadcastSubscribe(this._getReqHeaders(),e)}_dealSubscribeResult(e,t,r){const i=null==t?void 0:t.map((e=>`${e.msid}_${e.mediaType}`)),n=e.filter((e=>{if(e.track.isMCUTrack()){const t=this._roomRes[e.track.getTrackId()],r=`${t.msid}_${t.mediaType}`;return i.includes(r)}return null==i?void 0:i.includes(e.track.getTrackId())})),s=null==n?void 0:n.map((e=>`${e.track.getTrackId()}`)),o=e.filter((e=>!(null==s?void 0:s.includes(e.track.getTrackId()))));for(const e in this._remoteTracks){const t=n.some((t=>t.track.getTrackId()===e));this._remoteTracks[e].__innerSetSubscribed(t)}return this._subscribedList.splice(0,this._subscribedList.length,...n),this._logger.info(S.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:O.SUCCESSED,subSuccessTrackIds:i,failedList:o}),r),o}_getParams(e){let t=e.map((e=>e instanceof _t?{track:e}:Object.assign({},e)));const r={};return t=t.filter((e=>{const t=e.track.getTrackId();return!r[t]&&(r[t]=!0,!0)})).map((e=>Object.assign({},e))),t}_reportPubOrSubQualityData(e,t,r,i){i&&this._reportMediaActionLogger.reportPubOrSubQualityData(i,e,t,r,this._trackMediaMap)}_updateSubListHandle(e,t,r,i,n=!1){var s;return E(this,void 0,void 0,(function*(){this._logger.info(S.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_T,JSON.stringify({trackIds:e.map(kt),forceReq:n}),t);const o=this._getParams(e),a=this._subscribedList.map((e=>Object.assign({},e)));if(!n&&!go(o,a))return this._logger.info(S.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:O.SUCCESSED,msg:"repeat subscribe"}),t),{code:I.SUCCESS};this._pc.clearReTryExchangeTimer(),this._pc.updateSubRemoteTracks(o.map((e=>e.track)));const{reqBody:c}=yield this._createSubscribeParams(o,{},!1),_=yield this._exchangeHandle(c);if(a.length){const e=[];a.forEach((t=>{e.push(t.track.getTrackId())})),null===(s=this._pc.reportParser)||void 0===s||s.clearLatestPacketsRecv(e)}if(e.forEach((e=>{const t=e instanceof _t?e.getTrackId():e.track.getTrackId();this._trackMediaMap[t]=_.qualityMsList||[]})),_.code!==I.SUCCESS)return this._reportPubOrSubQualityData(r,e,_.code,i),this._logger.error(S.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:O.FAILED,code:_.code}),t),{code:_.code};const{sdp:d,resultCode:l,message:u,subscribedList:h}=_.data;if(l!==I.SUCCESS)return this._reportPubOrSubQualityData(r,e,l,i),this._logger.error(S.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:O.FAILED,code:l,msg:u}),t),{code:l};o.forEach((e=>{const{track:t}=e;if(t.isMCUTrack()){const e=this._roomRes[t.getTrackId()].msid,{tag:r,userId:i}=Et(t.getTrackId()),n=[i,r].join("_");d.sdp=d.sdp.replace(new RegExp(e,"g"),n)}}));const p=yield this._pc.setRemoteAnswer(d.sdp);if(this._reportPubOrSubQualityData(r,e,p,i),p!==I.SUCCESS)return this._logger.error(S.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:O.FAILED,code:p,msg:"set remote answer error"}),t),{code:p};const g=this._dealSubscribeResult(o,h,t);return g.length?{code:I.SUCCESS,failedList:g}:{code:I.SUCCESS}}))}_diffCDNUris(e,t){return E(this,void 0,void 0,(function*(){if(this._CDNUris.url&&!e.url)return this._logger.info(S.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCDNInfoDisable"}),t),this._callAppListener("onCDNInfoDisable"),void(this._CDNUris=e);(!this._CDNUris||!this._CDNUris.url&&e.url)&&(this._logger.info(S.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCDNInfoEnable",resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`}),t),this._callAppListener("onCDNInfoEnable",{resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`}));const r=this._CDNUris.w&&e.w&&this._CDNUris.w!==e.w,i=this._CDNUris.h&&e.h&&this._CDNUris.h!==e.h,n=this._CDNUris.fps&&e.fps&&this._CDNUris.fps!==e.fps;(r||i||n)&&(this._logger.info(S.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCDNInfoChange",resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`}),t),this._callAppListener("onCDNInfoChange",{resolution:`W${e.w}_H${e.h}`,fps:`FPS_${e.fps}`})),this._CDNUris=e}))}_getCDNPlayUrl(e,t){return E(this,void 0,void 0,(function*(){const{w:r,h:i,fps:n}=e,s=this._initOptions.pullInnerCDNProtocol||na.FLV,o=this._initOptions.pullInnerCDNUseHttps===sa.NOT_HTTPS?sa.NOT_HTTPS:sa.HTTPS;if(!this._CDNUris.url)return this._logger.error(S.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:O.FAILED,code:I.CDN_RESOURCE_IS_EMPTY,msg:"cdn_uris url is empty, the anchor need to open or push CDN"}),t),{code:I.CDN_RESOURCE_IS_EMPTY};const a={"App-Key":this._context.getAppkey(),Token:this._joinResData.token,RoomId:this.getRoomId(),UserId:this._crtUserId,SessionId:this.getSessionId()},c=[],{w:_=0,h:d=1}=this._CDNUris;_/d>1?(r&&c.push(`w=${r}`),i&&c.push(`h=${i}`)):(r&&c.push(`h=${r}`),i&&c.push(`w=${i}`)),n&&c.push(`fps=${n}`),c.push(`kind=${s}`),c.push(`is_https=${o}`);const l=c.join("&");let u=`${this._CDNUris.url}?`;l&&(u+=l);const{code:h,res:p}=yield this._service.getCDNResourceInfo(a,u,t);return h!==I.SUCCESS?{code:h}:{code:h,CDNPlayUrl:null==p?void 0:p.data.pull_url}}))}getCDNPlayUrl(e,t){return E(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();if(this._logger.info(S.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_T,JSON.stringify({resolution:e,fps:t}),r),e&&!vt(e))return this._logger.error(S.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> resolution"}),r),{code:I.PARAMS_ERROR};if(t&&!bt(t))return this._logger.error(S.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> fps"}),r),{code:I.PARAMS_ERROR};const{width:i,height:n}=e?Ct(e):{width:null,height:null},s=t?Lt(t):null,o={};return i&&(o.w=i),n&&(o.h=n),s&&(o.fps=s),this._getCDNPlayUrl(o,r)}))}subscribe(e){return E(this,void 0,void 0,(function*(){return ra((()=>this._subscribeHandle(e,!1,!0)),"audience-sub")}))}__unsubscribe(e){return E(this,void 0,void 0,(function*(){const t=Date.now(),i=eo.UNSUB,n=this._logger.createTraceId();this._logger.info(S.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_T,JSON.stringify({trackIds:e.map((e=>e.getTrackId()))}),n);if(this._assertRoomDestroyed())return this._logger.error(S.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),n),{code:I.ROOM_HAS_BEEN_DESTROYED};if(!r("tracks",e,(()=>_(e)&&e.length>0&&e.every((e=>e instanceof _t))),!0))return this._logger.error(S.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> tracks"}),n),{code:I.PARAMS_ERROR};const s=this._subscribedList.map((e=>Object.assign({},e))).filter((t=>e.every((e=>e.getTrackId()!==t.track.getTrackId()))));return this._polarisReport.sendR2(Qs.SUBSCRIBE,Zs.END,e.map((e=>e.getTrackId()))),this._updateSubListHandle(s,n,t,i,!1)}))}unsubscribe(e){return E(this,void 0,void 0,(function*(){return ra((()=>this.__unsubscribe(e)),"audience-unsub")}))}__destroy(e){var t;return E(this,void 0,void 0,(function*(){this._destroyed||(this._destroyed=!0,e&&(yield this._context.quitLivingRoomAsAudience(this._roomId)),yield this._service.broadcastExit(this._getReqHeaders()),null===(t=this._pc)||void 0===t||t.destroy(),this._context.registerRTCSignalListener())}))}getRemoteTrack(e){return this._remoteTracks[e]}getLocalTrack(e){return{}}__onReconnected(){return E(this,void 0,void 0,(function*(){const e=this._logger.createTraceId();this._logger.info(S.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_T,void 0,e);const{code:t}=yield this._context.joinLivingRoomAsAudience(this._roomId,ms.LIVE);t!==n.SUCCESS&&this._logger.error(S.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,`status: ${O.FAILED}`,e),this._logger.info(S.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,`status: ${O.SUCCESSED}`,e)}))}registerRoomEventListener(e){this._appListener=e}onAudioLevelChange(e,t){this._logger.info(S.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O),this._audioLevelReport.onAudioLevelChange(e)}registerReportListener(e){this._reportListener=e}getRoomId(){return this._roomId}getCrtUserId(){return this._crtUserId}getSessionId(){return this._sessionId}getRemoteUserIds(){return this._roomAnchorList}getRemoteTracksByUserId(e){const t=[];for(const r in this._remoteTracks){const i=this._remoteTracks[r];i.getUserId()===e&&t.push(i)}return t}getRemoteTracks(){const e=[],t=[];for(const e in this._remoteTracks){if(2===t.length)break;const r=this._remoteTracks[e];r.isMCUTrack()&&t.push(r)}return this._roomAnchorList.forEach((t=>{e.push(...this.getRemoteTracksByUserId(t))})),[...t,...e]}getRemoteRTCTracks(){const e=[];for(const t in this._remoteTracks){const r=this._remoteTracks[t];r.isMCUTrack()||e.push(r)}return e}getRemoteMCUTracks(){const e=[];for(const t in this._remoteTracks){const r=this._remoteTracks[t];r.isMCUTrack()&&e.push(r)}return e}getCDNInfo(){return this._CDNUris.w?{resolution:`W${this._CDNUris.w}_H${this._CDNUris.h}`,fps:`FPS_${this._CDNUris.fps}`,CDNEnable:this._CDNUris.enableInnerCDN}:{CDNEnable:!1}}getClientSessionId(){return this._clientSessionId}}var ca,_a;!function(e){e[e.AUTOMATIC=0]="AUTOMATIC",e[e.MANUAL=1]="MANUAL"}(ca||(ca={}));class da{constructor(e){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_isElectron",{enumerable:!0,configurable:!0,writable:!0,value:/Electron/.test(navigator.userAgent)}),this._logger=e.logger}_getMediaStream(e,t="getUserMedia"){return E(this,void 0,void 0,(function*(){try{const r=this.setConstraintsConfig(e),i=yield navigator.mediaDevices[t](r);return{code:I.SUCCESS,stream:i}}catch(e){if(this._logger.error(S.L_GET_MEDIA_STREAM_E,JSON.stringify({name:e.name,message:e.message})),"Permission denied"===e.message)return{code:I.BROWSER_PERMISSION_DENIED};if("Permission denied by system"===e.message)return{code:I.SYSTEM_PERMISSION_DENIED}}return{code:"getUserMedia"===t?I.GET_USER_MEDIA_FAILED:I.GET_DISPLAY_MEDIA_FAILED}}))}_getMediaStreamErrorReason(e){let t="";return e===I.BROWSER_PERMISSION_DENIED&&(t="Permission denied"),e===I.SYSTEM_PERMISSION_DENIED&&(t="Permission denied by system"),t}setConstraintsConfig(e){var t,r;if((null==e?void 0:e.audio)&&!this._isElectron){"boolean"==typeof e.audio&&(e.audio={});const i=null===(r=(t=navigator.mediaDevices).getSupportedConstraints)||void 0===r?void 0:r.call(t);(null==i?void 0:i.noiseSuppression)&&(e.audio.noiseSuppression=!!i.noiseSuppression),(null==i?void 0:i.autoGainControl)&&(e.audio.autoGainControl=!!i.autoGainControl),(null==i?void 0:i.echoCancellation)&&(e.audio.echoCancellation=!!i.echoCancellation),this._logger.info(S.L_SET_AUDIO_CONSTRAINTS_O,`browser supported -> ${JSON.stringify(i)}`)}return e}createMicrophoneAudioTrack(e="RongCloudRTC",t){return E(this,void 0,void 0,(function*(){if(!pt(e))return this._logger.error(S.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return this._logger.error(S.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID};const{stream:i,code:n}=yield this._getMediaStream({audio:{deviceId:null==t?void 0:t.micphoneId,sampleRate:null==t?void 0:t.sampleRate,noiseSuppression:null==t?void 0:t.noiseSuppression,echoCancellation:null==t?void 0:t.echoCancellation,autoGainControl:null==t?void 0:t.autoGainControl}});if(n!==I.SUCCESS)return this._logger.error(S.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:O.FAILED,code:n,msg:this._getMediaStreamErrorReason(n)})),{code:n};const s=i.getAudioTracks()[0],o=new st(this._logger,e,r,s);return this._logger.info(S.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:O.SUCCESSED,trackId:o.getTrackId()})),{code:n,track:o}}))}createCameraVideoTrack(e="RongCloudRTC",t){return E(this,void 0,void 0,(function*(){if(!pt(e))return this._logger.error(S.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS};const r=this._context.getCurrentId();if(!r)return this._logger.error(S.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID};const i=vt(null==t?void 0:t.resolution)?t.resolution:xe.W640_H480,{width:n,height:s}=Ct(i),{stream:o,code:a}=yield this._getMediaStream({video:{deviceId:null==t?void 0:t.cameraId,frameRate:Lt((null==t?void 0:t.frameRate)||Be.FPS_15),width:{ideal:n,max:n},height:{ideal:s,max:s},facingMode:null==t?void 0:t.faceMode}});if(a!==I.SUCCESS)return this._logger.error(S.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,code:a,msg:this._getMediaStreamErrorReason(a)})),{code:a};const c=o.getVideoTracks()[0];yield this._applyVideoAspectRatio(c,n,s);const _=new ot(this._logger,e,r,c);return this._logger.info(S.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:O.SUCCESSED,trackId:_.getTrackId()})),{code:a,track:_}}))}createMicrophoneAndCameraTracks(e="RongCloudRTC",t){var r,i,n,s;return E(this,void 0,void 0,(function*(){const o=[];if(!pt(e))return this._logger.error(S.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS,tracks:o};const a=this._context.getCurrentId();if(!a)return this._logger.error(S.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID,tracks:o};const c=vt(null===(r=null==t?void 0:t.video)||void 0===r?void 0:r.resolution)?t.video.resolution:xe.W640_H480,{width:_,height:d}=Ct(c),l=null==t?void 0:t.audio,{stream:u,code:h}=yield this._getMediaStream({video:{deviceId:null===(i=null==t?void 0:t.video)||void 0===i?void 0:i.cameraId,frameRate:Lt((null===(n=null==t?void 0:t.video)||void 0===n?void 0:n.frameRate)||Be.FPS_15),width:{ideal:_,max:_},height:{ideal:d,max:d},facingMode:null===(s=null==t?void 0:t.video)||void 0===s?void 0:s.faceMode},audio:{deviceId:null==l?void 0:l.micphoneId,sampleRate:null==l?void 0:l.sampleRate,noiseSuppression:null==l?void 0:l.noiseSuppression,echoCancellation:null==l?void 0:l.echoCancellation,autoGainControl:null==l?void 0:l.autoGainControl}});if(h!==I.SUCCESS)return this._logger.error(S.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:O.FAILED,code:h,msg:this._getMediaStreamErrorReason(h)})),{code:h,tracks:o};const p=u.getTracks();for(let t=0;t<p.length;t++){const r=p[t];"video"===r.kind?(yield this._applyVideoAspectRatio(r,_,d),o.push(new ot(this._logger,e,a,r))):o.unshift(new st(this._logger,e,a,r))}return this._logger.info(S.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:O.SUCCESSED,trackIds:o.map((e=>e.getTrackId()))})),{code:h,tracks:o}}))}createScreenVideoTrack(e="screenshare",t){return E(this,void 0,void 0,(function*(){const r=yield this._createScreenTracks(e,!1,S.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,t);return r.code===I.SUCCESS?{code:r.code,track:r.tracks[0]}:r}))}createScreenWithAudioTracks(e="screenshare",t){return E(this,void 0,void 0,(function*(){return this._createScreenTracks(e,!0,S.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_AND_AUDIO_TRACKS_O,t)}))}_createScreenTracks(e,t,r,i){return E(this,void 0,void 0,(function*(){if(!pt(e))return this._logger.error(r,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS};const n=this._context.getCurrentId();if(!n)return this._logger.error(r,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID};if(!At())return this._logger.error(S.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.BROWSER_NOT_SUPPORT,msg:"browser not support"})),{code:I.BROWSER_NOT_SUPPORT};const s=/macintosh|mac os x/i.test(navigator.userAgent),o=(!this._isElectron||!s)&&t,a=vt(null==i?void 0:i.resolution)?i.resolution:xe.W1280_H720,{stream:c,code:_}=this._isElectron?yield this._createElectronScreenStream(t,r,a,null==i?void 0:i.chromeMediaSourceId):yield this._createWebScreenStream(t,a,null==i?void 0:i.frameRate);if(_!==I.SUCCESS)return this._logger.error(r,JSON.stringify({status:O.FAILED,code:_,msg:this._getMediaStreamErrorReason(_)})),{code:_};const d=c.getVideoTracks()[0],l=[new at(this._logger,e,n,d)];if(o){const t=c.getAudioTracks()[0];t&&l.push(new ct(this._logger,e,n,t))}return this._logger.info(r,JSON.stringify({status:O.SUCCESSED,trackIds:l.map((e=>e.getTrackId()))})),{code:_,tracks:l}}))}_createElectronScreenStream(e,t,r,i){var n,s;return E(this,void 0,void 0,(function*(){const o=/macintosh|mac os x/i.test(navigator.userAgent);this._isElectron&&o&&e&&this._logger.warn(t,JSON.stringify({status:O.INFO,code:I.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO,msg:"mac in electron not support screen share with audio"}));const a=(!this._isElectron||!o)&&e;if(this._isElectron&&!g(i)&&!c(i))return this._logger.error(t,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> options.chromeMediaSourceId type is string"})),{code:I.PARAMS_ERROR};const{width:_,height:d}=Ct(r),l={mandatory:{chromeMediaSourceId:i,chromeMediaSource:"desktop",minWidth:_,maxWidth:_,minHeight:d,maxHeight:d}};!i&&this._isElectron&&(null===(n=l.mandatory)||void 0===n||delete n.chromeMediaSourceId);let u=null;return a&&this._isElectron&&(null===(s=l.mandatory)||void 0===s||delete s.chromeMediaSourceId,u={mandatory:{chromeMediaSource:"desktop"}}),this._getMediaStream({video:l,audio:u||a},"getUserMedia")}))}_createWebScreenStream(e,t,r){return E(this,void 0,void 0,(function*(){const{width:i,height:n}=Ct(t),s={frameRate:Lt(r||Be.FPS_15),width:i,height:n};return this._getMediaStream({video:s,audio:e},"getDisplayMedia")}))}createLocalAudioTrack(e,t){return E(this,void 0,void 0,(function*(){if(!pt(e))return this._logger.error(S.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS};if(!t||"[object MediaStreamTrack]"!==t.toString()||"audio"!==t.kind)return this._logger.error(S.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not audio"})),{code:I.CREATE_CUSTOM_TRACK_FAILED};const r=this._context.getCurrentId();if(!r)return this._logger.error(S.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID};const i=new et(this._logger,e,r,t);return this._logger.info(S.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:O.SUCCESSED,trackId:i.getTrackId()})),{code:I.SUCCESS,track:i}}))}createLocalVideoTrack(e,t){return E(this,void 0,void 0,(function*(){if(!pt(e))return this._logger.error(S.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS};if(!(t&&t instanceof MediaStreamTrack&&"video"===t.kind))return this._logger.error(S.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not video"})),{code:I.CREATE_CUSTOM_TRACK_FAILED};const r=this._context.getCurrentId();if(!r)return this._logger.error(S.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID};const i=new tt(this._logger,e,r,t);return this._logger.info(S.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:O.SUCCESSED,trackId:i.getTrackId()})),{code:I.SUCCESS,track:i}}))}_validateCreateLocalFileTracks(e,t){if(!pt(e))return this._logger.error(S.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS,tracks:[]};if(!Nt())return this._logger.error(S.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.BROWSER_NOT_SUPPORT,msg:"browser not support"})),{code:I.BROWSER_NOT_SUPPORT,tracks:[]};const r=t instanceof File?URL.createObjectURL(t):t;if(!h(r)&&!/^blob:/.test(r))return this._logger.error(S.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> file"})),{code:I.PARAMS_ERROR,tracks:[]};return this._context.getCurrentId()?{code:I.SUCCESS,tracks:[],url:r}:(this._logger.error(S.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID,tracks:[]})}createLocalFileTracks(e,t,r){return E(this,void 0,void 0,(function*(){const i=this._validateCreateLocalFileTracks(e,t);if(i.code!==I.SUCCESS)return i;const n=this._context.getCurrentId();return new Promise((t=>{const s=document.createElement("video");(null==r?void 0:r.withoutAudio)&&(s.muted=!0),s.onloadedmetadata=()=>{const i=[];let o;try{const e=s.mozCaptureStream?"mozCaptureStream":"captureStream";o=s[e]()}catch(e){this._logger.error(S.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.CREATE_FILE_TRACK_FAILED,msg:`captureSteam error -> ${JSON.stringify(e)}`})),t({code:I.CREATE_FILE_TRACK_FAILED,tracks:i})}const[a,c]=da.getTracksWithOptions(o,r);a&&i.push(new nt(this._logger,e,n,a,s)),c&&i.push(new it(this._logger,e,n,c,s)),0===i.length&&(s.pause(),s.src=""),s.onerror=null,this._logger.info(S.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:O.SUCCESSED,trackIds:i.map((e=>e.getTrackId()))})),t({code:I.SUCCESS,tracks:i})},s.onerror=()=>{this._logger.error(S.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.CREATE_FILE_TRACK_FAILED,msg:"Failed to create file stream, video onerror"})),t({code:I.CREATE_FILE_TRACK_FAILED,tracks:[]})},s.src=i.url,s.loop=!0,s.play()}))}))}createLocalTracks(e,t,r){return E(this,void 0,void 0,(function*(){const i=[];if(!pt(e))return this._logger.error(S.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.INVALID_TAGS,msg:"invalid tag"})),{code:I.INVALID_TAGS,tracks:i};if(!(t instanceof MediaStream))return this._logger.error(S.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> stream"})),{code:I.PARAMS_ERROR,tracks:i};const n=this._context.getCurrentId();if(!n)return this._logger.error(S.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:O.FAILED,code:I.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:I.INVALID_USER_ID,tracks:i};const[s,o]=da.getTracksWithOptions(t,r);return s&&i.push(new et(this._logger,e,n,s)),o&&i.push(new tt(this._logger,e,n,o)),this._logger.info(S.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:O.SUCCESSED,trackIds:i.map((e=>e.getTrackId()))})),{code:I.SUCCESS,tracks:i}}))}static getTracksWithOptions(e,t){const r=[];return r[0]=(null==t?void 0:t.withoutAudio)?void 0:e.getAudioTracks()[0],r[1]=(null==t?void 0:t.withoutVideo)?void 0:e.getVideoTracks()[0],r}_applyVideoAspectRatio(e,t,r){return E(this,void 0,void 0,(function*(){const{width:i,height:n}=e.getSettings();if(i===t&&n===r)return;const s=t/r>=1?{width:{ideal:i,max:i}}:{height:{ideal:n,max:n}};try{yield e.applyConstraints(Object.assign(Object.assign({},s),{aspectRatio:{ideal:t/r}})),this._logger.info(S.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:O.SUCCESSED,msg:`apply aspectRatio success -> ${t} / ${r}`}))}catch(e){this._logger.warn(S.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:O.FAILED,msg:`apply aspectRatio error -> ${JSON.stringify(e)}`}))}}))}}class la extends da{constructor(e,t,r){super(e),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,"_options",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_crtRoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_audience",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_crtAudienceLivingRoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),bs.setSdpSemantics(r.sdpSemantics||"unified-plan",this._logger),this._service=new rs(this._runtime,this._context,this._options.mediaServer,this._options.timeout),this._context.registerConnectionStateChangeListener(this._onIMStatusChange.bind(this)),this._context.registerDestroyListener(this._onIMUninit.bind(this)),this._context.registerMessageListener(this._handleMessage.bind(this)),this._context.getPluginContext().onnavidatachange=this.naviDataChange.bind(this)}_handleMessage(e){if(e.conversationType!==u.RTC_ROOM)return!1;const t=this._logger.createTraceId();if(this._crtRoom instanceof Xo){this._getJoinedPKRoomList().forEach((r=>{r.__parseInnerMessage(e,t)}))}return this._logger.info(S.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:O.SUCCESSED,message:e}),t),this._crtRoom?(this._crtRoom.__parseInnerMessage(e,t),!0):(this._logger.warn(S.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:O.FAILED,message:"the crtRoom is empty"}),t),!0)}naviDataChange(e){this._logger.info(S.L_RTC_CLIENT_NAVI_CHANGE_O,`on navi change data => ${JSON.stringify(e)}`),this._service.clearMSList(),this._service.isNededDetector()&&this._service.detectorMediaSever()}_getJoinedPKRoomList(){const{code:e,roomPKHandler:t}=this._crtRoom.getRoomPKHandler();if(e===I.SUCCESS&&t){const e=t.getJoinedPKRooms()||{};return Object.values(e)}return[]}getCurrentId(){return this._context.getCurrentId()}joinCrossRTCRoom(e,t,r,i=!1,n=ms.CROSS_MUTI){return E(this,void 0,void 0,(function*(){return console.warn("joinCrossRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),this.joinRTCRoomWithOptions(e,{joinType:t,userData:r,mode:ms.CROSS_MUTI})}))}joinRTCRoom(e,t,r,i=!1,n=ms.RTC){return E(this,void 0,void 0,(function*(){return console.warn("joinRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),this.joinRTCRoomWithOptions(e,{mode:n,joinType:t,userData:r})}))}joinRTCRoomWithOptions(e,t){return E(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();if(this._logger.info(S.L_RTC_CLIENT_JOIN_RTC_ROOM_T,JSON.stringify({roomId:e,options:t}),r),this._crtRoom)return this._logger.error(S.L_RTC_CLIENT_JOIN_RTC_ROOM_R,JSON.stringify({status:O.FAILED,code:I.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),r),{code:I.REPERT_JOIN_ROOM};const i=this._crtRoom=new ea(this._context,this._runtime,e,this._service,this._options,null==t?void 0:t.mode,null==t?void 0:t.encrypt),{code:n}=yield i.__innerInit((null==t?void 0:t.mode)||ms.RTC,null==t?void 0:t.joinType,void 0,void 0,null==t?void 0:t.userData,r);return n!==I.SUCCESS?(this._crtRoom=null,{code:n}):(i.once(wo,(()=>{this._crtRoom=null})),{code:n,room:i,userIds:i.getRemoteUserIds(),tracks:i.getRemoteTracks()})}))}joinLivingRoom(e,t,r,i,n=!1){return E(this,void 0,void 0,(function*(){const n=this._logger.createTraceId();if(this._logger.info(S.L_RTC_CLIENT_JOIN_LIVING_ROOM_T,JSON.stringify({roomId:e,livingType:t,joinType:r,outerUserDatas:i}),n),this._crtRoom)return this._logger.error(S.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:O.FAILED,code:I.REPERT_JOIN_ROOM,msg:`Join the room repeatedly -> roomId: ${e}`}),n),{code:I.REPERT_JOIN_ROOM};const s=this._crtRoom=new Xo(this._context,this._runtime,e,this._service,this._options,t,!1,!0),{code:o}=yield s.__innerInit(ms.LIVE,r,t,void 0,i,n);if(o!==I.SUCCESS)return this._crtRoom=null,{code:o};s.once(wo,(()=>{this._crtRoom=null}));const a={code:o,room:s,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()};return s.__getCDNPushMode()===ca.MANUAL&&Object.assign(a,{CDNEnable:s.__getCDNEnable()}),a}))}getAudienceClient(e){return this._audience||(this._audience=new ia(this._context,this._runtime,this._options)),this._logger.info(S.L_RTC_CLIENT_GET_AUDIENCE_CLIENT_O),this._audience}_onIMStatusChange(e,t){if(this._logger.info(S.L_RTC_CLIENT_IM_CONNECTION_STATE_S,JSON.stringify({status:e,code:t,desc:o[e]})),e===o.SUSPENDED&&t===n.RC_CONN_REDIRECTED&&this._service.clearMSList(),e===o.DISCONNECTED){if(this._crtRoom){let e=No.IM_DISCONNECTED;t===n.RC_DISCONN_KICK?e=No.OTHER_CLIENT_IM_CONNECTED:2===t&&(e=No.IM_LOGOUT),this._crtRoom.__kickoff(!0,{users:[{userId:this._context.getCurrentId(),type:e}]})}}else if(e===o.CONNECTED){if(this._service.isNededDetector()&&this._service.detectorMediaSever(),this._crtRoom instanceof Xo){this._getJoinedPKRoomList().forEach((e=>{e.__onReconnected()}))}this._crtRoom&&this._crtRoom.__onReconnected()}}_onIMUninit(){var e;this._logger.info(S.L_RTC_CLIENT_DESTROY_S,JSON.stringify({msg:"TODO -> on IM client ondestroy"})),null===(e=this._crtRoom)||void 0===e||e.__destroy(!0)}leaveRoom(e){var t;return E(this,void 0,void 0,(function*(){const r=this._logger.createTraceId();return this._logger.info(S.L_RTC_CLIENT_LEAVE_ROOM_T,JSON.stringify({roomId:e.getRoomId()}),r),this._crtRoom?(yield this._crtRoom.__destroy(!0),this._service.isNededDetector()&&this._service.detectorMediaSever(),this._logger.info(S.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:O.SUCCESSED,roomId:null===(t=this._crtRoom)||void 0===t?void 0:t.getRoomId()}),r),this._crtRoom=null,{code:I.SUCCESS}):(this._logger.warn(S.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:O.FAILED,msg:"Room does not exist, without leave"}),r),{code:I.SUCCESS})}))}joinLivingRoomAsAudience(e,t,i){return E(this,void 0,void 0,(function*(){const i=this._logger.createTraceId();if(this._logger.info(S.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_T,JSON.stringify({roomId:e,livingType:t}),i),this._service.isNededDetector()&&this._service.detectorMediaSever(),Pt(this._context.getNaviInfo()))return this._logger.error(S.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.FAILED,code:I.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),i),{code:I.PACKAGE_ENVIRONMENT_ERROR};if(!r("roomId",e,a,!0)||!r("livingType",t,(e=>e===Ko.AUDIO||e===Ko.VIDEO)))return this._logger.error(S.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> roomId or livingType"}),i),{code:I.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return this._logger.error(S.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.FAILED,code:I.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),i),{code:I.REPERT_JOIN_ROOM};if(!this._service.getMsList().length)return this._logger.error(S.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.FAILED,code:I.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),i),{code:I.NOT_OPEN_VIDEO_AUDIO_SERVER};const{code:s,data:o}=yield this._context.joinLivingRoomAsAudience(e,ms.LIVE,t);if(s!==n.SUCCESS)return this._logger.error(S.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.FAILED,code:s,msg:"signal error -> audience join room"}),i),{code:I.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED};const c=Zn(),_=new aa(this._context,this._runtime,this._options,e,o,t,c);return this._crtAudienceLivingRoom=_,this._logger.info(S.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.SUCCESSED,roomData:o}),i),{room:_,code:I.SUCCESS,userIds:_.getRemoteUserIds(),RTCTracks:_.getRemoteRTCTracks(),MCUTracks:_.getRemoteMCUTracks(),CDNUris:_.getCDNInfo()}}))}leaveLivingRoomAsAudience(e){return E(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();return this._logger.info(S.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_T,JSON.stringify({roomId:e.getRoomId(),userId:this._context.getCurrentId()}),t),this._crtAudienceLivingRoom?this._crtAudienceLivingRoom!==e?(this._logger.error(S.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> room"}),t),{code:I.PARAMS_ERROR}):(yield this._crtAudienceLivingRoom.__destroy(!0),this._crtAudienceLivingRoom=null,this._logger.info(S.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.SUCCESSED}),t),{code:I.SUCCESS}):(this._logger.warn(S.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:O.FAILED,msg:"Room does not exist, without leave"}),t),{code:I.SUCCESS})}))}upgradeToAnchorRoom(e){return E(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();if(this._logger.info(S.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_T,void 0,t),!r("room",e,(()=>e instanceof aa),!0))return this._logger.error(S.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> room"}),t),{code:I.PARAMS_ERROR};const i=e.getRoomId();if(this._crtRoom)return this._logger.error(S.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:O.FAILED,code:I.REPERT_JOIN_ROOM,msg:"Join the room repeatedly",roomId:i}),t),{code:I.REPERT_JOIN_ROOM};const s=this._crtRoom=new Xo(this._context,this._runtime,i,this._service,this._options,e.livingType,!0,!0,e.getClientSessionId()),o=yield s.__innerInitByIdentityChange(t);if(o!==n.SUCCESS)return this._crtRoom=null,{code:o};s.once(wo,(()=>{this._crtRoom=null})),yield this._crtAudienceLivingRoom.__destroy(!1),this._crtAudienceLivingRoom=null;const a={room:s,code:I.SUCCESS,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()};return s.__getCDNPushMode()===ca.MANUAL&&Object.assign(a,{CDNEnable:s.__getCDNEnable()}),a}))}downgradeToAudienceRoom(e){return E(this,void 0,void 0,(function*(){const t=this._logger.createTraceId();if(this._logger.info(S.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_T,JSON.stringify({roomId:e._roomId,userId:this._context.getCurrentId()}),t),!e.isMainRoom())return this._logger.error(S.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:O.FAILED,code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"the `downgradeToAudienceRoom` is disabled in PK room"}),t),{code:I.THE_FUNCTION_IS_DISABLED_IN_PKROOM};if(!r("room",e,(()=>e instanceof Xo),!0))return this._logger.error(S.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:O.FAILED,code:I.PARAMS_ERROR,msg:"params error -> room"}),t),{code:I.PARAMS_ERROR};if(this._crtAudienceLivingRoom)return this._logger.error(S.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:O.FAILED,code:I.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),t),{code:I.REPERT_JOIN_ROOM};const{code:i,data:s}=yield this._context.rtcIdentityChange(e._roomId,Wo.AnchorToViewer,e.getLivingType());if(i!==n.SUCCESS)return this._logger.error(S.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:O.FAILED,code:I.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}),t),{code:I.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED};this._logger.info(S.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:O.SUCCESSED,roomData:s}),t);const o=e.getClientSessionId(),a=new aa(this._context,this._runtime,this._options,e._roomId,s,e.getLivingType(),o);return this._crtAudienceLivingRoom=a,this._crtRoom.__destroy(!1),this._crtRoom=null,{room:a,code:I.SUCCESS,userIds:a.getRemoteUserIds(),RTCTracks:a.getRemoteRTCTracks(),MCUTracks:a.getRemoteMCUTracks(),CDNUris:a.getCDNInfo()}}))}getJoinedRoomInfo(){return E(this,void 0,void 0,(function*(){const e=this._logger.createTraceId(),t=this._context.getCurrentId();this._logger.error(S.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_T,JSON.stringify({userId:t}),e);const{code:r,data:i}=yield this._context.getRTCJoinedUserInfo(t);return r!==n.SUCCESS?(this._logger.error(S.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:O.FAILED,code:r}),e),{code:r}):(this._logger.info(S.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:O.SUCCESSED,roomInfo:i}),e),{code:I.SUCCESS,data:i})}))}}!function(e){e[e.KICK=0]="KICK",e[e.REFUSE=1]="REFUSE"}(_a||(_a={}));const ua="rtcRJoin_data",ha="rtcRExit",pa="rtcRInfo",ga="rtcUData",Ra="rtcUDel",ma="rtcSetData",fa="userSetData",Ea="rtcQryData",Ia="rtcDelData",Sa="rtcToken",Oa="rtcUserState",Ta="rtcUList",Ca="viewerJoinR",va="viewerExitR",ba="rtcPullKv",La="rtcIdentityChange",ya="rtcInvite",Na="rtcCancelInvite",Aa="rtcInviteAnswer",Da="rtcEndInvite",Pa="rtcQueryJoined",Ua="rtcPullRoomStatus",ka="reportsdk",Ma="rtcPing";var wa;!function(e){e.RtcInput="RtcInput",e.RtcOutput="RtcOutput",e.RtcUserListOutput="RtcUserListOutput",e.SetUserStatusInput="SetUserStatusInput",e.RtcSetDataInput="RtcSetDataInput",e.RtcUserSetDataInput="RtcUserSetDataInput",e.RtcDataInput="RtcDataInput",e.RtcSetOutDataInput="RtcSetOutDataInput",e.MCFollowInput="MCFollowInput",e.RtcTokenOutput="RtcTokenOutput",e.RtcQryOutput="RtcQryOutput",e.RtcQryUserOutDataInput="RtcQryUserOutDataInput",e.RtcUserOutDataOutput="RtcUserOutDataOutput",e.RtcQueryListInput="RtcQueryListInput",e.RtcRoomInfoOutput="RtcRoomInfoOutput",e.RtcValueInfo="RtcValueInfo",e.RtcKeyDeleteInput="RtcKeyDeleteInput",e.RtcNotifyMsg="RtcNotifyMsg",e.RtcPullKV="RtcPullKV",e.RtcKVOutput="RtcKVOutput",e.RtcQueryUserJoinedInput="RtcQueryUserJoinedInput",e.RtcQueryUserJoinedOutput="RtcQueryUserJoinedOutput",e.RtcViewerJoinedOutput="RtcViewerJoinedOutput",e.RtcInviteInput="RtcInviteInput",e.RtcCancelInviteInput="RtcCancelInviteInput",e.RtcInviteAnswerInput="RtcInviteAnswerInput",e.RtcEndInviteInput="RtcEndInviteInput",e.RtcRoomStatusInput="RtcRoomStatusInput",e.RtcRoomStatusOutput="RtcRoomStatusOutput",e.RtcReportSDKInput="RtcReportSDKInput",e.RtcPBPolaris="RCRTCPBPolaris",e.RtcPBR1Info="RCRTCPBR1Info",e.RtcPBR2Info="RCRTCPBR2Info",e.RtcPBR3Info="RCRTCPBR3Info",e.RtcPBR4Info="RCRTCPBR4Info",e.RtcPBStatusInfo="RCRTCPBStatusInfo",e.RtcPBStreamInfo="RCRTCPBStreamInfo"}(wa||(wa={}));const Ba={[wa.RtcInput]:["roomType","broadcastType","extraInnerData","needSysChatroom","identityChangeType","joinType","innerDatas","outerDatas","supportNtf"],[wa.RtcOutput]:["version"],[wa.RtcUserListOutput]:["users","token","sessionId","roomInfo","version"],[wa.SetUserStatusInput]:["status"],[wa.RtcSetDataInput]:["interior","target","key","value","objectName","content"],[wa.RtcUserSetDataInput]:["valueInfo","objectName","content"],[wa.RtcDataInput]:["interior","target","key","objectName","content"],[wa.RtcSetOutDataInput]:["target","valueInfo","objectName","content"],[wa.MCFollowInput]:["state"],[wa.RtcTokenOutput]:["rtcToken"],[wa.RtcQryOutput]:["outInfo"],[wa.RtcQryUserOutDataInput]:["userId"],[wa.RtcUserOutDataOutput]:["user"],[wa.RtcQueryListInput]:["order"],[wa.RtcRoomInfoOutput]:["roomId","roomData","userCount","list"],[wa.RtcValueInfo]:["key","value"],[wa.RtcKeyDeleteInput]:["key"],[wa.RtcNotifyMsg]:["type","time","roomId"],[wa.RtcPullKV]:["timestamp","roomId"],[wa.RtcKVOutput]:["entries","bFullUpdate","syncTime"],[wa.RtcQueryUserJoinedInput]:["userId"],[wa.RtcQueryUserJoinedOutput]:["info"],[wa.RtcInviteInput]:["invitedUserId","timeoutTime","invitedRoomId","inviteInfo","inviteSessionId"],[wa.RtcCancelInviteInput]:["invitedUserId","invitedRoomId","inviteInfo","inviteSessionId"],[wa.RtcInviteAnswerInput]:["inviteUserId","answerCode","inviteRoomId","inviteSessionId","content","key","value"],[wa.RtcEndInviteInput]:["inviteRoomId","inviteSessionId","inviteContent","inviteRoomKeys"],[wa.RtcRoomStatusInput]:["version"],[wa.RtcRoomStatusOutput]:["bFullStatus","version","usersData","roomStatus"],[wa.RtcReportSDKInput]:["sdkInfo"],[wa.RtcPBPolaris]:["type","appKey","sessionId","roomId","roomCreateTime","userId","userRole","joinTime","signalDataCenter","r1Info","r2Info","r3Info","r4Info"],[wa.RtcPBR1Info]:["joinTime","rtcVersion","imVersion","platform","device","os","browserName","browserVersion"],[wa.RtcPBR2Info]:["joinTime","sendTime","rtcActionType","rtcActionStatus","trackId"],[wa.RtcPBR3Info]:["info"],[wa.RtcPBR4Info]:["info"],[wa.RtcPBStatusInfo]:["joinTime","receiveTime","totalBitRate","appCPUUsage","systemCPUUsage","systemCPUFrequency","networkStatus","googleRTTNetwork","ipAddress","useReceiveBroadBand","useSendBroadBand","packetLossCount","streams"],[wa.RtcPBStreamInfo]:["trackId","codeName","volume","samplingRate","bitRate","packetLossRate","frameRate","resolution","blockTime","jitterData","nAckCount","pliCount","googleRTTTotalTime","isReceiveFirstFrameRate","codeType","isEnabled"]},xa=`\npackage Modules;\nmessage probuf {\n enum JoinType {\n KICK = 0; //踢前一个设备\n REFUSE = 1; //当前加入拒绝\n COEXIST = 2; //两个设备共存\n }\n enum targetType {\n ROOM =1 ;\n PERSON = 2;\n }\n message ${wa.SetUserStatusInput}\n {\n optional int32 status=1;\n }\n message ${wa.MCFollowInput}\n {\n required string state = 1;\n }\n message ${wa.RtcQueryListInput}{\n optional int32 order=1;\n }\n message ${wa.RtcKeyDeleteInput}{\n repeated string key=1;\n }\n message ${wa.RtcValueInfo}{\n required string key=1;\n required string value=2;\n }\n message RtcUserInfo{\n required string userId=1;\n repeated ${wa.RtcValueInfo} userData=2; //用户资源信息\n }\n message ${wa.RtcRoomStatusInput}{ // rtc 和 living room 拉房间资源状态使用的参数\n required int64 version =1; //当前客户端最大的房间状态的version\n }\n message ${wa.RtcRoomStatusOutput}{ // rtc 和 living room 拉房间资源状态返回的数据\n required bool bFullStatus =1; //标识此次给的数据是否是全量数据\n required int64 version =2; //当前获取后房间的最大版本号\n repeated RtcUserInfo usersData=3;//如果是全量数据,这个不为空,给的是房间全部的人以及发布的资源\n repeated RtcRoomStatus roomStatus=4;//房间增量数据\n }\n message RtcRoomStatus{ //房间状态变动\n required string userId = 1;//用户ID\n required int32 event = 2;//房间状态变更的event(人员加入/退出/离线/发布资源) (0:加入;1:离开;2:离线;3:资源变动) \n required int64 time = 3;//本次变更的版本号\n repeated RtcValueInfo userData = 4;//用户变更的资源(event为0或者3时可能有值)\n optional int32 switchRoleType = 5;//如果是切换角色导致的加入房间或退出房间的类型\n optional string extra = 6;\n }\n message ${wa.RtcUserListOutput}{\n repeated RtcUserInfo users=1;\n optional string token=2;\n optional string sessionId=3;\n repeated RtcValueInfo roomInfo = 4; //房间key value\n repeated RtcKVEntity entries = 5;//直播KV属性对象集合\n optional int64 syncTime = 6;//所有属性的最大时间戳(下次拉取KV时用)。\n optional int32 offlineKickTime = 7;//server超时踢人时间,默认60s\n repeated string codeFormat = 8; //当前房间用户支持的编码交集\n optional int64 roomCreateTime = 9;//房间创建时间\n optional int64 userJoinTime = 10;//用户加入房间\n optional int64 version = 11;//当前房间的版本号\n }\n message RtcRoomInfoOutput{\n optional string roomId = 1;\n repeated ${wa.RtcValueInfo} roomData = 2;\n optional int32 userCount = 3;\n repeated RtcUserInfo list=4;\n }\n message ${wa.RtcInput}{\n required int32 roomType=1;\n optional int32 broadcastType=2;\n optional RtcValueInfo extraInnerData = 3;\n optional bool needSysChatroom = 4; //是否需要同步聊天室\n optional IdentityChangeType identityChangeType = 5; //身份变更类型\n optional JoinType joinType = 6; // 加入房间类型\n repeated ${wa.RtcValueInfo} innerDatas = 7; //用户内部inner数据,角色或者连麦信息等\n repeated ${wa.RtcValueInfo} outerDatas = 8; //用户内部outer数据,自定义数据结构RtcInput。\n optional bool supportNtf = 9; //是否支持房间状态的变更通过通知拉取的方式获取\n }\n message ${wa.RtcQryOutput}{\n repeated ${wa.RtcValueInfo} outInfo=1;\n }\n message ${wa.RtcDataInput}{\n required bool interior=1;\n required targetType target=2;\n repeated string key=3;\n optional string objectName=4;\n optional string content=5;\n }\n message ${wa.RtcSetDataInput}{\n required bool interior=1;\n required targetType target=2;\n required string key=3;\n required string value=4;\n optional string objectName=5;\n optional string content=6;\n }\n message ${wa.RtcUserSetDataInput} {\n repeated ${wa.RtcValueInfo} valueInfo = 1;\n required string objectName = 2;\n repeated ${wa.RtcValueInfo} content = 3;\n }\n message RtcQryInput{\n required bool isInterior=1;\n required targetType target=2;\n repeated string key=3;\n }\n message RtcDelDataInput{\n repeated string key=1;\n required bool isInterior=2;\n required targetType target=3;\n }\n message RtcOutput\n {\n optional int32 nothing=1;\n optional int64 version=2;\n }\n message ${wa.RtcTokenOutput}{\n required string rtcToken=1;\n }\n message ${wa.RtcSetOutDataInput}{\n required targetType target=1;\n repeated ${wa.RtcValueInfo} valueInfo=2;\n optional string objectName=3;\n optional string content=4;\n }\n message ${wa.RtcQryUserOutDataInput}{\n repeated string userId = 1;\n }\n message ${wa.RtcUserOutDataOutput}{\n repeated RtcUserInfo user = 1;\n }\n message ${wa.RtcNotifyMsg} \n {\n required int32 type= 1; //(通知类型 1:rtc房间状态KV变更通知)\n optional int64 time= 2; //消息产生时间\n optional string roomId=3; //主播房间id\n }\n message ${wa.RtcPullKV}\n {\n required int64 timestamp = 1;\n required string roomId = 2;\n }\n message RtcKVEntity \n {\n required string key = 1;\n required string value = 2;\n optional int32 status = 3;\n optional int64 timestamp = 4;\n optional string uid = 5;\n }\n message ${wa.RtcKVOutput}\n {\n repeated RtcKVEntity entries = 1;\n optional bool bFullUpdate = 2;\n optional int64 syncTime = 3; \n }\n enum IdentityChangeType \n {\n AnchorToViewer = 1; //1为主播变观众\n ViewerToAnchor = 2; //2为观众变主播\n }\n message ${wa.RtcQueryUserJoinedInput}\n {\n required string userId = 1;\n }\n message RtcJoinedInfo\n {\n required string deviceId = 1; //设备ID\n required string roomId = 2; //加入的房间ID\n optional int64 joinTime = 3; //加入的时间\n }\n message ${wa.RtcQueryUserJoinedOutput}\n {\n repeated RtcJoinedInfo info = 1;\n }\n message ${wa.RtcViewerJoinedOutput}\n {\n required string rtcToken=1;\n repeated RtcKVEntity entries = 2;//KV属性对象集合\n optional int64 syncTime = 3;//所有属性的最大时间戳(下次拉取KV时用)。\n optional string sessionId=4;\n optional int64 roomCreateTime = 5;//房间创建时间\n optional int64 userJoinTime = 6;//用户加入房间\n }\n message ${wa.RtcInviteInput}\n {\n required string invitedUserId=1; //被邀请的人的uid\n optional int32 timeoutTime=2; //邀请超时时间(秒),默认三十秒\n required string invitedRoomId=3; //被邀请的房间\n required string inviteInfo=4; //邀请的信息(包含邀请人,被邀请人,各自userid)客户端定义好.协议栈和server透传\n required string inviteSessionId= 5; //客户端保证唯一性(建议roomid_userid_时间戳_随机数)\n }\n message ${wa.RtcCancelInviteInput}\n {\n required string invitedUserId=1; //被邀请的人的uid\n required string invitedRoomId=2; //被邀请的房间\n required string inviteInfo=3; //取消邀请的信息(包含邀请人,被邀请人,各自userid)客户端定义好.协议栈和server透传\n required string inviteSessionId=4; //邀请的sessionId,客户端发起邀请时产生\n }\n message ${wa.RtcInviteAnswerInput}\n {\n required string inviteUserId=1; //邀请的人的uid\n required int32 answerCode=2; //是否接受连麦邀请.0为拒绝,1为接受\n required string inviteRoomId=3; //邀请的房间\n required string inviteSessionId=4; //邀请的sessionId\n required string content=5; //需要转发的content\n optional string key=6; //如果接受的话,需要加这个字段,放在room级别的k和v,新加入房间的能拉取到\n optional string value=7; //如果接受的话,需要加这个字段,放在room级别的k和v,新加入房间的能拉取到\n }\n message ${wa.RtcEndInviteInput}\n {\n required string inviteRoomId=1; //邀请的房间\n required string inviteSessionId=2; //邀请的sessionId\n required string inviteContent=3; //结束连麦的信息(需要透传给房间内其他人)\n repeated string inviteRoomKeys=4; //需要删除连麦的信息的key\n }\n message ${wa.RtcReportSDKInput} {\n required string sdkInfo=1; // 用户集成的 sdk 信息,json 格式 {"web-rtc": "4.0.3.7"}\n }\n // ---- 北极星数据上报 -------\n message ${wa.RtcPBPolaris} {\n required string type = 1;//上报数据类型 R1-R4\n required string appKey = 2;\n required string sessionId = 3;//房间通话id\n required string roomId = 4;\n required int64 roomCreateTime = 5;//房间创建时间\n required string userId = 6;\n required int32 userRole = 7;\n required int64 joinTime = 8;\n required string signalDataCenter = 9;//signal数据中心\n optional ${wa.RtcPBR1Info} r1Info = 10;\n optional ${wa.RtcPBR2Info} r2Info = 11;\n optional ${wa.RtcPBR3Info} r3Info = 12;\n optional ${wa.RtcPBR4Info} r4Info = 13;\n }\n message ${wa.RtcPBR1Info} {\n required int64 joinTime = 1;//用户加入房间的时间\n required string rtcVersion = 2;//Rtc版本号\n required string imVersion = 3;//IM SDK 版本\n required string platform = 4;//平台(如:Android、iOS、Web)\n required string device = 5; //设备信息(手机名称+型号)\n required string os = 6;//系统版本(手机系统版本)\n optional string browserName = 7; //浏览器名称, 没有用 -1 表示\n optional string browserVersion = 8;//浏览器版本, 没有用 -1 表示\n optional int64 receiveTime = 9; // 发送数据的时间\n }\n message ${wa.RtcPBR2Info} {\n required int64 joinTime = 1;\n required int64 sendTime = 2;\n required string rtcActionType = 3;//发布类型 subscribe : 订阅 publish : 发布\n required string rtcActionStatus = 4;//发布状态 begin : 开始 tend : 结束\n repeated string trackId = 5;\n optional int64 receiveTime = 6; // 发送数据的时间\n }\n message ${wa.RtcPBR3Info} {\n required ${wa.RtcPBStatusInfo} info = 1;\n }\n message ${wa.RtcPBR4Info} {\n required ${wa.RtcPBStatusInfo} info = 1;\n }\n message ${wa.RtcPBStatusInfo} {\n optional int64 joinTime = 1;//用户加入房间的时间\n optional int64 receiveTime = 2;//用户发布数据流的时间(毫秒),暂时由客户端生成,后期如果有问题服务端做兜底处理\n optional int64 totalBitRate = 3;//总码率\n optional float appCPUUsage = 4;//APP CPU占用率\n optional float systemCPUUsage = 5;////系统 CPU占用率\n optional float systemCPUFrequency = 6;//系统CPU频率 (安卓8.0以上)\n optional string networkStatus = 7;//实时网络状态(2g、3g、4g、wifi)\n optional int32 googleRTTNetwork = 8;//Goog rtt 网络延迟\n optional string ipAddress = 9;//ip地址\n optional string useReceiveBroadBand = 10; //可接收带宽(单位: bit)\n optional string useSendBroadBand = 11;//可用发送带宽(单位: bit)\n optional string packetLossCount = 12;//丢包数\n repeated ${wa.RtcPBStreamInfo} streams = 13;\n }\n message ${wa.RtcPBStreamInfo} {\n required string trackId = 1;\n optional string codeName = 2;//编解码名称\n optional string volume = 3;//音频播放音量\n optional int32 samplingRate = 4; //音频采样率\n optional float bitRate = 5;//下行码率\n optional float packetLossRate = 6;\n optional int32 frameRate = 7;//视频接收帧率(单位:fps)\n optional string resolution = 8;//视频分辨率(格式:640*480)\n optional int64 blockTime = 9;//接收卡顿(间隔时间, 单位: ms)\n optional int32 jitterData = 10;//jitter数据抖动\n optional string nAckCount = 11;//nack数量\n optional string pliCount = 12; //PLI请求数\n optional int64 googleRTTTotalTime = 13; //googRtt往返时长\n optional int32 isReceiveFirstFrameRate = 14;//第一个关键帧是否正常收到\n optional string codeType = 15;//编码方式\n optional int32 isEnabled = 16; //当前流的状态是否可用\n }\n // ---- 北极星数据上报 -------\n}\n`,Va=(e,t,r,i,n,s,o)=>{const a=n?Object.keys(n).map((t=>e.encode(wa.RtcValueInfo,{key:t,value:n[t]},!0))):void 0,c=s?Object.keys(s).map((t=>e.encode(wa.RtcValueInfo,{key:t,value:s[t]},!0))):void 0;return e.encode(wa.RtcInput,{roomType:t,broadcastType:r,joinType:i,innerDatas:a,outerDatas:c,supportNtf:o})},ja=(e,t)=>{const r=e.decode(wa.RtcUserListOutput,t),{users:i,token:n,sessionId:s,roomInfo:o,entries:a,offlineKickTime:c=60,codeFormat:_,roomCreateTime:d,userJoinTime:l,version:u}=r,h={};return R(i,(e=>{const{userId:t,userData:r}=e,i={};R(r,(e=>{const{key:t,value:r}=e;i[t]=r})),h[t]=i})),{users:h,token:n,sessionId:s,roomInfo:o,kvEntries:a,offlineKickTime:c,codeFormat:_,roomCreateTime:Mt(d),userJoinTime:Mt(l),version:u}};class Fa{constructor(e,t,r){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,"codec",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"roomCreateTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"userJoinTime",{enumerable:!0,configurable:!0,writable:!0,value:0})}joinRTCRoom(e,t,r,i,s,o,a){return E(this,void 0,void 0,(function*(){const c=Va(this.codec,t,r,i,s,o,a),{code:_,buffer:d}=yield this.context.rtcSignaling(e,ua,!0,c);let l;if(_===n.SUCCESS&&d){l=ja(this.codec,d);const{users:e,token:t,sessionId:r,roomInfo:i,kvEntries:n,offlineKickTime:s,roomCreateTime:o,userJoinTime:a,version:c}=l;return this.roomCreateTime=o,this.userJoinTime=a,{code:_,data:{users:e,token:t,sessionId:r,roomInfo:i,kvEntries:n,offlineKickTime:s,version:c}}}return{code:_,data:l}}))}quitRTCRoom(e){return E(this,void 0,void 0,(function*(){const t=this.codec.encode(wa.SetUserStatusInput,{status:0}),{code:r}=yield this.context.rtcSignaling(e,ha,!0,t);return r}))}getRTCRoomInfo(e){return E(this,void 0,void 0,(function*(){const t=this.codec.encode(wa.RtcQueryListInput,{order:2}),{code:r,buffer:i}=yield this.context.rtcSignaling(e,pa,!0,t);let s;return r===n.SUCCESS&&i&&(s=this.codec.decode(wa.RtcRoomInfoOutput,i)),{code:r,data:s}}))}getRTCUserInfoList(e){return E(this,void 0,void 0,(function*(){const t=this.codec.encode(wa.RtcQueryListInput,{order:2}),{code:r,buffer:i}=yield this.context.rtcSignaling(e,ga,!0,t);let s;if(r===n.SUCCESS&&i){s={users:ja(this.codec,i).users}}return{code:r,data:s}}))}getRTCUserInfo(e){throw new Error("Method not implemented.")}removeRTCUserInfo(e,t){return E(this,void 0,void 0,(function*(){const r=this.codec.encode(wa.RtcKeyDeleteInput,{key:t}),{code:i}=yield this.context.rtcSignaling(e,Ra,!1,r);return i}))}setRTCData(e,t,r,i,n,s){return E(this,void 0,void 0,(function*(){const o=this.codec.encode(wa.RtcSetDataInput,{interior:i,target:n,key:t,value:r,objectName:null==s?void 0:s.name,content:null==s?void 0:s.content}),{code:a}=yield this.context.rtcSignaling(e,ma,!1,o);return a}))}setRTCTotalRes(e,t,r,i,n,s){return E(this,void 0,void 0,(function*(){const o={objectName:i,content:[],valueInfo:[this.codec.encode(wa.RtcValueInfo,{key:"uris",value:r},!0)]};t.forEach((e=>{const t=this.codec.encode(wa.RtcValueInfo,{key:e.name,value:e.content},!0);o.content.push(t)})),n&&o.valueInfo.push(this.codec.encode(wa.RtcValueInfo,{key:"mcu_uris",value:n},!0)),s&&o.valueInfo.push(this.codec.encode(wa.RtcValueInfo,{key:"cdn_uris",value:s},!0));const a=this.codec.encode(wa.RtcUserSetDataInput,o),{code:c}=yield this.context.rtcSignaling(e,fa,!0,a);return c}))}setRTCCDNUris(e,t,r){return E(this,void 0,void 0,(function*(){const i=this.codec.encode(wa.RtcUserSetDataInput,{objectName:t,valueInfo:this.codec.encode(wa.RtcValueInfo,{key:"cdn_uris",value:r},!0)}),{code:n}=yield this.context.rtcSignaling(e,fa,!0,i);return n}))}getRTCData(e,t,r,i){return E(this,void 0,void 0,(function*(){const s=this.codec.encode(wa.RtcDataInput,{interior:r,target:i,key:t}),{code:o,buffer:a}=yield this.context.rtcSignaling(e,Ea,!0,s);if(o!==n.SUCCESS||!a)return{code:o};const{outInfo:c}=this.codec.decode(wa.RtcQryOutput,a),_={};return c.forEach((e=>{_[e.key]=e.value})),{code:o,data:_}}))}removeRTCData(e,t,r,i,n){return E(this,void 0,void 0,(function*(){const s=this.codec.encode(wa.RtcDataInput,{interior:r,target:i,key:t,objectName:(null==n?void 0:n.name)||"",content:(null==n?void 0:n.content)||""}),{code:o}=yield this.context.rtcSignaling(e,Ia,!1,s);return o}))}setRTCOutData(e,t,r,i){return E(this,void 0,void 0,(function*(){throw new Error("JSEngine's method not implemented.")}))}getRTCOutData(e,t){return E(this,void 0,void 0,(function*(){throw new Error("JSEngine's method not implemented.")}))}getRTCToken(e,t,r){return E(this,void 0,void 0,(function*(){const i=Va(this.codec,t,r),{code:s,buffer:o}=yield this.context.rtcSignaling(e,Sa,!0,i);if(s!==n.SUCCESS||!o)return{code:s};const{rtcToken:a}=this.codec.decode(wa.RtcTokenOutput,o);return{code:s,data:{rtcToken:a}}}))}setRTCState(e,t){return E(this,void 0,void 0,(function*(){const r=this.codec.encode(wa.MCFollowInput,{state:t}),{code:i}=yield this.context.rtcSignaling(e,Oa,!0,r);return i}))}setRTCStateByHttp(e,t,r,i){var n;return E(this,void 0,void 0,(function*(){const o=((e,t,r)=>{const{type:i,appKey:n,sessionId:s,roomId:o,roomCreateTime:a,userId:c,userRole:_,joinTime:d,signalDataCenter:l,r1Info:u,r2Info:h,r3Info:p,r4Info:g}=t,R={type:i,appKey:n,sessionId:s,roomId:o,roomCreateTime:a,userId:c,userRole:_,joinTime:d,signalDataCenter:l};if(r===Uo.R1&&u){const t=e.encode(wa.RtcPBR1Info,u,!0);return e.encode(wa.RtcPBPolaris,Object.assign(Object.assign({},R),{r1Info:t}))}if(r===Uo.R2&&h){const t=e.encode(wa.RtcPBR2Info,h,!0);return e.encode(wa.RtcPBPolaris,Object.assign(Object.assign({},R),{r2Info:t}))}if(r===Uo.R3&&p){const{info:t}=p,{streams:r}=t;let i=Array.isArray(r)&&r.map((t=>t&&e.encode(wa.RtcPBStreamInfo,t,!0))),n=e.encode(wa.RtcPBStatusInfo,Object.assign(Object.assign({},t),{streams:i}),!0),s=e.encode(wa.RtcPBR3Info,{info:n},!0);return e.encode(wa.RtcPBPolaris,Object.assign(Object.assign({},R),{r3Info:s}))}if(r===Uo.R4&&g){const{info:t}=g,{streams:r}=t;let i=Array.isArray(r)&&r.map((t=>t&&e.encode(wa.RtcPBStreamInfo,t,!0))),n=e.encode(wa.RtcPBStatusInfo,Object.assign(Object.assign({},t),{streams:i}),!0),s=e.encode(wa.RtcPBR4Info,{info:n},!0);return e.encode(wa.RtcPBPolaris,Object.assign(Object.assign({},R),{r4Info:s}))}return{}})(this.codec,r,i);let a=e;/^https:\/\//.test(e)||(a=`https://${e}`);try{const e=yield t.httpReq({url:`${a}/rtc/logserver/polaris`,body:o,method:s.POST,headers:{jwt:(null===(n=this.context.getNaviInfo())||void 0===n?void 0:n.jwt)||""},timeout:2e3});if(!e.data)throw new Error("http request fail");return JSON.parse(e.data).resultCode}catch(e){return Po.REPORT_FAIL}}))}getRTCUserList(e){return E(this,void 0,void 0,(function*(){const t=this.codec.encode(wa.RtcQueryListInput,{order:2}),{code:r,buffer:i}=yield this.context.rtcSignaling(e,Ta,!0,t);if(r!==n.SUCCESS||!i)return{code:r};return{code:r,data:ja(this.codec,i)}}))}joinLivingRoomAsAudience(e,t,r){return E(this,void 0,void 0,(function*(){const i=Va(this.codec,t,r),{code:s,buffer:o}=yield this.context.rtcSignaling(e,Ca,!0,i);if(s!==n.SUCCESS||!o)return{code:s};const{rtcToken:a,entries:c,roomCreateTime:_,userJoinTime:d}=this.codec.decode(wa.RtcViewerJoinedOutput,o);return this.roomCreateTime=Mt(_),this.userJoinTime=Mt(d),{code:s,data:{token:a,kvEntries:c}}}))}quitLivingRoomAsAudience(e){return E(this,void 0,void 0,(function*(){const t=this.codec.encode(wa.SetUserStatusInput,{status:0}),{code:r}=yield this.context.rtcSignaling(e,va,!0,t);return r}))}rtcIdentityChange(e,t,r){return E(this,void 0,void 0,(function*(){const i=this.codec.encode(wa.RtcInput,{roomType:ms.LIVE,broadcastType:r,identityChangeType:t,needSysChatroom:!1}),{code:s,buffer:o}=yield this.context.rtcSignaling(e,La,!0,i);if(s!==n.SUCCESS||!o)return{code:s};return{code:s,data:ja(this.codec,o)}}))}requestRoomPK(e){return E(this,void 0,void 0,(function*(){const{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,inviteTimeout:n,inviteInfo:s,roomId:o}=e,a=this.codec.encode(wa.RtcInviteInput,{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,timeoutTime:n,inviteInfo:s}),{code:c}=yield this.context.rtcSignaling(o,ya,!0,a);return c}))}cancelRoomPK(e){return E(this,void 0,void 0,(function*(){const{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,inviteInfo:n,roomId:s}=e,o=this.codec.encode(wa.RtcCancelInviteInput,{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,inviteInfo:n}),{code:a}=yield this.context.rtcSignaling(s,Na,!0,o);return a}))}responseRoomPK(e){return E(this,void 0,void 0,(function*(){const{inviteUserId:t,inviteRoomId:r,inviteSessionId:i,content:n,key:s,value:o,agree:a,roomId:c}=e,_=this.codec.encode(wa.RtcInviteAnswerInput,{inviteUserId:t,inviteRoomId:r,inviteSessionId:i,content:n,key:s,value:o,answerCode:a?1:0}),{code:d}=yield this.context.rtcSignaling(c,Aa,!0,_);return d}))}endRoomPK(e){return E(this,void 0,void 0,(function*(){const{endRoomId:t,sessionId:r,content:i,keys:n,roomId:s}=e,o=this.codec.encode(wa.RtcEndInviteInput,{inviteRoomId:t,inviteSessionId:r,inviteContent:i,inviteRoomKeys:n}),{code:a}=yield this.context.rtcSignaling(s,Da,!0,o);return a}))}getRTCJoinedUserInfo(e){return E(this,void 0,void 0,(function*(){const t=this.codec.encode(wa.RtcQueryUserJoinedInput,{userId:e}),{code:r,buffer:i}=yield this.context.rtcSignaling("",Pa,!0,t);if(r!==n.SUCCESS||!i)return{code:r};return{code:r,data:(this.codec.decode(wa.RtcQueryUserJoinedOutput,i).info||[]).map((e=>({deviceId:e.deviceId,roomId:e.roomId,joinTime:Mt(e.joinTime)})))}}))}pullRTCRoomEntry(e){return E(this,void 0,void 0,(function*(){const t=this.codec.encode(wa.RtcPullKV,{timestamp:0,roomId:e}),{code:r,buffer:i}=yield this.context.rtcSignaling(e,ba,!0,t);if(r!==n.SUCCESS)return{code:r};const s=this.codec.decode(wa.RtcKVOutput,i);let{entries:o,syncTime:a}=s;return o=(o||[]).map((e=>Object.assign(Object.assign({},e),{timestamp:Mt(e.timestamp)}))),{code:r,data:{kvEntries:o,syncTime:Mt(a)}}}))}pullRTCRoomStatus(e,t){return E(this,void 0,void 0,(function*(){const r=this.codec.encode(wa.RtcRoomStatusInput,{version:t}),{code:i,buffer:s}=yield this.context.rtcSignaling(e,Ua,!0,r);if(i!==n.SUCCESS)return{code:i};return{code:i,data:this.codec.decode(wa.RtcRoomStatusOutput,s)}}))}decodeRtcNotify(e){const{time:t,type:r,roomId:i}=this.codec.decode(wa.RtcNotifyMsg,e);return{time:Mt(t),type:r,roomId:i}}getCurrentId(){return this.context.getCurrentId()}getNaviInfo(){return this.context.getNaviInfo()}getConnectionStatus(){return this.context.getConnectionStatus()}getAppkey(){return this.context.getAppkey()}webRtcPing(e,t,r){return E(this,void 0,void 0,(function*(){const i=this.codec.encode(wa.RtcInput,{roomType:t,broadcastType:r}),{code:s,buffer:o}=yield this.context.rtcSignaling(e,Ma,!0,i);if(s!==n.SUCCESS)return{code:s};const a=this.codec.decode(wa.RtcOutput,o);return a.version=Mt(a.version),{code:s,data:a}}))}rtcPing(e,t,r){return/Electron/.test(navigator.userAgent)?this.context.rtcPingResVersion(e,t,r):this.webRtcPing(e,t,r)}sendMessage(e,t,r){return this.context.sendMessage(e,t,r)}registerRTCSignalListener(e){this.context.registerRTCSignalListener(e)}registerConnectionStateChangeListener(e){this.context.onconnectionstatechange=e}registerDisconnectListener(e){this.context.ondisconnect=e}registerDestroyListener(e){this.context.ondestroy=e}registerMessageListener(e){this.context.onmessage=e}getCoreVersion(){return this.context.getCoreVersion()}getPluginContext(){return this.context}reportSDKInfo(e){const t=this.codec.encode(wa.RtcReportSDKInput,{sdkInfo:JSON.stringify(e)});this.context.rtcSignaling("",ka,!0,t)}}var Ja;!function(e){e.RTC="RTC"}(Ja||(Ja={})),m.add("rtclib","5.28.0");const Ga={tag:"RCRTC",verify:e=>"undefined"==typeof isSecureContext||isSecureContext?!!m.validEngine("5.28.0")||(console.error(`The current engine version '${m.getInfo().engine}' error, plugin-rtc required engine version at least '5.28.0'.`),!1):(console.error("Please use the https protocol or use `http://localhost` to open the page!"),!1),setup(e,r,i={}){const n=e.createLogger("RCRTC",Ja.RTC);if(i.logLevel&&n.setOutputLevel(i.logLevel),n.warn(S.L_INDEX_INSTALL_RTC_PLUGIN_O,JSON.stringify({"RCRTC Version":"5.28.0",Commit:"863cb74b5c0ba6e848be60eeb09fdb7a20d69d92","browserInfo.browser":yt.browser,"browserInfo.supportsUnifiedPlan":yt.supportsUnifiedPlan,"browserInfo.version":yt.version})),l("options",i,f.OBJECT,!0),l("options.mediaServer",i.mediaServer,(e=>!(!h(e)||"https:"===location.protocol&&!/^https/.test(e)))),l("options.timeout",i.timeout,(e=>t(e)&&e>=5e3&&e<=3e4)),l("options.pingGap",i.pingGap,(e=>t(e)&&e>=3e3&&e<=1e4)),i.AAAWorklet){l("options.AAAWorklet",i.AAAWorklet,f.OBJECT,!0);const{scriptUrl:e,wasmUrl:t}=i.AAAWorklet;l("AAAWorklet.scriptUrl",e,f.STRING,!0),l("AAAWorklet.wasmUrl",t,f.STRING,!0),Ze.SCRIPT_URL=e,Ze.WASM_URL=t}return i.encryptor&&(l("options.encrypt",i.encryptor,f.OBJECT,!0),l("options.encrypt.decodeAudio",i.encryptor.decodeAudio,(e=>"function"==typeof e),!0),l("options.encrypt.decodeVideo",i.encryptor.decodeVideo,(e=>"function"==typeof e),!0),l("options.encrypt.encodeAudio",i.encryptor.encodeAudio,(e=>"function"==typeof e),!0),l("options.encrypt.encodeVideo",i.encryptor.encodeVideo,(e=>"function"==typeof e),!0),Cs.init(i.encryptor,n)),new la(new Fa(e,n,e.createCodec(Ba,xa)),r,i)}},Ha={DEFAULT:"RongCloudRTC"},Ka={transResolution:Ct,transFrameRate:Lt,parseTrackId:Et,ifSupportLocalFileTrack:Nt,ifSupportScreenShare:At};export{Vo as BackgroundPictureFillMode,jo as MixLayoutMode,Fo as MixVideoRenderMode,Bo as RCAbstractRoom,ia as RCAudienceClient,aa as RCAudienceLivingRoom,We as RCAudioBitrate,ot as RCCameraVideoTrack,Be as RCFrameRate,sa as RCInnerCDNPullIsHttps,na as RCInnerCDNPullKind,No as RCKickReason,Xo as RCLivingRoom,Ko as RCLivingType,et as RCLocalAudioTrack,nt as RCLocalFileAudioTrack,rt as RCLocalFileTrack,it as RCLocalFileVideoTrack,Xe as RCLocalTrack,tt as RCLocalVideoTrack,Ho as RCMCUConfigBuilder,da as RCMediaStreamCapture,Ve as RCMediaType,st as RCMicphoneAudioTrack,la as RCRTCClient,I as RCRTCCode,hs as RCRTCLiveRole,Bt as RCRTCPingResult,ea as RCRTCRoom,dt as RCRemoteAudioTrack,_t as RCRemoteTrack,lt as RCRemoteVideoTrack,xe as RCResolution,ct as RCScreenAudioTrack,at as RCScreenVideoTrack,Ha as RCTag,Ye as RCTrack,qe as RCVideoBitrate,_a as RTCJoinType,ms as RTCMode,Ke as device,Ka as helper,Ga as installer};
|