@rongcloud/plugin-rtc 5.32.0-c-im-alpha.2 → 5.34.0-alpha.1
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.d.ts +1466 -1246
- package/dist/index.esm.js +2 -2
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@rongcloud/engine"),t=function(e,r){return t=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])},t(e,r)};function r(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}var i,n,o,a=function(){return a=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},a.apply(this,arguments)};function s(e,t,r,i){return new(r||(r=Promise))((function(n,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(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(a,s)}c((i=i.apply(e,t||[])).next())}))}function c(e,t){var r,i,n,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[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,i&&(n=2&s[0]?i.return:s[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,s[1])).done)return n;switch(i=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){o.label=s[1];break}if(6===s[0]&&o.label<n[1]){o.label=n[1],n=s;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(s);break}n[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],i=0}finally{r=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return a}function d(e,t,r){if(r||2===arguments.length)for(var i,n=0,o=t.length;n<o;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,exports.RCRTCCode=void 0,(i=exports.RCRTCCode||(exports.RCRTCCode={}))[i.SUCCESS=1e4]="SUCCESS",i[i.PB_ERROR=40001]="PB_ERROR",i[i.SIGNAL_DISCONNECTED=5e4]="SIGNAL_DISCONNECTED",i[i.PARAMS_ERROR=50001]="PARAMS_ERROR",i[i.REPERT_JOIN_ROOM=50002]="REPERT_JOIN_ROOM",i[i.NOT_IN_ROOM=50003]="NOT_IN_ROOM",i[i.SERVICE_INVALID=50004]="SERVICE_INVALID",i[i.RTC_TOKEN_INVALID=50006]="RTC_TOKEN_INVALID",i[i.SIGNAL_ERROR=53001]="SIGNAL_ERROR",i[i.CREATE_OFFER_FAILED=53003]="CREATE_OFFER_FAILED",i[i.REQUEST_FAILED=53004]="REQUEST_FAILED",i[i.MCU_SERVER_NOT_FOUND=53005]="MCU_SERVER_NOT_FOUND",i[i.BROADCAST_SUB_LIST_NOT_EMPTY=53007]="BROADCAST_SUB_LIST_NOT_EMPTY",i[i.ROOM_HAS_BEEN_DESTROYED=53008]="ROOM_HAS_BEEN_DESTROYED",i[i.NOT_OPEN_VIDEO_AUDIO_SERVER=53009]="NOT_OPEN_VIDEO_AUDIO_SERVER",i[i.GET_USER_MEDIA_FAILED=53010]="GET_USER_MEDIA_FAILED",i[i.GET_DISPLAY_MEDIA_FAILED=53011]="GET_DISPLAY_MEDIA_FAILED",i[i.BROWSER_PERMISSION_DENIED=53012]="BROWSER_PERMISSION_DENIED",i[i.CREATE_CUSTOM_TRACK_FAILED=53013]="CREATE_CUSTOM_TRACK_FAILED",i[i.INVALID_TAGS=53014]="INVALID_TAGS",i[i.INVALID_USER_ID=53015]="INVALID_USER_ID",i[i.CREATE_FILE_TRACK_FAILED=53016]="CREATE_FILE_TRACK_FAILED",i[i.INVALID_FILE_INSTANCE=53017]="INVALID_FILE_INSTANCE",i[i.SET_REMOTE_DESCRIPTION_FAILED=53018]="SET_REMOTE_DESCRIPTION_FAILED",i[i.BROWSER_NOT_SUPPORT=53019]="BROWSER_NOT_SUPPORT",i[i.TRACK_NOT_READY=53020]="TRACK_NOT_READY",i[i.VIDEO_TRACK_MISS_MEDIA_ELEMENT=53021]="VIDEO_TRACK_MISS_MEDIA_ELEMENT",i[i.TRACK_PLAY_ERROR=53022]="TRACK_PLAY_ERROR",i[i.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED=53023]="SIGNAL_AUDIENCE_JOIN_ROOM_FAILED",i[i.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED=53024]="SIGNAL_ROOM_CHANGE_IDENTITY_FAILED",i[i.PACKAGE_ENVIRONMENT_ERROR=53025]="PACKAGE_ENVIRONMENT_ERROR",i[i.PUBLISH_TRACK_LIMIT_EXCEEDED=53026]="PUBLISH_TRACK_LIMIT_EXCEEDED",i[i.CDN_RESOURCE_IS_EMPTY=53027]="CDN_RESOURCE_IS_EMPTY",i[i.SIGNAL_JOIN_RTC_ROOM_REFUSED=53028]="SIGNAL_JOIN_RTC_ROOM_REFUSED",i[i.NO_PERMISSION_TO_USE_REQUESTED_DEVICE=53029]="NO_PERMISSION_TO_USE_REQUESTED_DEVICE",i[i.THE_FUNCTION_IS_DISABLED_IN_PKROOM=53030]="THE_FUNCTION_IS_DISABLED_IN_PKROOM",i[i.SOME_TRACKS_PUBLISH_FAILED=53031]="SOME_TRACKS_PUBLISH_FAILED",i[i.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO=53032]="MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO",i[i.JWT_TIME_OUT=1004]="JWT_TIME_OUT",i[i.SYSTEM_PERMISSION_DENIED=53033]="SYSTEM_PERMISSION_DENIED",i[i.PUBLISH_TRACKS_IS_INVALID=53034]="PUBLISH_TRACKS_IS_INVALID",i[i.TRACK_READYSTATE_IS_ENDED=53035]="TRACK_READYSTATE_IS_ENDED",i[i.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH=53036]="APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH",i[i.LOAD_3A_MODULE_FAILED=53037]="LOAD_3A_MODULE_FAILED",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.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_T="L-rtc_client_change_media_device-T",e.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R="L-rtc_client_change_media_device-R"}(n||(n={})),function(e){e.FAILED="fail",e.SUCCESSED="success",e.TIMEOUT="timeout",e.INFO="info"}(o||(o={}));let _=!0,p=!0;function f(e,t,r){const i=e.match(t);return i&&i.length>=r&&parseInt(i[r],10)}function h(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 o=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,o),n.apply(this,[e,o])};const o=i.removeEventListener;i.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 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,o.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 b(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(_=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function R(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(p=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function g(){if("object"==typeof window){if(_)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function m(e,t){p&&console.warn(e+" is deprecated, please use "+t+" instead.")}function C(e){return"[object Object]"===Object.prototype.toString.call(e)}function v(e){return C(e)?Object.keys(e).reduce((function(t,r){const i=C(e[r]),n=i?v(e[r]):e[r],o=i&&!Object.keys(n).length;return void 0===n||o?t:Object.assign(t,{[r]:n})}),{}):e}function O(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach((i=>{i.endsWith("Id")?O(e,e.get(t[i]),r):i.endsWith("Ids")&&t[i].forEach((t=>{O(e,e.get(t),r)}))})))}function T(e,t,r){const i=r?"outbound-rtp":"inbound-rtp",n=new Map;if(null===t)return n;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((r=>{r.type===i&&r.trackId===t.id&&O(e,r,n)}))})),n}const E=g;function I(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 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=i(e.video),E("chrome: "+JSON.stringify(e)),n(e)}))}e.video=i(e.video)}return E("chrome: "+JSON.stringify(e)),n(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,i){n(e,(e=>{r.webkitGetUserMedia(e,t,(e=>{i&&i(o(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(o(e))))))}}}function S(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function y(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 h(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function L(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 P(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},o=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const i=function(e){r(o(n(e)))};return t.apply(this,[i,e])}return new Promise(((e,r)=>{t.apply(this,[function(t){e(o(n(t)))},r])})).then(r,i)}}function A(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=>T(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}),h(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>T(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 N(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 w(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return N(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 o(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=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]=i[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 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]),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 D(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){h(e,"negotiationneeded",(e=>{const r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var U=Object.freeze({__proto__:null,shimMediaStream:S,shimOnTrack:y,shimGetSendersWithDtmf:L,shimGetStats:P,shimSenderReceiverGetStats:A,shimAddTrackRemoveTrackWithNative:N,shimAddTrackRemoveTrack:w,shimPeerConnection:D,fixNegotiationNeeded:k,shimGetUserMedia:I,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,o=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||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 M,x,j=(M=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 o=i[n],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 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),o=-1!==n.fecMechanisms.indexOf("RED"),a=-1!==n.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]),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),o&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},i.push(t))}})),0===i.length&&c&&i.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,i.forEach((function(e){e.maxBitrate=l}))),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 o=t.matchPrefix(e,"a=rtcp-mux");return r.mux=o.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 o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:i.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,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 o=t.writeRtpDescription(e.kind,r);if(o+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===i?"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:"+n.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 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},M(x={exports:{}},x.exports),x.exports);function B(e,t,r,i,n){var o=j.writeRtpDescription(e.kind,t);if(o+=j.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=j.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":n||"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:"+(i?i.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:"+j.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+j.localCName+"\r\n"),o}function V(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 o=i(e.parameters.apt,r),a=i(t.parameters.apt,n);return o&&a&&o.name.toLowerCase()===a.name.toLowerCase()};return e.codecs.forEach((function(i){for(var o=0;o<t.codecs.length;o++){var a=t.codecs[o];if(i.name.toLowerCase()===a.name.toLowerCase()&&i.clockRate===a.clockRate){if("rtx"===i.name.toLowerCase()&&i.parameters&&a.parameters.apt&&!n(i,a,e.codecs,t.codecs))continue;(a=JSON.parse(JSON.stringify(a))).numChannels=Math.min(i.numChannels,a.numChannels),r.codecs.push(a),a.rtcpFeedback=a.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 F(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 J(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 G(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 H=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 o=new Event("track");o.track=r,o.receiver=i,o.transceiver={receiver:i},o.streams=n,e.setTimeout((function(){t._dispatchEvent("track",o)}))}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 G("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 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=j.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 G("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var i;if(this.transceivers.find((function(e){return e.track===t})))throw G("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 G("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 G("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 o=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 o=new Event("icecandidate");o.candidate={sdpMid:t,sdpMLineIndex:r};var a=e.candidate,s=!a||0===Object.keys(a).length;if(s)"new"!==n.state&&"gathering"!==n.state||(n.state="completed");else{"new"===n.state&&(n.state="gathering"),a.component=1,a.ufrag=n.getLocalParameters().usernameFragment;var c=j.writeCandidate(a);o.candidate=Object.assign(o.candidate,j.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=j.getMediaSections(i._localDescription.sdp);u[o.candidate.sdpMLineIndex]+=s?"a=end-of-candidates\r\n":"a="+o.candidate.candidate+"\r\n",i._localDescription.sdp=j.getDescription(i._localDescription.sdp)+u.join("");var l=i.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),s||i._dispatchEvent("icecandidate",o),l&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout((function(){o.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=V(e.localCapabilities,e.remoteCapabilities);r&&e.rtpSender&&(n.encodings=e.sendEncodingParameters,n.rtcp={cname:j.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(G("TypeError",'Unsupported type "'+e.type+'"'));if(!F("setLocalDescription",e.type,i.signalingState)||i._isClosed)return Promise.reject(G("InvalidStateError","Can not set local "+e.type+" in state "+i.signalingState));if("offer"===e.type)t=j.splitSections(e.sdp),r=t.shift(),t.forEach((function(e,t){var r=j.parseRtpParameters(e);i.transceivers[t].localCapabilities=r})),i.transceivers.forEach((function(e,t){i._gather(e.mid,t)}));else if("answer"===e.type){t=j.splitSections(i._remoteDescription.sdp),r=t.shift();var n=j.matchPrefix(r,"a=ice-lite").length>0;t.forEach((function(e,t){var o=i.transceivers[t],a=o.iceGatherer,s=o.iceTransport,c=o.dtlsTransport,u=o.localCapabilities,l=o.remoteCapabilities;if(!(j.isRejected(e)&&0===j.matchPrefix(e,"a=bundle-only").length)&&!o.rejected){var d=j.getIceParameters(e,r),_=j.getDtlsParameters(e,r);n&&(_.role="server"),i.usingBundle&&0!==t||(i._gather(o.mid,t),"new"===s.state&&s.start(a,d,n?"controlling":"controlled"),"new"===c.state&&c.start(_));var p=V(u,l);i._transceive(o,p.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 o=this;if(-1===["offer","answer"].indexOf(n.type))return Promise.reject(G("TypeError",'Unsupported type "'+n.type+'"'));if(!F("setRemoteDescription",n.type,o.signalingState)||o._isClosed)return Promise.reject(G("InvalidStateError","Can not set remote "+n.type+" in state "+o.signalingState));var a={};o.remoteStreams.forEach((function(e){a[e.id]=e}));var s=[],c=j.splitSections(n.sdp),u=c.shift(),l=j.matchPrefix(u,"a=ice-lite").length>0,d=j.matchPrefix(u,"a=group:BUNDLE ").length>0;o.usingBundle=d;var _=j.matchPrefix(u,"a=ice-options:")[0];return o.canTrickleIceCandidates=!!_&&_.substr(14).split(" ").indexOf("trickle")>=0,c.forEach((function(i,c){var _=j.splitLines(i),p=j.getKind(i),f=j.isRejected(i)&&0===j.matchPrefix(i,"a=bundle-only").length,h=_[0].substr(2).split(" ")[2],b=j.getDirection(i,u),R=j.parseMsid(i),g=j.getMid(i)||j.generateIdentifier();if(f||"application"===p&&("DTLS/SCTP"===h||"UDP/DTLS/SCTP"===h))o.transceivers[c]={mid:g,kind:p,protocol:h,rejected:!0};else{var m,C,v,O,T,E,I,S,y;!f&&o.transceivers[c]&&o.transceivers[c].rejected&&(o.transceivers[c]=o._createTransceiver(p,!0));var L,P,A=j.parseRtpParameters(i);f||(L=j.getIceParameters(i,u),(P=j.getDtlsParameters(i,u)).role="client"),I=j.parseRtpEncodingParameters(i);var N=j.parseRtcpParameters(i),w=j.matchPrefix(i,"a=end-of-candidates",u).length>0,D=j.matchPrefix(i,"a=candidate:").map((function(e){return j.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===n.type||"answer"===n.type)&&!f&&d&&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"!==n.type||f){if("answer"===n.type&&!f){C=(m=o.transceivers[c]).iceGatherer,v=m.iceTransport,O=m.dtlsTransport,T=m.rtpReceiver,E=m.sendEncodingParameters,S=m.localCapabilities,o.transceivers[c].recvEncodingParameters=I,o.transceivers[c].remoteCapabilities=A,o.transceivers[c].rtcpParameters=N,D.length&&"new"===v.state&&(!l&&!w||d&&0!==c?D.forEach((function(e){J(m.iceTransport,e)})):v.setRemoteCandidates(D)),d&&0!==c||("new"===v.state&&v.start(C,L,"controlling"),"new"===O.state&&O.start(P)),!V(m.localCapabilities,m.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&m.sendEncodingParameters[0].rtx&&delete m.sendEncodingParameters[0].rtx,o._transceive(m,"sendrecv"===b||"recvonly"===b,"sendrecv"===b||"sendonly"===b),!T||"sendrecv"!==b&&"sendonly"!==b?delete m.rtpReceiver:(y=T.track,R?(a[R.stream]||(a[R.stream]=new e.MediaStream),r(y,a[R.stream]),s.push([y,T,a[R.stream]])):(a.default||(a.default=new e.MediaStream),r(y,a.default),s.push([y,T,a.default])))}}else{(m=o.transceivers[c]||o._createTransceiver(p)).mid=g,m.iceGatherer||(m.iceGatherer=o._createIceGatherer(c,d)),D.length&&"new"===m.iceTransport.state&&(!w||d&&0!==c?D.forEach((function(e){J(m.iceTransport,e)})):m.iceTransport.setRemoteCandidates(D)),S=e.RTCRtpReceiver.getCapabilities(p),t<15019&&(S.codecs=S.codecs.filter((function(e){return"rtx"!==e.name}))),E=m.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var k,U=!1;if("sendrecv"===b||"sendonly"===b){if(U=!m.rtpReceiver,T=m.rtpReceiver||new e.RTCRtpReceiver(m.dtlsTransport,p),U)y=T.track,R&&"-"===R.stream||(R?(a[R.stream]||(a[R.stream]=new e.MediaStream,Object.defineProperty(a[R.stream],"id",{get:function(){return R.stream}})),Object.defineProperty(y,"id",{get:function(){return R.track}}),k=a[R.stream]):(a.default||(a.default=new e.MediaStream),k=a.default)),k&&(r(y,k),m.associatedRemoteMediaStreams.push(k)),s.push([y,T,k])}else m.rtpReceiver&&m.rtpReceiver.track&&(m.associatedRemoteMediaStreams.forEach((function(t){var r=t.getTracks().find((function(e){return e.id===m.rtpReceiver.track.id}));r&&function(t,r){r.removeTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(r,t)})),m.associatedRemoteMediaStreams=[]);m.localCapabilities=S,m.remoteCapabilities=A,m.rtpReceiver=T,m.rtcpParameters=N,m.sendEncodingParameters=E,m.recvEncodingParameters=I,o._transceive(o.transceivers[c],!1,U)}}})),void 0===o._dtlsRole&&(o._dtlsRole="offer"===n.type?"active":"passive"),o._remoteDescription={type:n.type,sdp:n.sdp},"offer"===n.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 n=new Event("addstream");n.stream=r,e.setTimeout((function(){o._dispatchEvent("addstream",n)}))}s.forEach((function(e){var t=e[0],n=e[1];r.id===e[2].id&&i(o,t,n,[r])}))}})),s.forEach((function(e){e[2]||i(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()},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(G("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,o=arguments[0];if(o){if(o.mandatory||o.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==o.offerToReceiveAudio&&(i=!0===o.offerToReceiveAudio?1:!1===o.offerToReceiveAudio?0:o.offerToReceiveAudio),void 0!==o.offerToReceiveVideo&&(n=!0===o.offerToReceiveVideo?1:!1===o.offerToReceiveVideo?0:o.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 a=j.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.transceivers.forEach((function(i,n){var o=i.track,a=i.kind,s=i.mid||j.generateIdentifier();i.mid=s,i.iceGatherer||(i.iceGatherer=r._createIceGatherer(n,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"),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 u=i.sendEncodingParameters||[{ssrc:1001*(2*n+1)}];o&&t>=15019&&"video"===a&&!u[0].rtx&&(u[0].rtx={ssrc:u[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,a)),i.localCapabilities=c,i.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+=B(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="+j.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)},n.prototype.createAnswer=function(){var r=this;if(r._isClosed)return Promise.reject(G("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==r.signalingState&&"have-local-pranswer"!==r.signalingState)return Promise.reject(G("InvalidStateError","Can not call createAnswer in signalingState "+r.signalingState));var i=j.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=j.getMediaSections(r._remoteDescription.sdp).length;r.transceivers.forEach((function(e,o){if(!(o+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 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=V(e.localCapabilities,e.remoteCapabilities);!s.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,i+=B(e,s,"answer",e.stream,r._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(i+="a=rtcp-rsize\r\n")}}));var o=new e.RTCSessionDescription({type:"answer",sdp:i});return Promise.resolve(o)},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(G("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 n(G("OperationError","Can not add ICE candidate"));if(s.rejected)return i();var c=Object.keys(e.candidate).length>0?j.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===o||o>0&&s.iceTransport!==r.transceivers[0].iceTransport)&&!J(s.iceTransport,c))return n(G("OperationError","Can not add ICE candidate"));var u=e.candidate.trim();0===u.indexOf("a=")&&(u=u.substr(2)),(t=j.getMediaSections(r._remoteDescription.sdp))[o]+="a="+(c.type?u:"end-of-candidates")+"\r\n",r._remoteDescription.sdp=j.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=j.getMediaSections(r._remoteDescription.sdp))[l]+="a=end-of-candidates\r\n",r._remoteDescription.sdp=j.getDescription(r._remoteDescription.sdp)+t.join(""),!r.usingBundle));l++);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 G("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 o=["createOffer","createAnswer"];return o.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)}})),(o=["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 K(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 W(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 Y(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=H(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&&m("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),g("ICE servers after filtering:",e.iceServers)),new r(e)},e.RTCPeerConnection.prototype=r.prototype}function z(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}var q=Object.freeze({__proto__:null,shimPeerConnection:Y,shimReplaceTrack:z,shimGetUserMedia:K,shimGetDisplayMedia:W});function Q(e,t){const r=e&&e.navigator,i=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,i){m("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 Z(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 X(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,o]=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,o)}}function $(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 ee(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}),h(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function te(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){m("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 ie(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 ne(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 oe(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 ae(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 se=Object.freeze({__proto__:null,shimOnTrack:Z,shimPeerConnection:X,shimSenderGetStats:$,shimReceiverGetStats:ee,shimRemoveStream:te,shimRTCDataChannel:re,shimAddTransceiver:ie,shimGetParameters:ne,shimCreateOffer:oe,shimCreateAnswer:ae,shimGetUserMedia:Q,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 ce(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 ue(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,i=t.createAnswer,n=t.setLocalDescription,o=t.setRemoteDescription,a=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 s=function(e,t,r){const i=n.apply(this,[e]);return r?(i.then(t,r),Promise.resolve()):i};t.setLocalDescription=s,s=function(e,t,r){const i=o.apply(this,[e]);return r?(i.then(t,r),Promise.resolve()):i},t.setRemoteDescription=s,s=function(e,t,r){const i=a.apply(this,[e]);return r?(i.then(t,r),Promise.resolve()):i},t.addIceCandidate=s}function de(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(_e(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,i){t.mediaDevices.getUserMedia(e).then(r,i)}.bind(t))}function _e(e){return e&&void 0!==e.video?Object.assign({},e,{video:v(e.video)}):e}function pe(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")?(m("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 fe(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 he(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 be(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var Re=Object.freeze({__proto__:null,shimLocalStreamsAPI:ce,shimRemoteStreamsAPI:ue,shimCallbacksAPI:le,shimGetUserMedia:de,shimConstraints:_e,shimRTCIceServerUrls:pe,shimTrackEventTransceiver:fe,shimCreateOfferLegacy:he,shimAudioContext:be});function ge(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=j.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,h(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function me(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=j.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=j.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=j.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 o={};Object.defineProperty(o,"maxMessageSize",{get:()=>n}),this._sctp=o}return r.apply(this,arguments)}}function Ce(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},h(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function ve(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 Oe(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 Te(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 Ee=Object.freeze({__proto__:null,shimRTCIceCandidate:ge,shimMaxMessageSize:me,shimSendThrowTypeError:Ce,shimConnectionState:ve,removeExtmapAllowMixed:Oe,shimAddIceCandidateNullOrEmpty:Te});const Ie=function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const r=g,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=f(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=f(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(r.mediaDevices&&r.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=f(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=f(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),n={browserDetails:i,commonShim:Ee,extractVersion:f,disableLog:b,disableWarnings:R};switch(i.browser){case"chrome":if(!U||!D||!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=U,Te(e,i),I(e,i),S(e),D(e,i),y(e),w(e,i),L(e),P(e),A(e),k(e,i),ge(e),ve(e),me(e,i),Ce(e),Oe(e,i);break;case"firefox":if(!se||!X||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),n;r("adapter.js shimming firefox."),n.browserShim=se,Te(e,i),Q(e,i),X(e,i),Z(e),te(e),$(e),ee(e),re(e),ie(e),ne(e),oe(e),ae(e),ge(e),ve(e),me(e,i),Ce(e);break;case"edge":if(!q||!Y||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),n;r("adapter.js shimming edge."),n.browserShim=q,K(e),W(e),Y(e,i),z(e),me(e,i),Ce(e);break;case"safari":if(!Re||!t.shimSafari)return r("Safari shim is not included in this adapter release."),n;r("adapter.js shimming safari."),n.browserShim=Re,Te(e,i),pe(e),he(e),le(e),ce(e),ue(e),fe(e),de(e),be(e),ge(e),me(e,i),Ce(e),Oe(e,i);break;default:r("Unsupported browser!")}return n}({window:"undefined"==typeof window?void 0:window});var Se,ye,Le,Pe;exports.RCFrameRate=void 0,(Se=exports.RCFrameRate||(exports.RCFrameRate={})).FPS_10="FPS_10",Se.FPS_15="FPS_15",Se.FPS_24="FPS_24",Se.FPS_30="FPS_30",exports.RCResolution=void 0,(ye=exports.RCResolution||(exports.RCResolution={})).W176_H132="W176_H132",ye.W176_H144="W176_H144",ye.W180_H180="W180_H180",ye.W240_H180="W240_H180",ye.W240_H240="W240_H240",ye.W256_H144="W256_H144",ye.W320_H180="W320_H180",ye.W320_H240="W320_H240",ye.W360_H360="W360_H360",ye.W480_H360="W480_H360",ye.W480_H480="W480_H480",ye.W640_H360="W640_H360",ye.W640_H480="W640_H480",ye.W720_H480="W720_H480",ye.W848_H480="W848_H480",ye.W960_H720="W960_H720",ye.W1280_H720="W1280_H720",ye.W1920_H1080="W1920_H1080",ye.W144_H176="W144_H176",ye.W144_H256="W144_H256",ye.W180_H240="W180_H240",ye.W180_H320="W180_H320",ye.W240_H320="W240_H320",ye.W360_H480="W360_H480",ye.W360_H640="W360_H640",ye.W480_H640="W480_H640",ye.W480_H720="W480_H720",ye.W480_H848="W480_H848",ye.W720_H1280="W720_H1280",ye.W720_H960="W720_H960",ye.W1080_H1920="W1080_H1920",exports.RCMediaType=void 0,(Le=exports.RCMediaType||(exports.RCMediaType={}))[Le.AUDIO_ONLY=0]="AUDIO_ONLY",Le[Le.VIDEO_ONLY=1]="VIDEO_ONLY",Le[Le.AUDIO_VIDEO=2]="AUDIO_VIDEO";var Ae,Ne=((Pe={})[exports.RCResolution.W176_H132]={width:176,height:132,maxBitrate:150,minBitrate:80},Pe[exports.RCResolution.W176_H144]={width:176,height:144,maxBitrate:150,minBitrate:80},Pe[exports.RCResolution.W180_H180]={width:180,height:180,maxBitrate:200,minBitrate:100},Pe[exports.RCResolution.W240_H180]={width:240,height:180,maxBitrate:240,minBitrate:120},Pe[exports.RCResolution.W240_H240]={width:240,height:240,maxBitrate:280,minBitrate:120},Pe[exports.RCResolution.W256_H144]={width:256,height:144,maxBitrate:240,minBitrate:120},Pe[exports.RCResolution.W320_H180]={width:320,height:180,maxBitrate:280,minBitrate:120},Pe[exports.RCResolution.W320_H240]={width:320,height:240,maxBitrate:400,minBitrate:120},Pe[exports.RCResolution.W360_H360]={width:360,height:360,maxBitrate:520,minBitrate:140},Pe[exports.RCResolution.W480_H360]={width:480,height:360,maxBitrate:650,minBitrate:150},Pe[exports.RCResolution.W480_H480]={width:480,height:480,maxBitrate:800,minBitrate:180},Pe[exports.RCResolution.W640_H360]={width:640,height:360,maxBitrate:800,minBitrate:180},Pe[exports.RCResolution.W640_H480]={width:640,height:480,maxBitrate:900,minBitrate:200},Pe[exports.RCResolution.W720_H480]={width:720,height:480,maxBitrate:1e3,minBitrate:200},Pe[exports.RCResolution.W848_H480]={width:848,height:480,maxBitrate:1860,minBitrate:200},Pe[exports.RCResolution.W960_H720]={width:960,height:720,maxBitrate:2e3,minBitrate:250},Pe[exports.RCResolution.W1280_H720]={width:1280,height:720,maxBitrate:2200,minBitrate:250},Pe[exports.RCResolution.W1920_H1080]={width:1920,height:1080,maxBitrate:4e3,minBitrate:400},Pe[exports.RCResolution.W144_H176]={width:144,height:176,maxBitrate:150,minBitrate:80},Pe[exports.RCResolution.W144_H256]={width:144,height:256,maxBitrate:240,minBitrate:120},Pe[exports.RCResolution.W180_H240]={width:180,height:240,maxBitrate:240,minBitrate:120},Pe[exports.RCResolution.W180_H320]={width:180,height:320,maxBitrate:280,minBitrate:120},Pe[exports.RCResolution.W240_H320]={width:240,height:320,maxBitrate:400,minBitrate:120},Pe[exports.RCResolution.W360_H480]={width:360,height:480,maxBitrate:650,minBitrate:150},Pe[exports.RCResolution.W360_H640]={width:360,height:640,maxBitrate:800,minBitrate:180},Pe[exports.RCResolution.W480_H640]={width:480,height:640,maxBitrate:900,minBitrate:200},Pe[exports.RCResolution.W480_H720]={width:480,height:720,maxBitrate:1e3,minBitrate:200},Pe[exports.RCResolution.W480_H848]={width:480,height:848,maxBitrate:1860,minBitrate:930},Pe[exports.RCResolution.W720_H1280]={width:720,height:1280,maxBitrate:2200,minBitrate:250},Pe[exports.RCResolution.W720_H960]={width:720,height:960,maxBitrate:2760,minBitrate:910},Pe[exports.RCResolution.W1080_H1920]={width:1080,height:1920,maxBitrate:4e3,minBitrate:400},Pe),we=function(e){var t={192:180,368:360,1088:1080};return t[e]?t[e]:e},De=function(e,t){e=we(e),t=we(t);var r=Ne["W".concat(e,"_H").concat(t)];if(r)return r;var i=e*t;return Object.keys(Ne).map((function(e){return Ne[e]})).sort((function(e,t){return e.height*e.width-t.width*t.height})).filter((function(e){return e.height*e.width>=i}))[0]||Ne.W1920_H1080},ke={10:1,15:1,24:1.5,30:1.5},Ue=function(e){var t=Number.MAX_VALUE,r=1;for(var i in ke){var n=Math.abs(e-parseInt(i));n<t&&(t=n,r=ke[i])}return r},Me={getCameras:function(){return s(void 0,void 0,void 0,(function(){return c(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 s(void 0,void 0,void 0,(function(){return c(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 s(void 0,void 0,void 0,(function(){return c(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"}(Ae||(Ae={}));var xe,je,Be,Ve=function(t){function i(e,r,i,n,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:i}),Object.defineProperty(s,"_kind",{enumerable:!0,configurable:!0,writable:!0,value:n}),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(i,t),Object.defineProperty(i.prototype,"getStreamId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._streamId}}),Object.defineProperty(i.prototype,"getTrackId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._id}}),Object.defineProperty(i.prototype,"getUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._userId}}),Object.defineProperty(i.prototype,"__innerGetMediaStreamTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._msTrack}}),Object.defineProperty(i.prototype,"streamTrack",{get:function(){return this._msTrack},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"getTag",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._tag}}),Object.defineProperty(i.prototype,"isLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isLocalTrack}}),Object.defineProperty(i.prototype,"isVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"video"===this._kind}}),Object.defineProperty(i.prototype,"isAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"audio"===this._kind}}),Object.defineProperty(i.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(i.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(n.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(i.prototype,"_setLocalMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){return this._msTrack&&(this._msTrack.enabled=!e),this._localMuted=e,[2,exports.RCRTCCode.SUCCESS]}))}))}}),Object.defineProperty(i.prototype,"mute",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this._setLocalMuted(!0)]}))}))}}),Object.defineProperty(i.prototype,"unmute",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this._setLocalMuted(!1)]}))}))}}),Object.defineProperty(i.prototype,"isLocalMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._localMuted}}),Object.defineProperty(i.prototype,"isMCUTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Boolean(this._roomId)}}),Object.defineProperty(i.prototype,"isOwnerMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._remoteMuted}}),Object.defineProperty(i.prototype,"_validateVolume",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(null==t?void 0:t.volume){if(!e.isNumber(null==t?void 0:t.volume))return this._logger.error(n.L_TRACK_PLAY_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> options.volume not a number"})),{code:exports.RCRTCCode.PARAMS_ERROR};(null==t?void 0:t.volume)<0&&(t.volume=0,this._logger.warn(n.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==t?void 0:t.volume)>100&&(t.volume=100,this._logger.warn(n.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"})))}}}),Object.defineProperty(i.prototype,"_validatePlayOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i;return c(this,(function(a){switch(a.label){case 0:return this._msTrack?("ended"===this._msTrack.readyState&&this._logger.warn(n.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,Me.getSpeakers()]:[3,2]):(this._logger.error(n.L_TRACK_PLAY_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.TRACK_NOT_READY,kind:this._kind,msg:"the track is not ready to play -> id: ".concat(this._id)})),[2,{code:exports.RCRTCCode.TRACK_NOT_READY}]);case 1:if(i=a.sent().map((function(e){return e.deviceId})),!i.includes(t.audioDeviceId))return this._logger.error(n.L_TRACK_PLAY_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> options.audioDeviceId"})),[2,{code:exports.RCRTCCode.PARAMS_ERROR}];a.label=2;case 2:return!this.isVideoTrack()||e&&(e instanceof HTMLVideoElement||this._validateVideoNodeName(e))?[2]:(this._logger.error(n.L_TRACK_PLAY_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.VIDEO_TRACK_MISS_MEDIA_ELEMENT,kind:this._kind,msg:"params element is not a HTMLVideoElement"})),[2,{code:exports.RCRTCCode.VIDEO_TRACK_MISS_MEDIA_ELEMENT}])}}))}))}}),Object.defineProperty(i.prototype,"_setPlayAttrs",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return s(this,void 0,void 0,(function(){return c(this,(function(i){switch(i.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:i.sent(),i.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(i.prototype,"play",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,a=this;return c(this,(function(u){switch(u.label){case 0:return this._logger.info(n.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=u.sent())?[2,r]:(i=this.isVideoTrack(),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=function(e){var t;a._logger.info(n.L_TRACK_LOAD_START_O,JSON.stringify({status:o.INFO,kind:a._kind,msg:"HTMLMediaElement onloadstart -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(a._id)}))},this._element.ondurationchange=function(e){var t;a._logger.info(n.L_TRACK_DURATION_CHANGE_O,JSON.stringify({status:o.INFO,kind:a._kind,msg:"HTMLMediaElement ondurationchange -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(a._id)}))},this._element.onloadedmetadata=function(e){var t;a._logger.info(n.L_TRACK_LOADED_META_DATA_O,JSON.stringify({status:o.INFO,kind:a._kind,msg:"HTMLMediaElement onloadedmetadata -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(a._id)}))},this._element.onloadeddata=function(e){var t;a._logger.info(n.L_TRACK_LOADED_DATA_O,JSON.stringify({status:o.INFO,kind:a._kind,msg:"HTMLMediaElement onloadeddata -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(a._id)}))},this._element.onabort=function(e){var t;a._logger.info(n.L_TRACK_ABORT_O,JSON.stringify({status:o.INFO,kind:a._kind,msg:"HTMLMediaElement onabort -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(a._id)}))},this._element.oncanplay=function(e){return s(a,void 0,void 0,(function(){var r,a,s;return c(this,(function(c){switch(c.label){case 0:this._logger.info(n.L_TRACK_CANPLAY_O,JSON.stringify({status:o.INFO,kind:this._kind,msg:"HTMLMediaElement oncanplay -> id: ".concat(null===(a=e.target)||void 0===a?void 0:a.id,", trackId: ").concat(this._id)})),c.label=1;case 1:return c.trys.push([1,5,,6]),!(null==t?void 0:t.audioDeviceId)||i?[3,3]:[4,this._element.setSinkId(t.audioDeviceId)];case 2:c.sent(),c.label=3;case 3:return[4,null===(s=this._element)||void 0===s?void 0:s.play()];case 4:return c.sent(),[3,6];case 5:return"No permission to use requested device"===(r=c.sent()).message?(this._logger.error(n.L_TRACK_PLAY_E,JSON.stringify({status:o.FAILED,kind:this._kind,code:exports.RCRTCCode.NO_PERMISSION_TO_USE_REQUESTED_DEVICE,msg:"setSinkId failed, error msg: ".concat(r.message)})),[2]):(this._logger.error(n.L_TRACK_PLAY_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.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,i=Math.floor(100*(null===(t=e.target)||void 0===t?void 0:t.volume));a._logger.info(n.L_TRACK_VOLUME_CHANGE_O,JSON.stringify({status:o.INFO,msg:"HTMLMediaElement onvolumechange -> id: ".concat(null===(r=e.target)||void 0===r?void 0:r.id,", volume: ").concat(i,", trackId: ").concat(a._id)}))},this._element.srcObject=this._msStream,this._element.autoplay=!0,[4,this._setPlayAttrs(i,t)]);case 2:return u.sent(),[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),Object.defineProperty(i.prototype,"__innerDestroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.__innerSetMediaStreamTrack(void 0)}}),Object.defineProperty(i.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(i.prototype,"_validateVideoNodeName",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e&&e.nodeName&&"VIDEO"===e.nodeName.toUpperCase()}}),i}(e.EventEmitter);exports.RCAudioBitrate=void 0,(Be=exports.RCAudioBitrate||(exports.RCAudioBitrate={})).Speech="Speech",Be.Music="Music",Be.MusicHigh="MusicHigh";var Fe,Je=((xe={})[exports.RCAudioBitrate.Music]={max:64,min:64},xe[exports.RCAudioBitrate.MusicHigh]={max:128,min:128},xe[exports.RCAudioBitrate.Speech]={max:32,min:32},xe);exports.RCVideoBitrate=void 0,(Fe=exports.RCVideoBitrate||(exports.RCVideoBitrate={})).LEVEL0="LEVEL0",Fe.LEVEL1="LEVEL1",Fe.LEVEL2="LEVEL2",Fe.LEVEL3="LEVEL3",Fe.LEVEL4="LEVEL4",Fe.LEVEL5="LEVEL5";var Ge=((je={})[exports.RCVideoBitrate.LEVEL0]={max:150,min:80},je[exports.RCVideoBitrate.LEVEL1]={max:280,min:120},je[exports.RCVideoBitrate.LEVEL2]={max:650,min:150},je[exports.RCVideoBitrate.LEVEL3]={max:1e3,min:200},je[exports.RCVideoBitrate.LEVEL4]={max:2200,min:250},je[exports.RCVideoBitrate.LEVEL5]={max:4e3,min:400},je),He=function(){function e(){}return Object.defineProperty(e,"apply3ANoiseWorklet",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,n,o,a,s;return c(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 i=c.sent(),[3,6];case 5:return c.sent(),[2,{code:exports.RCRTCCode.LOAD_3A_MODULE_FAILED}];case 6:return n=r.createMediaStreamSource(new MediaStream([t])),o=new AudioWorkletNode(r,"process-worklet",{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{binary:i}}),a=r.createMediaStreamDestination(),n.connect(o).connect(a),s=a.stream.getAudioTracks()[0],e._maps.set(t.id,r),[2,{code:exports.RCRTCCode.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}(),Ke=function(t){function i(e,r,i,n,o){var a=t.call(this,e,r,i,n,!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(i,t),Object.defineProperty(i.prototype,"_onTrackEnded",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.emit(i.EVENT_LOCAL_TRACK_END,this),this.removeAll(i.EVENT_LOCAL_TRACK_END)}}),Object.defineProperty(i.prototype,"_setLocalMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this;return new Promise((function(o){var a=r._localMuted!==e;t.prototype._setLocalMuted.call(r,e),r._remoteMuted=r._localMuted,a&&r._isPublished?r.emit(i.__INNER_EVENT_MUTED_CHANGE__,r,o):o(exports.RCRTCCode.SUCCESS),r._logger.info(n.L_LOCAL_TRACK_SET_LOCAL_MUTED_O,JSON.stringify({enable:e,trackId:r._id}))}))}}),Object.defineProperty(i.prototype,"__innerSetPublished",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._isPublished=e}}),Object.defineProperty(i.prototype,"isPublished",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isPublished}}),Object.defineProperty(i.prototype,"destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r;void 0===e&&(e=!0),this._isDestroyed||(this._logger.info(n.L_LOCAL_TRACK_DESTROY_O,this._id),this._isDestroyed=!0,null===(r=this._msTrack)||void 0===r||r.stop(),t.prototype.__innerDestroy.call(this),this.isAudioTrack()&&t.prototype.__releaseMediaElement.call(this),this._isPublished&&e&&this.emit(i.__INNER_EVENT_DESTROY__,this))}}),Object.defineProperty(i.prototype,"isDestroyed",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isDestroyed}}),Object.defineProperty(i.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){void 0===t&&(t=0),void 0===r&&(r=0),void 0===i&&(i=0),!e.isNumber(t)||!e.isNumber(r)||!e.isNumber(i)||t<=0||r<=0||t<r?this._logger.error(n.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:o.FAILED,msg:"params error -> max: ".concat(t,",min: ").concat(r,", start: ").concat(i),trackId:this._id})):(this._logger.info(n.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:o.SUCCESSED,max:t,min:r,start:i,trackId:this._id})),this._bitrateInfo={max:t,min:r,start:i})}}),Object.defineProperty(i.prototype,"getBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t,r,i,n,o,a,s,c,u=0,l=0,d=0;return(null===(r=this._msTrack)||void 0===r?void 0:r.kind)===Ae.VIDEO?(u=(e=ut(this._msTrack)).min,l=e.max):(null===(i=this._msTrack)||void 0===i?void 0:i.kind)===Ae.AUDIO&&(u=(t={min:32,max:32}).min,l=t.max),(null===(n=this._bitrateInfo)||void 0===n?void 0:n.max)&&(d=.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)||d}}}),Object.defineProperty(i.prototype,"getSettings",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return null===(e=this._msTrack)||void 0===e?void 0:e.getSettings()}}),Object.defineProperty(i,"EVENT_LOCAL_TRACK_END",{enumerable:!0,configurable:!0,writable:!0,value:"local-track-end"}),Object.defineProperty(i,"__INNER_EVENT_MUTED_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-muted-change"}),Object.defineProperty(i,"__INNER_EVENT_DESTROY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-destroy"}),i}(Ve),We=function(t){function i(e,r,i,n){return t.call(this,e,r,i,"audio",n)||this}return r(i,t),Object.defineProperty(i.prototype,"setRecommendBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(e.validate("audioBitrate",t,(function(e){return e in exports.RCAudioBitrate}))){var r=Je[t];this.setBitrate(r.max,r.min,r.start||.7*r.max)}else this._logger.warn(n.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:o.FAILED,msg:"params error -> params type is RCAudioBitrate"}))}}),Object.defineProperty(i.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var n=l(r,2),o=n[0],a=void 0===o?1:o,s=n[1],c=void 0===s?.7*e||1:s;t.prototype.setBitrate.call(this,e,a,c)}}),i}(Ke),Ye=function(t){function i(e,r,i,n,o){void 0===o&&(o=!1);var a=t.call(this,e,r,i,"video",n)||this;return Object.defineProperty(a,"_isTiny",{enumerable:!0,configurable:!0,writable:!0,value:o}),a}return r(i,t),Object.defineProperty(i.prototype,"__isTiny",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isTiny}}),Object.defineProperty(i.prototype,"getStreamId",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=t.prototype.getStreamId.call(this);return this._isTiny?"".concat(e,"_tiny"):e}}),Object.defineProperty(i.prototype,"getTrackId",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=t.prototype.getTrackId.call(this);return this._isTiny?"".concat(e,"_tiny"):e}}),Object.defineProperty(i.prototype,"setRecommendBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(e.validate("videoBitrate",t,(function(e){return e in exports.RCVideoBitrate}))){var r=Ge[t];this.setBitrate(r.max,r.min,r.start||.7*r.max)}else this._logger.warn(n.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:o.FAILED,msg:"params error -> params type is RCVideoBitrate"}))}}),Object.defineProperty(i.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var n=l(r,2),o=n[0],a=void 0===o?1:o,s=n[1],c=void 0===s?.7*e||1:s;t.prototype.setBitrate.call(this,e,a,c)}}),i}(Ke),ze=function(e){function t(r,i,n,o,a,s){var c=e.call(this,r,i,n,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,i,n=null===(r=this._mapping.get(t))||void 0===r?void 0:r.filter((function(t){return 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))}}),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}(Ke),qe=function(e){function t(t,r,i,n,o){return e.call(this,t,r,i,"video",n,o)||this}return r(t,e),t}(ze),Qe=function(e){function t(t,r,i,n,o){return e.call(this,t,r,i,"audio",n,o)||this}return r(t,e),Object.defineProperty(t.prototype,"_setLocalMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){return c(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 s(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this._setLocalMuted(!1)];case 1:return[2,{code:e.sent()}]}}))}))}}),t}(ze),Ze=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 s(this,void 0,void 0,(function(){var e,t,r;return c(this,(function(i){switch(i.label){case 0:return this._logger.info(n.A_APPLY_3A_NOISE_WORKLET_T),this._originTrack?(this._logger.warn(n.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:o.FAILED,msg:"3A noise module already applied"})),[2,{code:exports.RCRTCCode.SUCCESS}]):!this._msTrack||this.isDestroyed()?(this._logger.warn(n.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:o.FAILED,msg:"track not ready"})),[2,{code:exports.RCRTCCode.TRACK_NOT_READY}]):this.isPublished()?(this._logger.warn(n.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:o.FAILED,msg:"track already published"})),[2,{code:exports.RCRTCCode.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH}]):[4,He.apply3ANoiseWorklet(this._msTrack)];case 1:return e=i.sent(),t=e.code,r=e.track,t===exports.RCRTCCode.SUCCESS&&r?(this._originTrack=this._msTrack,this._msTrack=r,this._logger.info(n.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:o.SUCCESSED})),[2,{code:exports.RCRTCCode.SUCCESS}]):(this._logger.warn(n.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:o.FAILED,msg:"apply 3A noise module failed: ".concat(t),SCRIPT_URL:He.SCRIPT_URL,WASM_URL:He.WASM_URL})),[2,{code:t}])}}))}))}}),Object.defineProperty(t.prototype,"__innerSetMediaStreamTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(t){!t&&this._originTrack&&(He.release3ANoiseWorklet(this._originTrack),this._originTrack.stop(),this._originTrack=null),e.prototype.__innerSetMediaStreamTrack.call(this,t)}}),Object.defineProperty(t.prototype,"replaceInnerTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){}}),t}(We),Xe=function(e){function t(t,r,i,n,o){return void 0===o&&(o=!1),e.call(this,t,r,i,n,o)||this}return r(t,e),Object.defineProperty(t.prototype,"replaceInnerTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){}}),t}(Ye),$e=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(Ke.__INNER_EVENT_DESTROY__,this)}}),t}(Ye),et=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(Ke.__INNER_EVENT_DESTROY__,this)}}),t}(We),tt=function(e){function t(t,r,i,n,o){var a=e.call(this,t,r,i,n,!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}(Ve),rt=function(e){function t(t,r,i,n){return e.call(this,t,r,i,"audio",n)||this}return r(t,e),Object.defineProperty(t.prototype,"_setLocalMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=Ct.browser,i=Ct.version;return this._element&&i&&/chrome/i.test(r)&&i>=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}(tt),it=function(e){function t(t,r,i,n){var o=e.call(this,t,r,i,"video",n)||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}(tt),nt=function(e,t){return{name:e,content:JSON.stringify({uris:t,ignore:!0})}},ot=function(e){return JSON.stringify(e)},at=function(e){return/^[a-zA-Z\d-=]+$/g.test(e)},st=function(t){if(void 0===t)return 0;if(e.isNumber(t))return t;var r=t;return r.exact||r.ideal||r.max||0},ct=function(e){var t=e.getSettings(),r=e.getConstraints();return{width:st(r.width)||t.width||0,height:st(r.height)||t.height||0,frameRate:t.frameRate||st(r.frameRate)}},ut=function(e){var t=ct(e),r=t.width,i=t.height,n=t.frameRate,o=De(r||1920,i||1080),a=Ue(n);return{min:o.minBitrate*a,max:o.maxBitrate*a}},lt=function(e){return[e.msid,e.mediaType].join("_")},dt=function(e){var t=e.split("_");return{mediaType:parseInt(t.pop()),tag:t.pop(),userId:t.join("_")}},_t=function(e,t){return[e,t].join("_")},pt=function(e){return e.map((function(e){return a({},e)}))},ft=function(e,t,r){void 0===r&&(r=!1),e=e.slice();var i=[],n=[],o=[];return t.forEach((function(t){var n=lt(t),a=e.findIndex((function(e){return lt(e)===n}));if(r&&(a=e.findIndex((function(e){return e.uri===t.uri}))),-1!==a){var s=e[a];s.uri!==t.uri?i.push(t):s.state!==t.state&&o.push(t),e.splice(a,1)}else i.push(t)})),n.push.apply(n,d([],l(e),!1)),{publishedList:i,unpublishedList:n,modifiedList:o}},ht=function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return e="".concat(e.replace(/-/g,""),"0"),(e=function(e){var t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),r=t.length+1,i=+e,n=[];do{var o=i%r;i=(i-o)/r,n.unshift(t[o])}while(i);return n.join("")}(e=parseInt(e,16))).length>22&&(e=e.slice(0,22)),e},bt=function(e){if(Ne[e]){var t=Ne[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]}},Rt=function(e){return!!exports.RCResolution[e]},gt=function(e){return!!exports.RCFrameRate[e]},mt=function(e){return parseInt(e.replace("FPS_",""))},Ct=function(){var e=Ie.browserDetails;return{browser:e.browser,version:e.version,supportsUnifiedPlan:!1!==e.supportsUnifiedPlan}}();function vt(){return"captureStream"in HTMLMediaElement.prototype||"mozCaptureStream"in HTMLMediaElement.prototype}function Ot(){return"mediaDevices"in navigator&&"getDisplayMedia"in navigator.mediaDevices}var Tt,Et,It=function(e){return"[object Null]"===Object.prototype.toString.call(e)},St=function(e){return 1===e.type},yt=function(e,t,r,i){var o={},a=Object.keys(e.users);return a.length&&a.forEach((function(a){var s=[],c=e.users[a];if(c.extra){var u=JSON.parse(c.extra).roomId;if(t!==u)return}if(c.uris)try{s.push.apply(s,d([],l(JSON.parse(c.uris)),!1))}catch(e){r.warn(n.L_PARSE_ROOMDATA_URIS_R,"invalid user data -> userId: ".concat(a,", userData: ").concat(c),i)}o[a]=s})),o},Lt=function(e){return e instanceof Ve?e.getTrackId():e.track.getTrackId()},Pt=function(t){if(!e.isObject(t)||void 0===t.low||void 0===t.high)return t;var r=t.low;return r<0&&(r+=4294967296),r=r.toString(16),parseInt(t.high.toString(16)+"00000000".replace(new RegExp("0{".concat(r.length,"}$")),r),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"}(Tt||(Tt={})),exports.RCRTCPingResult=void 0,(Et=exports.RCRTCPingResult||(exports.RCRTCPingResult={})).SUCCESS="Success",Et.FAIL="Fail";var At=function(){function t(e,t,r,i){void 0===i&&(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}return Object.defineProperty(t.prototype,"start",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._started||(e<15e3&&(e=15e3),this._logger.info(n.L_PINGER_START_O,JSON.stringify({interval:this._gap,offlineKickTime:e})),this._started=!0,this._checkAlive(e))}}),Object.defineProperty(t.prototype,"_sendPing",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;return new Promise((function(r){t._context.rtcPing(t._roomId,t._roomMode).then(r),setTimeout(r,5e3,{code:e.ErrorCode.TIMEOUT})}))}}),Object.defineProperty(t.prototype,"_checkAlive",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,o,a,s,u,l=this;return c(this,(function(c){switch(c.label){case 0:return r=this._context.logger,i=r.createTraceId(),[4,this._sendPing()];case 1:return o=c.sent(),a=o.code,s=o.data,this._started?(u=Date.now(),a===e.ErrorCode.SUCCESS?(this._latestTimestamp=u,this.onPingResult(exports.RCRTCPingResult.SUCCESS,s.version),this._timer=setTimeout((function(){return l._checkAlive(t)}),this._gap),[2]):(r.error(n.L_PINGER_SEND_RTCPING_E,JSON.stringify({roomId:this._roomId,code:a}),i),this.onPingResult(exports.RCRTCPingResult.FAIL),40003===a||u-this._latestTimestamp>t?(this.stop(),this.onFailed(40003===a),[2]):(this._timer=setTimeout((function(){return l._checkAlive(t)}),this._gap),[2]))):[2]}}))}))}}),Object.defineProperty(t.prototype,"stop",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._started&&(this._logger.info(n.L_PINGER_STOP_O),this._started=!1,this._timer&&(clearTimeout(this._timer),this._timer=null))}}),t}();function Nt(e){let t=e.length;for(;--t>=0;)e[t]=0}const wt=256,Dt=286,kt=30,Ut=15,Mt=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]),xt=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]),jt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Bt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Vt=new Array(576);Nt(Vt);const Ft=new Array(60);Nt(Ft);const Jt=new Array(512);Nt(Jt);const Gt=new Array(256);Nt(Gt);const Ht=new Array(29);Nt(Ht);const Kt=new Array(kt);function Wt(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 Yt,zt,qt;function Qt(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Nt(Kt);const Zt=e=>e<256?Jt[e]:Jt[256+(e>>>7)],Xt=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},$t=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,Xt(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)},er=(e,t,r)=>{$t(e,r[2*t],r[2*t+1])},tr=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},rr=(e,t,r)=>{const i=new Array(16);let n,o,a=0;for(n=1;n<=Ut;n++)a=a+r[n-1]<<1,i[n]=a;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=tr(i[t]++,t))}},ir=e=>{let t;for(t=0;t<Dt;t++)e.dyn_ltree[2*t]=0;for(t=0;t<kt;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},nr=e=>{e.bi_valid>8?Xt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},or=(e,t,r,i)=>{const n=2*t,o=2*r;return e[n]<e[o]||e[n]===e[o]&&i[t]<=i[r]},ar=(e,t,r)=>{const i=e.heap[r];let n=r<<1;for(;n<=e.heap_len&&(n<e.heap_len&&or(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!or(t,i,e.heap[n],e.depth));)e.heap[r]=e.heap[n],r=n,n<<=1;e.heap[r]=i},sr=(e,t,r)=>{let i,n,o,a,s=0;if(0!==e.sym_next)do{i=255&e.pending_buf[e.sym_buf+s++],i+=(255&e.pending_buf[e.sym_buf+s++])<<8,n=e.pending_buf[e.sym_buf+s++],0===i?er(e,n,t):(o=Gt[n],er(e,o+wt+1,t),a=Mt[o],0!==a&&(n-=Ht[o],$t(e,n,a)),i--,o=Zt(i),er(e,o,r),a=xt[o],0!==a&&(i-=Kt[o],$t(e,i,a)))}while(s<e.sym_next);er(e,256,t)},cr=(e,t)=>{const r=t.dyn_tree,i=t.stat_desc.static_tree,n=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--,n&&(e.static_len-=i[2*c+1]);for(t.max_code=u,a=e.heap_len>>1;a>=1;a--)ar(e,r,a);c=o;do{a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ar(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++,ar(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,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,_,p,f,h=0;for(_=0;_<=Ut;_++)e.bl_count[_]=0;for(r[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)l=e.heap[u],_=r[2*r[2*l+1]+1]+1,_>c&&(_=c,h++),r[2*l+1]=_,l>i||(e.bl_count[_]++,p=0,l>=s&&(p=a[l-s]),f=r[2*l],e.opt_len+=f*(_+p),o&&(e.static_len+=f*(n[2*l+1]+p)));if(0!==h){do{for(_=c-1;0===e.bl_count[_];)_--;e.bl_count[_]--,e.bl_count[_+1]+=2,e.bl_count[c]--,h-=2}while(h>0);for(_=c;0!==_;_--)for(l=e.bl_count[_];0!==l;)d=e.heap[--u],d>i||(r[2*d+1]!==_&&(e.opt_len+=(_-r[2*d+1])*r[2*d],r[2*d+1]=_),l--)}})(e,t),rr(r,u,e.bl_count)},ur=(e,t,r)=>{let i,n,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),t[2*(r+1)+1]=65535,i=0;i<=r;i++)n=a,a=t[2*(i+1)+1],++s<c&&n===a||(s<u?e.bl_tree[2*n]+=s:0!==n?(n!==o&&e.bl_tree[2*n]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=0,o=n,0===a?(c=138,u=3):n===a?(c=6,u=3):(c=7,u=4))},lr=(e,t,r)=>{let i,n,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),i=0;i<=r;i++)if(n=a,a=t[2*(i+1)+1],!(++s<c&&n===a)){if(s<u)do{er(e,n,e.bl_tree)}while(0!=--s);else 0!==n?(n!==o&&(er(e,n,e.bl_tree),s--),er(e,16,e.bl_tree),$t(e,s-3,2)):s<=10?(er(e,17,e.bl_tree),$t(e,s-3,3)):(er(e,18,e.bl_tree),$t(e,s-11,7));s=0,o=n,0===a?(c=138,u=3):n===a?(c=6,u=3):(c=7,u=4)}};let dr=!1;const _r=(e,t,r,i)=>{$t(e,0+(i?1:0),3),nr(e),Xt(e,r),Xt(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r};var pr=(e,t,r,i)=>{let n,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<wt;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),cr(e,e.l_desc),cr(e,e.d_desc),a=(e=>{let t;for(ur(e,e.dyn_ltree,e.l_desc.max_code),ur(e,e.dyn_dtree,e.d_desc.max_code),cr(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Bt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),n=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=n&&(n=o)):n=o=r+5,r+4<=n&&-1!==t?_r(e,t,r,i):4===e.strategy||o===n?($t(e,2+(i?1:0),3),sr(e,Vt,Ft)):($t(e,4+(i?1:0),3),((e,t,r,i)=>{let n;for($t(e,t-257,5),$t(e,r-1,5),$t(e,i-4,4),n=0;n<i;n++)$t(e,e.bl_tree[2*Bt[n]+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),sr(e,e.dyn_ltree,e.dyn_dtree)),ir(e),i&&nr(e)},fr={_tr_init:e=>{dr||((()=>{let e,t,r,i,n;const o=new Array(16);for(r=0,i=0;i<28;i++)for(Ht[i]=r,e=0;e<1<<Mt[i];e++)Gt[r++]=i;for(Gt[r-1]=i,n=0,i=0;i<16;i++)for(Kt[i]=n,e=0;e<1<<xt[i];e++)Jt[n++]=i;for(n>>=7;i<kt;i++)for(Kt[i]=n<<7,e=0;e<1<<xt[i]-7;e++)Jt[256+n++]=i;for(t=0;t<=Ut;t++)o[t]=0;for(e=0;e<=143;)Vt[2*e+1]=8,e++,o[8]++;for(;e<=255;)Vt[2*e+1]=9,e++,o[9]++;for(;e<=279;)Vt[2*e+1]=7,e++,o[7]++;for(;e<=287;)Vt[2*e+1]=8,e++,o[8]++;for(rr(Vt,287,o),e=0;e<kt;e++)Ft[2*e+1]=5,Ft[2*e]=tr(e,5);Yt=new Wt(Vt,Mt,257,Dt,Ut),zt=new Wt(Ft,xt,0,kt,Ut),qt=new Wt(new Array(0),jt,0,19,7)})(),dr=!0),e.l_desc=new Qt(e.dyn_ltree,Yt),e.d_desc=new Qt(e.dyn_dtree,zt),e.bl_desc=new Qt(e.bl_tree,qt),e.bi_buf=0,e.bi_valid=0,ir(e)},_tr_stored_block:_r,_tr_flush_block:pr,_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*(Gt[r]+wt+1)]++,e.dyn_dtree[2*Zt(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{$t(e,2,3),er(e,256,Vt),(e=>{16===e.bi_valid?(Xt(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 hr=(e,t,r,i)=>{let n=65535&e,o=e>>>16&65535,a=0;for(;0!==r;){a=r>2e3?2e3:r,r-=a;do{n=n+t[i++]|0,o=o+n|0}while(--a);n%=65521,o%=65521}return n|o<<16};const br=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 Rr=(e,t,r,i)=>{const n=br,o=i+r;e^=-1;for(let r=i;r<o;r++)e=e>>>8^n[255&(e^t[r])];return~e},gr={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"},mr={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:Cr,_tr_stored_block:vr,_tr_flush_block:Or,_tr_tally:Tr,_tr_align:Er}=fr,{Z_NO_FLUSH:Ir,Z_PARTIAL_FLUSH:Sr,Z_FULL_FLUSH:yr,Z_FINISH:Lr,Z_BLOCK:Pr,Z_OK:Ar,Z_STREAM_END:Nr,Z_STREAM_ERROR:wr,Z_DATA_ERROR:Dr,Z_BUF_ERROR:kr,Z_DEFAULT_COMPRESSION:Ur,Z_FILTERED:Mr,Z_HUFFMAN_ONLY:xr,Z_RLE:jr,Z_FIXED:Br,Z_DEFAULT_STRATEGY:Vr,Z_UNKNOWN:Fr,Z_DEFLATED:Jr}=mr,Gr=258,Hr=262,Kr=42,Wr=113,Yr=666,zr=(e,t)=>(e.msg=gr[t],t),qr=e=>2*e-(e>4?9:0),Qr=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Zr=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 Xr=(e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask;const $r=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))},ei=(e,t)=>{Or(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,$r(e.strm)},ti=(e,t)=>{e.pending_buf[e.pending++]=t},ri=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},ii=(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=hr(e.adler,t,n,r):2===e.state.wrap&&(e.adler=Rr(e.adler,t,n,r)),e.next_in+=n,e.total_in+=n,n)},ni=(e,t)=>{let r,i,n=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match;const c=e.strstart>e.w_size-Hr?e.strstart-(e.w_size-Hr):0,u=e.window,l=e.w_mask,d=e.prev,_=e.strstart+Gr;let p=u[o+a-1],f=u[o+a];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(r=t,u[r+a]===f&&u[r+a-1]===p&&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<_);if(i=Gr-(_-o),o=_-Gr,i>a){if(e.match_start=t,a=i,i>=s)break;p=u[o+a-1],f=u[o+a]}}}while((t=d[t&l])>c&&0!=--n);return a<=e.lookahead?a:e.lookahead},oi=e=>{const t=e.w_size;let r,i,n;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Hr)&&(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),Zr(e),i+=t),0===e.strm.avail_in)break;if(r=ii(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=Xr(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=Xr(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<Hr&&0!==e.strm.avail_in)},ai=(e,t)=>{let r,i,n,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,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<o&&(0===r&&t!==Lr||t===Ir||r!==i+e.strm.avail_in))break;a=t===Lr&&r===i+e.strm.avail_in?1:0,vr(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,$r(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&&(ii(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!==Ir&&t!==Lr&&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&&(ii(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,o=n>e.w_size?e.w_size:n,i=e.strstart-e.block_start,(i>=o||(i||t===Lr)&&t!==Ir&&0===e.strm.avail_in&&i<=n)&&(r=i>n?n:i,a=t===Lr&&0===e.strm.avail_in&&r===i?1:0,vr(e,e.block_start,r,a),e.block_start+=r,$r(e.strm)),a?3:1)},si=(e,t)=>{let r,i;for(;;){if(e.lookahead<Hr){if(oi(e),e.lookahead<Hr&&t===Ir)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=Xr(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-Hr&&(e.match_length=ni(e,r)),e.match_length>=3)if(i=Tr(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=Xr(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=Xr(e,e.ins_h,e.window[e.strstart+1]);else i=Tr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(ei(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Lr?(ei(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ei(e,!1),0===e.strm.avail_out)?1:2},ci=(e,t)=>{let r,i,n;for(;;){if(e.lookahead<Hr){if(oi(e),e.lookahead<Hr&&t===Ir)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=Xr(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-Hr&&(e.match_length=ni(e,r),e.match_length<=5&&(e.strategy===Mr||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=Tr(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=Xr(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&&(ei(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Tr(e,0,e.window[e.strstart-1]),i&&ei(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=Tr(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Lr?(ei(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ei(e,!1),0===e.strm.avail_out)?1:2};function ui(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 li=[new ui(0,0,0,0,ai),new ui(4,4,8,4,si),new ui(4,5,16,8,si),new ui(4,6,32,32,si),new ui(4,4,16,16,ci),new ui(8,16,32,32,ci),new ui(8,16,128,128,ci),new ui(8,32,128,256,ci),new ui(32,128,258,1024,ci),new ui(32,258,258,4096,ci)];function di(){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=Jr,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),Qr(this.dyn_ltree),Qr(this.dyn_dtree),Qr(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),Qr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Qr(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 _i=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Kr&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Wr&&t.status!==Yr?1:0},pi=e=>{if(_i(e))return zr(e,wr);e.total_in=e.total_out=0,e.data_type=Fr;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?Kr:Wr,e.adler=2===t.wrap?0:1,t.last_flush=-2,Cr(t),Ar},fi=e=>{const t=pi(e);var r;return t===Ar&&((r=e.state).window_size=2*r.w_size,Qr(r.head),r.max_lazy_match=li[r.level].max_lazy,r.good_match=li[r.level].good_length,r.nice_match=li[r.level].nice_length,r.max_chain_length=li[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},hi=(e,t,r,i,n,o)=>{if(!e)return wr;let a=1;if(t===Ur&&(t=6),i<0?(a=0,i=-i):i>15&&(a=2,i-=16),n<1||n>9||r!==Jr||i<8||i>15||t<0||t>9||o<0||o>Br||8===i&&1!==a)return zr(e,wr);8===i&&(i=9);const s=new di;return e.state=s,s.strm=e,s.status=Kr,s.wrap=a,s.gzhead=null,s.w_bits=i,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=n+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<<n+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,fi(e)};var bi={deflateInit:(e,t)=>hi(e,t,Jr,15,8,Vr),deflateInit2:hi,deflateReset:fi,deflateResetKeep:pi,deflateSetHeader:(e,t)=>_i(e)||2!==e.state.wrap?wr:(e.state.gzhead=t,Ar),deflate:(e,t)=>{if(_i(e)||t>Pr||t<0)return e?zr(e,wr):wr;const r=e.state;if(!e.output||0!==e.avail_in&&!e.input||r.status===Yr&&t!==Lr)return zr(e,0===e.avail_out?kr:wr);const i=r.last_flush;if(r.last_flush=t,0!==r.pending){if($r(e),0===e.avail_out)return r.last_flush=-1,Ar}else if(0===e.avail_in&&qr(t)<=qr(i)&&t!==Lr)return zr(e,kr);if(r.status===Yr&&0!==e.avail_in)return zr(e,kr);if(r.status===Kr&&0===r.wrap&&(r.status=Wr),r.status===Kr){let t=Jr+(r.w_bits-8<<4)<<8,i=-1;if(i=r.strategy>=xr||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,ri(r,t),0!==r.strstart&&(ri(r,e.adler>>>16),ri(r,65535&e.adler)),e.adler=1,r.status=Wr,$r(e),0!==r.pending)return r.last_flush=-1,Ar}if(57===r.status)if(e.adler=0,ti(r,31),ti(r,139),ti(r,8),r.gzhead)ti(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)),ti(r,255&r.gzhead.time),ti(r,r.gzhead.time>>8&255),ti(r,r.gzhead.time>>16&255),ti(r,r.gzhead.time>>24&255),ti(r,9===r.level?2:r.strategy>=xr||r.level<2?4:0),ti(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(ti(r,255&r.gzhead.extra.length),ti(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Rr(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(ti(r,0),ti(r,0),ti(r,0),ti(r,0),ti(r,0),ti(r,9===r.level?2:r.strategy>=xr||r.level<2?4:0),ti(r,3),r.status=Wr,$r(e),0!==r.pending)return r.last_flush=-1,Ar;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=Rr(e.adler,r.pending_buf,r.pending-t,t)),r.gzindex+=n,$r(e),0!==r.pending)return r.last_flush=-1,Ar;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=Rr(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=Rr(e.adler,r.pending_buf,r.pending-i,i)),$r(e),0!==r.pending)return r.last_flush=-1,Ar;i=0}t=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,ti(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>i&&(e.adler=Rr(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=Rr(e.adler,r.pending_buf,r.pending-i,i)),$r(e),0!==r.pending)return r.last_flush=-1,Ar;i=0}t=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,ti(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>i&&(e.adler=Rr(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&&($r(e),0!==r.pending))return r.last_flush=-1,Ar;ti(r,255&e.adler),ti(r,e.adler>>8&255),e.adler=0}if(r.status=Wr,$r(e),0!==r.pending)return r.last_flush=-1,Ar}if(0!==e.avail_in||0!==r.lookahead||t!==Ir&&r.status!==Yr){let i=0===r.level?ai(r,t):r.strategy===xr?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(oi(e),0===e.lookahead)){if(t===Ir)return 1;break}if(e.match_length=0,r=Tr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(ei(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Lr?(ei(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ei(e,!1),0===e.strm.avail_out)?1:2})(r,t):r.strategy===jr?((e,t)=>{let r,i,n,o;const a=e.window;for(;;){if(e.lookahead<=Gr){if(oi(e),e.lookahead<=Gr&&t===Ir)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=e.strstart-1,i=a[n],i===a[++n]&&i===a[++n]&&i===a[++n])){o=e.strstart+Gr;do{}while(i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&n<o);e.match_length=Gr-(o-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=Tr(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Tr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(ei(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Lr?(ei(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ei(e,!1),0===e.strm.avail_out)?1:2})(r,t):li[r.level].func(r,t);if(3!==i&&4!==i||(r.status=Yr),1===i||3===i)return 0===e.avail_out&&(r.last_flush=-1),Ar;if(2===i&&(t===Sr?Er(r):t!==Pr&&(vr(r,0,0,!1),t===yr&&(Qr(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),$r(e),0===e.avail_out))return r.last_flush=-1,Ar}return t!==Lr?Ar:r.wrap<=0?Nr:(2===r.wrap?(ti(r,255&e.adler),ti(r,e.adler>>8&255),ti(r,e.adler>>16&255),ti(r,e.adler>>24&255),ti(r,255&e.total_in),ti(r,e.total_in>>8&255),ti(r,e.total_in>>16&255),ti(r,e.total_in>>24&255)):(ri(r,e.adler>>>16),ri(r,65535&e.adler)),$r(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?Ar:Nr)},deflateEnd:e=>{if(_i(e))return wr;const t=e.state.status;return e.state=null,t===Wr?zr(e,Dr):Ar},deflateSetDictionary:(e,t)=>{let r=t.length;if(_i(e))return wr;const i=e.state,n=i.wrap;if(2===n||1===n&&i.status!==Kr||i.lookahead)return wr;if(1===n&&(e.adler=hr(e.adler,t,r,0)),i.wrap=0,r>=i.w_size){0===n&&(Qr(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 o=e.avail_in,a=e.next_in,s=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,oi(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=Xr(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,oi(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=a,e.input=s,e.avail_in=o,i.wrap=n,Ar},deflateInfo:"pako deflate (from Nodeca project)"};const Ri=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var gi=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)Ri(r,t)&&(e[t]=r[t])}}return e},mi=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 Ci=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){Ci=!1}const vi=new Uint8Array(256);for(let e=0;e<256;e++)vi[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;vi[254]=vi[254]=1;var Oi=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,r,i,n,o,a=e.length,s=0;for(n=0;n<a;n++)r=e.charCodeAt(n),55296==(64512&r)&&n+1<a&&(i=e.charCodeAt(n+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),n++)),s+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(s),o=0,n=0;o<s;n++)r=e.charCodeAt(n),55296==(64512&r)&&n+1<a&&(i=e.charCodeAt(n+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),n++)),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},Ti=(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 o=new Array(2*r);for(n=0,i=0;i<r;){let t=e[i++];if(t<128){o[n++]=t;continue}let a=vi[t];if(a>4)o[n++]=65533,i+=a-1;else{for(t&=2===a?31:3===a?15:7;a>1&&i<r;)t=t<<6|63&e[i++],a--;a>1?o[n++]=65533:t<65536?o[n++]=t:(t-=65536,o[n++]=55296|t>>10&1023,o[n++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Ci)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})(o,n)},Ei=(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+vi[e[r]]>t?r:t};var Ii=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 Si=Object.prototype.toString,{Z_NO_FLUSH:yi,Z_SYNC_FLUSH:Li,Z_FULL_FLUSH:Pi,Z_FINISH:Ai,Z_OK:Ni,Z_STREAM_END:wi,Z_DEFAULT_COMPRESSION:Di,Z_DEFAULT_STRATEGY:ki,Z_DEFLATED:Ui}=mr;function Mi(e){this.options=gi({level:Di,method:Ui,chunkSize:16384,windowBits:15,memLevel:8,strategy:ki},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 Ii,this.strm.avail_out=0;let r=bi.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Ni)throw new Error(gr[r]);if(t.header&&bi.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Oi(t.dictionary):"[object ArrayBuffer]"===Si.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,r=bi.deflateSetDictionary(this.strm,e),r!==Ni)throw new Error(gr[r]);this._dict_set=!0}}function xi(e,t){const r=new Mi(t);if(r.push(e,!0),r.err)throw r.msg||gr[r.err];return r.result}Mi.prototype.push=function(e,t){const r=this.strm,i=this.options.chunkSize;let n,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Ai:yi,"string"==typeof e?r.input=Oi(e):"[object ArrayBuffer]"===Si.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),(o===Li||o===Pi)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(n=bi.deflate(r,o),n===wi)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),n=bi.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Ni;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},Mi.prototype.onData=function(e){this.chunks.push(e)},Mi.prototype.onEnd=function(e){e===Ni&&(this.result=mi(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ji={Deflate:Mi,deflate:xi,deflateRaw:function(e,t){return(t=t||{}).raw=!0,xi(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,xi(e,t)},constants:mr};const Bi=16209;var Vi=function(e,t){let r,i,n,o,a,s,c,u,l,d,_,p,f,h,b,R,g,m,C,v,O,T,E,I;const S=e.state;r=e.next_in,E=e.input,i=r+(e.avail_in-5),n=e.next_out,I=e.output,o=n-(t-e.avail_out),a=n+(e.avail_out-257),s=S.dmax,c=S.wsize,u=S.whave,l=S.wnext,d=S.window,_=S.hold,p=S.bits,f=S.lencode,h=S.distcode,b=(1<<S.lenbits)-1,R=(1<<S.distbits)-1;e:do{p<15&&(_+=E[r++]<<p,p+=8,_+=E[r++]<<p,p+=8),g=f[_&b];t:for(;;){if(m=g>>>24,_>>>=m,p-=m,m=g>>>16&255,0===m)I[n++]=65535&g;else{if(!(16&m)){if(64&m){if(32&m){S.mode=16191;break e}e.msg="invalid literal/length code",S.mode=Bi;break e}g=f[(65535&g)+(_&(1<<m)-1)];continue t}for(C=65535&g,m&=15,m&&(p<m&&(_+=E[r++]<<p,p+=8),C+=_&(1<<m)-1,_>>>=m,p-=m),p<15&&(_+=E[r++]<<p,p+=8,_+=E[r++]<<p,p+=8),g=h[_&R];;){if(m=g>>>24,_>>>=m,p-=m,m=g>>>16&255,16&m){if(v=65535&g,m&=15,p<m&&(_+=E[r++]<<p,p+=8,p<m&&(_+=E[r++]<<p,p+=8)),v+=_&(1<<m)-1,v>s){e.msg="invalid distance too far back",S.mode=Bi;break e}if(_>>>=m,p-=m,m=n-o,v>m){if(m=v-m,m>u&&S.sane){e.msg="invalid distance too far back",S.mode=Bi;break e}if(O=0,T=d,0===l){if(O+=c-m,m<C){C-=m;do{I[n++]=d[O++]}while(--m);O=n-v,T=I}}else if(l<m){if(O+=c+l-m,m-=l,m<C){C-=m;do{I[n++]=d[O++]}while(--m);if(O=0,l<C){m=l,C-=m;do{I[n++]=d[O++]}while(--m);O=n-v,T=I}}}else if(O+=l-m,m<C){C-=m;do{I[n++]=d[O++]}while(--m);O=n-v,T=I}for(;C>2;)I[n++]=T[O++],I[n++]=T[O++],I[n++]=T[O++],C-=3;C&&(I[n++]=T[O++],C>1&&(I[n++]=T[O++]))}else{O=n-v;do{I[n++]=I[O++],I[n++]=I[O++],I[n++]=I[O++],C-=3}while(C>2);C&&(I[n++]=I[O++],C>1&&(I[n++]=I[O++]))}break}if(64&m){e.msg="invalid distance code",S.mode=Bi;break e}g=h[(65535&g)+(_&(1<<m)-1)]}}break}}while(r<i&&n<a);C=p>>3,r-=C,p-=C<<3,_&=(1<<p)-1,e.next_in=r,e.next_out=n,e.avail_in=r<i?i-r+5:5-(r-i),e.avail_out=n<a?a-n+257:257-(n-a),S.hold=_,S.bits=p};const Fi=15,Ji=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]),Gi=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]),Hi=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]),Ki=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 Wi=(e,t,r,i,n,o,a,s)=>{const c=s.bits;let u,l,d,_,p,f,h=0,b=0,R=0,g=0,m=0,C=0,v=0,O=0,T=0,E=0,I=null;const S=new Uint16Array(16),y=new Uint16Array(16);let L,P,A,N=null;for(h=0;h<=Fi;h++)S[h]=0;for(b=0;b<i;b++)S[t[r+b]]++;for(m=c,g=Fi;g>=1&&0===S[g];g--);if(m>g&&(m=g),0===g)return n[o++]=20971520,n[o++]=20971520,s.bits=1,0;for(R=1;R<g&&0===S[R];R++);for(m<R&&(m=R),O=1,h=1;h<=Fi;h++)if(O<<=1,O-=S[h],O<0)return-1;if(O>0&&(0===e||1!==g))return-1;for(y[1]=0,h=1;h<Fi;h++)y[h+1]=y[h]+S[h];for(b=0;b<i;b++)0!==t[r+b]&&(a[y[t[r+b]]++]=b);if(0===e?(I=N=a,f=20):1===e?(I=Ji,N=Gi,f=257):(I=Hi,N=Ki,f=0),E=0,b=0,h=R,p=o,C=m,v=0,d=-1,T=1<<m,_=T-1,1===e&&T>852||2===e&&T>592)return 1;for(;;){L=h-v,a[b]+1<f?(P=0,A=a[b]):a[b]>=f?(P=N[a[b]-f],A=I[a[b]-f]):(P=96,A=0),u=1<<h-v,l=1<<C,R=l;do{l-=u,n[p+(E>>v)+l]=L<<24|P<<16|A}while(0!==l);for(u=1<<h-1;E&u;)u>>=1;if(0!==u?(E&=u-1,E+=u):E=0,b++,0==--S[h]){if(h===g)break;h=t[r+a[b]]}if(h>m&&(E&_)!==d){for(0===v&&(v=m),p+=R,C=h-v,O=1<<C;C+v<g&&(O-=S[C+v],!(O<=0));)C++,O<<=1;if(T+=1<<C,1===e&&T>852||2===e&&T>592)return 1;d=E&_,n[d]=m<<24|C<<16|p-o}}return 0!==E&&(n[p+E]=h-v<<24|64<<16),s.bits=m,0};const{Z_FINISH:Yi,Z_BLOCK:zi,Z_TREES:qi,Z_OK:Qi,Z_STREAM_END:Zi,Z_NEED_DICT:Xi,Z_STREAM_ERROR:$i,Z_DATA_ERROR:en,Z_MEM_ERROR:tn,Z_BUF_ERROR:rn,Z_DEFLATED:nn}=mr,on=16180,an=16190,sn=16191,cn=16192,un=16194,ln=16199,dn=16200,_n=16206,pn=16209,fn=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function hn(){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 bn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<on||t.mode>16211?1:0},Rn=e=>{if(bn(e))return $i;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=on,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,Qi},gn=e=>{if(bn(e))return $i;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Rn(e)},mn=(e,t)=>{let r;if(bn(e))return $i;const i=e.state;return t<0?(r=0,t=-t):(r=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?$i:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,gn(e))},Cn=(e,t)=>{if(!e)return $i;const r=new hn;e.state=r,r.strm=e,r.window=null,r.mode=on;const i=mn(e,t);return i!==Qi&&(e.state=null),i};let vn,On,Tn=!0;const En=e=>{if(Tn){vn=new Int32Array(512),On=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(Wi(1,e.lens,0,288,vn,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Wi(2,e.lens,0,32,On,0,e.work,{bits:5}),Tn=!1}e.lencode=vn,e.lenbits=9,e.distcode=On,e.distbits=5},In=(e,t,r,i)=>{let n;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)),i>=o.wsize?(o.window.set(t.subarray(r-o.wsize,r),0),o.wnext=0,o.whave=o.wsize):(n=o.wsize-o.wnext,n>i&&(n=i),o.window.set(t.subarray(r-i,r-i+n),o.wnext),(i-=n)?(o.window.set(t.subarray(r-i,r),0),o.wnext=i,o.whave=o.wsize):(o.wnext+=n,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=n))),0};var Sn={inflateReset:gn,inflateReset2:mn,inflateResetKeep:Rn,inflateInit:e=>Cn(e,15),inflateInit2:Cn,inflate:(e,t)=>{let r,i,n,o,a,s,c,u,l,d,_,p,f,h,b,R,g,m,C,v,O,T,E=0;const I=new Uint8Array(4);let S,y;const L=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(bn(e)||!e.output||!e.input&&0!==e.avail_in)return $i;r=e.state,r.mode===sn&&(r.mode=cn),a=e.next_out,n=e.output,c=e.avail_out,o=e.next_in,i=e.input,s=e.avail_in,u=r.hold,l=r.bits,d=s,_=c,T=Qi;e:for(;;)switch(r.mode){case on:if(0===r.wrap){r.mode=cn;break}for(;l<16;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}if(2&r.wrap&&35615===u){0===r.wbits&&(r.wbits=15),r.check=0,I[0]=255&u,I[1]=u>>>8&255,r.check=Rr(r.check,I,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=pn;break}if((15&u)!==nn){e.msg="unknown compression method",r.mode=pn;break}if(u>>>=4,l-=4,O=8+(15&u),0===r.wbits&&(r.wbits=O),O>15||O>r.wbits){e.msg="invalid window size",r.mode=pn;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=512&u?16189:sn,u=0,l=0;break;case 16181:for(;l<16;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}if(r.flags=u,(255&r.flags)!==nn){e.msg="unknown compression method",r.mode=pn;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=pn;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&4&r.wrap&&(I[0]=255&u,I[1]=u>>>8&255,r.check=Rr(r.check,I,2,0)),u=0,l=0,r.mode=16182;case 16182:for(;l<32;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}r.head&&(r.head.time=u),512&r.flags&&4&r.wrap&&(I[0]=255&u,I[1]=u>>>8&255,I[2]=u>>>16&255,I[3]=u>>>24&255,r.check=Rr(r.check,I,4,0)),u=0,l=0,r.mode=16183;case 16183:for(;l<16;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&4&r.wrap&&(I[0]=255&u,I[1]=u>>>8&255,r.check=Rr(r.check,I,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+=i[o++]<<l,l+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&4&r.wrap&&(I[0]=255&u,I[1]=u>>>8&255,r.check=Rr(r.check,I,2,0)),u=0,l=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(p=r.length,p>s&&(p=s),p&&(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(o,o+p),O)),512&r.flags&&4&r.wrap&&(r.check=Rr(r.check,i,p,o)),s-=p,o+=p,r.length-=p),r.length))break e;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===s)break e;p=0;do{O=i[o+p++],r.head&&O&&r.length<65536&&(r.head.name+=String.fromCharCode(O))}while(O&&p<s);if(512&r.flags&&4&r.wrap&&(r.check=Rr(r.check,i,p,o)),s-=p,o+=p,O)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;p=0;do{O=i[o+p++],r.head&&O&&r.length<65536&&(r.head.comment+=String.fromCharCode(O))}while(O&&p<s);if(512&r.flags&&4&r.wrap&&(r.check=Rr(r.check,i,p,o)),s-=p,o+=p,O)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+=i[o++]<<l,l+=8}if(4&r.wrap&&u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=pn;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=sn;break;case 16189:for(;l<32;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}e.adler=r.check=fn(u),u=0,l=0,r.mode=an;case an: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,Xi;e.adler=r.check=1,r.mode=sn;case sn:if(t===zi||t===qi)break e;case cn:if(r.last){u>>>=7&l,l-=7&l,r.mode=_n;break}for(;l<3;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}switch(r.last=1&u,u>>>=1,l-=1,3&u){case 0:r.mode=16193;break;case 1:if(En(r),r.mode=ln,t===qi){u>>>=2,l-=2;break e}break;case 2:r.mode=16196;break;case 3:e.msg="invalid block type",r.mode=pn}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=pn;break}if(r.length=65535&u,u=0,l=0,r.mode=un,t===qi)break e;case un:r.mode=16195;case 16195:if(p=r.length,p){if(p>s&&(p=s),p>c&&(p=c),0===p)break e;n.set(i.subarray(o,o+p),a),s-=p,o+=p,c-=p,a+=p,r.length-=p;break}r.mode=sn;break;case 16196:for(;l<14;){if(0===s)break e;s--,u+=i[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=pn;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;l<3;){if(0===s)break e;s--,u+=i[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,S={bits:r.lenbits},T=Wi(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,T){e.msg="invalid code lengths set",r.mode=pn;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;E=r.lencode[u&(1<<r.lenbits)-1],b=E>>>24,R=E>>>16&255,g=65535&E,!(b<=l);){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}if(g<16)u>>>=b,l-=b,r.lens[r.have++]=g;else{if(16===g){for(y=b+2;l<y;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}if(u>>>=b,l-=b,0===r.have){e.msg="invalid bit length repeat",r.mode=pn;break}O=r.lens[r.have-1],p=3+(3&u),u>>>=2,l-=2}else if(17===g){for(y=b+3;l<y;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}u>>>=b,l-=b,O=0,p=3+(7&u),u>>>=3,l-=3}else{for(y=b+7;l<y;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}u>>>=b,l-=b,O=0,p=11+(127&u),u>>>=7,l-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=pn;break}for(;p--;)r.lens[r.have++]=O}}if(r.mode===pn)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=pn;break}if(r.lenbits=9,S={bits:r.lenbits},T=Wi(1,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,T){e.msg="invalid literal/lengths set",r.mode=pn;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},T=Wi(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,T){e.msg="invalid distances set",r.mode=pn;break}if(r.mode=ln,t===qi)break e;case ln:r.mode=dn;case dn: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,Vi(e,_),a=e.next_out,n=e.output,c=e.avail_out,o=e.next_in,i=e.input,s=e.avail_in,u=r.hold,l=r.bits,r.mode===sn&&(r.back=-1);break}for(r.back=0;E=r.lencode[u&(1<<r.lenbits)-1],b=E>>>24,R=E>>>16&255,g=65535&E,!(b<=l);){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}if(R&&!(240&R)){for(m=b,C=R,v=g;E=r.lencode[v+((u&(1<<m+C)-1)>>m)],b=E>>>24,R=E>>>16&255,g=65535&E,!(m+b<=l);){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}u>>>=m,l-=m,r.back+=m}if(u>>>=b,l-=b,r.back+=b,r.length=g,0===R){r.mode=16205;break}if(32&R){r.back=-1,r.mode=sn;break}if(64&R){e.msg="invalid literal/length code",r.mode=pn;break}r.extra=15&R,r.mode=16201;case 16201:if(r.extra){for(y=r.extra;l<y;){if(0===s)break e;s--,u+=i[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(;E=r.distcode[u&(1<<r.distbits)-1],b=E>>>24,R=E>>>16&255,g=65535&E,!(b<=l);){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}if(!(240&R)){for(m=b,C=R,v=g;E=r.distcode[v+((u&(1<<m+C)-1)>>m)],b=E>>>24,R=E>>>16&255,g=65535&E,!(m+b<=l);){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}u>>>=m,l-=m,r.back+=m}if(u>>>=b,l-=b,r.back+=b,64&R){e.msg="invalid distance code",r.mode=pn;break}r.offset=g,r.extra=15&R,r.mode=16203;case 16203:if(r.extra){for(y=r.extra;l<y;){if(0===s)break e;s--,u+=i[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=pn;break}r.mode=16204;case 16204:if(0===c)break e;if(p=_-c,r.offset>p){if(p=r.offset-p,p>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=pn;break}p>r.wnext?(p-=r.wnext,f=r.wsize-p):f=r.wnext-p,p>r.length&&(p=r.length),h=r.window}else h=n,f=a-r.offset,p=r.length;p>c&&(p=c),c-=p,r.length-=p;do{n[a++]=h[f++]}while(--p);0===r.length&&(r.mode=dn);break;case 16205:if(0===c)break e;n[a++]=r.length,c--,r.mode=dn;break;case _n:if(r.wrap){for(;l<32;){if(0===s)break e;s--,u|=i[o++]<<l,l+=8}if(_-=c,e.total_out+=_,r.total+=_,4&r.wrap&&_&&(e.adler=r.check=r.flags?Rr(r.check,n,_,a-_):hr(r.check,n,_,a-_)),_=c,4&r.wrap&&(r.flags?u:fn(u))!==r.check){e.msg="incorrect data check",r.mode=pn;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+=i[o++]<<l,l+=8}if(4&r.wrap&&u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=pn;break}u=0,l=0}r.mode=16208;case 16208:T=Zi;break e;case pn:T=en;break e;case 16210:return tn;default:return $i}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||_!==e.avail_out&&r.mode<pn&&(r.mode<_n||t!==Yi))&&In(e,e.output,e.next_out,_-e.avail_out),d-=e.avail_in,_-=e.avail_out,e.total_in+=d,e.total_out+=_,r.total+=_,4&r.wrap&&_&&(e.adler=r.check=r.flags?Rr(r.check,n,_,e.next_out-_):hr(r.check,n,_,e.next_out-_)),e.data_type=r.bits+(r.last?64:0)+(r.mode===sn?128:0)+(r.mode===ln||r.mode===un?256:0),(0===d&&0===_||t===Yi)&&T===Qi&&(T=rn),T},inflateEnd:e=>{if(bn(e))return $i;let t=e.state;return t.window&&(t.window=null),e.state=null,Qi},inflateGetHeader:(e,t)=>{if(bn(e))return $i;const r=e.state;return 2&r.wrap?(r.head=t,t.done=!1,Qi):$i},inflateSetDictionary:(e,t)=>{const r=t.length;let i,n,o;return bn(e)?$i:(i=e.state,0!==i.wrap&&i.mode!==an?$i:i.mode===an&&(n=1,n=hr(n,t,r,0),n!==i.check)?en:(o=In(e,t,r,r),o?(i.mode=16210,tn):(i.havedict=1,Qi)))},inflateInfo:"pako inflate (from Nodeca project)"};var yn=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 Ln=Object.prototype.toString,{Z_NO_FLUSH:Pn,Z_FINISH:An,Z_OK:Nn,Z_STREAM_END:wn,Z_NEED_DICT:Dn,Z_STREAM_ERROR:kn,Z_DATA_ERROR:Un,Z_MEM_ERROR:Mn}=mr;function xn(e){this.options=gi({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 Ii,this.strm.avail_out=0;let r=Sn.inflateInit2(this.strm,t.windowBits);if(r!==Nn)throw new Error(gr[r]);if(this.header=new yn,Sn.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Oi(t.dictionary):"[object ArrayBuffer]"===Ln.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Sn.inflateSetDictionary(this.strm,t.dictionary),r!==Nn)))throw new Error(gr[r])}xn.prototype.push=function(e,t){const r=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let o,a,s;if(this.ended)return!1;for(a=t===~~t?t:!0===t?An:Pn,"[object ArrayBuffer]"===Ln.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),o=Sn.inflate(r,a),o===Dn&&n&&(o=Sn.inflateSetDictionary(r,n),o===Nn?o=Sn.inflate(r,a):o===Un&&(o=Dn));r.avail_in>0&&o===wn&&r.state.wrap>0&&0!==e[r.next_in];)Sn.inflateReset(r),o=Sn.inflate(r,a);switch(o){case kn:case Un:case Dn:case Mn:return this.onEnd(o),this.ended=!0,!1}if(s=r.avail_out,r.next_out&&(0===r.avail_out||o===wn))if("string"===this.options.to){let e=Ei(r.output,r.next_out),t=r.next_out-e,n=Ti(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(o!==Nn||0!==s){if(o===wn)return o=Sn.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},xn.prototype.onData=function(e){this.chunks.push(e)},xn.prototype.onEnd=function(e){e===Nn&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=mi(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};const{Deflate:jn,deflate:Bn,deflateRaw:Vn,gzip:Fn}=ji;var Jn=Fn;var Gn,Hn=-1,Kn=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)}))},Wn=function(t,r,i){return s(void 0,void 0,void 0,(function(){var n,o;return c(this,(function(a){return n=[],o=i.jwt||"",[2,new Promise((function(i,a){t.forEach((function(t){return s(void 0,void 0,void 0,(function(){var a,s,u;return c(this,(function(c){switch(c.label){case 0:return a=t.detectorAddr.replace(/^(https?:\/\/)?/,"https://"),s="".concat(a,"/rtc/detector/ping?t=").concat((d=9999,(l=1e3)+Math.floor(Math.random()*(d-l)))),u={jwt:o},[4,r.httpReq({url:s,body:JSON.stringify(u),timeout:5e3,method:e.HttpMethod.POST})];case 1:return 200===c.sent().status&&n.push(t.clusterId),i(n),[2]}var l,d}))}))}))}))]}))}))},Yn=function(e,t){var r,i;if(!t)return"";try{i=JSON.parse(t.voipCallInfo||'{ "strategy": 0 }')}catch(r){return e.warn(n.L_MEDIA_SERVICE_PARSE_NAVI_CALLVOIP_INFO_O,"parse `voipCallInfo` of navi failed: ".concat(t.voipCallInfo)),""}if(0===i.strategy)return"";var o=null===(r=i.callEngine)||void 0===r?void 0:r.filter((function(e){return 4===e.engineType}));if(!o||0===o.length)return"";var a=o[0];return a.detectorManager?a.detectorManager:""},zn=function(t,r,i){return s(void 0,void 0,void 0,(function(){var n,o,a,s,u,l,d,_;return c(this,(function(c){switch(c.label){case 0:return n=Yn(r,i),o=i.jwt||"",a=120,s=0,u=i.ipType||0,l={jwt:o,ipType:u},[4,t.httpReq({url:"".concat(n,"/rtc/detector/servers"),body:JSON.stringify(l),headers:{"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:"web|".concat(Ct.browser,"|").concat(Ct.version),ClientVersion:"5.32.0-c-im-alpha.2","Client-Session-Id":Kn(),"Request-Id":Date.now().toString()},method:e.HttpMethod.POST})];case 1:return d=c.sent(),_=d.data&&JSON.parse(d.data).detectorAddrs||[],a=d.data&&JSON.parse(d.data).clientDetectMinute,s=d.data&&JSON.parse(d.data).resultCode,[2,{detectoraddrs:_,clientDetectMinute:a,status:s}]}}))}))},qn=function(){return{"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:"web|".concat(Ct.browser,"|").concat(Ct.version),ClientVersion:"5.32.0-c-im-alpha.2","Client-Session-Id":Kn(),"Request-Id":Date.now().toString()}},Qn=function(){function t(t,r,i,n){void 0===n&&(n=5e3),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_msUrl",{enumerable:!0,configurable:!0,writable:!0,value:i}),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,r.getConnectionStatus()===e.RCConnectionStatus.CONNECTED&&this.isNededDetector()&&this.detectorMediaSever()}return Object.defineProperty(t.prototype,"isNededDetector",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._context.getNaviInfo();if(!e)return!1;var r=Yn(this._logger,e),i=e.jwt||"",n=Date.now(),o=!1;return 0===t.detectorTime?o=!1:t.detectValidMinute+t.detectorTime<n&&(o=!0),!(!r||!i||this._msUrl||o)}}),Object.defineProperty(t.prototype,"detectorMediaSever",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.clearMSList();var e=this._context.getNaviInfo();this._startDetector(e)}}),Object.defineProperty(t.prototype,"_startDetector",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var r,i,n,o;return c(this,(function(a){switch(a.label){case 0:return[4,zn(this._runtime,this._logger,e)];case 1:return r=a.sent(),i=r.detectoraddrs,n=r.clientDetectMinute,r.status!==exports.RCRTCCode.JWT_TIME_OUT?[3,3]:[4,this._context.getPluginContext().refetchNaviInfo()];case 2:return a.sent(),this.detectorMediaSever(),[2];case 3:return i.length?(o=t,[4,Wn(i,this._runtime,e)]):[3,5];case 4:o.msInDetector=a.sent(),a.label=5;case 5:return t.detectorTime=Date.now(),t.detectValidMinute=60*n*1e3,[2]}}))}))}}),Object.defineProperty(t.prototype,"clearMSList",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._msList.length=0}}),Object.defineProperty(t.prototype,"getMsList",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._msUrl?[this._msUrl]:(this._sortMediaServiceList(),d([],l(this._msList),!1))}}),Object.defineProperty(t.prototype,"_sortMediaServiceList",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=t.msInDetector[0],r=t.msInDetector.slice(1),i=function(e,t){var r,i;if(!e)return[];try{i=JSON.parse(e.voipCallInfo||'{ "strategy": 0 }')}catch(r){return t.warn(n.L_PARSE_VOIP_SERVER_CONF_E,e.voipCallInfo),[]}if(0===i.strategy)return[];var o=null===(r=i.callEngine)||void 0===r?void 0:r.filter((function(e){return 4===e.engineType}));if(!o||0===o.length)return[];var a=o[0],s=[];return a.mediaServer&&s.push(a.mediaServer.replace(/^(https?:\/\/)?/,"https://")),a.backupMediaServer&&a.backupMediaServer.forEach((function(e){s.push(e.replace(/^(https?:\/\/)?/,"https://"))})),s}(this._context.getNaviInfo(),this._logger),o=i[0],a=i.slice(1),s=d(d([this._clusterId,e,o],l(r),!1),l(a),!1).filter((function(e){return!!e})).map((function(e){return e.replace(/^(https?:\/\/)?/,"https://")}));this._msList=d([],l(new Set(s)),!1),this._logger.info(n.L_MEDIA_SERVICE_MSLIST_CHANGE_O,"MediaServiceList msList -> ".concat(JSON.stringify(this._msList)))}}),Object.defineProperty(t.prototype,"_openGzip",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){for(var r=JSON.stringify(t),i=r.length,n=new Uint8Array(i),o=0;o<i;o++)n[o]=r.charCodeAt(o);var s;return{headers:e=a(a({},e),{"Content-Encoding":"gzip","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}),body:t=Jn(n,s)}}}),Object.defineProperty(t.prototype,"_dealRequestSuccessResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var 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(n.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:o.SUCCESSED,url:t}),r),{code:exports.RCRTCCode.SUCCESS,data:i,qualityMsList:this._qualityMsList}}}),Object.defineProperty(t.prototype,"_request",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,u,l){return s(this,void 0,void 0,(function(){var s,d,_,p,f,h,b,R,g,m,C,v,O,T;return c(this,(function(c){switch(c.label){case 0:if(this._qualityMsList=[],d=(s={headers:r,body:i}).headers,_=s.body,0===(p=this.getMsList()).length)return this._logger.error(n.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"have no valid service address"}),u),[2,{code:exports.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER}];this._rtcFinger&&(_.rtcFinger=this._rtcFinger),f=0,c.label=1;case 1:return f<p.length?(h=Date.now(),b="".concat(p[f]).concat(t),R=qn(),g=a(a({},R),d),m=/x-www-form-urlencoded/.test(g["Content-Type"])?_:JSON.stringify(_),C=R["Request-Id"],this._logger.info(n.L_MEDIA_SERVICE_REQUEST_T,JSON.stringify({url:b,"Request-Id":C}),u),[4,this._runtime.httpReq({url:b,body:m,headers:g,method:e.HttpMethod.POST,timeout:this._timeout})]):[3,4];case 2:if(v=c.sent(),O=v.status,T=v.data,l&&this._qualityMsList.push({rsdur:Date.now()-h,rsid:C,rscod:200===O?exports.RCRTCCode.SUCCESS:exports.RCRTCCode.REQUEST_FAILED,msa:b}),200===O)return[2,this._dealRequestSuccessResult(T,b,u)];this._logger.error(n.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:o.FAILED,msg:"request error -> Request-Id: ".concat(C,", status: ").concat(O,", url: ").concat(b),timeout:this._timeout}),u),c.label=3;case 3:return f+=1,[3,1];case 4:return[2,{code:exports.RCRTCCode.REQUEST_FAILED,qualityMsList:this._qualityMsList}]}}))}))}}),Object.defineProperty(t.prototype,"exchange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var n;return s(this,void 0,void 0,(function(){var o,a;return c(this,(function(s){switch(s.label){case 0:return[4,this._request("/exchange",e,t,r,i)];case 1:return(o=s.sent()).code===exports.RCRTCCode.SUCCESS&&(null===(n=o.data)||void 0===n?void 0:n.resultCode)===exports.RCRTCCode.SUCCESS&&(a=o.data.urls)&&(this._configUrl=a.configUrl),[2,o]}}))}))}}),Object.defineProperty(t.prototype,"exit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(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(t.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(t.prototype,"broadcastExit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(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(t.prototype,"setMcuConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return s(this,void 0,void 0,(function(){var i,s,u,l,d,_,p,f,h,b,R;return c(this,(function(c){switch(c.label){case 0:return i=this._logger.createTraceId(),this._logger.info(n.L_MEDIA_SERVICE_SET_MCU_CONFIG_T,JSON.stringify({body:r}),i),this._configUrl?(s="".concat(this._configUrl.replace(/^(https?:\/\/)?/,"https://"),"/server/mcu/config"),u=qn(),l=a(a({},u),t),d=JSON.stringify(r),_=u["Request-Id"],[4,this._runtime.httpReq({url:s,headers:l,body:d,method:e.HttpMethod.POST})]):(this._logger.error(n.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.MCU_SERVER_NOT_FOUND,msg:"MCU server not found"}),i),[2,{code:exports.RCRTCCode.MCU_SERVER_NOT_FOUND}]);case 1:return p=c.sent(),f=p.status,h=p.data,200===f?(b=JSON.parse(h),(R=b.resultCode)===exports.RCRTCCode.SUCCESS?this._logger.info(n.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:o.SUCCESSED,"Request-Id":_}),i):this._logger.warn(n.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({code:R,"Request-Id":_}),i),[2,{code:R,res:b}]):(this._logger.error(n.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REQUEST_FAILED,msg:"request error -> Request-Id: ".concat(_,", status: ").concat(f,", url: ").concat(s)}),i),[2,{code:exports.RCRTCCode.REQUEST_FAILED}])}}))}))}}),Object.defineProperty(t.prototype,"getCDNResourceInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var s,u,l,d,_,p,f;return c(this,(function(c){switch(c.label){case 0:return s=qn(),u=a(a({},s),t),l=s["Request-Id"],this._logger.info(n.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_T,"Request-Id: ".concat(l,", url: ").concat(r),i),[4,this._runtime.httpReq({url:r,headers:u,method:e.HttpMethod.GET})];case 1:return d=c.sent(),_=d.status,p=d.data,200===_?(f=JSON.parse(p),this._logger.info(n.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:o.SUCCESSED,cdnPlayerUrl:null==f?void 0:f.data.pull_url}),i),[2,{code:f.resultCode,res:f}]):(this._logger.info(n.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REQUEST_FAILED}),i),[2,{code:exports.RCRTCCode.REQUEST_FAILED}])}}))}))}}),Object.defineProperty(t,"msInDetector",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(t,"detectorTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(t,"detectValidMinute",{enumerable:!0,configurable:!0,writable:!0,value:72e5}),t}();!function(e){e[e.NORMAL=1]="NORMAL",e[e.TINY=2]="TINY"}(Gn||(Gn={}));var Zn,Xn=function(e,t){return Math.round(8*t/e)},$n=function(e,t){void 0===t&&(t=2);var r=Math.pow(10,t);return Math.round(e*r)/r},eo=function(e,t){void 0===t&&(t=2),e>1&&(e=1);var r=Math.pow(10,t);return Math.round(e*r)},to=function(e,t,r,i){if(0===t)return 0;if(!r||!i)return $n(e/t,3);var n=t-i;if(0===n)return 0;var o=e-r;return o<0||n<0?0:$n(o/n,3)},ro=function(e){var t=e.jitter,r=e.rtt,i=e.packetsLostRate;return!It(t)||!It(r)||0!==i};!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"}(Zn||(Zn={}));var io,no=function(){function e(e,t,r,i,n,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:i}),Object.defineProperty(this,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:n}),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 i,n;if(this._latestBytesSent[e]&&t<this._latestBytesSent[e].bytesSent&&this.clearLatestpacketsSent([e]),this._latestBytesSent[e]){var o=this._latestBytesSent[e];i=t-o.bytesSent,n=r-o.timestamp,this._latestBytesSent[e]={bytesSent:t,timestamp:r}}else i=t,n=1e3,this._latestBytesSent[e]={bytesSent:t,timestamp:r};return Xn(n,i)}}),Object.defineProperty(e.prototype,"updateBytesRecv",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i,n;if(this._latestBytesRecv[e]&&t<this._latestBytesRecv[e].bytesRecv&&this.clearLatestPacketsRecv([e]),this._latestBytesRecv[e]){var o=this._latestBytesRecv[e];i=t-o.bytesRecv,n=r-o.timestamp,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r}}else i=t,n=1e3,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r};return Xn(n,i)}}),Object.defineProperty(e.prototype,"updateSenderPacketsLost",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i;if(Object.prototype.hasOwnProperty.call(this._latestPacketsSent[e],"packetsSent")){var n=this._latestPacketsSent[e],o=n.packetsLost,a=n.packetsSent;i=to(t,r,o,a),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=o===t?a:r}else i=to(t,r),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=r;return i}}),Object.defineProperty(e.prototype,"updateReceiverPacketsLost",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i;if(this._latestPacketsRecv[e]){var n=this._latestPacketsRecv[e],o=n.packetsLost,a=n.packetsRecv;i=to(t,r+t,o,a+o)}else i=to(t,r);return this._latestPacketsRecv[e]={packetsLost:t,packetsRecv:r},i}}),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())===exports.RCMediaType.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,i={};try{for(var n=u(e.entries()),o=n.next();!o.done;o=n.next()){var a=l(o.value,2),s=a[0],c=a[1];/codec/gi.test(c)&&s.includes("RTCCodec_")||(i[s]=c)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return i}}),Object.defineProperty(e.prototype,"formatRCRTCStateReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={senders:[],receivers:[]};return this._logger.info(n.L_ABSTRACT_STAT_PARSER_FORMAT_RTC_STATE_REPORT_O,JSON.stringify({status:o.SUCCESSED,stats:e,reports:t})),t}}),Object.defineProperty(e.prototype,"isValidTranceiver",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i,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,o=e.ssrc;return!(null==n?void 0:n.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===Zn.REMOTEINBOUNDRTP?(e.remoteInbound.push(t),e):t.type===Zn.INBOUNDRTP?(e.inbound.push(t),e):t.type===Zn.OUTBOUNDRTP?(e.outbound.push(t),e):t.type===Zn.TRANSPORT?(e.transport.push(t),e):t.type===Zn.PEERCONNECTION?(e.connection.push(t),e):e}),{outbound:[],remoteInbound:[],inbound:[],transport:[],connection:[]})}}),e}(),oo=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,i=this.formatStateData(e),n=i.outbound,o=i.remoteInbound,a=i.inbound,s=i.transport,c=i.connection,u={senders:[],receivers:[]},l=Math.floor(c[0].timestamp);u.timestamp=l;var d=0,_=0;d=(t=this.pickOutbound(n,e,d,l,_)).totalPacketsLost,_=t.bitrateSend,u.senders=t.senders,o.length>0&&u.senders.length>0&&this.pickRemoteInbound(o,u.senders,e);var p=0;if(d=(r=this.pickInbound(a,e,d,l,p)).totalPacketsLost,p=r.bitrateRecv,u.receivers=r.receivers,s.length>0){var f=s[0];this.pickRtcTransport(f,e,u,p,_,d)}return u}}),Object.defineProperty(t.prototype,"pickRtcTransport",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n,o){var a=e.selectedCandidatePairId;if(a){var s=t[a],c=s.availableOutgoingBitrate,u=s.availableIncomingBitrate,l=s.currentRoundTripTime,d=s.localCandidateId,_=s.remoteCandidateId,p=t[d],f=p.ip,h=p.port,b=p.networkType,R=t[_],g=R.ip,m=R.port,C=R.protocol;r.iceCandidatePair={IP:f,port:h,networkType:b,remoteIP:g,remotePort:m,protocol:C,bitrateRecv:i,bitrateSend:n,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 i=this;e.forEach((function(e){var n,o=e.localId,a=e.jitter,s=e.roundTripTime,c=e.packetsLost,u=t.filter((function(e){return e.id===o}))[0];if(u&&!ro(u)){var l=null===(n=i._store)||void 0===n?void 0:n.getTrackIdBySSRC(r[u.id].ssrc);u.jitter=Math.round(1e3*a),u.rtt=s;var d=i._latestPacketsSent[l].crtPacketsSent;u.packetsLostRate=i.updateSenderPacketsLost(l,c,d)}}))}}),Object.defineProperty(t.prototype,"_getOutboundVideoAttrs",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n){var o,a,s,c=e.framesPerSecond,u=e.frameWidth,l=e.frameHeight;return"video"!==r||u||l||c||(u=(null===(o=t[i])||void 0===o?void 0:o.frameWidth)||t[n].width,l=(null===(a=t[i])||void 0===a?void 0:a.frameHeight)||t[n].height,c=(null===(s=t[n])||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,i,n){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,d=e.remoteId,_=e.packetsSent,p=e.bytesSent,f=e.encoderImplementation,h=e.pliCount,b=e.nackCount,R=e.mid,g=e.trackId;if(void 0!==R&&(g=o.getTrackIdByMid(R)),g){var m=o._getOutboundVideoAttrs(e,t,u,g,l),C=m.frameRate,v=m.frameWidth,O=m.frameHeight,T=t[d],E=null,I=null,S=0;T&&(E=T.jitter,I=T.roundTripTime,S=T.packetsLost),r+=S;var y=null===(s=o._store)||void 0===s?void 0:s.getTrackIdBySSRC(e.ssrc);if(y){var L=l?t[l].audioLevel:t[g].audioLevel,P=0;!o._latestPacketsSent[y]&&(o._latestPacketsSent[y]={}),T?P=o.updateSenderPacketsLost(y,S,_):o._latestPacketsSent[y].crtPacketsSent=_;var A=o.updateBytesSent(y,p,i);A<0&&(A=0),n+=A,a.push({id:c,trackId:y,kind:u,packetsLostRate:P,remoteResource:!1,audioLevel:L||0===L?eo(L):null,frameWidth:v,frameHeight:O,frameRate:C,bitrate:A,jitter:E?Math.round(1e3*E):E,rtt:I?Math.round(1e3*I):I,encoderImplementation:f,pliCount:h,nackCount:b,googFirsSent:Hn,samplingRate:Hn,googRenderDelayMs:Hn,trackState:Hn})}}}})),{totalPacketsLost:r,bitrateSend:n,senders:a}}}),Object.defineProperty(t.prototype,"_getInboundMediaAttrs",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n){var o,a,s,c=e.frameWidth,u=e.frameHeight,l=e.audioLevel;return"video"===n?c||u||(c=(null===(o=t[r])||void 0===o?void 0:o.frameWidth)||t[i].width,u=(null===(a=t[r])||void 0===a?void 0:a.frameHeight)||t[i].height):l||(l=(null===(s=t[r])||void 0===s?void 0:s.audioLevel)||t[i].audioLevel),{frameWidth:c,frameHeight:u,audioLevel:l}}}),Object.defineProperty(t.prototype,"pickInbound",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n){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,d=e.bytesReceived,_=e.framesPerSecond,p=e.kind,f=e.codecImplementationName,h=e.nackCount,b=e.pliCount,R=e.mid,g=e.id,m=e.trackId;if(void 0!==R&&(m=o.getTrackIdByMid(R)),m){var C=o._getInboundMediaAttrs(e,t,m,g,p),v=C.frameWidth,O=C.frameHeight,T=C.audioLevel;r+=c;var E=null===(s=o._store)||void 0===s?void 0:s.getTrackIdBySSRC(e.ssrc),I=o.updateReceiverPacketsLost(E,c,u),S=o.updateBytesRecv(E,d,i);S<0&&(S=0),n+=S,a.push({trackId:E,kind:p,packetsLostRate:I,remoteResource:!0,audioLevel:T||0===T?eo(T):null,frameWidth:v,frameHeight:O,frameRate:_,bitrate:S,jitter:l?Math.round(1e3*l):0,codecImplementationName:f,nackCount:h,pliCount:b,rtt:null,samplingRate:Hn,googFirsReceived:Hn,googRenderDelayMs:Hn,trackState:Hn})}}})),{totalPacketsLost:r,bitrateRecv:n,receivers:a}}}),t}(no),ao=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 i;if("unified-plan"!==this._sdpSemantics||this.isValidTranceiver(e,r)){var n=e.kind,o=e.bytesSent,a=e.packetsSent,s=e.bitrateMean,c=e.framerateMean,u=e.nackCount,l=e.pliCount,d=e.remoteId,_=d?t[d]:{jitter:null,roundTripTime:null,packetsLost:0},p=_.jitter,f=_.roundTripTime,h=_.packetsLost,b=null===(i=this._store)||void 0===i?void 0:i.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=h;var R=0;!this._latestPacketsSent[b]&&(this._latestPacketsSent[b]={}),d?R=this.updateSenderPacketsLost(b,h,a):this._latestPacketsSent[b].crtPacketsSent=a;var g=0;"video"===n?s&&(g=Math.floor(s/1e3)):g=this.updateBytesSent(b,o,this._reportsData.timestamp),g<0&&(g=0),this._bitrateSend+=g,this._reportsData.senders.push({trackId:b,kind:n,packetsLostRate:R,remoteResource:!1,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(c),bitrate:g,jitter:p?Math.round(1e3*p):null,rtt:f,encoderImplementation:null,pliCount:l,nackCount:u,googFirsSent:Hn,samplingRate:Hn,googRenderDelayMs:Hn,trackState:Hn})}}}),Object.defineProperty(t.prototype,"_addSenderData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i=t.localId,n=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e[i].ssrc),o=this._reportsData.senders.filter((function(e){return e.trackId===n}))[0];o&&ro(o)&&(o.jitter=Math.round(1e3*t.jitter),o.rtt=t.rtt,o.packetsLostRate=this.updateSenderPacketsLost(n,t.packetsLost,this._latestPacketsSent[n].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 i=e.packetsLost,n=e.bytesReceived,o=e.packetsReceived,a=e.jitter,s=e.framerateMean,c=e.kind,u=e.bitrateMean,l=e.nackCount,d=e.pliCount,_=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=i;var p=this.updateReceiverPacketsLost(_,i,o),f=0;"video"===c?u&&(f=Math.floor(u/1e3)):f=this.updateBytesRecv(_,n,this._reportsData.timestamp),f<0&&(f=0),this._bitrateRecv+=f,this._reportsData.receivers.push({trackId:_,kind:c,packetsLostRate:p,remoteResource:!0,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(s),bitrate:f,jitter:a?Math.round(1e3*a):null,codecImplementationName:null,nackCount:l,pliCount:d,rtt:null,samplingRate:Hn,googFirsReceived:Hn,googRenderDelayMs:Hn,trackState:Hn})}}}),Object.defineProperty(t.prototype,"_pickIceCandidatePair",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e[t.localCandidateId],i=r.address,n=r.port,o=e[t.remoteCandidateId],a=o.address,s=o.port,c=o.protocol;this._reportsData.iceCandidatePair={IP:i,port:n,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 i=e[r],n=i.type;"outbound-rtp"===n&&this._pickSenderData(i,e,n),"remote-inbound-rtp"===n&&this._addSenderData(e,i),"inbound-rtp"===n&&this._pickReceiverData(i,n),"candidate-pair"===n&&"succeeded"===i.state&&this._pickIceCandidatePair(e,i)}return this._reportsData}}),t}(no),so=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 i=e.packetsLost,n=e.packetsReceived,o=e.jitter,a=e.bytesReceived,s=e.kind,c=e.nackCount,u=e.pliCount,l=e.audioLevel,d=e.frameHeight,_=e.frameWidth,p=null===(t=r._store)||void 0===t?void 0:t.getTrackIdBySSRC(e.ssrc);if(p){r._totalPacketsLost+=i;var f=r.updateReceiverPacketsLost(p,i,n),h=r.updateBytesRecv(p,a,r._reportsData.timestamp);h<0&&(h=0),r._bitrateRecv+=h,r._reportsData.receivers.push({trackId:p,kind:s,packetsLostRate:f,remoteResource:!0,audioLevel:l||0===l?eo(l):null,frameWidth:_,frameHeight:d,frameRate:null,bitrate:h,jitter:o?Math.round(1e3*o):o,codecImplementationName:null,nackCount:c,pliCount:u,rtt:null,samplingRate:Hn,googFirsReceived:Hn,googRenderDelayMs:Hn,trackState:Hn})}}}))}}),Object.defineProperty(t.prototype,"_pickSenderData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;e.forEach((function(e){var i;if("unified-plan"!==r._sdpSemantics||r.isValidTranceiver(e,"outbound-rtp")){var n=null===(i=r._store)||void 0===i?void 0:i.getTrackIdBySSRC(e.ssrc),o=e.kind,a=e.bytesSent,s=e.pliCount,c=e.nackCount,u=e.audioLevel,l=e.frameHeight,d=e.frameWidth,_=e.codecId,p=e.remoteId,f=e.packetsSent;if(n){var h=t[p],b=null,R=null,g=0;h&&(b=h.jitter,R=h.roundTripTime,g=h.packetsLost),r._totalPacketsLost+=g;var m=0;!r._latestPacketsSent[n]&&(r._latestPacketsSent[n]={}),h?m=r.updateSenderPacketsLost(n,g,f):r._latestPacketsSent[n].crtPacketsSent=f;var C=r.updateBytesSent(n,a,r._reportsData.timestamp);C<0&&(C=0),r._bitrateSend+=C,r._reportsData.senders.push({trackId:n,kind:o,packetsLostRate:m,remoteResource:!1,audioLevel:u||0===u?eo(u):null,frameWidth:d,frameHeight:l,frameRate:null,bitrate:C,jitter:b?Math.round(1e3*b):b,rtt:R?Math.round(1e3*R):R,encoderImplementation:t[_].mimeType,pliCount:s,nackCount:c,googFirsSent:Hn,samplingRate:Hn,googRenderDelayMs:Hn,trackState:Hn})}}}))}}),Object.defineProperty(t.prototype,"_pickIceCandidatePair",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.selectedCandidatePairId;if(r){var i=t[r],n=i.availableOutgoingBitrate,o=i.availableIncomingBitrate,a=i.currentRoundTripTime,s=i.localCandidateId,c=i.remoteCandidateId,u=t[s],l=u.address,d=u.port,_=t[c],p=_.address,f=_.port,h=_.protocol;this._reportsData.iceCandidatePair={IP:l||null,port:d,networkType:null,remoteIP:p,remotePort:f,protocol:h,bitrateRecv:this._bitrateRecv,bitrateSend:this._bitrateSend,rtt:1e3*a,availableOutgoingBitrate:n,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,i=t.inbound,n=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(i,e),n.length>0){var s=n[0];this._pickIceCandidatePair(s,e)}return this._reportsData}}),t}(no),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 i=this.getStreamIndex();this.spliteStreams(i)}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),d([],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(i){return new RegExp("\\bmsid:".concat(t,"\\b"),"ig").test(i)?r.setAudioItemBitrate(i,e):i})),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(i){return new RegExp("\\bmid:".concat(t,"\\b"),"ig").test(i)?r.setAudioItemBitrate(i,e):i})),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 i=["$1","maxaveragebitrate=".concat(r.max*e.KBitrate*1e3)];t=t.replace(/(\buseinbandfec=[^\r\n]+)/gi,i.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(i){return new RegExp("\\bmsid:".concat(t,"\\b"),"ig").test(i)?r.setVideoItemBitrate(i,e):i})),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(i){return new RegExp("\\bmid:".concat(t,"\\b"),"ig").test(i)?r.setVideoItemBitrate(i,e):i})),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 i=["$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,i.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(i){return new RegExp("\\bmid:".concat(e,"\\b"),"ig").test(i)?r.clearSSRC(i,t):i})),this.videoStreams=this.videoStreams.map((function(i){return new RegExp("\\bmid:".concat(e,"\\b"),"ig").test(i)?r.clearSSRC(i,t):i})),this}}),Object.defineProperty(e.prototype,"clearSSRC",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(t===_o.SENDONLY&&/\ba=sendonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"");if(t===_o.RECVONLY&&/\ba=recvonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"");if(t===_o.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}(),uo=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(n.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(n.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(n.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(n.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"}(io||(io={})),io.NB,io.NB,io.NB,io.NB,io.MB,io.MB,io.MB,io.MB,io.WB,io.WB,io.WB,io.WB,io.SWB,io.SWB,io.FB,io.FB,io.NB,io.NB,io.NB,io.NB,io.WB,io.WB,io.WB,io.WB,io.SWB,io.SWB,io.SWB,io.SWB,io.FB,io.FB,io.FB,io.FB;var lo,_o,po=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,i=e.matchPrefix(t,"a=msid:");if(1===i.length)return{stream:(r=i[0].substr(7).split(" "))[0],track:r[1]};var n=e.matchPrefix(t,"a=ssrc:").map((function(t){return e.parseSsrcMedia(t)})).filter((function(e){return"msid"===e.attribute}));return n.length>0&&n[0].value?{stream:(r=n[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)},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}}),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 i=t.join(","),n=i.indexOf("0,0,0,1,101");-1===n&&(n=i.indexOf("0,0,0,1,37")),r=i.substring(0,n).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 i=r.match(/a=rtpmap:(\d+)\s+(\S+)/g);i&&(e.payloadTypeCodecMap=i.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"}(lo||(lo={})),function(e){e.SENDONLY="sendonly",e.RECVONLY="recvonly",e.INACTIVE="inactive"}(_o||(_o={}));var fo,ho,bo,Ro,go=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=Ct.browser,i=Ct.version,o=Ct.supportsUnifiedPlan;if(t.info(n.L_A_SDP_STRATEGY_SET_SDP_SEMANTICS_O,JSON.stringify({sdpSemantics:e,supportsUnifiedPlan:o,browser:r,version:i})),o)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"}}),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 i=/_tiny$/.test(t),n=ct(r),o=n.width,a=n.height;e.push({trackId:r.id,simulcast:i?Gn.TINY:Gn.NORMAL,resolution:"".concat(o,"x").concat(a)})}}return e}}),Object.defineProperty(e.prototype,"setRemoteAnswer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(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(n.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:o.FAILED,msg:t})),[2,exports.RCRTCCode.SET_REMOTE_DESCRIPTION_FAILED];case 4:return this._logger.info(n.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:o.SUCCESSED,sdp:e})),[2,exports.RCRTCCode.SUCCESS]}}))}))}}),Object.defineProperty(e.prototype,"getStatParsr",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){return/chrome/i.test(Ct.browser)?new oo(this,e,this._logger,t,r,i):/Firefox/i.test(Ct.browser)?new ao(this,e,this._logger,t,r,i):/Safari/i.test(Ct.browser)?new so(this,e,this._logger,t,r,i):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,i=t.writable,n=new TransformStream({transform:this._encodeRtpChunk.bind(this,e)});r.pipeThrough(n).pipeTo(i)}}}),Object.defineProperty(e.prototype,"_setupReceiverTransform",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this._useEncrypt){var t=e.createEncodedStreams(),r=t.readable,i=t.writable,n=new TransformStream({transform:this._decodeRtpChunk.bind(this,e)});r.pipeThrough(n).pipeTo(i)}}}),Object.defineProperty(e.prototype,"_encodeVideoFrame",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=po.splitNaluData(e),r=t.header,i=t.payloadData,n=uo.encodeVideo(i),o=po.deal0x03(n,"encode");return new Uint8Array(d(d([],l(r),!1),l(o),!1)).buffer}}),Object.defineProperty(e.prototype,"_decodeVideoFrame",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=po.splitNaluData(e),r=t.header,i=t.payloadData,n=po.deal0x03(i,"decode"),o=uo.decodeVideo(n);return new Uint8Array(d(d([],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 i,n=!(e[r]>>7),o=127&e[r],a=void 0,s=void 0,c=void 0;if(n?(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),i=new Uint8Array(s),t.push({timestampOffset:a,header:c,block:i,isPrimary:n,blockPType:o}),n)break}return t.forEach((function(t){var i=t.block.byteLength,n=e.slice(r,r+i);t.block.set(n),r+=i})),t}(new Uint8Array(e)),i=[],n=[],o=0;r.forEach((function(e){var r="decode"===t?uo.decodeAudio(e.block):uo.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,i.push(e.header),n.push(e.block)}));var a=new Uint8Array(o),s=0;return d(d([],l(i),!1),l(n),!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?uo.encodeAudio(r):uo.decodeAudio(r)).buffer}}),Object.defineProperty(e.prototype,"_encodeRtpChunk",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._encodeVideoFrame(i);else{var n=t.getMetadata().payloadType,o=po.payloadTypeCodecMap.filter((function(e){return e.payloadType===n}))[0].codec;"red"===o?t.data=this._handleAudioREDFrame(i,"encode"):"opus"===o?t.data=this._handleOpusFrame(i,"encode"):console.error("Unsupport audio payloadType: ".concat(n,", codec: ").concat(o))}r.enqueue(t)}}),Object.defineProperty(e.prototype,"_decodeRtpChunk",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._decodeVideoFrame(i);else{var n=t.getMetadata().payloadType,o=po.payloadTypeCodecMap.filter((function(e){return e.payloadType===n}))[0].codec;"red"===o?t.data=this._handleAudioREDFrame(i,"decode"):"opus"===o?t.data=this._handleOpusFrame(i,"decode"):console.error("Unsupport audio payloadType: ".concat(n,", codec: ").concat(o))}r.enqueue(t)}}),e}(),mo=function(e){function t(t,r){var i=e.call(this,r,lo.PLANB,t)||this;return Object.defineProperty(i,"SDP",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return r(t,e),Object.defineProperty(t.prototype,"stringify",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[this.SDPHeader];d(d([],l(this.audioStreams),!1),l(this.videoStreams),!1).forEach((function(t){var r=t.match(/\ba=mid:(video|audio)\b/),i=co.clearInactiveOrRecvonly(t);r&&r[1]===Ae.AUDIO&&(e[1]=i),r&&r[1]===Ae.VIDEO&&(e[2]=i)}));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(n.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(n.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Video Bitrate With Stream Id"),this}}),t}(co),Co=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(),i=this._outboundStreams[t]||(this._outboundStreams[t]=new MediaStream);i.getTracks().forEach((function(e){e.kind===r.kind&&i.removeTrack(e)})),i.addTrack(r);var n=e.getTrackId(),o=this.senders[n];o?o.replaceTrack(r):(this.senders[n]=this._peer.addTrack(r,i),Object.defineProperty(r,"trackId",{value:n,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(),i=this.senders[r];i&&(i.replaceTrack(null),this._peer.removeTrack(i),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 s(this,void 0,void 0,(function(){var t,r,i;return c(this,(function(n){switch(n.label){case 0:return[4,this._peer.createOffer({iceRestart:e,offerToReceiveAudio:!0,offerToReceiveVideo:!0})];case 1:for(r in t=n.sent(),this._outboundStreams)i=this._outboundStreams[r].id,t.sdp=t.sdp.replace(new RegExp(i,"g"),r);return t.sdp&&(t.sdp=this.resetSdp(t.sdp)),[4,this._peer.setLocalDescription(t)];case 2:return n.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===exports.RCMediaType.AUDIO_ONLY?t.isAudioTrack():t.isVideoTrack()})),r={max:0,min:0};return t.forEach((function(e){var t=e.getBitrate(),i=t.min,n=t.max,o=t.start;r.max=r.max<n?n:r.max,r.min=r.min>i?i:r.min,r.max===n?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 mo(this._logger,e),r=this._getMaxRangeBitrate(exports.RCMediaType.VIDEO_ONLY),i=this._getMaxRangeBitrate(exports.RCMediaType.AUDIO_ONLY);return t.setAudiosBitrate(i),t.setVideosBitrate(r),t.stringify()}}),t}(go),vo=function(e){function t(t,r){return e.call(this,r,lo.UNIFIEDPLAN,t)||this}return r(t,e),Object.defineProperty(t.prototype,"stringify",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[this.SDPHeader];d(d([],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),Oo=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 i=u(this.__streams.keys()),n=i.next();!n.done;n=i.next()){var o=n.value;r.set(o,this.pickup(o))}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return r},enumerable:!1,configurable:!0}),e}(),To=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(n.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(),i=e.getStreamId(),n=e.__innerGetMediaStreamTrack();this._localTracks[r]=e;var o=this._outboundStreams[i]||(this._outboundStreams[i]=new MediaStream);o.getTracks().forEach((function(e){e.kind===n.kind&&o.removeTrack(e)})),o.addTrack(n);var a=this._sendTransceiver[r];if(a)a.sender.replaceTrack(n),a.direction="sendonly";else{var s=this._sendTransceiver[r]=this._peer.addTransceiver(n,{direction:"sendonly",streams:[o]});this._setupSenderTransform(s.sender)}Oo.getInstance().push(r,{msid:i,id:this._outboundStreams[i].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,t){void 0===t&&(t=!0);var r=e.getTrackId(),i=e.getStreamId();delete this._localTracks[r];var n=this._sendTransceiver[r];if(n){"closed"!==this._peer.connectionState&&(n.direction="inactive",this._peer.removeTrack(n.sender),n.sender.replaceTrack(null));var o=this._outboundStreams[i];(e.isAudioTrack()?o.getAudioTracks():o.getVideoTracks()).forEach((function(e){return o.removeTrack(e)}));var a=this._sendTransceiver["".concat(r,"_tiny")];if(a&&"inactive"!==a.direction&&t&&"closed"!==this._peer.connectionState){a.direction="inactive";var s=a.sender,c=s.track;this._peer.removeTrack(s),s.replaceTrack(null),this._outboundStreams["".concat(i,"_tiny")].removeTrack(c),c.stop()}}}}),Object.defineProperty(t.prototype,"updateRecvTransceiverMap",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=dt(e).mediaType;this._recvTransceiver[e]=t;var i=r===exports.RCMediaType.AUDIO_ONLY?this._recvAudio:this._recvVideo,n=i.findIndex((function(e){return e===t}));n>=0&&i.splice(n,1)}}),Object.defineProperty(t.prototype,"updateSubRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=e.slice(),i=this._subedTracks.slice();this._subedTracks=e.slice();for(var n=function(e){var t=r[e],n=i.findIndex((function(e){return e===t}));n>=0&&(r.splice(e,1),i.splice(n,1))},o=r.length-1;o>=0;o-=1)n(o);i.length&&i.forEach((function(e){var r=e.getTrackId();e.__innerSetMediaStreamTrack(void 0);var i=t._recvTransceiver[r];i&&(i.direction="inactive")}));var a={audio:0,video:0};r.length&&r.forEach((function(e){var r=e.isAudioTrack()?"audio":"video",i=t._recvTransceiver[e.getTrackId()];i?i.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 s(this,void 0,void 0,(function(){var t,r,i,n;return c(this,(function(o){switch(o.label){case 0:return[4,this._peer.createOffer({iceRestart:e})];case 1:for(i in t=o.sent(),r=t.sdp,this._outboundStreams)n=this._outboundStreams[i].id,r=r.replace(new RegExp(n,"g"),i);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 i=null;return po.getMediaSections(e).forEach((function(e){po.parseExtmap(e);var n=po.parseMLine(e).kind,o=po.parseMsid(e).stream,a=po.getMid(e);"video"===r?/tiny$/.test(o)?o=o.replace(/tiny$/gi,"1_tiny"):o+="_1":o+="_0",o===t&&r===n&&a&&(i=a)})),i}}),Object.defineProperty(t.prototype,"_setSenderTransceiverBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var n=this._localTracks[t],o=null==n?void 0:n.getBitrate();i===Ae.AUDIO&&o&&e.setAudioBitrateWithMid(o,r),i===Ae.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 i in this._sendTransceiver){var n=this._sendTransceiver[i],o=null===(r=n.sender.track)||void 0===r?void 0:r.kind,a=n.direction,s=n.mid;s||(s=this._genarateMid(e,i,o)),s&&(a===_o.SENDONLY&&this._setSenderTransceiverBitrate(t,i,s,o),a===_o.INACTIVE&&t.clearnSsrcWithMid(s,_o.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],i=r.direction,n=r.mid;n&&i===_o.INACTIVE&&e.clearnSsrcWithMid(n,_o.RECVONLY)}}}),Object.defineProperty(t.prototype,"resetOfferSdp",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=new vo(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 vo(this._logger,e);for(var i in this._sendTransceiver){var n=this._sendTransceiver[i],o=n.mid;if(o){var a=this._localTracks[i],s=null==a?void 0:a.getBitrate(),c=null===(t=n.sender.track)||void 0===t?void 0:t.kind;c===Ae.AUDIO&&s&&r.setAudioBitrateWithMid(s,o),c===Ae.VIDEO&&s&&r.setVideoBitrateWithMid(s,o)}}return r.stringify()}}),t}(go),Eo=function(e){function t(t,r,i,n,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:i}),Object.defineProperty(c,"_store",{enumerable:!0,configurable:!0,writable:!0,value:n}),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=go.getSdpSemantics(),l="unified-plan"===u&&s&&"function"==typeof RTCRtpSender.prototype.createEncodedStreams&&"function"==typeof RTCRtpReceiver.prototype.createEncodedStreams&&uo.isInit(),d=c._rtcPeerConn=new RTCPeerConnection({sdpSemantics:u,encodedInsertableStreams:l});return c._sdpStrategy="plan-b"===u?new Co(c._logger,d,!1):new To(c._logger,d,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(n.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 s(this,void 0,void 0,(function(){var i,a,s;return c(this,(function(c){switch(c.label){case 0:return i=this._rtcPeerConn.iceConnectionState,this._logger.info(n.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_S,JSON.stringify({iceConnectionState:i})),[4,this._getStatsData()];case 1:a=c.sent(),s=a?this._createRCRTCStateReport(a).iceCandidatePair:null,this.emit(t.__INNER_ICE_STATE_CHANGE__,{status:i,time:Date.now(),iceCandidatePair:s}),"connected"===i?(this.emit(t.__INNER_ICE_CONNECTED__,this._firstConnectFromPub),this.startAutoExecute(1e3)):"failed"!==i&&"disconnected"!==i||this._handleRetry();try{null===(r=null===(e=this._reportListener)||void 0===e?void 0:e.onICEConnectionStateChange)||void 0===r||r.call(e,i)}catch(e){this._logger.error(n.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_REPORT_R,JSON.stringify({status:o.FAILED,mag:e}))}return[2]}}))}))}}),Object.defineProperty(t.prototype,"_handleRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var e,t=this;return c(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===exports.RCRTCCode.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,i=e.receiver.track,n=[r,"audio"===i.kind?exports.RCMediaType.AUDIO_ONLY:exports.RCMediaType.VIDEO_ONLY].join("_");Object.defineProperty(i,"trackId",{value:n,writable:!1,enumerable:!1,configurable:!1}),this._updateRecvTransceiverMap(n,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 s(this,void 0,void 0,(function(){return c(this,(function(i){return this._sdpStrategy.setBitrate(e,t,r),this._logger.info(n.L_RTC_PEER_CONNECTION_SET_BITRATE_O,JSON.stringify({status:o.SUCCESSED,max:e,min:t,start:r})),[2]}))}))}}),Object.defineProperty(t.prototype,"createOffer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return[4,this._sdpStrategy.createOffer(e)];case 1:return t=r.sent(),this._logger.info(n.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),s(this,void 0,void 0,(function(){return c(this,(function(i){return po.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(Ke.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(Ke.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.on(Ke.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(Ke.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),this._logger.info(n.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(n.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:o.SUCCESSED,trackId:e})),this.removeLocalTrack(t)):this._logger.warn(n.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:o.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,t){void 0===t&&(t=!0);var r=e.getTrackId();delete this.pubLocalTracks[r],this._sdpStrategy.removeLocalTrack(e,t),e.__innerSetPublished(!1),e.off(Ke.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(Ke.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this);var i="".concat(r,"_tiny"),o=this.getLocalTrack(i);o&&t&&(this._sdpStrategy.removeLocalTrack(o,t),delete this.pubLocalTracks[i],o.destroy()),this._logger.info(n.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_O,JSON.stringify({trackId:r}))}}),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(Ke.__INNER_EVENT_MUTED_CHANGE__,e,t)}}),Object.defineProperty(t.prototype,"_onLocalTrackDestroied",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.emit(Ke.__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),a({},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),a({},t)}))}}),Object.defineProperty(t.prototype,"_createRCRTCStateReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.timestamp,r=e.iceCandidatePair,i=e.senders,n=e.receivers;for(var o in(null==r?void 0:r.totalPacketsLost)&&(null==r||delete r.totalPacketsLost),r)It(r[o])&&delete r[o];return{timestamp:t,iceCandidatePair:r,senders:this._createSenderReport(i),receivers:this._createReceiverReport(n)}}}),Object.defineProperty(t.prototype,"_getStatsData",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t;return s(this,void 0,void 0,(function(){var r,i,n;return c(this,(function(o){switch(o.label){case 0:return this._formatStatsData=null,r=null,[4,this._rtcPeerConn.getStats()];case 1:return i=o.sent(),r=null===(e=this.reportParser)||void 0===e?void 0:e.parseRTCStatsReport(i),n=null===(t=this.reportParser)||void 0===t?void 0:t.formatRCRTCStateReport(r),this._formatStatsData=n,[2,n]}}))}))}}),Object.defineProperty(t.prototype,"_reportHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,r,i,o,a;return s(this,void 0,void 0,(function(){var s,u,_,p;return c(this,(function(c){switch(c.label){case 0:return[4,this._getStatsData()];case 1:if(!(s=c.sent()))return[2];u=this._createRCRTCStateReport(s);try{null===(r=null===(e=this._reportListener)||void 0===e?void 0:e.onStateReport)||void 0===r||r.call(e,JSON.parse(JSON.stringify(u)))}catch(e){this._logger.error(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}if(_=d(d([],l(s.receivers),!1),l(s.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__,_),this._isRoomAudience&&(null===(i=this._reportListener)||void 0===i?void 0:i.onReportLiveAudioStates)){p=this._getLiveAudioState();try{p.length&&(null===(a=null===(o=this._reportListener)||void 0===o?void 0:o.onReportLiveAudioStates)||void 0===a||a.call(o,p))}catch(e){this._logger.error(n.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,d([],l(r),!1))})),t.map((function(t){var r=t.source,i=t.audioLevel,n=e._store.getTrackIdBySSRC(r);if(!n)return{};var o=dt(n).userId;return{audioLevel:eo(i),userId:o,trackId:n}})).filter((function(e){return!!e.userId}))}}),Object.defineProperty(t.prototype,"_sendR3R4Data",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t,r,i;return s(this,void 0,void 0,(function(){var n,o,a;return c(this,(function(s){switch(s.label){case 0:return(n=this._formatStatsData)?(o=n.senders,a=n.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(n)]:[3,2]):[2];case 1:s.sent(),s.label=2;case 2:return a.length?[4,null===(i=this._polarisReport)||void 0===i?void 0:i.sendR4Data(n)]:[3,4];case 3:s.sent(),s.label=4;case 4:return o.length=0,a.length=0,n=null,[2]}}))}))}}),Object.defineProperty(t.prototype,"__reportR3R4ToPolaris",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var e=this;return c(this,(function(t){return this._isDestroyed||(clearTimeout(this._reportR3R4ToPolarisTimer),this._reportR3R4ToPolarisTimer=setTimeout((function(){return s(e,void 0,void 0,(function(){var e=this;return c(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(n.L_RTC_PEER_CONNECTION_DESTROY_O,JSON.stringify({status:o.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}(e.EventEmitter),Io=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 i=dt(e.trackId).userId,n=t._store.crtUserId===i?t._peer.getLocalTrack(e.trackId):t._store.getRemoteTrack(e.trackId);n&&r.push({track:n,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}();exports.RCRTCLiveRole=void 0,(fo=exports.RCRTCLiveRole||(exports.RCRTCLiveRole={}))[fo.ANCHOR=1]="ANCHOR",fo[fo.AUDIENCE=2]="AUDIENCE",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"}(ho||(ho={})),function(e){e[e.LOW=0]="LOW",e[e.NORMAL=1]="NORMAL",e[e.HIGH=2]="HIGH"}(bo||(bo={})),function(e){e[e.Destroy=40400]="Destroy"}(Ro||(Ro={}));var So,yo=function(){function e(){}return Object.defineProperty(e.prototype,"priority",{get:function(){return bo.LOW},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"kind",{get:function(){return ho.UNKNOWN},enumerable:!1,configurable:!0}),e}(),Lo=function(){function t(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})}return Object.defineProperty(t.prototype,"_next",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._busy=!1,this._execute()}}),Object.defineProperty(t.prototype,"_execute",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var t,r,i,o,a,s,u;return c(this,(function(c){switch(c.label){case 0:if(this._isDestroyed||this._busy||0===this._queue.length)return[2];this._busy=!0,t=this._queue.shift(),r=t.command,i=t.resolve,a=this._logger.createTraceId(),c.label=1;case 1:return c.trys.push([1,3,,4]),this._logger.info(n.L_INVOKER_EXECUTE_T,"kind: ".concat(r.kind,", length: ").concat(this._queue.length),a),[4,r.execute(this._context,this._store,this)];case 2:return o=c.sent(),[3,4];case 3:return s=c.sent(),console.error(s),this._logger.error(n.L_INVOKER_EXECUTE_R,r.kind,a),this._next(),[2];case 4:return(u=o.code)!==exports.RCRTCCode.SUCCESS&&u!==e.ErrorCode.SUCCESS?this._logger.warn(n.L_INVOKER_EXECUTE_R,"code: ".concat(u,", kind: ").concat(r.kind),a):this._logger.info(n.L_INVOKER_EXECUTE_R,"kind: ".concat(r.kind,", Done"),a),i(o),this._next(),[2]}}))}))}}),Object.defineProperty(t.prototype,"push",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t=this;return c(this,(function(r){return[2,new Promise((function(r){if(t._logger.info(n.L_INVOKER_PUSH_O,JSON.stringify({isDestroyed:t._isDestroyed,kind:e.kind,length:t._queue.length})),t._isDestroyed)r({code:exports.RCRTCCode.NOT_IN_ROOM});else{var i=e.priority;if(i===bo.LOW)t._queue.push({command:e,resolve:r});else{var o=t._queue.findIndex((function(e){return e.command.priority<i})),a=-1===o?t._queue.length-1:o;t._queue.splice(a,0,{command:e,resolve:r})}setTimeout((function(){t._execute()}),0)}}))]}))}))}}),Object.defineProperty(t.prototype,"isDestroyed",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isDestroyed}}),Object.defineProperty(t.prototype,"destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._isDestroyed||(this._logger.info(n.L_INVOKER_DESTROY_O),this._isDestroyed=!0,this._queue.forEach((function(t){t.resolve({code:e.abortCode})})),this._queue.length=0)}}),t}(),Po=function(e){function t(t,r){return e.call(this,t.logger,t,r,exports.RCRTCCode.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}(Lo),Ao=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),i=r.ssrc,n=r.resourceId;e._trackIdSSRCMap.set(i,n)}))}))}}),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),i=dt(r),n=i.tag,o=i.userId,a=i.mediaType===exports.RCMediaType.AUDIO_ONLY?new rt(e._logger,n,o):new it(e._logger,n,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=Pt(e.version),this._roomResources=yt(e,this.roomId,this._logger,t),this._updateTrackIdSSRCMap(),this._initRemoteTracks(),this.setResourcesByUserId(this.crtUserId,this.getResourcesByUserId(this.crtUserId)||[]),this._logger.info(n.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,d([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,d([0,this._collectSubscribeList.length],l(e),!1))}}),Object.defineProperty(t.prototype,"setRoomStatusVersion",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._roomStatusVersion=Pt(e)}}),t}(function(){function e(e,t,r,i,n,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:i}),Object.defineProperty(this,"crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:n}),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 i=this._remoteTracks[r];i.getUserId()===e&&t.push(i)}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=dt(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}()),No=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return ho.UNPUBLISH_PREV},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return s(this,void 0,void 0,(function(){var i,a,s,u,l,d;return c(this,(function(c){switch(c.label){case 0:return i=t.logger,a=t.context,s=r.getResourcesByUserId(r.crtUserId),u=s.slice(),s.length=0,l=i.createTraceId(),i.info(n.L_UNPUBLISH_PREV_COMMAND_T,JSON.stringify({resource:u}),l),[4,a.setRTCTotalRes(r.roomId,[nt(Tt.UNPUBLISH,u)],ot([]),Tt.TOTAL_CONTENT_RESOURCE,ot([]))];case 1:return(d=c.sent())!==e.ErrorCode.SUCCESS?i.error(n.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:o.FAILED,code:d}),l):i.info(n.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:o.SUCCESSED}),l),[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),i}(yo);exports.RTCMode=void 0,(So=exports.RTCMode||(exports.RTCMode={}))[So.RTC=0]="RTC",So[So.LIVE=2]="LIVE",So[So.CROSS_MUTI=7]="CROSS_MUTI",So[So.SIP=4]="SIP",So[So.CALL=5]="CALL";var wo,Do=function(t){function i(e,r,i,n,o,a,s){var c=t.call(this)||this;return Object.defineProperty(c,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(c,"roomType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(c,"joinType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(c,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:n}),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(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return ho.JOINROOM},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"_getResultTag",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=n.L_RTC_CLIENT_JOIN_RTC_ROOM_R;return this.roomType===exports.RTCMode.LIVE&&(e=n.L_RTC_CLIENT_JOIN_LIVING_ROOM_R),e}}),Object.defineProperty(i.prototype,"_validateParams",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){var n=this;if(t.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED)return r.error(i,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.SIGNAL_DISCONNECTED,msg:"im not connected"}),this.traceId),{code:exports.RCRTCCode.SIGNAL_DISCONNECTED};if(St(t.getNaviInfo()))return r.error(i,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),this.traceId),{code:exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR};if(!e.validate("roomId",this.roomId,e.notEmptyString,!0))return r.error(i,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> roomId"}),this.traceId),{code:exports.RCRTCCode.PARAMS_ERROR};if(!e.validate("roomType",this.roomType,(function(e){return void 0!==exports.RTCMode[e]})))return r.error(i,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> roomType"}),this.traceId),{code:exports.RCRTCCode.PARAMS_ERROR};if(!e.validate("outerUserDatas",this.outerUserDatas,e.isObject,!1))return r.error(i,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:exports.RCRTCCode.PARAMS_ERROR};if(this.outerUserDatas&&!Object.keys(this.outerUserDatas).every((function(t){return e.validate("outerUserDatas.".concat(t),n.outerUserDatas[t],e.isString,!0)})))return r.error(i,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:exports.RCRTCCode.PARAMS_ERROR};return{code:exports.RCRTCCode.SUCCESS}}}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){var n;return s(this,void 0,void 0,(function(){var a,s,u,l,d,_,p,f,h,b,R,g,m;return c(this,(function(c){switch(c.label){case 0:return a=Date.now(),s=t.context,u=t.service,l=t.logger,d=t.reportMediaActionLogger,_=this._getResultTag(),(p=this._validateParams(s,l,_).code)!==exports.RCRTCCode.SUCCESS?[2,{code:p}]:u.getMsList().length?(f=r.getSupportNtf(),[4,s.joinRTCRoom(this.roomId,this.roomType,this.livingType,this.joinType,this.innerUserDatas,this.outerUserDatas,f)]):(l.error(_,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),this.traceId),[2,{code:exports.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER}]);case 1:return h=c.sent(),b=h.code,R=h.data,d.reportQualityJoinRoomData(a,b,this.roomType,null==R?void 0:R.sessionId),b===e.ErrorCode.SUCCESS&&R?(r.initWithRoomData(R,this.traceId),r.getResourcesByUserId(r.crtUserId).length>0&&i.push(new No),(m=null===(n=R.roomInfo.filter((function(e){return"cdn_uris"===e.key}))[0])||void 0===n?void 0:n.value)&&r.setCDNUris(JSON.parse(m)[0]),l.info(_,JSON.stringify({status:o.SUCCESSED,userId:r.crtUserId,roomId:this.roomId}),this.traceId),[2,{code:exports.RCRTCCode.SUCCESS,data:R}]):(g=40032===b?exports.RCRTCCode.SIGNAL_JOIN_RTC_ROOM_REFUSED:b,l.error(_,JSON.stringify({status:o.FAILED,code:g,msg:"joinRoom failed"}),this.traceId),[2,{code:g}])}}))}))}}),i}(yo);!function(e){e[e.ROOM=1]="ROOM",e[e.PERSON=2]="PERSON"}(wo||(wo={}));var ko,Uo,Mo,xo="PEER_CONNECTION_CLOSED_BY_EXCEPTION",jo="USER_JOIN",Bo="USER_LEAVE",Vo="TRACKS_PUBLISH",Fo="TRACKS_UNPUBLISH",Jo="AUDIO_MUTE_CHANGE",Go="VIDEO_MUTE_CHANGE",Ho="CDN_ENABLE_CHANGE",Ko="USER_STATE_CHANGE",Wo=function(e){function t(t,r,i,n,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:i}),Object.defineProperty(u,"runtime",{enumerable:!0,configurable:!0,writable:!0,value:n}),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}(e.EventEmitter);!function(e){e.PUBLISH="publish",e.SUBSCRIBE="subscribe"}(ko||(ko={})),function(e){e.BEGIN="begin",e.END="end"}(Uo||(Uo={})),function(e){e[e.SPREAD=0]="SPREAD",e[e.NO_SPREAD=-1]="NO_SPREAD"}(Mo||(Mo={}));var Yo,zo=function(e){function t(t,r,i){var n=e.call(this)||this;return Object.defineProperty(n,"reqBody",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"isNeedUpdateMsas",{enumerable:!0,configurable:!0,writable:!0,value:i}),n}return r(t,e),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i;return s(this,void 0,void 0,(function(){var r,n,o,s,u,l,d,_,p,f;return c(this,(function(c){switch(c.label){case 0:return r=e.service,n=e.context,[4,r.exchange(t.getRTCRequestHeader(),this.reqBody,this.traceId,this.isNeedUpdateMsas)];case 1:return o=c.sent(),s=o.code,u=o.data,l=o.qualityMsList,d={code:s,data:{data:u,qualityMsList:l}},_=null===(i=null==u?void 0:u.urls)||void 0===i?void 0:i.pull_url,t.roomMode===exports.RTCMode.LIVE&&_&&(p=JSON.parse(_),t.setCDNUris(p),(null==p?void 0:p.broadcast)===Mo.SPREAD&&(t.setCDNEnabel(!0),f=a(a({},p),{enableInnerCDN:!0}),ea(n,t.roomId,f))),[2,d]}}))}))}}),t}(yo);!function(e){e.PUB="pub",e.UNPUB="unpub",e.SUB="sub",e.UNSUB="unsub"}(Yo||(Yo={}));var qo=function(t){function i(e,r,i,n,o){void 0===n&&(n=Yo.SUB);var a=t.call(this)||this;return Object.defineProperty(a,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(a,"forceReq",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(a,"fromCommand",{enumerable:!0,configurable:!0,writable:!0,value:n}),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(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return ho.UPDATE_SUBSCRIBE_LIST},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"_dealSubscribeResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var a=null==i?void 0:i.map((function(e){return"".concat(e.msid,"_").concat(e.mediaType)})),s=r.filter((function(e){return null==a?void 0:a.includes(e.track.getTrackId())})),c=r.filter((function(e){return!(null==a?void 0:a.includes(e.track.getTrackId()))}));t.info(n.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:o.SUCCESSED,subSuccessTrackIds:a,failedList:c}),this.traceId);var u=e.getRemoteTracks(),l=function(e){var t=s.some((function(t){return t.track.getTrackId()===e}));u[e].__innerSetSubscribed(t);var r=s.some((function(t){return t.track.getTrackId()===e&&t.subTiny}));u[e].isVideoTrack()&&u[e].__innerSetIsTinyTrack(r)};for(var d in u)l(d);return e.resetSubscribedList(s),c}}),Object.defineProperty(i.prototype,"_getParams",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=this,o=r.map((function(e){return e instanceof tt?{track:e}:a({},e)})),s={};return o=o.filter((function(r){var o=r.track.getTrackId();return e.getRemoteTrack(o)?!s[o]&&(s[o]=!0,!0):(t.warn(n.L_UPDATE_SUBSCRIBELIST_COMMAND_P,"track cannot found in room -> trackId: ".concat(o),i.traceId),!1)})).map((function(e){return a({},e)}))}}),Object.defineProperty(i.prototype,"_validateParams",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return e.validate("tracks",r,(function(){return e.isArray(r)&&r.every((function(e){return e instanceof tt||e.track instanceof tt}))}),!0)?{code:exports.RCRTCCode.SUCCESS}:(t.warn(n.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"tracks is invalid"}),this.traceId),{code:exports.RCRTCCode.PARAMS_ERROR})}}),Object.defineProperty(i.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(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,s,u,l,d,_,p,f,h,b,R,g,m,C,v,O,T,E,I,S,y,L,P=this;return c(this,(function(c){switch(c.label){case 0:if(i=e.logger,s=e.peer,u=e.reportMediaActionLogger,l=e.context,this._actionStartTime=Date.now(),_=(d=this).tracks,p=d.forceReq,f=t.roomId,i.info(n.L_UPDATE_SUBSCRIBELIST_COMMAND_T,"roomId: ".concat(f,", forceReq: ").concat(p,", trackIds: ").concat(_.map(Lt)),this.traceId),(h=this._validateParams(i,_).code)!==exports.RCRTCCode.SUCCESS)return[2,{code:h}];if(b=this._getParams(t,i,_),R=t.getSubscribedList().map((function(e){return a({},e)})),!p){if(!sa(b,R))return i.warn(n.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:o.SUCCESSED,msg:"subscribe list unchanged"}),this.traceId),[2,{code:exports.RCRTCCode.SUCCESS}];R.length&&(g=R.map((function(e){return e.track})),i.warn(n.L_CLEAR_UNSUBSCRIBE_LIST_O,JSON.stringify({list:g.map((function(e){return e.getTrackId()}))}),this.traceId),m=t.getSubscribedList().filter((function(e){return g.every((function(t){return t.getTrackId()!==e.track.getTrackId()}))})),t.resetSubscribedList(m))}return s.__reportR3R4ToPolaris(),s.clearReTryExchangeTimer(),s.updateSubRemoteTracks(b.map((function(e){return e.track}))),[4,Xo(b,!1,s,t,l)];case 1:return(C=c.sent()).pushOtherRooms=e.getPushOtherRooms(),[4,new zo(C,this.traceId,!0).execute(e,t,r)];case 2:return v=c.sent(),_.forEach((function(e){var t=e instanceof tt?e.getTrackId():e.track.getTrackId();P._trackMediaMap[t]=v.data.qualityMsList||[]})),O=this.fromCommand===Yo.SUB?_:this.unsubTracks,v.code!==exports.RCRTCCode.SUCCESS?(this._reportPubOrSubQualityData(u,v.code,O),i.error(n.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:o.FAILED,code:v.code}),this.traceId),[2,{code:v.code}]):(T=v.data.data,E=T.sdp,I=T.resultCode,S=T.subscribedList,I!==exports.RCRTCCode.SUCCESS?(this._reportPubOrSubQualityData(u,I,O),i.error(n.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:o.FAILED,code:I}),this.traceId),[2,{code:I}]):(u.setPubOrSubSuccessTime(Date.now()),[4,s.setRemoteAnswer(E.sdp)]));case 3:return y=c.sent(),this._reportPubOrSubQualityData(u,y,O),y!==exports.RCRTCCode.SUCCESS?[2,{code:y}]:[2,(L=this._dealSubscribeResult(t,i,b,S)).length?{code:exports.RCRTCCode.SUCCESS,data:L}:{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),i}(yo),Qo=function(t){function i(e,r){var i=t.call(this)||this;return Object.defineProperty(i,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(i,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return ho.UNSUBSCRIBE},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var s,u,l,d;return c(this,(function(c){return s=t.logger,u=t.polarisReport,l=this.tracks,e.validate("tracks",l,(function(){return e.isArray(l)&&l.length>0&&l.every((function(e){return e instanceof tt}))}),!0)?(s.info(n.L_ABSTRACT_ROOM_UNSUBSCRIBE_T,JSON.stringify({unSubscribeTrackIds:l.map(Lt)}),this.traceId),d=r.getSubscribedList().map((function(e){return a({},e)})).filter((function(e){return l.every((function(t){return t.getTrackId()!==e.track.getTrackId()}))})),u.sendR2(ko.SUBSCRIBE,Uo.END,l.map((function(e){return e.getTrackId()}))),[2,new qo(d,!1,this.traceId,Yo.UNSUB,this.tracks).execute(t,r,i)]):(s.warn(n.L_ABSTRACT_ROOM_UNSUBSCRIBE_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),[2,{code:exports.RCRTCCode.PARAMS_ERROR}])}))}))}}),i}(yo),Zo=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 s(this,void 0,void 0,(function(){var i,o,a;return c(this,(function(s){switch(s.label){case 0:return i=e.logger,o=this.tracks,a=i.createTraceId(),i.info(n.L_USER_LEFT_UNSUBSCRIBE_O,void 0,a),[4,new Qo(o,a).execute(e,t,r)];case 1:return s.sent(),o.forEach((function(e){e.__innerDestroy(),t.removeRemoteTrack(e.getTrackId())})),e.emit(Fo,o),[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),t}(yo);function Xo(e,t,r,i,n){var o;return s(this,void 0,void 0,(function(){var a,s;return c(this,(function(c){switch(c.label){case 0:return a=(null===(o=n.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=dt(t).userId,n=i.getResourcesByUserId(r);if(!n)return!1;var o=n.filter((function(e){return t==="".concat(e.msid,"_").concat(e.mediaType)})).length;return o})).map((function(e){return{simulcast:e.subTiny?Gn.TINY:Gn.NORMAL,resolution:"",uri:i.getPublishedResourceByTrackId(e.track.getTrackId()).uri}})),switchstream:!1}]}}))}))}function $o(t,r,i){return s(this,void 0,void 0,(function(){var a,s;return c(this,(function(c){switch(c.label){case 0:return a=t.logger.createTraceId(),t.logger.info(n.L_LIVING_ROOM_SPREAD_CDN_INFO_T,JSON.stringify({CDNUris:i}),a),[4,t.setRTCCDNUris(r,Tt.TOTAL_CONTENT_RESOURCE,JSON.stringify([i]))];case 1:return(s=c.sent())!==e.ErrorCode.SUCCESS?(t.logger.error(n.L_LIVING_ROOM_SPREAD_CDN_INFO_R,"status: ".concat(o.FAILED,", code: ").concat(s),a),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(t.logger.info(n.L_LIVING_ROOM_SPREAD_CDN_INFO_R,"status: ".concat(o.SUCCESSED),a),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}function ea(t,r,i){return s(this,void 0,void 0,(function(){var a,s;return c(this,(function(c){switch(c.label){case 0:return a=t.logger.createTraceId(),t.logger.info(n.L_LIVING_ROOM_SET_ROOM_CDN_INFO_T,"CDNUris: ".concat(i),a),[4,t.setRTCData(r,"cdn_uris",JSON.stringify([i]),!0,wo.ROOM)];case 1:return(s=c.sent())!==e.ErrorCode.SUCCESS?(t.logger.error(n.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,"status: ".concat(o.FAILED,", code: ").concat(s),a),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(t.logger.info(n.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,"status: ".concat(o.SUCCESSED),a),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}function ta(e,t){return s(this,void 0,void 0,(function(){var r,i,n;return c(this,(function(o){switch(o.label){case 0:return r=t.roomId,i=Object.assign({},t.getCDNUris(),{enableInnerCDN:t.getCDNEnable()}),[4,Promise.all([$o(e,r,i),ea(e,r,i)])];case 1:return n=o.sent(),[2,n.every((function(e){return e.code===exports.RCRTCCode.SUCCESS}))?{code:exports.RCRTCCode.SUCCESS}:{code:exports.RCRTCCode.SIGNAL_ERROR}]}}))}))}var ra=function(e,t,r,i){return s(void 0,void 0,void 0,(function(){var n,o,a,s,u,l,d;return c(this,(function(c){switch(c.label){case 0:for(a in n=e.crtUserId,o=[],i)o.push(a);s=0,c.label=1;case 1:return s<o.length?(u=o[s])===n?[3,3]:(l=i[u]).length?(d=l.map((function(t){return e.getRemoteTrack(lt(t))})),[4,new Zo(d).execute(t,e,r)]):[3,3]:[3,4];case 2:c.sent(),c.label=3;case 3:return s++,[3,1];case 4:return[2]}}))}))};function ia(t,r,i,a,u,l){return s(this,void 0,void 0,(function(){var s,d,_,p,f,h,b,R,g,m,C,v,O,T,E,I,S,y,L;return c(this,(function(c){switch(c.label){case 0:for(s=i.logger,d=r.roomId,_=r.roomMode,p=[],f={},h={},b={},R=yt(t,d,s,l),g=Object.keys(R),m=r.getAllUserIds(),C=g.length-1;C>=0;C-=1)v=g[C],-1!==(O=m.indexOf(v))?(T=r.getResourcesByUserId(v),E=R[v],I=ft(T,E,!0),S=I.publishedList,y=I.modifiedList,L=I.unpublishedList,f[v]=pt(S),h[v]=pt(L),b[v]=pt(y),m.splice(O,1)):(p.push(v),f[v]=pt(R[v]));return m.length&&m.forEach((function(e){r.removeResourcesByUserId(e)})),r.assignRoomData(R),m.length?[4,na(m,i,r,a,l)]:[3,2];case 1:c.sent(),i.emit(Bo,m),c.label=2;case 2:return p.length&&i.emit(jo,p),[4,ra(r,i,a,h)];case 3:return c.sent(),function(e,t,r){var i=t.logger;Object.keys(r).forEach((function(n){var o=r[n];if(0!==o.length){var a=o.map((function(t){var r=lt(t),n=dt(r),o=n.userId,a=n.tag,s=n.mediaType===exports.RCMediaType.AUDIO_ONLY?new rt(i,a,o):new it(i,a,o);return e.addRemoteTrack(s),s.__innerSetRemoteMuted(0===t.state),s}));a.length&&t.emit(Vo,a)}}))}(r,i,f),function(e,t,r){Object.keys(r).forEach((function(i){r[i].forEach((function(r){var i=lt(r),n=e.getRemoteTrack(i);n.__innerSetRemoteMuted(0===r.state),n.isAudioTrack()?t.emit(Jo,n):t.emit(Go,n)}))}))}(r,i,b),_===e.RTCMode.LIVE&&function(e,t,r,i){var a;if(!i)return void r.warn(n.L_LIVING_ROOM_RECONNECTED_R,JSON.stringify({status:o.FAILED,code:"",msg:"cdn_uris not found"}));var s=JSON.parse(i),c=(null===(a=t.getCDNUris())||void 0===a?void 0:a.enableInnerCDN)!==s.enableInnerCDN;t.setCDNUris(s),c&&e.emit(Ho,s.enableInnerCDN)}(i,r,s,u),[2]}}))}))}function na(e,t,r,i,n){return s(this,void 0,void 0,(function(){var o,a;return c(this,(function(s){switch(s.label){case 0:return o=[],a=[],e.forEach((function(e){o.push.apply(o,d([],l(r.getRemoteTracksByUserId(e)),!1)),a.push(e)})),o.length?[4,new Qo(o,n).execute(t,r,i)]:[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 oa,aa=function(e,t,r){var i=e.split("\r\nm"),n=r===exports.RCMediaType.AUDIO_ONLY?"audio":"video",o=i.filter((function(e){return e.includes("=".concat(n))&&e.includes(t)}))[0],a=new RegExp("a=ssrc:(.*?) msid:".concat(t)),s=o.match(a);return s?s[1]:""},sa=function(e,t){var r=!1;return e.forEach((function(e){var i=t.findIndex((function(t){return t.track.getTrackId()===e.track.getTrackId()}));-1!==i?t.splice(i,1)[0].subTiny!==e.subTiny&&(r=!0):r=!0})),t.length&&(r=!0),r},ca=function(e){function t(t,r){var i=e.call(this)||this;return Object.defineProperty(i,"msgContent",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return r(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return ho.PARSE_USERSTATE},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"priority",{get:function(){return bo.NORMAL},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_isPKRoomUser",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i;try{for(var n=u(t),o=n.next();!o.done;o=n.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&&(i=n.return)&&i.call(n)}finally{if(r)throw r.error}}return!1}}),Object.defineProperty(t.prototype,"_dealAddUser",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,o){var a=e.getResourcesByUserId(o);a||(i?r.upgrade.push(o):r.joined.push(o),t.info(n.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:o,msg:"user ".concat(i?"upgrade":"joined")}),this.traceId)),e.setResourcesByUserId(o,a||[])}}),Object.defineProperty(t.prototype,"_dealReduceUser",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,o){e.info(n.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:o,msg:"user ".concat(i?"downgrade":"left")}),this.traceId),i?t.downgrade.push(o):1!==Number(r)?t.offline.push(o):t.left.push(o)}}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n,o,a,s=this;return c(this,(function(c){switch(c.label){case 0:return i=e.logger,n={joined:[],left:[],offline:[],upgrade:[],downgrade:[]},0===(o=this.msgContent.users).length?[2,{code:exports.RCRTCCode.SUCCESS,data:n}]:this._isPKRoomUser(t,o)?[2,{code:exports.RCRTCCode.SUCCESS,data:n}]:(o.forEach((function(e){var r=e.userId;0===Number(e.state)?s._dealAddUser(t,i,n,e.switchRoleType,r):s._dealReduceUser(i,n,e.state,e.switchRoleType,r)})),(a=d(d(d([],l(n.left),!1),l(n.downgrade),!1),l(n.offline),!1)).length?[4,na(a,e,t,r,this.traceId)]:[3,2]);case 1:c.sent(),c.label=2;case 2:return[2,{code:exports.RCRTCCode.SUCCESS,data:n}]}}))}))}}),t}(yo),ua=function(e){function t(t,r,i,n,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:i}),Object.defineProperty(a,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:n}),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 ho.PARSE_REMOTERES},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"priority",{get:function(){return bo.NORMAL},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_dealPublishList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,a,s,u,l,d,_,p=this;return c(this,(function(c){switch(c.label){case 0:return i=e.logger,a=e.reportMediaActionLogger,s=this._nowResources.map(lt),u=[],l=[],this._publishedList.forEach((function(e){var r=lt(e),n=s.indexOf(r),o=dt(r),a=o.userId,c=o.tag,d=o.mediaType;n>-1?p._nowResources[n]=e:p._nowResources.push(e);var _=t.getRemoteTrack(r);_?_.isSubscribed()&&u.push(_):(_=d===exports.RCMediaType.AUDIO_ONLY?new rt(i,c,a):new it(i,c,a),t.addRemoteTrack(_),l.push(_)),_.__innerSetRemoteMuted(0===e.state)})),u.length?(d=u.map((function(e){return e.getTrackId()})),[4,new qo(u,!0,this.traceId).execute(e,t,r)]):[3,2];case 1:(_=c.sent().code)!==exports.RCRTCCode.SUCCESS&&i.error(n.L_RESUB_REPUB_RES_R,JSON.stringify({status:o.FAILED,trackIds:d,code:_}),this.traceId),c.label=2;case 2:return l.length&&e.emit(Vo,l),a.reportQualityRecvPubMsgData(this.sentTime,this.senderId),[2]}}))}))}}),Object.defineProperty(t.prototype,"_dealUnpublishList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n,o,a;return c(this,(function(s){switch(s.label){case 0:for(i=this._unpublishedList.map(lt),n=this._nowResources.length-1;n>=0;n-=1)o=this._nowResources[n],i.includes(lt(o))&&this._nowResources.splice(n,1);return a=this._unpublishedList.map((function(e){var r=lt(e);return t.getRemoteTrack(r)})),[4,new Zo(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 s(this,void 0,void 0,(function(){var r,i,n,o,a,s,l,d,_;return c(this,(function(c){r=this._nowResources.map(lt);try{for(i=u(this._modifiedList),n=i.next();!n.done;n=i.next())o=n.value,a=lt(o),s=r.indexOf(a),this._nowResources[s].state=o.state,(l=t.getRemoteTrack(a)).__innerSetRemoteMuted(0===o.state),l.isAudioTrack()?e.emit(Jo,l):e.emit(Go,l)}catch(e){d={error:e}}finally{try{n&&!n.done&&(_=i.return)&&_.call(i)}finally{if(d)throw d.error}}return[2]}))}))}}),Object.defineProperty(t.prototype,"_updateCDNUris",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i,n=this.msgContent.cdn_uris[0],o=(null===(r=t.getCDNUris())||void 0===r?void 0:r.enableInnerCDN)!==n.enableInnerCDN;t.setCDNUris(n),o&&e.emit(Ho,!!(null===(i=t.getCDNUris())||void 0===i?void 0:i.enableInnerCDN))}}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n,o,a,s,u,_,p,f,h;return c(this,(function(c){switch(c.label){case 0:if(i=this.msgContent.uris,this._publishedList=[],this._unpublishedList=[],this._modifiedList=[],o=this.senderId,a=this.messageType,!t.getRemoteUserIds().includes(o))return[2,{code:exports.RCRTCCode.SUCCESS}];switch(this._nowResources=t.getResourcesByUserId(o)||[],a){case Tt.MODIFY:(s=this._modifiedList).push.apply(s,d([],l(i),!1));break;case Tt.PUBLISH:(u=this._publishedList).push.apply(u,d([],l(i),!1));break;case Tt.UNPUBLISH:(_=this._unpublishedList).push.apply(_,d([],l(i),!1));break;case Tt.TOTAL_CONTENT_RESOURCE:n=ft(this._nowResources,i),(p=this._publishedList).push.apply(p,d([],l(n.publishedList),!1)),(f=this._unpublishedList).push.apply(f,d([],l(n.unpublishedList),!1)),(h=this._modifiedList).push.apply(h,d([],l(n.modifiedList),!1))}return this._publishedList.length?[4,this._dealPublishList(e,t,r)]:[3,2];case 1:c.sent(),c.label=2;case 2:return this._unpublishedList.length?[4,this._dealUnpublishList(e,t,r)]:[3,4];case 3:c.sent(),c.label=4;case 4:return this._modifiedList.length?[4,this._dealModifiedList(e,t)]:[3,6];case 5:c.sent(),c.label=6;case 6:return t.setResourcesByUserId(o,this._nowResources),t.roomMode!==exports.RTCMode.LIVE?[2,{code:exports.RCRTCCode.SUCCESS}]:this.msgContent.cdn_uris?(this._updateCDNUris(e,t),[2,{code:exports.RCRTCCode.SUCCESS}]):[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),t}(yo),la=function(t){function i(e,r,i){var n=t.call(this)||this;return Object.defineProperty(n,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(n,"forceReq",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i}),n}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return ho.SUBSCRIBE},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var s,u,l,d,_,p,f,h,b;return c(this,(function(c){return s=t.logger,u=t.polarisReport,d=(l=this).tracks,_=l.forceReq,e.validate("tracks",d,(function(){return e.isArray(d)&&d.length>0&&d.every((function(e){return e instanceof tt||e.track instanceof tt}))}),!0)?(s.info(n.L_ABSTRACT_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:d.map(Lt),forceReq:_}),this.traceId),p=r.getSubscribedList().map((function(e){return a({},e)})),f=d.map((function(e){return e instanceof tt?{track:e}:e})),h=!1,b=[],f.forEach((function(e){var t=e.track.getTrackId();b.push(t);var r=p.find((function(e){return e.track.getTrackId()===t}));r&&r.subTiny===e.subTiny||(r?r.subTiny=e.subTiny:p.push(e),h=!0)})),h||_?(u.sendR2(ko.SUBSCRIBE,Uo.BEGIN,b),[2,new qo(p,!0,this.traceId).execute(t,r,i)]):(s.warn(n.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:o.SUCCESSED,msg:"repeat subscribe"}),this.traceId),[2,{code:exports.RCRTCCode.SUCCESS}])):(s.error(n.L_ABSTRACT_ROOM_SUBSCRIBE_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),[2,{code:exports.RCRTCCode.PARAMS_ERROR}])}))}))}}),i}(yo),da=function(t){function i(e){var r=t.call(this)||this;return Object.defineProperty(r,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),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(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return ho.PUBLISH},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"_removePubFailedTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.forEach((function(e){var r=e instanceof Ke?e:e.track;t.removeLocalTrackById(r.getTrackId())}))}}),Object.defineProperty(i.prototype,"_addLocalTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,o,a,s,l,d,_,p,f,h,b,R,g,m,C,v,O,T;return c(this,(function(c){switch(c.label){case 0:r=[],c.label=1;case 1:c.trys.push([1,10,11,12]),i=u(e),o=i.next(),c.label=2;case 2:if(o.done)return[3,9];if(a=o.value,l=(s=a instanceof Ke?{pubTiny:!1,track:a}:a).track,d=s.pubTiny,!l.isVideoTrack())return[3,7];if(!d)return[3,7];_=void 0,c.label=3;case 3:return c.trys.push([3,5,,6]),_=l.__innerGetMediaStreamTrack().clone(),p=d.frameRate||exports.RCFrameRate.FPS_15,f=d.resolution||exports.RCResolution.W176_H144,h=bt(f),b=h.width,R=h.height,g=mt(p),[4,_.applyConstraints({width:b,height:R,frameRate:g})];case 4:return c.sent(),[3,6];case 5:return m=c.sent(),null==_||_.stop(),this._logger.warn(n.L_ABSTRACT_ROOM_PUBLISH_E,"pubTiny failed -> id: ".concat(l.getTrackId(),", msg: ").concat(m.message),this._traceId),[3,9];case 6:return C=new Ye(this._logger,l.getTag(),l.getUserId(),_,!0),r.push(C),t.addLocalTrack(C),[3,7];case 7:t.addLocalTrack(l),c.label=8;case 8:return o=i.next(),[3,2];case 9:return[3,12];case 10:return v=c.sent(),O={error:v},[3,12];case 11:try{o&&!o.done&&(T=i.return)&&T.call(i)}finally{if(O)throw O.error}return[7];case 12:return[2,r]}}))}))}}),Object.defineProperty(i.prototype,"__publish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){return s(this,void 0,void 0,(function(){var s,u,l,d,_,p,f,h,b,R,g,m,C=this;return c(this,(function(c){switch(c.label){case 0:return s=e.peer,u=e.reportMediaActionLogger,l=e.context,t.roomId,d=[],r.forEach((function(e){var t=(e instanceof Ke?{track:e}:e).track;d.push(t)})),r.sort((function(e,t){return(e instanceof Ke?{track:e}:e).track.getBitrate().max-(t instanceof Ke?{track:t}:t).track.getBitrate().max})),s.getLocalTracks().length+function(e,t){var r=0;return e.forEach((function(e){var i=e instanceof Ke?e.getTrackId():e.track.getTrackId();t.getLocalTrack(i)||(e instanceof Ke?r++:e.pubTiny&&e.track.isVideoTrack()&&(r+=2))})),r}(r,s)>10?(this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PUBLISH_TRACK_LIMIT_EXCEEDED,trackIds:r.map(Lt),msg:"publish track limit exceeded"}),this._traceId),[2,{code:exports.RCRTCCode.PUBLISH_TRACK_LIMIT_EXCEEDED,tracks:d}]):[4,this._addLocalTracks(r,s)];case 1:return _=c.sent(),s.clearReTryExchangeTimer(),[4,Xo(t.getSubscribedList(),!1,s,t,l)];case 2:return(p=c.sent()).pushOtherRooms=e.getPushOtherRooms(),[4,new zo(p,this._traceId,!0).execute(e,t,i)];case 3:return f=c.sent(),d.forEach((function(e){var t=e.getTrackId();C._trackMediaMap[t]=f.data.qualityMsList||[]})),f.code!==exports.RCRTCCode.SUCCESS?(u.reportPubOrSubQualityData(Yo.PUB,this._actionStartTime,d,f.code,this._trackMediaMap),this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:o.FAILED,tracks:r.map(Lt),code:f.code,msg:"exchange failed"}),this._traceId),this._removePubFailedTracks(r,s),[2,{code:f.code,tracks:d}]):(h=f.data.data,b=h.sdp,R=h.resultCode,g=h.message,R!==exports.RCRTCCode.SUCCESS?(u.reportPubOrSubQualityData(Yo.PUB,this._actionStartTime,d,R,this._trackMediaMap),this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:o.FAILED,trackIds:r.map(Lt),code:R,msg:"exchange inner failed: ".concat(g)}),this._traceId),this._removePubFailedTracks(r,s),[2,{code:R,tracks:d}]):(u.setPubOrSubSuccessTime(Date.now()),[4,s.setRemoteAnswer(b.sdp,!0)]));case 4:return(m=c.sent())!==exports.RCRTCCode.SUCCESS?(u.reportPubOrSubQualityData(Yo.PUB,this._actionStartTime,d,m,this._trackMediaMap),this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:o.FAILED,trackIds:r.map(Lt),code:m,msg:"set remote answer error"}),this._traceId),[2,{code:m,tracks:d}]):(_.length&&this._updateTinyTrackIdSSRCMap(t,p.sdp.sdp,_),[2,a(a({code:R},f.data),{tracks:d})])}}))}))}}),Object.defineProperty(i.prototype,"_updateTinyTrackIdSSRCMap",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){r.forEach((function(r){var i=aa(t,r.getStreamId(),exports.RCMediaType.VIDEO_ONLY);e.setTrackIdSSRCMap(Number(i),r.getTrackId())}))}}),Object.defineProperty(i.prototype,"_dealPublishRes",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var s,u,_,p,f,h,b,R,g,m,C,v,O,T,E,I,S,y,L,P,A,N,w;return c(this,(function(c){switch(c.label){case 0:return s=i.polarisReport,u=i.context,_=i.peer,p=i.reportMediaActionLogger,f=r.crtUserId,h=r.roomId,b="",R=r.getResourcesByUserId(f),g=d([],l(R),!1),[],C=t.tracks,t.code!==exports.RCRTCCode.SUCCESS?[2,{code:t.code}]:(v=t.data,O=v.publishList,T=v.urls,E=v.mcuPublishList,b=null==T?void 0:T.liveUrl,O.map((function(e){return a({tag:e.msid.split("_").pop(),state:_.getLocalTrack(lt(e)).isLocalMuted()?0:1},e)})).forEach((function(e){var t=function(e,t){for(var r=!1,i=0,n=0;n<t.length;n++){var o=t[n];if("".concat(e.msid,"_").concat(e.mediaType)==="".concat(o.msid,"_").concat(o.mediaType)){r=!0,i=n;break}}return{isInclude:r,index:i}}(e,g),r=t.isInclude,i=t.index;r?g.splice(i,1,e):g.push(e)})),I=(null==E?void 0:E.map((function(e){return a({tag:e.msid.split("_").pop(),state:1},e)})))||[],m=I,S=ft(R,g).publishedList,y=a(a({},r.getCDNUris()),{enableInnerCDN:r.getCDNEnable()}),L=y&&y.broadcast===Mo.SPREAD?JSON.stringify([y]):"",P=Date.now(),[4,u.setRTCTotalRes(h,[nt(Tt.PUBLISH,S)],ot(g),Tt.TOTAL_CONTENT_RESOURCE,ot(m),L)]);case 1:return A=c.sent(),p.reportPubOrSubQualityData(Yo.PUB,this._actionStartTime,C,A,this._trackMediaMap,[{dur:Date.now()-P,cod:A}]),A!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:o.FAILED,code:A,msg:"send publish streams notification failed"}),this._traceId),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(r.setResourcesByUserId(f,g),N=S.map((function(e){return lt(e)})),s.sendR2(ko.PUBLISH,Uo.BEGIN,N),S.forEach((function(e){_.getLocalTrack("".concat(e.msid,"_").concat(e.mediaType)).__innerSetPublished(!0)})),w={code:exports.RCRTCCode.SUCCESS},b&&(w.liveUrl=b),[2,w])}}))}))}}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var a,s,u,l,d=this;return c(this,(function(c){switch(c.label){case 0:return a=t.logger,s=t.peer,this._traceId=a.createTraceId(),this._logger=a,this._actionStartTime=Date.now(),u=this.tracks,e.validate("tracks",u,(function(){return e.isArray(u)&&u.length>0&&u.every((function(e){return e instanceof Ke||e.track instanceof Ke}))}),!0)?(this._logger.info(n.L_ABSTRACT_ROOM_PUBLISH_T,JSON.stringify({trackIds:u.map(Lt)})),(u=u.filter((function(e){var t=(e instanceof Ke?{track:e}:e).track,r=t.isDestroyed();return r&&d._logger.warn(n.L_ABSTRACT_ROOM_PUBLISH_E,"track '".concat(t.getTrackId(),"' has beem destroyed"),d._traceId),!r}))).length?(s.__reportR3R4ToPolaris(),s.clearReTryExchangeTimer(),[4,this.__publish(t,r,u,i)]):(this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PUBLISH_TRACKS_IS_INVALID,msg:"params tracks is empty"}),this._traceId),[2,{code:exports.RCRTCCode.PUBLISH_TRACKS_IS_INVALID}])):(this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> tracks"}),this._traceId),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return l=c.sent(),[4,this._dealPublishRes(l,r,t)];case 2:return[2,c.sent()]}}))}))}}),i}(yo),_a=function(t){function i(e){var r=t.call(this)||this;return Object.defineProperty(r,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),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(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return ho.UNPUBLISH},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"__unpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){return s(this,void 0,void 0,(function(){var s,u,l,d,_,p,f,h,b,R,g,m,C=this;return c(this,(function(c){switch(c.label){case 0:return s=e.peer,u=e.polarisReport,l=e.logger,d=e.reportMediaActionLogger,_=e.context,p=i.map((function(e){return e.getTrackId()})),0===p.map(t.getPublishedResourceByTrackId.bind(t)).filter((function(e){return!!e})).length?[2,{code:exports.RCRTCCode.SUCCESS,tracks:i}]:(p.forEach((function(e){return s.removeLocalTrackById(e)})),u.sendR2(ko.PUBLISH,Uo.END,p),s.clearReTryExchangeTimer(),[4,Xo(t.getSubscribedList(),!1,s,t,_)]);case 1:return f=c.sent(),(h=e.getPushOtherRooms()).length&&(f.pushOtherRooms=h),[4,new zo(f,this._traceId,!0).execute(e,t,r)];case 2:return b=c.sent(),i.forEach((function(e){var t=e.getTrackId();C._trackMediaMap[t]=b.data.qualityMsList||[]})),b.code!==exports.RCRTCCode.SUCCESS?(d.reportPubOrSubQualityData(Yo.UNPUB,this._actionStartTime,i,b.code,this._trackMediaMap),l.error(n.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:o.FAILED,code:b.code,trackIds:i.map(Lt),msg:"exchange failed"}),this._traceId),[2,{code:b.code,tracks:i}]):(R=b.data.data,g=R.resultCode,m=R.message,g!==exports.RCRTCCode.SUCCESS?(d.reportPubOrSubQualityData(Yo.UNPUB,this._actionStartTime,i,b.data.data.resultCode,this._trackMediaMap),l.error(n.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:o.FAILED,code:g,trackIds:i.map(Lt),msg:"exchange inner failed: ".concat(m)}),this._traceId),[2,{code:g,tracks:i}]):[2,a(a({code:b.code},b.data),{tracks:i})])}}))}))}}),Object.defineProperty(i.prototype,"_dealUnpublishRes",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var s,u,_,p,f,h,b,R,g,m,C,v,O,T,E,I,S,y,L,P;return c(this,(function(c){switch(c.label){case 0:return s=t.context,u=t.logger,_=t.peer,p=t.reportMediaActionLogger,f=s.getCurrentId(),h=r.roomId,b=[],[],g=i.tracks,m=i.code,C=i.data,m!==exports.RCRTCCode.SUCCESS?(u.error(n.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({code:m,msg:"unpublish failed"}),this._traceId),[2,{code:m}]):C?(v=C.mcuPublishList,O=g.map((function(e){return e.getTrackId()})),T=O.map(r.getPublishedResourceByTrackId.bind(r)).filter((function(e){return!!e})),b.push.apply(b,d([],l(T),!1)),E=v?v.map((function(e){return a({tag:e.msid.split("_").pop(),state:1},e)})):[],R=E,I=r.getResourcesByUserId(f),S=I.filter((function(e){return!b.includes(e)})),y=Date.now(),[4,s.setRTCTotalRes(h,[nt(Tt.UNPUBLISH,b)],ot(S),Tt.TOTAL_CONTENT_RESOURCE,ot(R))]):(u.info(n.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:o.SUCCESSED,msg:"unpublish list is empty "})),[2,{code:exports.RCRTCCode.SUCCESS}]);case 1:return L=c.sent(),p.reportPubOrSubQualityData(Yo.UNPUB,this._actionStartTime,g,L,this._trackMediaMap,[{dur:Date.now()-y,cod:L}]),L!==e.ErrorCode.SUCCESS?(u.error(n.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:o.FAILED,code:L,msg:"send unpublish notification failed"}),this._traceId),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(u.info(n.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:o.SUCCESSED,code:exports.RCRTCCode.SUCCESS,msg:"unpublish success",unPubResourceIds:O}),this._traceId),P=i.data.sdp,[4,_.setRemoteAnswer(P.sdp)]);case 2:return c.sent(),r.setResourcesByUserId(f,S),[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return a=t.logger,this._actionStartTime=Date.now(),s=r.crtUserId,u=this.tracks,this._traceId=a.createTraceId(),e.validate("tracks",u,(function(){return u.every((function(e){return e.getUserId()===s&&e instanceof Ke}))}),!0)?(a.info(n.L_ABSTRACT_ROOM_UNPUBLISH_T,JSON.stringify({trackIds:u.map(Lt)})),[4,this.__unpublish(t,r,i,u)]):(a.error(n.L_ABSTRACT_ROOM_UNPUBLISH_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> tracks"})),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return l=c.sent(),[4,this._dealUnpublishRes(t,r,l)];case 2:return[2,c.sent()]}}))}))}}),i}(yo),pa=function(t){function i(e){var r=t.call(this)||this;return Object.defineProperty(r,"localTrack",{enumerable:!0,configurable:!0,writable:!0,value:e}),r}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return ho.LOCAL_TRACK_MUTE},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var i,a,s,l,d,_,p,f,h,b,R,g,m,C,v,O,T,E;return c(this,(function(c){switch(c.label){case 0:i=t.logger,a=t.context,s=this.localTrack,l=s.getTrackId(),d=r.crtUserId,_=r.roomId,p=!s.isLocalMuted(),f=i.createTraceId(),i.info(n.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_T,JSON.stringify({enabled:p,trackId:this.localTrack.getTrackId()}),f),h=[{resourceId:l,enabled:p}],b=r.getResourcesByUserId(d),R=[],g=function(e){var t=lt(e),r=h.findIndex((function(e){return e.resourceId===t}));if(r>=0){var i=h[r].enabled;return e.state=i?1:0,R.push(e),"break"}};try{for(m=u(b),C=m.next();!C.done&&(v=C.value,"break"!==g(v));C=m.next());}catch(e){T={error:e}}finally{try{C&&!C.done&&(E=m.return)&&E.call(m)}finally{if(T)throw T.error}}return[4,a.setRTCTotalRes(_,[nt(Tt.MODIFY,R)],ot(b),Tt.TOTAL_CONTENT_RESOURCE)];case 1:return(O=c.sent())!==e.ErrorCode.SUCCESS?(i.error(n.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:o.FAILED,code:O,msg:"signal error"}),f),[2,{code:O}]):(i.info(n.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:o.SUCCESSED}),f),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),i}(yo),fa=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return ho.RETRY_EXCHANGE},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"priority",{get:function(){return bo.HIGH},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,o,a,s,u,l,d,_,p,f,h,b,R,g,m;return c(this,(function(c){switch(c.label){case 0:return i=e.logger,o=e.peer,a=e.context,s=i.createTraceId(),i.info(n.L_RETRY_EXCHANGE_COMMAND_T),u=a.getCurrentId(),[4,Xo(t.getSubscribedList(),!0,o,t,a)];case 1:return(l=c.sent()).pushOtherRooms=e.getPushOtherRooms(),[4,new zo(l,s).execute(e,t,r)];case 2:return(d=c.sent()).code!==exports.RCRTCCode.SUCCESS?[2,{code:d.code}]:(_=d.data.data,p=_.sdp,(f=_.resultCode)!==exports.RCRTCCode.SUCCESS?[2,{code:f}]:(o.clearReTryExchangeTimer(),[4,o.setRemoteAnswer(p.sdp)]));case 3:return(h=c.sent())!==exports.RCRTCCode.SUCCESS?[2,{code:h}]:(b=d.data.data.publishList||[],R=this._diffPublishListChange(b,t,o,u),g=R.plus,m=R.minus,g.length||m.length?[4,this._spreadPublishListUri(e,u,g,m,s)]:[3,5]);case 4:c.sent(),c.label=5;case 5:return[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),Object.defineProperty(i.prototype,"_diffPublishListChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var n=t.getResourcesByUserId(i),o=JSON.parse(JSON.stringify(n));e.forEach((function(e){var t,i=e.mediaType,n=e.msid,s=o.findIndex((function(e){var t=e.mediaType,r=e.msid;return i===t&&n===r}));if(-1===s){var c=a({tag:n.split("_").pop(),state:(null===(t=r.getLocalTrack(lt(e)))||void 0===t?void 0:t.isLocalMuted)?0:1},e);o.push(c)}else o[s].uri=e.uri}));var s=ft(n,o,!0),c=s.publishedList,u=s.unpublishedList;return t.setResourcesByUserId(i,o),{plus:c,minus:u}}}),Object.defineProperty(i.prototype,"_spreadPublishListUri",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,a,u){return s(this,void 0,void 0,(function(){var s,l,d,_;return c(this,(function(c){switch(c.label){case 0:return s=t.store,l=t.logger,d=s.getResourcesByUserId(r),l.info(n.L_RETRY_EXCHANGE_SPREAD_T,JSON.stringify({plus:i,minus:a,allPublishList:d}),u),_=[],a.length&&_.push(nt(Tt.UNPUBLISH,a)),i.length&&_.push(nt(Tt.PUBLISH,i)),[4,t.context.setRTCTotalRes(s.roomId,_,ot(d),Tt.TOTAL_CONTENT_RESOURCE)];case 1:return c.sent()===e.ErrorCode.SUCCESS?l.info(n.L_RETRY_EXCHANGE_SPREAD_R,"status: ".concat(o.SUCCESSED),u):l.error(n.L_RETRY_EXCHANGE_SPREAD_R,"status: ".concat(o.FAILED),u),[2]}}))}))}}),i}(yo);!function(e){e[e.JOIN=0]="JOIN",e[e.LEAVE=1]="LEAVE",e[e.OFFLINE=2]="OFFLINE",e[e.RESOURCECHANGE=3]="RESOURCECHANGE"}(oa||(oa={}));var ha,ba,Ra=function(t){function i(e,r,i,n){var o=t.call(this)||this;return Object.defineProperty(o,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(o,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(o,"_context",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(o,"_targetPullVersion",{enumerable:!0,configurable:!0,writable:!0,value:n}),o}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return ho.PULL_RTCROOM_STATUS},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var a,s,l,d,_,p,f,h,b,R,g,m,C,v,O,T,E,I,S,y,L,P,A;return c(this,(function(c){switch(c.label){case 0:return a=t.logger,s=r.getRoomStatusVersion(),a.info(n.L_PULL_ROOM_STATUS_T,JSON.stringify({roomId:this._roomId,localVersion:s}),this._traceId),this._targetPullVersion&&this._targetPullVersion<=s?(a.info(n.L_PULL_ROOM_STATUS_R,JSON.stringify({status:o.SUCCESSED,msg:"the roomData has been pulled",localVersion:s,targetPullVersion:this._targetPullVersion}),this._traceId),[2,{code:e.ErrorCode.SUCCESS}]):[4,this._context.pullRTCRoomStatus(this._roomId,s)];case 1:return l=c.sent(),d=l.code,_=l.data,d!==e.ErrorCode.SUCCESS?(a.info(n.L_PULL_ROOM_STATUS_R,JSON.stringify({status:o.FAILED,code:d}),this._traceId),[2,{code:d}]):(f=(p=_).bFullStatus,h=p.version,b=p.usersData,R=p.roomStatus,a.info(n.L_PULL_ROOM_STATUS_R,JSON.stringify({bFullStatus:f,version:Pt(h),usersData:b,roomStatus:R}),this._traceId),r.setRoomStatusVersion(h),f?(g=function(e){var t={users:{}},r="";return e.forEach((function(e){var i,n,o=e.userId,a=e.userData;t.users[o]={};var s=null===(i=a.filter((function(e){return"uris"===e.key}))[0])||void 0===i?void 0:i.value,c=null===(n=a.filter((function(e){return"cdn_uris"===e.key}))[0])||void 0===n?void 0:n.value;r=c||r,t.users[o]={uris:s}})),{urisData:t,CDNUris:r&&JSON.stringify(JSON.parse(r)[0])}}(b),m=g.urisData,C=g.CDNUris,[4,ia(m,r,t,i,C,this._traceId)]):[3,3]);case 2:return c.sent(),[2,{code:d}];case 3:c.trys.push([3,10,11,12]),v=u(R),O=v.next(),c.label=4;case 4:return O.done?[3,9]:(T=O.value).event!==oa.RESOURCECHANGE?[3,6]:(E=function(e){var t,r,i=e.userId,n=e.userData,o=function(e){return e.some((function(e){return"uris"===e.key||"cdn_uris"===e.key}))}(n);if(o){var a=null===(t=n.filter((function(e){return"uris"===e.key}))[0])||void 0===t?void 0:t.value,s=null===(r=n.filter((function(e){return"cdn_uris"===e.key}))[0])||void 0===r?void 0:r.value;return{userId:i,content:{uris:a?JSON.parse(a):[],cdn_uris:s&&JSON.parse(s)}}}}(T),E?(S=E.content,(I=E.userId)===r.crtUserId?[3,8]:[4,new ua(S,Tt.TOTAL_CONTENT_RESOURCE,I,this._traceId).execute(t,r,i)]):[3,8]);case 5:return c.sent(),[3,8];case 6:return S=function(e){var t,r=e.userId,i=e.userData,n=e.event,o=e.switchRoleType;return{users:[{userId:r,extra:null===(t=i.filter((function(e){return"extra"===e.key}))[0])||void 0===t?void 0:t.value,state:n,switchRoleType:o}]}}(T),[4,new ca(S,this._traceId).execute(t,r,i)];case 7:y=c.sent().data,t.emit(Ko,y),c.label=8;case 8:return O=v.next(),[3,4];case 9:return[3,12];case 10:return L=c.sent(),P={error:L},[3,12];case 11:try{O&&!O.done&&(A=v.return)&&A.call(v)}finally{if(P)throw P.error}return[7];case 12:return[2,{code:d}]}}))}))}}),i}(yo),ga=function(t){function i(e){var r=t.call(this)||this;return Object.defineProperty(r,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:e}),r}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return ho.ON_SIGNAL_RECONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"priority",{get:function(){return bo.HIGH},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var o,a,s,u,l,d;return c(this,(function(c){switch(c.label){case 0:return o=t.logger,a=t.peer,s=t.context,u=r.roomId,l=r.roomMode,d=o.createTraceId(),o.info(n.L_ABSTRACT_ROOM_IM_RECONNECTED_T,void 0,d),"closed"===a.getRTCPeerConn().connectionState?(o.error(n.L_ABSTRACT_ROOM_IM_RECONNECTED_R,"RTCPeerConnection closed. Please rejoin room to restore services",d),t.emit(xo),[2,{code:exports.RCRTCCode.SUCCESS}]):[4,s.rtcPing(u,l)];case 1:return 40001!==c.sent().code?[3,5]:[4,this._joinRoom(t,r,i,d)];case 2:return c.sent()!==e.ErrorCode.SUCCESS?[3,4]:[4,this._restoreMediaServer(t,r,i)];case 3:c.sent(),c.label=4;case 4:return[3,7];case 5:return[4,new Ra(u,d,s).execute(t,r,i)];case 6:c.sent(),c.label=7;case 7:return[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),Object.defineProperty(i.prototype,"_joinRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,a){var u;return s(this,void 0,void 0,(function(){var s,l,d,_,p,f;return c(this,(function(c){switch(c.label){case 0:return s=t.context,l=t.logger,[4,s.joinRTCRoom(r.roomId,r.roomMode,this.livingType)];case 1:return d=c.sent(),_=d.code,p=d.data,_!==e.ErrorCode.SUCCESS?(l.error(n.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:o.FAILED,code:_,msg:"im reconnect joinRTCRoom failed"}),a),[2]):p?(f=null===(u=p.roomInfo.filter((function(e){return"cdn_uris"===e.key}))[0])||void 0===u?void 0:u.value,[4,ia(p,r,t,i,f,a)]):(l.info(n.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:o.FAILED,msg:"im reconnect joinRTCRoom, roomData is empty"}),a),[2]);case 2:return c.sent(),l.info(n.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:o.SUCCESSED,roomData:p}),a),[2,_]}}))}))}}),Object.defineProperty(i.prototype,"_restoreMediaServer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n;return c(this,(function(o){switch(o.label){case 0:return i=e.peer.getLocalTracks(),n=Object.values(t.getRemoteTracks()).filter((function(e){return!!e.isSubscribed()})),i.length?[4,new da(i).execute(e,t,r)]:[3,2];case 1:o.sent(),o.label=2;case 2:return i.length||!n.length?[3,4]:[4,new la(n,!0).execute(e,t,r)];case 3:o.sent(),o.label=4;case 4:return[2]}}))}))}}),i}(yo),ma=1,Ca=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"}(ha||(ha={})),exports.RCKickReason=void 0,(ba=exports.RCKickReason||(exports.RCKickReason={}))[ba.SERVER_KICK=1]="SERVER_KICK",ba[ba.OTHER_KICK=2]="OTHER_KICK",ba[ba.IM_DISCONNECTED=3]="IM_DISCONNECTED",ba[ba.IM_LOGOUT=4]="IM_LOGOUT",ba[ba.OTHER_CLIENT_IM_CONNECTED=5]="OTHER_CLIENT_IM_CONNECTED";var va,Oa,Ta,Ea,Ia=function(){function e(e,t,r,i){var o=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: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:function(e,t,r,i){o._baseReportData=Object.assign(o._baseReportData,{snid:i});var s=a(a(a({},o._baseReportData),o._networkReportData),{cod:t,time:e,dur:Date.now()-e,rtp:r});o._logger.__statistics(n.L_QS_JOIN_ROOM_S,JSON.stringify(s))}}),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=a(a(a({},this._baseReportData),this._networkReportData),{time:Date.now(),cod:e===exports.RCKickReason.OTHER_KICK?Ca:ma});this._logger.__statistics(n.L_QS_KICKED_S,JSON.stringify(t))}}),Object.defineProperty(e.prototype,"reportPubOrSubQualityData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,o,s){var c=this;r.forEach((function(r){var u,l,d=r instanceof Ke||r instanceof tt?r:r.track,_=d.getTrackId(),p=dt(_).mediaType,f=!1;f=d instanceof Ke?!!d.isVideoTrack()&&(null===(l=(u=d).__isTiny)||void 0===l?void 0:l.call(u)):r.subTiny||!1;var h=a(a(a({},c._baseReportData),c._networkReportData),{resid:_,mtp:p,smct:f?Gn.TINY:Gn.NORMAL,stp:"Rongcloud"!==d.getTag()?1:0,cod:i,msas:o?o[_]:[],sigs:s,time:Date.now(),dur:Date.now()-t});switch(e){case"pub":c._logger.__statistics(n.L_QS_PUBLISH_S,JSON.stringify(h));break;case"unpub":c._logger.__statistics(n.L_QS_UNPUBLISH_S,JSON.stringify(h));break;case"sub":c._logger.__statistics(n.L_QS_SUBSCRIBE_S,JSON.stringify(h));break;case"unsub":c._logger.__statistics(n.L_QS_UNSUBSCRIBE_S,JSON.stringify(h))}}))}}),Object.defineProperty(e.prototype,"reportQualityRecvPubMsgData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=a(a(a({},this._baseReportData),this._networkReportData),{puid:t,time:Date.now(),dur:Date.now()-e});this._logger.__statistics(n.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=a(a(a({},this._baseReportData),this._networkReportData),{time:this._pubOrSubSuccessTime,dur:Date.now()-this._pubOrSubSuccessTime}),r="pub"===e?n.L_QS_PUB_ICE_STATUS_S:n.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 i=this._peerCStatus||{},o=i.status,s=i.time;if(s){var c=e.IP,u=e.port,l=e.networkType,d=e.remoteIP,_=e.remotePort,p=a(a(a({},this._baseReportData),this._networkReportData),{dur:r-s,time:r,pices:ha[o],ices:ha[t],rcdts:[{ip:"".concat(d,":").concat(_)}],lcdts:[{ip:"".concat(c,":").concat(u),nttp:l}],cncdts:[]});console.log(n.L_QS_ICE_STATUS_S,p),this._logger.__statistics(n.L_QS_ICE_STATUS_S,JSON.stringify(p)),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"}(va||(va={})),function(e){e[e.MeetingOrAnchor=1]="MeetingOrAnchor",e[e.Audience=2]="Audience"}(Oa||(Oa={})),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"}(Ta||(Ta={})),function(e){e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4"}(Ea||(Ea={}));var Sa,ya,La,Pa,Aa=function(){function t(e,t,r,i,n){void 0===n&&(n=Oa.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})}return Object.defineProperty(t.prototype,"_send",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return this._context.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED?[2,Ta.NOT_REPORT]:[4,this._context.setRTCState(this._roomId,t)];case 1:return r.sent()===e.ErrorCode.SUCCESS?[2,Ta.REPORT_SUCCESS]:[2,Ta.REPORT_FAIL]}}))}))}}),Object.defineProperty(t.prototype,"_getClientID",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e="uuid",t=this._runtime.localStorage.getItem(e);return t||(t=ht(),this._runtime.localStorage.setItem(e,t)),t}}),Object.defineProperty(t.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(t.prototype,"_getPolarisTrackId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t="",r=e.split("_");if(e.includes("_tiny")){var i=r.pop(),n=parseInt(r.pop())===exports.RCMediaType.AUDIO_ONLY?"audio":"video",o=r.pop();t=[r.join("_"),o,i,n].join("_")}else{n=parseInt(r.pop())===exports.RCMediaType.AUDIO_ONLY?"audio":"video",o=r.pop();t=[r.join("_"),o,n].join("_")}return t}}),Object.defineProperty(t.prototype,"_getBaseData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return{bitrateSend:(null==e?void 0:e.bitrateSend)||Hn,bitrateRecv:(null==e?void 0:e.bitrateRecv)||Hn,networkType:(null==e?void 0:e.networkType)||"unknown",rtt:(null==e?void 0:e.rtt)||Hn,localAddress:"".concat((null==e?void 0:e.IP)||Hn,":").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)||Hn,sendBand:(null==e?void 0:e.availableOutgoingBitrate)||Hn,packetsLost:(null==e?void 0:e.totalPacketsLost)||Hn,deviceId:this._context.getCurrentId()}}}),Object.defineProperty(t.prototype,"_getAudioLevel",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||0===e?e:Hn}}),Object.defineProperty(t.prototype,"_getBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||0===e?e:Hn}}),Object.defineProperty(t.prototype,"_getPacketsLostRate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||0===e?e:Hn}}),Object.defineProperty(t.prototype,"_getFrameRate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||Hn}}),Object.defineProperty(t.prototype,"_getResolution",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return e&&t?"".concat(e," * ").concat(t):"".concat(Hn)}}),Object.defineProperty(t.prototype,"_getJitter",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||Hn}}),Object.defineProperty(t.prototype,"_getNackCount",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||0===e?e:Hn}}),Object.defineProperty(t.prototype,"_getPliCount",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||0===e?e:Hn}}),Object.defineProperty(t.prototype,"_getRTT",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||Hn}}),Object.defineProperty(t.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())?va.DISABLE:va.ENABLE}}),Object.defineProperty(t.prototype,"sendR3Data",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t,r,i,n,o,a=this;return c(this,(function(s){switch(s.label){case 0:return t=e.iceCandidatePair,r=e.senders,i=this._getBaseData(t),n="R3\t".concat(i.bitrateSend,"\t-1\t-1\t-1\t").concat(i.networkType,"\t").concat(i.rtt,"\t").concat(i.localAddress,"\t").concat(i.receiveBand,"\t").concat(i.sendBand,"\t").concat(i.packetsLost,"\t").concat(i.deviceId,"\r"),o=r.map((function(e){var t=e.trackId,r=e.audioLevel,i=e.samplingRate,n=e.bitrate,o=e.packetsLostRate,s=e.frameRate,c=e.frameWidth,u=e.frameHeight,l=e.googRenderDelayMs,d=e.jitter,_=e.nackCount,p=e.pliCount,f=e.rtt,h=e.googFirsSent,b=e.encoderImplementation,R=a._getPolarisTrackId(t),g=a._getRealResourceId(t);return{trackId:R,googCodecName:b||String(Hn),audioLevel:a._getAudioLevel(r),bitrate:a._getBitrate(n),packetsLostRate:a._getPacketsLostRate(o),frameRate:a._getFrameRate(s),resolution:a._getResolution(c,u),jitter:a._getJitter(d),nackCount:a._getNackCount(_),pliCount:a._getPliCount(p),rtt:a._getRTT(f),googFirsSent:h,samplingRate:i,googRenderDelayMs:l,encoderImplementation:b||String(Hn),trackState:a._getTrackState(!0,g)}})),n+=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(n,"\r").concat(this._userRole))];case 1:return s.sent()!==Ta.REPORT_SUCCESS?[2,Ta.REPORT_FAIL]:[2,Ta.REPORT_SUCCESS]}}))}))}}),Object.defineProperty(t.prototype,"sendR4Data",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t,r,i,n,o,a=this;return c(this,(function(s){switch(s.label){case 0:return t=e.iceCandidatePair,r=e.receivers,i=this._getBaseData(t),n="R4\t".concat(i.bitrateRecv,"\t-1\t-1\t-1\t").concat(i.networkType,"\t").concat(i.rtt,"\t").concat(i.localAddress,"\t").concat(i.receiveBand,"\t").concat(i.sendBand,"\t").concat(i.packetsLost,"\t").concat(i.deviceId,"\r"),o=r.filter((function(e){return!!e.trackId})).map((function(e){var t=e.trackId,r=e.audioLevel,i=e.samplingRate,n=e.bitrate,o=e.packetsLostRate,s=e.frameRate,c=e.frameWidth,u=e.frameHeight,l=e.googRenderDelayMs,d=e.jitter,_=e.nackCount,p=e.pliCount,f=e.rtt,h=e.googFirsReceived,b=e.codecImplementationName,R=a._getPolarisTrackId(t),g=a._getRealResourceId(t);return{trackId:R,googCodecName:b||String(Hn),audioLevel:a._getAudioLevel(r),bitrate:a._getBitrate(n),packetsLostRate:a._getPacketsLostRate(o),frameRate:a._getFrameRate(s),resolution:a._getResolution(c,u),jitter:a._getJitter(d),nackCount:a._getNackCount(_),pliCount:a._getPliCount(p),rtt:a._getRTT(f),googFirsReceived:h,samplingRate:i,googRenderDelayMs:l,codecImplementationName:b||String(Hn),trackState:a._getTrackState(!1,g)}})),n+=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(n,"\r").concat(this._userRole))];case 1:return s.sent()!==Ta.REPORT_SUCCESS?[2,Ta.REPORT_FAIL]:[2,Ta.REPORT_SUCCESS]}}))}))}}),Object.defineProperty(t.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,i=Ct.browser,n=Ct.version,o=this._getClientID(),a="R1\t".concat("5.32.0-c-im-alpha.2","\t").concat(t,"\t").concat("web","\t").concat(r,"\t").concat(-1,"\t").concat(i,"\t").concat(n,"\t").concat(o,"\t").concat(this._userRole);this._send(a)}}),Object.defineProperty(t.prototype,"sendR2",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=this._getClientID(),n="R2\t".concat(e,"\t").concat(t,"\t").concat(i,"\r").concat(r.join("\t"),"\r").concat(this._userRole);this._send(n)}}),t}(),Na=function(e){function t(t,r){var i=e.call(this)||this;return Object.defineProperty(i,"oldTrack",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"newTrack",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return r(t,e),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,o,a,s,u,l,d,_,p,f,h,b=this;return c(this,(function(c){switch(c.label){case 0:return i=e.peer,o=e.logger,this.oldTrack&&this.newTrack?[Xe,Ze].every((function(e){return!(b.oldTrack instanceof e)}))?(o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack is not RCCameraVideoTrack or RCMicphoneAudioTrack"),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):[Xe,Ze].every((function(e){return!(b.newTrack instanceof e)}))?(o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"newTrack is not RCCameraVideoTrack or RCMicphoneAudioTrack"),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(a=this.oldTrack.getSettings(),s=this.newTrack.getSettings(),u=this.oldTrack.getTrackId(),l=this.newTrack.getTrackId(),d=this.oldTrack.isAudioTrack()?"audio":"video",_=this.newTrack.isAudioTrack()?"audio":"video",o.info(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_T,JSON.stringify({oldTrackId:u,newTrackId:l,oldSettings:a,newSettings:s})),this.oldTrack.isPublished()?u!==l?(o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack and newTrack trackId are different, oldTrackId: ".concat(u,", newTrackId: ").concat(l)),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):d!==_?(o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack and newTrack are not the same kind, oldTrackKind: ".concat(d,", newTrackKind: ").concat(_)),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(null==a?void 0:a.deviceId)===(null==s?void 0:s.deviceId)?(o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack and newTrack deviceId are the same, oldDeviceId: ".concat(null==a?void 0:a.deviceId,", newDeviceId: ").concat(null==s?void 0:s.deviceId)),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(i.addLocalTrack(this.newTrack),p=(null==a?void 0:a.width)!==(null==s?void 0:s.width)||(null==a?void 0:a.height)!==(null==s?void 0:s.height)||(null==a?void 0:a.frameRate)!==(null==s?void 0:s.frameRate),f=i.getLocalTrack("".concat(this.oldTrack.getTrackId(),"_tiny")),p?[4,(new fa).execute(e,t,r)]:(f&&f.destroy(),this.oldTrack.destroy(!1),this.newTrack.__innerSetPublished(!0),o.info(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"changeMediaDevice success"),[2,{code:exports.RCRTCCode.SUCCESS}])):(o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack is not published"),[2,{code:exports.RCRTCCode.PARAMS_ERROR}])):(o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack or newTrack is empty"),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return(h=c.sent()).code!==exports.RCRTCCode.SUCCESS?(i.removeLocalTrack(this.newTrack,!1),i.addLocalTrack(this.oldTrack),this.newTrack.destroy(),o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"negotiation failed, code: ".concat(h.code)),[2,{code:h.code}]):(f&&f.destroy(),this.oldTrack.destroy(!1),this.newTrack.__innerSetPublished(!0),o.info(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"changeMediaDevice success"),[2,{code:h.code}])}}))}))}}),t}(yo),wa="evt-leave",Da=function(t){function i(e,r,i,o,a,u,l,d,_,p){void 0===_&&(_=Kn()),void 0===p&&(p=!1);var f=t.call(this)||this;Object.defineProperty(f,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(f,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(f,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(f,"_service",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(f,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:u}),Object.defineProperty(f,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(f,"_pinger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_audioLevelReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_peerConnection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_executeCtx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(f,"_onRecvPKMsg",{enumerable:!0,configurable:!0,writable:!0,value:null});var h=f._logger=f._context.logger;f._reportMediaActionLogger=new Ia(h,f._roomId,f._clientSessionId,f._context.getCurrentId()),f._polarisReport=new Aa(f._context,f._runtime,f._roomId,f);var b=f._context.getCurrentId(),R=new Ao(h,_,f._context.getAppkey(),i,b,o,l,d),g=f._peerConnection=new Eo(h,f._reTryExchange.bind(f),b,R,f._polarisReport,!1,p);f._setPeerConnectionListener();var m=f._executeCtx=new Wo(h,f._service,e,r,g,R,f._polarisReport,f._reportMediaActionLogger);return m.getPushOtherRooms=function(){return f._getPushOtherRoomsParams()},f.setCommandEventListener(),f._invoker=new Po(m,R),f._store=f._invoker.store,f._audioLevelReport=new Io(f._store,g),g.on(Eo.__INNER_AUDIOLEVEL_CHANGE__,f._audioLevelReport.audioLevelReport,f._audioLevelReport),f._pinger=new At(f._context,f._roomId,o,f._initOptions.pingGap),f._pinger.onFailed=f.__kickoff.bind(f),f._pinger.onPingResult=f._handlePingResult.bind(f),f._context.registerRTCSignalListener((function(e){return s(f,void 0,void 0,(function(){var t,r,i,o,a;return c(this,(function(s){return t=this._context.decodeRtcNotify(e),r=t.time,i=t.type,o=t.roomId,this._invoker.isDestroyed()?(this._logger.info(n.L_RTCNTF_PULL_ROOM_STATUS_O,JSON.stringify({isDestroyed:!0,type:i,time:r,roomId:o})),[2]):(2===i&&o===this._roomId&&(a=this._logger.createTraceId(),this._logger.info(n.L_RTCNTF_PULL_ROOM_STATUS_O,null,a),this._startPullRTCRoomStatus(o,a,r)),[2])}))}))})),f}return r(i,t),Object.defineProperty(i.prototype,"_setPeerConnectionListener",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=this._peerConnection;t.on(Eo.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),t.on(Ke.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),t.on(Ke.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),t.once(Eo.__INNER_ICE_CONNECTED__,(function(t){e._reportMediaActionLogger.reportIceFirstConnectData(t?"pub":"sub")}),this),t.on(Eo.__INNER_ICE_STATE_CHANGE__,(function(t){var r=t.status,i=t.time,n=t.iceCandidatePair;e._reportMediaActionLogger.recordQualityIceStatusData(n,r,i)}))}}),Object.defineProperty(i.prototype,"setCommandEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._executeCtx;e.on(xo,this._rtcpeerClosed,this),e.on(jo,this._callAppListener.bind(this,"onUserJoin"),this),e.on(Bo,this._callAppListener.bind(this,"onUserLeave"),this),e.on(Vo,this._onTrackPublish,this),e.on(Fo,this._onTrackUnpublish,this),e.on(Jo,this._onAudioMuteChange,this),e.on(Go,this._onVideoMuteChange,this),e.on(Ho,this._callAppListener.bind(this,"onCDNEnableChange"),this),e.on(Ko,this._dealUserAppListener,this)}}),Object.defineProperty(i.prototype,"_startPullRTCRoomStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){return c(this,(function(i){switch(i.label){case 0:return[4,this._invoker.push(new Ra(e,t,this._context,r))];case 1:return i.sent(),[2]}}))}))}}),Object.defineProperty(i.prototype,"__innerInit",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n,o){return s(this,void 0,void 0,(function(){var a,s,u;return c(this,(function(c){switch(c.label){case 0:return[4,this._invoker.push(new Do(this._roomId,e,t,r,i,n,o))];case 1:return a=c.sent(),s=a.code,u=a.data,s!==exports.RCRTCCode.SUCCESS?[2,{code:s}]:(this._initWithRoomData(u.offlineKickTime),[2,{code:s,data:u}])}}))}))}}),Object.defineProperty(i.prototype,"_initWithRoomData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._pinger.start(1e3*e),this._polarisReport.sendR1()}}),Object.defineProperty(i.prototype,"_handlePingResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(e===exports.RCRTCPingResult.SUCCESS&&(t>this._store.getRoomStatusVersion()&&this._store.getSupportNtf())){var r=this._logger.createTraceId();this._logger.info(n.L_RTCPING_PULL_ROOM_STATUS_O,JSON.stringify({dataVersion:t}),r),this._startPullRTCRoomStatus(this._roomId,r,t)}this._callAppListener("onPing",e)}}),Object.defineProperty(i.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){this._logger.warn(n.L_ABSTRACT_ROOM_SETBITRATE_O,"`RCAbstractRoom.setBitrate` will be deprecated, use `RCLocalTrack.setBitrate` instead."),e.assert("max",t,(function(t){return e.isNumber(t)&&t>Math.max(r||1,200)}),!0),e.assert("min",r,(function(r){return e.isNumber(r)&&r>=1&&(!e.isNumber(t)||r<t)}),!0),e.assert("start",i,(function(i){return e.isNumber(i)&&i>r&&i<=t})),this._peerConnection.setBitrate(t,r,i)}}),Object.defineProperty(i.prototype,"_onTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.streams[0].id,r=e.receiver.track,i=[t,"audio"===r.kind?exports.RCMediaType.AUDIO_ONLY:exports.RCMediaType.VIDEO_ONLY].join("_"),a=this._store.getRemoteTrack(i);a?(a.__innerSetMediaStreamTrack(r),this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onTrackReady",trackId:a.getTrackId()})),this._callAppListener("onTrackReady",a)):this._logger.warn(n.L_ABSTRACT_ROOM_ONTRACKREADY_O,"cannot found remote track ".concat(r.id))}}),Object.defineProperty(i.prototype,"_callAppListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var o=null===(t=this._appListener)||void 0===t?void 0:t[e];if(o)try{o.apply(void 0,d([],l(r),!1))}catch(e){this._logger.error(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}}),Object.defineProperty(i.prototype,"_onTrackUnpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onTrackUnpublish",trackIds:null==e?void 0:e.map((function(e){return e.getTrackId()}))})),this._callAppListener("onTrackUnpublish",e)}}),Object.defineProperty(i.prototype,"__parseInnerMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.targetId;if(r===this._roomId){this._logger.info(n.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,"recv inner msg -> message: ".concat(JSON.stringify(e)," | roomid: ").concat(this._roomId),t);var i=e.content;switch(e.messageType){case Tt.KICK:this.__kickoff(!0,i);break;case Tt.STATE:this._stateHandle(i,t);break;case Tt.MODIFY:case Tt.PUBLISH:case Tt.UNPUBLISH:case Tt.TOTAL_CONTENT_RESOURCE:this._resourceHandle(i,e.messageType,e.senderUserId,e.sentTime,t);break;case Tt.ROOM_NOTIFY:this._logger.info(n.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 Tt.USER_NOTIFY:this._logger.warn(n.L_OLD_DAILY_RECORD_O,"TODO: ".concat(Tt.USER_NOTIFY));break;case Tt.PK_INVITE:case Tt.PK_CANCEL_INVITE:case Tt.PK_INVITE_TIMEOUT:case Tt.PK_INVITE_ANSWER:case Tt.PK_END:this._onRecvPKMsg&&this._onRecvPKMsg(e);break;case Tt.OTHER_ROOM_OFFLINE:break;default:this._logger.info(n.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)}}else this._logger.warn(n.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,JSON.stringify({status:o.FAILED,message:"roomId is different, msg roomId-> ".concat(r,", this._roomId-> ").concat(this._roomId," ")}),t)}}),Object.defineProperty(i.prototype,"__kickoff",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,a=this;return c(this,(function(s){return this._invoker.isDestroyed()||(this._logger.warn(n.L_ABSTRACT_ROOM_ONKICKOFF_O,"onKickOff -> byServer: ".concat(e,", kickContent: ").concat(JSON.stringify(t))),this.emit(wa),this._leaveHandle(!e),e&&((null==t?void 0:t.users)||[]).forEach((function(e){e.userId===a._context.getCurrentId()&&(i=e.type,r=e.kickExtra,a._reportMediaActionLogger.reportQualityKickedData(i))})),this._logger.info(n.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)),[2]}))}))}}),Object.defineProperty(i.prototype,"_rtcpeerClosed",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.emit(wa),this._leaveHandle(!0),this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,"onRTCPeerConnectionCloseByException"),this._callAppListener("onRTCPeerConnectionCloseByException")}}),Object.defineProperty(i.prototype,"_resourceHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n){return s(this,void 0,void 0,(function(){var o;return c(this,(function(a){return o=e.uris,e.ignore||!o||this._invoker.push(new ua(e,t,r,n,i)),[2]}))}))}}),Object.defineProperty(i.prototype,"_onTrackPublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onTrackPublish",trackIds:null==e?void 0:e.map((function(e){return e.getTrackId()}))})),this._callAppListener("onTrackPublish",e)}}),Object.defineProperty(i.prototype,"_stateHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i;return c(this,(function(n){switch(n.label){case 0:return[4,this._invoker.push(new ca(e,t))];case 1:return r=n.sent(),i=r.data,this._dealUserAppListener(i),[2]}}))}))}}),Object.defineProperty(i.prototype,"_dealUserAppListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,i=this,a=e.left,s=e.joined,c=e.upgrade,u=e.downgrade,_=e.offline,p=d([],l(s),!1),f=d([],l(a),!1);(null===(t=this._appListener)||void 0===t?void 0:t.onSwitchRole)?(null==c||c.forEach((function(e){i._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onSwitchRole",userId:e,role:exports.RCRTCLiveRole.ANCHOR})),i._callAppListener("onSwitchRole",e,exports.RCRTCLiveRole.ANCHOR)})),null==u||u.forEach((function(e){i._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onSwitchRole",userId:e,role:exports.RCRTCLiveRole.AUDIENCE})),i._callAppListener("onSwitchRole",e,exports.RCRTCLiveRole.AUDIENCE)}))):(p.push.apply(p,d([],l(c),!1)),f.push.apply(f,d([],l(u),!1))),_.length&&((null===(r=this._appListener)||void 0===r?void 0:r.onUserOffline)?(this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onUserOffline",offline:_})),this._callAppListener("onUserOffline",_)):f.push.apply(f,d([],l(_),!1))),p.length>0&&(this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onUserJoin",allJoined:p})),this._callAppListener("onUserJoin",p)),f.length>0&&(this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onUserLeave",allLeft:f})),this._callAppListener("onUserLeave",f))}}),Object.defineProperty(i.prototype,"getRoomId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._roomId}}),Object.defineProperty(i.prototype,"getCrtUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._context.getCurrentId()}}),Object.defineProperty(i.prototype,"getRemoteUserIds",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.getRemoteUserIds()}}),Object.defineProperty(i.prototype,"getRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=[];return this.getRemoteUserIds().forEach((function(r){t.push.apply(t,d([],l(e.getRemoteTracksByUserId(r)),!1))})),t}}),Object.defineProperty(i.prototype,"getRemoteTracksByUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._store.getRemoteTracksByUserId(e)}}),Object.defineProperty(i.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.getSessionId()}}),Object.defineProperty(i.prototype,"sendMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return s(this,void 0,void 0,(function(){var i,a;return c(this,(function(s){switch(s.label){case 0:return i=this._logger.createTraceId(),this._logger.info(n.L_ABSTRACT_ROOM_SEND_MESSAGE_T,JSON.stringify({name:t,content:r}),i),[4,this._context.sendMessage(e.ConversationType.RTC_ROOM,this._roomId,{messageType:t,content:r,isStatusMessage:!0})];case 1:return(a=s.sent().code)!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:o.FAILED,code:a}),i),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(this._logger.info(n.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:o.SUCCESSED,name:t,content:r}),i),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),Object.defineProperty(i.prototype,"setRoomAttribute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,a){return void 0===a&&(a=!1),s(this,void 0,void 0,(function(){var s,u;return c(this,(function(c){switch(c.label){case 0:return s=this._logger.createTraceId(),this._logger.info(n.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,key:t,value:r,message:i,isInner:a}),s),[4,this._context.setRTCData(this._roomId,t,r,a,wo.ROOM,i)];case 1:return(u=c.sent())!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:o.FAILED,code:u}),s),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(this._logger.info(n.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:o.SUCCESSED,roomId:this._roomId,key:t,value:r,message:i,isInner:a}),s),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),Object.defineProperty(i.prototype,"deleteRoomAttributes",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return void 0===i&&(i=!1),s(this,void 0,void 0,(function(){var a,s;return c(this,(function(c){switch(c.label){case 0:return a=this._logger.createTraceId(),this._logger.info(n.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:t,message:r,isInner:i}),a),[4,this._context.removeRTCData(this._roomId,t,i,wo.ROOM,r)];case 1:return(s=c.sent())!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:o.FAILED,code:s}),a),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(this._logger.info(n.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:o.SUCCESSED,roomId:this._roomId,keys:t,message:r,isInner:i}),a),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),Object.defineProperty(i.prototype,"getRoomAttributes",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return void 0===t&&(t=[]),void 0===r&&(r=!1),s(this,void 0,void 0,(function(){var i,a,s,u;return c(this,(function(c){switch(c.label){case 0:return i=this._logger.createTraceId(),this._logger.info(n.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:t,isInner:r}),i),[4,this._context.getRTCData(this._roomId,t,r,wo.ROOM)];case 1:return a=c.sent(),s=a.code,u=a.data,s!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_R,"GetRoomAttributes Failed: ".concat(s),i),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(this._logger.info(n.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:o.SUCCESSED,data:u}),i),[2,{code:exports.RCRTCCode.SUCCESS,data:u}])}}))}))}}),Object.defineProperty(i.prototype,"_setUserAttributeValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return this._context.setRTCData(this._roomId,e,t,!1,wo.PERSON,r)}}),Object.defineProperty(i.prototype,"_deleteUserAttributes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._context.removeRTCData(this._roomId,e,!1,wo.PERSON,t)}}),Object.defineProperty(i.prototype,"_getUserAttributes",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._context.getRTCData(this._roomId,e,!1,wo.PERSON)}}),Object.defineProperty(i.prototype,"isDestroyed",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._invoker.isDestroyed()}}),Object.defineProperty(i.prototype,"__destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._leaveHandle(e)}}),Object.defineProperty(i.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(i.prototype,"_leaveHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(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(i.prototype,"_releasePCManager",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._peerConnection;e.removeAllLocalTrack(),e.destroy()}}),Object.defineProperty(i.prototype,"_onLocalTrackDestroied",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e instanceof Ye&&e.__isTiny()||this.unpublish([e])}}),Object.defineProperty(i.prototype,"_onLocalTrackMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r;return c(this,(function(i){switch(i.label){case 0:return[4,this._invoker.push(new pa(e))];case 1:return r=i.sent().code,t(r),[2]}}))}))}}),Object.defineProperty(i.prototype,"publish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this._invoker.push(new da(e))]}))}))}}),Object.defineProperty(i.prototype,"_getPushOtherRoomsParams",{enumerable:!1,configurable:!0,writable:!0,value:function(){return[]}}),Object.defineProperty(i.prototype,"_reTryExchange",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._invoker.push(new fa)}}),Object.defineProperty(i.prototype,"unpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this._invoker.push(new _a(e))]}))}))}}),Object.defineProperty(i.prototype,"_isValidResourceId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=dt(e).userId;return!!(null===(t=this._store.getResourcesByUserId(r))||void 0===t?void 0:t.find((function(t){return lt(t)===e})))}}),Object.defineProperty(i.prototype,"subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this._invoker.push(new la(e,void 0,void 0))]}))}))}}),Object.defineProperty(i.prototype,"unsubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){return t=this._logger.createTraceId(),this._logger.info(n.L_APP_CALL_UNSUBSCRIBE_O,void 0,t),[2,this._invoker.push(new Qo(e,t))]}))}))}}),Object.defineProperty(i.prototype,"updateSubList",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this._invoker.push(new qo(e,!0,this._logger.createTraceId()))]}))}))}}),Object.defineProperty(i.prototype,"getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._peerConnection.getLocalTrack(e)}}),Object.defineProperty(i.prototype,"getLocalTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._peerConnection.getLocalTracks()}}),Object.defineProperty(i.prototype,"getRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._store.getRemoteTrack(e)||null}}),Object.defineProperty(i.prototype,"subscribedTracks",{get:function(){return this._store.getSubscribedList().slice()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"registerRoomEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(n.L_ABSTRACT_ROOM_REGISTER_ROOM_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._appListener=e}}),Object.defineProperty(i.prototype,"registerReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(n.L_ABSTRACT_ROOM_REGISTER_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._peerConnection.registerReportListener(e)}}),Object.defineProperty(i.prototype,"onAudioLevelChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(n.L_ABSTRACT_ROOM_AUDIO_LEVEL_O),this._audioLevelReport.onAudioLevelChange(e)}}),Object.defineProperty(i.prototype,"__onReconnected",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._invoker.push(new ga(e))}}),Object.defineProperty(i.prototype,"_onAudioMuteChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onAudioMuteChange",trackId:e.getTrackId()})),this._callAppListener("onAudioMuteChange",e)}}),Object.defineProperty(i.prototype,"_onVideoMuteChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onVideoMuteChange",trackId:e.getTrackId()})),this._callAppListener("onVideoMuteChange",e)}}),Object.defineProperty(i.prototype,"_registerPKMsgListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._onRecvPKMsg=e}}),Object.defineProperty(i.prototype,"_quitAllPKRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){return c(this,(function(e){return[2]}))}))}}),Object.defineProperty(i.prototype,"getClientSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.clientSessionId}}),Object.defineProperty(i.prototype,"changeMediaDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){return c(this,(function(r){return[2,this._invoker.push(new Na(e,t))]}))}))}}),i}(e.EventEmitter),ka=function(e){function t(t,r){var i=e.call(this)||this;return Object.defineProperty(i,"data",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"cdnValues",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return r(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return ho.MCUCONFIG_FLUSH},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i,n,o,a;return s(this,void 0,void 0,(function(){var r,s,u,l,d,_,p;return c(this,(function(c){switch(c.label){case 0:return r=e.context,s=e.service,u={"App-Key":r.getAppkey(),Token:t.getToken(),RoomId:t.roomId,UserId:r.getCurrentId(),SessionId:t.getSessionId()},[4,s.setMcuConfig(u,this.data)];case 1:return l=c.sent(),d=l.code,_=l.res,d!==exports.RCRTCCode.SUCCESS?[2,{code:d}]:(_.pull_url&&t.setCDNUris(JSON.parse(_.pull_url)),p=this.cdnValues,d===exports.RCRTCCode.SUCCESS&&((null===(n=null===(i=p.output)||void 0===i?void 0:i.video.normal)||void 0===n?void 0:n.width)||(null===(a=null===(o=p.output)||void 0===o?void 0:o.video.normal)||void 0===a?void 0:a.fps))&&ta(r,t),[2,{code:d,data:_}])}}))}))}}),t}(yo);exports.BackgroundPictureFillMode=void 0,(Sa=exports.BackgroundPictureFillMode||(exports.BackgroundPictureFillMode={}))[Sa.CROP=1]="CROP",Sa[Sa.WHOLE=2]="WHOLE",exports.MixLayoutMode=void 0,(ya=exports.MixLayoutMode||(exports.MixLayoutMode={}))[ya.CUSTOMIZE=1]="CUSTOMIZE",ya[ya.SUSPENSION=2]="SUSPENSION",ya[ya.ADAPTATION=3]="ADAPTATION",exports.MixVideoRenderMode=void 0,(La=exports.MixVideoRenderMode||(exports.MixVideoRenderMode={}))[La.CROP=1]="CROP",La[La.WHOLE=2]="WHOLE",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"}(Pa||(Pa={}));var Ua,Ma=function(){return{version:2,mode:exports.MixLayoutMode.SUSPENSION}},xa=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:Ma()}),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(n.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,msg:"videoTrackId: ".concat(e," is invalid")})),this;var t=dt(e),r=t.mediaType,i=t.tag,a=t.userId;return r!==exports.RCMediaType.VIDEO_ONLY?(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,msg:"kind of ".concat(e," is not video")})),this):(this._values.host_stream_id=_t(a,i),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:o.SUCCESSED,videoTrackId:e})),this)}}),Object.defineProperty(t.prototype,"setMixLayoutMode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return[exports.MixLayoutMode.CUSTOMIZE,exports.MixLayoutMode.SUSPENSION,exports.MixLayoutMode.ADAPTATION].includes(e)?(this._values.mode=e,this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:o.SUCCESSED,mode:e})),this):(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:o.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 i=this._values.output||(this._values.output={video:{normal:{width:640,height:480}}});if("cdn"!==e)if("audio"!==e){var n=i.video;if("normal"!==r&&"tiny"!==r)if("backgroundColor"!==r)if("exparams"!==r){if("backgroundPicture"===r){var o=n.backgroundPicture||(n.backgroundPicture={fillMode:exports.BackgroundPictureFillMode.CROP,picture:[]});Object.assign(o,t)}}else n.exparams={renderMode:t};else n.backgroundColor=t;else{var a=n[r]||(n[r]={});Object.assign(a,t)}}else i.audio={bitrate:t};else i.cdn=t}}),Object.defineProperty(t.prototype,"setOutputVideoResolution",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!Rt(e))return this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:o.FAILED,msg:"params error -> resolution: ".concat(e)})),this;var t=bt(e),r=t.width,i=t.height;return this._addOutputValue("video",{width:r,height:i},"normal"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:o.SUCCESSED,resolution:e})),this}}),Object.defineProperty(t.prototype,"setOutputVideoFPS",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!gt(e))return this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:o.FAILED,msg:"params error -> fps: ".concat(e)})),this;var t=mt(e);return this._addOutputValue("video",{fps:t},"normal"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:o.SUCCESSED,fps:e})),this}}),Object.defineProperty(t.prototype,"setOutputVideoBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return!e.isNumber(t)||t<=0?(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:o.FAILED,msg:"params error -> bitrate: ".concat(t)})),this):(this._addOutputValue("video",{bitrate:t},"normal"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:o.SUCCESSED,bitrate:t})),this)}}),Object.defineProperty(t.prototype,"setOutputTinyVideoResolution",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!Rt(e))return this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:o.FAILED,msg:"params error -> resolution: ".concat(e)})),this;var t=bt(e),r=t.width,i=t.height;return this._addOutputValue("video",{width:r,height:i},"tiny"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:o.SUCCESSED,resolution:e})),this}}),Object.defineProperty(t.prototype,"setOutputTinyVideoFPS",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!gt(e))return this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:o.FAILED,msg:"params error -> fps: ".concat(e)})),this;var t=mt(e);return this._addOutputValue("video",{fps:t},"tiny"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:o.SUCCESSED,fps:e})),this}}),Object.defineProperty(t.prototype,"setOutputTinyVideoBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return!e.isNumber(t)||t<=0?(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:o.FAILED,msg:"params error -> bitrate: ".concat(t)})),this):(this._addOutputValue("video",{bitrate:t},"tiny"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:o.SUCCESSED,bitrate:t})),this)}}),Object.defineProperty(t.prototype,"setOutputVideoRenderMode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return[exports.MixVideoRenderMode.CROP,exports.MixVideoRenderMode.WHOLE].includes(e)?(this._addOutputValue("video",e,"exparams"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:o.SUCCESSED,renderMode:e})),this):(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:o.FAILED,msg:"params error -> renderMode: ".concat(e)})),this)}}),Object.defineProperty(t.prototype,"setOutputAudioBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.isNumber(t)&&t>0?(this._addOutputValue("audio",t),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:o.SUCCESSED,bitrate:t})),this):(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:o.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(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:o.SUCCESSED,color:e})),this):(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:o.FAILED,msg:"params error -> color: ".concat(e)})),this)}}),Object.defineProperty(t.prototype,"addOutputBackgroundPicture",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,a,s){var c,u,l;if(!e.isHttpUrl(t))return this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:o.FAILED,msg:"params error -> uri: ".concat(t)})),this;if([r,i,a,s].some((function(t){return!e.isNumber(t)||t<0||t>1})))return this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:o.FAILED,msg:"params of (x, y, w, h) error -> x: ".concat(r,", y: ").concat(i,", w: ").concat(a,", h: ").concat(s)})),this;var d=(null===(l=null===(u=null===(c=this._values.output)||void 0===c?void 0:c.video)||void 0===u?void 0:u.backgroundPicture)||void 0===l?void 0:l.picture)||[];return d.push({uri:t,w:a,h:s,x:r,y:i}),this._addOutputValue("video",{picture:d},"backgroundPicture"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:o.SUCCESSED,uri:t,x:r,y:i,w:a,h:s})),this}}),Object.defineProperty(t.prototype,"removeOutputBackgroundPicture",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r,i,a;if(!e.isHttpUrl(t))return this._logger.error(n.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:o.FAILED,msg:"params error -> uri: ".concat(t)})),this;var s=null===(a=null===(i=null===(r=this._values.output)||void 0===r?void 0:r.video)||void 0===i?void 0:i.backgroundPicture)||void 0===a?void 0:a.picture;return s&&(s=s.filter((function(e){return e.uri!==t})),this._addOutputValue("video",{pictures:s},"backgroundPicture")),this._logger.info(n.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:o.SUCCESSED,uri:t})),this}}),Object.defineProperty(t.prototype,"clearOutputBackgroundPicture",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._addOutputValue("video",{pictures:[]},"backgroundPicture"),this._logger.info(n.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[exports.BackgroundPictureFillMode.CROP,exports.BackgroundPictureFillMode.WHOLE].includes(e)?(this._addOutputValue("video",{fillMode:e},"backgroundPicture"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:o.SUCCESSED,fillMode:e})),this):(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:o.FAILED,msg:"params error -> fillMode: ".concat(e)})),this)}}),Object.defineProperty(t.prototype,"addPublishStreamUrls",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r,i,a=/^rtmp:\/\/.+/;if(!e.isArray(t)||0===t.length||t.some((function(e){return!a.test(e)})))return this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:o.FAILED,msg:"params error -> urls: ".concat(t.join(","))})),this;var s=(null===(i=null===(r=this._values.output)||void 0===r?void 0:r.cdn)||void 0===i?void 0:i.concat())||[],c=!1;return t.forEach((function(e){s.some((function(t){return t.pushurl===e}))||(c=!0,s.push({pushurl:e}))})),s.length>5?(this._logger.error(n.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: ".concat(t.length)})),this):(c&&this._addOutputValue("cdn",s),this._logger.info(n.L_MCU_CONFIG_BUILDER_ADD_PUBLISH_STREAM_URLS_O,JSON.stringify({status:o.SUCCESSED,urls:t})),this)}}),Object.defineProperty(t.prototype,"removePublishStreamUrls",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r,i,a=/^rtmp:\/\/.+/;if(!e.isArray(t)||0===t.length||t.some((function(e){return!a.test(e)})))return this._logger.error(n.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:o.FAILED,msg:"params error -> urls: ".concat(t.join(","))})),this;for(var s=(null===(i=null===(r=this._values.output)||void 0===r?void 0:r.cdn)||void 0===i?void 0:i.concat())||[],c=s.length-1;c>=0;c-=1){var u=s[c].pushurl,l=t.indexOf(u);l>=0&&(t.splice(l,1),s.splice(c,1))}return this._addOutputValue("cdn",s),this._logger.info(n.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:o.SUCCESSED,urls:t})),this}}),Object.defineProperty(t.prototype,"clearPublishStreamUrls",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._addOutputValue("cdn",[]),this._logger.info(n.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,i,a,s){if(!e.notEmptyString(t)||!this._isValidTrackId(t))return this._logger.error(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.FAILED,msg:"params error -> trackId: ".concat(t)})),this;if(!e.isNumber(r)||!e.isNumber(i))return this._logger.error(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.FAILED,msg:"params x or y is error -> x: ".concat(r,", y: ").concat(i)})),this;if([a,s].some((function(t){return!e.isNumber(t)||t<0})))return this._logger.error(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.FAILED,msg:"params width or height error -> width: ".concat(a,", height: ").concat(s)})),this;var c=dt(t),u=c.userId,l=c.tag;if(c.mediaType!==exports.RCMediaType.VIDEO_ONLY)return this._logger.error(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.FAILED,msg:"type of trackId: ".concat(t," is not video")})),this;var d=_t(u,l),_=this._values.input||(this._values.input={}),p=_.video||(_.video=[]);return p.some((function(e){return e.height===s&&e.width===a&&e.stream_id===d&&e.user_id===u&&e.x===r&&e.y===i}))?(this._logger.warn(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.FAILED,msg:"Duplicate configuration item place ignored"})),this):(p.push({user_id:u,stream_id:d,x:r,y:i,width:a,height:s}),this._logger.info(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.SUCCESSED,trackId:t,x:r,y:i,width:a,height:s})),this)}}),Object.defineProperty(t.prototype,"removeCustomizeLayoutVideo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._isValidTrackId(e))return this._logger.error(n.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.FAILED,msg:"params error -> trackId: ".concat(e)})),this;var t=dt(e),r=t.userId,i=t.tag;if(t.mediaType!==exports.RCMediaType.VIDEO_ONLY)return this._logger.error(n.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.FAILED,msg:"type of trackId: ".concat(e," is not video")})),this;var a=_t(r,i),s=this._values.input;return(null==s?void 0:s.video)&&s.video.length>0&&(s.video=s.video.filter((function(e){return e.stream_id===a}))),this._logger.info(n.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.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(n.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(n.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.FAILED,msg:"trackIds contain invalid item -> trackIds: ".concat(e.join(","))})),this):((this._values.input||(this._values.input={})).audio=e.map((function(e){var t=dt(e),r=t.userId,i=t.tag;return{stream_id:_t(r,i),user_id:r}})),this._values.inputFilterMode=Pa.AUDIO_INPUT_VIDEO_ALL,this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.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(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.FAILED,msg:"params error -> trackId: ".concat(e)})),this;var t=this._values.input||(this._values.input={}),r=t.audio||(t.audio=[]),i=dt(e),a=i.userId,s=i.tag,c=_t(a,s);return r.some((function(e){return e.stream_id===c&&e.user_id===a}))?(this._logger.warn(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.FAILED,msg:"trackId: ".concat(e," is exist")})),this):(r.push({user_id:a,stream_id:c}),this._values.inputFilterMode=Pa.AUDIO_INPUT_VIDEO_ALL,this._logger.info(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.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(n.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.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(n.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.FAILED,msg:"type of trackId: ".concat(e," is not audio")})),this;var r=dt(e),i=r.userId,a=r.tag,s=_t(i,a);return t.audio=t.audio.filter((function(e){return i!==e.user_id||s!==e.stream_id})),this._logger.info(n.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.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=Pa.AUDIO_VIDEO_ALL,this._logger.info(n.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,i,a,s,c){if(!this._isValidTrackId(t))return this._logger.error(n.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:o.FAILED,msg:"params error -> trackId: ".concat(t)})),this;if(!e.isHttpUrl(r))return this._logger.error(n.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:o.FAILED,msg:"params error -> uri: ".concat(r)})),this;if([i,a,s,c].some((function(t){return!e.isNumber(t)||t<0||t>1}))||i+s>1||a+c>1)return this._logger.error(n.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: ".concat(i,", y: ").concat(a,", w: ").concat(s,", h: ").concat(c)})),this;var u=dt(t),l=u.userId,d=u.tag,_=_t(l,d),p=(this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]})).singleScreen,f=p.filter((function(e){return e.streamId===_}))[0];return f?f.picture.push({uri:r,w:s,h:c,x:i,y:a}):p.push({streamId:_,picture:[{uri:r,w:s,h:c,x:i,y:a}]}),this._values.waterMark.singleScreen=p,this._logger.info(n.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:o.SUCCESSED,trackId:t,uri:r,x:i,y:a,w:s,h:c,singleScreen:p})),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(n.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}}),Object.defineProperty(t.prototype,"removePictureWaterMark",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){if(!e.notEmptyString(t)||!this._isValidTrackId(t))return this._logger.error(n.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:o.FAILED,msg:"params error -> trackId: ".concat(t)})),this;var i=dt(t),a=i.userId,s=i.tag,c=_t(a,s);return(this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]})).singleScreen.forEach((function(e){e.streamId===c&&(e.picture=e.picture.filter((function(e){return e.uri!==r})))})),this._logger.info(n.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:o.SUCCESSED,trackId:t,uri:r})),this}}),Object.defineProperty(t.prototype,"reset",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._values=Ma(),this._logger.info(n.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),s(this,void 0,void 0,(function(){var t,r;return c(this,(function(i){switch(i.label){case 0:return t=JSON.parse(JSON.stringify(this._values)),[4,this._invoker.push(new ka(t,this._values))];case 1:return r=i.sent().code,e&&(this._values=Ma()),[2,{code:r}]}}))}))}}),Object.defineProperty(t.prototype,"__innerGetValues",{enumerable:!1,configurable:!0,writable:!0,value:function(){return JSON.parse(JSON.stringify(this._values))}}),t}();exports.RCLivingType=void 0,(Ua=exports.RCLivingType||(exports.RCLivingType={}))[Ua.VIDEO=0]="VIDEO",Ua[Ua.AUDIO=1]="AUDIO";var ja,Ba=function(e){function t(t,r,i){var n=e.call(this)||this;return Object.defineProperty(n,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"roomPKHandler",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i}),n}return r(t,e),Object.defineProperty(t.prototype,"_exchangeWithPushOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,a,s,u,l,d,_,p,f,h;return c(this,(function(c){switch(c.label){case 0:return i=e.logger,a=e.peer,s=e.context,a.getLocalTracks().length?(u=a,[4,Xo(t.getSubscribedList(),!1,u,t,s)]):(i.info(n.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:o.SUCCESSED,msg:"have not published resource"}),this.traceId),[2]);case 1:return l=c.sent(),d=e.getPushOtherRooms(),l.pushOtherRooms=d,[4,new zo(l,this.traceId,!0).execute(e,t,r)];case 2:return(_=c.sent()).code!==exports.RCRTCCode.SUCCESS?(i.error(n.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:o.FAILED,code:_.code,pushOtherRooms:d}),this.traceId),[2]):(p=_.data.data,f=p.sdp,(h=p.resultCode)!==exports.RCRTCCode.SUCCESS?(i.error(n.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:o.FAILED,code:h,pushOtherRooms:d}),this.traceId),[2]):(i.info(n.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:o.SUCCESSED,pushOtherRooms:d}),this.traceId),u.setRemoteAnswer(f.sdp),[2]))}}))}))}}),Object.defineProperty(t.prototype,"kind",{get:function(){return ho.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 s(this,void 0,void 0,(function(){var i,a;return c(this,(function(s){switch(s.label){case 0:return i=e.logger,a=this.roomId,i.info(n.L_EXCHANGE_WITH_PUSHOTHERROOM_T,a),this.roomPKHandler?this.roomPKHandler.getPKInfo(a)?[4,this._exchangeWithPushOtherRoom(e,t,r)]:(i.warn(n.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:o.FAILED,msg:"PKInfo not exist"}),this.traceId),[2,{code:exports.RCRTCCode.SUCCESS}]):(i.error(n.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:o.FAILED,msg:"_roomPKHandler not exist"}),this.traceId),[2,{code:exports.RCRTCCode.SUCCESS}]);case 1:return s.sent(),[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),t}(yo),Va=function(t){function i(e,r,i,n,o,a){var s=t.call(this)||this;return Object.defineProperty(s,"pkHandler",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(s,"room",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"_PKInfo",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(s,"_joinedPKRooms",{enumerable:!0,configurable:!0,writable:!0,value:n}),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(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return ho.LEAVE_OTHER_ROOM},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"quitRoomPK",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,a){return s(this,void 0,void 0,(function(){var s,u,l,d,_,p,f,h,b,R;return c(this,(function(c){switch(c.label){case 0:return s=t.logger,u=t.context,s.info(n.L_QUIT_PK_T,"roomId: ".concat(r),a),this._PKInfo[r]?(l=this._PKInfo[r],d=l.inviterRoomId,_=l.inviteeRoomId,p=l.inviterUserId,f=l.inviteSessionId,h={inviteeRoomId:_,inviterRoomId:d,userId:i.crtUserId},b={roomId:i.roomId,endRoomId:r,sessionId:f,content:JSON.stringify(h),keys:["".concat(d,"|").concat(p)]},[4,u.endRoomPK(b)]):(s.warn(n.L_QUIT_PK_R,"status: ".concat(o.FAILED,", msg: pkinfo is empty"),a),[2]);case 1:return(R=c.sent())!==e.ErrorCode.SUCCESS?(s.error(n.L_QUIT_PK_R,"status: ".concat(o.FAILED,", code: ").concat(R),a),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(s.info(n.L_QUIT_PK_R,"status: ".concat(o.SUCCESSED),a),delete this._PKInfo[r],[2])}}))}))}}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return i=e.logger,s=(a=this).room,u=a.isQuitPK,l=s.getRoomId(),i.info(n.L_LIVING_ROOM_LEAVE_PK_ROOM_T,JSON.stringify({roomId:l,isQuitPK:u}),this.traceId),[4,s.__destroy(!0)];case 1:return c.sent(),delete this._joinedPKRooms[l],[4,new Ba(l,this.pkHandler,this.traceId).execute(e,t,r)];case 2:return c.sent(),u&&this.quitRoomPK(e,l,t,this.traceId),i.info(n.L_LIVING_ROOM_LEAVE_PK_ROOM_R,JSON.stringify({status:o.SUCCESSED}),this.traceId),[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),i}(yo),Fa=function(){function t(e,t,r,i,n,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:i}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:n}),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(t.prototype,"_callAppListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var o=null===(t=this._appListener)||void 0===t?void 0:t[e];if(o)try{o.apply(void 0,d([],l(r),!1))}catch(e){this._logger.error(n.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify(e))}}}),Object.defineProperty(t.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.inviteInfo||{},r=t.inviterRoomId,i={inviterRoomId:r,inviterUserId:t.inviterUserId,extra:t.extra};this._PKInfo[r]=t,this._logger.info(n.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onRequestJoinOtherRoom",info:i})),this._callAppListener("onRequestJoinOtherRoom",i)}}),Object.defineProperty(t.prototype,"_onCancelInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.inviteInfo||{},r=t.inviterRoomId,i={inviterRoomId:r,inviterUserId:t.inviterUserId,extra:t.extra};delete this._PKInfo[r],this._logger.info(n.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCancelRequestOtherRoom",cancelInfo:i})),this._callAppListener("onCancelRequestOtherRoom",i)}}),Object.defineProperty(t.prototype,"_onInviteTimeout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){}}),Object.defineProperty(t.prototype,"_onInviteAnswer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.answerCode,r=e.inviteContent,i=r.inviteSessionId,o=r.inviterUserId,a=r.inviterRoomId,s=r.inviteeUserId,c=r.inviterUserAutoMix,u=r.inviteeUserAutoMix,l=r.inviteeRoomId,d={agree:1===t,inviterRoomId:a,inviterUserId:o,inviteeRoomId:l,inviteeUserId:s,extra:r.extra};this._PKInfo[l]=this._PKInfo[l]||{inviteSessionId:i,inviterRoomId:a,inviterUserId:o,inviterUserAutoMix:c,inviteeRoomId:l},this._PKInfo[l].inviteeUserAutoMix=u,this._logger.info(n.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onResponseJoinOtherRoom",answerInfo:d})),this._callAppListener("onResponseJoinOtherRoom",d)}}),Object.defineProperty(t.prototype,"createLeaveOtherRoomCommand",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return new Va(this,e,this._PKInfo,this._joinedPKRooms,t,r)}}),Object.defineProperty(t.prototype,"_onPKEnd",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t,r,i,o,a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return t=e.inviteInfo,r=t.inviteeRoomId,i=t.inviterRoomId,o=t.userId,a=i===this._mainRoomId?r:i,s={endRoomId:a,endUserId:o},u=this._joinedPKRooms[a],l=this._logger.createTraceId(),this._logger.info(n.L_QUIT_PK_LEAVE_PK_ROOM_O,void 0,l),u?[4,this._invoker.push(this.createLeaveOtherRoomCommand(u,!0,l))]:[3,2];case 1:c.sent(),c.label=2;case 2:return delete this._PKInfo[a],this._logger.info(n.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onFinishOtherRoom",endInfo:s})),this._callAppListener("onFinishOtherRoom",s),[2]}}))}))}}),Object.defineProperty(t.prototype,"_onRecvPKMsg",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.content;switch(e.messageType){case Tt.PK_INVITE:this._onInvite(t);break;case Tt.PK_CANCEL_INVITE:this._onCancelInvite(t);break;case Tt.PK_INVITE_TIMEOUT:this._onInviteTimeout(t);break;case Tt.PK_INVITE_ANSWER:this._onInviteAnswer(t);break;case Tt.PK_END:this._onPKEnd(t)}}}),Object.defineProperty(t.prototype,"registerRoomPKEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(n.L_LIVING_PK_HANDLER_REGISTER_ROOM_PK_EVENT_LISTENER_O,JSON.stringify({listener:e&&Object.keys(e)})),this._appListener=e}}),Object.defineProperty(t.prototype,"requestJoinOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var a,s,u,l,d,_;return c(this,(function(c){switch(c.label){case 0:return a=this._logger.createTraceId(),this._logger.info(n.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:t,inviteeUserId:r,options:i}),a),e.validate("inviteeRoomId",t,e.notEmptyString,!0)&&e.validate("inviteeUserId",r,e.notEmptyString,!0)?(s=Kn(),u=!e.isBoolean(null==i?void 0:i.autoMix)||(null==i?void 0:i.autoMix),l={inviteSessionId:s,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:u,inviteeRoomId:t,inviteeUserId:r,inviteeTimeoutTime:this._inviteTimeout,extra:(null==i?void 0:i.extra)||""},d={roomId:this._mainRoomId,invitedRoomId:t,invitedUserId:r,inviteTimeout:this._inviteTimeout,inviteInfo:JSON.stringify(l),inviteSessionId:s},[4,this._context.requestRoomPK(d)]):(this._logger.error(n.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),a),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return(_=c.sent())!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:_}),a),[2,{code:_}]):(this._PKInfo[t]={inviteSessionId:s,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:u,inviteeRoomId:t},this._logger.info(n.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.SUCCESSED}),a),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),Object.defineProperty(t.prototype,"cancelRequestJoinOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return a=this._logger.createTraceId(),this._logger.info(n.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:t,inviteeUserId:r,extra:i}),a),e.validate("inviteeRoomId",t,e.notEmptyString,!0)&&e.validate("inviteeUserId",r,e.notEmptyString,!0)?this._PKInfo[t]?(s={inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviteeRoomId:t,inviteeUserId:r,extra:i||""},u={roomId:this._mainRoomId,invitedRoomId:t,invitedUserId:r,inviteSessionId:this._PKInfo[t].inviteSessionId,inviteInfo:JSON.stringify(s)},[4,this._context.cancelRoomPK(u)]):(this._logger.error(n.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"The request to connect with ".concat(r," user in room ").concat(t," is not initiated")}),a),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(this._logger.error(n.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),a),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return(l=c.sent())!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:l}),a),[2,{code:l}]):(this._logger.info(n.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.SUCCESSED}),a),delete this._PKInfo[t],[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),Object.defineProperty(t.prototype,"responseJoinOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,a){return s(this,void 0,void 0,(function(){var s,u,l,d,_,p,f,h,b,R;return c(this,(function(c){switch(c.label){case 0:return s=this._logger.createTraceId(),this._logger.info(n.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_T,JSON.stringify({inviterRoomId:t,inviterUserId:r,agree:i,options:a}),s),e.validate("inviterRoomId",t,e.notEmptyString,!0)&&e.validate("inviterUserId",r,e.notEmptyString,!0)?this._PKInfo[t]?(u=this._PKInfo[t],l=u.inviteSessionId,d=u.inviterUserAutoMix,_=!e.isBoolean(null==a?void 0:a.autoMix)||(null==a?void 0:a.autoMix),p={inviteSessionId:l,inviterRoomId:t,inviterUserId:r,inviterUserAutoMix:d,inviteeRoomId:this._mainRoomId,inviteeUserId:this._context.getCurrentId(),inviteeUserAutoMix:_},f=Object.assign(p,{inviterUserAutoMix:d}),h=i?Object.assign(p,{MultiRoomKey:"".concat(t,"|").concat(this._mainRoomId),MultiRoomValue:JSON.stringify(f)}):p,!e.isUndefined(null==a?void 0:a.extra)&&Object.assign(h,{extra:a.extra}),b={agree:i,roomId:this._mainRoomId,inviteSessionId:l,inviteRoomId:t,inviteUserId:r,content:JSON.stringify(h),key:"".concat(t,"|").concat(this._mainRoomId),value:JSON.stringify(p)},[4,this._context.responseRoomPK(b)]):(this._logger.error(n.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"User ".concat(r," in room ").concat(t," did not send a request for connection")}),s),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(this._logger.error(n.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> inviterRoomId or inviterUserId"}),s),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return(R=c.sent())!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:R}),s),[2,{code:R}]):(this._logger.info(n.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.SUCCESSED}),s),this._PKInfo[t].inviteeUserAutoMix=_,[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),Object.defineProperty(t.prototype,"joinOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,a,s,u;return c(this,(function(c){switch(c.label){case 0:return r=this._logger.createTraceId(),this._logger.info(n.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_T,JSON.stringify({roomId:t}),r),e.validate("roomId",t,e.notEmptyString,!0)?this._context.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED?(this._logger.error(n.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.SIGNAL_DISCONNECTED,msg:"IM disconnected"}),r),[2,{code:exports.RCRTCCode.SIGNAL_DISCONNECTED}]):this._joinedPKRooms[t]?(this._logger.warn(n.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),r),[2,{code:exports.RCRTCCode.REPERT_JOIN_ROOM}]):(i=exports.RCLivingType.VIDEO,a={extra:'{"roomId": "'.concat(this._mainRoomId,'"}')},[4,(s=new Ya(this._context,this._runtime,t,this._service,this._initOptions,i,!1,!1,this._clientSessionId)).__innerInit(exports.RTCMode.LIVE,void 0,i,a)]):(this._logger.error(n.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> roomId"}),r),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return(u=c.sent().code)!==exports.RCRTCCode.SUCCESS?(this._logger.error(n.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:u}),r),[2,{code:u}]):(this._joinedPKRooms[t]=s,[4,this._onJoinedPKRoom(t,r)]);case 2:return c.sent(),this._logger.info(n.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.SUCCESSED}),r),[2,{room:s,code:exports.RCRTCCode.SUCCESS,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()}]}}))}))}}),Object.defineProperty(t.prototype,"leaveOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r;return c(this,(function(i){return r=this._logger.createTraceId(),this._logger.info(n.L_APP_CALL_LEAVE_PK_ROOM_O,void 0,r),[2,this._invoker.push(this.createLeaveOtherRoomCommand(e,t,r))]}))}))}}),Object.defineProperty(t.prototype,"getPKInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._PKInfo[e]}}),Object.defineProperty(t.prototype,"getAllPKInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._PKInfo}}),Object.defineProperty(t.prototype,"getJoinedPKRooms",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._joinedPKRooms}}),t}();!function(e){e[e.OPEN=1]="OPEN",e[e.STOP=2]="STOP"}(ja||(ja={}));var Ja,Ga=function(t){function i(e,r){var i=t.call(this)||this;return Object.defineProperty(i,"cdnValues",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(i,"enable",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return ho.ENABLE_INNER_CDN},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var a,s,u,l,d,_,p;return c(this,(function(c){switch(c.label){case 0:return a=t.logger,s=t.context,u=this.enable,a.info(n.L_LIVING_ROOM_ENABLE_INNER_CDN_T,JSON.stringify({roomId:r.roomId,enable:u})),r.isMainRoom?e.isBoolean(u)?(r.setCDNEnabel(u),l={version:2,output:{inCDNModel:u?ja.OPEN:ja.STOP}},[4,new ka(l,this.cdnValues).execute(t,r,i)]):(a.error(n.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> enable"})),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(a.error(n.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),[2,{code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM}]);case 1:return(d=c.sent().code)!==exports.RCRTCCode.SUCCESS?(a.error(n.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:o.FAILED,code:d,msg:"signal error"})),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(_=r.getCDNUris())&&_.broadcast!==Mo.SPREAD?(a.info(n.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:o.SUCCESSED,enable:u})),[2,{code:exports.RCRTCCode.SUCCESS}]):[4,ta(s,r)];case 2:return(p=c.sent().code)===exports.RCRTCCode.SUCCESS?(a.info(n.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:o.SUCCESSED,enable:u})),[2,{code:exports.RCRTCCode.SUCCESS}]):(a.error(n.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:o.FAILED,code:p})),[2,{code:p}])}}))}))}}),i}(yo);!function(e){e[e.AnchorToViewer=1]="AnchorToViewer",e[e.ViewerToAnchor=2]="ViewerToAnchor"}(Ja||(Ja={}));var Ha,Ka,Wa=function(t){function i(e,r){var i=t.call(this)||this;return Object.defineProperty(i,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(i,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return ho.RTC_IDENTITY_CHANGE},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){var n;return s(this,void 0,void 0,(function(){var o,a,s,u;return c(this,(function(c){switch(c.label){case 0:return[4,t.context.rtcIdentityChange(r.roomId,Ja.ViewerToAnchor,this.livingType)];case 1:return o=c.sent(),a=o.code,s=o.data,a===e.ErrorCode.SUCCESS&&s?(r.initWithRoomData(s,this.traceId),r.getResourcesByUserId(r.crtUserId).length>0&&i.push(new No),(u=null===(n=s.roomInfo.filter((function(e){return"cdn_uris"===e.key}))[0])||void 0===n?void 0:n.value)&&r.setCDNUris(JSON.parse(u)[0]),[2,{code:a,data:s}]):[2,{code:a}]}}))}))}}),i}(yo),Ya=function(t){function i(e,r,i,n,o,a,s,c,u){var l=t.call(this,e,r,i,exports.RTCMode.LIVE,n,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 xa(l._executeCtx,l._invoker,l._isValidResourceId.bind(l)),l}return r(i,t),Object.defineProperty(i.prototype,"_initRoomPKHandler",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this._store.isMainRoom){var r=(i=this._roomId,n=e.roomInfo,o={},n.forEach((function(e){var t=JSON.parse(e.value),r=t.inviterRoomId,n=t.inviteeRoomId;o[i===r?n:r]=JSON.parse(e.value)})),o);this._roomPKHandler=new Fa(this._invoker,r,this._context,this._runtime,this._service,this._initOptions,this,t.prototype._registerPKMsgListener.bind(this),this._onJoinedPKRoom.bind(this),this._clientSessionId)}var i,n,o}}),Object.defineProperty(i.prototype,"__innerInit",{enumerable:!1,configurable:!0,writable:!0,value:function(r,i,a,u,l,d){return s(this,void 0,void 0,(function(){var s,_,p;return c(this,(function(c){switch(c.label){case 0:return e.validate("livingType",a,(function(e){return e===exports.RCLivingType.AUDIO||e===exports.RCLivingType.VIDEO}))?[4,t.prototype.__innerInit.call(this,r,i,a,u,l,d)]:(this._logger.error(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> livingType"}),d),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return s=c.sent(),_=s.code,p=s.data,_===exports.RCRTCCode.SUCCESS&&p&&this._initRoomPKHandler(p),[2,{code:_,data:p}]}}))}))}}),Object.defineProperty(i.prototype,"__innerInitByIdentityChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,a;return c(this,(function(s){switch(s.label){case 0:return[4,this._invoker.push(new Wa(this._livingType,t))];case 1:return r=s.sent(),i=r.code,a=r.data,i===e.ErrorCode.SUCCESS&&a?(this._initRoomPKHandler(a),this._initWithRoomData(a.offlineKickTime),this._logger.info(n.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:o.SUCCESSED,roomData:a}),t)):this._logger.error(n.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:o.FAILED,code:i}),t),[2,i]}}))}))}}),Object.defineProperty(i.prototype,"publish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(r){return this._store.isMainRoom?[2,t.prototype.publish.call(this,e)]:(this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),[2,{code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM}])}))}))}}),Object.defineProperty(i.prototype,"unpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(r){return this._store.isMainRoom?[2,t.prototype.unpublish.call(this,e)]:(this._logger.error(n.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),[2,{code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM}])}))}))}}),Object.defineProperty(i.prototype,"_isValidResourceId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,i=dt(e).userId,n=!!(null===(t=this._store.getResourcesByUserId(i))||void 0===t?void 0:t.find((function(t){return lt(t)===e}))),o=this.getRoomPKHandler(),a=o.code,s=o.roomPKHandler;if(a!==exports.RCRTCCode.SUCCESS||!s)return n;var c=s.getJoinedPKRooms(),u=[];return Object.values(c).forEach((function(e){u.push.apply(u,d([],l(e.getRemoteTracks()),!1))})),r=u.some((function(t){return e===t.getTrackId()})),n||r}}),Object.defineProperty(i.prototype,"getLivingType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._livingType}}),Object.defineProperty(i.prototype,"getMCUConfigBuilder",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.isMainRoom?this._mcuConfigBuilder:(this._logger.error(n.L_LIVING_ROOM_GET_MCU_CONFIG_BUILDER_O,"the `getMCUConfigBuilder` is disabled in PK room"),{code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}}),Object.defineProperty(i.prototype,"enableInnerCDN",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this._invoker.push(new Ga(this._mcuConfigBuilder.__innerGetValues(),e))]}))}))}}),Object.defineProperty(i.prototype,"_resourceHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i,n,o){return s(this,void 0,void 0,(function(){return c(this,(function(a){return t.prototype._resourceHandle.call(this,e,r,i,n,o),[2]}))}))}}),Object.defineProperty(i.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(i.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(i.prototype,"_onJoinedPKRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){return c(this,(function(r){return this._invoker.push(new Ba(e,this._roomPKHandler,t)),[2]}))}))}}),Object.defineProperty(i.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 i=t[r].getSessionId(),n=this._roomPKHandler.getPKInfo(r);if(n){var o=n.inviterUserAutoMix,a=n.inviteeUserAutoMix,s=n.inviterUserId,c=this._context.getCurrentId()===s;e.push({roomId:r,sessionId:i,autoMix:c?!!o:!!a})}}return e}}),Object.defineProperty(i.prototype,"getRoomPKHandler",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.isMainRoom?(this._logger.info(n.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:o.SUCCESSED})),{code:exports.RCRTCCode.SUCCESS,roomPKHandler:this._roomPKHandler}):(this._logger.error(n.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:o.SUCCESSED,code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}}),Object.defineProperty(i.prototype,"_quitAllPKRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var e,t;return c(this,(function(r){for(t in e=this._roomPKHandler.getJoinedPKRooms())this._roomPKHandler.leaveOtherRoom(e[t]);return this._logger.info(n.L_LIVING_ROOM_QUIT_ALL_PK_ROOM_O,JSON.stringify({status:o.SUCCESSED,roomIds:Object.keys(e)})),[2]}))}))}}),Object.defineProperty(i.prototype,"isMainRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.isMainRoom}}),i}(Da),za=function(e){function t(t,r,i,n,o,a,s){return void 0===a&&(a=exports.RTCMode.RTC),void 0===s&&(s=!1),e.call(this,t,r,i,a,n,o,!1,!1,Kn(),s)||this}return r(t,e),t}(Da),qa=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 s(this,void 0,void 0,(function(){var e,t,r,i,n,o;return c(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,i=e.reject,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r()];case 2:return n=a.sent(),t(n),[3,4];case 3:return o=a.sent(),i(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,i=new Promise((function(t,i){r.queue.push({resolve:t,task:e,reject:i})}));return this.checkToStart(),i}}),e}(),Qa=new qa,Za=function(e,t){return void 0===t&&(t=""),Qa.push(e,t)},Xa=function(){function t(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:Kn()}),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 Qn(t,e,r.mediaServer),this._logger=this._context.logger,this._store=new Ao(this._logger,this._clientSessionId,this._context.getAppkey(),this._crtUserId,this._crtUserId,exports.RTCMode.LIVE)}return Object.defineProperty(t.prototype,"_getReqHeaders",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,n,o;return c(this,(function(a){switch(a.label){case 0:return r=this._crtUserId,this._rtcToken?[3,2]:[4,this._context.getRTCToken(r,exports.RTCMode.LIVE,t)];case 1:if(i=a.sent(),n=i.code,o=i.data,n!==e.ErrorCode.SUCCESS)return[2,{code:exports.RCRTCCode.SIGNAL_ERROR}];this._rtcToken=o.rtcToken,a.label=2;case 2:return[2,{code:exports.RCRTCCode.SUCCESS,headers:{"App-Key":this._context.getAppkey(),UserId:this._crtUserId,RoomId:r,RoomType:exports.RTCMode.LIVE,Token:this._rtcToken,"Client-Session-Id":this._clientSessionId}}]}}))}))}}),Object.defineProperty(t.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(t.prototype,"_reTryExchange",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return s(this,void 0,void 0,(function(){var t;return c(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)===exports.RCRTCCode.SUCCESS&&(null===(e=this._pc)||void 0===e||e.clearReTryExchangeTimer()),[2,{code:t}]}}))}))}}),Object.defineProperty(t.prototype,"subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){return void 0===i&&(i=!1),s(this,void 0,void 0,(function(){var n=this;return c(this,(function(o){return[2,Za((function(){return n.__subscribe(e,t,r,i)}),"audience-client-sub")]}))}))}}),Object.defineProperty(t.prototype,"__subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,a){var u;return void 0===a&&(a=!1),s(this,void 0,void 0,(function(){var s,l,d,_,p,f,h,b,R,g,m,C,v,O=this;return c(this,(function(c){switch(c.label){case 0:return this._logger.info(n.L_AUDIENCE_CLIENT_SUBSCRIBE_T,JSON.stringify({liveUrl:t,livingType:r,mediaType:i,subTiny:a})),s=[],St(this._context.getNaviInfo())?(this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"})),[2,{code:exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR,tracks:s}]):(!this._fromRetry&&(null===(u=this._pc)||void 0===u||u.clearReTryExchangeTimer()),this._fromRetry=!1,e.isString(t)?[exports.RCLivingType.AUDIO,exports.RCLivingType.VIDEO].includes(r)?[exports.RCMediaType.AUDIO_ONLY,exports.RCMediaType.VIDEO_ONLY,exports.RCMediaType.AUDIO_VIDEO].includes(i)?this._liveUrl&&this._liveUrl!==t?(this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.BROADCAST_SUB_LIST_NOT_EMPTY,msg:"repeat subscribe"})),[2,{code:exports.RCRTCCode.BROADCAST_SUB_LIST_NOT_EMPTY,tracks:s}]):(this._pc||(this._pc=new Eo(this._logger,this._reTryExchange.bind(this),this._crtUserId,this._store,void 0,!1),this._pc.on(Eo.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),this._pc.registerReportListener(this._reportListener),this._pc.__reportR3R4ToPolaris()),this._liveUrl=t,[4,this._getReqHeaders(r)]):(this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> -> mediaType: ".concat(i)})),[2,{code:exports.RCRTCCode.PARAMS_ERROR,tracks:s}]):(this._logger.error("livingType is invalid: ".concat(r)),this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> livingType: ".concat(r)})),[2,{code:exports.RCRTCCode.PARAMS_ERROR,tracks:s}]):(this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> liveUrl: ".concat(t)})),[2,{code:exports.RCRTCCode.PARAMS_ERROR,tracks:s}]));case 1:return l=c.sent(),d=l.code,_=l.headers,d!==exports.RCRTCCode.SUCCESS?(this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:d,msg:"getRTCToken failed"})),[2,{code:d,tracks:s}]):(p="rc_mcu_".concat(Date.now()),f="RongCloudRTC",0===this._subTracks.length&&(this._subTracks.push(new rt(this._logger,f,p),new it(this._logger,f,p)),this._pc.updateSubRemoteTracks(this._subTracks.slice())),[4,this._pc.createOffer(!0)]);case 2:return h=c.sent(),b={sdp:h,liveUrl:t,mediaType:i,simulcast:a?Gn.TINY:Gn.NORMAL,switchstream:!1},[4,this._service.broadcastSubscribe(_,b)];case 3:return(R=c.sent()).code!==exports.RCRTCCode.SUCCESS?(this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:R.code})),[2,{code:R.code,tracks:s}]):(g=R.data).resultCode!==exports.RCRTCCode.SUCCESS?(this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:g.resultCode,msg:g.message})),[2,{code:g.resultCode,tracks:s}]):(this._livingType=r,this._mediaType=i,this._subTiny=a,m=g.sdp,C=g.subscribedList,this._subscribedList=C,v=[],C.forEach((function(e){var t=e.mediaType,r=O._subTracks[t];v.push(r),r.__innerSetRemoteMuted(!0)})),this._pc.setRemoteAnswer(m.sdp),v&&this._updateTrackIdSSRCMap(m.sdp,v),this._logger.info(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.SUCCESSED,liveUrl:t})),[2,{code:exports.RCRTCCode.SUCCESS,tracks:v}])}}))}))}}),Object.defineProperty(t.prototype,"_updateTrackIdSSRCMap",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;t.forEach((function(t){var i=t.getTrackId(),n=dt(i).mediaType,o=r._subscribedList.filter((function(e){return e.mediaType===n}))[0].msid,a=aa(e,o,n);r._store.setTrackIdSSRCMap(Number(a),i)}))}}),Object.defineProperty(t.prototype,"unsubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var e=this;return c(this,(function(t){return[2,Za((function(){return e.__unsubscribe()}),"audience-client-unsub")]}))}))}}),Object.defineProperty(t.prototype,"__unsubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return s(this,void 0,void 0,(function(){var t,r;return c(this,(function(i){switch(i.label){case 0:return this._logger.info(n.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(n.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:"",msg:"Address does not exist, without unsubscribe"})),[2,{code:exports.RCRTCCode.SUCCESS}]);case 1:return t=i.sent().headers,[4,this._service.broadcastExit(t)];case 2:return(r=i.sent().code)!==exports.RCRTCCode.SUCCESS?this._logger.error(n.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:r})):(this._logger.info(n.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:o.SUCCESSED,liveUrl:this._liveUrl})),this._subscribedList=[]),this._clearSubscribeInfo(),[2,{code:r}]}}))}))}}),Object.defineProperty(t.prototype,"registerReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._reportListener=e}}),Object.defineProperty(t.prototype,"registerTrackEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._appListener=e}}),Object.defineProperty(t.prototype,"_onTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,i=e.receiver.track,o="audio"===i.kind?exports.RCMediaType.AUDIO_ONLY:exports.RCMediaType.VIDEO_ONLY,a=this._subTracks[o];a.__innerSetMediaStreamTrack(i);try{this._logger.info(n.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,"trackId: ".concat(a.getTrackId())),null===(r=null===(t=this._appListener)||void 0===t?void 0:t.onTrackReady)||void 0===r||r.call(t,a)}catch(e){this._logger.error(n.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,JSON.stringify(e))}}}),t}();exports.RCInnerCDNPullKind=void 0,(Ha=exports.RCInnerCDNPullKind||(exports.RCInnerCDNPullKind={})).RTMP="rtmp",Ha.FLV="flv",Ha.HLS="hls",exports.RCInnerCDNPullIsHttps=void 0,(Ka=exports.RCInnerCDNPullIsHttps||(exports.RCInnerCDNPullIsHttps={}))[Ka.NOT_HTTPS=0]="NOT_HTTPS",Ka[Ka.HTTPS=1]="HTTPS";var $a,es=a(a({},bt(exports.RCResolution.W176_H144)),{frameRate:mt(exports.RCFrameRate.FPS_15)}),ts=function(){function t(e,t,r,i,n,o,a){void 0===a&&(a=Kn());var u=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:i}),Object.defineProperty(this,"_joinResData",{enumerable:!0,configurable:!0,writable:!0,value:n}),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 Aa(this._context,this._runtime,this._roomId,this,Oa.Audience),this._reportMediaActionLogger=new Ia(this._logger,this._roomId,this._clientSessionId,this._crtUserId),this._service=new Qn(this._runtime,this._context,this._initOptions.mediaServer,this._initOptions.timeout);var l=this._store=new Ao(this._logger,a,e.getAppkey(),i,this._crtUserId,exports.RTCMode.LIVE),d=this._pc=new Eo(this._logger,this._reTryExchange.bind(this),this._crtUserId,l,this._polarisReport,!0);this._audioLevelReport=new Io(this._store,d),d.on(Eo.__INNER_AUDIOLEVEL_CHANGE__,this._audioLevelReport.audioLevelReport,this._audioLevelReport),this._polarisReport.sendR1(),this._context.registerRTCSignalListener((function(e){return s(u,void 0,void 0,(function(){var t,r,i,n;return c(this,(function(o){return t=this._context.decodeRtcNotify(e),r=t.time,i=t.type,n=t.roomId,1===i&&this._startPull(n,r),[2]}))}))})),this._setInitData()}return Object.defineProperty(t.prototype,"_startPull",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return s(this,void 0,void 0,(function(){var i,a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return this._isPulling?[2]:(this._isPulling=!0,this._pullTime>r?(this._isPulling=!1,[2]):(i=this._logger.createTraceId(),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T,"pullTime: ".concat(this._pullTime),i),[4,this._context.pullRTCRoomEntry(t)]));case 1:return a=c.sent(),s=a.code,u=a.data,s===e.ErrorCode.SUCCESS&&(this._isPulling=!1,this._pullTime=(null==u?void 0:u.syncTime)||0,l=(null==u?void 0:u.kvEntries)||[],this._logger.info(n.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,"status: ".concat(o.SUCCESSED,", kvEntries: ").concat(JSON.stringify(l)),i),this.singalDataChange(l,t,i)),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,"status: ".concat(o.FAILED,", code: ").concat(s),i),[2]}}))}))}}),Object.defineProperty(t.prototype,"_setInitData",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=function(e,t,r){var i=t.filter((function(e){return"RC_RTC_SESSIONID"===e.key}))[0],n=i?i.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 i=t.mediaType,n=t.tag,o=i===exports.RCMediaType.AUDIO_ONLY?new rt(r,n,"",e):new it(r,n,"",e);c.push(o)}));var u=[],_=[];a.forEach((function(e){var t=JSON.parse(e.uris||"[]");u.push.apply(u,d([],l(t),!1)),t.forEach((function(e){var t=e.mediaType,i=e.tag,n=e.msid.split("_");n.pop();var o=n.join("_"),a=t===exports.RCMediaType.AUDIO_ONLY?new rt(r,i,o):new it(r,i,o);_.push(a)}))}));var p=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:n,remoteUserIds:o||[],remoteRTCUris:u,remoteMUCUris:s,remoteRTCTracks:_,remoteMCUTracks:c,remoteTracks:d(d([],l(_),!1),l(c),!1),CDNUris:p||{}}}(this._roomId,this._joinResData.kvEntries,this._logger),r=t.sessionId,i=t.remoteUserIds,n=t.remoteRTCUris,o=t.remoteMUCUris,a=t.remoteTracks,s=t.CDNUris;this._sessionId=r,this._roomAnchorList=i,a.forEach((function(t){e._remoteTracks[t.getTrackId()]=t})),this._CDNUris=s,n.forEach((function(t){var r=t.msid.split("_")[0];e._roomAnchorRes[r]?e._roomAnchorRes[r].push(t):e._roomAnchorRes[r]=[t];var i=JSON.parse(t.uri),n=i.ssrc,o=i.resourceId;e._store.setTrackIdSSRCMap(n,o)})),o.forEach((function(t){var r=t.mediaType,i=t.tag,n=[e._roomId,i,r].join("_");e._roomRes[n]=t;var o=JSON.parse(t.uri).ssrc;e._store.setTrackIdSSRCMap(o,n)})),n.forEach((function(t){var r=lt(t);e._roomRes[r]=t}))}}),Object.defineProperty(t.prototype,"_assertRoomDestroyed",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this._destroyed)return exports.RCRTCCode.ROOM_HAS_BEEN_DESTROYED}}),Object.defineProperty(t.prototype,"singalDataChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i,a=this;if(t===this._roomId){var s=[],c=null===(i=e.filter((function(e){return"RC_CDN"===e.key}))[0])||void 0===i?void 0:i.value;c&&this._diffCDNUris(JSON.parse(JSON.parse(c).cdn_uris)[0],r),e.forEach((function(e){var t=e.key,i=e.value,n=e.uid;if(-1!==t.indexOf("RC_RES_")){var o=JSON.parse(i||"{}"),c=JSON.parse(o.mcu_uris||"[]"),u=JSON.parse(o.uris||"[]");return s.push.apply(s,d([],l(c),!1)),void a._diffAnchorResource(u,n,r)}if("RC_ANCHOR_LIST"===t){var _=JSON.parse(i||"[]");a._diffAnchorList(_,r)}})),this._diffRoomResource(s,r)}else this._logger.error(n.L_AUDIENCE_LIVING_ROOM_SINGAL_DATA_CHANGE_P,JSON.stringify({status:o.FAILED,msg:"roomId inconsistency -> params roomId:".concat(t,", current roomId:").concat(this._roomId)}),r)}}),Object.defineProperty(t.prototype,"_diffAnchorList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,i=e.filter((function(e){return r._roomAnchorList.indexOf(e)<0})),n=this._roomAnchorList.filter((function(t){return e.indexOf(t)<0}));i.length>0&&this._handleNewJoinedAnchor(i,t),n.length>0&&this._handleLeftedAnchor(n,t)}}),Object.defineProperty(t.prototype,"_handleNewJoinedAnchor",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;(r=this._roomAnchorList).push.apply(r,d([],l(e),!1)),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorJoin",list:e}),t),this._callAppListener("onAnchorJoin",e)}}),Object.defineProperty(t.prototype,"_handleLeftedAnchor",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i=this;return c(this,(function(o){switch(o.label){case 0:return this._roomAnchorList=this._roomAnchorList.filter((function(t){return!e.includes(t)})),r=[],e.forEach((function(e){r.push.apply(r,d([],l(i.getRemoteTracksByUserId(e)),!1)),delete i._roomAnchorRes[e]})),r.length?[4,this.unsubscribe(r)]:[3,2];case 1:o.sent(),r.forEach((function(e){return delete i._remoteTracks[e.getTrackId()]})),o.label=2;case 2:return this._logger.info(n.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorLeave",list:e}),t),this._callAppListener("onAnchorLeave",e),[2]}}))}))}}),Object.defineProperty(t.prototype,"_diffRoomResource",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,o,a=this;return c(this,(function(s){return r=[],i=[],o=[],e.forEach((function(e){var t=lt(e),i=dt(t),n=i.tag,s=i.mediaType,c=[a._roomId,n,s].join("_"),u=JSON.parse(e.uri).ssrc;if(a._store.setTrackIdSSRCMap(u,c),!a._remoteTracks[c]){var l=s===exports.RCMediaType.AUDIO_ONLY?new rt(a._logger,n,"",a._roomId):new it(a._logger,n,"",a._roomId);r.push(l),a._remoteTracks[c]=l,a._roomRes[l.getTrackId()]=e}o.push(c)})),Object.keys(this._remoteTracks).forEach((function(e){o.indexOf(e)<0&&a._remoteTracks[e].isMCUTrack()&&i.push(a._remoteTracks[e])})),r.length>0&&(this._logger.info(n.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)),i.length>0&&this._onUserUnpublish(i,"onTrackUnpublish",t),[2]}))}))}}),Object.defineProperty(t.prototype,"_dealPublished",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,a,s,u,l,d=this;return c(this,(function(c){switch(c.label){case 0:return i=e.map(lt),a=[],s=[],t.forEach((function(t){var r=lt(t),n=i.indexOf(r),o=dt(r),c=o.userId,u=o.tag,l=o.mediaType,_=JSON.parse(t.uri).ssrc;d._store.setTrackIdSSRCMap(_,r),n>-1?e[n]=t:e.push(t);var p=d._remoteTracks[r];d._roomRes[r]=t,p?p.isSubscribed()&&a.push(p):(p=l===exports.RCMediaType.AUDIO_ONLY?new rt(d._logger,u,c):new it(d._logger,u,c),d._remoteTracks[r]=p,s.push(p)),p.__innerSetRemoteMuted(0===t.state)})),a.length?(u=a.map((function(e){return e.getTrackId()})),[4,Za((function(){return d._subscribeHandle(a,!0)}))]):[3,2];case 1:(l=c.sent().code)!==exports.RCRTCCode.SUCCESS&&this._logger.error(n.L_RESUB_REPUB_RES_R,JSON.stringify({status:o.FAILED,trackIds:u,code:l})),c.label=2;case 2:return this._logger.info(n.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorTrackPublish",trackIds:s.map((function(e){return e.getTrackId()}))}),r),this._callAppListener("onAnchorTrackPublish",s),[2]}}))}))}}),Object.defineProperty(t.prototype,"_dealUnpublished",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n,o,a,s=this;return c(this,(function(c){switch(c.label){case 0:for(i=t.map(lt),n=e.length-1;n>=0;n-=1)o=e[n],i.includes(lt(o))&&e.splice(n,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(t.prototype,"_dealModified",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i,o,a=e.map(lt);try{for(var s=u(t),c=s.next();!c.done;c=s.next()){var l=c.value,d=lt(l);e[a.indexOf(d)].state=l.state;var _=this._remoteTracks[d];_.__innerSetRemoteMuted(0===l.state);var p=_.isAudioTrack()?"onAudioMuteChange":"onVideoMuteChange";this._logger.info(n.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:p,trackId:_.getTrackId()}),r),this._callAppListener(p,_)}}catch(e){i={error:e}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}}),Object.defineProperty(t.prototype,"_diffAnchorResource",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n,o,a,s;return c(this,(function(c){switch(c.label){case 0:return i=this._roomAnchorRes[t]||(this._roomAnchorRes[t]=[]),n=ft(i,e),o=n.publishedList,a=n.unpublishedList,s=n.modifiedList,o.length?[4,this._dealPublished(i,o,r)]:[3,2];case 1:c.sent(),c.label=2;case 2:return a.length?[4,this._dealUnpublished(i,a,r)]:[3,4];case 3:c.sent(),c.label=4;case 4:return s.length&&this._dealModified(i,s,r),[2]}}))}))}}),Object.defineProperty(t.prototype,"_onUserUnpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i=this;return c(this,(function(o){switch(o.label){case 0:return[4,this.unsubscribe(e)];case 1:return o.sent(),e.forEach((function(e){i._subscribedList=i._subscribedList.filter((function(t){return t.track.getTrackId()!==e.getTrackId()})),delete i._roomRes[e.getTrackId()],e.__innerDestroy(),delete i._remoteTracks[e.getTrackId()]})),this._logger.info(n.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(t.prototype,"_callAppListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var o=null===(t=this._appListener)||void 0===t?void 0:t[e];if(o)try{o.apply(void 0,d([],l(r),!1))}catch(e){this._logger.error(n.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify(e))}}}),Object.defineProperty(t.prototype,"_reTryExchange",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var e=this;return c(this,(function(t){return[2,Za((function(){return s(e,void 0,void 0,(function(){var e,t,r,i,n,o,a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return[4,this._createSubscribeParams(this._subscribedList,{},!0)];case 1:return e=c.sent().reqBody,[4,this._exchangeHandle(e)];case 2:return(t=c.sent()).code!==exports.RCRTCCode.SUCCESS?[2,{code:t.code}]:(r=t.data,i=r.sdp,(n=r.resultCode)!==exports.RCRTCCode.SUCCESS?[2,{code:n}]:(this._pc.clearReTryExchangeTimer(),(o=this._subscribedList.filter((function(e){return e.track.isMCUTrack()}))).length>0&&(a=o[0].track.getTrackId(),s=null===(l=this._roomRes[a])||void 0===l?void 0:l.msid,u=[this._roomId,"RongCloudRTC"].join("_"),i.sdp=i.sdp.replace(new RegExp(s,"g"),u)),[4,this._pc.setRemoteAnswer(i.sdp)]));case 3:return[2,{code:c.sent()}]}}))}))}),"audience-retry-exchange")]}))}))}}),Object.defineProperty(t.prototype,"_createSubscribeParams",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n,o,a=this;return c(this,(function(s){switch(s.label){case 0:return[4,this._pc.createOffer(r)];case 1:return i=s.sent(),n={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;i.sdp=null===(a=i.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?ct(c):es,d=l.width,_=l.height,p=l.frameRate;n.resolutionInfo.push({trackId:c.id,simulcast:u?Gn.NORMAL:Gn.TINY,resolution:"".concat(d,"x").concat(_)});var f=De(d,_),h=Ue(p);o.min+=f.minBitrate*h,o.max+=f.maxBitrate*h}}))})),[2,{reqBody:{sdp:i,switchstream:!1,newVersionFlag:!0,subscribeList:e.map((function(e){return{simulcast:e.subTiny?Gn.TINY:Gn.NORMAL,resolution:"",uri:a._roomRes[e.track.getTrackId()].uri}}))},dynamicBitrate:o,offer:i}]}}))}))}}),Object.defineProperty(t.prototype,"_subscribeHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return void 0===r&&(r=!1),void 0===i&&(i=!1),s(this,void 0,void 0,(function(){var s,u,l,d,_,p;return c(this,(function(c){return s=Date.now(),u=i?Yo.SUB:void 0,l=this._logger.createTraceId(),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:t.map(Lt),forceReq:r}),l),this._assertRoomDestroyed()?(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),l),this._reportPubOrSubQualityData(s,t,exports.RCRTCCode.ROOM_HAS_BEEN_DESTROYED,u),[2,{code:exports.RCRTCCode.ROOM_HAS_BEEN_DESTROYED}]):e.validate("tracks",t,(function(){return e.isArray(t)&&t.length>0&&t.every((function(e){return e instanceof tt||e.track instanceof tt}))}),!0)?(this._pc.__reportR3R4ToPolaris(),this._pc.registerReportListener(this._reportListener),this._addPeerCEvent(),d=this._subscribedList.map((function(e){return a({},e)})),_=t.map((function(e){return e instanceof tt?{track:e}:e})),p=[],_.forEach((function(e){var t=e.track.getTrackId();p.push(t);var r=d.find((function(e){return e.track.getTrackId()===t}));r&&r.subTiny===e.subTiny||(r?r.subTiny=e.subTiny:d.push(e))})),this._polarisReport.sendR2(ko.SUBSCRIBE,Uo.BEGIN,p),[2,this._updateSubListHandle(d,l,s,u,!0)]):(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> tracks"}),l),this._reportPubOrSubQualityData(s,t,exports.RCRTCCode.PARAMS_ERROR,u),[2,{code:exports.RCRTCCode.PARAMS_ERROR}])}))}))}}),Object.defineProperty(t.prototype,"_addPeerCEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._pc.on(Eo.__INNER_EVENT_TRACK_READY__,(function(t){var r=t.streams[0].id,i=t.receiver.track,o=[r,"audio"===i.kind?exports.RCMediaType.AUDIO_ONLY:exports.RCMediaType.VIDEO_ONLY].join("_"),a=e._remoteTracks[o];a?(a.__innerSetMediaStreamTrack(i),e._logger.info(n.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackReady",trackId:a.getTrackId()})),e._callAppListener("onTrackReady",a)):e._logger.warn(n.L_AUDIENCE_LIVING_ROOM_ONTRACKREADY_O,"cannot found RCRemoteTrack: ".concat(i.id))})),this._pc.once(Eo.__INNER_ICE_CONNECTED__,(function(){e._reportMediaActionLogger.reportIceFirstConnectData("sub")}),this),this._pc.on(Eo.__INNER_ICE_STATE_CHANGE__,(function(t){var r=t.status,i=t.time,n=t.iceCandidatePair;n&&e._reportMediaActionLogger.recordQualityIceStatusData(n,r,i)}))}}),Object.defineProperty(t.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:exports.RTCMode.LIVE,UserId:e,"Session-Id":this._sessionId,"Client-Session-Id":this._clientSessionId}}}),Object.defineProperty(t.prototype,"_exchangeHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._service.broadcastSubscribe(this._getReqHeaders(),e)}}),Object.defineProperty(t.prototype,"_dealSubscribeResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i,a=this,s=null==t?void 0:t.map((function(e){return"".concat(e.msid,"_").concat(e.mediaType)})),c=e.filter((function(e){if(e.track.isMCUTrack()){var t=a._roomRes[e.track.getTrackId()],r="".concat(t.msid,"_").concat(t.mediaType);return s.includes(r)}return null==s?void 0:s.includes(e.track.getTrackId())})),u=null==c?void 0:c.map((function(e){return"".concat(e.track.getTrackId())})),_=e.filter((function(e){return!(null==u?void 0:u.includes(e.track.getTrackId()))})),p=function(e){var t=c.some((function(t){return t.track.getTrackId()===e}));f._remoteTracks[e].__innerSetSubscribed(t)},f=this;for(var h in this._remoteTracks)p(h);return(i=this._subscribedList).splice.apply(i,d([0,this._subscribedList.length],l(c),!1)),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:o.SUCCESSED,subSuccessTrackIds:s,failedList:_}),r),_}}),Object.defineProperty(t.prototype,"_getParams",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.map((function(e){return e instanceof tt?{track:e}:a({},e)})),r={};return t=t.filter((function(e){var t=e.track.getTrackId();return!r[t]&&(r[t]=!0,!0)})).map((function(e){return a({},e)}))}}),Object.defineProperty(t.prototype,"_reportPubOrSubQualityData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){i&&this._reportMediaActionLogger.reportPubOrSubQualityData(i,e,t,r,this._trackMediaMap)}}),Object.defineProperty(t.prototype,"_updateSubListHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,u){var l;return void 0===u&&(u=!1),s(this,void 0,void 0,(function(){var s,d,_,p,f,h,b,R,g,m,C,v,O=this;return c(this,(function(c){switch(c.label){case 0:return this._logger.info(n.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_T,JSON.stringify({trackIds:e.map(Lt),forceReq:u}),t),s=this._getParams(e),d=this._subscribedList.map((function(e){return a({},e)})),u||sa(s,d)?(this._pc.clearReTryExchangeTimer(),this._pc.updateSubRemoteTracks(s.map((function(e){return e.track}))),[4,this._createSubscribeParams(s,{},!1)]):(this._logger.info(n.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:o.SUCCESSED,msg:"repeat subscribe"}),t),[2,{code:exports.RCRTCCode.SUCCESS}]);case 1:return _=c.sent().reqBody,[4,this._exchangeHandle(_)];case 2:return p=c.sent(),d.length&&(f=[],d.forEach((function(e){f.push(e.track.getTrackId())})),null===(l=this._pc.reportParser)||void 0===l||l.clearLatestPacketsRecv(f)),e.forEach((function(e){var t=e instanceof tt?e.getTrackId():e.track.getTrackId();O._trackMediaMap[t]=p.qualityMsList||[]})),p.code!==exports.RCRTCCode.SUCCESS?(this._reportPubOrSubQualityData(r,e,p.code,i),this._logger.error(n.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:o.FAILED,code:p.code}),t),[2,{code:p.code}]):(h=p.data,b=h.sdp,R=h.resultCode,g=h.message,m=h.subscribedList,R!==exports.RCRTCCode.SUCCESS?(this._reportPubOrSubQualityData(r,e,R,i),this._logger.error(n.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:o.FAILED,code:R,msg:g}),t),[2,{code:R}]):(s.forEach((function(e){var t=e.track;if(t.isMCUTrack()){var r=O._roomRes[t.getTrackId()].msid,i=dt(t.getTrackId()),n=i.tag,o=[i.userId,n].join("_");b.sdp=b.sdp.replace(new RegExp(r,"g"),o)}})),[4,this._pc.setRemoteAnswer(b.sdp)]));case 3:return C=c.sent(),this._reportPubOrSubQualityData(r,e,C,i),C!==exports.RCRTCCode.SUCCESS?(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:o.FAILED,code:C,msg:"set remote answer error"}),t),[2,{code:C}]):[2,(v=this._dealSubscribeResult(s,m,t)).length?{code:exports.RCRTCCode.SUCCESS,failedList:v}:{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),Object.defineProperty(t.prototype,"_diffCDNUris",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,o;return c(this,(function(a){return this._CDNUris.url&&!e.url?(this._logger.info(n.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(n.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,i=this._CDNUris.h&&e.h&&this._CDNUris.h!==e.h,o=this._CDNUris.fps&&e.fps&&this._CDNUris.fps!==e.fps,(r||i||o)&&(this._logger.info(n.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(t.prototype,"_getCDNPlayUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,a,s,u,l,d,_,p,f,h,b,R,g,m,C;return c(this,(function(c){switch(c.label){case 0:return r=e.w,i=e.h,a=e.fps,s=this._initOptions.pullInnerCDNProtocol||exports.RCInnerCDNPullKind.FLV,u=this._initOptions.pullInnerCDNUseHttps===exports.RCInnerCDNPullIsHttps.NOT_HTTPS?exports.RCInnerCDNPullIsHttps.NOT_HTTPS:exports.RCInnerCDNPullIsHttps.HTTPS,this._CDNUris.url?(l={"App-Key":this._context.getAppkey(),Token:this._joinResData.token,RoomId:this.getRoomId(),UserId:this._crtUserId,SessionId:this.getSessionId()},d=[],_=this._CDNUris,p=_.w,f=void 0===p?0:p,h=_.h,f/(void 0===h?1:h)>1?(r&&d.push("w=".concat(r)),i&&d.push("h=".concat(i))):(r&&d.push("h=".concat(r)),i&&d.push("w=".concat(i))),a&&d.push("fps=".concat(a)),d.push("kind=".concat(s)),d.push("is_https=".concat(u)),b=d.join("&"),R="".concat(this._CDNUris.url,"?"),b&&(R+=b),[4,this._service.getCDNResourceInfo(l,R,t)]):(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.CDN_RESOURCE_IS_EMPTY,msg:"cdn_uris url is empty, the anchor need to open or push CDN"}),t),[2,{code:exports.RCRTCCode.CDN_RESOURCE_IS_EMPTY}]);case 1:return g=c.sent(),m=g.code,C=g.res,m!==exports.RCRTCCode.SUCCESS?[2,{code:m}]:[2,{code:m,CDNPlayUrl:null==C?void 0:C.data.pull_url}]}}))}))}}),Object.defineProperty(t.prototype,"getCDNPlayUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,a,s,u,l;return c(this,(function(c){return r=this._logger.createTraceId(),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_T,JSON.stringify({resolution:e,fps:t}),r),e&&!Rt(e)?(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> resolution"}),r),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):t&&!gt(t)?(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> fps"}),r),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(i=e?bt(e):{width:null,height:null},a=i.width,s=i.height,u=t?mt(t):null,l={},a&&(l.w=a),s&&(l.h=s),u&&(l.fps=u),[2,this._getCDNPlayUrl(l,r)])}))}))}}),Object.defineProperty(t.prototype,"subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t=this;return c(this,(function(r){return[2,Za((function(){return t._subscribeHandle(e,!1,!0)}),"audience-sub")]}))}))}}),Object.defineProperty(t.prototype,"__unsubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,s,u;return c(this,(function(c){return r=Date.now(),i=Yo.UNSUB,s=this._logger.createTraceId(),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_T,JSON.stringify({trackIds:t.map((function(e){return e.getTrackId()}))}),s),this._assertRoomDestroyed()?(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),s),[2,{code:exports.RCRTCCode.ROOM_HAS_BEEN_DESTROYED}]):e.validate("tracks",t,(function(){return e.isArray(t)&&t.length>0&&t.every((function(e){return e instanceof tt}))}),!0)?(u=this._subscribedList.map((function(e){return a({},e)})).filter((function(e){return t.every((function(t){return t.getTrackId()!==e.track.getTrackId()}))})),this._polarisReport.sendR2(ko.SUBSCRIBE,Uo.END,t.map((function(e){return e.getTrackId()}))),[2,this._updateSubListHandle(u,s,r,i,!1)]):(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> tracks"}),s),[2,{code:exports.RCRTCCode.PARAMS_ERROR}])}))}))}}),Object.defineProperty(t.prototype,"unsubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t=this;return c(this,(function(r){return[2,Za((function(){return t.__unsubscribe(e)}),"audience-unsub")]}))}))}}),Object.defineProperty(t.prototype,"__destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;return s(this,void 0,void 0,(function(){return c(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(t.prototype,"getRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._remoteTracks[e]}}),Object.defineProperty(t.prototype,"getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return{}}}),Object.defineProperty(t.prototype,"__onReconnected",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return t=this._logger.createTraceId(),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_T,void 0,t),[4,this._context.joinLivingRoomAsAudience(this._roomId,exports.RTCMode.LIVE)];case 1:return r.sent().code!==e.ErrorCode.SUCCESS&&this._logger.error(n.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,"status: ".concat(o.FAILED),t),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,"status: ".concat(o.SUCCESSED),t),[2]}}))}))}}),Object.defineProperty(t.prototype,"registerRoomEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._appListener=e}}),Object.defineProperty(t.prototype,"onAudioLevelChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(n.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O),this._audioLevelReport.onAudioLevelChange(e)}}),Object.defineProperty(t.prototype,"registerReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._reportListener=e}}),Object.defineProperty(t.prototype,"getRoomId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._roomId}}),Object.defineProperty(t.prototype,"getCrtUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._crtUserId}}),Object.defineProperty(t.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._sessionId}}),Object.defineProperty(t.prototype,"getRemoteUserIds",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._roomAnchorList}}),Object.defineProperty(t.prototype,"getRemoteTracksByUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=[];for(var r in this._remoteTracks){var i=this._remoteTracks[r];i.getUserId()===e&&t.push(i)}return t}}),Object.defineProperty(t.prototype,"getRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=[],r=[];for(var i in this._remoteTracks){if(2===r.length)break;var n=this._remoteTracks[i];n.isMCUTrack()&&r.push(n)}return this._roomAnchorList.forEach((function(r){t.push.apply(t,d([],l(e.getRemoteTracksByUserId(r)),!1))})),d(d([],l(r),!1),l(t),!1)}}),Object.defineProperty(t.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(t.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(t.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(t.prototype,"getClientSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._clientSessionId}}),t}();!function(e){e[e.AUTOMATIC=0]="AUTOMATIC",e[e.MANUAL=1]="MANUAL"}($a||($a={}));var rs,is,ns=function(){function t(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(t.prototype,"_getMediaStream",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===t&&(t="getUserMedia"),s(this,void 0,void 0,(function(){var r,i,o;return c(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),r=this.setConstraintsConfig(e),[4,navigator.mediaDevices[t](r)];case 1:return i=a.sent(),[2,{code:exports.RCRTCCode.SUCCESS,stream:i}];case 2:return o=a.sent(),this._logger.error(n.L_GET_MEDIA_STREAM_E,JSON.stringify({name:o.name,message:o.message})),"Permission denied"===o.message?[2,{code:exports.RCRTCCode.BROWSER_PERMISSION_DENIED}]:"Permission denied by system"===o.message?[2,{code:exports.RCRTCCode.SYSTEM_PERMISSION_DENIED}]:[3,3];case 3:return[2,{code:"getUserMedia"===t?exports.RCRTCCode.GET_USER_MEDIA_FAILED:exports.RCRTCCode.GET_DISPLAY_MEDIA_FAILED}]}}))}))}}),Object.defineProperty(t.prototype,"_getMediaStreamErrorReason",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t="";return e===exports.RCRTCCode.BROWSER_PERMISSION_DENIED&&(t="Permission denied"),e===exports.RCRTCCode.SYSTEM_PERMISSION_DENIED&&(t="Permission denied by system"),t}}),Object.defineProperty(t.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 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(n.L_SET_AUDIO_CONSTRAINTS_O,"browser supported -> ".concat(JSON.stringify(i)))}return e}}),Object.defineProperty(t.prototype,"createMicrophoneAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===e&&(e="RongCloudRTC"),s(this,void 0,void 0,(function(){var r,i,a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return at(e)?(r=this._context.getCurrentId())?[4,this._getMediaStream({audio:{deviceId:(null==t?void 0:t.micphoneId)?{exact:null==t?void 0:t.micphoneId}:void 0,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(n.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:exports.RCRTCCode.INVALID_USER_ID}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),[2,{code:exports.RCRTCCode.INVALID_TAGS}]);case 1:return i=c.sent(),a=i.stream,(s=i.code)!==exports.RCRTCCode.SUCCESS?(this._logger.error(n.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:o.FAILED,code:s,msg:this._getMediaStreamErrorReason(s)})),[2,{code:s}]):(u=a.getAudioTracks()[0],l=new Ze(this._logger,e,r,u),this._logger.info(n.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:o.SUCCESSED,trackId:l.getTrackId()})),[2,{code:s,track:l}])}}))}))}}),Object.defineProperty(t.prototype,"createCameraVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===e&&(e="RongCloudRTC"),s(this,void 0,void 0,(function(){var r,i,a,s,u,l,d,_,p,f;return c(this,(function(c){switch(c.label){case 0:return at(e)?(r=this._context.getCurrentId())?(i=Rt(null==t?void 0:t.resolution)?t.resolution:exports.RCResolution.W640_H480,a=bt(i),s=a.width,u=a.height,[4,this._getMediaStream({video:{deviceId:(null==t?void 0:t.cameraId)?{exact:null==t?void 0:t.cameraId}:void 0,frameRate:mt((null==t?void 0:t.frameRate)||exports.RCFrameRate.FPS_15),width:{ideal:s,max:s},height:{ideal:u,max:u},facingMode:null==t?void 0:t.faceMode}})]):(this._logger.error(n.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:exports.RCRTCCode.INVALID_USER_ID}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),[2,{code:exports.RCRTCCode.INVALID_TAGS}]);case 1:return l=c.sent(),d=l.stream,(_=l.code)!==exports.RCRTCCode.SUCCESS?(this._logger.error(n.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,code:_,msg:this._getMediaStreamErrorReason(_)})),[2,{code:_}]):(p=d.getVideoTracks()[0],[4,this._applyVideoAspectRatio(p,s,u)]);case 2:return c.sent(),f=new Xe(this._logger,e,r,p),this._logger.info(n.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:o.SUCCESSED,trackId:f.getTrackId()})),[2,{code:_,track:f}]}}))}))}}),Object.defineProperty(t.prototype,"createMicrophoneAndCameraTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return void 0===e&&(e="RongCloudRTC"),s(this,void 0,void 0,(function(){var i,a,s,u,l,d,_,p,f,h,b,R,g,m;return c(this,(function(c){switch(c.label){case 0:return i=[],at(e)?(a=this._context.getCurrentId())?(s=Rt(null===(r=null==t?void 0:t.video)||void 0===r?void 0:r.resolution)?t.video.resolution:exports.RCResolution.W640_H480,u=bt(s),l=u.width,d=u.height,_=null==t?void 0:t.audio,p=null==t?void 0:t.video,[4,this._getMediaStream({video:{deviceId:(null==p?void 0:p.cameraId)?{exact:null==p?void 0:p.cameraId}:void 0,frameRate:mt((null==p?void 0:p.frameRate)||exports.RCFrameRate.FPS_15),width:{ideal:l,max:l},height:{ideal:d,max:d},facingMode:null==p?void 0:p.faceMode},audio:{deviceId:(null==_?void 0:_.micphoneId)?{exact:null==_?void 0:_.micphoneId}:void 0,sampleRate:null==_?void 0:_.sampleRate,noiseSuppression:null==_?void 0:_.noiseSuppression,echoCancellation:null==_?void 0:_.echoCancellation,autoGainControl:null==_?void 0:_.autoGainControl}})]):(this._logger.error(n.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:exports.RCRTCCode.INVALID_USER_ID,tracks:i}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),[2,{code:exports.RCRTCCode.INVALID_TAGS,tracks:i}]);case 1:if(f=c.sent(),h=f.stream,(b=f.code)!==exports.RCRTCCode.SUCCESS)return this._logger.error(n.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:o.FAILED,code:b,msg:this._getMediaStreamErrorReason(b)})),[2,{code:b,tracks:i}];R=h.getTracks(),g=0,c.label=2;case 2:return g<R.length?"video"!==(m=R[g]).kind?[3,4]:[4,this._applyVideoAspectRatio(m,l,d)]:[3,6];case 3:return c.sent(),i.push(new Xe(this._logger,e,a,m)),[3,5];case 4:i.unshift(new Ze(this._logger,e,a,m)),c.label=5;case 5:return g++,[3,2];case 6:return this._logger.info(n.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:o.SUCCESSED,trackIds:i.map((function(e){return e.getTrackId()}))})),[2,{code:b,tracks:i}]}}))}))}}),Object.defineProperty(t.prototype,"createScreenVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===e&&(e="screenshare"),s(this,void 0,void 0,(function(){var r;return c(this,(function(i){switch(i.label){case 0:return[4,this._createScreenTracks(e,!1,n.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,t)];case 1:return(r=i.sent()).code===exports.RCRTCCode.SUCCESS?[2,{code:r.code,track:r.tracks[0]}]:[2,r]}}))}))}}),Object.defineProperty(t.prototype,"createScreenWithAudioTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===e&&(e="screenshare"),s(this,void 0,void 0,(function(){return c(this,(function(r){return[2,this._createScreenTracks(e,!0,n.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_AND_AUDIO_TRACKS_O,t)]}))}))}}),Object.defineProperty(t.prototype,"_createScreenTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){return s(this,void 0,void 0,(function(){var a,s,u,l,d,_,p,f,h,b,R,g;return c(this,(function(c){switch(c.label){case 0:return at(e)?(a=this._context.getCurrentId())?Ot()?(s=/macintosh|mac os x/i.test(navigator.userAgent),u=(!this._isElectron||!s)&&t,l=Rt(null==i?void 0:i.resolution)?i.resolution:exports.RCResolution.W1280_H720,this._isElectron?[4,this._createElectronScreenStream(t,r,l,null==i?void 0:i.chromeMediaSourceId)]:[3,2]):(this._logger.error(n.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.BROWSER_NOT_SUPPORT,msg:"browser not support"})),[2,{code:exports.RCRTCCode.BROWSER_NOT_SUPPORT}]):(this._logger.error(r,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:exports.RCRTCCode.INVALID_USER_ID}]):(this._logger.error(r,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),[2,{code:exports.RCRTCCode.INVALID_TAGS}]);case 1:return f=c.sent(),[3,4];case 2:return[4,this._createWebScreenStream(t,l,null==i?void 0:i.frameRate)];case 3:f=c.sent(),c.label=4;case 4:return _=(d=f).stream,(p=d.code)!==exports.RCRTCCode.SUCCESS?(this._logger.error(r,JSON.stringify({status:o.FAILED,code:p,msg:this._getMediaStreamErrorReason(p)})),[2,{code:p}]):(h=_.getVideoTracks()[0],b=new $e(this._logger,e,a,h),R=[b],u&&(g=_.getAudioTracks()[0])&&R.push(new et(this._logger,e,a,g)),this._logger.info(r,JSON.stringify({status:o.SUCCESSED,trackIds:R.map((function(e){return e.getTrackId()}))})),[2,{code:p,tracks:R}])}}))}))}}),Object.defineProperty(t.prototype,"_createElectronScreenStream",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,n){var a,u;return s(this,void 0,void 0,(function(){var s,l,d,_,p,f,h;return c(this,(function(c){return s=/macintosh|mac os x/i.test(navigator.userAgent),this._isElectron&&s&&t&&this._logger.warn(r,JSON.stringify({status:o.INFO,code:exports.RCRTCCode.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO,msg:"mac in electron not support screen share with audio"})),l=(!this._isElectron||!s)&&t,!this._isElectron||e.isUndefined(n)||e.isString(n)?(d=bt(i),_=d.width,p=d.height,f={mandatory:{chromeMediaSourceId:n,chromeMediaSource:"desktop",minWidth:_,maxWidth:_,minHeight:p,maxHeight:p}},!n&&this._isElectron&&(null===(a=f.mandatory)||void 0===a||delete a.chromeMediaSourceId),h=null,l&&this._isElectron&&(null===(u=f.mandatory)||void 0===u||delete u.chromeMediaSourceId,h={mandatory:{chromeMediaSource:"desktop"}}),[2,this._getMediaStream({video:f,audio:h||l},"getUserMedia")]):(this._logger.error(r,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> options.chromeMediaSourceId type is string"})),[2,{code:exports.RCRTCCode.PARAMS_ERROR}])}))}))}}),Object.defineProperty(t.prototype,"_createWebScreenStream",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n,o,a;return c(this,(function(s){return i=bt(t),n=i.width,o=i.height,a={frameRate:mt(r||exports.RCFrameRate.FPS_15),width:n,height:o},[2,this._getMediaStream({video:a,audio:e},"getDisplayMedia")]}))}))}}),Object.defineProperty(t.prototype,"createLocalAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i;return c(this,(function(a){return at(e)?t&&"[object MediaStreamTrack]"===t.toString()&&"audio"===t.kind?(r=this._context.getCurrentId())?(i=new We(this._logger,e,r,t),this._logger.info(n.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:o.SUCCESSED,trackId:i.getTrackId()})),[2,{code:exports.RCRTCCode.SUCCESS,track:i}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:exports.RCRTCCode.INVALID_USER_ID}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not audio"})),[2,{code:exports.RCRTCCode.CREATE_CUSTOM_TRACK_FAILED}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),[2,{code:exports.RCRTCCode.INVALID_TAGS}])}))}))}}),Object.defineProperty(t.prototype,"createLocalVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i;return c(this,(function(a){return at(e)?t&&t instanceof MediaStreamTrack&&"video"===t.kind?(r=this._context.getCurrentId())?(i=new Ye(this._logger,e,r,t),this._logger.info(n.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:o.SUCCESSED,trackId:i.getTrackId()})),[2,{code:exports.RCRTCCode.SUCCESS,track:i}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:exports.RCRTCCode.INVALID_USER_ID}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not video"})),[2,{code:exports.RCRTCCode.CREATE_CUSTOM_TRACK_FAILED}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),[2,{code:exports.RCRTCCode.INVALID_TAGS}])}))}))}}),Object.defineProperty(t.prototype,"_validateCreateLocalFileTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){if(!at(t))return this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),{code:exports.RCRTCCode.INVALID_TAGS,tracks:[]};if(!vt())return this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.BROWSER_NOT_SUPPORT,msg:"browser not support"})),{code:exports.RCRTCCode.BROWSER_NOT_SUPPORT,tracks:[]};var i=r instanceof File?URL.createObjectURL(r):r;return e.isHttpUrl(i)||/^blob:/.test(i)?this._context.getCurrentId()?{code:exports.RCRTCCode.SUCCESS,tracks:[],url:i}:(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:exports.RCRTCCode.INVALID_USER_ID,tracks:[]}):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> file"})),{code:exports.RCRTCCode.PARAMS_ERROR,tracks:[]})}}),Object.defineProperty(t.prototype,"createLocalFileTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i){return s(this,void 0,void 0,(function(){var a,s,u=this;return c(this,(function(c){return(a=this._validateCreateLocalFileTracks(e,r)).code!==exports.RCRTCCode.SUCCESS?[2,a]:(s=this._context.getCurrentId(),[2,new Promise((function(r){var c=document.createElement("video");(null==i?void 0:i.withoutAudio)&&(c.muted=!0),c.onloadedmetadata=function(){var a,d=[];try{var _=c.mozCaptureStream?"mozCaptureStream":"captureStream";a=c[_]()}catch(e){u._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.CREATE_FILE_TRACK_FAILED,msg:"captureSteam error -> ".concat(JSON.stringify(e))})),r({code:exports.RCRTCCode.CREATE_FILE_TRACK_FAILED,tracks:d})}var p=l(t.getTracksWithOptions(a,i),2),f=p[0],h=p[1];f&&d.push(new Qe(u._logger,e,s,f,c)),h&&d.push(new qe(u._logger,e,s,h,c)),0===d.length&&(c.pause(),c.src=""),c.onerror=null,u._logger.info(n.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:o.SUCCESSED,trackIds:d.map((function(e){return e.getTrackId()}))})),r({code:exports.RCRTCCode.SUCCESS,tracks:d})},c.onerror=function(){u._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.CREATE_FILE_TRACK_FAILED,msg:"Failed to create file stream, video onerror"})),r({code:exports.RCRTCCode.CREATE_FILE_TRACK_FAILED,tracks:[]})},c.src=a.url,c.loop=!0,c.play()}))])}))}))}}),Object.defineProperty(t.prototype,"createLocalTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i){return s(this,void 0,void 0,(function(){var a,s,u,d,_;return c(this,(function(c){return a=[],at(e)?r instanceof MediaStream?(s=this._context.getCurrentId())?(u=l(t.getTracksWithOptions(r,i),2),d=u[0],_=u[1],d&&a.push(new We(this._logger,e,s,d)),_&&a.push(new Ye(this._logger,e,s,_)),this._logger.info(n.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:o.SUCCESSED,trackIds:a.map((function(e){return e.getTrackId()}))})),[2,{code:exports.RCRTCCode.SUCCESS,tracks:a}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:exports.RCRTCCode.INVALID_USER_ID,tracks:a}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> stream"})),[2,{code:exports.RCRTCCode.PARAMS_ERROR,tracks:a}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),[2,{code:exports.RCRTCCode.INVALID_TAGS,tracks:a}])}))}))}}),Object.defineProperty(t,"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(t.prototype,"_applyVideoAspectRatio",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,s,u,l,d;return c(this,(function(c){switch(c.label){case 0:if(i=e.getSettings(),s=i.width,u=i.height,s===t&&u===r)return[2];l=t/r>=1?{width:{ideal:s,max:s}}:{height:{ideal:u,max:u}},c.label=1;case 1:return c.trys.push([1,3,,4]),[4,e.applyConstraints(a(a({},l),{aspectRatio:{ideal:t/r}}))];case 2:return c.sent(),this._logger.info(n.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:o.SUCCESSED,msg:"apply aspectRatio success -> ".concat(t," / ").concat(r)})),[3,4];case 3:return d=c.sent(),this._logger.warn(n.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:o.FAILED,msg:"apply aspectRatio error -> ".concat(JSON.stringify(d))})),[3,4];case 4:return[2]}}))}))}}),t}(),os=function(t){function i(e,r,i){var n=t.call(this,e)||this;return Object.defineProperty(n,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(n,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"_options",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(n,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"_crtRoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(n,"_audience",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(n,"_crtAudienceLivingRoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),go.setSdpSemantics(i.sdpSemantics||"unified-plan",n._logger),n._service=new Qn(n._runtime,n._context,n._options.mediaServer,n._options.timeout),n._context.registerConnectionStateChangeListener(n._onIMStatusChange.bind(n)),n._context.registerDestroyListener(n._onIMUninit.bind(n)),n._context.registerMessageListener(n._handleMessage.bind(n)),n._context.getPluginContext().onnavidatachange=n.naviDataChange.bind(n),n}return r(i,t),Object.defineProperty(i.prototype,"_handleMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(t.conversationType!==e.ConversationType.RTC_ROOM)return!1;var r=this._logger.createTraceId();this._crtRoom instanceof Ya&&this._getJoinedPKRoomList().forEach((function(e){e.__parseInnerMessage(t,r)}));return this._logger.info(n.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:o.SUCCESSED,message:t}),r),this._crtRoom?(this._crtRoom.__parseInnerMessage(t,r),!0):(this._logger.warn(n.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:o.FAILED,message:"the crtRoom is empty"}),r),!0)}}),Object.defineProperty(i.prototype,"naviDataChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(n.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(i.prototype,"_getJoinedPKRoomList",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._crtRoom.getRoomPKHandler(),t=e.code,r=e.roomPKHandler;if(t===exports.RCRTCCode.SUCCESS&&r){var i=r.getJoinedPKRooms()||{};return Object.values(i)}return[]}}),Object.defineProperty(i.prototype,"getCurrentId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._context.getCurrentId()}}),Object.defineProperty(i.prototype,"joinCrossRTCRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n){return void 0===n&&(n=exports.RTCMode.CROSS_MUTI),s(this,void 0,void 0,(function(){return c(this,(function(i){return console.warn("joinCrossRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),[2,this.joinRTCRoomWithOptions(e,{joinType:t,userData:r,mode:exports.RTCMode.CROSS_MUTI})]}))}))}}),Object.defineProperty(i.prototype,"joinRTCRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n){return void 0===n&&(n=exports.RTCMode.RTC),s(this,void 0,void 0,(function(){return c(this,(function(i){return console.warn("joinRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),[2,this.joinRTCRoomWithOptions(e,{mode:n,joinType:t,userData:r})]}))}))}}),Object.defineProperty(i.prototype,"joinRTCRoomWithOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,a,s=this;return c(this,(function(c){switch(c.label){case 0:return r=this._logger.createTraceId(),this._logger.info(n.L_RTC_CLIENT_JOIN_RTC_ROOM_T,JSON.stringify({roomId:e,options:t}),r),this._crtRoom?(this._logger.error(n.L_RTC_CLIENT_JOIN_RTC_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),r),[2,{code:exports.RCRTCCode.REPERT_JOIN_ROOM}]):[4,(i=this._crtRoom=new za(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)||exports.RTCMode.RTC,null==t?void 0:t.joinType,void 0,void 0,null==t?void 0:t.userData,r)];case 1:return(a=c.sent().code)!==exports.RCRTCCode.SUCCESS?(this._crtRoom=null,[2,{code:a}]):(i.once(wa,(function(){s._crtRoom=null})),[2,{code:a,room:i,userIds:i.getRemoteUserIds(),tracks:i.getRemoteTracks()}])}}))}))}}),Object.defineProperty(i.prototype,"joinLivingRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,a){return s(this,void 0,void 0,(function(){var a,s,u,l,d=this;return c(this,(function(c){switch(c.label){case 0:return a=this._logger.createTraceId(),this._logger.info(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_T,JSON.stringify({roomId:e,livingType:t,joinType:r,outerUserDatas:i}),a),this._crtRoom?(this._logger.error(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REPERT_JOIN_ROOM,msg:"Join the room repeatedly -> roomId: ".concat(e)}),a),[2,{code:exports.RCRTCCode.REPERT_JOIN_ROOM}]):[4,(s=this._crtRoom=new Ya(this._context,this._runtime,e,this._service,this._options,t,!1,!0)).__innerInit(exports.RTCMode.LIVE,r,t,void 0,i,a)];case 1:return(u=c.sent().code)!==exports.RCRTCCode.SUCCESS?(this._crtRoom=null,[2,{code:u}]):(s.once(wa,(function(){d._crtRoom=null})),l={code:u,room:s,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()},s.__getCDNPushMode()===$a.MANUAL&&Object.assign(l,{CDNEnable:s.__getCDNEnable()}),[2,l])}}))}))}}),Object.defineProperty(i.prototype,"getAudienceClient",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._audience||(this._audience=new Xa(this._context,this._runtime,this._options)),this._logger.info(n.L_RTC_CLIENT_GET_AUDIENCE_CLIENT_O),this._audience}}),Object.defineProperty(i.prototype,"_onIMStatusChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){if(this._logger.info(n.L_RTC_CLIENT_IM_CONNECTION_STATE_S,JSON.stringify({status:t,code:r,desc:e.RCConnectionStatus[t]})),t===e.RCConnectionStatus.SUSPENDED&&r===e.ErrorCode.RC_CONN_REDIRECTED&&this._service.clearMSList(),t===e.RCConnectionStatus.DISCONNECTED){if(this._crtRoom){var i=exports.RCKickReason.IM_DISCONNECTED;r===e.ErrorCode.RC_DISCONN_KICK?i=exports.RCKickReason.OTHER_CLIENT_IM_CONNECTED:2===r&&(i=exports.RCKickReason.IM_LOGOUT),this._crtRoom.__kickoff(!0,{users:[{userId:this._context.getCurrentId(),type:i}]})}}else if(t===e.RCConnectionStatus.CONNECTED){if(this._service.isNededDetector()&&this._service.detectorMediaSever(),this._crtRoom instanceof Ya)this._getJoinedPKRoomList().forEach((function(e){e.__onReconnected()}));this._crtRoom&&this._crtRoom.__onReconnected()}}}),Object.defineProperty(i.prototype,"_onIMUninit",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;this._logger.info(n.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(i.prototype,"leaveRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;return s(this,void 0,void 0,(function(){var r;return c(this,(function(i){switch(i.label){case 0:return r=this._logger.createTraceId(),this._logger.info(n.L_RTC_CLIENT_LEAVE_ROOM_T,JSON.stringify({roomId:e.getRoomId()}),r),this._crtRoom?[4,this._crtRoom.__destroy(!0)]:(this._logger.warn(n.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:o.FAILED,msg:"Room does not exist, without leave"}),r),[2,{code:exports.RCRTCCode.SUCCESS}]);case 1:return i.sent(),this._service.isNededDetector()&&this._service.detectorMediaSever(),this._logger.info(n.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,[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),Object.defineProperty(i.prototype,"joinLivingRoomAsAudience",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var i,a,s,u,l,d;return c(this,(function(c){switch(c.label){case 0:return i=this._logger.createTraceId(),this._logger.info(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_T,JSON.stringify({roomId:t,livingType:r}),i),this._service.isNededDetector()&&this._service.detectorMediaSever(),St(this._context.getNaviInfo())?(this._logger.error(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),i),[2,{code:exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR}]):e.validate("roomId",t,e.notEmptyString,!0)&&e.validate("livingType",r,(function(e){return e===exports.RCLivingType.AUDIO||e===exports.RCLivingType.VIDEO}))?this._crtAudienceLivingRoom?(this._logger.error(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),i),[2,{code:exports.RCRTCCode.REPERT_JOIN_ROOM}]):this._service.getMsList().length?[4,this._context.joinLivingRoomAsAudience(t,exports.RTCMode.LIVE,r)]:(this._logger.error(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),i),[2,{code:exports.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER}]):(this._logger.error(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> roomId or livingType"}),i),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return a=c.sent(),s=a.code,u=a.data,s!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.FAILED,code:s,msg:"signal error -> audience join room"}),i),[2,{code:exports.RCRTCCode.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED}]):(l=Kn(),d=new ts(this._context,this._runtime,this._options,t,u,r,l),this._crtAudienceLivingRoom=d,this._logger.info(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.SUCCESSED,roomData:u}),i),[2,{room:d,code:exports.RCRTCCode.SUCCESS,userIds:d.getRemoteUserIds(),RTCTracks:d.getRemoteRTCTracks(),MCUTracks:d.getRemoteMCUTracks(),CDNUris:d.getCDNInfo()}])}}))}))}}),Object.defineProperty(i.prototype,"leaveLivingRoomAsAudience",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return t=this._logger.createTraceId(),this._logger.info(n.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(n.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> room"}),t),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):[4,this._crtAudienceLivingRoom.__destroy(!0)]:(this._logger.warn(n.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.FAILED,msg:"Room does not exist, without leave"}),t),[2,{code:exports.RCRTCCode.SUCCESS}]);case 1:return r.sent(),this._crtAudienceLivingRoom=null,this._logger.info(n.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.SUCCESSED}),t),[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),Object.defineProperty(i.prototype,"upgradeToAnchorRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,a,s,u,l=this;return c(this,(function(c){switch(c.label){case 0:return r=this._logger.createTraceId(),this._logger.info(n.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_T,void 0,r),e.validate("room",t,(function(){return t instanceof ts}),!0)?(i=t.getRoomId(),this._crtRoom?(this._logger.error(n.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REPERT_JOIN_ROOM,msg:"Join the room repeatedly",roomId:i}),r),[2,{code:exports.RCRTCCode.REPERT_JOIN_ROOM}]):[4,(a=this._crtRoom=new Ya(this._context,this._runtime,i,this._service,this._options,t.livingType,!0,!0,t.getClientSessionId())).__innerInitByIdentityChange(r)]):(this._logger.error(n.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> room"}),r),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return(s=c.sent())!==e.ErrorCode.SUCCESS?(this._crtRoom=null,[2,{code:s}]):(a.once(wa,(function(){l._crtRoom=null})),[4,this._crtAudienceLivingRoom.__destroy(!1)]);case 2:return c.sent(),this._crtAudienceLivingRoom=null,u={room:a,code:exports.RCRTCCode.SUCCESS,userIds:a.getRemoteUserIds(),tracks:a.getRemoteTracks()},a.__getCDNPushMode()===$a.MANUAL&&Object.assign(u,{CDNEnable:a.__getCDNEnable()}),[2,u]}}))}))}}),Object.defineProperty(i.prototype,"downgradeToAudienceRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return r=this._logger.createTraceId(),this._logger.info(n.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_T,JSON.stringify({roomId:t._roomId,userId:this._context.getCurrentId()}),r),t.isMainRoom()?e.validate("room",t,(function(){return t instanceof Ya}),!0)?this._crtAudienceLivingRoom?(this._logger.error(n.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),r),[2,{code:exports.RCRTCCode.REPERT_JOIN_ROOM}]):[4,this._context.rtcIdentityChange(t._roomId,Ja.AnchorToViewer,t.getLivingType())]:(this._logger.error(n.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> room"}),r),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(this._logger.error(n.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"the `downgradeToAudienceRoom` is disabled in PK room"}),r),[2,{code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM}]);case 1:return i=c.sent(),a=i.code,s=i.data,a!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}),r),[2,{code:exports.RCRTCCode.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}]):(this._logger.info(n.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:o.SUCCESSED,roomData:s}),r),u=t.getClientSessionId(),l=new ts(this._context,this._runtime,this._options,t._roomId,s,t.getLivingType(),u),this._crtAudienceLivingRoom=l,this._crtRoom.__destroy(!1),this._crtRoom=null,[2,{room:l,code:exports.RCRTCCode.SUCCESS,userIds:l.getRemoteUserIds(),RTCTracks:l.getRemoteRTCTracks(),MCUTracks:l.getRemoteMCUTracks(),CDNUris:l.getCDNInfo()}])}}))}))}}),Object.defineProperty(i.prototype,"getJoinedRoomInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var t,r,i,a,s;return c(this,(function(c){switch(c.label){case 0:return t=this._logger.createTraceId(),r=this._context.getCurrentId(),this._logger.error(n.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_T,JSON.stringify({userId:r}),t),[4,this._context.getRTCJoinedUserInfo(r)];case 1:return i=c.sent(),a=i.code,s=i.data,a!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:o.FAILED,code:a}),t),[2,{code:a}]):(this._logger.info(n.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:o.SUCCESSED,roomInfo:s}),t),[2,{code:exports.RCRTCCode.SUCCESS,data:s}])}}))}))}}),i}(ns);exports.RTCJoinType=void 0,(rs=exports.RTCJoinType||(exports.RTCJoinType={}))[rs.KICK=0]="KICK",rs[rs.REFUSE=1]="REFUSE";var as,ss="rtcRJoin_data",cs="rtcRExit",us="rtcRInfo",ls="rtcUData",ds="rtcUDel",_s="rtcSetData",ps="userSetData",fs="rtcQryData",hs="rtcDelData",bs="rtcToken",Rs="rtcUserState",gs="rtcUList",ms="viewerJoinR",Cs="viewerExitR",vs="rtcPullKv",Os="rtcIdentityChange",Ts="rtcInvite",Es="rtcCancelInvite",Is="rtcInviteAnswer",Ss="rtcEndInvite",ys="rtcQueryJoined",Ls="rtcPullRoomStatus",Ps="reportsdk",As="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"}(as||(as={}));var Ns,ws=((is={})[as.RtcInput]=["roomType","broadcastType","extraInnerData","needSysChatroom","identityChangeType","joinType","innerDatas","outerDatas","supportNtf"],is[as.RtcOutput]=["version"],is[as.RtcUserListOutput]=["users","token","sessionId","roomInfo","version"],is[as.SetUserStatusInput]=["status"],is[as.RtcSetDataInput]=["interior","target","key","value","objectName","content"],is[as.RtcUserSetDataInput]=["valueInfo","objectName","content"],is[as.RtcDataInput]=["interior","target","key","objectName","content"],is[as.RtcSetOutDataInput]=["target","valueInfo","objectName","content"],is[as.MCFollowInput]=["state"],is[as.RtcTokenOutput]=["rtcToken"],is[as.RtcQryOutput]=["outInfo"],is[as.RtcQryUserOutDataInput]=["userId"],is[as.RtcUserOutDataOutput]=["user"],is[as.RtcQueryListInput]=["order"],is[as.RtcRoomInfoOutput]=["roomId","roomData","userCount","list"],is[as.RtcValueInfo]=["key","value"],is[as.RtcKeyDeleteInput]=["key"],is[as.RtcNotifyMsg]=["type","time","roomId"],is[as.RtcPullKV]=["timestamp","roomId"],is[as.RtcKVOutput]=["entries","bFullUpdate","syncTime"],is[as.RtcQueryUserJoinedInput]=["userId"],is[as.RtcQueryUserJoinedOutput]=["info"],is[as.RtcInviteInput]=["invitedUserId","timeoutTime","invitedRoomId","inviteInfo","inviteSessionId"],is[as.RtcCancelInviteInput]=["invitedUserId","invitedRoomId","inviteInfo","inviteSessionId"],is[as.RtcInviteAnswerInput]=["inviteUserId","answerCode","inviteRoomId","inviteSessionId","content","key","value"],is[as.RtcEndInviteInput]=["inviteRoomId","inviteSessionId","inviteContent","inviteRoomKeys"],is[as.RtcRoomStatusInput]=["version"],is[as.RtcRoomStatusOutput]=["bFullStatus","version","usersData","roomStatus"],is[as.RtcReportSDKInput]=["sdkInfo"],is[as.RtcPBPolaris]=["type","appKey","sessionId","roomId","roomCreateTime","userId","userRole","joinTime","signalDataCenter","r1Info","r2Info","r3Info","r4Info"],is[as.RtcPBR1Info]=["joinTime","rtcVersion","imVersion","platform","device","os","browserName","browserVersion"],is[as.RtcPBR2Info]=["joinTime","sendTime","rtcActionType","rtcActionStatus","trackId"],is[as.RtcPBR3Info]=["info"],is[as.RtcPBR4Info]=["info"],is[as.RtcPBStatusInfo]=["joinTime","receiveTime","totalBitRate","appCPUUsage","systemCPUUsage","systemCPUFrequency","networkStatus","googleRTTNetwork","ipAddress","useReceiveBroadBand","useSendBroadBand","packetLossCount","streams"],is[as.RtcPBStreamInfo]=["trackId","codeName","volume","samplingRate","bitRate","packetLossRate","frameRate","resolution","blockTime","jitterData","nAckCount","pliCount","googleRTTTotalTime","isReceiveFirstFrameRate","codeType","isEnabled"],is),Ds="\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(as.SetUserStatusInput,"\n {\n optional int32 status=1;\n }\n message ").concat(as.MCFollowInput,"\n {\n required string state = 1;\n }\n message ").concat(as.RtcQueryListInput,"{\n optional int32 order=1;\n }\n message ").concat(as.RtcKeyDeleteInput,"{\n repeated string key=1;\n }\n message ").concat(as.RtcValueInfo,"{\n required string key=1;\n required string value=2;\n }\n message RtcUserInfo{\n required string userId=1;\n repeated ").concat(as.RtcValueInfo," userData=2; //用户资源信息\n }\n message ").concat(as.RtcRoomStatusInput,"{ // rtc 和 living room 拉房间资源状态使用的参数\n required int64 version =1; //当前客户端最大的房间状态的version\n }\n message ").concat(as.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(as.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(as.RtcValueInfo," roomData = 2;\n optional int32 userCount = 3;\n repeated RtcUserInfo list=4;\n }\n message ").concat(as.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(as.RtcValueInfo," innerDatas = 7; //用户内部inner数据,角色或者连麦信息等\n repeated ").concat(as.RtcValueInfo," outerDatas = 8; //用户内部outer数据,自定义数据结构RtcInput。\n optional bool supportNtf = 9; //是否支持房间状态的变更通过通知拉取的方式获取\n }\n message ").concat(as.RtcQryOutput,"{\n repeated ").concat(as.RtcValueInfo," outInfo=1;\n }\n message ").concat(as.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(as.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(as.RtcUserSetDataInput," {\n repeated ").concat(as.RtcValueInfo," valueInfo = 1;\n required string objectName = 2;\n repeated ").concat(as.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(as.RtcTokenOutput,"{\n required string rtcToken=1;\n }\n message ").concat(as.RtcSetOutDataInput,"{\n required targetType target=1;\n repeated ").concat(as.RtcValueInfo," valueInfo=2;\n optional string objectName=3;\n optional string content=4;\n }\n message ").concat(as.RtcQryUserOutDataInput,"{\n repeated string userId = 1;\n }\n message ").concat(as.RtcUserOutDataOutput,"{\n repeated RtcUserInfo user = 1;\n }\n message ").concat(as.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(as.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(as.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(as.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(as.RtcQueryUserJoinedOutput,"\n {\n repeated RtcJoinedInfo info = 1;\n }\n message ").concat(as.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(as.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(as.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(as.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(as.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(as.RtcReportSDKInput,' {\n required string sdkInfo=1; // 用户集成的 sdk 信息,json 格式 {"web-rtc": "4.0.3.7"}\n }\n // ---- 北极星数据上报 -------\n message ').concat(as.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(as.RtcPBR1Info," r1Info = 10;\n optional ").concat(as.RtcPBR2Info," r2Info = 11;\n optional ").concat(as.RtcPBR3Info," r3Info = 12;\n optional ").concat(as.RtcPBR4Info," r4Info = 13;\n }\n message ").concat(as.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(as.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(as.RtcPBR3Info," {\n required ").concat(as.RtcPBStatusInfo," info = 1;\n }\n message ").concat(as.RtcPBR4Info," {\n required ").concat(as.RtcPBStatusInfo," info = 1;\n }\n message ").concat(as.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(as.RtcPBStreamInfo," streams = 13;\n }\n message ").concat(as.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"),ks=function(e,t,r,i,n,o,a){var s=n?Object.keys(n).map((function(t){return e.encode(as.RtcValueInfo,{key:t,value:n[t]},!0)})):void 0,c=o?Object.keys(o).map((function(t){return e.encode(as.RtcValueInfo,{key:t,value:o[t]},!0)})):void 0;return e.encode(as.RtcInput,{roomType:t,broadcastType:r,joinType:i,innerDatas:s,outerDatas:c,supportNtf:a})},Us=function(t,r){var i=t.decode(as.RtcUserListOutput,r),n=i.users,o=i.token,a=i.sessionId,s=i.roomInfo,c=i.entries,u=i.offlineKickTime,l=void 0===u?60:u,d=i.codeFormat,_=i.roomCreateTime,p=i.userJoinTime,f=i.version,h={};return e.forEach(n,(function(t){var r=t.userId,i=t.userData,n={};e.forEach(i,(function(e){var t=e.key,r=e.value;n[t]=r})),h[r]=n})),{users:h,token:o,sessionId:a,roomInfo:s,kvEntries:c,offlineKickTime:l,codeFormat:d,roomCreateTime:Pt(_),userJoinTime:Pt(p),version:f}},Ms=function(){function t(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(t.prototype,"joinRTCRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,n,o,a,u){return s(this,void 0,void 0,(function(){var s,l,d,_,p,f,h,b,R,g,m,C,v,O;return c(this,(function(c){switch(c.label){case 0:return s=ks(this.codec,r,i,n,o,a,u),[4,this.context.rtcSignaling(t,ss,!0,s)];case 1:return l=c.sent(),d=l.code,_=l.buffer,d===e.ErrorCode.SUCCESS&&_?(p=Us(this.codec,_),f=p.users,h=p.token,b=p.sessionId,R=p.roomInfo,g=p.kvEntries,m=p.offlineKickTime,C=p.roomCreateTime,v=p.userJoinTime,O=p.version,this.roomCreateTime=C,this.userJoinTime=v,[2,{code:d,data:{users:f,token:h,sessionId:b,roomInfo:R,kvEntries:g,offlineKickTime:m,version:O}}]):[2,{code:d,data:p}]}}))}))}}),Object.defineProperty(t.prototype,"quitRTCRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return t=this.codec.encode(as.SetUserStatusInput,{status:0}),[4,this.context.rtcSignaling(e,cs,!0,t)];case 1:return[2,r.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"getRTCRoomInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,n,o,a;return c(this,(function(s){switch(s.label){case 0:return r=this.codec.encode(as.RtcQueryListInput,{order:2}),[4,this.context.rtcSignaling(t,us,!0,r)];case 1:return i=s.sent(),n=i.code,o=i.buffer,n===e.ErrorCode.SUCCESS&&o&&(a=this.codec.decode(as.RtcRoomInfoOutput,o)),[2,{code:n,data:a}]}}))}))}}),Object.defineProperty(t.prototype,"getRTCUserInfoList",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,n,o,a,s;return c(this,(function(c){switch(c.label){case 0:return r=this.codec.encode(as.RtcQueryListInput,{order:2}),[4,this.context.rtcSignaling(t,ls,!0,r)];case 1:return i=c.sent(),n=i.code,o=i.buffer,n===e.ErrorCode.SUCCESS&&o&&(s=Us(this.codec,o),a={users:s.users}),[2,{code:n,data:a}]}}))}))}}),Object.defineProperty(t.prototype,"getRTCUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){throw new Error("Method not implemented.")}}),Object.defineProperty(t.prototype,"removeRTCUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r;return c(this,(function(i){switch(i.label){case 0:return r=this.codec.encode(as.RtcKeyDeleteInput,{key:t}),[4,this.context.rtcSignaling(e,ds,!1,r)];case 1:return[2,i.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"setRTCData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n,o){return s(this,void 0,void 0,(function(){var a;return c(this,(function(s){switch(s.label){case 0:return a=this.codec.encode(as.RtcSetDataInput,{interior:i,target:n,key:t,value:r,objectName:null==o?void 0:o.name,content:null==o?void 0:o.content}),[4,this.context.rtcSignaling(e,_s,!1,a)];case 1:return[2,s.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"setRTCTotalRes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n,o){return s(this,void 0,void 0,(function(){var a,s,u=this;return c(this,(function(c){switch(c.label){case 0:return a={objectName:i,content:[],valueInfo:[this.codec.encode(as.RtcValueInfo,{key:"uris",value:r},!0)]},t.forEach((function(e){var t=u.codec.encode(as.RtcValueInfo,{key:e.name,value:e.content},!0);a.content.push(t)})),n&&a.valueInfo.push(this.codec.encode(as.RtcValueInfo,{key:"mcu_uris",value:n},!0)),o&&a.valueInfo.push(this.codec.encode(as.RtcValueInfo,{key:"cdn_uris",value:o},!0)),s=this.codec.encode(as.RtcUserSetDataInput,a),[4,this.context.rtcSignaling(e,ps,!0,s)];case 1:return[2,c.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"setRTCCDNUris",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i;return c(this,(function(n){switch(n.label){case 0:return i=this.codec.encode(as.RtcUserSetDataInput,{objectName:t,valueInfo:this.codec.encode(as.RtcValueInfo,{key:"cdn_uris",value:r},!0)}),[4,this.context.rtcSignaling(e,ps,!0,i)];case 1:return[2,n.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"getRTCData",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,n){return s(this,void 0,void 0,(function(){var o,a,s,u,l,d;return c(this,(function(c){switch(c.label){case 0:return o=this.codec.encode(as.RtcDataInput,{interior:i,target:n,key:r}),[4,this.context.rtcSignaling(t,fs,!0,o)];case 1:return a=c.sent(),s=a.code,u=a.buffer,s===e.ErrorCode.SUCCESS&&u?(l=this.codec.decode(as.RtcQryOutput,u).outInfo,d={},l.forEach((function(e){d[e.key]=e.value})),[2,{code:s,data:d}]):[2,{code:s}]}}))}))}}),Object.defineProperty(t.prototype,"removeRTCData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n){return s(this,void 0,void 0,(function(){var o;return c(this,(function(a){switch(a.label){case 0:return o=this.codec.encode(as.RtcDataInput,{interior:r,target:i,key:t,objectName:(null==n?void 0:n.name)||"",content:(null==n?void 0:n.content)||""}),[4,this.context.rtcSignaling(e,hs,!1,o)];case 1:return[2,a.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"setRTCOutData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){return s(this,void 0,void 0,(function(){return c(this,(function(e){throw new Error("JSEngine's method not implemented.")}))}))}}),Object.defineProperty(t.prototype,"getRTCOutData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){return c(this,(function(e){throw new Error("JSEngine's method not implemented.")}))}))}}),Object.defineProperty(t.prototype,"getRTCToken",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var n,o,a,s,u;return c(this,(function(c){switch(c.label){case 0:return n=ks(this.codec,r,i),[4,this.context.rtcSignaling(t,bs,!0,n)];case 1:return o=c.sent(),a=o.code,s=o.buffer,a===e.ErrorCode.SUCCESS&&s?(u=this.codec.decode(as.RtcTokenOutput,s).rtcToken,[2,{code:a,data:{rtcToken:u}}]):[2,{code:a}]}}))}))}}),Object.defineProperty(t.prototype,"setRTCState",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r;return c(this,(function(i){switch(i.label){case 0:return r=this.codec.encode(as.MCFollowInput,{state:t}),[4,this.context.rtcSignaling(e,Rs,!0,r)];case 1:return[2,i.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"setRTCStateByHttp",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,n){var o;return s(this,void 0,void 0,(function(){var s,u,l;return c(this,(function(c){switch(c.label){case 0:s=function(e,t,r){var i=t.type,n=t.appKey,o=t.sessionId,s=t.roomId,c=t.roomCreateTime,u=t.userId,l=t.userRole,d=t.joinTime,_=t.signalDataCenter,p=t.r1Info,f=t.r2Info,h=t.r3Info,b=t.r4Info,R={type:i,appKey:n,sessionId:o,roomId:s,roomCreateTime:c,userId:u,userRole:l,joinTime:d,signalDataCenter:_};if(r===Ea.R1&&p){var g=e.encode(as.RtcPBR1Info,p,!0);return e.encode(as.RtcPBPolaris,a(a({},R),{r1Info:g}))}if(r===Ea.R2&&f){var m=e.encode(as.RtcPBR2Info,f,!0);return e.encode(as.RtcPBPolaris,a(a({},R),{r2Info:m}))}if(r===Ea.R3&&h){var C=(E=h.info).streams,v=Array.isArray(C)&&C.map((function(t){return t&&e.encode(as.RtcPBStreamInfo,t,!0)})),O=e.encode(as.RtcPBStatusInfo,a(a({},E),{streams:v}),!0),T=e.encode(as.RtcPBR3Info,{info:O},!0);return e.encode(as.RtcPBPolaris,a(a({},R),{r3Info:T}))}if(r===Ea.R4&&b){C=(E=b.info).streams,v=Array.isArray(C)&&C.map((function(t){return t&&e.encode(as.RtcPBStreamInfo,t,!0)})),O=e.encode(as.RtcPBStatusInfo,a(a({},E),{streams:v}),!0);var E,I=e.encode(as.RtcPBR4Info,{info:O},!0);return e.encode(as.RtcPBPolaris,a(a({},R),{r4Info:I}))}return{}}(this.codec,i,n),u=t,/^https:\/\//.test(t)||(u="https://".concat(t)),c.label=1;case 1:return c.trys.push([1,3,,4]),[4,r.httpReq({url:"".concat(u,"/rtc/logserver/polaris"),body:s,method:e.HttpMethod.POST,headers:{jwt:(null===(o=this.context.getNaviInfo())||void 0===o?void 0:o.jwt)||""},timeout:2e3})];case 2:if(!(l=c.sent()).data)throw new Error("http request fail");return[2,JSON.parse(l.data).resultCode];case 3:return c.sent(),[2,Ta.REPORT_FAIL];case 4:return[2]}}))}))}}),Object.defineProperty(t.prototype,"getRTCUserList",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,n,o,a;return c(this,(function(s){switch(s.label){case 0:return r=this.codec.encode(as.RtcQueryListInput,{order:2}),[4,this.context.rtcSignaling(t,gs,!0,r)];case 1:return i=s.sent(),n=i.code,o=i.buffer,n===e.ErrorCode.SUCCESS&&o?(a=Us(this.codec,o),[2,{code:n,data:a}]):[2,{code:n}]}}))}))}}),Object.defineProperty(t.prototype,"joinLivingRoomAsAudience",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var n,o,a,s,u,l,d,_,p;return c(this,(function(c){switch(c.label){case 0:return n=ks(this.codec,r,i),[4,this.context.rtcSignaling(t,ms,!0,n)];case 1:return o=c.sent(),a=o.code,s=o.buffer,a===e.ErrorCode.SUCCESS&&s?(u=this.codec.decode(as.RtcViewerJoinedOutput,s),l=u.rtcToken,d=u.entries,_=u.roomCreateTime,p=u.userJoinTime,this.roomCreateTime=Pt(_),this.userJoinTime=Pt(p),[2,{code:a,data:{token:l,kvEntries:d}}]):[2,{code:a}]}}))}))}}),Object.defineProperty(t.prototype,"quitLivingRoomAsAudience",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return t=this.codec.encode(as.SetUserStatusInput,{status:0}),[4,this.context.rtcSignaling(e,Cs,!0,t)];case 1:return[2,r.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"rtcIdentityChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var n,o,a,s,u;return c(this,(function(c){switch(c.label){case 0:return n=this.codec.encode(as.RtcInput,{roomType:exports.RTCMode.LIVE,broadcastType:i,identityChangeType:r,needSysChatroom:!1}),[4,this.context.rtcSignaling(t,Os,!0,n)];case 1:return o=c.sent(),a=o.code,s=o.buffer,a===e.ErrorCode.SUCCESS&&s?(u=Us(this.codec,s),[2,{code:a,data:u}]):[2,{code:a}]}}))}))}}),Object.defineProperty(t.prototype,"requestRoomPK",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t,r,i,n,o,a,s;return c(this,(function(c){switch(c.label){case 0:return t=e.invitedRoomId,r=e.invitedUserId,i=e.inviteSessionId,n=e.inviteTimeout,o=e.inviteInfo,a=e.roomId,s=this.codec.encode(as.RtcInviteInput,{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,timeoutTime:n,inviteInfo:o}),[4,this.context.rtcSignaling(a,Ts,!0,s)];case 1:return[2,c.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"cancelRoomPK",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t,r,i,n,o,a;return c(this,(function(s){switch(s.label){case 0:return t=e.invitedRoomId,r=e.invitedUserId,i=e.inviteSessionId,n=e.inviteInfo,o=e.roomId,a=this.codec.encode(as.RtcCancelInviteInput,{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,inviteInfo:n}),[4,this.context.rtcSignaling(o,Es,!0,a)];case 1:return[2,s.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"responseRoomPK",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t,r,i,n,o,a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return t=e.inviteUserId,r=e.inviteRoomId,i=e.inviteSessionId,n=e.content,o=e.key,a=e.value,s=e.agree,u=e.roomId,l=this.codec.encode(as.RtcInviteAnswerInput,{inviteUserId:t,inviteRoomId:r,inviteSessionId:i,content:n,key:o,value:a,answerCode:s?1:0}),[4,this.context.rtcSignaling(u,Is,!0,l)];case 1:return[2,c.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"endRoomPK",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t,r,i,n,o,a;return c(this,(function(s){switch(s.label){case 0:return t=e.endRoomId,r=e.sessionId,i=e.content,n=e.keys,o=e.roomId,a=this.codec.encode(as.RtcEndInviteInput,{inviteRoomId:t,inviteSessionId:r,inviteContent:i,inviteRoomKeys:n}),[4,this.context.rtcSignaling(o,Ss,!0,a)];case 1:return[2,s.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"getRTCJoinedUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,n,o,a;return c(this,(function(s){switch(s.label){case 0:return r=this.codec.encode(as.RtcQueryUserJoinedInput,{userId:t}),[4,this.context.rtcSignaling("",ys,!0,r)];case 1:return i=s.sent(),n=i.code,o=i.buffer,n===e.ErrorCode.SUCCESS&&o?(a=this.codec.decode(as.RtcQueryUserJoinedOutput,o).info||[],[2,{code:n,data:a.map((function(e){return{deviceId:e.deviceId,roomId:e.roomId,joinTime:Pt(e.joinTime)}}))}]):[2,{code:n}]}}))}))}}),Object.defineProperty(t.prototype,"pullRTCRoomEntry",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,n,o,s,u,l;return c(this,(function(c){switch(c.label){case 0:return r=this.codec.encode(as.RtcPullKV,{timestamp:0,roomId:t}),[4,this.context.rtcSignaling(t,vs,!0,r)];case 1:return i=c.sent(),n=i.code,o=i.buffer,n!==e.ErrorCode.SUCCESS?[2,{code:n}]:(s=this.codec.decode(as.RtcKVOutput,o),u=s.entries,l=s.syncTime,u=(u||[]).map((function(e){return a(a({},e),{timestamp:Pt(e.timestamp)})})),[2,{code:n,data:{kvEntries:u,syncTime:Pt(l)}}])}}))}))}}),Object.defineProperty(t.prototype,"pullRTCRoomStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return s(this,void 0,void 0,(function(){var i,n,o,a,s;return c(this,(function(c){switch(c.label){case 0:return i=this.codec.encode(as.RtcRoomStatusInput,{version:r}),[4,this.context.rtcSignaling(t,Ls,!0,i)];case 1:return n=c.sent(),o=n.code,a=n.buffer,o!==e.ErrorCode.SUCCESS?[2,{code:o}]:(s=this.codec.decode(as.RtcRoomStatusOutput,a),[2,{code:o,data:s}])}}))}))}}),Object.defineProperty(t.prototype,"decodeRtcNotify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.codec.decode(as.RtcNotifyMsg,e),r=t.time,i=t.type,n=t.roomId;return{time:Pt(r),type:i,roomId:n}}}),Object.defineProperty(t.prototype,"getCurrentId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context.getCurrentId()}}),Object.defineProperty(t.prototype,"getNaviInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context.getNaviInfo()}}),Object.defineProperty(t.prototype,"getConnectionStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context.getConnectionStatus()}}),Object.defineProperty(t.prototype,"getAppkey",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context.getAppkey()}}),Object.defineProperty(t.prototype,"webRtcPing",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var n,o,a,s,u;return c(this,(function(c){switch(c.label){case 0:return n=this.codec.encode(as.RtcInput,{roomType:r,broadcastType:i}),[4,this.context.rtcSignaling(t,As,!0,n)];case 1:return o=c.sent(),a=o.code,s=o.buffer,a!==e.ErrorCode.SUCCESS?[2,{code:a}]:((u=this.codec.decode(as.RtcOutput,s)).version=Pt(u.version),[2,{code:a,data:u}])}}))}))}}),Object.defineProperty(t.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(t.prototype,"sendMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return this.context.sendMessage(e,t,r)}}),Object.defineProperty(t.prototype,"registerRTCSignalListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.context.registerRTCSignalListener(e)}}),Object.defineProperty(t.prototype,"registerConnectionStateChangeListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.context.onconnectionstatechange=e}}),Object.defineProperty(t.prototype,"registerDisconnectListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.context.ondisconnect=e}}),Object.defineProperty(t.prototype,"registerDestroyListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.context.ondestroy=e}}),Object.defineProperty(t.prototype,"registerMessageListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.context.onmessage=e}}),Object.defineProperty(t.prototype,"getCoreVersion",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context.getCoreVersion()}}),Object.defineProperty(t.prototype,"getPluginContext",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context}}),Object.defineProperty(t.prototype,"reportSDKInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.codec.encode(as.RtcReportSDKInput,{sdkInfo:JSON.stringify(e)});this.context.rtcSignaling("",Ps,!0,t)}}),t}();!function(e){e.RTC="RTC"}(Ns||(Ns={})),e.VersionManage.add("rtclib","5.32.0-c-im-alpha.2");var xs={tag:"RCRTC",verify:function(t){return"undefined"==typeof isSecureContext||isSecureContext?!!e.VersionManage.validEngine("5.32.0")||(console.error("The current engine version '".concat(e.VersionManage.getInfo().engine,"' error, plugin-rtc required engine version at least '").concat("5.32.0","'.")),!1):(console.error("Please use the https protocol or use `http://localhost` to open the page!"),!1)},setup:function(t,r,i){void 0===i&&(i={});var o=t.createLogger("RCRTC",Ns.RTC);if(i.logLevel&&o.setOutputLevel(i.logLevel),o.warn(n.L_INDEX_INSTALL_RTC_PLUGIN_O,JSON.stringify({"RCRTC Version":"5.32.0-c-im-alpha.2",Commit:"4a1df2c60d640b93153c2dc695d9d9d07e0a8746","browserInfo.browser":Ct.browser,"browserInfo.supportsUnifiedPlan":Ct.supportsUnifiedPlan,"browserInfo.version":Ct.version})),e.assert("options",i,e.AssertRules.OBJECT,!0),e.assert("options.mediaServer",i.mediaServer,(function(t){return!(!e.isHttpUrl(t)||"https:"===location.protocol&&!/^https/.test(t))})),e.assert("options.timeout",i.timeout,(function(t){return e.isNumber(t)&&t>=5e3&&t<=3e4})),e.assert("options.pingGap",i.pingGap,(function(t){return e.isNumber(t)&&t>=3e3&&t<=1e4})),i.AAAWorklet){e.assert("options.AAAWorklet",i.AAAWorklet,e.AssertRules.OBJECT,!0);var a=i.AAAWorklet,s=a.scriptUrl,c=a.wasmUrl;e.assert("AAAWorklet.scriptUrl",s,e.AssertRules.STRING,!0),e.assert("AAAWorklet.wasmUrl",c,e.AssertRules.STRING,!0),He.SCRIPT_URL=s,He.WASM_URL=c}return i.encryptor&&(e.assert("options.encrypt",i.encryptor,e.AssertRules.OBJECT,!0),e.assert("options.encrypt.decodeAudio",i.encryptor.decodeAudio,(function(e){return"function"==typeof e}),!0),e.assert("options.encrypt.decodeVideo",i.encryptor.decodeVideo,(function(e){return"function"==typeof e}),!0),e.assert("options.encrypt.encodeAudio",i.encryptor.encodeAudio,(function(e){return"function"==typeof e}),!0),e.assert("options.encrypt.encodeVideo",i.encryptor.encodeVideo,(function(e){return"function"==typeof e}),!0),uo.init(i.encryptor,o)),new os(new Ms(t,o,t.createCodec(ws,Ds)),r,i)}},js={transResolution:bt,transFrameRate:mt,parseTrackId:dt,ifSupportLocalFileTrack:vt,ifSupportScreenShare:Ot};exports.RCAbstractRoom=Da,exports.RCAudienceClient=Xa,exports.RCAudienceLivingRoom=ts,exports.RCCameraVideoTrack=Xe,exports.RCLivingRoom=Ya,exports.RCLocalAudioTrack=We,exports.RCLocalFileAudioTrack=Qe,exports.RCLocalFileTrack=ze,exports.RCLocalFileVideoTrack=qe,exports.RCLocalTrack=Ke,exports.RCLocalVideoTrack=Ye,exports.RCMCUConfigBuilder=xa,exports.RCMediaStreamCapture=ns,exports.RCMicphoneAudioTrack=Ze,exports.RCRTCClient=os,exports.RCRTCRoom=za,exports.RCRemoteAudioTrack=rt,exports.RCRemoteTrack=tt,exports.RCRemoteVideoTrack=it,exports.RCScreenAudioTrack=et,exports.RCScreenVideoTrack=$e,exports.RCTag={DEFAULT:"RongCloudRTC"},exports.RCTrack=Ve,exports.device=Me,exports.helper=js,exports.installer=xs;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@rongcloud/engine"),t=function(e,r){return t=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])},t(e,r)};function r(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}var i,n,o,a=function(){return a=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},a.apply(this,arguments)};function s(e,t,r,i){return new(r||(r=Promise))((function(n,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(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(a,s)}c((i=i.apply(e,t||[])).next())}))}function c(e,t){var r,i,n,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[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,i&&(n=2&s[0]?i.return:s[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,s[1])).done)return n;switch(i=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){o.label=s[1];break}if(6===s[0]&&o.label<n[1]){o.label=n[1],n=s;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(s);break}n[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],i=0}finally{r=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return a}function d(e,t,r){if(r||2===arguments.length)for(var i,n=0,o=t.length;n<o;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,exports.RCRTCCode=void 0,(i=exports.RCRTCCode||(exports.RCRTCCode={}))[i.SUCCESS=1e4]="SUCCESS",i[i.PB_ERROR=40001]="PB_ERROR",i[i.SIGNAL_DISCONNECTED=5e4]="SIGNAL_DISCONNECTED",i[i.PARAMS_ERROR=50001]="PARAMS_ERROR",i[i.REPERT_JOIN_ROOM=50002]="REPERT_JOIN_ROOM",i[i.NOT_IN_ROOM=50003]="NOT_IN_ROOM",i[i.SERVICE_INVALID=50004]="SERVICE_INVALID",i[i.RTC_TOKEN_INVALID=50006]="RTC_TOKEN_INVALID",i[i.ASR_NOT_AVAILABLE=50034]="ASR_NOT_AVAILABLE",i[i.ASR_NOT_START=50035]="ASR_NOT_START",i[i.SIGNAL_ERROR=53001]="SIGNAL_ERROR",i[i.CREATE_OFFER_FAILED=53003]="CREATE_OFFER_FAILED",i[i.REQUEST_FAILED=53004]="REQUEST_FAILED",i[i.MCU_SERVER_NOT_FOUND=53005]="MCU_SERVER_NOT_FOUND",i[i.BROADCAST_SUB_LIST_NOT_EMPTY=53007]="BROADCAST_SUB_LIST_NOT_EMPTY",i[i.ROOM_HAS_BEEN_DESTROYED=53008]="ROOM_HAS_BEEN_DESTROYED",i[i.NOT_OPEN_VIDEO_AUDIO_SERVER=53009]="NOT_OPEN_VIDEO_AUDIO_SERVER",i[i.GET_USER_MEDIA_FAILED=53010]="GET_USER_MEDIA_FAILED",i[i.GET_DISPLAY_MEDIA_FAILED=53011]="GET_DISPLAY_MEDIA_FAILED",i[i.BROWSER_PERMISSION_DENIED=53012]="BROWSER_PERMISSION_DENIED",i[i.CREATE_CUSTOM_TRACK_FAILED=53013]="CREATE_CUSTOM_TRACK_FAILED",i[i.INVALID_TAGS=53014]="INVALID_TAGS",i[i.INVALID_USER_ID=53015]="INVALID_USER_ID",i[i.CREATE_FILE_TRACK_FAILED=53016]="CREATE_FILE_TRACK_FAILED",i[i.INVALID_FILE_INSTANCE=53017]="INVALID_FILE_INSTANCE",i[i.SET_REMOTE_DESCRIPTION_FAILED=53018]="SET_REMOTE_DESCRIPTION_FAILED",i[i.BROWSER_NOT_SUPPORT=53019]="BROWSER_NOT_SUPPORT",i[i.TRACK_NOT_READY=53020]="TRACK_NOT_READY",i[i.VIDEO_TRACK_MISS_MEDIA_ELEMENT=53021]="VIDEO_TRACK_MISS_MEDIA_ELEMENT",i[i.TRACK_PLAY_ERROR=53022]="TRACK_PLAY_ERROR",i[i.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED=53023]="SIGNAL_AUDIENCE_JOIN_ROOM_FAILED",i[i.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED=53024]="SIGNAL_ROOM_CHANGE_IDENTITY_FAILED",i[i.PACKAGE_ENVIRONMENT_ERROR=53025]="PACKAGE_ENVIRONMENT_ERROR",i[i.PUBLISH_TRACK_LIMIT_EXCEEDED=53026]="PUBLISH_TRACK_LIMIT_EXCEEDED",i[i.CDN_RESOURCE_IS_EMPTY=53027]="CDN_RESOURCE_IS_EMPTY",i[i.SIGNAL_JOIN_RTC_ROOM_REFUSED=53028]="SIGNAL_JOIN_RTC_ROOM_REFUSED",i[i.NO_PERMISSION_TO_USE_REQUESTED_DEVICE=53029]="NO_PERMISSION_TO_USE_REQUESTED_DEVICE",i[i.THE_FUNCTION_IS_DISABLED_IN_PKROOM=53030]="THE_FUNCTION_IS_DISABLED_IN_PKROOM",i[i.SOME_TRACKS_PUBLISH_FAILED=53031]="SOME_TRACKS_PUBLISH_FAILED",i[i.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO=53032]="MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO",i[i.JWT_TIME_OUT=1004]="JWT_TIME_OUT",i[i.SYSTEM_PERMISSION_DENIED=53033]="SYSTEM_PERMISSION_DENIED",i[i.PUBLISH_TRACKS_IS_INVALID=53034]="PUBLISH_TRACKS_IS_INVALID",i[i.TRACK_READYSTATE_IS_ENDED=53035]="TRACK_READYSTATE_IS_ENDED",i[i.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH=53036]="APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH",i[i.LOAD_3A_MODULE_FAILED=53037]="LOAD_3A_MODULE_FAILED",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_ABSTRACT_ROOM_SET_SRC_LANGUAGE_T="L-abstract_room_set_src_language-T",e.L_ABSTRACT_ROOM_SET_SRC_LANGUAGE_R="L-abstract_room_set_src_language-R",e.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_T="L-abstract_room_operate_asr_status-T",e.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R="L-abstract_room_operate_asr_status-R",e.L_ABSTRACT_ROOM_SET_ENABLE_ASR_T="L-abstract_room_set_enable_asr-T",e.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R="L-abstract_room_set_enable_asr-R",e.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_T="L-abstract_room_operate_realtime_translation-T",e.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R="L-abstract_room_operate_realtime_translation-R",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.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_T="L-rtc_client_change_media_device-T",e.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R="L-rtc_client_change_media_device-R"}(n||(n={})),function(e){e.FAILED="fail",e.SUCCESSED="success",e.TIMEOUT="timeout",e.INFO="info"}(o||(o={}));let _=!0,p=!0;function f(e,t,r){const i=e.match(t);return i&&i.length>=r&&parseInt(i[r],10)}function h(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 o=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,o),n.apply(this,[e,o])};const o=i.removeEventListener;i.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 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,o.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 b(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(_=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function R(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(p=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function g(){if("object"==typeof window){if(_)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function m(e,t){p&&console.warn(e+" is deprecated, please use "+t+" instead.")}function C(e){return"[object Object]"===Object.prototype.toString.call(e)}function v(e){return C(e)?Object.keys(e).reduce((function(t,r){const i=C(e[r]),n=i?v(e[r]):e[r],o=i&&!Object.keys(n).length;return void 0===n||o?t:Object.assign(t,{[r]:n})}),{}):e}function O(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),Object.keys(t).forEach((i=>{i.endsWith("Id")?O(e,e.get(t[i]),r):i.endsWith("Ids")&&t[i].forEach((t=>{O(e,e.get(t),r)}))})))}function T(e,t,r){const i=r?"outbound-rtp":"inbound-rtp",n=new Map;if(null===t)return n;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((r=>{r.type===i&&r.trackId===t.id&&O(e,r,n)}))})),n}const E=g;function S(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 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=i(e.video),E("chrome: "+JSON.stringify(e)),n(e)}))}e.video=i(e.video)}return E("chrome: "+JSON.stringify(e)),n(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,i){n(e,(e=>{r.webkitGetUserMedia(e,t,(e=>{i&&i(o(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(o(e))))))}}}function I(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function y(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 h(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function L(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 A(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},o=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const i=function(e){r(o(n(e)))};return t.apply(this,[i,e])}return new Promise(((e,r)=>{t.apply(this,[function(t){e(o(n(t)))},r])})).then(r,i)}}function P(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=>T(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}),h(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>T(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 N(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 w(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return N(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 o(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=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]=i[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 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]),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 D(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){h(e,"negotiationneeded",(e=>{const r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var U=Object.freeze({__proto__:null,shimMediaStream:I,shimOnTrack:y,shimGetSendersWithDtmf:L,shimGetStats:A,shimSenderReceiverGetStats:P,shimAddTrackRemoveTrackWithNative:N,shimAddTrackRemoveTrack:w,shimPeerConnection:D,fixNegotiationNeeded:k,shimGetUserMedia:S,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,o=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||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 M,x,j=(M=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 o=i[n],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 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),o=-1!==n.fecMechanisms.indexOf("RED"),a=-1!==n.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]),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),o&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},i.push(t))}})),0===i.length&&c&&i.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,i.forEach((function(e){e.maxBitrate=l}))),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 o=t.matchPrefix(e,"a=rtcp-mux");return r.mux=o.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 o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:i.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,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 o=t.writeRtpDescription(e.kind,r);if(o+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===i?"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:"+n.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 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},M(x={exports:{}},x.exports),x.exports);function B(e,t,r,i,n){var o=j.writeRtpDescription(e.kind,t);if(o+=j.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=j.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":n||"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:"+(i?i.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:"+j.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+j.localCName+"\r\n"),o}function V(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 o=i(e.parameters.apt,r),a=i(t.parameters.apt,n);return o&&a&&o.name.toLowerCase()===a.name.toLowerCase()};return e.codecs.forEach((function(i){for(var o=0;o<t.codecs.length;o++){var a=t.codecs[o];if(i.name.toLowerCase()===a.name.toLowerCase()&&i.clockRate===a.clockRate){if("rtx"===i.name.toLowerCase()&&i.parameters&&a.parameters.apt&&!n(i,a,e.codecs,t.codecs))continue;(a=JSON.parse(JSON.stringify(a))).numChannels=Math.min(i.numChannels,a.numChannels),r.codecs.push(a),a.rtcpFeedback=a.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 F(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 J(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 G(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 H=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 o=new Event("track");o.track=r,o.receiver=i,o.transceiver={receiver:i},o.streams=n,e.setTimeout((function(){t._dispatchEvent("track",o)}))}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 G("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 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=j.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 G("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var i;if(this.transceivers.find((function(e){return e.track===t})))throw G("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 G("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 G("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 o=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 o=new Event("icecandidate");o.candidate={sdpMid:t,sdpMLineIndex:r};var a=e.candidate,s=!a||0===Object.keys(a).length;if(s)"new"!==n.state&&"gathering"!==n.state||(n.state="completed");else{"new"===n.state&&(n.state="gathering"),a.component=1,a.ufrag=n.getLocalParameters().usernameFragment;var c=j.writeCandidate(a);o.candidate=Object.assign(o.candidate,j.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=j.getMediaSections(i._localDescription.sdp);u[o.candidate.sdpMLineIndex]+=s?"a=end-of-candidates\r\n":"a="+o.candidate.candidate+"\r\n",i._localDescription.sdp=j.getDescription(i._localDescription.sdp)+u.join("");var l=i.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),s||i._dispatchEvent("icecandidate",o),l&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout((function(){o.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=V(e.localCapabilities,e.remoteCapabilities);r&&e.rtpSender&&(n.encodings=e.sendEncodingParameters,n.rtcp={cname:j.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(G("TypeError",'Unsupported type "'+e.type+'"'));if(!F("setLocalDescription",e.type,i.signalingState)||i._isClosed)return Promise.reject(G("InvalidStateError","Can not set local "+e.type+" in state "+i.signalingState));if("offer"===e.type)t=j.splitSections(e.sdp),r=t.shift(),t.forEach((function(e,t){var r=j.parseRtpParameters(e);i.transceivers[t].localCapabilities=r})),i.transceivers.forEach((function(e,t){i._gather(e.mid,t)}));else if("answer"===e.type){t=j.splitSections(i._remoteDescription.sdp),r=t.shift();var n=j.matchPrefix(r,"a=ice-lite").length>0;t.forEach((function(e,t){var o=i.transceivers[t],a=o.iceGatherer,s=o.iceTransport,c=o.dtlsTransport,u=o.localCapabilities,l=o.remoteCapabilities;if(!(j.isRejected(e)&&0===j.matchPrefix(e,"a=bundle-only").length)&&!o.rejected){var d=j.getIceParameters(e,r),_=j.getDtlsParameters(e,r);n&&(_.role="server"),i.usingBundle&&0!==t||(i._gather(o.mid,t),"new"===s.state&&s.start(a,d,n?"controlling":"controlled"),"new"===c.state&&c.start(_));var p=V(u,l);i._transceive(o,p.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 o=this;if(-1===["offer","answer"].indexOf(n.type))return Promise.reject(G("TypeError",'Unsupported type "'+n.type+'"'));if(!F("setRemoteDescription",n.type,o.signalingState)||o._isClosed)return Promise.reject(G("InvalidStateError","Can not set remote "+n.type+" in state "+o.signalingState));var a={};o.remoteStreams.forEach((function(e){a[e.id]=e}));var s=[],c=j.splitSections(n.sdp),u=c.shift(),l=j.matchPrefix(u,"a=ice-lite").length>0,d=j.matchPrefix(u,"a=group:BUNDLE ").length>0;o.usingBundle=d;var _=j.matchPrefix(u,"a=ice-options:")[0];return o.canTrickleIceCandidates=!!_&&_.substr(14).split(" ").indexOf("trickle")>=0,c.forEach((function(i,c){var _=j.splitLines(i),p=j.getKind(i),f=j.isRejected(i)&&0===j.matchPrefix(i,"a=bundle-only").length,h=_[0].substr(2).split(" ")[2],b=j.getDirection(i,u),R=j.parseMsid(i),g=j.getMid(i)||j.generateIdentifier();if(f||"application"===p&&("DTLS/SCTP"===h||"UDP/DTLS/SCTP"===h))o.transceivers[c]={mid:g,kind:p,protocol:h,rejected:!0};else{var m,C,v,O,T,E,S,I,y;!f&&o.transceivers[c]&&o.transceivers[c].rejected&&(o.transceivers[c]=o._createTransceiver(p,!0));var L,A,P=j.parseRtpParameters(i);f||(L=j.getIceParameters(i,u),(A=j.getDtlsParameters(i,u)).role="client"),S=j.parseRtpEncodingParameters(i);var N=j.parseRtcpParameters(i),w=j.matchPrefix(i,"a=end-of-candidates",u).length>0,D=j.matchPrefix(i,"a=candidate:").map((function(e){return j.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===n.type||"answer"===n.type)&&!f&&d&&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"!==n.type||f){if("answer"===n.type&&!f){C=(m=o.transceivers[c]).iceGatherer,v=m.iceTransport,O=m.dtlsTransport,T=m.rtpReceiver,E=m.sendEncodingParameters,I=m.localCapabilities,o.transceivers[c].recvEncodingParameters=S,o.transceivers[c].remoteCapabilities=P,o.transceivers[c].rtcpParameters=N,D.length&&"new"===v.state&&(!l&&!w||d&&0!==c?D.forEach((function(e){J(m.iceTransport,e)})):v.setRemoteCandidates(D)),d&&0!==c||("new"===v.state&&v.start(C,L,"controlling"),"new"===O.state&&O.start(A)),!V(m.localCapabilities,m.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&m.sendEncodingParameters[0].rtx&&delete m.sendEncodingParameters[0].rtx,o._transceive(m,"sendrecv"===b||"recvonly"===b,"sendrecv"===b||"sendonly"===b),!T||"sendrecv"!==b&&"sendonly"!==b?delete m.rtpReceiver:(y=T.track,R?(a[R.stream]||(a[R.stream]=new e.MediaStream),r(y,a[R.stream]),s.push([y,T,a[R.stream]])):(a.default||(a.default=new e.MediaStream),r(y,a.default),s.push([y,T,a.default])))}}else{(m=o.transceivers[c]||o._createTransceiver(p)).mid=g,m.iceGatherer||(m.iceGatherer=o._createIceGatherer(c,d)),D.length&&"new"===m.iceTransport.state&&(!w||d&&0!==c?D.forEach((function(e){J(m.iceTransport,e)})):m.iceTransport.setRemoteCandidates(D)),I=e.RTCRtpReceiver.getCapabilities(p),t<15019&&(I.codecs=I.codecs.filter((function(e){return"rtx"!==e.name}))),E=m.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var k,U=!1;if("sendrecv"===b||"sendonly"===b){if(U=!m.rtpReceiver,T=m.rtpReceiver||new e.RTCRtpReceiver(m.dtlsTransport,p),U)y=T.track,R&&"-"===R.stream||(R?(a[R.stream]||(a[R.stream]=new e.MediaStream,Object.defineProperty(a[R.stream],"id",{get:function(){return R.stream}})),Object.defineProperty(y,"id",{get:function(){return R.track}}),k=a[R.stream]):(a.default||(a.default=new e.MediaStream),k=a.default)),k&&(r(y,k),m.associatedRemoteMediaStreams.push(k)),s.push([y,T,k])}else m.rtpReceiver&&m.rtpReceiver.track&&(m.associatedRemoteMediaStreams.forEach((function(t){var r=t.getTracks().find((function(e){return e.id===m.rtpReceiver.track.id}));r&&function(t,r){r.removeTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(r,t)})),m.associatedRemoteMediaStreams=[]);m.localCapabilities=I,m.remoteCapabilities=P,m.rtpReceiver=T,m.rtcpParameters=N,m.sendEncodingParameters=E,m.recvEncodingParameters=S,o._transceive(o.transceivers[c],!1,U)}}})),void 0===o._dtlsRole&&(o._dtlsRole="offer"===n.type?"active":"passive"),o._remoteDescription={type:n.type,sdp:n.sdp},"offer"===n.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 n=new Event("addstream");n.stream=r,e.setTimeout((function(){o._dispatchEvent("addstream",n)}))}s.forEach((function(e){var t=e[0],n=e[1];r.id===e[2].id&&i(o,t,n,[r])}))}})),s.forEach((function(e){e[2]||i(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()},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(G("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,o=arguments[0];if(o){if(o.mandatory||o.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==o.offerToReceiveAudio&&(i=!0===o.offerToReceiveAudio?1:!1===o.offerToReceiveAudio?0:o.offerToReceiveAudio),void 0!==o.offerToReceiveVideo&&(n=!0===o.offerToReceiveVideo?1:!1===o.offerToReceiveVideo?0:o.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 a=j.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.transceivers.forEach((function(i,n){var o=i.track,a=i.kind,s=i.mid||j.generateIdentifier();i.mid=s,i.iceGatherer||(i.iceGatherer=r._createIceGatherer(n,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"),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 u=i.sendEncodingParameters||[{ssrc:1001*(2*n+1)}];o&&t>=15019&&"video"===a&&!u[0].rtx&&(u[0].rtx={ssrc:u[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,a)),i.localCapabilities=c,i.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+=B(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="+j.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)},n.prototype.createAnswer=function(){var r=this;if(r._isClosed)return Promise.reject(G("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==r.signalingState&&"have-local-pranswer"!==r.signalingState)return Promise.reject(G("InvalidStateError","Can not call createAnswer in signalingState "+r.signalingState));var i=j.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=j.getMediaSections(r._remoteDescription.sdp).length;r.transceivers.forEach((function(e,o){if(!(o+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 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=V(e.localCapabilities,e.remoteCapabilities);!s.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,i+=B(e,s,"answer",e.stream,r._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(i+="a=rtcp-rsize\r\n")}}));var o=new e.RTCSessionDescription({type:"answer",sdp:i});return Promise.resolve(o)},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(G("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 n(G("OperationError","Can not add ICE candidate"));if(s.rejected)return i();var c=Object.keys(e.candidate).length>0?j.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===o||o>0&&s.iceTransport!==r.transceivers[0].iceTransport)&&!J(s.iceTransport,c))return n(G("OperationError","Can not add ICE candidate"));var u=e.candidate.trim();0===u.indexOf("a=")&&(u=u.substr(2)),(t=j.getMediaSections(r._remoteDescription.sdp))[o]+="a="+(c.type?u:"end-of-candidates")+"\r\n",r._remoteDescription.sdp=j.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=j.getMediaSections(r._remoteDescription.sdp))[l]+="a=end-of-candidates\r\n",r._remoteDescription.sdp=j.getDescription(r._remoteDescription.sdp)+t.join(""),!r.usingBundle));l++);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 G("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 o=["createOffer","createAnswer"];return o.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)}})),(o=["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 K(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 W(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 Y(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=H(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&&m("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),g("ICE servers after filtering:",e.iceServers)),new r(e)},e.RTCPeerConnection.prototype=r.prototype}function z(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}var q=Object.freeze({__proto__:null,shimPeerConnection:Y,shimReplaceTrack:z,shimGetUserMedia:K,shimGetDisplayMedia:W});function Q(e,t){const r=e&&e.navigator,i=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,i){m("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 Z(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 X(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,o]=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,o)}}function $(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 ee(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}),h(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function te(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){m("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 ie(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 ne(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 oe(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 ae(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 se=Object.freeze({__proto__:null,shimOnTrack:Z,shimPeerConnection:X,shimSenderGetStats:$,shimReceiverGetStats:ee,shimRemoveStream:te,shimRTCDataChannel:re,shimAddTransceiver:ie,shimGetParameters:ne,shimCreateOffer:oe,shimCreateAnswer:ae,shimGetUserMedia:Q,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 ce(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 ue(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,i=t.createAnswer,n=t.setLocalDescription,o=t.setRemoteDescription,a=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 s=function(e,t,r){const i=n.apply(this,[e]);return r?(i.then(t,r),Promise.resolve()):i};t.setLocalDescription=s,s=function(e,t,r){const i=o.apply(this,[e]);return r?(i.then(t,r),Promise.resolve()):i},t.setRemoteDescription=s,s=function(e,t,r){const i=a.apply(this,[e]);return r?(i.then(t,r),Promise.resolve()):i},t.addIceCandidate=s}function de(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(_e(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,i){t.mediaDevices.getUserMedia(e).then(r,i)}.bind(t))}function _e(e){return e&&void 0!==e.video?Object.assign({},e,{video:v(e.video)}):e}function pe(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")?(m("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 fe(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 he(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 be(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var Re=Object.freeze({__proto__:null,shimLocalStreamsAPI:ce,shimRemoteStreamsAPI:ue,shimCallbacksAPI:le,shimGetUserMedia:de,shimConstraints:_e,shimRTCIceServerUrls:pe,shimTrackEventTransceiver:fe,shimCreateOfferLegacy:he,shimAudioContext:be});function ge(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=j.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,h(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function me(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=j.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=j.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=j.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 o={};Object.defineProperty(o,"maxMessageSize",{get:()=>n}),this._sctp=o}return r.apply(this,arguments)}}function Ce(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},h(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function ve(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 Oe(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 Te(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 Ee=Object.freeze({__proto__:null,shimRTCIceCandidate:ge,shimMaxMessageSize:me,shimSendThrowTypeError:Ce,shimConnectionState:ve,removeExtmapAllowMixed:Oe,shimAddIceCandidateNullOrEmpty:Te});const Se=function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const r=g,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=f(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=f(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(r.mediaDevices&&r.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=f(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=f(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),n={browserDetails:i,commonShim:Ee,extractVersion:f,disableLog:b,disableWarnings:R};switch(i.browser){case"chrome":if(!U||!D||!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=U,Te(e,i),S(e,i),I(e),D(e,i),y(e),w(e,i),L(e),A(e),P(e),k(e,i),ge(e),ve(e),me(e,i),Ce(e),Oe(e,i);break;case"firefox":if(!se||!X||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),n;r("adapter.js shimming firefox."),n.browserShim=se,Te(e,i),Q(e,i),X(e,i),Z(e),te(e),$(e),ee(e),re(e),ie(e),ne(e),oe(e),ae(e),ge(e),ve(e),me(e,i),Ce(e);break;case"edge":if(!q||!Y||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),n;r("adapter.js shimming edge."),n.browserShim=q,K(e),W(e),Y(e,i),z(e),me(e,i),Ce(e);break;case"safari":if(!Re||!t.shimSafari)return r("Safari shim is not included in this adapter release."),n;r("adapter.js shimming safari."),n.browserShim=Re,Te(e,i),pe(e),he(e),le(e),ce(e),ue(e),fe(e),de(e),be(e),ge(e),me(e,i),Ce(e),Oe(e,i);break;default:r("Unsupported browser!")}return n}({window:"undefined"==typeof window?void 0:window});var Ie,ye,Le,Ae;exports.RCFrameRate=void 0,(Ie=exports.RCFrameRate||(exports.RCFrameRate={})).FPS_10="FPS_10",Ie.FPS_15="FPS_15",Ie.FPS_24="FPS_24",Ie.FPS_30="FPS_30",exports.RCResolution=void 0,(ye=exports.RCResolution||(exports.RCResolution={})).W176_H132="W176_H132",ye.W176_H144="W176_H144",ye.W180_H180="W180_H180",ye.W240_H180="W240_H180",ye.W240_H240="W240_H240",ye.W256_H144="W256_H144",ye.W320_H180="W320_H180",ye.W320_H240="W320_H240",ye.W360_H360="W360_H360",ye.W480_H360="W480_H360",ye.W480_H480="W480_H480",ye.W640_H360="W640_H360",ye.W640_H480="W640_H480",ye.W720_H480="W720_H480",ye.W848_H480="W848_H480",ye.W960_H720="W960_H720",ye.W1280_H720="W1280_H720",ye.W1920_H1080="W1920_H1080",ye.W144_H176="W144_H176",ye.W144_H256="W144_H256",ye.W180_H240="W180_H240",ye.W180_H320="W180_H320",ye.W240_H320="W240_H320",ye.W360_H480="W360_H480",ye.W360_H640="W360_H640",ye.W480_H640="W480_H640",ye.W480_H720="W480_H720",ye.W480_H848="W480_H848",ye.W720_H1280="W720_H1280",ye.W720_H960="W720_H960",ye.W1080_H1920="W1080_H1920",exports.RCMediaType=void 0,(Le=exports.RCMediaType||(exports.RCMediaType={}))[Le.AUDIO_ONLY=0]="AUDIO_ONLY",Le[Le.VIDEO_ONLY=1]="VIDEO_ONLY",Le[Le.AUDIO_VIDEO=2]="AUDIO_VIDEO";var Pe,Ne=((Ae={})[exports.RCResolution.W176_H132]={width:176,height:132,maxBitrate:150,minBitrate:80},Ae[exports.RCResolution.W176_H144]={width:176,height:144,maxBitrate:150,minBitrate:80},Ae[exports.RCResolution.W180_H180]={width:180,height:180,maxBitrate:200,minBitrate:100},Ae[exports.RCResolution.W240_H180]={width:240,height:180,maxBitrate:240,minBitrate:120},Ae[exports.RCResolution.W240_H240]={width:240,height:240,maxBitrate:280,minBitrate:120},Ae[exports.RCResolution.W256_H144]={width:256,height:144,maxBitrate:240,minBitrate:120},Ae[exports.RCResolution.W320_H180]={width:320,height:180,maxBitrate:280,minBitrate:120},Ae[exports.RCResolution.W320_H240]={width:320,height:240,maxBitrate:400,minBitrate:120},Ae[exports.RCResolution.W360_H360]={width:360,height:360,maxBitrate:520,minBitrate:140},Ae[exports.RCResolution.W480_H360]={width:480,height:360,maxBitrate:650,minBitrate:150},Ae[exports.RCResolution.W480_H480]={width:480,height:480,maxBitrate:800,minBitrate:180},Ae[exports.RCResolution.W640_H360]={width:640,height:360,maxBitrate:800,minBitrate:180},Ae[exports.RCResolution.W640_H480]={width:640,height:480,maxBitrate:900,minBitrate:200},Ae[exports.RCResolution.W720_H480]={width:720,height:480,maxBitrate:1e3,minBitrate:200},Ae[exports.RCResolution.W848_H480]={width:848,height:480,maxBitrate:1860,minBitrate:200},Ae[exports.RCResolution.W960_H720]={width:960,height:720,maxBitrate:2e3,minBitrate:250},Ae[exports.RCResolution.W1280_H720]={width:1280,height:720,maxBitrate:2200,minBitrate:250},Ae[exports.RCResolution.W1920_H1080]={width:1920,height:1080,maxBitrate:4e3,minBitrate:400},Ae[exports.RCResolution.W144_H176]={width:144,height:176,maxBitrate:150,minBitrate:80},Ae[exports.RCResolution.W144_H256]={width:144,height:256,maxBitrate:240,minBitrate:120},Ae[exports.RCResolution.W180_H240]={width:180,height:240,maxBitrate:240,minBitrate:120},Ae[exports.RCResolution.W180_H320]={width:180,height:320,maxBitrate:280,minBitrate:120},Ae[exports.RCResolution.W240_H320]={width:240,height:320,maxBitrate:400,minBitrate:120},Ae[exports.RCResolution.W360_H480]={width:360,height:480,maxBitrate:650,minBitrate:150},Ae[exports.RCResolution.W360_H640]={width:360,height:640,maxBitrate:800,minBitrate:180},Ae[exports.RCResolution.W480_H640]={width:480,height:640,maxBitrate:900,minBitrate:200},Ae[exports.RCResolution.W480_H720]={width:480,height:720,maxBitrate:1e3,minBitrate:200},Ae[exports.RCResolution.W480_H848]={width:480,height:848,maxBitrate:1860,minBitrate:930},Ae[exports.RCResolution.W720_H1280]={width:720,height:1280,maxBitrate:2200,minBitrate:250},Ae[exports.RCResolution.W720_H960]={width:720,height:960,maxBitrate:2760,minBitrate:910},Ae[exports.RCResolution.W1080_H1920]={width:1080,height:1920,maxBitrate:4e3,minBitrate:400},Ae),we=function(e){var t={192:180,368:360,1088:1080};return t[e]?t[e]:e},De=function(e,t){e=we(e),t=we(t);var r=Ne["W".concat(e,"_H").concat(t)];if(r)return r;var i=e*t;return Object.keys(Ne).map((function(e){return Ne[e]})).sort((function(e,t){return e.height*e.width-t.width*t.height})).filter((function(e){return e.height*e.width>=i}))[0]||Ne.W1920_H1080},ke={10:1,15:1,24:1.5,30:1.5},Ue=function(e){var t=Number.MAX_VALUE,r=1;for(var i in ke){var n=Math.abs(e-parseInt(i));n<t&&(t=n,r=ke[i])}return r},Me={getCameras:function(){return s(void 0,void 0,void 0,(function(){return c(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 s(void 0,void 0,void 0,(function(){return c(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 s(void 0,void 0,void 0,(function(){return c(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"}(Pe||(Pe={}));var xe,je,Be,Ve=function(t){function i(e,r,i,n,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:i}),Object.defineProperty(s,"_kind",{enumerable:!0,configurable:!0,writable:!0,value:n}),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(i,t),Object.defineProperty(i.prototype,"getStreamId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._streamId}}),Object.defineProperty(i.prototype,"getTrackId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._id}}),Object.defineProperty(i.prototype,"getUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._userId}}),Object.defineProperty(i.prototype,"__innerGetMediaStreamTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._msTrack}}),Object.defineProperty(i.prototype,"streamTrack",{get:function(){return this._msTrack},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"getTag",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._tag}}),Object.defineProperty(i.prototype,"isLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isLocalTrack}}),Object.defineProperty(i.prototype,"isVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"video"===this._kind}}),Object.defineProperty(i.prototype,"isAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"audio"===this._kind}}),Object.defineProperty(i.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(i.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(n.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(i.prototype,"_setLocalMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){return this._msTrack&&(this._msTrack.enabled=!e),this._localMuted=e,[2,exports.RCRTCCode.SUCCESS]}))}))}}),Object.defineProperty(i.prototype,"mute",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this._setLocalMuted(!0)]}))}))}}),Object.defineProperty(i.prototype,"unmute",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this._setLocalMuted(!1)]}))}))}}),Object.defineProperty(i.prototype,"isLocalMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._localMuted}}),Object.defineProperty(i.prototype,"isMCUTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Boolean(this._roomId)}}),Object.defineProperty(i.prototype,"isOwnerMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._remoteMuted}}),Object.defineProperty(i.prototype,"_validateVolume",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(null==t?void 0:t.volume){if(!e.isNumber(null==t?void 0:t.volume))return this._logger.error(n.L_TRACK_PLAY_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> options.volume not a number"})),{code:exports.RCRTCCode.PARAMS_ERROR};(null==t?void 0:t.volume)<0&&(t.volume=0,this._logger.warn(n.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==t?void 0:t.volume)>100&&(t.volume=100,this._logger.warn(n.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"})))}}}),Object.defineProperty(i.prototype,"_validatePlayOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i;return c(this,(function(a){switch(a.label){case 0:return this._msTrack?("ended"===this._msTrack.readyState&&this._logger.warn(n.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,Me.getSpeakers()]:[3,2]):(this._logger.error(n.L_TRACK_PLAY_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.TRACK_NOT_READY,kind:this._kind,msg:"the track is not ready to play -> id: ".concat(this._id)})),[2,{code:exports.RCRTCCode.TRACK_NOT_READY}]);case 1:if(i=a.sent().map((function(e){return e.deviceId})),!i.includes(t.audioDeviceId))return this._logger.error(n.L_TRACK_PLAY_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> options.audioDeviceId"})),[2,{code:exports.RCRTCCode.PARAMS_ERROR}];a.label=2;case 2:return!this.isVideoTrack()||e&&(e instanceof HTMLVideoElement||this._validateVideoNodeName(e))?[2]:(this._logger.error(n.L_TRACK_PLAY_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.VIDEO_TRACK_MISS_MEDIA_ELEMENT,kind:this._kind,msg:"params element is not a HTMLVideoElement"})),[2,{code:exports.RCRTCCode.VIDEO_TRACK_MISS_MEDIA_ELEMENT}])}}))}))}}),Object.defineProperty(i.prototype,"_setPlayAttrs",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return s(this,void 0,void 0,(function(){return c(this,(function(i){switch(i.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:i.sent(),i.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(i.prototype,"play",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,a=this;return c(this,(function(u){switch(u.label){case 0:return this._logger.info(n.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=u.sent())?[2,r]:(i=this.isVideoTrack(),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=function(e){var t;a._logger.info(n.L_TRACK_LOAD_START_O,JSON.stringify({status:o.INFO,kind:a._kind,msg:"HTMLMediaElement onloadstart -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(a._id)}))},this._element.ondurationchange=function(e){var t;a._logger.info(n.L_TRACK_DURATION_CHANGE_O,JSON.stringify({status:o.INFO,kind:a._kind,msg:"HTMLMediaElement ondurationchange -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(a._id)}))},this._element.onloadedmetadata=function(e){var t;a._logger.info(n.L_TRACK_LOADED_META_DATA_O,JSON.stringify({status:o.INFO,kind:a._kind,msg:"HTMLMediaElement onloadedmetadata -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(a._id)}))},this._element.onloadeddata=function(e){var t;a._logger.info(n.L_TRACK_LOADED_DATA_O,JSON.stringify({status:o.INFO,kind:a._kind,msg:"HTMLMediaElement onloadeddata -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(a._id)}))},this._element.onabort=function(e){var t;a._logger.info(n.L_TRACK_ABORT_O,JSON.stringify({status:o.INFO,kind:a._kind,msg:"HTMLMediaElement onabort -> id: ".concat(null===(t=e.target)||void 0===t?void 0:t.id,", trackId: ").concat(a._id)}))},this._element.oncanplay=function(e){return s(a,void 0,void 0,(function(){var r,a,s;return c(this,(function(c){switch(c.label){case 0:this._logger.info(n.L_TRACK_CANPLAY_O,JSON.stringify({status:o.INFO,kind:this._kind,msg:"HTMLMediaElement oncanplay -> id: ".concat(null===(a=e.target)||void 0===a?void 0:a.id,", trackId: ").concat(this._id)})),c.label=1;case 1:return c.trys.push([1,5,,6]),!(null==t?void 0:t.audioDeviceId)||i?[3,3]:[4,this._element.setSinkId(t.audioDeviceId)];case 2:c.sent(),c.label=3;case 3:return[4,null===(s=this._element)||void 0===s?void 0:s.play()];case 4:return c.sent(),[3,6];case 5:return"No permission to use requested device"===(r=c.sent()).message?(this._logger.error(n.L_TRACK_PLAY_E,JSON.stringify({status:o.FAILED,kind:this._kind,code:exports.RCRTCCode.NO_PERMISSION_TO_USE_REQUESTED_DEVICE,msg:"setSinkId failed, error msg: ".concat(r.message)})),[2]):(this._logger.error(n.L_TRACK_PLAY_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.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,i=Math.floor(100*(null===(t=e.target)||void 0===t?void 0:t.volume));a._logger.info(n.L_TRACK_VOLUME_CHANGE_O,JSON.stringify({status:o.INFO,msg:"HTMLMediaElement onvolumechange -> id: ".concat(null===(r=e.target)||void 0===r?void 0:r.id,", volume: ").concat(i,", trackId: ").concat(a._id)}))},this._element.srcObject=this._msStream,this._element.autoplay=!0,[4,this._setPlayAttrs(i,t)]);case 2:return u.sent(),[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),Object.defineProperty(i.prototype,"__innerDestroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.__innerSetMediaStreamTrack(void 0)}}),Object.defineProperty(i.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(i.prototype,"_validateVideoNodeName",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e&&e.nodeName&&"VIDEO"===e.nodeName.toUpperCase()}}),i}(e.EventEmitter);exports.RCAudioBitrate=void 0,(Be=exports.RCAudioBitrate||(exports.RCAudioBitrate={})).Speech="Speech",Be.Music="Music",Be.MusicHigh="MusicHigh";var Fe,Je=((xe={})[exports.RCAudioBitrate.Music]={max:64,min:64},xe[exports.RCAudioBitrate.MusicHigh]={max:128,min:128},xe[exports.RCAudioBitrate.Speech]={max:32,min:32},xe);exports.RCVideoBitrate=void 0,(Fe=exports.RCVideoBitrate||(exports.RCVideoBitrate={})).LEVEL0="LEVEL0",Fe.LEVEL1="LEVEL1",Fe.LEVEL2="LEVEL2",Fe.LEVEL3="LEVEL3",Fe.LEVEL4="LEVEL4",Fe.LEVEL5="LEVEL5";var Ge=((je={})[exports.RCVideoBitrate.LEVEL0]={max:150,min:80},je[exports.RCVideoBitrate.LEVEL1]={max:280,min:120},je[exports.RCVideoBitrate.LEVEL2]={max:650,min:150},je[exports.RCVideoBitrate.LEVEL3]={max:1e3,min:200},je[exports.RCVideoBitrate.LEVEL4]={max:2200,min:250},je[exports.RCVideoBitrate.LEVEL5]={max:4e3,min:400},je),He=function(){function e(){}return Object.defineProperty(e,"apply3ANoiseWorklet",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,n,o,a,s;return c(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 i=c.sent(),[3,6];case 5:return c.sent(),[2,{code:exports.RCRTCCode.LOAD_3A_MODULE_FAILED}];case 6:return n=r.createMediaStreamSource(new MediaStream([t])),o=new AudioWorkletNode(r,"process-worklet",{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{binary:i}}),a=r.createMediaStreamDestination(),n.connect(o).connect(a),s=a.stream.getAudioTracks()[0],e._maps.set(t.id,r),[2,{code:exports.RCRTCCode.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}(),Ke=function(t){function i(e,r,i,n,o){var a=t.call(this,e,r,i,n,!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(i,t),Object.defineProperty(i.prototype,"_onTrackEnded",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.emit(i.EVENT_LOCAL_TRACK_END,this),this.removeAll(i.EVENT_LOCAL_TRACK_END)}}),Object.defineProperty(i.prototype,"_setLocalMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this;return new Promise((function(o){var a=r._localMuted!==e;t.prototype._setLocalMuted.call(r,e),r._remoteMuted=r._localMuted,a&&r._isPublished?r.emit(i.__INNER_EVENT_MUTED_CHANGE__,r,o):o(exports.RCRTCCode.SUCCESS),r._logger.info(n.L_LOCAL_TRACK_SET_LOCAL_MUTED_O,JSON.stringify({enable:e,trackId:r._id}))}))}}),Object.defineProperty(i.prototype,"__innerSetPublished",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._isPublished=e}}),Object.defineProperty(i.prototype,"isPublished",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isPublished}}),Object.defineProperty(i.prototype,"destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r;void 0===e&&(e=!0),this._isDestroyed||(this._logger.info(n.L_LOCAL_TRACK_DESTROY_O,this._id),this._isDestroyed=!0,null===(r=this._msTrack)||void 0===r||r.stop(),t.prototype.__innerDestroy.call(this),this.isAudioTrack()&&t.prototype.__releaseMediaElement.call(this),this._isPublished&&e&&this.emit(i.__INNER_EVENT_DESTROY__,this))}}),Object.defineProperty(i.prototype,"isDestroyed",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isDestroyed}}),Object.defineProperty(i.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){void 0===t&&(t=0),void 0===r&&(r=0),void 0===i&&(i=0),!e.isNumber(t)||!e.isNumber(r)||!e.isNumber(i)||t<=0||r<=0||t<r?this._logger.error(n.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:o.FAILED,msg:"params error -> max: ".concat(t,",min: ").concat(r,", start: ").concat(i),trackId:this._id})):(this._logger.info(n.L_LOCAL_TRACK_SET_BITRATE_O,JSON.stringify({status:o.SUCCESSED,max:t,min:r,start:i,trackId:this._id})),this._bitrateInfo={max:t,min:r,start:i})}}),Object.defineProperty(i.prototype,"getBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t,r,i,n,o,a,s,c,u=0,l=0,d=0;return(null===(r=this._msTrack)||void 0===r?void 0:r.kind)===Pe.VIDEO?(u=(e=ut(this._msTrack)).min,l=e.max):(null===(i=this._msTrack)||void 0===i?void 0:i.kind)===Pe.AUDIO&&(u=(t={min:32,max:32}).min,l=t.max),(null===(n=this._bitrateInfo)||void 0===n?void 0:n.max)&&(d=.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)||d}}}),Object.defineProperty(i.prototype,"getSettings",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return null===(e=this._msTrack)||void 0===e?void 0:e.getSettings()}}),Object.defineProperty(i,"EVENT_LOCAL_TRACK_END",{enumerable:!0,configurable:!0,writable:!0,value:"local-track-end"}),Object.defineProperty(i,"__INNER_EVENT_MUTED_CHANGE__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-muted-change"}),Object.defineProperty(i,"__INNER_EVENT_DESTROY__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-destroy"}),i}(Ve),We=function(t){function i(e,r,i,n){return t.call(this,e,r,i,"audio",n)||this}return r(i,t),Object.defineProperty(i.prototype,"setRecommendBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(e.validate("audioBitrate",t,(function(e){return e in exports.RCAudioBitrate}))){var r=Je[t];this.setBitrate(r.max,r.min,r.start||.7*r.max)}else this._logger.warn(n.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:o.FAILED,msg:"params error -> params type is RCAudioBitrate"}))}}),Object.defineProperty(i.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var n=l(r,2),o=n[0],a=void 0===o?1:o,s=n[1],c=void 0===s?.7*e||1:s;t.prototype.setBitrate.call(this,e,a,c)}}),i}(Ke),Ye=function(t){function i(e,r,i,n,o){void 0===o&&(o=!1);var a=t.call(this,e,r,i,"video",n)||this;return Object.defineProperty(a,"_isTiny",{enumerable:!0,configurable:!0,writable:!0,value:o}),a}return r(i,t),Object.defineProperty(i.prototype,"__isTiny",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isTiny}}),Object.defineProperty(i.prototype,"getStreamId",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=t.prototype.getStreamId.call(this);return this._isTiny?"".concat(e,"_tiny"):e}}),Object.defineProperty(i.prototype,"getTrackId",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=t.prototype.getTrackId.call(this);return this._isTiny?"".concat(e,"_tiny"):e}}),Object.defineProperty(i.prototype,"setRecommendBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(e.validate("videoBitrate",t,(function(e){return e in exports.RCVideoBitrate}))){var r=Ge[t];this.setBitrate(r.max,r.min,r.start||.7*r.max)}else this._logger.warn(n.L_RTC_SET_RECOMMEND_BITRATE_O,JSON.stringify({status:o.FAILED,msg:"params error -> params type is RCVideoBitrate"}))}}),Object.defineProperty(i.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var n=l(r,2),o=n[0],a=void 0===o?1:o,s=n[1],c=void 0===s?.7*e||1:s;t.prototype.setBitrate.call(this,e,a,c)}}),i}(Ke),ze=function(e){function t(r,i,n,o,a,s){var c=e.call(this,r,i,n,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,i,n=null===(r=this._mapping.get(t))||void 0===r?void 0:r.filter((function(t){return 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))}}),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}(Ke),qe=function(e){function t(t,r,i,n,o){return e.call(this,t,r,i,"video",n,o)||this}return r(t,e),t}(ze),Qe=function(e){function t(t,r,i,n,o){return e.call(this,t,r,i,"audio",n,o)||this}return r(t,e),Object.defineProperty(t.prototype,"_setLocalMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){return c(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 s(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this._setLocalMuted(!1)];case 1:return[2,{code:e.sent()}]}}))}))}}),t}(ze),Ze=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 s(this,void 0,void 0,(function(){var e,t,r;return c(this,(function(i){switch(i.label){case 0:return this._logger.info(n.A_APPLY_3A_NOISE_WORKLET_T),this._originTrack?(this._logger.warn(n.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:o.FAILED,msg:"3A noise module already applied"})),[2,{code:exports.RCRTCCode.SUCCESS}]):!this._msTrack||this.isDestroyed()?(this._logger.warn(n.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:o.FAILED,msg:"track not ready"})),[2,{code:exports.RCRTCCode.TRACK_NOT_READY}]):this.isPublished()?(this._logger.warn(n.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:o.FAILED,msg:"track already published"})),[2,{code:exports.RCRTCCode.APPLY_3A_NOISE_WORKLET_BEFORE_PUBLISH}]):[4,He.apply3ANoiseWorklet(this._msTrack)];case 1:return e=i.sent(),t=e.code,r=e.track,t===exports.RCRTCCode.SUCCESS&&r?(this._originTrack=this._msTrack,this._msTrack=r,this._logger.info(n.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:o.SUCCESSED})),[2,{code:exports.RCRTCCode.SUCCESS}]):(this._logger.warn(n.A_APPLY_3A_NOISE_WORKLET_R,JSON.stringify({status:o.FAILED,msg:"apply 3A noise module failed: ".concat(t),SCRIPT_URL:He.SCRIPT_URL,WASM_URL:He.WASM_URL})),[2,{code:t}])}}))}))}}),Object.defineProperty(t.prototype,"__innerSetMediaStreamTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(t){!t&&this._originTrack&&(He.release3ANoiseWorklet(this._originTrack),this._originTrack.stop(),this._originTrack=null),e.prototype.__innerSetMediaStreamTrack.call(this,t)}}),Object.defineProperty(t.prototype,"replaceInnerTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){}}),t}(We),Xe=function(e){function t(t,r,i,n,o){return void 0===o&&(o=!1),e.call(this,t,r,i,n,o)||this}return r(t,e),Object.defineProperty(t.prototype,"replaceInnerTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){}}),t}(Ye),$e=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(Ke.__INNER_EVENT_DESTROY__,this)}}),t}(Ye),et=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(Ke.__INNER_EVENT_DESTROY__,this)}}),t}(We),tt=function(e){function t(t,r,i,n,o){var a=e.call(this,t,r,i,n,!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}(Ve),rt=function(e){function t(t,r,i,n){return e.call(this,t,r,i,"audio",n)||this}return r(t,e),Object.defineProperty(t.prototype,"_setLocalMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=Ct.browser,i=Ct.version;return this._element&&i&&/chrome/i.test(r)&&i>=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}(tt),it=function(e){function t(t,r,i,n){var o=e.call(this,t,r,i,"video",n)||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}(tt),nt=function(e,t){return{name:e,content:JSON.stringify({uris:t,ignore:!0})}},ot=function(e){return JSON.stringify(e)},at=function(e){return/^[a-zA-Z\d-=]+$/g.test(e)},st=function(t){if(void 0===t)return 0;if(e.isNumber(t))return t;var r=t;return r.exact||r.ideal||r.max||0},ct=function(e){var t=e.getSettings(),r=e.getConstraints();return{width:st(r.width)||t.width||0,height:st(r.height)||t.height||0,frameRate:t.frameRate||st(r.frameRate)}},ut=function(e){var t=ct(e),r=t.width,i=t.height,n=t.frameRate,o=De(r||1920,i||1080),a=Ue(n);return{min:o.minBitrate*a,max:o.maxBitrate*a}},lt=function(e){return[e.msid,e.mediaType].join("_")},dt=function(e){var t=e.split("_");return{mediaType:parseInt(t.pop()),tag:t.pop(),userId:t.join("_")}},_t=function(e,t){return[e,t].join("_")},pt=function(e){return e.map((function(e){return a({},e)}))},ft=function(e,t,r){void 0===r&&(r=!1),e=e.slice();var i=[],n=[],o=[];return t.forEach((function(t){var n=lt(t),a=e.findIndex((function(e){return lt(e)===n}));if(r&&(a=e.findIndex((function(e){return e.uri===t.uri}))),-1!==a){var s=e[a];s.uri!==t.uri?i.push(t):s.state!==t.state&&o.push(t),e.splice(a,1)}else i.push(t)})),n.push.apply(n,d([],l(e),!1)),{publishedList:i,unpublishedList:n,modifiedList:o}},ht=function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return e="".concat(e.replace(/-/g,""),"0"),(e=function(e){var t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),r=t.length+1,i=+e,n=[];do{var o=i%r;i=(i-o)/r,n.unshift(t[o])}while(i);return n.join("")}(e=parseInt(e,16))).length>22&&(e=e.slice(0,22)),e},bt=function(e){if(Ne[e]){var t=Ne[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]}},Rt=function(e){return!!exports.RCResolution[e]},gt=function(e){return!!exports.RCFrameRate[e]},mt=function(e){return parseInt(e.replace("FPS_",""))},Ct=function(){var e=Se.browserDetails;return{browser:e.browser,version:e.version,supportsUnifiedPlan:!1!==e.supportsUnifiedPlan}}();function vt(){return"captureStream"in HTMLMediaElement.prototype||"mozCaptureStream"in HTMLMediaElement.prototype}function Ot(){return"mediaDevices"in navigator&&"getDisplayMedia"in navigator.mediaDevices}var Tt,Et,St=function(e){return"[object Null]"===Object.prototype.toString.call(e)},It=function(e){return 1===e.type},yt=function(e,t,r,i){var o={},a=Object.keys(e.users);return a.length&&a.forEach((function(a){var s=[],c=e.users[a];if(c.extra){var u=JSON.parse(c.extra).roomId;if(t!==u)return}if(c.uris)try{s.push.apply(s,d([],l(JSON.parse(c.uris)),!1))}catch(e){r.warn(n.L_PARSE_ROOMDATA_URIS_R,"invalid user data -> userId: ".concat(a,", userData: ").concat(c),i)}o[a]=s})),o},Lt=function(e){return e instanceof Ve?e.getTrackId():e.track.getTrackId()},At=function(t){if(!e.isObject(t)||void 0===t.low||void 0===t.high)return t;var r=t.low;return r<0&&(r+=4294967296),r=r.toString(16),parseInt(t.high.toString(16)+"00000000".replace(new RegExp("0{".concat(r.length,"}$")),r),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",e.ASR_STATUS="RCRTC:AsrStatus",e.ASR_SEI="RCRTC:PublishSeiAi"}(Tt||(Tt={})),exports.RCRTCPingResult=void 0,(Et=exports.RCRTCPingResult||(exports.RCRTCPingResult={})).SUCCESS="Success",Et.FAIL="Fail";var Pt=function(){function t(e,t,r,i){void 0===i&&(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}return Object.defineProperty(t.prototype,"start",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._started||(e<15e3&&(e=15e3),this._logger.info(n.L_PINGER_START_O,JSON.stringify({interval:this._gap,offlineKickTime:e})),this._started=!0,this._checkAlive(e))}}),Object.defineProperty(t.prototype,"_sendPing",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;return new Promise((function(r){t._context.rtcPing(t._roomId,t._roomMode).then(r),setTimeout(r,5e3,{code:e.ErrorCode.TIMEOUT})}))}}),Object.defineProperty(t.prototype,"_checkAlive",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,o,a,s,u,l=this;return c(this,(function(c){switch(c.label){case 0:return r=this._context.logger,i=r.createTraceId(),[4,this._sendPing()];case 1:return o=c.sent(),a=o.code,s=o.data,this._started?(u=Date.now(),a===e.ErrorCode.SUCCESS?(this._latestTimestamp=u,this.onPingResult(exports.RCRTCPingResult.SUCCESS,s.version),this._timer=setTimeout((function(){return l._checkAlive(t)}),this._gap),[2]):(r.error(n.L_PINGER_SEND_RTCPING_E,JSON.stringify({roomId:this._roomId,code:a}),i),this.onPingResult(exports.RCRTCPingResult.FAIL),40003===a||u-this._latestTimestamp>t?(this.stop(),this.onFailed(40003===a),[2]):(this._timer=setTimeout((function(){return l._checkAlive(t)}),this._gap),[2]))):[2]}}))}))}}),Object.defineProperty(t.prototype,"stop",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._started&&(this._logger.info(n.L_PINGER_STOP_O),this._started=!1,this._timer&&(clearTimeout(this._timer),this._timer=null))}}),t}();function Nt(e){let t=e.length;for(;--t>=0;)e[t]=0}const wt=256,Dt=286,kt=30,Ut=15,Mt=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]),xt=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]),jt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Bt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Vt=new Array(576);Nt(Vt);const Ft=new Array(60);Nt(Ft);const Jt=new Array(512);Nt(Jt);const Gt=new Array(256);Nt(Gt);const Ht=new Array(29);Nt(Ht);const Kt=new Array(kt);function Wt(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 Yt,zt,qt;function Qt(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Nt(Kt);const Zt=e=>e<256?Jt[e]:Jt[256+(e>>>7)],Xt=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},$t=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,Xt(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)},er=(e,t,r)=>{$t(e,r[2*t],r[2*t+1])},tr=(e,t)=>{let r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1},rr=(e,t,r)=>{const i=new Array(16);let n,o,a=0;for(n=1;n<=Ut;n++)a=a+r[n-1]<<1,i[n]=a;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=tr(i[t]++,t))}},ir=e=>{let t;for(t=0;t<Dt;t++)e.dyn_ltree[2*t]=0;for(t=0;t<kt;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},nr=e=>{e.bi_valid>8?Xt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},or=(e,t,r,i)=>{const n=2*t,o=2*r;return e[n]<e[o]||e[n]===e[o]&&i[t]<=i[r]},ar=(e,t,r)=>{const i=e.heap[r];let n=r<<1;for(;n<=e.heap_len&&(n<e.heap_len&&or(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!or(t,i,e.heap[n],e.depth));)e.heap[r]=e.heap[n],r=n,n<<=1;e.heap[r]=i},sr=(e,t,r)=>{let i,n,o,a,s=0;if(0!==e.sym_next)do{i=255&e.pending_buf[e.sym_buf+s++],i+=(255&e.pending_buf[e.sym_buf+s++])<<8,n=e.pending_buf[e.sym_buf+s++],0===i?er(e,n,t):(o=Gt[n],er(e,o+wt+1,t),a=Mt[o],0!==a&&(n-=Ht[o],$t(e,n,a)),i--,o=Zt(i),er(e,o,r),a=xt[o],0!==a&&(i-=Kt[o],$t(e,i,a)))}while(s<e.sym_next);er(e,256,t)},cr=(e,t)=>{const r=t.dyn_tree,i=t.stat_desc.static_tree,n=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--,n&&(e.static_len-=i[2*c+1]);for(t.max_code=u,a=e.heap_len>>1;a>=1;a--)ar(e,r,a);c=o;do{a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ar(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++,ar(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,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,_,p,f,h=0;for(_=0;_<=Ut;_++)e.bl_count[_]=0;for(r[2*e.heap[e.heap_max]+1]=0,u=e.heap_max+1;u<573;u++)l=e.heap[u],_=r[2*r[2*l+1]+1]+1,_>c&&(_=c,h++),r[2*l+1]=_,l>i||(e.bl_count[_]++,p=0,l>=s&&(p=a[l-s]),f=r[2*l],e.opt_len+=f*(_+p),o&&(e.static_len+=f*(n[2*l+1]+p)));if(0!==h){do{for(_=c-1;0===e.bl_count[_];)_--;e.bl_count[_]--,e.bl_count[_+1]+=2,e.bl_count[c]--,h-=2}while(h>0);for(_=c;0!==_;_--)for(l=e.bl_count[_];0!==l;)d=e.heap[--u],d>i||(r[2*d+1]!==_&&(e.opt_len+=(_-r[2*d+1])*r[2*d],r[2*d+1]=_),l--)}})(e,t),rr(r,u,e.bl_count)},ur=(e,t,r)=>{let i,n,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),t[2*(r+1)+1]=65535,i=0;i<=r;i++)n=a,a=t[2*(i+1)+1],++s<c&&n===a||(s<u?e.bl_tree[2*n]+=s:0!==n?(n!==o&&e.bl_tree[2*n]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=0,o=n,0===a?(c=138,u=3):n===a?(c=6,u=3):(c=7,u=4))},lr=(e,t,r)=>{let i,n,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),i=0;i<=r;i++)if(n=a,a=t[2*(i+1)+1],!(++s<c&&n===a)){if(s<u)do{er(e,n,e.bl_tree)}while(0!=--s);else 0!==n?(n!==o&&(er(e,n,e.bl_tree),s--),er(e,16,e.bl_tree),$t(e,s-3,2)):s<=10?(er(e,17,e.bl_tree),$t(e,s-3,3)):(er(e,18,e.bl_tree),$t(e,s-11,7));s=0,o=n,0===a?(c=138,u=3):n===a?(c=6,u=3):(c=7,u=4)}};let dr=!1;const _r=(e,t,r,i)=>{$t(e,0+(i?1:0),3),nr(e),Xt(e,r),Xt(e,~r),r&&e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r};var pr=(e,t,r,i)=>{let n,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<wt;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),cr(e,e.l_desc),cr(e,e.d_desc),a=(e=>{let t;for(ur(e,e.dyn_ltree,e.l_desc.max_code),ur(e,e.dyn_dtree,e.d_desc.max_code),cr(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Bt[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),n=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=n&&(n=o)):n=o=r+5,r+4<=n&&-1!==t?_r(e,t,r,i):4===e.strategy||o===n?($t(e,2+(i?1:0),3),sr(e,Vt,Ft)):($t(e,4+(i?1:0),3),((e,t,r,i)=>{let n;for($t(e,t-257,5),$t(e,r-1,5),$t(e,i-4,4),n=0;n<i;n++)$t(e,e.bl_tree[2*Bt[n]+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),sr(e,e.dyn_ltree,e.dyn_dtree)),ir(e),i&&nr(e)},fr={_tr_init:e=>{dr||((()=>{let e,t,r,i,n;const o=new Array(16);for(r=0,i=0;i<28;i++)for(Ht[i]=r,e=0;e<1<<Mt[i];e++)Gt[r++]=i;for(Gt[r-1]=i,n=0,i=0;i<16;i++)for(Kt[i]=n,e=0;e<1<<xt[i];e++)Jt[n++]=i;for(n>>=7;i<kt;i++)for(Kt[i]=n<<7,e=0;e<1<<xt[i]-7;e++)Jt[256+n++]=i;for(t=0;t<=Ut;t++)o[t]=0;for(e=0;e<=143;)Vt[2*e+1]=8,e++,o[8]++;for(;e<=255;)Vt[2*e+1]=9,e++,o[9]++;for(;e<=279;)Vt[2*e+1]=7,e++,o[7]++;for(;e<=287;)Vt[2*e+1]=8,e++,o[8]++;for(rr(Vt,287,o),e=0;e<kt;e++)Ft[2*e+1]=5,Ft[2*e]=tr(e,5);Yt=new Wt(Vt,Mt,257,Dt,Ut),zt=new Wt(Ft,xt,0,kt,Ut),qt=new Wt(new Array(0),jt,0,19,7)})(),dr=!0),e.l_desc=new Qt(e.dyn_ltree,Yt),e.d_desc=new Qt(e.dyn_dtree,zt),e.bl_desc=new Qt(e.bl_tree,qt),e.bi_buf=0,e.bi_valid=0,ir(e)},_tr_stored_block:_r,_tr_flush_block:pr,_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*(Gt[r]+wt+1)]++,e.dyn_dtree[2*Zt(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{$t(e,2,3),er(e,256,Vt),(e=>{16===e.bi_valid?(Xt(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 hr=(e,t,r,i)=>{let n=65535&e,o=e>>>16&65535,a=0;for(;0!==r;){a=r>2e3?2e3:r,r-=a;do{n=n+t[i++]|0,o=o+n|0}while(--a);n%=65521,o%=65521}return n|o<<16};const br=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 Rr=(e,t,r,i)=>{const n=br,o=i+r;e^=-1;for(let r=i;r<o;r++)e=e>>>8^n[255&(e^t[r])];return~e},gr={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"},mr={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:Cr,_tr_stored_block:vr,_tr_flush_block:Or,_tr_tally:Tr,_tr_align:Er}=fr,{Z_NO_FLUSH:Sr,Z_PARTIAL_FLUSH:Ir,Z_FULL_FLUSH:yr,Z_FINISH:Lr,Z_BLOCK:Ar,Z_OK:Pr,Z_STREAM_END:Nr,Z_STREAM_ERROR:wr,Z_DATA_ERROR:Dr,Z_BUF_ERROR:kr,Z_DEFAULT_COMPRESSION:Ur,Z_FILTERED:Mr,Z_HUFFMAN_ONLY:xr,Z_RLE:jr,Z_FIXED:Br,Z_DEFAULT_STRATEGY:Vr,Z_UNKNOWN:Fr,Z_DEFLATED:Jr}=mr,Gr=258,Hr=262,Kr=42,Wr=113,Yr=666,zr=(e,t)=>(e.msg=gr[t],t),qr=e=>2*e-(e>4?9:0),Qr=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Zr=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 Xr=(e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask;const $r=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))},ei=(e,t)=>{Or(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,$r(e.strm)},ti=(e,t)=>{e.pending_buf[e.pending++]=t},ri=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},ii=(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=hr(e.adler,t,n,r):2===e.state.wrap&&(e.adler=Rr(e.adler,t,n,r)),e.next_in+=n,e.total_in+=n,n)},ni=(e,t)=>{let r,i,n=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match;const c=e.strstart>e.w_size-Hr?e.strstart-(e.w_size-Hr):0,u=e.window,l=e.w_mask,d=e.prev,_=e.strstart+Gr;let p=u[o+a-1],f=u[o+a];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(r=t,u[r+a]===f&&u[r+a-1]===p&&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<_);if(i=Gr-(_-o),o=_-Gr,i>a){if(e.match_start=t,a=i,i>=s)break;p=u[o+a-1],f=u[o+a]}}}while((t=d[t&l])>c&&0!=--n);return a<=e.lookahead?a:e.lookahead},oi=e=>{const t=e.w_size;let r,i,n;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Hr)&&(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),Zr(e),i+=t),0===e.strm.avail_in)break;if(r=ii(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=Xr(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=Xr(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<Hr&&0!==e.strm.avail_in)},ai=(e,t)=>{let r,i,n,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,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<o&&(0===r&&t!==Lr||t===Sr||r!==i+e.strm.avail_in))break;a=t===Lr&&r===i+e.strm.avail_in?1:0,vr(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,$r(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&&(ii(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!==Sr&&t!==Lr&&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&&(ii(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,o=n>e.w_size?e.w_size:n,i=e.strstart-e.block_start,(i>=o||(i||t===Lr)&&t!==Sr&&0===e.strm.avail_in&&i<=n)&&(r=i>n?n:i,a=t===Lr&&0===e.strm.avail_in&&r===i?1:0,vr(e,e.block_start,r,a),e.block_start+=r,$r(e.strm)),a?3:1)},si=(e,t)=>{let r,i;for(;;){if(e.lookahead<Hr){if(oi(e),e.lookahead<Hr&&t===Sr)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=Xr(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-Hr&&(e.match_length=ni(e,r)),e.match_length>=3)if(i=Tr(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=Xr(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=Xr(e,e.ins_h,e.window[e.strstart+1]);else i=Tr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(ei(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Lr?(ei(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ei(e,!1),0===e.strm.avail_out)?1:2},ci=(e,t)=>{let r,i,n;for(;;){if(e.lookahead<Hr){if(oi(e),e.lookahead<Hr&&t===Sr)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=Xr(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-Hr&&(e.match_length=ni(e,r),e.match_length<=5&&(e.strategy===Mr||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=Tr(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=Xr(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&&(ei(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=Tr(e,0,e.window[e.strstart-1]),i&&ei(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=Tr(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Lr?(ei(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ei(e,!1),0===e.strm.avail_out)?1:2};function ui(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 li=[new ui(0,0,0,0,ai),new ui(4,4,8,4,si),new ui(4,5,16,8,si),new ui(4,6,32,32,si),new ui(4,4,16,16,ci),new ui(8,16,32,32,ci),new ui(8,16,128,128,ci),new ui(8,32,128,256,ci),new ui(32,128,258,1024,ci),new ui(32,258,258,4096,ci)];function di(){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=Jr,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),Qr(this.dyn_ltree),Qr(this.dyn_dtree),Qr(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),Qr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Qr(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 _i=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Kr&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Wr&&t.status!==Yr?1:0},pi=e=>{if(_i(e))return zr(e,wr);e.total_in=e.total_out=0,e.data_type=Fr;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?Kr:Wr,e.adler=2===t.wrap?0:1,t.last_flush=-2,Cr(t),Pr},fi=e=>{const t=pi(e);var r;return t===Pr&&((r=e.state).window_size=2*r.w_size,Qr(r.head),r.max_lazy_match=li[r.level].max_lazy,r.good_match=li[r.level].good_length,r.nice_match=li[r.level].nice_length,r.max_chain_length=li[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},hi=(e,t,r,i,n,o)=>{if(!e)return wr;let a=1;if(t===Ur&&(t=6),i<0?(a=0,i=-i):i>15&&(a=2,i-=16),n<1||n>9||r!==Jr||i<8||i>15||t<0||t>9||o<0||o>Br||8===i&&1!==a)return zr(e,wr);8===i&&(i=9);const s=new di;return e.state=s,s.strm=e,s.status=Kr,s.wrap=a,s.gzhead=null,s.w_bits=i,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=n+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<<n+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,fi(e)};var bi={deflateInit:(e,t)=>hi(e,t,Jr,15,8,Vr),deflateInit2:hi,deflateReset:fi,deflateResetKeep:pi,deflateSetHeader:(e,t)=>_i(e)||2!==e.state.wrap?wr:(e.state.gzhead=t,Pr),deflate:(e,t)=>{if(_i(e)||t>Ar||t<0)return e?zr(e,wr):wr;const r=e.state;if(!e.output||0!==e.avail_in&&!e.input||r.status===Yr&&t!==Lr)return zr(e,0===e.avail_out?kr:wr);const i=r.last_flush;if(r.last_flush=t,0!==r.pending){if($r(e),0===e.avail_out)return r.last_flush=-1,Pr}else if(0===e.avail_in&&qr(t)<=qr(i)&&t!==Lr)return zr(e,kr);if(r.status===Yr&&0!==e.avail_in)return zr(e,kr);if(r.status===Kr&&0===r.wrap&&(r.status=Wr),r.status===Kr){let t=Jr+(r.w_bits-8<<4)<<8,i=-1;if(i=r.strategy>=xr||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,ri(r,t),0!==r.strstart&&(ri(r,e.adler>>>16),ri(r,65535&e.adler)),e.adler=1,r.status=Wr,$r(e),0!==r.pending)return r.last_flush=-1,Pr}if(57===r.status)if(e.adler=0,ti(r,31),ti(r,139),ti(r,8),r.gzhead)ti(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)),ti(r,255&r.gzhead.time),ti(r,r.gzhead.time>>8&255),ti(r,r.gzhead.time>>16&255),ti(r,r.gzhead.time>>24&255),ti(r,9===r.level?2:r.strategy>=xr||r.level<2?4:0),ti(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(ti(r,255&r.gzhead.extra.length),ti(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=Rr(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(ti(r,0),ti(r,0),ti(r,0),ti(r,0),ti(r,0),ti(r,9===r.level?2:r.strategy>=xr||r.level<2?4:0),ti(r,3),r.status=Wr,$r(e),0!==r.pending)return r.last_flush=-1,Pr;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=Rr(e.adler,r.pending_buf,r.pending-t,t)),r.gzindex+=n,$r(e),0!==r.pending)return r.last_flush=-1,Pr;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=Rr(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=Rr(e.adler,r.pending_buf,r.pending-i,i)),$r(e),0!==r.pending)return r.last_flush=-1,Pr;i=0}t=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,ti(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>i&&(e.adler=Rr(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=Rr(e.adler,r.pending_buf,r.pending-i,i)),$r(e),0!==r.pending)return r.last_flush=-1,Pr;i=0}t=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,ti(r,t)}while(0!==t);r.gzhead.hcrc&&r.pending>i&&(e.adler=Rr(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&&($r(e),0!==r.pending))return r.last_flush=-1,Pr;ti(r,255&e.adler),ti(r,e.adler>>8&255),e.adler=0}if(r.status=Wr,$r(e),0!==r.pending)return r.last_flush=-1,Pr}if(0!==e.avail_in||0!==r.lookahead||t!==Sr&&r.status!==Yr){let i=0===r.level?ai(r,t):r.strategy===xr?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(oi(e),0===e.lookahead)){if(t===Sr)return 1;break}if(e.match_length=0,r=Tr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(ei(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Lr?(ei(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ei(e,!1),0===e.strm.avail_out)?1:2})(r,t):r.strategy===jr?((e,t)=>{let r,i,n,o;const a=e.window;for(;;){if(e.lookahead<=Gr){if(oi(e),e.lookahead<=Gr&&t===Sr)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=e.strstart-1,i=a[n],i===a[++n]&&i===a[++n]&&i===a[++n])){o=e.strstart+Gr;do{}while(i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&n<o);e.match_length=Gr-(o-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=Tr(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=Tr(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(ei(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Lr?(ei(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ei(e,!1),0===e.strm.avail_out)?1:2})(r,t):li[r.level].func(r,t);if(3!==i&&4!==i||(r.status=Yr),1===i||3===i)return 0===e.avail_out&&(r.last_flush=-1),Pr;if(2===i&&(t===Ir?Er(r):t!==Ar&&(vr(r,0,0,!1),t===yr&&(Qr(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),$r(e),0===e.avail_out))return r.last_flush=-1,Pr}return t!==Lr?Pr:r.wrap<=0?Nr:(2===r.wrap?(ti(r,255&e.adler),ti(r,e.adler>>8&255),ti(r,e.adler>>16&255),ti(r,e.adler>>24&255),ti(r,255&e.total_in),ti(r,e.total_in>>8&255),ti(r,e.total_in>>16&255),ti(r,e.total_in>>24&255)):(ri(r,e.adler>>>16),ri(r,65535&e.adler)),$r(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?Pr:Nr)},deflateEnd:e=>{if(_i(e))return wr;const t=e.state.status;return e.state=null,t===Wr?zr(e,Dr):Pr},deflateSetDictionary:(e,t)=>{let r=t.length;if(_i(e))return wr;const i=e.state,n=i.wrap;if(2===n||1===n&&i.status!==Kr||i.lookahead)return wr;if(1===n&&(e.adler=hr(e.adler,t,r,0)),i.wrap=0,r>=i.w_size){0===n&&(Qr(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 o=e.avail_in,a=e.next_in,s=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,oi(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=Xr(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,oi(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=a,e.input=s,e.avail_in=o,i.wrap=n,Pr},deflateInfo:"pako deflate (from Nodeca project)"};const Ri=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var gi=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)Ri(r,t)&&(e[t]=r[t])}}return e},mi=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 Ci=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){Ci=!1}const vi=new Uint8Array(256);for(let e=0;e<256;e++)vi[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;vi[254]=vi[254]=1;var Oi=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,r,i,n,o,a=e.length,s=0;for(n=0;n<a;n++)r=e.charCodeAt(n),55296==(64512&r)&&n+1<a&&(i=e.charCodeAt(n+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),n++)),s+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(s),o=0,n=0;o<s;n++)r=e.charCodeAt(n),55296==(64512&r)&&n+1<a&&(i=e.charCodeAt(n+1),56320==(64512&i)&&(r=65536+(r-55296<<10)+(i-56320),n++)),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},Ti=(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 o=new Array(2*r);for(n=0,i=0;i<r;){let t=e[i++];if(t<128){o[n++]=t;continue}let a=vi[t];if(a>4)o[n++]=65533,i+=a-1;else{for(t&=2===a?31:3===a?15:7;a>1&&i<r;)t=t<<6|63&e[i++],a--;a>1?o[n++]=65533:t<65536?o[n++]=t:(t-=65536,o[n++]=55296|t>>10&1023,o[n++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Ci)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})(o,n)},Ei=(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+vi[e[r]]>t?r:t};var Si=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 Ii=Object.prototype.toString,{Z_NO_FLUSH:yi,Z_SYNC_FLUSH:Li,Z_FULL_FLUSH:Ai,Z_FINISH:Pi,Z_OK:Ni,Z_STREAM_END:wi,Z_DEFAULT_COMPRESSION:Di,Z_DEFAULT_STRATEGY:ki,Z_DEFLATED:Ui}=mr;function Mi(e){this.options=gi({level:Di,method:Ui,chunkSize:16384,windowBits:15,memLevel:8,strategy:ki},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 Si,this.strm.avail_out=0;let r=bi.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(r!==Ni)throw new Error(gr[r]);if(t.header&&bi.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Oi(t.dictionary):"[object ArrayBuffer]"===Ii.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,r=bi.deflateSetDictionary(this.strm,e),r!==Ni)throw new Error(gr[r]);this._dict_set=!0}}function xi(e,t){const r=new Mi(t);if(r.push(e,!0),r.err)throw r.msg||gr[r.err];return r.result}Mi.prototype.push=function(e,t){const r=this.strm,i=this.options.chunkSize;let n,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?Pi:yi,"string"==typeof e?r.input=Oi(e):"[object ArrayBuffer]"===Ii.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),(o===Li||o===Ai)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(n=bi.deflate(r,o),n===wi)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),n=bi.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Ni;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},Mi.prototype.onData=function(e){this.chunks.push(e)},Mi.prototype.onEnd=function(e){e===Ni&&(this.result=mi(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ji={Deflate:Mi,deflate:xi,deflateRaw:function(e,t){return(t=t||{}).raw=!0,xi(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,xi(e,t)},constants:mr};const Bi=16209;var Vi=function(e,t){let r,i,n,o,a,s,c,u,l,d,_,p,f,h,b,R,g,m,C,v,O,T,E,S;const I=e.state;r=e.next_in,E=e.input,i=r+(e.avail_in-5),n=e.next_out,S=e.output,o=n-(t-e.avail_out),a=n+(e.avail_out-257),s=I.dmax,c=I.wsize,u=I.whave,l=I.wnext,d=I.window,_=I.hold,p=I.bits,f=I.lencode,h=I.distcode,b=(1<<I.lenbits)-1,R=(1<<I.distbits)-1;e:do{p<15&&(_+=E[r++]<<p,p+=8,_+=E[r++]<<p,p+=8),g=f[_&b];t:for(;;){if(m=g>>>24,_>>>=m,p-=m,m=g>>>16&255,0===m)S[n++]=65535&g;else{if(!(16&m)){if(64&m){if(32&m){I.mode=16191;break e}e.msg="invalid literal/length code",I.mode=Bi;break e}g=f[(65535&g)+(_&(1<<m)-1)];continue t}for(C=65535&g,m&=15,m&&(p<m&&(_+=E[r++]<<p,p+=8),C+=_&(1<<m)-1,_>>>=m,p-=m),p<15&&(_+=E[r++]<<p,p+=8,_+=E[r++]<<p,p+=8),g=h[_&R];;){if(m=g>>>24,_>>>=m,p-=m,m=g>>>16&255,16&m){if(v=65535&g,m&=15,p<m&&(_+=E[r++]<<p,p+=8,p<m&&(_+=E[r++]<<p,p+=8)),v+=_&(1<<m)-1,v>s){e.msg="invalid distance too far back",I.mode=Bi;break e}if(_>>>=m,p-=m,m=n-o,v>m){if(m=v-m,m>u&&I.sane){e.msg="invalid distance too far back",I.mode=Bi;break e}if(O=0,T=d,0===l){if(O+=c-m,m<C){C-=m;do{S[n++]=d[O++]}while(--m);O=n-v,T=S}}else if(l<m){if(O+=c+l-m,m-=l,m<C){C-=m;do{S[n++]=d[O++]}while(--m);if(O=0,l<C){m=l,C-=m;do{S[n++]=d[O++]}while(--m);O=n-v,T=S}}}else if(O+=l-m,m<C){C-=m;do{S[n++]=d[O++]}while(--m);O=n-v,T=S}for(;C>2;)S[n++]=T[O++],S[n++]=T[O++],S[n++]=T[O++],C-=3;C&&(S[n++]=T[O++],C>1&&(S[n++]=T[O++]))}else{O=n-v;do{S[n++]=S[O++],S[n++]=S[O++],S[n++]=S[O++],C-=3}while(C>2);C&&(S[n++]=S[O++],C>1&&(S[n++]=S[O++]))}break}if(64&m){e.msg="invalid distance code",I.mode=Bi;break e}g=h[(65535&g)+(_&(1<<m)-1)]}}break}}while(r<i&&n<a);C=p>>3,r-=C,p-=C<<3,_&=(1<<p)-1,e.next_in=r,e.next_out=n,e.avail_in=r<i?i-r+5:5-(r-i),e.avail_out=n<a?a-n+257:257-(n-a),I.hold=_,I.bits=p};const Fi=15,Ji=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]),Gi=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]),Hi=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]),Ki=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 Wi=(e,t,r,i,n,o,a,s)=>{const c=s.bits;let u,l,d,_,p,f,h=0,b=0,R=0,g=0,m=0,C=0,v=0,O=0,T=0,E=0,S=null;const I=new Uint16Array(16),y=new Uint16Array(16);let L,A,P,N=null;for(h=0;h<=Fi;h++)I[h]=0;for(b=0;b<i;b++)I[t[r+b]]++;for(m=c,g=Fi;g>=1&&0===I[g];g--);if(m>g&&(m=g),0===g)return n[o++]=20971520,n[o++]=20971520,s.bits=1,0;for(R=1;R<g&&0===I[R];R++);for(m<R&&(m=R),O=1,h=1;h<=Fi;h++)if(O<<=1,O-=I[h],O<0)return-1;if(O>0&&(0===e||1!==g))return-1;for(y[1]=0,h=1;h<Fi;h++)y[h+1]=y[h]+I[h];for(b=0;b<i;b++)0!==t[r+b]&&(a[y[t[r+b]]++]=b);if(0===e?(S=N=a,f=20):1===e?(S=Ji,N=Gi,f=257):(S=Hi,N=Ki,f=0),E=0,b=0,h=R,p=o,C=m,v=0,d=-1,T=1<<m,_=T-1,1===e&&T>852||2===e&&T>592)return 1;for(;;){L=h-v,a[b]+1<f?(A=0,P=a[b]):a[b]>=f?(A=N[a[b]-f],P=S[a[b]-f]):(A=96,P=0),u=1<<h-v,l=1<<C,R=l;do{l-=u,n[p+(E>>v)+l]=L<<24|A<<16|P}while(0!==l);for(u=1<<h-1;E&u;)u>>=1;if(0!==u?(E&=u-1,E+=u):E=0,b++,0==--I[h]){if(h===g)break;h=t[r+a[b]]}if(h>m&&(E&_)!==d){for(0===v&&(v=m),p+=R,C=h-v,O=1<<C;C+v<g&&(O-=I[C+v],!(O<=0));)C++,O<<=1;if(T+=1<<C,1===e&&T>852||2===e&&T>592)return 1;d=E&_,n[d]=m<<24|C<<16|p-o}}return 0!==E&&(n[p+E]=h-v<<24|64<<16),s.bits=m,0};const{Z_FINISH:Yi,Z_BLOCK:zi,Z_TREES:qi,Z_OK:Qi,Z_STREAM_END:Zi,Z_NEED_DICT:Xi,Z_STREAM_ERROR:$i,Z_DATA_ERROR:en,Z_MEM_ERROR:tn,Z_BUF_ERROR:rn,Z_DEFLATED:nn}=mr,on=16180,an=16190,sn=16191,cn=16192,un=16194,ln=16199,dn=16200,_n=16206,pn=16209,fn=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function hn(){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 bn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<on||t.mode>16211?1:0},Rn=e=>{if(bn(e))return $i;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=on,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,Qi},gn=e=>{if(bn(e))return $i;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Rn(e)},mn=(e,t)=>{let r;if(bn(e))return $i;const i=e.state;return t<0?(r=0,t=-t):(r=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?$i:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,gn(e))},Cn=(e,t)=>{if(!e)return $i;const r=new hn;e.state=r,r.strm=e,r.window=null,r.mode=on;const i=mn(e,t);return i!==Qi&&(e.state=null),i};let vn,On,Tn=!0;const En=e=>{if(Tn){vn=new Int32Array(512),On=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(Wi(1,e.lens,0,288,vn,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Wi(2,e.lens,0,32,On,0,e.work,{bits:5}),Tn=!1}e.lencode=vn,e.lenbits=9,e.distcode=On,e.distbits=5},Sn=(e,t,r,i)=>{let n;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)),i>=o.wsize?(o.window.set(t.subarray(r-o.wsize,r),0),o.wnext=0,o.whave=o.wsize):(n=o.wsize-o.wnext,n>i&&(n=i),o.window.set(t.subarray(r-i,r-i+n),o.wnext),(i-=n)?(o.window.set(t.subarray(r-i,r),0),o.wnext=i,o.whave=o.wsize):(o.wnext+=n,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=n))),0};var In={inflateReset:gn,inflateReset2:mn,inflateResetKeep:Rn,inflateInit:e=>Cn(e,15),inflateInit2:Cn,inflate:(e,t)=>{let r,i,n,o,a,s,c,u,l,d,_,p,f,h,b,R,g,m,C,v,O,T,E=0;const S=new Uint8Array(4);let I,y;const L=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(bn(e)||!e.output||!e.input&&0!==e.avail_in)return $i;r=e.state,r.mode===sn&&(r.mode=cn),a=e.next_out,n=e.output,c=e.avail_out,o=e.next_in,i=e.input,s=e.avail_in,u=r.hold,l=r.bits,d=s,_=c,T=Qi;e:for(;;)switch(r.mode){case on:if(0===r.wrap){r.mode=cn;break}for(;l<16;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}if(2&r.wrap&&35615===u){0===r.wbits&&(r.wbits=15),r.check=0,S[0]=255&u,S[1]=u>>>8&255,r.check=Rr(r.check,S,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=pn;break}if((15&u)!==nn){e.msg="unknown compression method",r.mode=pn;break}if(u>>>=4,l-=4,O=8+(15&u),0===r.wbits&&(r.wbits=O),O>15||O>r.wbits){e.msg="invalid window size",r.mode=pn;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=512&u?16189:sn,u=0,l=0;break;case 16181:for(;l<16;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}if(r.flags=u,(255&r.flags)!==nn){e.msg="unknown compression method",r.mode=pn;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=pn;break}r.head&&(r.head.text=u>>8&1),512&r.flags&&4&r.wrap&&(S[0]=255&u,S[1]=u>>>8&255,r.check=Rr(r.check,S,2,0)),u=0,l=0,r.mode=16182;case 16182:for(;l<32;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}r.head&&(r.head.time=u),512&r.flags&&4&r.wrap&&(S[0]=255&u,S[1]=u>>>8&255,S[2]=u>>>16&255,S[3]=u>>>24&255,r.check=Rr(r.check,S,4,0)),u=0,l=0,r.mode=16183;case 16183:for(;l<16;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&r.flags&&4&r.wrap&&(S[0]=255&u,S[1]=u>>>8&255,r.check=Rr(r.check,S,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+=i[o++]<<l,l+=8}r.length=u,r.head&&(r.head.extra_len=u),512&r.flags&&4&r.wrap&&(S[0]=255&u,S[1]=u>>>8&255,r.check=Rr(r.check,S,2,0)),u=0,l=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(p=r.length,p>s&&(p=s),p&&(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(o,o+p),O)),512&r.flags&&4&r.wrap&&(r.check=Rr(r.check,i,p,o)),s-=p,o+=p,r.length-=p),r.length))break e;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===s)break e;p=0;do{O=i[o+p++],r.head&&O&&r.length<65536&&(r.head.name+=String.fromCharCode(O))}while(O&&p<s);if(512&r.flags&&4&r.wrap&&(r.check=Rr(r.check,i,p,o)),s-=p,o+=p,O)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;p=0;do{O=i[o+p++],r.head&&O&&r.length<65536&&(r.head.comment+=String.fromCharCode(O))}while(O&&p<s);if(512&r.flags&&4&r.wrap&&(r.check=Rr(r.check,i,p,o)),s-=p,o+=p,O)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+=i[o++]<<l,l+=8}if(4&r.wrap&&u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=pn;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=sn;break;case 16189:for(;l<32;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}e.adler=r.check=fn(u),u=0,l=0,r.mode=an;case an: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,Xi;e.adler=r.check=1,r.mode=sn;case sn:if(t===zi||t===qi)break e;case cn:if(r.last){u>>>=7&l,l-=7&l,r.mode=_n;break}for(;l<3;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}switch(r.last=1&u,u>>>=1,l-=1,3&u){case 0:r.mode=16193;break;case 1:if(En(r),r.mode=ln,t===qi){u>>>=2,l-=2;break e}break;case 2:r.mode=16196;break;case 3:e.msg="invalid block type",r.mode=pn}u>>>=2,l-=2;break;case 16193:for(u>>>=7&l,l-=7&l;l<32;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=pn;break}if(r.length=65535&u,u=0,l=0,r.mode=un,t===qi)break e;case un:r.mode=16195;case 16195:if(p=r.length,p){if(p>s&&(p=s),p>c&&(p=c),0===p)break e;n.set(i.subarray(o,o+p),a),s-=p,o+=p,c-=p,a+=p,r.length-=p;break}r.mode=sn;break;case 16196:for(;l<14;){if(0===s)break e;s--,u+=i[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=pn;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;l<3;){if(0===s)break e;s--,u+=i[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,I={bits:r.lenbits},T=Wi(0,r.lens,0,19,r.lencode,0,r.work,I),r.lenbits=I.bits,T){e.msg="invalid code lengths set",r.mode=pn;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;E=r.lencode[u&(1<<r.lenbits)-1],b=E>>>24,R=E>>>16&255,g=65535&E,!(b<=l);){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}if(g<16)u>>>=b,l-=b,r.lens[r.have++]=g;else{if(16===g){for(y=b+2;l<y;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}if(u>>>=b,l-=b,0===r.have){e.msg="invalid bit length repeat",r.mode=pn;break}O=r.lens[r.have-1],p=3+(3&u),u>>>=2,l-=2}else if(17===g){for(y=b+3;l<y;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}u>>>=b,l-=b,O=0,p=3+(7&u),u>>>=3,l-=3}else{for(y=b+7;l<y;){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}u>>>=b,l-=b,O=0,p=11+(127&u),u>>>=7,l-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=pn;break}for(;p--;)r.lens[r.have++]=O}}if(r.mode===pn)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=pn;break}if(r.lenbits=9,I={bits:r.lenbits},T=Wi(1,r.lens,0,r.nlen,r.lencode,0,r.work,I),r.lenbits=I.bits,T){e.msg="invalid literal/lengths set",r.mode=pn;break}if(r.distbits=6,r.distcode=r.distdyn,I={bits:r.distbits},T=Wi(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,I),r.distbits=I.bits,T){e.msg="invalid distances set",r.mode=pn;break}if(r.mode=ln,t===qi)break e;case ln:r.mode=dn;case dn: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,Vi(e,_),a=e.next_out,n=e.output,c=e.avail_out,o=e.next_in,i=e.input,s=e.avail_in,u=r.hold,l=r.bits,r.mode===sn&&(r.back=-1);break}for(r.back=0;E=r.lencode[u&(1<<r.lenbits)-1],b=E>>>24,R=E>>>16&255,g=65535&E,!(b<=l);){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}if(R&&!(240&R)){for(m=b,C=R,v=g;E=r.lencode[v+((u&(1<<m+C)-1)>>m)],b=E>>>24,R=E>>>16&255,g=65535&E,!(m+b<=l);){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}u>>>=m,l-=m,r.back+=m}if(u>>>=b,l-=b,r.back+=b,r.length=g,0===R){r.mode=16205;break}if(32&R){r.back=-1,r.mode=sn;break}if(64&R){e.msg="invalid literal/length code",r.mode=pn;break}r.extra=15&R,r.mode=16201;case 16201:if(r.extra){for(y=r.extra;l<y;){if(0===s)break e;s--,u+=i[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(;E=r.distcode[u&(1<<r.distbits)-1],b=E>>>24,R=E>>>16&255,g=65535&E,!(b<=l);){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}if(!(240&R)){for(m=b,C=R,v=g;E=r.distcode[v+((u&(1<<m+C)-1)>>m)],b=E>>>24,R=E>>>16&255,g=65535&E,!(m+b<=l);){if(0===s)break e;s--,u+=i[o++]<<l,l+=8}u>>>=m,l-=m,r.back+=m}if(u>>>=b,l-=b,r.back+=b,64&R){e.msg="invalid distance code",r.mode=pn;break}r.offset=g,r.extra=15&R,r.mode=16203;case 16203:if(r.extra){for(y=r.extra;l<y;){if(0===s)break e;s--,u+=i[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=pn;break}r.mode=16204;case 16204:if(0===c)break e;if(p=_-c,r.offset>p){if(p=r.offset-p,p>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=pn;break}p>r.wnext?(p-=r.wnext,f=r.wsize-p):f=r.wnext-p,p>r.length&&(p=r.length),h=r.window}else h=n,f=a-r.offset,p=r.length;p>c&&(p=c),c-=p,r.length-=p;do{n[a++]=h[f++]}while(--p);0===r.length&&(r.mode=dn);break;case 16205:if(0===c)break e;n[a++]=r.length,c--,r.mode=dn;break;case _n:if(r.wrap){for(;l<32;){if(0===s)break e;s--,u|=i[o++]<<l,l+=8}if(_-=c,e.total_out+=_,r.total+=_,4&r.wrap&&_&&(e.adler=r.check=r.flags?Rr(r.check,n,_,a-_):hr(r.check,n,_,a-_)),_=c,4&r.wrap&&(r.flags?u:fn(u))!==r.check){e.msg="incorrect data check",r.mode=pn;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+=i[o++]<<l,l+=8}if(4&r.wrap&&u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=pn;break}u=0,l=0}r.mode=16208;case 16208:T=Zi;break e;case pn:T=en;break e;case 16210:return tn;default:return $i}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||_!==e.avail_out&&r.mode<pn&&(r.mode<_n||t!==Yi))&&Sn(e,e.output,e.next_out,_-e.avail_out),d-=e.avail_in,_-=e.avail_out,e.total_in+=d,e.total_out+=_,r.total+=_,4&r.wrap&&_&&(e.adler=r.check=r.flags?Rr(r.check,n,_,e.next_out-_):hr(r.check,n,_,e.next_out-_)),e.data_type=r.bits+(r.last?64:0)+(r.mode===sn?128:0)+(r.mode===ln||r.mode===un?256:0),(0===d&&0===_||t===Yi)&&T===Qi&&(T=rn),T},inflateEnd:e=>{if(bn(e))return $i;let t=e.state;return t.window&&(t.window=null),e.state=null,Qi},inflateGetHeader:(e,t)=>{if(bn(e))return $i;const r=e.state;return 2&r.wrap?(r.head=t,t.done=!1,Qi):$i},inflateSetDictionary:(e,t)=>{const r=t.length;let i,n,o;return bn(e)?$i:(i=e.state,0!==i.wrap&&i.mode!==an?$i:i.mode===an&&(n=1,n=hr(n,t,r,0),n!==i.check)?en:(o=Sn(e,t,r,r),o?(i.mode=16210,tn):(i.havedict=1,Qi)))},inflateInfo:"pako inflate (from Nodeca project)"};var yn=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 Ln=Object.prototype.toString,{Z_NO_FLUSH:An,Z_FINISH:Pn,Z_OK:Nn,Z_STREAM_END:wn,Z_NEED_DICT:Dn,Z_STREAM_ERROR:kn,Z_DATA_ERROR:Un,Z_MEM_ERROR:Mn}=mr;function xn(e){this.options=gi({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 Si,this.strm.avail_out=0;let r=In.inflateInit2(this.strm,t.windowBits);if(r!==Nn)throw new Error(gr[r]);if(this.header=new yn,In.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Oi(t.dictionary):"[object ArrayBuffer]"===Ln.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=In.inflateSetDictionary(this.strm,t.dictionary),r!==Nn)))throw new Error(gr[r])}xn.prototype.push=function(e,t){const r=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let o,a,s;if(this.ended)return!1;for(a=t===~~t?t:!0===t?Pn:An,"[object ArrayBuffer]"===Ln.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),o=In.inflate(r,a),o===Dn&&n&&(o=In.inflateSetDictionary(r,n),o===Nn?o=In.inflate(r,a):o===Un&&(o=Dn));r.avail_in>0&&o===wn&&r.state.wrap>0&&0!==e[r.next_in];)In.inflateReset(r),o=In.inflate(r,a);switch(o){case kn:case Un:case Dn:case Mn:return this.onEnd(o),this.ended=!0,!1}if(s=r.avail_out,r.next_out&&(0===r.avail_out||o===wn))if("string"===this.options.to){let e=Ei(r.output,r.next_out),t=r.next_out-e,n=Ti(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(o!==Nn||0!==s){if(o===wn)return o=In.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},xn.prototype.onData=function(e){this.chunks.push(e)},xn.prototype.onEnd=function(e){e===Nn&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=mi(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};const{Deflate:jn,deflate:Bn,deflateRaw:Vn,gzip:Fn}=ji;var Jn=Fn;var Gn,Hn=-1,Kn="RongCloudSEIAI",Wn=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)}))},Yn=function(t,r,i){return s(void 0,void 0,void 0,(function(){var n,o;return c(this,(function(a){return n=[],o=i.jwt||"",[2,new Promise((function(i,a){t.forEach((function(t){return s(void 0,void 0,void 0,(function(){var a,s,u;return c(this,(function(c){switch(c.label){case 0:return a=t.detectorAddr.replace(/^(https?:\/\/)?/,"https://"),s="".concat(a,"/rtc/detector/ping?t=").concat((d=9999,(l=1e3)+Math.floor(Math.random()*(d-l)))),u={jwt:o},[4,r.httpReq({url:s,body:JSON.stringify(u),timeout:5e3,method:e.HttpMethod.POST})];case 1:return 200===c.sent().status&&n.push(t.clusterId),i(n),[2]}var l,d}))}))}))}))]}))}))},zn=function(e,t){var r,i;if(!t)return"";try{i=JSON.parse(t.voipCallInfo||'{ "strategy": 0 }')}catch(r){return e.warn(n.L_MEDIA_SERVICE_PARSE_NAVI_CALLVOIP_INFO_O,"parse `voipCallInfo` of navi failed: ".concat(t.voipCallInfo)),""}if(0===i.strategy)return"";var o=null===(r=i.callEngine)||void 0===r?void 0:r.filter((function(e){return 4===e.engineType}));if(!o||0===o.length)return"";var a=o[0];return a.detectorManager?a.detectorManager:""},qn=function(t,r,i){return s(void 0,void 0,void 0,(function(){var n,o,a,s,u,l,d,_;return c(this,(function(c){switch(c.label){case 0:return n=zn(r,i),o=i.jwt||"",a=120,s=0,u=i.ipType||0,l={jwt:o,ipType:u},[4,t.httpReq({url:"".concat(n,"/rtc/detector/servers"),body:JSON.stringify(l),headers:{"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:"web|".concat(Ct.browser,"|").concat(Ct.version),ClientVersion:"5.34.0-alpha.1","Client-Session-Id":Wn(),"Request-Id":Date.now().toString()},method:e.HttpMethod.POST})];case 1:return d=c.sent(),_=d.data&&JSON.parse(d.data).detectorAddrs||[],a=d.data&&JSON.parse(d.data).clientDetectMinute,s=d.data&&JSON.parse(d.data).resultCode,[2,{detectoraddrs:_,clientDetectMinute:a,status:s}]}}))}))},Qn=function(){return{"Content-Type":"application/json;charset=UTF-8","Cache-Control":"no-cache",ClientType:"web|".concat(Ct.browser,"|").concat(Ct.version),ClientVersion:"5.34.0-alpha.1","Client-Session-Id":Wn(),"Request-Id":Date.now().toString()}},Zn=function(){function t(t,r,i,n){void 0===n&&(n=5e3),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_msUrl",{enumerable:!0,configurable:!0,writable:!0,value:i}),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,r.getConnectionStatus()===e.RCConnectionStatus.CONNECTED&&this.isNededDetector()&&this.detectorMediaSever()}return Object.defineProperty(t.prototype,"isNededDetector",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._context.getNaviInfo();if(!e)return!1;var r=zn(this._logger,e),i=e.jwt||"",n=Date.now(),o=!1;return 0===t.detectorTime?o=!1:t.detectValidMinute+t.detectorTime<n&&(o=!0),!(!r||!i||this._msUrl||o)}}),Object.defineProperty(t.prototype,"detectorMediaSever",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.clearMSList();var e=this._context.getNaviInfo();this._startDetector(e)}}),Object.defineProperty(t.prototype,"_startDetector",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var r,i,n,o;return c(this,(function(a){switch(a.label){case 0:return[4,qn(this._runtime,this._logger,e)];case 1:return r=a.sent(),i=r.detectoraddrs,n=r.clientDetectMinute,r.status!==exports.RCRTCCode.JWT_TIME_OUT?[3,3]:[4,this._context.getPluginContext().refetchNaviInfo()];case 2:return a.sent(),this.detectorMediaSever(),[2];case 3:return i.length?(o=t,[4,Yn(i,this._runtime,e)]):[3,5];case 4:o.msInDetector=a.sent(),a.label=5;case 5:return t.detectorTime=Date.now(),t.detectValidMinute=60*n*1e3,[2]}}))}))}}),Object.defineProperty(t.prototype,"clearMSList",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._msList.length=0}}),Object.defineProperty(t.prototype,"getMsList",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._msUrl?[this._msUrl]:(this._sortMediaServiceList(),d([],l(this._msList),!1))}}),Object.defineProperty(t.prototype,"_sortMediaServiceList",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=t.msInDetector[0],r=t.msInDetector.slice(1),i=function(e,t){var r,i;if(!e)return[];try{i=JSON.parse(e.voipCallInfo||'{ "strategy": 0 }')}catch(r){return t.warn(n.L_PARSE_VOIP_SERVER_CONF_E,e.voipCallInfo),[]}if(0===i.strategy)return[];var o=null===(r=i.callEngine)||void 0===r?void 0:r.filter((function(e){return 4===e.engineType}));if(!o||0===o.length)return[];var a=o[0],s=[];return a.mediaServer&&s.push(a.mediaServer.replace(/^(https?:\/\/)?/,"https://")),a.backupMediaServer&&a.backupMediaServer.forEach((function(e){s.push(e.replace(/^(https?:\/\/)?/,"https://"))})),s}(this._context.getNaviInfo(),this._logger),o=i[0],a=i.slice(1),s=d(d([this._clusterId,e,o],l(r),!1),l(a),!1).filter((function(e){return!!e})).map((function(e){return e.replace(/^(https?:\/\/)?/,"https://")}));this._msList=d([],l(new Set(s)),!1),this._logger.info(n.L_MEDIA_SERVICE_MSLIST_CHANGE_O,"MediaServiceList msList -> ".concat(JSON.stringify(this._msList)))}}),Object.defineProperty(t.prototype,"_openGzip",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){for(var r=JSON.stringify(t),i=r.length,n=new Uint8Array(i),o=0;o<i;o++)n[o]=r.charCodeAt(o);var s;return{headers:e=a(a({},e),{"Content-Encoding":"gzip","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}),body:t=Jn(n,s)}}}),Object.defineProperty(t.prototype,"_dealRequestSuccessResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var 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(n.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:o.SUCCESSED,url:t}),r),{code:exports.RCRTCCode.SUCCESS,data:i,qualityMsList:this._qualityMsList}}}),Object.defineProperty(t.prototype,"_request",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,u,l){return s(this,void 0,void 0,(function(){var s,d,_,p,f,h,b,R,g,m,C,v,O,T;return c(this,(function(c){switch(c.label){case 0:if(this._qualityMsList=[],d=(s={headers:r,body:i}).headers,_=s.body,0===(p=this.getMsList()).length)return this._logger.error(n.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"have no valid service address"}),u),[2,{code:exports.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER}];this._rtcFinger&&(_.rtcFinger=this._rtcFinger),f=0,c.label=1;case 1:return f<p.length?(h=Date.now(),b="".concat(p[f]).concat(t),R=Qn(),g=a(a({},R),d),m=/x-www-form-urlencoded/.test(g["Content-Type"])?_:JSON.stringify(_),C=R["Request-Id"],this._logger.info(n.L_MEDIA_SERVICE_REQUEST_T,JSON.stringify({url:b,"Request-Id":C}),u),[4,this._runtime.httpReq({url:b,body:m,headers:g,method:e.HttpMethod.POST,timeout:this._timeout})]):[3,4];case 2:if(v=c.sent(),O=v.status,T=v.data,l&&this._qualityMsList.push({rsdur:Date.now()-h,rsid:C,rscod:200===O?exports.RCRTCCode.SUCCESS:exports.RCRTCCode.REQUEST_FAILED,msa:b}),200===O)return[2,this._dealRequestSuccessResult(T,b,u)];this._logger.error(n.L_MEDIA_SERVICE_REQUEST_R,JSON.stringify({status:o.FAILED,msg:"request error -> Request-Id: ".concat(C,", status: ").concat(O,", url: ").concat(b),timeout:this._timeout}),u),c.label=3;case 3:return f+=1,[3,1];case 4:return[2,{code:exports.RCRTCCode.REQUEST_FAILED,qualityMsList:this._qualityMsList}]}}))}))}}),Object.defineProperty(t.prototype,"exchange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var n;return s(this,void 0,void 0,(function(){var o,a;return c(this,(function(s){switch(s.label){case 0:return[4,this._request("/exchange",e,t,r,i)];case 1:return(o=s.sent()).code===exports.RCRTCCode.SUCCESS&&(null===(n=o.data)||void 0===n?void 0:n.resultCode)===exports.RCRTCCode.SUCCESS&&(a=o.data.urls)&&(this._configUrl=a.configUrl),[2,o]}}))}))}}),Object.defineProperty(t.prototype,"exit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(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(t.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(t.prototype,"broadcastExit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(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(t.prototype,"setMcuConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return s(this,void 0,void 0,(function(){var i,s,u,l,d,_,p,f,h,b,R;return c(this,(function(c){switch(c.label){case 0:return i=this._logger.createTraceId(),this._logger.info(n.L_MEDIA_SERVICE_SET_MCU_CONFIG_T,JSON.stringify({body:r}),i),this._configUrl?(s="".concat(this._configUrl.replace(/^(https?:\/\/)?/,"https://"),"/server/mcu/config"),u=Qn(),l=a(a({},u),t),d=JSON.stringify(r),_=u["Request-Id"],[4,this._runtime.httpReq({url:s,headers:l,body:d,method:e.HttpMethod.POST})]):(this._logger.error(n.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.MCU_SERVER_NOT_FOUND,msg:"MCU server not found"}),i),[2,{code:exports.RCRTCCode.MCU_SERVER_NOT_FOUND}]);case 1:return p=c.sent(),f=p.status,h=p.data,200===f?(b=JSON.parse(h),(R=b.resultCode)===exports.RCRTCCode.SUCCESS?this._logger.info(n.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:o.SUCCESSED,"Request-Id":_}),i):this._logger.warn(n.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({code:R,"Request-Id":_}),i),[2,{code:R,res:b}]):(this._logger.error(n.L_MEDIA_SERVICE_SET_MCU_CONFIG_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REQUEST_FAILED,msg:"request error -> Request-Id: ".concat(_,", status: ").concat(f,", url: ").concat(s)}),i),[2,{code:exports.RCRTCCode.REQUEST_FAILED}])}}))}))}}),Object.defineProperty(t.prototype,"getCDNResourceInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var s,u,l,d,_,p,f;return c(this,(function(c){switch(c.label){case 0:return s=Qn(),u=a(a({},s),t),l=s["Request-Id"],this._logger.info(n.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_T,"Request-Id: ".concat(l,", url: ").concat(r),i),[4,this._runtime.httpReq({url:r,headers:u,method:e.HttpMethod.GET})];case 1:return d=c.sent(),_=d.status,p=d.data,200===_?(f=JSON.parse(p),this._logger.info(n.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:o.SUCCESSED,cdnPlayerUrl:null==f?void 0:f.data.pull_url}),i),[2,{code:f.resultCode,res:f}]):(this._logger.info(n.L_MEDIA_SERVICE_GET_CDN_RESOURCE_INFO_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REQUEST_FAILED}),i),[2,{code:exports.RCRTCCode.REQUEST_FAILED}])}}))}))}}),Object.defineProperty(t.prototype,"updateASRStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){return c(this,(function(i){switch(i.label){case 0:return[4,this._request("/rtc/media/v1/asr/update",e,t,r)];case 1:return[2,i.sent()]}}))}))}}),Object.defineProperty(t.prototype,"operateRealtimeTranslation",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){return c(this,(function(i){switch(i.label){case 0:return[4,this._request("/rtc/media/v1/asr/translation",e,t,r)];case 1:return[2,i.sent()]}}))}))}}),Object.defineProperty(t,"msInDetector",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(t,"detectorTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(t,"detectValidMinute",{enumerable:!0,configurable:!0,writable:!0,value:72e5}),t}();!function(e){e[e.NORMAL=1]="NORMAL",e[e.TINY=2]="TINY"}(Gn||(Gn={}));var Xn,$n=function(e,t){return Math.round(8*t/e)},eo=function(e,t){void 0===t&&(t=2);var r=Math.pow(10,t);return Math.round(e*r)/r},to=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,i){if(0===t)return 0;if(!r||!i)return eo(e/t,3);var n=t-i;if(0===n)return 0;var o=e-r;return o<0||n<0?0:eo(o/n,3)},io=function(e){var t=e.jitter,r=e.rtt,i=e.packetsLostRate;return!St(t)||!St(r)||0!==i};!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"}(Xn||(Xn={}));var no,oo=function(){function e(e,t,r,i,n,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:i}),Object.defineProperty(this,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:n}),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 i,n;if(this._latestBytesSent[e]&&t<this._latestBytesSent[e].bytesSent&&this.clearLatestpacketsSent([e]),this._latestBytesSent[e]){var o=this._latestBytesSent[e];i=t-o.bytesSent,n=r-o.timestamp,this._latestBytesSent[e]={bytesSent:t,timestamp:r}}else i=t,n=1e3,this._latestBytesSent[e]={bytesSent:t,timestamp:r};return $n(n,i)}}),Object.defineProperty(e.prototype,"updateBytesRecv",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i,n;if(this._latestBytesRecv[e]&&t<this._latestBytesRecv[e].bytesRecv&&this.clearLatestPacketsRecv([e]),this._latestBytesRecv[e]){var o=this._latestBytesRecv[e];i=t-o.bytesRecv,n=r-o.timestamp,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r}}else i=t,n=1e3,this._latestBytesRecv[e]={bytesRecv:t,timestamp:r};return $n(n,i)}}),Object.defineProperty(e.prototype,"updateSenderPacketsLost",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i;if(Object.prototype.hasOwnProperty.call(this._latestPacketsSent[e],"packetsSent")){var n=this._latestPacketsSent[e],o=n.packetsLost,a=n.packetsSent;i=ro(t,r,o,a),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=o===t?a:r}else i=ro(t,r),this._latestPacketsSent[e].packetsLost=t,this._latestPacketsSent[e].packetsSent=r;return i}}),Object.defineProperty(e.prototype,"updateReceiverPacketsLost",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i;if(this._latestPacketsRecv[e]){var n=this._latestPacketsRecv[e],o=n.packetsLost,a=n.packetsRecv;i=ro(t,r+t,o,a+o)}else i=ro(t,r);return this._latestPacketsRecv[e]={packetsLost:t,packetsRecv:r},i}}),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())===exports.RCMediaType.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,i={};try{for(var n=u(e.entries()),o=n.next();!o.done;o=n.next()){var a=l(o.value,2),s=a[0],c=a[1];/codec/gi.test(c)&&s.includes("RTCCodec_")||(i[s]=c)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return i}}),Object.defineProperty(e.prototype,"formatRCRTCStateReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={senders:[],receivers:[]};return this._logger.info(n.L_ABSTRACT_STAT_PARSER_FORMAT_RTC_STATE_REPORT_O,JSON.stringify({status:o.SUCCESSED,stats:e,reports:t})),t}}),Object.defineProperty(e.prototype,"isValidTranceiver",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i,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,o=e.ssrc;return!(null==n?void 0:n.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===Xn.REMOTEINBOUNDRTP?(e.remoteInbound.push(t),e):t.type===Xn.INBOUNDRTP?(e.inbound.push(t),e):t.type===Xn.OUTBOUNDRTP?(e.outbound.push(t),e):t.type===Xn.TRANSPORT?(e.transport.push(t),e):t.type===Xn.PEERCONNECTION?(e.connection.push(t),e):e}),{outbound:[],remoteInbound:[],inbound:[],transport:[],connection:[]})}}),e}(),ao=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,i=this.formatStateData(e),n=i.outbound,o=i.remoteInbound,a=i.inbound,s=i.transport,c=i.connection,u={senders:[],receivers:[]},l=Math.floor(c[0].timestamp);u.timestamp=l;var d=0,_=0;d=(t=this.pickOutbound(n,e,d,l,_)).totalPacketsLost,_=t.bitrateSend,u.senders=t.senders,o.length>0&&u.senders.length>0&&this.pickRemoteInbound(o,u.senders,e);var p=0;if(d=(r=this.pickInbound(a,e,d,l,p)).totalPacketsLost,p=r.bitrateRecv,u.receivers=r.receivers,s.length>0){var f=s[0];this.pickRtcTransport(f,e,u,p,_,d)}return u}}),Object.defineProperty(t.prototype,"pickRtcTransport",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n,o){var a=e.selectedCandidatePairId;if(a){var s=t[a],c=s.availableOutgoingBitrate,u=s.availableIncomingBitrate,l=s.currentRoundTripTime,d=s.localCandidateId,_=s.remoteCandidateId,p=t[d],f=p.ip,h=p.port,b=p.networkType,R=t[_],g=R.ip,m=R.port,C=R.protocol;r.iceCandidatePair={IP:f,port:h,networkType:b,remoteIP:g,remotePort:m,protocol:C,bitrateRecv:i,bitrateSend:n,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 i=this;e.forEach((function(e){var n,o=e.localId,a=e.jitter,s=e.roundTripTime,c=e.packetsLost,u=t.filter((function(e){return e.id===o}))[0];if(u&&!io(u)){var l=null===(n=i._store)||void 0===n?void 0:n.getTrackIdBySSRC(r[u.id].ssrc);u.jitter=Math.round(1e3*a),u.rtt=s;var d=i._latestPacketsSent[l].crtPacketsSent;u.packetsLostRate=i.updateSenderPacketsLost(l,c,d)}}))}}),Object.defineProperty(t.prototype,"_getOutboundVideoAttrs",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n){var o,a,s,c=e.framesPerSecond,u=e.frameWidth,l=e.frameHeight;return"video"!==r||u||l||c||(u=(null===(o=t[i])||void 0===o?void 0:o.frameWidth)||t[n].width,l=(null===(a=t[i])||void 0===a?void 0:a.frameHeight)||t[n].height,c=(null===(s=t[n])||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,i,n){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,d=e.remoteId,_=e.packetsSent,p=e.bytesSent,f=e.encoderImplementation,h=e.pliCount,b=e.nackCount,R=e.mid,g=e.trackId;if(void 0!==R&&(g=o.getTrackIdByMid(R)),g){var m=o._getOutboundVideoAttrs(e,t,u,g,l),C=m.frameRate,v=m.frameWidth,O=m.frameHeight,T=t[d],E=null,S=null,I=0;T&&(E=T.jitter,S=T.roundTripTime,I=T.packetsLost),r+=I;var y=null===(s=o._store)||void 0===s?void 0:s.getTrackIdBySSRC(e.ssrc);if(y){var L=l?t[l].audioLevel:t[g].audioLevel,A=0;!o._latestPacketsSent[y]&&(o._latestPacketsSent[y]={}),T?A=o.updateSenderPacketsLost(y,I,_):o._latestPacketsSent[y].crtPacketsSent=_;var P=o.updateBytesSent(y,p,i);P<0&&(P=0),n+=P,a.push({id:c,trackId:y,kind:u,packetsLostRate:A,remoteResource:!1,audioLevel:L||0===L?to(L):null,frameWidth:v,frameHeight:O,frameRate:C,bitrate:P,jitter:E?Math.round(1e3*E):E,rtt:S?Math.round(1e3*S):S,encoderImplementation:f,pliCount:h,nackCount:b,googFirsSent:Hn,samplingRate:Hn,googRenderDelayMs:Hn,trackState:Hn})}}}})),{totalPacketsLost:r,bitrateSend:n,senders:a}}}),Object.defineProperty(t.prototype,"_getInboundMediaAttrs",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n){var o,a,s,c=e.frameWidth,u=e.frameHeight,l=e.audioLevel;return"video"===n?c||u||(c=(null===(o=t[r])||void 0===o?void 0:o.frameWidth)||t[i].width,u=(null===(a=t[r])||void 0===a?void 0:a.frameHeight)||t[i].height):l||(l=(null===(s=t[r])||void 0===s?void 0:s.audioLevel)||t[i].audioLevel),{frameWidth:c,frameHeight:u,audioLevel:l}}}),Object.defineProperty(t.prototype,"pickInbound",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n){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,d=e.bytesReceived,_=e.framesPerSecond,p=e.kind,f=e.codecImplementationName,h=e.nackCount,b=e.pliCount,R=e.mid,g=e.id,m=e.trackId;if(void 0!==R&&(m=o.getTrackIdByMid(R)),m){var C=o._getInboundMediaAttrs(e,t,m,g,p),v=C.frameWidth,O=C.frameHeight,T=C.audioLevel;r+=c;var E=null===(s=o._store)||void 0===s?void 0:s.getTrackIdBySSRC(e.ssrc),S=o.updateReceiverPacketsLost(E,c,u),I=o.updateBytesRecv(E,d,i);I<0&&(I=0),n+=I,a.push({trackId:E,kind:p,packetsLostRate:S,remoteResource:!0,audioLevel:T||0===T?to(T):null,frameWidth:v,frameHeight:O,frameRate:_,bitrate:I,jitter:l?Math.round(1e3*l):0,codecImplementationName:f,nackCount:h,pliCount:b,rtt:null,samplingRate:Hn,googFirsReceived:Hn,googRenderDelayMs:Hn,trackState:Hn})}}})),{totalPacketsLost:r,bitrateRecv:n,receivers:a}}}),t}(oo),so=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 i;if("unified-plan"!==this._sdpSemantics||this.isValidTranceiver(e,r)){var n=e.kind,o=e.bytesSent,a=e.packetsSent,s=e.bitrateMean,c=e.framerateMean,u=e.nackCount,l=e.pliCount,d=e.remoteId,_=d?t[d]:{jitter:null,roundTripTime:null,packetsLost:0},p=_.jitter,f=_.roundTripTime,h=_.packetsLost,b=null===(i=this._store)||void 0===i?void 0:i.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=h;var R=0;!this._latestPacketsSent[b]&&(this._latestPacketsSent[b]={}),d?R=this.updateSenderPacketsLost(b,h,a):this._latestPacketsSent[b].crtPacketsSent=a;var g=0;"video"===n?s&&(g=Math.floor(s/1e3)):g=this.updateBytesSent(b,o,this._reportsData.timestamp),g<0&&(g=0),this._bitrateSend+=g,this._reportsData.senders.push({trackId:b,kind:n,packetsLostRate:R,remoteResource:!1,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(c),bitrate:g,jitter:p?Math.round(1e3*p):null,rtt:f,encoderImplementation:null,pliCount:l,nackCount:u,googFirsSent:Hn,samplingRate:Hn,googRenderDelayMs:Hn,trackState:Hn})}}}),Object.defineProperty(t.prototype,"_addSenderData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i=t.localId,n=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e[i].ssrc),o=this._reportsData.senders.filter((function(e){return e.trackId===n}))[0];o&&io(o)&&(o.jitter=Math.round(1e3*t.jitter),o.rtt=t.rtt,o.packetsLostRate=this.updateSenderPacketsLost(n,t.packetsLost,this._latestPacketsSent[n].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 i=e.packetsLost,n=e.bytesReceived,o=e.packetsReceived,a=e.jitter,s=e.framerateMean,c=e.kind,u=e.bitrateMean,l=e.nackCount,d=e.pliCount,_=null===(r=this._store)||void 0===r?void 0:r.getTrackIdBySSRC(e.ssrc);this._totalPacketsLost+=i;var p=this.updateReceiverPacketsLost(_,i,o),f=0;"video"===c?u&&(f=Math.floor(u/1e3)):f=this.updateBytesRecv(_,n,this._reportsData.timestamp),f<0&&(f=0),this._bitrateRecv+=f,this._reportsData.receivers.push({trackId:_,kind:c,packetsLostRate:p,remoteResource:!0,audioLevel:null,frameWidth:null,frameHeight:null,frameRate:Math.floor(s),bitrate:f,jitter:a?Math.round(1e3*a):null,codecImplementationName:null,nackCount:l,pliCount:d,rtt:null,samplingRate:Hn,googFirsReceived:Hn,googRenderDelayMs:Hn,trackState:Hn})}}}),Object.defineProperty(t.prototype,"_pickIceCandidatePair",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e[t.localCandidateId],i=r.address,n=r.port,o=e[t.remoteCandidateId],a=o.address,s=o.port,c=o.protocol;this._reportsData.iceCandidatePair={IP:i,port:n,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 i=e[r],n=i.type;"outbound-rtp"===n&&this._pickSenderData(i,e,n),"remote-inbound-rtp"===n&&this._addSenderData(e,i),"inbound-rtp"===n&&this._pickReceiverData(i,n),"candidate-pair"===n&&"succeeded"===i.state&&this._pickIceCandidatePair(e,i)}return this._reportsData}}),t}(oo),co=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 i=e.packetsLost,n=e.packetsReceived,o=e.jitter,a=e.bytesReceived,s=e.kind,c=e.nackCount,u=e.pliCount,l=e.audioLevel,d=e.frameHeight,_=e.frameWidth,p=null===(t=r._store)||void 0===t?void 0:t.getTrackIdBySSRC(e.ssrc);if(p){r._totalPacketsLost+=i;var f=r.updateReceiverPacketsLost(p,i,n),h=r.updateBytesRecv(p,a,r._reportsData.timestamp);h<0&&(h=0),r._bitrateRecv+=h,r._reportsData.receivers.push({trackId:p,kind:s,packetsLostRate:f,remoteResource:!0,audioLevel:l||0===l?to(l):null,frameWidth:_,frameHeight:d,frameRate:null,bitrate:h,jitter:o?Math.round(1e3*o):o,codecImplementationName:null,nackCount:c,pliCount:u,rtt:null,samplingRate:Hn,googFirsReceived:Hn,googRenderDelayMs:Hn,trackState:Hn})}}}))}}),Object.defineProperty(t.prototype,"_pickSenderData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;e.forEach((function(e){var i;if("unified-plan"!==r._sdpSemantics||r.isValidTranceiver(e,"outbound-rtp")){var n=null===(i=r._store)||void 0===i?void 0:i.getTrackIdBySSRC(e.ssrc),o=e.kind,a=e.bytesSent,s=e.pliCount,c=e.nackCount,u=e.audioLevel,l=e.frameHeight,d=e.frameWidth,_=e.codecId,p=e.remoteId,f=e.packetsSent;if(n){var h=t[p],b=null,R=null,g=0;h&&(b=h.jitter,R=h.roundTripTime,g=h.packetsLost),r._totalPacketsLost+=g;var m=0;!r._latestPacketsSent[n]&&(r._latestPacketsSent[n]={}),h?m=r.updateSenderPacketsLost(n,g,f):r._latestPacketsSent[n].crtPacketsSent=f;var C=r.updateBytesSent(n,a,r._reportsData.timestamp);C<0&&(C=0),r._bitrateSend+=C,r._reportsData.senders.push({trackId:n,kind:o,packetsLostRate:m,remoteResource:!1,audioLevel:u||0===u?to(u):null,frameWidth:d,frameHeight:l,frameRate:null,bitrate:C,jitter:b?Math.round(1e3*b):b,rtt:R?Math.round(1e3*R):R,encoderImplementation:t[_].mimeType,pliCount:s,nackCount:c,googFirsSent:Hn,samplingRate:Hn,googRenderDelayMs:Hn,trackState:Hn})}}}))}}),Object.defineProperty(t.prototype,"_pickIceCandidatePair",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.selectedCandidatePairId;if(r){var i=t[r],n=i.availableOutgoingBitrate,o=i.availableIncomingBitrate,a=i.currentRoundTripTime,s=i.localCandidateId,c=i.remoteCandidateId,u=t[s],l=u.address,d=u.port,_=t[c],p=_.address,f=_.port,h=_.protocol;this._reportsData.iceCandidatePair={IP:l||null,port:d,networkType:null,remoteIP:p,remotePort:f,protocol:h,bitrateRecv:this._bitrateRecv,bitrateSend:this._bitrateSend,rtt:1e3*a,availableOutgoingBitrate:n,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,i=t.inbound,n=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(i,e),n.length>0){var s=n[0];this._pickIceCandidatePair(s,e)}return this._reportsData}}),t}(oo),uo=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 i=this.getStreamIndex();this.spliteStreams(i)}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),d([],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(i){return new RegExp("\\bmsid:".concat(t,"\\b"),"ig").test(i)?r.setAudioItemBitrate(i,e):i})),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(i){return new RegExp("\\bmid:".concat(t,"\\b"),"ig").test(i)?r.setAudioItemBitrate(i,e):i})),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 i=["$1","maxaveragebitrate=".concat(r.max*e.KBitrate*1e3)];t=t.replace(/(\buseinbandfec=[^\r\n]+)/gi,i.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(i){return new RegExp("\\bmsid:".concat(t,"\\b"),"ig").test(i)?r.setVideoItemBitrate(i,e):i})),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(i){return new RegExp("\\bmid:".concat(t,"\\b"),"ig").test(i)?r.setVideoItemBitrate(i,e):i})),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 i=["$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,i.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(i){return new RegExp("\\bmid:".concat(e,"\\b"),"ig").test(i)?r.clearSSRC(i,t):i})),this.videoStreams=this.videoStreams.map((function(i){return new RegExp("\\bmid:".concat(e,"\\b"),"ig").test(i)?r.clearSSRC(i,t):i})),this}}),Object.defineProperty(e.prototype,"clearSSRC",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(t===po.SENDONLY&&/\ba=sendonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"");if(t===po.RECVONLY&&/\ba=recvonly\b/.test(e))return e.replace(/\r\na=(ssrc|msid)[^\r\n]+/gi,"");if(t===po.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(n.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(n.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(n.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(n.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"}(no||(no={})),no.NB,no.NB,no.NB,no.NB,no.MB,no.MB,no.MB,no.MB,no.WB,no.WB,no.WB,no.WB,no.SWB,no.SWB,no.FB,no.FB,no.NB,no.NB,no.NB,no.NB,no.WB,no.WB,no.WB,no.WB,no.SWB,no.SWB,no.SWB,no.SWB,no.FB,no.FB,no.FB,no.FB;var _o,po,fo=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,i=e.matchPrefix(t,"a=msid:");if(1===i.length)return{stream:(r=i[0].substr(7).split(" "))[0],track:r[1]};var n=e.matchPrefix(t,"a=ssrc:").map((function(t){return e.parseSsrcMedia(t)})).filter((function(e){return"msid"===e.attribute}));return n.length>0&&n[0].value?{stream:(r=n[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)},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}}),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 i=t.join(","),n=i.indexOf("0,0,0,1,101");-1===n&&(n=i.indexOf("0,0,0,1,37")),r=i.substring(0,n).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 i=r.match(/a=rtpmap:(\d+)\s+(\S+)/g);i&&(e.payloadTypeCodecMap=i.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"}(_o||(_o={})),function(e){e.SENDONLY="sendonly",e.RECVONLY="recvonly",e.INACTIVE="inactive"}(po||(po={}));var ho=function(){function e(e,t,r,i){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_peer",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_useEncrypt",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_onReceiveSeiListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),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=Ct.browser,i=Ct.version,o=Ct.supportsUnifiedPlan;if(t.info(n.L_A_SDP_STRATEGY_SET_SDP_SEMANTICS_O,JSON.stringify({sdpSemantics:e,supportsUnifiedPlan:o,browser:r,version:i})),o)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"}}),Object.defineProperty(e,"getSdpSemantics",{enumerable:!1,configurable:!0,writable:!0,value:function(){return e._sdpSemantics}}),Object.defineProperty(e.prototype,"setReceiveSeiListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._onReceiveSeiListener=e}}),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 i=/_tiny$/.test(t),n=ct(r),o=n.width,a=n.height;e.push({trackId:r.id,simulcast:i?Gn.TINY:Gn.NORMAL,resolution:"".concat(o,"x").concat(a)})}}return e}}),Object.defineProperty(e.prototype,"setRemoteAnswer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:e=uo.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(n.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:o.FAILED,msg:t})),[2,exports.RCRTCCode.SET_REMOTE_DESCRIPTION_FAILED];case 4:return this._logger.info(n.L_A_SDP_STRATEGY_SET_REMOTE_ANSWER_O,JSON.stringify({status:o.SUCCESSED,sdp:e})),[2,exports.RCRTCCode.SUCCESS]}}))}))}}),Object.defineProperty(e.prototype,"getStatParsr",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){return/chrome/i.test(Ct.browser)?new ao(this,e,this._logger,t,r,i):/Firefox/i.test(Ct.browser)?new so(this,e,this._logger,t,r,i):/Safari/i.test(Ct.browser)?new co(this,e,this._logger,t,r,i):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 uo.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,i=t.writable,n=new TransformStream({transform:this._encodeRtpChunk.bind(this,e)});r.pipeThrough(n).pipeTo(i)}}}),Object.defineProperty(e.prototype,"_setupReceiverTransform",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.createEncodedStreams(),r=t.readable,i=t.writable,n=new TransformStream({transform:this._decodeRtpChunk.bind(this,e)});r.pipeThrough(n).pipeTo(i)}}),Object.defineProperty(e.prototype,"_encodeVideoFrame",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=fo.splitNaluData(e),r=t.header,i=t.payloadData,n=lo.encodeVideo(i),o=fo.deal0x03(n,"encode");return new Uint8Array(d(d([],l(r),!1),l(o),!1)).buffer}}),Object.defineProperty(e.prototype,"_decodeVideoFrame",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=new Uint8Array(e),i=r.join(",").indexOf("0,0,0,1,6,5"),n=-1!==i?r.join(",").slice(i):null;if(n)return null===(t=this._onReceiveSeiListener)||void 0===t||t.call(this,n),e;if(!this._useEncrypt)return e;var o=fo.splitNaluData(e),a=o.header,s=o.payloadData,c=fo.deal0x03(s,"decode"),u=lo.decodeVideo(c);return new Uint8Array(d(d([],l(a),!1),l(u),!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 i,n=!(e[r]>>7),o=127&e[r],a=void 0,s=void 0,c=void 0;if(n?(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),i=new Uint8Array(s),t.push({timestampOffset:a,header:c,block:i,isPrimary:n,blockPType:o}),n)break}return t.forEach((function(t){var i=t.block.byteLength,n=e.slice(r,r+i);t.block.set(n),r+=i})),t}(new Uint8Array(e)),i=[],n=[],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,i.push(e.header),n.push(e.block)}));var a=new Uint8Array(o),s=0;return d(d([],l(i),!1),l(n),!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 i=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._encodeVideoFrame(i);else{var n=t.getMetadata().payloadType,o=fo.payloadTypeCodecMap.filter((function(e){return e.payloadType===n}))[0].codec;"red"===o?t.data=this._handleAudioREDFrame(i,"encode"):"opus"===o?t.data=this._handleOpusFrame(i,"encode"):console.error("Unsupport audio payloadType: ".concat(n,", codec: ").concat(o))}r.enqueue(t)}}),Object.defineProperty(e.prototype,"_decodeRtpChunk",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=t.data;if(t instanceof RTCEncodedVideoFrame)t.data=this._decodeVideoFrame(i);else if(this._useEncrypt){var n=t.getMetadata().payloadType,o=fo.payloadTypeCodecMap.filter((function(e){return e.payloadType===n}))[0].codec;"red"===o?t.data=this._handleAudioREDFrame(i,"decode"):"opus"===o?t.data=this._handleOpusFrame(i,"decode"):console.error("Unsupport audio payloadType: ".concat(n,", codec: ").concat(o))}r.enqueue(t)}}),e}(),bo=function(e){function t(t,r){var i=e.call(this,r,_o.PLANB,t)||this;return Object.defineProperty(i,"SDP",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return r(t,e),Object.defineProperty(t.prototype,"stringify",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[this.SDPHeader];d(d([],l(this.audioStreams),!1),l(this.videoStreams),!1).forEach((function(t){var r=t.match(/\ba=mid:(video|audio)\b/),i=uo.clearInactiveOrRecvonly(t);r&&r[1]===Pe.AUDIO&&(e[1]=i),r&&r[1]===Pe.VIDEO&&(e[2]=i)}));var t=e.join("");return uo.trimBlankLine(t)}}),Object.defineProperty(t.prototype,"setAudioBitrateWithStreamId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._logger.warn(n.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(n.L_FUNCTION_IS_UNAVAILABLE,"plan-b not support set Video Bitrate With Stream Id"),this}}),t}(uo),Ro=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(),i=this._outboundStreams[t]||(this._outboundStreams[t]=new MediaStream);i.getTracks().forEach((function(e){e.kind===r.kind&&i.removeTrack(e)})),i.addTrack(r);var n=e.getTrackId(),o=this.senders[n];o?o.replaceTrack(r):(this.senders[n]=this._peer.addTrack(r,i),Object.defineProperty(r,"trackId",{value:n,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(),i=this.senders[r];i&&(i.replaceTrack(null),this._peer.removeTrack(i),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 s(this,void 0,void 0,(function(){var t,r,i;return c(this,(function(n){switch(n.label){case 0:return[4,this._peer.createOffer({iceRestart:e,offerToReceiveAudio:!0,offerToReceiveVideo:!0})];case 1:for(r in t=n.sent(),this._outboundStreams)i=this._outboundStreams[r].id,t.sdp=t.sdp.replace(new RegExp(i,"g"),r);return t.sdp&&(t.sdp=this.resetSdp(t.sdp)),[4,this._peer.setLocalDescription(t)];case 2:return n.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===exports.RCMediaType.AUDIO_ONLY?t.isAudioTrack():t.isVideoTrack()})),r={max:0,min:0};return t.forEach((function(e){var t=e.getBitrate(),i=t.min,n=t.max,o=t.start;r.max=r.max<n?n:r.max,r.min=r.min>i?i:r.min,r.max===n?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 bo(this._logger,e),r=this._getMaxRangeBitrate(exports.RCMediaType.VIDEO_ONLY),i=this._getMaxRangeBitrate(exports.RCMediaType.AUDIO_ONLY);return t.setAudiosBitrate(i),t.setVideosBitrate(r),t.stringify()}}),t}(ho),go=function(e){function t(t,r){return e.call(this,r,_o.UNIFIEDPLAN,t)||this}return r(t,e),Object.defineProperty(t.prototype,"stringify",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[this.SDPHeader];d(d([],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 uo.trimBlankLine(t)}}),t}(uo),mo=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 i=u(this.__streams.keys()),n=i.next();!n.done;n=i.next()){var o=n.value;r.set(o,this.pickup(o))}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return r},enumerable:!1,configurable:!0}),e}(),Co=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(n.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(),i=e.getStreamId(),n=e.__innerGetMediaStreamTrack();this._localTracks[r]=e;var o=this._outboundStreams[i]||(this._outboundStreams[i]=new MediaStream);o.getTracks().forEach((function(e){e.kind===n.kind&&o.removeTrack(e)})),o.addTrack(n);var a=this._sendTransceiver[r];if(a)a.sender.replaceTrack(n),a.direction="sendonly";else{var s=this._sendTransceiver[r]=this._peer.addTransceiver(n,{direction:"sendonly",streams:[o]});this._setupSenderTransform(s.sender)}mo.getInstance().push(r,{msid:i,id:this._outboundStreams[i].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,t){void 0===t&&(t=!0);var r=e.getTrackId(),i=e.getStreamId();delete this._localTracks[r];var n=this._sendTransceiver[r];if(n){"closed"!==this._peer.connectionState&&(n.direction="inactive",this._peer.removeTrack(n.sender),n.sender.replaceTrack(null));var o=this._outboundStreams[i];(e.isAudioTrack()?o.getAudioTracks():o.getVideoTracks()).forEach((function(e){return o.removeTrack(e)}));var a=this._sendTransceiver["".concat(r,"_tiny")];if(a&&"inactive"!==a.direction&&t&&"closed"!==this._peer.connectionState){a.direction="inactive";var s=a.sender,c=s.track;this._peer.removeTrack(s),s.replaceTrack(null),this._outboundStreams["".concat(i,"_tiny")].removeTrack(c),c.stop()}}}}),Object.defineProperty(t.prototype,"updateRecvTransceiverMap",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=dt(e).mediaType;this._recvTransceiver[e]=t;var i=r===exports.RCMediaType.AUDIO_ONLY?this._recvAudio:this._recvVideo,n=i.findIndex((function(e){return e===t}));n>=0&&i.splice(n,1)}}),Object.defineProperty(t.prototype,"updateSubRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=e.slice(),i=this._subedTracks.slice();this._subedTracks=e.slice();for(var n=function(e){var t=r[e],n=i.findIndex((function(e){return e===t}));n>=0&&(r.splice(e,1),i.splice(n,1))},o=r.length-1;o>=0;o-=1)n(o);i.length&&i.forEach((function(e){var r=e.getTrackId();e.__innerSetMediaStreamTrack(void 0);var i=t._recvTransceiver[r];i&&(i.direction="inactive")}));var a={audio:0,video:0};r.length&&r.forEach((function(e){var r=e.isAudioTrack()?"audio":"video",i=t._recvTransceiver[e.getTrackId()];i?i.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 s(this,void 0,void 0,(function(){var t,r,i,n;return c(this,(function(o){switch(o.label){case 0:return[4,this._peer.createOffer({iceRestart:e})];case 1:for(i in t=o.sent(),r=t.sdp,this._outboundStreams)n=this._outboundStreams[i].id,r=r.replace(new RegExp(n,"g"),i);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 i=null;return fo.getMediaSections(e).forEach((function(e){fo.parseExtmap(e);var n=fo.parseMLine(e).kind,o=fo.parseMsid(e).stream,a=fo.getMid(e);"video"===r?/tiny$/.test(o)?o=o.replace(/tiny$/gi,"1_tiny"):o+="_1":o+="_0",o===t&&r===n&&a&&(i=a)})),i}}),Object.defineProperty(t.prototype,"_setSenderTransceiverBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var n=this._localTracks[t],o=null==n?void 0:n.getBitrate();i===Pe.AUDIO&&o&&e.setAudioBitrateWithMid(o,r),i===Pe.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 i in this._sendTransceiver){var n=this._sendTransceiver[i],o=null===(r=n.sender.track)||void 0===r?void 0:r.kind,a=n.direction,s=n.mid;s||(s=this._genarateMid(e,i,o)),s&&(a===po.SENDONLY&&this._setSenderTransceiverBitrate(t,i,s,o),a===po.INACTIVE&&t.clearnSsrcWithMid(s,po.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],i=r.direction,n=r.mid;n&&i===po.INACTIVE&&e.clearnSsrcWithMid(n,po.RECVONLY)}}}),Object.defineProperty(t.prototype,"resetOfferSdp",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=new go(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 go(this._logger,e);for(var i in this._sendTransceiver){var n=this._sendTransceiver[i],o=n.mid;if(o){var a=this._localTracks[i],s=null==a?void 0:a.getBitrate(),c=null===(t=n.sender.track)||void 0===t?void 0:t.kind;c===Pe.AUDIO&&s&&r.setAudioBitrateWithMid(s,o),c===Pe.VIDEO&&s&&r.setVideoBitrateWithMid(s,o)}}return r.stringify()}}),t}(ho);function vo(e,t){for(var r=0,i=t;i<e.length;){var n=e[i];if(r+=n,i++,255!==n)break}return{value:r,nextOffset:i}}function Oo(e,t){if(t>=e.length)return null;var r=vo(e,t),i=r.value,n=r.nextOffset,o=vo(e,n),a=o.value;if(n=o.nextOffset,a<16)return null;if(n+a>e.length)return null;var s=e.slice(n,n+16),c=n+16,u=a-16,l=e.slice(c,c+u);return l.length>=2&&0===l[l.length-2]&&128===l[l.length-1]?l=l.slice(0,l.length-2):l.length>=1&&128===l[l.length-1]&&(l=l.slice(0,l.length-1)),5===i?{payloadSize:a,uuid:s,content:l}:null}var To,Eo,So,Io,yo=function(e){function t(t,r,i,n,o,a,s,c){void 0===s&&(s=!1),void 0===c&&(c=!1);var u=e.call(this)||this;Object.defineProperty(u,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(u,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(u,"_reTryExchange",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(u,"_currentUserId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(u,"_store",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(u,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(u,"_isRoomAudience",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(u,"_rtcPeerConn",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_sdpStrategy",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"reportParser",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"pubLocalTracks",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(u,"_reTryExchangeTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(u,"_reportStatsTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(u,"_reportR3R4ToPolarisTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(u,"_isDestroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_formatStatsData",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(u,"_inRetry",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_firstConnectFromPub",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_reportListener",{enumerable:!0,configurable:!0,writable:!0,value:null});var l=ho.getSdpSemantics(),d="unified-plan"===l&&c&&"function"==typeof RTCRtpSender.prototype.createEncodedStreams&&"function"==typeof RTCRtpReceiver.prototype.createEncodedStreams&&lo.isInit(),_=u._rtcPeerConn=new RTCPeerConnection({sdpSemantics:l,encodedInsertableStreams:d});return u._sdpStrategy="plan-b"===l?new Ro(t,u._logger,_,!1):new Co(t,u._logger,_,d),u._sdpStrategy.setReceiveSeiListener(u._decodeSeiData.bind(u)),u._rtcPeerConn.oniceconnectionstatechange=u._onICEConnectionStateChange.bind(u),u._rtcPeerConn.onconnectionstatechange=u._onConnectionStateChange.bind(u),u._rtcPeerConn.ontrack=u._onTrackReady.bind(u),u.reportParser=u._sdpStrategy.getStatParsr(u._rtcPeerConn,l,u._currentUserId,u._store),u}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,"_decodeSeiData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=e.split(",").map((function(e){return Number(e)})),i=function(e){if(e.length>=4&&0===e[0]&&0===e[1]&&(1===e[2]||0===e[2]&&1===e[3]))for(var t=0;t+4<e.length;)if(0===e[t]&&0===e[t+1]&&(1===e[t+2]||0===e[t+2]&&1===e[t+3])){if((i=t+(1===e[t+2]?3:4))>=e.length)break;if(6==(31&e[i])&&(o=Oo(e,a=i+1)))return{payloadSize:o.payloadSize,content:o.content};t=i+1}else t++;else for(var r=0;r+4<=e.length;){var i,n=e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3];if(n<=0||r+4+n>e.length)break;if(6==(31&e[i=r+4])){var o,a=i+1;if(o=Oo(e.subarray(a,r+4+n),0))return{payloadSize:o.payloadSize,content:o.content}}r+=4+n}return null}(new Uint8Array(r));if(i){var n=this._context.decodeAsrText(i.content);this.emit(t.__INNER_SEI_CONTENT__,n)}}}),Object.defineProperty(t.prototype,"_onConnectionStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._logger.info(n.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 s(this,void 0,void 0,(function(){var i,a,s;return c(this,(function(c){switch(c.label){case 0:return i=this._rtcPeerConn.iceConnectionState,this._logger.info(n.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_S,JSON.stringify({iceConnectionState:i})),[4,this._getStatsData()];case 1:a=c.sent(),s=a?this._createRCRTCStateReport(a).iceCandidatePair:null,this.emit(t.__INNER_ICE_STATE_CHANGE__,{status:i,time:Date.now(),iceCandidatePair:s}),"connected"===i?(this.emit(t.__INNER_ICE_CONNECTED__,this._firstConnectFromPub),this.startAutoExecute(1e3)):"failed"!==i&&"disconnected"!==i||this._handleRetry();try{null===(r=null===(e=this._reportListener)||void 0===e?void 0:e.onICEConnectionStateChange)||void 0===r||r.call(e,i)}catch(e){this._logger.error(n.L_RTC_PEER_CONNECTION_ICE_CONNECTION_STATE_REPORT_R,JSON.stringify({status:o.FAILED,mag:e}))}return[2]}}))}))}}),Object.defineProperty(t.prototype,"_handleRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var e,t=this;return c(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===exports.RCRTCCode.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,i=e.receiver.track,n=[r,"audio"===i.kind?exports.RCMediaType.AUDIO_ONLY:exports.RCMediaType.VIDEO_ONLY].join("_");Object.defineProperty(i,"trackId",{value:n,writable:!1,enumerable:!1,configurable:!1}),this._updateRecvTransceiverMap(n,e.transceiver),dt(n).tag!==Kn&&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 s(this,void 0,void 0,(function(){return c(this,(function(i){return this._sdpStrategy.setBitrate(e,t,r),this._logger.info(n.L_RTC_PEER_CONNECTION_SET_BITRATE_O,JSON.stringify({status:o.SUCCESSED,max:e,min:t,start:r})),[2]}))}))}}),Object.defineProperty(t.prototype,"createOffer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return[4,this._sdpStrategy.createOffer(e)];case 1:return t=r.sent(),this._logger.info(n.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),s(this,void 0,void 0,(function(){return c(this,(function(i){return fo.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(Ke.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(Ke.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),e.on(Ke.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.on(Ke.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),this._logger.info(n.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(n.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:o.SUCCESSED,trackId:e})),this.removeLocalTrack(t)):this._logger.warn(n.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_BY_ID_O,JSON.stringify({status:o.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,t){void 0===t&&(t=!0);var r=e.getTrackId();delete this.pubLocalTracks[r],this._sdpStrategy.removeLocalTrack(e,t),e.__innerSetPublished(!1),e.off(Ke.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),e.off(Ke.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this);var i="".concat(r,"_tiny"),o=this.getLocalTrack(i);o&&t&&(this._sdpStrategy.removeLocalTrack(o,t),delete this.pubLocalTracks[i],o.destroy()),this._logger.info(n.L_RTC_PEER_CONNECTION_REMOVE_LOCAL_TRACK_O,JSON.stringify({trackId:r}))}}),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(Ke.__INNER_EVENT_MUTED_CHANGE__,e,t)}}),Object.defineProperty(t.prototype,"_onLocalTrackDestroied",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.emit(Ke.__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),a({},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),a({},t)}))}}),Object.defineProperty(t.prototype,"_createRCRTCStateReport",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.timestamp,r=e.iceCandidatePair,i=e.senders,n=e.receivers;for(var o in(null==r?void 0:r.totalPacketsLost)&&(null==r||delete r.totalPacketsLost),r)St(r[o])&&delete r[o];return{timestamp:t,iceCandidatePair:r,senders:this._createSenderReport(i),receivers:this._createReceiverReport(n)}}}),Object.defineProperty(t.prototype,"_getStatsData",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t;return s(this,void 0,void 0,(function(){var r,i,n;return c(this,(function(o){switch(o.label){case 0:return this._formatStatsData=null,r=null,[4,this._rtcPeerConn.getStats()];case 1:return i=o.sent(),r=null===(e=this.reportParser)||void 0===e?void 0:e.parseRTCStatsReport(i),n=null===(t=this.reportParser)||void 0===t?void 0:t.formatRCRTCStateReport(r),this._formatStatsData=n,[2,n]}}))}))}}),Object.defineProperty(t.prototype,"_reportHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,r,i,o,a;return s(this,void 0,void 0,(function(){var s,u,_,p;return c(this,(function(c){switch(c.label){case 0:return[4,this._getStatsData()];case 1:if(!(s=c.sent()))return[2];u=this._createRCRTCStateReport(s);try{null===(r=null===(e=this._reportListener)||void 0===e?void 0:e.onStateReport)||void 0===r||r.call(e,JSON.parse(JSON.stringify(u)))}catch(e){this._logger.error(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}if(_=d(d([],l(s.receivers),!1),l(s.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__,_),this._isRoomAudience&&(null===(i=this._reportListener)||void 0===i?void 0:i.onReportLiveAudioStates)){p=this._getLiveAudioState();try{p.length&&(null===(a=null===(o=this._reportListener)||void 0===o?void 0:o.onReportLiveAudioStates)||void 0===a||a.call(o,p))}catch(e){this._logger.error(n.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,d([],l(r),!1))})),t.map((function(t){var r=t.source,i=t.audioLevel,n=e._store.getTrackIdBySSRC(r);if(!n)return{};var o=dt(n).userId;return{audioLevel:to(i),userId:o,trackId:n}})).filter((function(e){return!!e.userId}))}}),Object.defineProperty(t.prototype,"_sendR3R4Data",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t,r,i;return s(this,void 0,void 0,(function(){var n,o,a;return c(this,(function(s){switch(s.label){case 0:return(n=this._formatStatsData)?(o=n.senders,a=n.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(n)]:[3,2]):[2];case 1:s.sent(),s.label=2;case 2:return a.length?[4,null===(i=this._polarisReport)||void 0===i?void 0:i.sendR4Data(n)]:[3,4];case 3:s.sent(),s.label=4;case 4:return o.length=0,a.length=0,n=null,[2]}}))}))}}),Object.defineProperty(t.prototype,"__reportR3R4ToPolaris",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var e=this;return c(this,(function(t){return this._isDestroyed||(clearTimeout(this._reportR3R4ToPolarisTimer),this._reportR3R4ToPolarisTimer=setTimeout((function(){return s(e,void 0,void 0,(function(){var e=this;return c(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(n.L_RTC_PEER_CONNECTION_DESTROY_O,JSON.stringify({status:o.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"}),Object.defineProperty(t,"__INNER_SEI_CONTENT__",{enumerable:!0,configurable:!0,writable:!0,value:"inner-sei-content"}),t}(e.EventEmitter),Lo=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 i=dt(e.trackId).userId,n=t._store.crtUserId===i?t._peer.getLocalTrack(e.trackId):t._store.getRemoteTrack(e.trackId);n&&r.push({track:n,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}();exports.RCRTCLiveRole=void 0,(To=exports.RCRTCLiveRole||(exports.RCRTCLiveRole={}))[To.ANCHOR=1]="ANCHOR",To[To.AUDIENCE=2]="AUDIENCE",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"}(Eo||(Eo={})),function(e){e[e.LOW=0]="LOW",e[e.NORMAL=1]="NORMAL",e[e.HIGH=2]="HIGH"}(So||(So={})),function(e){e[e.Destroy=40400]="Destroy"}(Io||(Io={}));var Ao,Po=function(){function e(){}return Object.defineProperty(e.prototype,"priority",{get:function(){return So.LOW},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"kind",{get:function(){return Eo.UNKNOWN},enumerable:!1,configurable:!0}),e}(),No=function(){function t(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})}return Object.defineProperty(t.prototype,"_next",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._busy=!1,this._execute()}}),Object.defineProperty(t.prototype,"_execute",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var t,r,i,o,a,s,u;return c(this,(function(c){switch(c.label){case 0:if(this._isDestroyed||this._busy||0===this._queue.length)return[2];this._busy=!0,t=this._queue.shift(),r=t.command,i=t.resolve,a=this._logger.createTraceId(),c.label=1;case 1:return c.trys.push([1,3,,4]),this._logger.info(n.L_INVOKER_EXECUTE_T,"kind: ".concat(r.kind,", length: ").concat(this._queue.length),a),[4,r.execute(this._context,this._store,this)];case 2:return o=c.sent(),[3,4];case 3:return s=c.sent(),console.error(s),this._logger.error(n.L_INVOKER_EXECUTE_R,r.kind,a),this._next(),[2];case 4:return(u=o.code)!==exports.RCRTCCode.SUCCESS&&u!==e.ErrorCode.SUCCESS?this._logger.warn(n.L_INVOKER_EXECUTE_R,"code: ".concat(u,", kind: ").concat(r.kind),a):this._logger.info(n.L_INVOKER_EXECUTE_R,"kind: ".concat(r.kind,", Done"),a),i(o),this._next(),[2]}}))}))}}),Object.defineProperty(t.prototype,"push",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t=this;return c(this,(function(r){return[2,new Promise((function(r){if(t._logger.info(n.L_INVOKER_PUSH_O,JSON.stringify({isDestroyed:t._isDestroyed,kind:e.kind,length:t._queue.length})),t._isDestroyed)r({code:exports.RCRTCCode.NOT_IN_ROOM});else{var i=e.priority;if(i===So.LOW)t._queue.push({command:e,resolve:r});else{var o=t._queue.findIndex((function(e){return e.command.priority<i})),a=-1===o?t._queue.length-1:o;t._queue.splice(a,0,{command:e,resolve:r})}setTimeout((function(){t._execute()}),0)}}))]}))}))}}),Object.defineProperty(t.prototype,"isDestroyed",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isDestroyed}}),Object.defineProperty(t.prototype,"destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._isDestroyed||(this._logger.info(n.L_INVOKER_DESTROY_O),this._isDestroyed=!0,this._queue.forEach((function(t){t.resolve({code:e.abortCode})})),this._queue.length=0)}}),t}(),wo=function(e){function t(t,r){return e.call(this,t.logger,t,r,exports.RCRTCCode.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}(No);!function(e){e.VOID="0",e.OPEN="2",e.CLOSE="1"}(Ao||(Ao={}));var Do,ko=function(){function e(e,t,r,i,n,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:i}),Object.defineProperty(this,"crtUserId",{enumerable:!0,configurable:!0,writable:!0,value:n}),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}),Object.defineProperty(this,"_asrStatus",{enumerable:!0,configurable:!0,writable:!0,value:Ao.VOID}),Object.defineProperty(this,"_asrEnable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_srcLanguage",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_asrSeiUris",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_isStartRealTranslate",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_translationLang",{enumerable:!0,configurable:!0,writable:!0,value:""})}return Object.defineProperty(e.prototype,"getResourcesByUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._roomResources[e]||this._asrSeiUris[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 i=this._remoteTracks[r];i.getUserId()===e&&t.push(i)}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=dt(e),r=t.tag,i=t.userId;return r===Kn?this._asrSeiUris[i][0]:this._roomResources[i].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}}),Object.defineProperty(e.prototype,"getASRIsAvailable",{enumerable:!1,configurable:!0,writable:!0,value:function(){return!1}}),Object.defineProperty(e.prototype,"getASRStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._asrStatus}}),Object.defineProperty(e.prototype,"getASREnable",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._asrEnable}}),Object.defineProperty(e.prototype,"getSrcLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._srcLanguage}}),Object.defineProperty(e.prototype,"getASRSeiUris",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=Object.values(this._asrSeiUris);return e.length?e[0]:[]}}),Object.defineProperty(e.prototype,"getIsStartRealTranslate",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isStartRealTranslate}}),Object.defineProperty(e.prototype,"getTranslationLang",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._translationLang}}),e}(),Uo=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),i=r.ssrc,n=r.resourceId;e._trackIdSSRCMap.set(i,n)}))}))}}),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),i=dt(r),n=i.tag,o=i.userId,a=i.mediaType===exports.RCMediaType.AUDIO_ONLY?new rt(e._logger,n,o):new it(e._logger,n,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=At(e.version),this._roomResources=yt(e,this.roomId,this._logger,t),this._updateTrackIdSSRCMap(),this._initRemoteTracks(),this.setResourcesByUserId(this.crtUserId,this.getResourcesByUserId(this.crtUserId)||[]),this._logger.info(n.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,d([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,d([0,this._collectSubscribeList.length],l(e),!1))}}),Object.defineProperty(t.prototype,"setRoomStatusVersion",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._roomStatusVersion=At(e)}}),Object.defineProperty(t.prototype,"setASRStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._asrStatus=e}}),Object.defineProperty(t.prototype,"setASREnable",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._asrEnable=e}}),Object.defineProperty(t.prototype,"setSrcLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._srcLanguage=e}}),Object.defineProperty(t.prototype,"setASRSeiUris",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.length){var t=e[0].msid.split("_")[0];this._asrSeiUris[t]=e}else this._asrSeiUris={}}}),Object.defineProperty(t.prototype,"addSeiRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e[0].msid.split("_"),r=t.pop(),i=t[0],n=new it(this._logger,r,i);this.addRemoteTrack(n)}}),Object.defineProperty(t.prototype,"removeSeiRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getASRSeiUris()[0],t=e.msid,r=e.mediaType,i="".concat(t,"_").concat(r);this.removeRemoteTrack(i)}}),Object.defineProperty(t.prototype,"setIsStartRealTranslate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._isStartRealTranslate=e}}),Object.defineProperty(t.prototype,"setTranslationLang",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._translationLang=e}}),t}(ko),Mo=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return Eo.UNPUBLISH_PREV},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return s(this,void 0,void 0,(function(){var i,a,s,u,l,d;return c(this,(function(c){switch(c.label){case 0:return i=t.logger,a=t.context,s=r.getResourcesByUserId(r.crtUserId),u=s.slice(),s.length=0,l=i.createTraceId(),i.info(n.L_UNPUBLISH_PREV_COMMAND_T,JSON.stringify({resource:u}),l),[4,a.setRTCTotalRes(r.roomId,[nt(Tt.UNPUBLISH,u)],ot([]),Tt.TOTAL_CONTENT_RESOURCE,ot([]))];case 1:return(d=c.sent())!==e.ErrorCode.SUCCESS?i.error(n.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:o.FAILED,code:d}),l):i.info(n.L_UNPUBLISH_PREV_COMMAND_R,JSON.stringify({status:o.SUCCESSED}),l),[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),i}(Po);exports.RTCMode=void 0,(Do=exports.RTCMode||(exports.RTCMode={}))[Do.RTC=0]="RTC",Do[Do.LIVE=2]="LIVE",Do[Do.CROSS_MUTI=7]="CROSS_MUTI",Do[Do.SIP=4]="SIP",Do[Do.CALL=5]="CALL";var xo,jo=function(t){function i(e,r,i,n,o,a,s){var c=t.call(this)||this;return Object.defineProperty(c,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(c,"roomType",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(c,"joinType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(c,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:n}),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(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return Eo.JOINROOM},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"_getResultTag",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=n.L_RTC_CLIENT_JOIN_RTC_ROOM_R;return this.roomType===exports.RTCMode.LIVE&&(e=n.L_RTC_CLIENT_JOIN_LIVING_ROOM_R),e}}),Object.defineProperty(i.prototype,"_validateParams",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){var n=this;if(t.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED)return r.error(i,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.SIGNAL_DISCONNECTED,msg:"im not connected"}),this.traceId),{code:exports.RCRTCCode.SIGNAL_DISCONNECTED};if(It(t.getNaviInfo()))return r.error(i,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),this.traceId),{code:exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR};if(!e.validate("roomId",this.roomId,e.notEmptyString,!0))return r.error(i,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> roomId"}),this.traceId),{code:exports.RCRTCCode.PARAMS_ERROR};if(!e.validate("roomType",this.roomType,(function(e){return void 0!==exports.RTCMode[e]})))return r.error(i,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> roomType"}),this.traceId),{code:exports.RCRTCCode.PARAMS_ERROR};if(!e.validate("outerUserDatas",this.outerUserDatas,e.isObject,!1))return r.error(i,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:exports.RCRTCCode.PARAMS_ERROR};if(this.outerUserDatas&&!Object.keys(this.outerUserDatas).every((function(t){return e.validate("outerUserDatas.".concat(t),n.outerUserDatas[t],e.isString,!0)})))return r.error(i,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> outerUserDatas"}),this.traceId),{code:exports.RCRTCCode.PARAMS_ERROR};return{code:exports.RCRTCCode.SUCCESS}}}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){var n,a,u;return s(this,void 0,void 0,(function(){var s,l,d,_,p,f,h,b,R,g,m,C,v,O,T,E;return c(this,(function(c){switch(c.label){case 0:return s=Date.now(),l=t.context,d=t.service,_=t.logger,p=t.reportMediaActionLogger,f=this._getResultTag(),(h=this._validateParams(l,_,f).code)!==exports.RCRTCCode.SUCCESS?[2,{code:h}]:d.getMsList().length?(b=r.getSupportNtf(),[4,l.joinRTCRoom(this.roomId,this.roomType,this.livingType,this.joinType,this.innerUserDatas,this.outerUserDatas,b)]):(_.error(f,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),this.traceId),[2,{code:exports.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER}]);case 1:return R=c.sent(),g=R.code,m=R.data,p.reportQualityJoinRoomData(s,g,this.roomType,null==m?void 0:m.sessionId),g===e.ErrorCode.SUCCESS&&m?(r.initWithRoomData(m,this.traceId),r.getResourcesByUserId(r.crtUserId).length>0&&i.push(new Mo),(v=null===(n=m.roomInfo.filter((function(e){return"cdn_uris"===e.key}))[0])||void 0===n?void 0:n.value)&&r.setCDNUris(JSON.parse(v)[0]),(O=null===(a=m.roomInfo.filter((function(e){return"asr_status"===e.key}))[0])||void 0===a?void 0:a.value)&&r.setASRStatus(O),(T=null===(u=m.roomInfo.filter((function(e){return"sei_ai_uris"===e.key}))[0])||void 0===u?void 0:u.value)&&(E=JSON.parse(T)).length&&(r.setASRSeiUris(E),r.addSeiRemoteTrack(E)),_.info(f,JSON.stringify({status:o.SUCCESSED,userId:r.crtUserId,roomId:this.roomId}),this.traceId),[2,{code:exports.RCRTCCode.SUCCESS,data:m}]):(C=40032===g?exports.RCRTCCode.SIGNAL_JOIN_RTC_ROOM_REFUSED:g,_.error(f,JSON.stringify({status:o.FAILED,code:C,msg:"joinRoom failed"}),this.traceId),[2,{code:C}])}}))}))}}),i}(Po);!function(e){e[e.ROOM=1]="ROOM",e[e.PERSON=2]="PERSON"}(xo||(xo={}));var Bo,Vo,Fo,Jo="PEER_CONNECTION_CLOSED_BY_EXCEPTION",Go="USER_JOIN",Ho="USER_LEAVE",Ko="TRACKS_PUBLISH",Wo="TRACKS_UNPUBLISH",Yo="AUDIO_MUTE_CHANGE",zo="VIDEO_MUTE_CHANGE",qo="CDN_ENABLE_CHANGE",Qo="USER_STATE_CHANGE",Zo="ASR_SEI_PUBLISH",Xo="ASR_SEI_UNPUBLISH",$o=function(e){function t(t,r,i,n,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:i}),Object.defineProperty(u,"runtime",{enumerable:!0,configurable:!0,writable:!0,value:n}),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}(e.EventEmitter);!function(e){e.PUBLISH="publish",e.SUBSCRIBE="subscribe"}(Bo||(Bo={})),function(e){e.BEGIN="begin",e.END="end"}(Vo||(Vo={})),function(e){e[e.SPREAD=0]="SPREAD",e[e.NO_SPREAD=-1]="NO_SPREAD"}(Fo||(Fo={}));var ea,ta=function(e){function t(t,r,i){var n=e.call(this)||this;return Object.defineProperty(n,"reqBody",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"isNeedUpdateMsas",{enumerable:!0,configurable:!0,writable:!0,value:i}),n}return r(t,e),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i;return s(this,void 0,void 0,(function(){var r,n,o,s,u,l,d,_,p,f;return c(this,(function(c){switch(c.label){case 0:return r=e.service,n=e.context,[4,r.exchange(t.getRTCRequestHeader(),this.reqBody,this.traceId,this.isNeedUpdateMsas)];case 1:return o=c.sent(),s=o.code,u=o.data,l=o.qualityMsList,d={code:s,data:{data:u,qualityMsList:l}},_=null===(i=null==u?void 0:u.urls)||void 0===i?void 0:i.pull_url,t.roomMode===exports.RTCMode.LIVE&&_&&(p=JSON.parse(_),t.setCDNUris(p),(null==p?void 0:p.broadcast)===Fo.SPREAD&&(t.setCDNEnabel(!0),f=a(a({},p),{enableInnerCDN:!0}),sa(n,t.roomId,f))),[2,d]}}))}))}}),t}(Po);!function(e){e.PUB="pub",e.UNPUB="unpub",e.SUB="sub",e.UNSUB="unsub"}(ea||(ea={}));var ra=function(t){function i(e,r,i,n,o){void 0===n&&(n=ea.SUB);var a=t.call(this)||this;return Object.defineProperty(a,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(a,"forceReq",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(a,"fromCommand",{enumerable:!0,configurable:!0,writable:!0,value:n}),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(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return Eo.UPDATE_SUBSCRIBE_LIST},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"_dealSubscribeResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var a=null==i?void 0:i.map((function(e){return"".concat(e.msid,"_").concat(e.mediaType)})),s=r.filter((function(e){return null==a?void 0:a.includes(e.track.getTrackId())})),c=r.filter((function(e){return!(null==a?void 0:a.includes(e.track.getTrackId()))}));t.info(n.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:o.SUCCESSED,subSuccessTrackIds:a,failedList:c}),this.traceId);var u=e.getRemoteTracks(),l=function(e){var t=s.some((function(t){return t.track.getTrackId()===e}));u[e].__innerSetSubscribed(t);var r=s.some((function(t){return t.track.getTrackId()===e&&t.subTiny}));u[e].isVideoTrack()&&u[e].__innerSetIsTinyTrack(r)};for(var d in u)l(d);return e.resetSubscribedList(s),c}}),Object.defineProperty(i.prototype,"_getParams",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=this,o=r.map((function(e){return e instanceof tt?{track:e}:a({},e)})),s={};return o=o.filter((function(r){var o=r.track.getTrackId();return e.getRemoteTrack(o)?!s[o]&&(s[o]=!0,!0):(t.warn(n.L_UPDATE_SUBSCRIBELIST_COMMAND_P,"track cannot found in room -> trackId: ".concat(o),i.traceId),!1)})).map((function(e){return a({},e)}))}}),Object.defineProperty(i.prototype,"_validateParams",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return e.validate("tracks",r,(function(){return e.isArray(r)&&r.every((function(e){return e instanceof tt||e.track instanceof tt}))}),!0)?{code:exports.RCRTCCode.SUCCESS}:(t.warn(n.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"tracks is invalid"}),this.traceId),{code:exports.RCRTCCode.PARAMS_ERROR})}}),Object.defineProperty(i.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(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,s,u,l,d,_,p,f,h,b,R,g,m,C,v,O,T,E,S,I,y,L,A=this;return c(this,(function(c){switch(c.label){case 0:if(i=e.logger,s=e.peer,u=e.reportMediaActionLogger,l=e.context,this._actionStartTime=Date.now(),_=(d=this).tracks,p=d.forceReq,f=t.roomId,i.info(n.L_UPDATE_SUBSCRIBELIST_COMMAND_T,"roomId: ".concat(f,", forceReq: ").concat(p,", trackIds: ").concat(_.map(Lt)),this.traceId),(h=this._validateParams(i,_).code)!==exports.RCRTCCode.SUCCESS)return[2,{code:h}];if(b=this._getParams(t,i,_),R=t.getSubscribedList().map((function(e){return a({},e)})),!p){if(!fa(b,R))return i.warn(n.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:o.SUCCESSED,msg:"subscribe list unchanged"}),this.traceId),[2,{code:exports.RCRTCCode.SUCCESS}];R.length&&(g=R.map((function(e){return e.track})),i.warn(n.L_CLEAR_UNSUBSCRIBE_LIST_O,JSON.stringify({list:g.map((function(e){return e.getTrackId()}))}),this.traceId),m=t.getSubscribedList().filter((function(e){return g.every((function(t){return t.getTrackId()!==e.track.getTrackId()}))})),t.resetSubscribedList(m))}return s.__reportR3R4ToPolaris(),s.clearReTryExchangeTimer(),s.updateSubRemoteTracks(b.map((function(e){return e.track}))),[4,oa(b,!1,s,t,l)];case 1:return(C=c.sent()).pushOtherRooms=e.getPushOtherRooms(),[4,new ta(C,this.traceId,!0).execute(e,t,r)];case 2:return v=c.sent(),_.forEach((function(e){var t=e instanceof tt?e.getTrackId():e.track.getTrackId();A._trackMediaMap[t]=v.data.qualityMsList||[]})),O=this.fromCommand===ea.SUB?_:this.unsubTracks,v.code!==exports.RCRTCCode.SUCCESS?(this._reportPubOrSubQualityData(u,v.code,O),i.error(n.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:o.FAILED,code:v.code}),this.traceId),[2,{code:v.code}]):(T=v.data.data,E=T.sdp,S=T.resultCode,I=T.subscribedList,S!==exports.RCRTCCode.SUCCESS?(this._reportPubOrSubQualityData(u,S,O),i.error(n.L_UPDATE_SUBSCRIBELIST_COMMAND_R,JSON.stringify({status:o.FAILED,code:S}),this.traceId),[2,{code:S}]):(u.setPubOrSubSuccessTime(Date.now()),[4,s.setRemoteAnswer(E.sdp)]));case 3:return y=c.sent(),this._reportPubOrSubQualityData(u,y,O),y!==exports.RCRTCCode.SUCCESS?[2,{code:y}]:[2,(L=this._dealSubscribeResult(t,i,b,I)).length?{code:exports.RCRTCCode.SUCCESS,data:L}:{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),i}(Po),ia=function(t){function i(e,r){var i=t.call(this)||this;return Object.defineProperty(i,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(i,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return Eo.UNSUBSCRIBE},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var s,u,l,d;return c(this,(function(c){return s=t.logger,u=t.polarisReport,l=this.tracks,e.validate("tracks",l,(function(){return e.isArray(l)&&l.length>0&&l.every((function(e){return e instanceof tt}))}),!0)?(s.info(n.L_ABSTRACT_ROOM_UNSUBSCRIBE_T,JSON.stringify({unSubscribeTrackIds:l.map(Lt)}),this.traceId),d=r.getSubscribedList().map((function(e){return a({},e)})).filter((function(e){return l.every((function(t){return t.getTrackId()!==e.track.getTrackId()}))})),u.sendR2(Bo.SUBSCRIBE,Vo.END,l.map((function(e){return e.getTrackId()}))),[2,new ra(d,!1,this.traceId,ea.UNSUB,this.tracks).execute(t,r,i)]):(s.warn(n.L_ABSTRACT_ROOM_UNSUBSCRIBE_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),[2,{code:exports.RCRTCCode.PARAMS_ERROR}])}))}))}}),i}(Po),na=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 s(this,void 0,void 0,(function(){var i,o,a;return c(this,(function(s){switch(s.label){case 0:return i=e.logger,o=this.tracks,a=i.createTraceId(),i.info(n.L_USER_LEFT_UNSUBSCRIBE_O,void 0,a),[4,new ia(o,a).execute(e,t,r)];case 1:return s.sent(),o.forEach((function(e){e.__innerDestroy(),t.removeRemoteTrack(e.getTrackId())})),e.emit(Wo,o),[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),t}(Po);function oa(e,t,r,i,n){var o;return s(this,void 0,void 0,(function(){var a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return a=(null===(o=n.getNaviInfo())||void 0===o?void 0:o.ipType)||0,[4,r.createOffer(t)];case 1:return s=c.sent(),u=i.getSrcLanguage(),l={resolutionInfo:r.getOutboundVideoInfo()},u&&Object.assign(l,{srcLanguage:u}),[2,{asr_status:i.getASRStatus(),ipType:a,sdp:s,extend:JSON.stringify(l),subscribeList:e.filter((function(e){var t=e.track.getTrackId(),r=dt(t).userId,n=i.getResourcesByUserId(r);if(!n)return!1;var o=n.filter((function(e){return t==="".concat(e.msid,"_").concat(e.mediaType)})).length;return o})).map((function(e){return{simulcast:e.subTiny?Gn.TINY:Gn.NORMAL,resolution:"",uri:i.getPublishedResourceByTrackId(e.track.getTrackId()).uri}})),switchstream:!1}]}}))}))}function aa(t,r,i){return s(this,void 0,void 0,(function(){var a,s;return c(this,(function(c){switch(c.label){case 0:return a=t.logger.createTraceId(),t.logger.info(n.L_LIVING_ROOM_SPREAD_CDN_INFO_T,JSON.stringify({CDNUris:i}),a),[4,t.setRTCCDNUris(r,Tt.TOTAL_CONTENT_RESOURCE,JSON.stringify([i]))];case 1:return(s=c.sent())!==e.ErrorCode.SUCCESS?(t.logger.error(n.L_LIVING_ROOM_SPREAD_CDN_INFO_R,"status: ".concat(o.FAILED,", code: ").concat(s),a),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(t.logger.info(n.L_LIVING_ROOM_SPREAD_CDN_INFO_R,"status: ".concat(o.SUCCESSED),a),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}function sa(t,r,i){return s(this,void 0,void 0,(function(){var a,s;return c(this,(function(c){switch(c.label){case 0:return a=t.logger.createTraceId(),t.logger.info(n.L_LIVING_ROOM_SET_ROOM_CDN_INFO_T,"CDNUris: ".concat(i),a),[4,t.setRTCData(r,"cdn_uris",JSON.stringify([i]),!0,xo.ROOM)];case 1:return(s=c.sent())!==e.ErrorCode.SUCCESS?(t.logger.error(n.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,"status: ".concat(o.FAILED,", code: ").concat(s),a),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(t.logger.info(n.L_LIVING_ROOM_SET_ROOM_CDN_INFO_R,"status: ".concat(o.SUCCESSED),a),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}function ca(e,t){return s(this,void 0,void 0,(function(){var r,i,n;return c(this,(function(o){switch(o.label){case 0:return r=t.roomId,i=Object.assign({},t.getCDNUris(),{enableInnerCDN:t.getCDNEnable()}),[4,Promise.all([aa(e,r,i),sa(e,r,i)])];case 1:return n=o.sent(),[2,n.every((function(e){return e.code===exports.RCRTCCode.SUCCESS}))?{code:exports.RCRTCCode.SUCCESS}:{code:exports.RCRTCCode.SIGNAL_ERROR}]}}))}))}var ua=function(e,t,r,i){return s(void 0,void 0,void 0,(function(){var n,o,a,s,u,l,d;return c(this,(function(c){switch(c.label){case 0:for(a in n=e.crtUserId,o=[],i)o.push(a);s=0,c.label=1;case 1:return s<o.length?(u=o[s])===n?[3,3]:(l=i[u]).length?(d=l.map((function(t){return e.getRemoteTrack(lt(t))})),[4,new na(d).execute(t,e,r)]):[3,3]:[3,4];case 2:c.sent(),c.label=3;case 3:return s++,[3,1];case 4:return[2]}}))}))};function la(t,r,i,a,u,l){return s(this,void 0,void 0,(function(){var s,d,_,p,f,h,b,R,g,m,C,v,O,T,E,S,I,y,L;return c(this,(function(c){switch(c.label){case 0:for(s=i.logger,d=r.roomId,_=r.roomMode,p=[],f={},h={},b={},R=yt(t,d,s,l),g=Object.keys(R),m=r.getAllUserIds(),C=g.length-1;C>=0;C-=1)v=g[C],-1!==(O=m.indexOf(v))?(T=r.getResourcesByUserId(v),E=R[v],S=ft(T,E,!0),I=S.publishedList,y=S.modifiedList,L=S.unpublishedList,f[v]=pt(I),h[v]=pt(L),b[v]=pt(y),m.splice(O,1)):(p.push(v),f[v]=pt(R[v]));return m.length&&m.forEach((function(e){r.removeResourcesByUserId(e)})),r.assignRoomData(R),m.length?[4,da(m,i,r,a,l)]:[3,2];case 1:c.sent(),i.emit(Ho,m),c.label=2;case 2:return p.length&&i.emit(Go,p),[4,ua(r,i,a,h)];case 3:return c.sent(),function(e,t,r){var i=t.logger;Object.keys(r).forEach((function(n){var o=r[n];if(0!==o.length){var a=o.map((function(t){var r=lt(t),n=dt(r),o=n.userId,a=n.tag,s=n.mediaType===exports.RCMediaType.AUDIO_ONLY?new rt(i,a,o):new it(i,a,o);return e.addRemoteTrack(s),s.__innerSetRemoteMuted(0===t.state),s}));a.length&&t.emit(Ko,a)}}))}(r,i,f),function(e,t,r){Object.keys(r).forEach((function(i){r[i].forEach((function(r){var i=lt(r),n=e.getRemoteTrack(i);n.__innerSetRemoteMuted(0===r.state),n.isAudioTrack()?t.emit(Yo,n):t.emit(zo,n)}))}))}(r,i,b),_===e.RTCMode.LIVE&&function(e,t,r,i){var a;if(!i)return void r.warn(n.L_LIVING_ROOM_RECONNECTED_R,JSON.stringify({status:o.FAILED,code:"",msg:"cdn_uris not found"}));var s=JSON.parse(i),c=(null===(a=t.getCDNUris())||void 0===a?void 0:a.enableInnerCDN)!==s.enableInnerCDN;t.setCDNUris(s),c&&e.emit(qo,s.enableInnerCDN)}(i,r,s,u),[2]}}))}))}function da(e,t,r,i,n){return s(this,void 0,void 0,(function(){var o,a;return c(this,(function(s){switch(s.label){case 0:return o=[],a=[],e.forEach((function(e){o.push.apply(o,d([],l(r.getRemoteTracksByUserId(e)),!1)),a.push(e)})),o.length?[4,new ia(o,n).execute(t,r,i)]:[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 _a,pa=function(e,t,r){var i=e.split("\r\nm"),n=r===exports.RCMediaType.AUDIO_ONLY?"audio":"video",o=i.filter((function(e){return e.includes("=".concat(n))&&e.includes(t)}))[0],a=new RegExp("a=ssrc:(.*?) msid:".concat(t)),s=o.match(a);return s?s[1]:""},fa=function(e,t){var r=!1;return e.forEach((function(e){var i=t.findIndex((function(t){return t.track.getTrackId()===e.track.getTrackId()}));-1!==i?t.splice(i,1)[0].subTiny!==e.subTiny&&(r=!0):r=!0})),t.length&&(r=!0),r},ha=function(e){function t(t,r){var i=e.call(this)||this;return Object.defineProperty(i,"msgContent",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return r(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Eo.PARSE_USERSTATE},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"priority",{get:function(){return So.NORMAL},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_isPKRoomUser",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i;try{for(var n=u(t),o=n.next();!o.done;o=n.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&&(i=n.return)&&i.call(n)}finally{if(r)throw r.error}}return!1}}),Object.defineProperty(t.prototype,"_dealAddUser",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,o){var a=e.getResourcesByUserId(o);a||(i?r.upgrade.push(o):r.joined.push(o),t.info(n.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:o,msg:"user ".concat(i?"upgrade":"joined")}),this.traceId)),e.setResourcesByUserId(o,a||[])}}),Object.defineProperty(t.prototype,"_dealReduceUser",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,o){e.info(n.L_PARSE_USERSTATE_COMMAND_R,JSON.stringify({userId:o,msg:"user ".concat(i?"downgrade":"left")}),this.traceId),i?t.downgrade.push(o):1!==Number(r)?t.offline.push(o):t.left.push(o)}}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n,o,a,s=this;return c(this,(function(c){switch(c.label){case 0:return i=e.logger,n={joined:[],left:[],offline:[],upgrade:[],downgrade:[]},0===(o=this.msgContent.users).length?[2,{code:exports.RCRTCCode.SUCCESS,data:n}]:this._isPKRoomUser(t,o)?[2,{code:exports.RCRTCCode.SUCCESS,data:n}]:(o.forEach((function(e){var r=e.userId;0===Number(e.state)?s._dealAddUser(t,i,n,e.switchRoleType,r):s._dealReduceUser(i,n,e.state,e.switchRoleType,r)})),(a=d(d(d([],l(n.left),!1),l(n.downgrade),!1),l(n.offline),!1)).length?[4,da(a,e,t,r,this.traceId)]:[3,2]);case 1:c.sent(),c.label=2;case 2:return[2,{code:exports.RCRTCCode.SUCCESS,data:n}]}}))}))}}),t}(Po),ba=function(e){function t(t,r,i,n,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:i}),Object.defineProperty(a,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:n}),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 Eo.PARSE_REMOTERES},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"priority",{get:function(){return So.NORMAL},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_dealPublishList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,a,s,u,l,d,_,p=this;return c(this,(function(c){switch(c.label){case 0:return i=e.logger,a=e.reportMediaActionLogger,s=this._nowResources.map(lt),u=[],l=[],this._publishedList.forEach((function(e){var r=lt(e),n=s.indexOf(r),o=dt(r),a=o.userId,c=o.tag,d=o.mediaType;n>-1?p._nowResources[n]=e:p._nowResources.push(e);var _=t.getRemoteTrack(r);_?_.isSubscribed()&&u.push(_):(_=d===exports.RCMediaType.AUDIO_ONLY?new rt(i,c,a):new it(i,c,a),t.addRemoteTrack(_),l.push(_)),_.__innerSetRemoteMuted(0===e.state)})),u.length?(d=u.map((function(e){return e.getTrackId()})),[4,new ra(u,!0,this.traceId).execute(e,t,r)]):[3,2];case 1:(_=c.sent().code)!==exports.RCRTCCode.SUCCESS&&i.error(n.L_RESUB_REPUB_RES_R,JSON.stringify({status:o.FAILED,trackIds:d,code:_}),this.traceId),c.label=2;case 2:return l.length&&e.emit(Ko,l),a.reportQualityRecvPubMsgData(this.sentTime,this.senderId),[2]}}))}))}}),Object.defineProperty(t.prototype,"_dealUnpublishList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n,o,a;return c(this,(function(s){switch(s.label){case 0:for(i=this._unpublishedList.map(lt),n=this._nowResources.length-1;n>=0;n-=1)o=this._nowResources[n],i.includes(lt(o))&&this._nowResources.splice(n,1);return a=this._unpublishedList.map((function(e){var r=lt(e);return t.getRemoteTrack(r)})),[4,new na(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 s(this,void 0,void 0,(function(){var r,i,n,o,a,s,l,d,_;return c(this,(function(c){r=this._nowResources.map(lt);try{for(i=u(this._modifiedList),n=i.next();!n.done;n=i.next())o=n.value,a=lt(o),s=r.indexOf(a),this._nowResources[s].state=o.state,(l=t.getRemoteTrack(a)).__innerSetRemoteMuted(0===o.state),l.isAudioTrack()?e.emit(Yo,l):e.emit(zo,l)}catch(e){d={error:e}}finally{try{n&&!n.done&&(_=i.return)&&_.call(i)}finally{if(d)throw d.error}}return[2]}))}))}}),Object.defineProperty(t.prototype,"_updateCDNUris",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,i,n=this.msgContent.cdn_uris[0],o=(null===(r=t.getCDNUris())||void 0===r?void 0:r.enableInnerCDN)!==n.enableInnerCDN;t.setCDNUris(n),o&&e.emit(qo,!!(null===(i=t.getCDNUris())||void 0===i?void 0:i.enableInnerCDN))}}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n,o,a,s,u,_,p,f,h;return c(this,(function(c){switch(c.label){case 0:if(i=this.msgContent.uris,this._publishedList=[],this._unpublishedList=[],this._modifiedList=[],o=this.senderId,a=this.messageType,!t.getRemoteUserIds().includes(o))return[2,{code:exports.RCRTCCode.SUCCESS}];switch(this._nowResources=t.getResourcesByUserId(o)||[],a){case Tt.MODIFY:(s=this._modifiedList).push.apply(s,d([],l(i),!1));break;case Tt.PUBLISH:(u=this._publishedList).push.apply(u,d([],l(i),!1));break;case Tt.UNPUBLISH:(_=this._unpublishedList).push.apply(_,d([],l(i),!1));break;case Tt.TOTAL_CONTENT_RESOURCE:n=ft(this._nowResources,i),(p=this._publishedList).push.apply(p,d([],l(n.publishedList),!1)),(f=this._unpublishedList).push.apply(f,d([],l(n.unpublishedList),!1)),(h=this._modifiedList).push.apply(h,d([],l(n.modifiedList),!1))}return this._publishedList.length?[4,this._dealPublishList(e,t,r)]:[3,2];case 1:c.sent(),c.label=2;case 2:return this._unpublishedList.length?[4,this._dealUnpublishList(e,t,r)]:[3,4];case 3:c.sent(),c.label=4;case 4:return this._modifiedList.length?[4,this._dealModifiedList(e,t)]:[3,6];case 5:c.sent(),c.label=6;case 6:return t.setResourcesByUserId(o,this._nowResources),t.roomMode!==exports.RTCMode.LIVE?[2,{code:exports.RCRTCCode.SUCCESS}]:this.msgContent.cdn_uris?(this._updateCDNUris(e,t),[2,{code:exports.RCRTCCode.SUCCESS}]):[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),t}(Po),Ra=function(t){function i(e,r,i){var n=t.call(this)||this;return Object.defineProperty(n,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(n,"forceReq",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i}),n}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return Eo.SUBSCRIBE},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var s,u,l,d,_,p,f,h,b;return c(this,(function(c){return s=t.logger,u=t.polarisReport,d=(l=this).tracks,_=l.forceReq,e.validate("tracks",d,(function(){return e.isArray(d)&&d.length>0&&d.every((function(e){return e instanceof tt||e.track instanceof tt}))}),!0)?(s.info(n.L_ABSTRACT_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:d.map(Lt),forceReq:_}),this.traceId),p=r.getSubscribedList().map((function(e){return a({},e)})),f=d.map((function(e){return e instanceof tt?{track:e}:e})),h=!1,b=[],f.forEach((function(e){var t=e.track.getTrackId();b.push(t);var r=p.find((function(e){return e.track.getTrackId()===t}));r&&r.subTiny===e.subTiny||(r?r.subTiny=e.subTiny:p.push(e),h=!0)})),h||_?(u.sendR2(Bo.SUBSCRIBE,Vo.BEGIN,b),[2,new ra(p,!0,this.traceId).execute(t,r,i)]):(s.warn(n.L_ABSTRACT_ROOM_SUBSCRIBE_R,JSON.stringify({status:o.SUCCESSED,msg:"repeat subscribe"}),this.traceId),[2,{code:exports.RCRTCCode.SUCCESS}])):(s.error(n.L_ABSTRACT_ROOM_SUBSCRIBE_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> tracks"}),this.traceId),[2,{code:exports.RCRTCCode.PARAMS_ERROR}])}))}))}}),i}(Po),ga=function(t){function i(e){var r=t.call(this)||this;return Object.defineProperty(r,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),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(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return Eo.PUBLISH},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"_removePubFailedTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.forEach((function(e){var r=e instanceof Ke?e:e.track;t.removeLocalTrackById(r.getTrackId())}))}}),Object.defineProperty(i.prototype,"_addLocalTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,o,a,s,l,d,_,p,f,h,b,R,g,m,C,v,O,T;return c(this,(function(c){switch(c.label){case 0:r=[],c.label=1;case 1:c.trys.push([1,10,11,12]),i=u(e),o=i.next(),c.label=2;case 2:if(o.done)return[3,9];if(a=o.value,l=(s=a instanceof Ke?{pubTiny:!1,track:a}:a).track,d=s.pubTiny,!l.isVideoTrack())return[3,7];if(!d)return[3,7];_=void 0,c.label=3;case 3:return c.trys.push([3,5,,6]),_=l.__innerGetMediaStreamTrack().clone(),p=d.frameRate||exports.RCFrameRate.FPS_15,f=d.resolution||exports.RCResolution.W176_H144,h=bt(f),b=h.width,R=h.height,g=mt(p),[4,_.applyConstraints({width:b,height:R,frameRate:g})];case 4:return c.sent(),[3,6];case 5:return m=c.sent(),null==_||_.stop(),this._logger.warn(n.L_ABSTRACT_ROOM_PUBLISH_E,"pubTiny failed -> id: ".concat(l.getTrackId(),", msg: ").concat(m.message),this._traceId),[3,9];case 6:return C=new Ye(this._logger,l.getTag(),l.getUserId(),_,!0),r.push(C),t.addLocalTrack(C),[3,7];case 7:t.addLocalTrack(l),c.label=8;case 8:return o=i.next(),[3,2];case 9:return[3,12];case 10:return v=c.sent(),O={error:v},[3,12];case 11:try{o&&!o.done&&(T=i.return)&&T.call(i)}finally{if(O)throw O.error}return[7];case 12:return[2,r]}}))}))}}),Object.defineProperty(i.prototype,"__publish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){return s(this,void 0,void 0,(function(){var s,u,l,d,_,p,f,h,b,R,g,m,C=this;return c(this,(function(c){switch(c.label){case 0:return s=e.peer,u=e.reportMediaActionLogger,l=e.context,t.roomId,d=[],r.forEach((function(e){var t=(e instanceof Ke?{track:e}:e).track;d.push(t)})),r.sort((function(e,t){return(e instanceof Ke?{track:e}:e).track.getBitrate().max-(t instanceof Ke?{track:t}:t).track.getBitrate().max})),s.getLocalTracks().length+function(e,t){var r=0;return e.forEach((function(e){var i=e instanceof Ke?e.getTrackId():e.track.getTrackId();t.getLocalTrack(i)||(e instanceof Ke?r++:e.pubTiny&&e.track.isVideoTrack()&&(r+=2))})),r}(r,s)>10?(this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PUBLISH_TRACK_LIMIT_EXCEEDED,trackIds:r.map(Lt),msg:"publish track limit exceeded"}),this._traceId),[2,{code:exports.RCRTCCode.PUBLISH_TRACK_LIMIT_EXCEEDED,tracks:d}]):[4,this._addLocalTracks(r,s)];case 1:return _=c.sent(),s.clearReTryExchangeTimer(),[4,oa(t.getSubscribedList(),!1,s,t,l)];case 2:return(p=c.sent()).pushOtherRooms=e.getPushOtherRooms(),[4,new ta(p,this._traceId,!0).execute(e,t,i)];case 3:return f=c.sent(),d.forEach((function(e){var t=e.getTrackId();C._trackMediaMap[t]=f.data.qualityMsList||[]})),f.code!==exports.RCRTCCode.SUCCESS?(u.reportPubOrSubQualityData(ea.PUB,this._actionStartTime,d,f.code,this._trackMediaMap),this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:o.FAILED,tracks:r.map(Lt),code:f.code,msg:"exchange failed"}),this._traceId),this._removePubFailedTracks(r,s),[2,{code:f.code,tracks:d}]):(h=f.data.data,b=h.sdp,R=h.resultCode,g=h.message,R!==exports.RCRTCCode.SUCCESS?(u.reportPubOrSubQualityData(ea.PUB,this._actionStartTime,d,R,this._trackMediaMap),this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:o.FAILED,trackIds:r.map(Lt),code:R,msg:"exchange inner failed: ".concat(g)}),this._traceId),this._removePubFailedTracks(r,s),[2,{code:R,tracks:d}]):(u.setPubOrSubSuccessTime(Date.now()),[4,s.setRemoteAnswer(b.sdp,!0)]));case 4:return(m=c.sent())!==exports.RCRTCCode.SUCCESS?(u.reportPubOrSubQualityData(ea.PUB,this._actionStartTime,d,m,this._trackMediaMap),this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:o.FAILED,trackIds:r.map(Lt),code:m,msg:"set remote answer error"}),this._traceId),[2,{code:m,tracks:d}]):(_.length&&this._updateTinyTrackIdSSRCMap(t,p.sdp.sdp,_),[2,a(a({code:R},f.data),{tracks:d})])}}))}))}}),Object.defineProperty(i.prototype,"_updateTinyTrackIdSSRCMap",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){r.forEach((function(r){var i=pa(t,r.getStreamId(),exports.RCMediaType.VIDEO_ONLY);e.setTrackIdSSRCMap(Number(i),r.getTrackId())}))}}),Object.defineProperty(i.prototype,"_dealPublishRes",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var s,u,_,p,f,h,b,R,g,m,C,v,O,T,E,S,I,y,L,A,P,N,w;return c(this,(function(c){switch(c.label){case 0:return s=i.polarisReport,u=i.context,_=i.peer,p=i.reportMediaActionLogger,f=r.crtUserId,h=r.roomId,b="",R=r.getResourcesByUserId(f),g=d([],l(R),!1),[],C=t.tracks,t.code!==exports.RCRTCCode.SUCCESS?[2,{code:t.code}]:(v=t.data,O=v.publishList,T=v.urls,E=v.mcuPublishList,b=null==T?void 0:T.liveUrl,O.map((function(e){return a({tag:e.msid.split("_").pop(),state:_.getLocalTrack(lt(e)).isLocalMuted()?0:1},e)})).forEach((function(e){var t=function(e,t){for(var r=!1,i=0,n=0;n<t.length;n++){var o=t[n];if("".concat(e.msid,"_").concat(e.mediaType)==="".concat(o.msid,"_").concat(o.mediaType)){r=!0,i=n;break}}return{isInclude:r,index:i}}(e,g),r=t.isInclude,i=t.index;r?g.splice(i,1,e):g.push(e)})),S=(null==E?void 0:E.map((function(e){return a({tag:e.msid.split("_").pop(),state:1},e)})))||[],m=S,I=ft(R,g).publishedList,y=a(a({},r.getCDNUris()),{enableInnerCDN:r.getCDNEnable()}),L=y&&y.broadcast===Fo.SPREAD?JSON.stringify([y]):"",A=Date.now(),[4,u.setRTCTotalRes(h,[nt(Tt.PUBLISH,I)],ot(g),Tt.TOTAL_CONTENT_RESOURCE,ot(m),L)]);case 1:return P=c.sent(),p.reportPubOrSubQualityData(ea.PUB,this._actionStartTime,C,P,this._trackMediaMap,[{dur:Date.now()-A,cod:P}]),P!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:o.FAILED,code:P,msg:"send publish streams notification failed"}),this._traceId),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(r.setResourcesByUserId(f,g),N=I.map((function(e){return lt(e)})),s.sendR2(Bo.PUBLISH,Vo.BEGIN,N),I.forEach((function(e){_.getLocalTrack("".concat(e.msid,"_").concat(e.mediaType)).__innerSetPublished(!0)})),w={code:exports.RCRTCCode.SUCCESS},b&&(w.liveUrl=b),[2,w])}}))}))}}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var a,s,u,l,d=this;return c(this,(function(c){switch(c.label){case 0:return a=t.logger,s=t.peer,this._traceId=a.createTraceId(),this._logger=a,this._actionStartTime=Date.now(),u=this.tracks,e.validate("tracks",u,(function(){return e.isArray(u)&&u.length>0&&u.every((function(e){return e instanceof Ke||e.track instanceof Ke}))}),!0)?(this._logger.info(n.L_ABSTRACT_ROOM_PUBLISH_T,JSON.stringify({trackIds:u.map(Lt)})),(u=u.filter((function(e){var t=(e instanceof Ke?{track:e}:e).track,r=t.isDestroyed();return r&&d._logger.warn(n.L_ABSTRACT_ROOM_PUBLISH_E,"track '".concat(t.getTrackId(),"' has beem destroyed"),d._traceId),!r}))).length?(s.__reportR3R4ToPolaris(),s.clearReTryExchangeTimer(),[4,this.__publish(t,r,u,i)]):(this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PUBLISH_TRACKS_IS_INVALID,msg:"params tracks is empty"}),this._traceId),[2,{code:exports.RCRTCCode.PUBLISH_TRACKS_IS_INVALID}])):(this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> tracks"}),this._traceId),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return l=c.sent(),[4,this._dealPublishRes(l,r,t)];case 2:return[2,c.sent()]}}))}))}}),i}(Po),ma=function(t){function i(e){var r=t.call(this)||this;return Object.defineProperty(r,"tracks",{enumerable:!0,configurable:!0,writable:!0,value:e}),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(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return Eo.UNPUBLISH},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"__unpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){return s(this,void 0,void 0,(function(){var s,u,l,d,_,p,f,h,b,R,g,m,C=this;return c(this,(function(c){switch(c.label){case 0:return s=e.peer,u=e.polarisReport,l=e.logger,d=e.reportMediaActionLogger,_=e.context,p=i.map((function(e){return e.getTrackId()})),0===p.map(t.getPublishedResourceByTrackId.bind(t)).filter((function(e){return!!e})).length?[2,{code:exports.RCRTCCode.SUCCESS,tracks:i}]:(p.forEach((function(e){return s.removeLocalTrackById(e)})),u.sendR2(Bo.PUBLISH,Vo.END,p),s.clearReTryExchangeTimer(),[4,oa(t.getSubscribedList(),!1,s,t,_)]);case 1:return f=c.sent(),(h=e.getPushOtherRooms()).length&&(f.pushOtherRooms=h),[4,new ta(f,this._traceId,!0).execute(e,t,r)];case 2:return b=c.sent(),i.forEach((function(e){var t=e.getTrackId();C._trackMediaMap[t]=b.data.qualityMsList||[]})),b.code!==exports.RCRTCCode.SUCCESS?(d.reportPubOrSubQualityData(ea.UNPUB,this._actionStartTime,i,b.code,this._trackMediaMap),l.error(n.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:o.FAILED,code:b.code,trackIds:i.map(Lt),msg:"exchange failed"}),this._traceId),[2,{code:b.code,tracks:i}]):(R=b.data.data,g=R.resultCode,m=R.message,g!==exports.RCRTCCode.SUCCESS?(d.reportPubOrSubQualityData(ea.UNPUB,this._actionStartTime,i,b.data.data.resultCode,this._trackMediaMap),l.error(n.L_ABSTRACT_ROOM_UNPUBLISH_P,JSON.stringify({status:o.FAILED,code:g,trackIds:i.map(Lt),msg:"exchange inner failed: ".concat(m)}),this._traceId),[2,{code:g,tracks:i}]):[2,a(a({code:b.code},b.data),{tracks:i})])}}))}))}}),Object.defineProperty(i.prototype,"_dealUnpublishRes",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var s,u,_,p,f,h,b,R,g,m,C,v,O,T,E,S,I,y,L,A;return c(this,(function(c){switch(c.label){case 0:return s=t.context,u=t.logger,_=t.peer,p=t.reportMediaActionLogger,f=s.getCurrentId(),h=r.roomId,b=[],[],g=i.tracks,m=i.code,C=i.data,m!==exports.RCRTCCode.SUCCESS?(u.error(n.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({code:m,msg:"unpublish failed"}),this._traceId),[2,{code:m}]):C?(v=C.mcuPublishList,O=g.map((function(e){return e.getTrackId()})),T=O.map(r.getPublishedResourceByTrackId.bind(r)).filter((function(e){return!!e})),b.push.apply(b,d([],l(T),!1)),E=v?v.map((function(e){return a({tag:e.msid.split("_").pop(),state:1},e)})):[],R=E,S=r.getResourcesByUserId(f),I=S.filter((function(e){return!b.includes(e)})),y=Date.now(),[4,s.setRTCTotalRes(h,[nt(Tt.UNPUBLISH,b)],ot(I),Tt.TOTAL_CONTENT_RESOURCE,ot(R))]):(u.info(n.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:o.SUCCESSED,msg:"unpublish list is empty "})),[2,{code:exports.RCRTCCode.SUCCESS}]);case 1:return L=c.sent(),p.reportPubOrSubQualityData(ea.UNPUB,this._actionStartTime,g,L,this._trackMediaMap,[{dur:Date.now()-y,cod:L}]),L!==e.ErrorCode.SUCCESS?(u.error(n.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:o.FAILED,code:L,msg:"send unpublish notification failed"}),this._traceId),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(u.info(n.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:o.SUCCESSED,code:exports.RCRTCCode.SUCCESS,msg:"unpublish success",unPubResourceIds:O}),this._traceId),A=i.data.sdp,[4,_.setRemoteAnswer(A.sdp)]);case 2:return c.sent(),r.setResourcesByUserId(f,I),[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return a=t.logger,this._actionStartTime=Date.now(),s=r.crtUserId,u=this.tracks,this._traceId=a.createTraceId(),e.validate("tracks",u,(function(){return u.every((function(e){return e.getUserId()===s&&e instanceof Ke}))}),!0)?(a.info(n.L_ABSTRACT_ROOM_UNPUBLISH_T,JSON.stringify({trackIds:u.map(Lt)})),[4,this.__unpublish(t,r,i,u)]):(a.error(n.L_ABSTRACT_ROOM_UNPUBLISH_E,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> tracks"})),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return l=c.sent(),[4,this._dealUnpublishRes(t,r,l)];case 2:return[2,c.sent()]}}))}))}}),i}(Po),Ca=function(t){function i(e){var r=t.call(this)||this;return Object.defineProperty(r,"localTrack",{enumerable:!0,configurable:!0,writable:!0,value:e}),r}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return Eo.LOCAL_TRACK_MUTE},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var i,a,s,l,d,_,p,f,h,b,R,g,m,C,v,O,T,E;return c(this,(function(c){switch(c.label){case 0:i=t.logger,a=t.context,s=this.localTrack,l=s.getTrackId(),d=r.crtUserId,_=r.roomId,p=!s.isLocalMuted(),f=i.createTraceId(),i.info(n.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_T,JSON.stringify({enabled:p,trackId:this.localTrack.getTrackId()}),f),h=[{resourceId:l,enabled:p}],b=r.getResourcesByUserId(d),R=[],g=function(e){var t=lt(e),r=h.findIndex((function(e){return e.resourceId===t}));if(r>=0){var i=h[r].enabled;return e.state=i?1:0,R.push(e),"break"}};try{for(m=u(b),C=m.next();!C.done&&(v=C.value,"break"!==g(v));C=m.next());}catch(e){T={error:e}}finally{try{C&&!C.done&&(E=m.return)&&E.call(m)}finally{if(T)throw T.error}}return[4,a.setRTCTotalRes(_,[nt(Tt.MODIFY,R)],ot(b),Tt.TOTAL_CONTENT_RESOURCE)];case 1:return(O=c.sent())!==e.ErrorCode.SUCCESS?(i.error(n.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:o.FAILED,code:O,msg:"signal error"}),f),[2,{code:O}]):(i.info(n.L_LOCAL_TRACK_SET_LOCAL_MUTED_SPREAD_R,JSON.stringify({status:o.SUCCESSED}),f),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),i}(Po),va=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return Eo.RETRY_EXCHANGE},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"priority",{get:function(){return So.HIGH},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,o,a,s,u,l,d,_,p,f,h,b,R,g,m;return c(this,(function(c){switch(c.label){case 0:return i=e.logger,o=e.peer,a=e.context,s=i.createTraceId(),i.info(n.L_RETRY_EXCHANGE_COMMAND_T),u=a.getCurrentId(),[4,oa(t.getSubscribedList(),!0,o,t,a)];case 1:return(l=c.sent()).pushOtherRooms=e.getPushOtherRooms(),[4,new ta(l,s).execute(e,t,r)];case 2:return(d=c.sent()).code!==exports.RCRTCCode.SUCCESS?[2,{code:d.code}]:(_=d.data.data,p=_.sdp,(f=_.resultCode)!==exports.RCRTCCode.SUCCESS?[2,{code:f}]:(o.clearReTryExchangeTimer(),[4,o.setRemoteAnswer(p.sdp)]));case 3:return(h=c.sent())!==exports.RCRTCCode.SUCCESS?[2,{code:h}]:(b=d.data.data.publishList||[],R=this._diffPublishListChange(b,t,o,u),g=R.plus,m=R.minus,g.length||m.length?[4,this._spreadPublishListUri(e,u,g,m,s)]:[3,5]);case 4:c.sent(),c.label=5;case 5:return[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),Object.defineProperty(i.prototype,"_diffPublishListChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var n=t.getResourcesByUserId(i),o=JSON.parse(JSON.stringify(n));e.forEach((function(e){var t,i=e.mediaType,n=e.msid,s=o.findIndex((function(e){var t=e.mediaType,r=e.msid;return i===t&&n===r}));if(-1===s){var c=a({tag:n.split("_").pop(),state:(null===(t=r.getLocalTrack(lt(e)))||void 0===t?void 0:t.isLocalMuted)?0:1},e);o.push(c)}else o[s].uri=e.uri}));var s=ft(n,o,!0),c=s.publishedList,u=s.unpublishedList;return t.setResourcesByUserId(i,o),{plus:c,minus:u}}}),Object.defineProperty(i.prototype,"_spreadPublishListUri",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,a,u){return s(this,void 0,void 0,(function(){var s,l,d,_;return c(this,(function(c){switch(c.label){case 0:return s=t.store,l=t.logger,d=s.getResourcesByUserId(r),l.info(n.L_RETRY_EXCHANGE_SPREAD_T,JSON.stringify({plus:i,minus:a,allPublishList:d}),u),_=[],a.length&&_.push(nt(Tt.UNPUBLISH,a)),i.length&&_.push(nt(Tt.PUBLISH,i)),[4,t.context.setRTCTotalRes(s.roomId,_,ot(d),Tt.TOTAL_CONTENT_RESOURCE)];case 1:return c.sent()===e.ErrorCode.SUCCESS?l.info(n.L_RETRY_EXCHANGE_SPREAD_R,"status: ".concat(o.SUCCESSED),u):l.error(n.L_RETRY_EXCHANGE_SPREAD_R,"status: ".concat(o.FAILED),u),[2]}}))}))}}),i}(Po);!function(e){e[e.JOIN=0]="JOIN",e[e.LEAVE=1]="LEAVE",e[e.OFFLINE=2]="OFFLINE",e[e.RESOURCECHANGE=3]="RESOURCECHANGE"}(_a||(_a={}));var Oa,Ta,Ea=function(t){function i(e,r,i,n){var o=t.call(this)||this;return Object.defineProperty(o,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(o,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(o,"_context",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(o,"_targetPullVersion",{enumerable:!0,configurable:!0,writable:!0,value:n}),o}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return Eo.PULL_RTCROOM_STATUS},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var a,s,l,d,_,p,f,h,b,R,g,m,C,v,O,T,E,S,I,y,L,A,P;return c(this,(function(c){switch(c.label){case 0:return a=t.logger,s=r.getRoomStatusVersion(),a.info(n.L_PULL_ROOM_STATUS_T,JSON.stringify({roomId:this._roomId,localVersion:s}),this._traceId),this._targetPullVersion&&this._targetPullVersion<=s?(a.info(n.L_PULL_ROOM_STATUS_R,JSON.stringify({status:o.SUCCESSED,msg:"the roomData has been pulled",localVersion:s,targetPullVersion:this._targetPullVersion}),this._traceId),[2,{code:e.ErrorCode.SUCCESS}]):[4,this._context.pullRTCRoomStatus(this._roomId,s)];case 1:return l=c.sent(),d=l.code,_=l.data,d!==e.ErrorCode.SUCCESS?(a.info(n.L_PULL_ROOM_STATUS_R,JSON.stringify({status:o.FAILED,code:d}),this._traceId),[2,{code:d}]):(f=(p=_).bFullStatus,h=p.version,b=p.usersData,R=p.roomStatus,a.info(n.L_PULL_ROOM_STATUS_R,JSON.stringify({bFullStatus:f,version:At(h),usersData:b,roomStatus:R}),this._traceId),r.setRoomStatusVersion(h),f?(g=function(e){var t={users:{}},r="";return e.forEach((function(e){var i,n,o=e.userId,a=e.userData;t.users[o]={};var s=null===(i=a.filter((function(e){return"uris"===e.key}))[0])||void 0===i?void 0:i.value,c=null===(n=a.filter((function(e){return"cdn_uris"===e.key}))[0])||void 0===n?void 0:n.value;r=c||r,t.users[o]={uris:s}})),{urisData:t,CDNUris:r&&JSON.stringify(JSON.parse(r)[0])}}(b),m=g.urisData,C=g.CDNUris,[4,la(m,r,t,i,C,this._traceId)]):[3,3]);case 2:return c.sent(),[2,{code:d}];case 3:c.trys.push([3,10,11,12]),v=u(R),O=v.next(),c.label=4;case 4:return O.done?[3,9]:(T=O.value).event!==_a.RESOURCECHANGE?[3,6]:(E=function(e){var t,r,i=e.userId,n=e.userData,o=function(e){return e.some((function(e){return"uris"===e.key||"cdn_uris"===e.key}))}(n);if(o){var a=null===(t=n.filter((function(e){return"uris"===e.key}))[0])||void 0===t?void 0:t.value,s=null===(r=n.filter((function(e){return"cdn_uris"===e.key}))[0])||void 0===r?void 0:r.value;return{userId:i,content:{uris:a?JSON.parse(a):[],cdn_uris:s&&JSON.parse(s)}}}}(T),E?(I=E.content,(S=E.userId)===r.crtUserId?[3,8]:[4,new ba(I,Tt.TOTAL_CONTENT_RESOURCE,S,this._traceId).execute(t,r,i)]):[3,8]);case 5:return c.sent(),[3,8];case 6:return I=function(e){var t,r=e.userId,i=e.userData,n=e.event,o=e.switchRoleType;return{users:[{userId:r,extra:null===(t=i.filter((function(e){return"extra"===e.key}))[0])||void 0===t?void 0:t.value,state:n,switchRoleType:o}]}}(T),[4,new ha(I,this._traceId).execute(t,r,i)];case 7:y=c.sent().data,t.emit(Qo,y),c.label=8;case 8:return O=v.next(),[3,4];case 9:return[3,12];case 10:return L=c.sent(),A={error:L},[3,12];case 11:try{O&&!O.done&&(P=v.return)&&P.call(v)}finally{if(A)throw A.error}return[7];case 12:return[2,{code:d}]}}))}))}}),i}(Po),Sa=function(t){function i(e){var r=t.call(this)||this;return Object.defineProperty(r,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:e}),r}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return Eo.ON_SIGNAL_RECONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"priority",{get:function(){return So.HIGH},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var o,a,s,u,l,d;return c(this,(function(c){switch(c.label){case 0:return o=t.logger,a=t.peer,s=t.context,u=r.roomId,l=r.roomMode,d=o.createTraceId(),o.info(n.L_ABSTRACT_ROOM_IM_RECONNECTED_T,void 0,d),"closed"===a.getRTCPeerConn().connectionState?(o.error(n.L_ABSTRACT_ROOM_IM_RECONNECTED_R,"RTCPeerConnection closed. Please rejoin room to restore services",d),t.emit(Jo),[2,{code:exports.RCRTCCode.SUCCESS}]):[4,s.rtcPing(u,l)];case 1:return 40001!==c.sent().code?[3,5]:[4,this._joinRoom(t,r,i,d)];case 2:return c.sent()!==e.ErrorCode.SUCCESS?[3,4]:[4,this._restoreMediaServer(t,r,i)];case 3:c.sent(),c.label=4;case 4:return[3,7];case 5:return[4,new Ea(u,d,s).execute(t,r,i)];case 6:c.sent(),c.label=7;case 7:return[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),Object.defineProperty(i.prototype,"_joinRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,a){var u,l,d;return s(this,void 0,void 0,(function(){var s,_,p,f,h,b,R,g,m,C,v,O,T,E;return c(this,(function(c){switch(c.label){case 0:return s=t.context,_=t.logger,[4,s.joinRTCRoom(r.roomId,r.roomMode,this.livingType)];case 1:return p=c.sent(),f=p.code,h=p.data,f!==e.ErrorCode.SUCCESS?(_.error(n.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:o.FAILED,code:f,msg:"im reconnect joinRTCRoom failed"}),a),[2]):h?(b=null===(u=h.roomInfo.filter((function(e){return"cdn_uris"===e.key}))[0])||void 0===u?void 0:u.value,[4,la(h,r,t,i,b,a)]):(_.info(n.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:o.FAILED,msg:"im reconnect joinRTCRoom, roomData is empty"}),a),[2]);case 2:return c.sent(),(R=null===(l=h.roomInfo.filter((function(e){return"asr_status"===e.key}))[0])||void 0===l?void 0:l.value)&&r.setASRStatus(R),g=null===(d=h.roomInfo.filter((function(e){return"sei_ai_uris"===e.key}))[0])||void 0===d?void 0:d.value,m=r.getASRIsAvailable(),g&&((C=JSON.parse(g)).length?(m||t.emit(Zo),r.setASRSeiUris(C),v=C[0],O=v.msid,T=v.mediaType,E="".concat(O,"_").concat(T),!r.getRemoteTrack(E)&&r.addSeiRemoteTrack(C)):(m&&t.emit(Xo),r.removeSeiRemoteTrack(),r.setASRSeiUris(C))),_.info(n.L_ABSTRACT_ROOM_IM_RECONNECTED_R,JSON.stringify({status:o.SUCCESSED,roomData:h}),a),[2,f]}}))}))}}),Object.defineProperty(i.prototype,"_restoreMediaServer",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n;return c(this,(function(o){switch(o.label){case 0:return i=e.peer.getLocalTracks(),n=Object.values(t.getRemoteTracks()).filter((function(e){return!!e.isSubscribed()})),i.length?[4,new ga(i).execute(e,t,r)]:[3,2];case 1:o.sent(),o.label=2;case 2:return i.length||!n.length?[3,4]:[4,new Ra(n,!0).execute(e,t,r)];case 3:o.sent(),o.label=4;case 4:return[2]}}))}))}}),i}(Po),Ia=1,ya=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"}(Oa||(Oa={})),exports.RCKickReason=void 0,(Ta=exports.RCKickReason||(exports.RCKickReason={}))[Ta.SERVER_KICK=1]="SERVER_KICK",Ta[Ta.OTHER_KICK=2]="OTHER_KICK",Ta[Ta.IM_DISCONNECTED=3]="IM_DISCONNECTED",Ta[Ta.IM_LOGOUT=4]="IM_LOGOUT",Ta[Ta.OTHER_CLIENT_IM_CONNECTED=5]="OTHER_CLIENT_IM_CONNECTED";var La,Aa,Pa,Na,wa=function(){function e(e,t,r,i){var o=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: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:function(e,t,r,i){o._baseReportData=Object.assign(o._baseReportData,{snid:i});var s=a(a(a({},o._baseReportData),o._networkReportData),{cod:t,time:e,dur:Date.now()-e,rtp:r});o._logger.__statistics(n.L_QS_JOIN_ROOM_S,JSON.stringify(s))}}),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=a(a(a({},this._baseReportData),this._networkReportData),{time:Date.now(),cod:e===exports.RCKickReason.OTHER_KICK?ya:Ia});this._logger.__statistics(n.L_QS_KICKED_S,JSON.stringify(t))}}),Object.defineProperty(e.prototype,"reportPubOrSubQualityData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,o,s){var c=this;r.forEach((function(r){var u,l,d=r instanceof Ke||r instanceof tt?r:r.track,_=d.getTrackId(),p=dt(_).mediaType,f=!1;f=d instanceof Ke?!!d.isVideoTrack()&&(null===(l=(u=d).__isTiny)||void 0===l?void 0:l.call(u)):r.subTiny||!1;var h=a(a(a({},c._baseReportData),c._networkReportData),{resid:_,mtp:p,smct:f?Gn.TINY:Gn.NORMAL,stp:"Rongcloud"!==d.getTag()?1:0,cod:i,msas:o?o[_]:[],sigs:s,time:Date.now(),dur:Date.now()-t});switch(e){case"pub":c._logger.__statistics(n.L_QS_PUBLISH_S,JSON.stringify(h));break;case"unpub":c._logger.__statistics(n.L_QS_UNPUBLISH_S,JSON.stringify(h));break;case"sub":c._logger.__statistics(n.L_QS_SUBSCRIBE_S,JSON.stringify(h));break;case"unsub":c._logger.__statistics(n.L_QS_UNSUBSCRIBE_S,JSON.stringify(h))}}))}}),Object.defineProperty(e.prototype,"reportQualityRecvPubMsgData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=a(a(a({},this._baseReportData),this._networkReportData),{puid:t,time:Date.now(),dur:Date.now()-e});this._logger.__statistics(n.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=a(a(a({},this._baseReportData),this._networkReportData),{time:this._pubOrSubSuccessTime,dur:Date.now()-this._pubOrSubSuccessTime}),r="pub"===e?n.L_QS_PUB_ICE_STATUS_S:n.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 i=this._peerCStatus||{},o=i.status,s=i.time;if(s){var c=e.IP,u=e.port,l=e.networkType,d=e.remoteIP,_=e.remotePort,p=a(a(a({},this._baseReportData),this._networkReportData),{dur:r-s,time:r,pices:Oa[o],ices:Oa[t],rcdts:[{ip:"".concat(d,":").concat(_)}],lcdts:[{ip:"".concat(c,":").concat(u),nttp:l}],cncdts:[]});console.log(n.L_QS_ICE_STATUS_S,p),this._logger.__statistics(n.L_QS_ICE_STATUS_S,JSON.stringify(p)),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"}(La||(La={})),function(e){e[e.MeetingOrAnchor=1]="MeetingOrAnchor",e[e.Audience=2]="Audience"}(Aa||(Aa={})),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"}(Pa||(Pa={})),function(e){e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4"}(Na||(Na={}));var Da,ka=function(){function t(e,t,r,i,n){void 0===n&&(n=Aa.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})}return Object.defineProperty(t.prototype,"_send",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return this._context.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED?[2,Pa.NOT_REPORT]:[4,this._context.setRTCState(this._roomId,t)];case 1:return r.sent()===e.ErrorCode.SUCCESS?[2,Pa.REPORT_SUCCESS]:[2,Pa.REPORT_FAIL]}}))}))}}),Object.defineProperty(t.prototype,"_getClientID",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e="uuid",t=this._runtime.localStorage.getItem(e);return t||(t=ht(),this._runtime.localStorage.setItem(e,t)),t}}),Object.defineProperty(t.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(t.prototype,"_getPolarisTrackId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t="",r=e.split("_");if(e.includes("_tiny")){var i=r.pop(),n=parseInt(r.pop())===exports.RCMediaType.AUDIO_ONLY?"audio":"video",o=r.pop();t=[r.join("_"),o,i,n].join("_")}else{n=parseInt(r.pop())===exports.RCMediaType.AUDIO_ONLY?"audio":"video",o=r.pop();t=[r.join("_"),o,n].join("_")}return t}}),Object.defineProperty(t.prototype,"_getBaseData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return{bitrateSend:(null==e?void 0:e.bitrateSend)||Hn,bitrateRecv:(null==e?void 0:e.bitrateRecv)||Hn,networkType:(null==e?void 0:e.networkType)||"unknown",rtt:(null==e?void 0:e.rtt)||Hn,localAddress:"".concat((null==e?void 0:e.IP)||Hn,":").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)||Hn,sendBand:(null==e?void 0:e.availableOutgoingBitrate)||Hn,packetsLost:(null==e?void 0:e.totalPacketsLost)||Hn,deviceId:this._context.getCurrentId()}}}),Object.defineProperty(t.prototype,"_getAudioLevel",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||0===e?e:Hn}}),Object.defineProperty(t.prototype,"_getBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||0===e?e:Hn}}),Object.defineProperty(t.prototype,"_getPacketsLostRate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||0===e?e:Hn}}),Object.defineProperty(t.prototype,"_getFrameRate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||Hn}}),Object.defineProperty(t.prototype,"_getResolution",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return e&&t?"".concat(e," * ").concat(t):"".concat(Hn)}}),Object.defineProperty(t.prototype,"_getJitter",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||Hn}}),Object.defineProperty(t.prototype,"_getNackCount",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||0===e?e:Hn}}),Object.defineProperty(t.prototype,"_getPliCount",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||0===e?e:Hn}}),Object.defineProperty(t.prototype,"_getRTT",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e||Hn}}),Object.defineProperty(t.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())?La.DISABLE:La.ENABLE}}),Object.defineProperty(t.prototype,"sendR3Data",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t,r,i,n,o,a=this;return c(this,(function(s){switch(s.label){case 0:return t=e.iceCandidatePair,r=e.senders,i=this._getBaseData(t),n="R3\t".concat(i.bitrateSend,"\t-1\t-1\t-1\t").concat(i.networkType,"\t").concat(i.rtt,"\t").concat(i.localAddress,"\t").concat(i.receiveBand,"\t").concat(i.sendBand,"\t").concat(i.packetsLost,"\t").concat(i.deviceId,"\r"),o=r.map((function(e){var t=e.trackId,r=e.audioLevel,i=e.samplingRate,n=e.bitrate,o=e.packetsLostRate,s=e.frameRate,c=e.frameWidth,u=e.frameHeight,l=e.googRenderDelayMs,d=e.jitter,_=e.nackCount,p=e.pliCount,f=e.rtt,h=e.googFirsSent,b=e.encoderImplementation,R=a._getPolarisTrackId(t),g=a._getRealResourceId(t);return{trackId:R,googCodecName:b||String(Hn),audioLevel:a._getAudioLevel(r),bitrate:a._getBitrate(n),packetsLostRate:a._getPacketsLostRate(o),frameRate:a._getFrameRate(s),resolution:a._getResolution(c,u),jitter:a._getJitter(d),nackCount:a._getNackCount(_),pliCount:a._getPliCount(p),rtt:a._getRTT(f),googFirsSent:h,samplingRate:i,googRenderDelayMs:l,encoderImplementation:b||String(Hn),trackState:a._getTrackState(!0,g)}})),n+=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(n,"\r").concat(this._userRole))];case 1:return s.sent()!==Pa.REPORT_SUCCESS?[2,Pa.REPORT_FAIL]:[2,Pa.REPORT_SUCCESS]}}))}))}}),Object.defineProperty(t.prototype,"sendR4Data",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t,r,i,n,o,a=this;return c(this,(function(s){switch(s.label){case 0:return t=e.iceCandidatePair,r=e.receivers,i=this._getBaseData(t),n="R4\t".concat(i.bitrateRecv,"\t-1\t-1\t-1\t").concat(i.networkType,"\t").concat(i.rtt,"\t").concat(i.localAddress,"\t").concat(i.receiveBand,"\t").concat(i.sendBand,"\t").concat(i.packetsLost,"\t").concat(i.deviceId,"\r"),o=r.filter((function(e){return!!e.trackId})).map((function(e){var t=e.trackId,r=e.audioLevel,i=e.samplingRate,n=e.bitrate,o=e.packetsLostRate,s=e.frameRate,c=e.frameWidth,u=e.frameHeight,l=e.googRenderDelayMs,d=e.jitter,_=e.nackCount,p=e.pliCount,f=e.rtt,h=e.googFirsReceived,b=e.codecImplementationName,R=a._getPolarisTrackId(t),g=a._getRealResourceId(t);return{trackId:R,googCodecName:b||String(Hn),audioLevel:a._getAudioLevel(r),bitrate:a._getBitrate(n),packetsLostRate:a._getPacketsLostRate(o),frameRate:a._getFrameRate(s),resolution:a._getResolution(c,u),jitter:a._getJitter(d),nackCount:a._getNackCount(_),pliCount:a._getPliCount(p),rtt:a._getRTT(f),googFirsReceived:h,samplingRate:i,googRenderDelayMs:l,codecImplementationName:b||String(Hn),trackState:a._getTrackState(!1,g)}})),n+=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(n,"\r").concat(this._userRole))];case 1:return s.sent()!==Pa.REPORT_SUCCESS?[2,Pa.REPORT_FAIL]:[2,Pa.REPORT_SUCCESS]}}))}))}}),Object.defineProperty(t.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,i=Ct.browser,n=Ct.version,o=this._getClientID(),a="R1\t".concat("5.34.0-alpha.1","\t").concat(t,"\t").concat("web","\t").concat(r,"\t").concat(-1,"\t").concat(i,"\t").concat(n,"\t").concat(o,"\t").concat(this._userRole);this._send(a)}}),Object.defineProperty(t.prototype,"sendR2",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i=this._getClientID(),n="R2\t".concat(e,"\t").concat(t,"\t").concat(i,"\r").concat(r.join("\t"),"\r").concat(this._userRole);this._send(n)}}),t}(),Ua=function(e){function t(t,r){var i=e.call(this)||this;return Object.defineProperty(i,"oldTrack",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"newTrack",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return r(t,e),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,o,a,s,u,l,d,_,p,f,h,b=this;return c(this,(function(c){switch(c.label){case 0:return i=e.peer,o=e.logger,this.oldTrack&&this.newTrack?[Xe,Ze].every((function(e){return!(b.oldTrack instanceof e)}))?(o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack is not RCCameraVideoTrack or RCMicphoneAudioTrack"),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):[Xe,Ze].every((function(e){return!(b.newTrack instanceof e)}))?(o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"newTrack is not RCCameraVideoTrack or RCMicphoneAudioTrack"),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(a=this.oldTrack.getSettings(),s=this.newTrack.getSettings(),u=this.oldTrack.getTrackId(),l=this.newTrack.getTrackId(),d=this.oldTrack.isAudioTrack()?"audio":"video",_=this.newTrack.isAudioTrack()?"audio":"video",o.info(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_T,JSON.stringify({oldTrackId:u,newTrackId:l,oldSettings:a,newSettings:s})),this.oldTrack.isPublished()?u!==l?(o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack and newTrack trackId are different, oldTrackId: ".concat(u,", newTrackId: ").concat(l)),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):d!==_?(o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack and newTrack are not the same kind, oldTrackKind: ".concat(d,", newTrackKind: ").concat(_)),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(null==a?void 0:a.deviceId)===(null==s?void 0:s.deviceId)?(o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack and newTrack deviceId are the same, oldDeviceId: ".concat(null==a?void 0:a.deviceId,", newDeviceId: ").concat(null==s?void 0:s.deviceId)),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(i.addLocalTrack(this.newTrack),p=(null==a?void 0:a.width)!==(null==s?void 0:s.width)||(null==a?void 0:a.height)!==(null==s?void 0:s.height)||(null==a?void 0:a.frameRate)!==(null==s?void 0:s.frameRate),f=i.getLocalTrack("".concat(this.oldTrack.getTrackId(),"_tiny")),p?[4,(new va).execute(e,t,r)]:(f&&f.destroy(),this.oldTrack.destroy(!1),this.newTrack.__innerSetPublished(!0),o.info(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"changeMediaDevice success"),[2,{code:exports.RCRTCCode.SUCCESS}])):(o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack is not published"),[2,{code:exports.RCRTCCode.PARAMS_ERROR}])):(o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"oldTrack or newTrack is empty"),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return(h=c.sent()).code!==exports.RCRTCCode.SUCCESS?(i.removeLocalTrack(this.newTrack,!1),i.addLocalTrack(this.oldTrack),this.newTrack.destroy(),o.error(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"negotiation failed, code: ".concat(h.code)),[2,{code:h.code}]):(f&&f.destroy(),this.oldTrack.destroy(!1),this.newTrack.__innerSetPublished(!0),o.info(n.L_RTC_CLIENT_CHANGE_MEDIA_DEVICE_R,"changeMediaDevice success"),[2,{code:h.code}])}}))}))}}),t}(Po);!function(e){e[e.OPEN=1]="OPEN",e[e.CLOSE=0]="CLOSE"}(Da||(Da={}));var Ma,xa=function(t){function i(e){var r=t.call(this)||this;return Object.defineProperty(r,"_type",{enumerable:!0,configurable:!0,writable:!0,value:e}),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}),r}return r(i,t),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var i,o,a,s,u,l,d,_,p,f;return c(this,(function(c){switch(c.label){case 0:return i=t.logger,o=t.context,a=t.service,this._traceId=i.createTraceId(),this._logger=i,this._logger.info(n.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_T,"type: ".concat(this._type)),(null==(s=o.getNaviInfo())?void 0:s.rtcAISwitch)===Da.CLOSE?(this._logger.error(n.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:exports.RCRTCCode.ASR_NOT_AVAILABLE})),[2,{code:exports.RCRTCCode.ASR_NOT_AVAILABLE}]):this._type===r.getASRStatus()?(this._logger.info(n.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:exports.RCRTCCode.SUCCESS})),[2,{code:exports.RCRTCCode.SUCCESS}]):(u=r.roomId,[4,o.setRTCData(u,"asr_status",this._type.toString(),!0,e.RTCApiType.ROOM)]);case 1:return(l=c.sent())!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:l})),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(r.setASRStatus(this._type),[4,a.updateASRStatus(r.getRTCRequestHeader(),{asr_status:this._type},this._traceId)]);case 2:return d=c.sent(),_=d.code,p=d.data,_!==exports.RCRTCCode.SUCCESS||(null==p?void 0:p.resultCode)!==exports.RCRTCCode.SUCCESS&&42200!==(null==p?void 0:p.resultCode)?(f=_!==exports.RCRTCCode.SUCCESS?_:null==p?void 0:p.resultCode,this._logger.error(n.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:f})),[2,{code:f}]):(this._logger.info(n.L_ABSTRACT_ROOM_OPERATE_ASR_STATUS_R,JSON.stringify({code:exports.RCRTCCode.SUCCESS})),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),i}(Po),ja=function(e){function t(t){var r=e.call(this)||this;return Object.defineProperty(r,"_enable",{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}),r}return r(t,e),Object.defineProperty(t.prototype,"_updateSubSei",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){var n="".concat(e[0].msid,"_").concat(e[0].mediaType),o=r.getRemoteTrack(n);return this._enable?new Ra([o]).execute(t,r,i):new ia([o],this._traceId).execute(t,r,i)}}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,o,a,s,u;return c(this,(function(c){switch(c.label){case 0:return i=e.logger,o=e.context,this._traceId=i.createTraceId(),this._logger=i,this._logger.info(n.L_ABSTRACT_ROOM_SET_ENABLE_ASR_T,"enable: ".concat(this._enable)),t.setASREnable(this._enable),(null==(a=o.getNaviInfo())?void 0:a.rtcAISwitch)===Da.CLOSE?(this._logger.error(n.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:exports.RCRTCCode.ASR_NOT_AVAILABLE})),[2,{code:exports.RCRTCCode.ASR_NOT_AVAILABLE}]):(s=t.getASRSeiUris()).length?[4,this._updateSubSei(s,e,t,r)]:(this._logger.info(n.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:exports.RCRTCCode.SUCCESS,asrSeiUrisLength:0})),[2,{code:exports.RCRTCCode.SUCCESS}]);case 1:return(u=c.sent().code)!==exports.RCRTCCode.SUCCESS?(this._logger.error(n.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:u})),[2,{code:u}]):(this._logger.info(n.L_ABSTRACT_ROOM_SET_ENABLE_ASR_R,JSON.stringify({code:exports.RCRTCCode.SUCCESS})),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),t}(Po);!function(e){e[e.OPEN=1]="OPEN",e[e.CLOSE=0]="CLOSE"}(Ma||(Ma={}));var Ba,Va,Fa,Ja,Ga=function(e){function t(t,r){var i=e.call(this)||this;return Object.defineProperty(i,"_status",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_destLanguage",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(i,"_traceId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),i}return r(t,e),Object.defineProperty(t.prototype,"_operateWithRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){return void 0===r&&(r=3),void 0===i&&(i=3e3),s(this,void 0,void 0,(function(){var n,o,a,s;return c(this,(function(c){switch(c.label){case 0:n=1,c.label=1;case 1:if(!(n<=r))return[3,8];c.label=2;case 2:return c.trys.push([2,4,,5]),[4,t.operateRealtimeTranslation(e.getRTCRequestHeader(),{status:this._status},this._traceId)];case 3:return o=c.sent(),a=o.code,o.data,a===exports.RCRTCCode.SUCCESS?[2]:(console.warn("第 ".concat(n," 次调用失败,code=").concat(a)),[3,5]);case 4:return s=c.sent(),console.error("第 ".concat(n," 次调用异常:"),s),[3,5];case 5:return n<r?[4,new Promise((function(e){setTimeout(e,i)}))]:[3,7];case 6:c.sent(),c.label=7;case 7:return n++,[3,1];case 8:return[2]}}))}))}}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var r,i,o,a,s,u,l,d,_;return c(this,(function(c){switch(c.label){case 0:if(r=e.logger,i=e.service,o=e.context,this._traceId=r.createTraceId(),this._logger=r,this._logger.info(n.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_T,JSON.stringify({status:this._status,destLanguage:this._destLanguage})),(null==(a=o.getNaviInfo())?void 0:a.rtcAISwitch)===Da.CLOSE)return this._logger.error(n.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:exports.RCRTCCode.ASR_NOT_AVAILABLE})),[2,{code:exports.RCRTCCode.ASR_NOT_AVAILABLE}];if(this._status===Ma.OPEN){if(!this._destLanguage)return this._logger.error(n.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:exports.RCRTCCode.PARAMS_ERROR})),[2,{code:exports.RCRTCCode.PARAMS_ERROR}];if(!t.getASRSeiUris().length)return this._logger.error(n.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:exports.RCRTCCode.ASR_NOT_START})),[2,{code:exports.RCRTCCode.ASR_NOT_START}]}return s={status:this._status},this._destLanguage&&(s.destLanguage=this._destLanguage),[4,i.operateRealtimeTranslation(t.getRTCRequestHeader(),s,this._traceId)];case 1:return u=c.sent(),l=u.code,d=u.data,this._status===Ma.CLOSE?(t.setIsStartRealTranslate(!1),this._logger.info(n.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:exports.RCRTCCode.SUCCESS})),l!==exports.RCRTCCode.SUCCESS&&this._operateWithRetry(t,i),[2,{code:exports.RCRTCCode.SUCCESS}]):l!==exports.RCRTCCode.SUCCESS||(null==d?void 0:d.resultCode)!==exports.RCRTCCode.SUCCESS?(_=l!==exports.RCRTCCode.SUCCESS?l:null==d?void 0:d.resultCode,this._logger.error(n.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:_})),[2,{code:_}]):(t.setIsStartRealTranslate(!0),this._destLanguage&&t.setTranslationLang(this._destLanguage),this._logger.info(n.L_ABSTRACT_ROOM_OPERATE_REALTIME_TRANSLATION_R,JSON.stringify({code:exports.RCRTCCode.SUCCESS})),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),t}(Po),Ha=function(e){function t(t){var r=e.call(this)||this;return Object.defineProperty(r,"_type",{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){return s(this,void 0,void 0,(function(){return c(this,(function(e){return t.setASRStatus(this._type),[2,{code:exports.RCRTCCode.SUCCESS}]}))}))}}),t}(Po),Ka=function(e){function t(t){var r=e.call(this)||this;return Object.defineProperty(r,"_asrSeiUris",{enumerable:!0,configurable:!0,writable:!0,value:t}),r}return r(t,e),Object.defineProperty(t.prototype,"_setEnableAsr",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i;return c(this,(function(n){switch(n.label){case 0:return(i=t.getASREnable())?[4,new ja(i).execute(e,t,r)]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(t.prototype,"_onPublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){e.emit(Zo),t.setASRSeiUris(this._asrSeiUris),t.addSeiRemoteTrack(this._asrSeiUris),this._setEnableAsr(e,t,r)}}),Object.defineProperty(t.prototype,"_onUnPublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){return c(this,(function(i){switch(i.label){case 0:return e.emit(Xo),[4,this._setEnableAsr(e,t,r)];case 1:return i.sent(),t.removeSeiRemoteTrack(),t.setASRSeiUris(this._asrSeiUris),[2]}}))}))}}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){return c(this,(function(i){return this._asrSeiUris.length?this._onPublish(e,t,r):this._onUnPublish(e,t,r),[2,{code:exports.RCRTCCode.SUCCESS}]}))}))}}),t}(Po),Wa=function(e){function t(t){var r=e.call(this)||this;return Object.defineProperty(r,"_srcLanguage",{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 s(this,void 0,void 0,(function(){var r;return c(this,(function(i){return(r=e.logger).info(n.L_ABSTRACT_ROOM_SET_SRC_LANGUAGE_T,"srcLanguage: ".concat(this._srcLanguage)),this._srcLanguage&&this._srcLanguage.length>50?(r.error(n.L_ABSTRACT_ROOM_SET_SRC_LANGUAGE_R,"code: ".concat(exports.RCRTCCode.PARAMS_ERROR)),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(t.setSrcLanguage(this._srcLanguage),r.info(n.L_ABSTRACT_ROOM_SET_SRC_LANGUAGE_R,"success"),[2,{code:exports.RCRTCCode.SUCCESS}])}))}))}}),t}(Po),Ya="evt-leave",za=function(t){function i(e,r,i,o,a,u,l,d,_,p){void 0===_&&(_=Wn()),void 0===p&&(p=!1);var f=t.call(this)||this;Object.defineProperty(f,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(f,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(f,"_roomId",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(f,"_service",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(f,"_initOptions",{enumerable:!0,configurable:!0,writable:!0,value:u}),Object.defineProperty(f,"_clientSessionId",{enumerable:!0,configurable:!0,writable:!0,value:_}),Object.defineProperty(f,"_pinger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_polarisReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_audioLevelReport",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_peerConnection",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_invoker",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_store",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_reportMediaActionLogger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_executeCtx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(f,"_appListener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(f,"_onRecvPKMsg",{enumerable:!0,configurable:!0,writable:!0,value:null});var h=f._logger=f._context.logger;f._reportMediaActionLogger=new wa(h,f._roomId,f._clientSessionId,f._context.getCurrentId()),f._polarisReport=new ka(f._context,f._runtime,f._roomId,f);var b=f._context.getCurrentId(),R=new Uo(h,_,f._context.getAppkey(),i,b,o,l,d),g=f._peerConnection=new yo(e,h,f._reTryExchange.bind(f),b,R,f._polarisReport,!1,p);f._setPeerConnectionListener();var m=f._executeCtx=new $o(h,f._service,e,r,g,R,f._polarisReport,f._reportMediaActionLogger);return m.getPushOtherRooms=function(){return f._getPushOtherRoomsParams()},f.setCommandEventListener(),f._invoker=new wo(m,R),f._store=f._invoker.store,f._audioLevelReport=new Lo(f._store,g),g.on(yo.__INNER_AUDIOLEVEL_CHANGE__,f._audioLevelReport.audioLevelReport,f._audioLevelReport),f._pinger=new Pt(f._context,f._roomId,o,f._initOptions.pingGap),f._pinger.onFailed=f.__kickoff.bind(f),f._pinger.onPingResult=f._handlePingResult.bind(f),f._context.registerRTCSignalListener((function(e){return s(f,void 0,void 0,(function(){var t,r,i,o,a;return c(this,(function(s){return t=this._context.decodeRtcNotify(e),r=t.time,i=t.type,o=t.roomId,this._invoker.isDestroyed()?(this._logger.info(n.L_RTCNTF_PULL_ROOM_STATUS_O,JSON.stringify({isDestroyed:!0,type:i,time:r,roomId:o})),[2]):(2===i&&o===this._roomId&&(a=this._logger.createTraceId(),this._logger.info(n.L_RTCNTF_PULL_ROOM_STATUS_O,null,a),this._startPullRTCRoomStatus(o,a,r)),[2])}))}))})),f}return r(i,t),Object.defineProperty(i.prototype,"_setPeerConnectionListener",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=this._peerConnection;t.on(yo.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),t.on(Ke.__INNER_EVENT_MUTED_CHANGE__,this._onLocalTrackMuted,this),t.on(Ke.__INNER_EVENT_DESTROY__,this._onLocalTrackDestroied,this),t.once(yo.__INNER_ICE_CONNECTED__,(function(t){e._reportMediaActionLogger.reportIceFirstConnectData(t?"pub":"sub")}),this),t.on(yo.__INNER_ICE_STATE_CHANGE__,(function(t){var r=t.status,i=t.time,n=t.iceCandidatePair;e._reportMediaActionLogger.recordQualityIceStatusData(n,r,i)})),t.on(yo.__INNER_SEI_CONTENT__,this._onReceiveAsrSeiContent,this)}}),Object.defineProperty(i.prototype,"setCommandEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._executeCtx;e.on(Jo,this._rtcpeerClosed,this),e.on(Go,this._callAppListener.bind(this,"onUserJoin"),this),e.on(Ho,this._callAppListener.bind(this,"onUserLeave"),this),e.on(Ko,this._onTrackPublish,this),e.on(Wo,this._onTrackUnpublish,this),e.on(Yo,this._onAudioMuteChange,this),e.on(zo,this._onVideoMuteChange,this),e.on(qo,this._callAppListener.bind(this,"onCDNEnableChange"),this),e.on(Qo,this._dealUserAppListener,this),e.on(Zo,this._callAppListener.bind(this,"onReceiveStartASR"),this),e.on(Xo,this._callAppListener.bind(this,"onReceiveStopASR"),this)}}),Object.defineProperty(i.prototype,"_startPullRTCRoomStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){return c(this,(function(i){switch(i.label){case 0:return[4,this._invoker.push(new Ea(e,t,this._context,r))];case 1:return i.sent(),[2]}}))}))}}),Object.defineProperty(i.prototype,"__innerInit",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n,o){return s(this,void 0,void 0,(function(){var a,s,u;return c(this,(function(c){switch(c.label){case 0:return[4,this._invoker.push(new jo(this._roomId,e,t,r,i,n,o))];case 1:return a=c.sent(),s=a.code,u=a.data,s!==exports.RCRTCCode.SUCCESS?[2,{code:s}]:(this._initWithRoomData(u.offlineKickTime),[2,{code:s,data:u}])}}))}))}}),Object.defineProperty(i.prototype,"_initWithRoomData",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._pinger.start(1e3*e),this._polarisReport.sendR1()}}),Object.defineProperty(i.prototype,"_handlePingResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(e===exports.RCRTCPingResult.SUCCESS&&(t>this._store.getRoomStatusVersion()&&this._store.getSupportNtf())){var r=this._logger.createTraceId();this._logger.info(n.L_RTCPING_PULL_ROOM_STATUS_O,JSON.stringify({dataVersion:t}),r),this._startPullRTCRoomStatus(this._roomId,r,t)}this._callAppListener("onPing",e)}}),Object.defineProperty(i.prototype,"setBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){this._logger.warn(n.L_ABSTRACT_ROOM_SETBITRATE_O,"`RCAbstractRoom.setBitrate` will be deprecated, use `RCLocalTrack.setBitrate` instead."),e.assert("max",t,(function(t){return e.isNumber(t)&&t>Math.max(r||1,200)}),!0),e.assert("min",r,(function(r){return e.isNumber(r)&&r>=1&&(!e.isNumber(t)||r<t)}),!0),e.assert("start",i,(function(i){return e.isNumber(i)&&i>r&&i<=t})),this._peerConnection.setBitrate(t,r,i)}}),Object.defineProperty(i.prototype,"_onTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.streams[0].id,r=e.receiver.track,i=[t,"audio"===r.kind?exports.RCMediaType.AUDIO_ONLY:exports.RCMediaType.VIDEO_ONLY].join("_"),a=this._store.getRemoteTrack(i);a?(a.__innerSetMediaStreamTrack(r),this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onTrackReady",trackId:a.getTrackId()})),this._callAppListener("onTrackReady",a)):this._logger.warn(n.L_ABSTRACT_ROOM_ONTRACKREADY_O,"cannot found remote track ".concat(r.id))}}),Object.defineProperty(i.prototype,"_callAppListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var o=null===(t=this._appListener)||void 0===t?void 0:t[e];if(o)try{o.apply(void 0,d([],l(r),!1))}catch(e){this._logger.error(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,null==e?void 0:e.stack)}}}),Object.defineProperty(i.prototype,"_onTrackUnpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onTrackUnpublish",trackIds:null==e?void 0:e.map((function(e){return e.getTrackId()}))})),this._callAppListener("onTrackUnpublish",e)}}),Object.defineProperty(i.prototype,"__parseInnerMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=e.targetId;if(r===this._roomId){this._logger.info(n.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,"recv inner msg -> message: ".concat(JSON.stringify(e)," | roomid: ").concat(this._roomId),t);var i=e.content;switch(e.messageType){case Tt.KICK:this.__kickoff(!0,i);break;case Tt.STATE:this._stateHandle(i,t);break;case Tt.MODIFY:case Tt.PUBLISH:case Tt.UNPUBLISH:case Tt.TOTAL_CONTENT_RESOURCE:this._resourceHandle(i,e.messageType,e.senderUserId,e.sentTime,t);break;case Tt.ASR_STATUS:this._invoker.push(new Ha(i.value));break;case Tt.ASR_SEI:this._invoker.push(new Ka(JSON.parse(i.sei_ai_uris||[])));break;case Tt.ROOM_NOTIFY:this._logger.info(n.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 Tt.USER_NOTIFY:this._logger.warn(n.L_OLD_DAILY_RECORD_O,"TODO: ".concat(Tt.USER_NOTIFY));break;case Tt.PK_INVITE:case Tt.PK_CANCEL_INVITE:case Tt.PK_INVITE_TIMEOUT:case Tt.PK_INVITE_ANSWER:case Tt.PK_END:this._onRecvPKMsg&&this._onRecvPKMsg(e);break;case Tt.OTHER_ROOM_OFFLINE:break;default:this._logger.info(n.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)}}else this._logger.warn(n.L_ABSTRACT_ROOM_RECEIVE_MESSAGE_O,JSON.stringify({status:o.FAILED,message:"roomId is different, msg roomId-> ".concat(r,", this._roomId-> ").concat(this._roomId," ")}),t)}}),Object.defineProperty(i.prototype,"__kickoff",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,a=this;return c(this,(function(s){return this._invoker.isDestroyed()||(this._logger.warn(n.L_ABSTRACT_ROOM_ONKICKOFF_O,"onKickOff -> byServer: ".concat(e,", kickContent: ").concat(JSON.stringify(t))),this.emit(Ya),this._leaveHandle(!e),e&&((null==t?void 0:t.users)||[]).forEach((function(e){e.userId===a._context.getCurrentId()&&(i=e.type,r=e.kickExtra,a._reportMediaActionLogger.reportQualityKickedData(i))})),this._logger.info(n.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)),[2]}))}))}}),Object.defineProperty(i.prototype,"_rtcpeerClosed",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.emit(Ya),this._leaveHandle(!0),this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,"onRTCPeerConnectionCloseByException"),this._callAppListener("onRTCPeerConnectionCloseByException")}}),Object.defineProperty(i.prototype,"_onReceiveAsrSeiContent",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.forEach((function(e){"destLangCode"in e?t._store.getIsStartRealTranslate()&&t._store.getTranslationLang()===e.destLangCode&&t._callAppListener("onReceiveRealtimeTranslationContent",e):t._callAppListener("onReceiveASRContent",e)}))}}),Object.defineProperty(i.prototype,"_resourceHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n){return s(this,void 0,void 0,(function(){var o;return c(this,(function(a){return o=e.uris,e.ignore||!o||this._invoker.push(new ba(e,t,r,n,i)),[2]}))}))}}),Object.defineProperty(i.prototype,"_onTrackPublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onTrackPublish",trackIds:null==e?void 0:e.map((function(e){return e.getTrackId()}))})),this._callAppListener("onTrackPublish",e)}}),Object.defineProperty(i.prototype,"_stateHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i;return c(this,(function(n){switch(n.label){case 0:return[4,this._invoker.push(new ha(e,t))];case 1:return r=n.sent(),i=r.data,this._dealUserAppListener(i),[2]}}))}))}}),Object.defineProperty(i.prototype,"_dealUserAppListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,i=this,a=e.left,s=e.joined,c=e.upgrade,u=e.downgrade,_=e.offline,p=d([],l(s),!1),f=d([],l(a),!1);(null===(t=this._appListener)||void 0===t?void 0:t.onSwitchRole)?(null==c||c.forEach((function(e){i._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onSwitchRole",userId:e,role:exports.RCRTCLiveRole.ANCHOR})),i._callAppListener("onSwitchRole",e,exports.RCRTCLiveRole.ANCHOR)})),null==u||u.forEach((function(e){i._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onSwitchRole",userId:e,role:exports.RCRTCLiveRole.AUDIENCE})),i._callAppListener("onSwitchRole",e,exports.RCRTCLiveRole.AUDIENCE)}))):(p.push.apply(p,d([],l(c),!1)),f.push.apply(f,d([],l(u),!1))),_.length&&((null===(r=this._appListener)||void 0===r?void 0:r.onUserOffline)?(this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onUserOffline",offline:_})),this._callAppListener("onUserOffline",_)):f.push.apply(f,d([],l(_),!1))),p.length>0&&(this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onUserJoin",allJoined:p})),this._callAppListener("onUserJoin",p)),f.length>0&&(this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onUserLeave",allLeft:f})),this._callAppListener("onUserLeave",f))}}),Object.defineProperty(i.prototype,"getRoomId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._roomId}}),Object.defineProperty(i.prototype,"getCrtUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._context.getCurrentId()}}),Object.defineProperty(i.prototype,"getRemoteUserIds",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.getRemoteUserIds()}}),Object.defineProperty(i.prototype,"getRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=[];return this.getRemoteUserIds().forEach((function(r){t.push.apply(t,d([],l(e.getRemoteTracksByUserId(r)),!1))})),t}}),Object.defineProperty(i.prototype,"getRemoteTracksByUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._store.getRemoteTracksByUserId(e)}}),Object.defineProperty(i.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.getSessionId()}}),Object.defineProperty(i.prototype,"sendMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return s(this,void 0,void 0,(function(){var i,a;return c(this,(function(s){switch(s.label){case 0:return i=this._logger.createTraceId(),this._logger.info(n.L_ABSTRACT_ROOM_SEND_MESSAGE_T,JSON.stringify({name:t,content:r}),i),[4,this._context.sendMessage(e.ConversationType.RTC_ROOM,this._roomId,{messageType:t,content:r,isStatusMessage:!0})];case 1:return(a=s.sent().code)!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:o.FAILED,code:a}),i),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(this._logger.info(n.L_ABSTRACT_ROOM_SEND_MESSAGE_R,JSON.stringify({status:o.SUCCESSED,name:t,content:r}),i),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),Object.defineProperty(i.prototype,"setRoomAttribute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,a){return void 0===a&&(a=!1),s(this,void 0,void 0,(function(){var s,u;return c(this,(function(c){switch(c.label){case 0:return s=this._logger.createTraceId(),this._logger.info(n.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,key:t,value:r,message:i,isInner:a}),s),[4,this._context.setRTCData(this._roomId,t,r,a,xo.ROOM,i)];case 1:return(u=c.sent())!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:o.FAILED,code:u}),s),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(this._logger.info(n.L_ABSTRACT_ROOM_SET_ROOM_ATTRIBUTE_R,JSON.stringify({status:o.SUCCESSED,roomId:this._roomId,key:t,value:r,message:i,isInner:a}),s),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),Object.defineProperty(i.prototype,"deleteRoomAttributes",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return void 0===i&&(i=!1),s(this,void 0,void 0,(function(){var a,s;return c(this,(function(c){switch(c.label){case 0:return a=this._logger.createTraceId(),this._logger.info(n.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:t,message:r,isInner:i}),a),[4,this._context.removeRTCData(this._roomId,t,i,xo.ROOM,r)];case 1:return(s=c.sent())!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:o.FAILED,code:s}),a),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(this._logger.info(n.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:o.SUCCESSED,roomId:this._roomId,keys:t,message:r,isInner:i}),a),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),Object.defineProperty(i.prototype,"getRoomAttributes",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return void 0===t&&(t=[]),void 0===r&&(r=!1),s(this,void 0,void 0,(function(){var i,a,s,u;return c(this,(function(c){switch(c.label){case 0:return i=this._logger.createTraceId(),this._logger.info(n.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_T,JSON.stringify({roomId:this._roomId,keys:t,isInner:r}),i),[4,this._context.getRTCData(this._roomId,t,r,xo.ROOM)];case 1:return a=c.sent(),s=a.code,u=a.data,s!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_ABSTRACT_ROOM_GET_ROOM_ATTRIBUTE_R,"GetRoomAttributes Failed: ".concat(s),i),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(this._logger.info(n.L_ABSTRACT_ROOM_DELETE_ROOM_ATTRIBUTE_R,JSON.stringify({status:o.SUCCESSED,data:u}),i),[2,{code:exports.RCRTCCode.SUCCESS,data:u}])}}))}))}}),Object.defineProperty(i.prototype,"_setUserAttributeValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return this._context.setRTCData(this._roomId,e,t,!1,xo.PERSON,r)}}),Object.defineProperty(i.prototype,"_deleteUserAttributes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._context.removeRTCData(this._roomId,e,!1,xo.PERSON,t)}}),Object.defineProperty(i.prototype,"_getUserAttributes",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._context.getRTCData(this._roomId,e,!1,xo.PERSON)}}),Object.defineProperty(i.prototype,"isDestroyed",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._invoker.isDestroyed()}}),Object.defineProperty(i.prototype,"__destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._leaveHandle(e)}}),Object.defineProperty(i.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(i.prototype,"_leaveHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(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(i.prototype,"_releasePCManager",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._peerConnection;e.removeAllLocalTrack(),e.destroy()}}),Object.defineProperty(i.prototype,"_onLocalTrackDestroied",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e instanceof Ye&&e.__isTiny()||this.unpublish([e])}}),Object.defineProperty(i.prototype,"_onLocalTrackMuted",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r;return c(this,(function(i){switch(i.label){case 0:return[4,this._invoker.push(new Ca(e))];case 1:return r=i.sent().code,t(r),[2]}}))}))}}),Object.defineProperty(i.prototype,"publish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this._invoker.push(new ga(e))]}))}))}}),Object.defineProperty(i.prototype,"_getPushOtherRoomsParams",{enumerable:!1,configurable:!0,writable:!0,value:function(){return[]}}),Object.defineProperty(i.prototype,"_reTryExchange",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._invoker.push(new va)}}),Object.defineProperty(i.prototype,"unpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this._invoker.push(new ma(e))]}))}))}}),Object.defineProperty(i.prototype,"_isValidResourceId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=dt(e).userId;return!!(null===(t=this._store.getResourcesByUserId(r))||void 0===t?void 0:t.find((function(t){return lt(t)===e})))}}),Object.defineProperty(i.prototype,"subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this._invoker.push(new Ra(e,void 0,void 0))]}))}))}}),Object.defineProperty(i.prototype,"unsubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){return t=this._logger.createTraceId(),this._logger.info(n.L_APP_CALL_UNSUBSCRIBE_O,void 0,t),[2,this._invoker.push(new ia(e,t))]}))}))}}),Object.defineProperty(i.prototype,"updateSubList",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this._invoker.push(new ra(e,!0,this._logger.createTraceId()))]}))}))}}),Object.defineProperty(i.prototype,"getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._peerConnection.getLocalTrack(e)}}),Object.defineProperty(i.prototype,"getLocalTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._peerConnection.getLocalTracks()}}),Object.defineProperty(i.prototype,"getRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._store.getRemoteTrack(e)||null}}),Object.defineProperty(i.prototype,"subscribedTracks",{get:function(){return this._store.getSubscribedList().slice()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"registerRoomEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(n.L_ABSTRACT_ROOM_REGISTER_ROOM_EVENT_LISTENER_O,e?Object.keys(e).join(","):null),this._appListener=e}}),Object.defineProperty(i.prototype,"registerReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(n.L_ABSTRACT_ROOM_REGISTER_REPORT_LISTENER_O,e?Object.keys(e).join(","):null),this._peerConnection.registerReportListener(e)}}),Object.defineProperty(i.prototype,"onAudioLevelChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(n.L_ABSTRACT_ROOM_AUDIO_LEVEL_O),this._audioLevelReport.onAudioLevelChange(e)}}),Object.defineProperty(i.prototype,"__onReconnected",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._invoker.push(new Sa(e))}}),Object.defineProperty(i.prototype,"_onAudioMuteChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onAudioMuteChange",trackId:e.getTrackId()})),this._callAppListener("onAudioMuteChange",e)}}),Object.defineProperty(i.prototype,"_onVideoMuteChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(n.L_ABSTRACT_ROOM_CALL_APP_LISTENER_O,JSON.stringify({status:o.SUCCESSED,eventType:"onVideoMuteChange",trackId:e.getTrackId()})),this._callAppListener("onVideoMuteChange",e)}}),Object.defineProperty(i.prototype,"_registerPKMsgListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._onRecvPKMsg=e}}),Object.defineProperty(i.prototype,"_quitAllPKRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){return c(this,(function(e){return[2]}))}))}}),Object.defineProperty(i.prototype,"getClientSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.clientSessionId}}),Object.defineProperty(i.prototype,"changeMediaDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){return c(this,(function(r){return[2,this._invoker.push(new Ua(e,t))]}))}))}}),Object.defineProperty(i.prototype,"setSrcLanguageCode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._invoker.push(new Wa(e))}}),Object.defineProperty(i.prototype,"startASR",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._invoker.push(new xa(Ao.OPEN))}}),Object.defineProperty(i.prototype,"stopASR",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._invoker.push(new xa(Ao.CLOSE))}}),Object.defineProperty(i.prototype,"asrIsAvailable",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.getASRIsAvailable()}}),Object.defineProperty(i.prototype,"setEnableASR",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._invoker.push(new ja(e))}}),Object.defineProperty(i.prototype,"startRealtimeTranslation",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._invoker.push(new Ga(Ma.OPEN,e))}}),Object.defineProperty(i.prototype,"stopRealtimeTranslation",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._invoker.push(new Ga(Ma.CLOSE))}}),i}(e.EventEmitter),qa=function(e){function t(t,r){var i=e.call(this)||this;return Object.defineProperty(i,"data",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"cdnValues",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return r(t,e),Object.defineProperty(t.prototype,"kind",{get:function(){return Eo.MCUCONFIG_FLUSH},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i,n,o,a;return s(this,void 0,void 0,(function(){var r,s,u,l,d,_,p;return c(this,(function(c){switch(c.label){case 0:return r=e.context,s=e.service,u={"App-Key":r.getAppkey(),Token:t.getToken(),RoomId:t.roomId,UserId:r.getCurrentId(),SessionId:t.getSessionId()},[4,s.setMcuConfig(u,this.data)];case 1:return l=c.sent(),d=l.code,_=l.res,d!==exports.RCRTCCode.SUCCESS?[2,{code:d}]:(_.pull_url&&t.setCDNUris(JSON.parse(_.pull_url)),p=this.cdnValues,d===exports.RCRTCCode.SUCCESS&&((null===(n=null===(i=p.output)||void 0===i?void 0:i.video.normal)||void 0===n?void 0:n.width)||(null===(a=null===(o=p.output)||void 0===o?void 0:o.video.normal)||void 0===a?void 0:a.fps))&&ca(r,t),[2,{code:d,data:_}])}}))}))}}),t}(Po);exports.BackgroundPictureFillMode=void 0,(Ba=exports.BackgroundPictureFillMode||(exports.BackgroundPictureFillMode={}))[Ba.CROP=1]="CROP",Ba[Ba.WHOLE=2]="WHOLE",exports.MixLayoutMode=void 0,(Va=exports.MixLayoutMode||(exports.MixLayoutMode={}))[Va.CUSTOMIZE=1]="CUSTOMIZE",Va[Va.SUSPENSION=2]="SUSPENSION",Va[Va.ADAPTATION=3]="ADAPTATION",exports.MixVideoRenderMode=void 0,(Fa=exports.MixVideoRenderMode||(exports.MixVideoRenderMode={}))[Fa.CROP=1]="CROP",Fa[Fa.WHOLE=2]="WHOLE",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"}(Ja||(Ja={}));var Qa,Za=function(){return{version:2,mode:exports.MixLayoutMode.SUSPENSION}},Xa=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:Za()}),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(n.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,msg:"videoTrackId: ".concat(e," is invalid")})),this;var t=dt(e),r=t.mediaType,i=t.tag,a=t.userId;return r!==exports.RCMediaType.VIDEO_ONLY?(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,msg:"kind of ".concat(e," is not video")})),this):(this._values.host_stream_id=_t(a,i),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_HOST_VIDEO_TRACK_O,JSON.stringify({status:o.SUCCESSED,videoTrackId:e})),this)}}),Object.defineProperty(t.prototype,"setMixLayoutMode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return[exports.MixLayoutMode.CUSTOMIZE,exports.MixLayoutMode.SUSPENSION,exports.MixLayoutMode.ADAPTATION].includes(e)?(this._values.mode=e,this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:o.SUCCESSED,mode:e})),this):(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_MIX_LAYOUT_MODE_O,JSON.stringify({status:o.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 i=this._values.output||(this._values.output={video:{normal:{width:640,height:480}}});if("cdn"!==e)if("audio"!==e){var n=i.video;if("normal"!==r&&"tiny"!==r)if("backgroundColor"!==r)if("exparams"!==r){if("backgroundPicture"===r){var o=n.backgroundPicture||(n.backgroundPicture={fillMode:exports.BackgroundPictureFillMode.CROP,picture:[]});Object.assign(o,t)}}else n.exparams={renderMode:t};else n.backgroundColor=t;else{var a=n[r]||(n[r]={});Object.assign(a,t)}}else i.audio={bitrate:t};else i.cdn=t}}),Object.defineProperty(t.prototype,"setOutputVideoResolution",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!Rt(e))return this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:o.FAILED,msg:"params error -> resolution: ".concat(e)})),this;var t=bt(e),r=t.width,i=t.height;return this._addOutputValue("video",{width:r,height:i},"normal"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RESOLUTION_O,JSON.stringify({status:o.SUCCESSED,resolution:e})),this}}),Object.defineProperty(t.prototype,"setOutputVideoFPS",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!gt(e))return this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:o.FAILED,msg:"params error -> fps: ".concat(e)})),this;var t=mt(e);return this._addOutputValue("video",{fps:t},"normal"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_FPS_O,JSON.stringify({status:o.SUCCESSED,fps:e})),this}}),Object.defineProperty(t.prototype,"setOutputVideoBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return!e.isNumber(t)||t<=0?(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:o.FAILED,msg:"params error -> bitrate: ".concat(t)})),this):(this._addOutputValue("video",{bitrate:t},"normal"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_BITRATE_O,JSON.stringify({status:o.SUCCESSED,bitrate:t})),this)}}),Object.defineProperty(t.prototype,"setOutputTinyVideoResolution",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!Rt(e))return this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:o.FAILED,msg:"params error -> resolution: ".concat(e)})),this;var t=bt(e),r=t.width,i=t.height;return this._addOutputValue("video",{width:r,height:i},"tiny"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_RESOLUTION_O,JSON.stringify({status:o.SUCCESSED,resolution:e})),this}}),Object.defineProperty(t.prototype,"setOutputTinyVideoFPS",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!gt(e))return this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:o.FAILED,msg:"params error -> fps: ".concat(e)})),this;var t=mt(e);return this._addOutputValue("video",{fps:t},"tiny"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_FPS_O,JSON.stringify({status:o.SUCCESSED,fps:e})),this}}),Object.defineProperty(t.prototype,"setOutputTinyVideoBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return!e.isNumber(t)||t<=0?(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:o.FAILED,msg:"params error -> bitrate: ".concat(t)})),this):(this._addOutputValue("video",{bitrate:t},"tiny"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_TINY_VIDEO_BITRATE_O,JSON.stringify({status:o.SUCCESSED,bitrate:t})),this)}}),Object.defineProperty(t.prototype,"setOutputVideoRenderMode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return[exports.MixVideoRenderMode.CROP,exports.MixVideoRenderMode.WHOLE].includes(e)?(this._addOutputValue("video",e,"exparams"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:o.SUCCESSED,renderMode:e})),this):(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_VIDEO_RENDER_MODE_O,JSON.stringify({status:o.FAILED,msg:"params error -> renderMode: ".concat(e)})),this)}}),Object.defineProperty(t.prototype,"setOutputAudioBitrate",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.isNumber(t)&&t>0?(this._addOutputValue("audio",t),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:o.SUCCESSED,bitrate:t})),this):(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_AUDIO_BITRATE_O,JSON.stringify({status:o.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(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:o.SUCCESSED,color:e})),this):(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_COLOR_O,JSON.stringify({status:o.FAILED,msg:"params error -> color: ".concat(e)})),this)}}),Object.defineProperty(t.prototype,"addOutputBackgroundPicture",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,a,s){var c,u,l;if(!e.isHttpUrl(t))return this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:o.FAILED,msg:"params error -> uri: ".concat(t)})),this;if([r,i,a,s].some((function(t){return!e.isNumber(t)||t<0||t>1})))return this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:o.FAILED,msg:"params of (x, y, w, h) error -> x: ".concat(r,", y: ").concat(i,", w: ").concat(a,", h: ").concat(s)})),this;var d=(null===(l=null===(u=null===(c=this._values.output)||void 0===c?void 0:c.video)||void 0===u?void 0:u.backgroundPicture)||void 0===l?void 0:l.picture)||[];return d.push({uri:t,w:a,h:s,x:r,y:i}),this._addOutputValue("video",{picture:d},"backgroundPicture"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:o.SUCCESSED,uri:t,x:r,y:i,w:a,h:s})),this}}),Object.defineProperty(t.prototype,"removeOutputBackgroundPicture",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r,i,a;if(!e.isHttpUrl(t))return this._logger.error(n.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:o.FAILED,msg:"params error -> uri: ".concat(t)})),this;var s=null===(a=null===(i=null===(r=this._values.output)||void 0===r?void 0:r.video)||void 0===i?void 0:i.backgroundPicture)||void 0===a?void 0:a.picture;return s&&(s=s.filter((function(e){return e.uri!==t})),this._addOutputValue("video",{pictures:s},"backgroundPicture")),this._logger.info(n.L_MCU_CONFIG_BUILDER_REMOVE_OUTPUT_BACKGROUND_PICTURE_O,JSON.stringify({status:o.SUCCESSED,uri:t})),this}}),Object.defineProperty(t.prototype,"clearOutputBackgroundPicture",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._addOutputValue("video",{pictures:[]},"backgroundPicture"),this._logger.info(n.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[exports.BackgroundPictureFillMode.CROP,exports.BackgroundPictureFillMode.WHOLE].includes(e)?(this._addOutputValue("video",{fillMode:e},"backgroundPicture"),this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:o.SUCCESSED,fillMode:e})),this):(this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:o.FAILED,msg:"params error -> fillMode: ".concat(e)})),this)}}),Object.defineProperty(t.prototype,"addPublishStreamUrls",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r,i,a=/^rtmp:\/\/.+/;if(!e.isArray(t)||0===t.length||t.some((function(e){return!a.test(e)})))return this._logger.error(n.L_MCU_CONFIG_BUILDER_SET_OUTPUT_BACKGROUND_PICTURE_FILL_MODE_O,JSON.stringify({status:o.FAILED,msg:"params error -> urls: ".concat(t.join(","))})),this;var s=(null===(i=null===(r=this._values.output)||void 0===r?void 0:r.cdn)||void 0===i?void 0:i.concat())||[],c=!1;return t.forEach((function(e){s.some((function(t){return t.pushurl===e}))||(c=!0,s.push({pushurl:e}))})),s.length>5?(this._logger.error(n.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: ".concat(t.length)})),this):(c&&this._addOutputValue("cdn",s),this._logger.info(n.L_MCU_CONFIG_BUILDER_ADD_PUBLISH_STREAM_URLS_O,JSON.stringify({status:o.SUCCESSED,urls:t})),this)}}),Object.defineProperty(t.prototype,"removePublishStreamUrls",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r,i,a=/^rtmp:\/\/.+/;if(!e.isArray(t)||0===t.length||t.some((function(e){return!a.test(e)})))return this._logger.error(n.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:o.FAILED,msg:"params error -> urls: ".concat(t.join(","))})),this;for(var s=(null===(i=null===(r=this._values.output)||void 0===r?void 0:r.cdn)||void 0===i?void 0:i.concat())||[],c=s.length-1;c>=0;c-=1){var u=s[c].pushurl,l=t.indexOf(u);l>=0&&(t.splice(l,1),s.splice(c,1))}return this._addOutputValue("cdn",s),this._logger.info(n.L_MCU_CONFIG_BUILDER_REMOVE_PUBLISH_STREAM_URLS_O,JSON.stringify({status:o.SUCCESSED,urls:t})),this}}),Object.defineProperty(t.prototype,"clearPublishStreamUrls",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._addOutputValue("cdn",[]),this._logger.info(n.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,i,a,s){if(!e.notEmptyString(t)||!this._isValidTrackId(t))return this._logger.error(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.FAILED,msg:"params error -> trackId: ".concat(t)})),this;if(!e.isNumber(r)||!e.isNumber(i))return this._logger.error(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.FAILED,msg:"params x or y is error -> x: ".concat(r,", y: ").concat(i)})),this;if([a,s].some((function(t){return!e.isNumber(t)||t<0})))return this._logger.error(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.FAILED,msg:"params width or height error -> width: ".concat(a,", height: ").concat(s)})),this;var c=dt(t),u=c.userId,l=c.tag;if(c.mediaType!==exports.RCMediaType.VIDEO_ONLY)return this._logger.error(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.FAILED,msg:"type of trackId: ".concat(t," is not video")})),this;var d=_t(u,l),_=this._values.input||(this._values.input={}),p=_.video||(_.video=[]);return p.some((function(e){return e.height===s&&e.width===a&&e.stream_id===d&&e.user_id===u&&e.x===r&&e.y===i}))?(this._logger.warn(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.FAILED,msg:"Duplicate configuration item place ignored"})),this):(p.push({user_id:u,stream_id:d,x:r,y:i,width:a,height:s}),this._logger.info(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.SUCCESSED,trackId:t,x:r,y:i,width:a,height:s})),this)}}),Object.defineProperty(t.prototype,"removeCustomizeLayoutVideo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._isValidTrackId(e))return this._logger.error(n.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.FAILED,msg:"params error -> trackId: ".concat(e)})),this;var t=dt(e),r=t.userId,i=t.tag;if(t.mediaType!==exports.RCMediaType.VIDEO_ONLY)return this._logger.error(n.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.FAILED,msg:"type of trackId: ".concat(e," is not video")})),this;var a=_t(r,i),s=this._values.input;return(null==s?void 0:s.video)&&s.video.length>0&&(s.video=s.video.filter((function(e){return e.stream_id===a}))),this._logger.info(n.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_LAYOUT_VIDEO_O,JSON.stringify({status:o.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(n.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(n.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.FAILED,msg:"trackIds contain invalid item -> trackIds: ".concat(e.join(","))})),this):((this._values.input||(this._values.input={})).audio=e.map((function(e){var t=dt(e),r=t.userId,i=t.tag;return{stream_id:_t(r,i),user_id:r}})),this._values.inputFilterMode=Ja.AUDIO_INPUT_VIDEO_ALL,this._logger.info(n.L_MCU_CONFIG_BUILDER_SET_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.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(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.FAILED,msg:"params error -> trackId: ".concat(e)})),this;var t=this._values.input||(this._values.input={}),r=t.audio||(t.audio=[]),i=dt(e),a=i.userId,s=i.tag,c=_t(a,s);return r.some((function(e){return e.stream_id===c&&e.user_id===a}))?(this._logger.warn(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.FAILED,msg:"trackId: ".concat(e," is exist")})),this):(r.push({user_id:a,stream_id:c}),this._values.inputFilterMode=Ja.AUDIO_INPUT_VIDEO_ALL,this._logger.info(n.L_MCU_CONFIG_BUILDER_ADD_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.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(n.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.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(n.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.FAILED,msg:"type of trackId: ".concat(e," is not audio")})),this;var r=dt(e),i=r.userId,a=r.tag,s=_t(i,a);return t.audio=t.audio.filter((function(e){return i!==e.user_id||s!==e.stream_id})),this._logger.info(n.L_MCU_CONFIG_BUILDER_REMOVE_CUSTOMIZE_INPUT_AUDIO_O,JSON.stringify({status:o.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=Ja.AUDIO_VIDEO_ALL,this._logger.info(n.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,i,a,s,c){if(!this._isValidTrackId(t))return this._logger.error(n.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:o.FAILED,msg:"params error -> trackId: ".concat(t)})),this;if(!e.isHttpUrl(r))return this._logger.error(n.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:o.FAILED,msg:"params error -> uri: ".concat(r)})),this;if([i,a,s,c].some((function(t){return!e.isNumber(t)||t<0||t>1}))||i+s>1||a+c>1)return this._logger.error(n.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: ".concat(i,", y: ").concat(a,", w: ").concat(s,", h: ").concat(c)})),this;var u=dt(t),l=u.userId,d=u.tag,_=_t(l,d),p=(this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]})).singleScreen,f=p.filter((function(e){return e.streamId===_}))[0];return f?f.picture.push({uri:r,w:s,h:c,x:i,y:a}):p.push({streamId:_,picture:[{uri:r,w:s,h:c,x:i,y:a}]}),this._values.waterMark.singleScreen=p,this._logger.info(n.L_MCU_CONFIG_BUILDER_ADD_SINGLE_WATER_MARK_O,JSON.stringify({status:o.SUCCESSED,trackId:t,uri:r,x:i,y:a,w:s,h:c,singleScreen:p})),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(n.L_MCU_CONFIG_BUILDER_CLEAR_OUTPUT_BACKGROUND_PICTURE_O),this}}),Object.defineProperty(t.prototype,"removePictureWaterMark",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){if(!e.notEmptyString(t)||!this._isValidTrackId(t))return this._logger.error(n.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:o.FAILED,msg:"params error -> trackId: ".concat(t)})),this;var i=dt(t),a=i.userId,s=i.tag,c=_t(a,s);return(this._values.waterMark||(this._values.waterMark={enable:"on",singleScreen:[]})).singleScreen.forEach((function(e){e.streamId===c&&(e.picture=e.picture.filter((function(e){return e.uri!==r})))})),this._logger.info(n.L_MCU_CONFIG_BUILDER_REMOVE_SINGLE_WATER_MARK_O,JSON.stringify({status:o.SUCCESSED,trackId:t,uri:r})),this}}),Object.defineProperty(t.prototype,"reset",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._values=Za(),this._logger.info(n.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),s(this,void 0,void 0,(function(){var t,r;return c(this,(function(i){switch(i.label){case 0:return t=JSON.parse(JSON.stringify(this._values)),[4,this._invoker.push(new qa(t,this._values))];case 1:return r=i.sent().code,e&&(this._values=Za()),[2,{code:r}]}}))}))}}),Object.defineProperty(t.prototype,"__innerGetValues",{enumerable:!1,configurable:!0,writable:!0,value:function(){return JSON.parse(JSON.stringify(this._values))}}),t}();exports.RCLivingType=void 0,(Qa=exports.RCLivingType||(exports.RCLivingType={}))[Qa.VIDEO=0]="VIDEO",Qa[Qa.AUDIO=1]="AUDIO";var $a,es=function(e){function t(t,r,i){var n=e.call(this)||this;return Object.defineProperty(n,"roomId",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"roomPKHandler",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:i}),n}return r(t,e),Object.defineProperty(t.prototype,"_exchangeWithPushOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,a,s,u,l,d,_,p,f,h;return c(this,(function(c){switch(c.label){case 0:return i=e.logger,a=e.peer,s=e.context,a.getLocalTracks().length?(u=a,[4,oa(t.getSubscribedList(),!1,u,t,s)]):(i.info(n.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:o.SUCCESSED,msg:"have not published resource"}),this.traceId),[2]);case 1:return l=c.sent(),d=e.getPushOtherRooms(),l.pushOtherRooms=d,[4,new ta(l,this.traceId,!0).execute(e,t,r)];case 2:return(_=c.sent()).code!==exports.RCRTCCode.SUCCESS?(i.error(n.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:o.FAILED,code:_.code,pushOtherRooms:d}),this.traceId),[2]):(p=_.data.data,f=p.sdp,(h=p.resultCode)!==exports.RCRTCCode.SUCCESS?(i.error(n.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:o.FAILED,code:h,pushOtherRooms:d}),this.traceId),[2]):(i.info(n.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:o.SUCCESSED,pushOtherRooms:d}),this.traceId),u.setRemoteAnswer(f.sdp),[2]))}}))}))}}),Object.defineProperty(t.prototype,"kind",{get:function(){return Eo.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 s(this,void 0,void 0,(function(){var i,a;return c(this,(function(s){switch(s.label){case 0:return i=e.logger,a=this.roomId,i.info(n.L_EXCHANGE_WITH_PUSHOTHERROOM_T,a),this.roomPKHandler?this.roomPKHandler.getPKInfo(a)?[4,this._exchangeWithPushOtherRoom(e,t,r)]:(i.warn(n.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:o.FAILED,msg:"PKInfo not exist"}),this.traceId),[2,{code:exports.RCRTCCode.SUCCESS}]):(i.error(n.L_EXCHANGE_WITH_PUSHOTHERROOM_R,JSON.stringify({status:o.FAILED,msg:"_roomPKHandler not exist"}),this.traceId),[2,{code:exports.RCRTCCode.SUCCESS}]);case 1:return s.sent(),[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),t}(Po),ts=function(t){function i(e,r,i,n,o,a){var s=t.call(this)||this;return Object.defineProperty(s,"pkHandler",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(s,"room",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"_PKInfo",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(s,"_joinedPKRooms",{enumerable:!0,configurable:!0,writable:!0,value:n}),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(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return Eo.LEAVE_OTHER_ROOM},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"quitRoomPK",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,a){return s(this,void 0,void 0,(function(){var s,u,l,d,_,p,f,h,b,R;return c(this,(function(c){switch(c.label){case 0:return s=t.logger,u=t.context,s.info(n.L_QUIT_PK_T,"roomId: ".concat(r),a),this._PKInfo[r]?(l=this._PKInfo[r],d=l.inviterRoomId,_=l.inviteeRoomId,p=l.inviterUserId,f=l.inviteSessionId,h={inviteeRoomId:_,inviterRoomId:d,userId:i.crtUserId},b={roomId:i.roomId,endRoomId:r,sessionId:f,content:JSON.stringify(h),keys:["".concat(d,"|").concat(p)]},[4,u.endRoomPK(b)]):(s.warn(n.L_QUIT_PK_R,"status: ".concat(o.FAILED,", msg: pkinfo is empty"),a),[2]);case 1:return(R=c.sent())!==e.ErrorCode.SUCCESS?(s.error(n.L_QUIT_PK_R,"status: ".concat(o.FAILED,", code: ").concat(R),a),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(s.info(n.L_QUIT_PK_R,"status: ".concat(o.SUCCESSED),a),delete this._PKInfo[r],[2])}}))}))}}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return i=e.logger,s=(a=this).room,u=a.isQuitPK,l=s.getRoomId(),i.info(n.L_LIVING_ROOM_LEAVE_PK_ROOM_T,JSON.stringify({roomId:l,isQuitPK:u}),this.traceId),[4,s.__destroy(!0)];case 1:return c.sent(),delete this._joinedPKRooms[l],[4,new es(l,this.pkHandler,this.traceId).execute(e,t,r)];case 2:return c.sent(),u&&this.quitRoomPK(e,l,t,this.traceId),i.info(n.L_LIVING_ROOM_LEAVE_PK_ROOM_R,JSON.stringify({status:o.SUCCESSED}),this.traceId),[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),i}(Po),rs=function(){function t(e,t,r,i,n,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:i}),Object.defineProperty(this,"_service",{enumerable:!0,configurable:!0,writable:!0,value:n}),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(t.prototype,"_callAppListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var o=null===(t=this._appListener)||void 0===t?void 0:t[e];if(o)try{o.apply(void 0,d([],l(r),!1))}catch(e){this._logger.error(n.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify(e))}}}),Object.defineProperty(t.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.inviteInfo||{},r=t.inviterRoomId,i={inviterRoomId:r,inviterUserId:t.inviterUserId,extra:t.extra};this._PKInfo[r]=t,this._logger.info(n.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onRequestJoinOtherRoom",info:i})),this._callAppListener("onRequestJoinOtherRoom",i)}}),Object.defineProperty(t.prototype,"_onCancelInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.inviteInfo||{},r=t.inviterRoomId,i={inviterRoomId:r,inviterUserId:t.inviterUserId,extra:t.extra};delete this._PKInfo[r],this._logger.info(n.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onCancelRequestOtherRoom",cancelInfo:i})),this._callAppListener("onCancelRequestOtherRoom",i)}}),Object.defineProperty(t.prototype,"_onInviteTimeout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){}}),Object.defineProperty(t.prototype,"_onInviteAnswer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.answerCode,r=e.inviteContent,i=r.inviteSessionId,o=r.inviterUserId,a=r.inviterRoomId,s=r.inviteeUserId,c=r.inviterUserAutoMix,u=r.inviteeUserAutoMix,l=r.inviteeRoomId,d={agree:1===t,inviterRoomId:a,inviterUserId:o,inviteeRoomId:l,inviteeUserId:s,extra:r.extra};this._PKInfo[l]=this._PKInfo[l]||{inviteSessionId:i,inviterRoomId:a,inviterUserId:o,inviterUserAutoMix:c,inviteeRoomId:l},this._PKInfo[l].inviteeUserAutoMix=u,this._logger.info(n.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onResponseJoinOtherRoom",answerInfo:d})),this._callAppListener("onResponseJoinOtherRoom",d)}}),Object.defineProperty(t.prototype,"createLeaveOtherRoomCommand",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return new ts(this,e,this._PKInfo,this._joinedPKRooms,t,r)}}),Object.defineProperty(t.prototype,"_onPKEnd",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t,r,i,o,a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return t=e.inviteInfo,r=t.inviteeRoomId,i=t.inviterRoomId,o=t.userId,a=i===this._mainRoomId?r:i,s={endRoomId:a,endUserId:o},u=this._joinedPKRooms[a],l=this._logger.createTraceId(),this._logger.info(n.L_QUIT_PK_LEAVE_PK_ROOM_O,void 0,l),u?[4,this._invoker.push(this.createLeaveOtherRoomCommand(u,!0,l))]:[3,2];case 1:c.sent(),c.label=2;case 2:return delete this._PKInfo[a],this._logger.info(n.L_LIVING_PK_HANDLER_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onFinishOtherRoom",endInfo:s})),this._callAppListener("onFinishOtherRoom",s),[2]}}))}))}}),Object.defineProperty(t.prototype,"_onRecvPKMsg",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.content;switch(e.messageType){case Tt.PK_INVITE:this._onInvite(t);break;case Tt.PK_CANCEL_INVITE:this._onCancelInvite(t);break;case Tt.PK_INVITE_TIMEOUT:this._onInviteTimeout(t);break;case Tt.PK_INVITE_ANSWER:this._onInviteAnswer(t);break;case Tt.PK_END:this._onPKEnd(t)}}}),Object.defineProperty(t.prototype,"registerRoomPKEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(n.L_LIVING_PK_HANDLER_REGISTER_ROOM_PK_EVENT_LISTENER_O,JSON.stringify({listener:e&&Object.keys(e)})),this._appListener=e}}),Object.defineProperty(t.prototype,"requestJoinOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var a,s,u,l,d,_;return c(this,(function(c){switch(c.label){case 0:return a=this._logger.createTraceId(),this._logger.info(n.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:t,inviteeUserId:r,options:i}),a),e.validate("inviteeRoomId",t,e.notEmptyString,!0)&&e.validate("inviteeUserId",r,e.notEmptyString,!0)?(s=Wn(),u=!e.isBoolean(null==i?void 0:i.autoMix)||(null==i?void 0:i.autoMix),l={inviteSessionId:s,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:u,inviteeRoomId:t,inviteeUserId:r,inviteeTimeoutTime:this._inviteTimeout,extra:(null==i?void 0:i.extra)||""},d={roomId:this._mainRoomId,invitedRoomId:t,invitedUserId:r,inviteTimeout:this._inviteTimeout,inviteInfo:JSON.stringify(l),inviteSessionId:s},[4,this._context.requestRoomPK(d)]):(this._logger.error(n.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),a),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return(_=c.sent())!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:_}),a),[2,{code:_}]):(this._PKInfo[t]={inviteSessionId:s,inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviterUserAutoMix:u,inviteeRoomId:t},this._logger.info(n.L_LIVING_PK_HANDLER_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.SUCCESSED}),a),[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),Object.defineProperty(t.prototype,"cancelRequestJoinOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return a=this._logger.createTraceId(),this._logger.info(n.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_T,JSON.stringify({inviteeRoomId:t,inviteeUserId:r,extra:i}),a),e.validate("inviteeRoomId",t,e.notEmptyString,!0)&&e.validate("inviteeUserId",r,e.notEmptyString,!0)?this._PKInfo[t]?(s={inviterRoomId:this._mainRoomId,inviterUserId:this._context.getCurrentId(),inviteeRoomId:t,inviteeUserId:r,extra:i||""},u={roomId:this._mainRoomId,invitedRoomId:t,invitedUserId:r,inviteSessionId:this._PKInfo[t].inviteSessionId,inviteInfo:JSON.stringify(s)},[4,this._context.cancelRoomPK(u)]):(this._logger.error(n.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"The request to connect with ".concat(r," user in room ").concat(t," is not initiated")}),a),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(this._logger.error(n.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> inviteeRoomId or inviteeUserId"}),a),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return(l=c.sent())!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:l}),a),[2,{code:l}]):(this._logger.info(n.L_LIVING_PK_HANDLER_CANCEL_REQUEST_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.SUCCESSED}),a),delete this._PKInfo[t],[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),Object.defineProperty(t.prototype,"responseJoinOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,a){return s(this,void 0,void 0,(function(){var s,u,l,d,_,p,f,h,b,R;return c(this,(function(c){switch(c.label){case 0:return s=this._logger.createTraceId(),this._logger.info(n.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_T,JSON.stringify({inviterRoomId:t,inviterUserId:r,agree:i,options:a}),s),e.validate("inviterRoomId",t,e.notEmptyString,!0)&&e.validate("inviterUserId",r,e.notEmptyString,!0)?this._PKInfo[t]?(u=this._PKInfo[t],l=u.inviteSessionId,d=u.inviterUserAutoMix,_=!e.isBoolean(null==a?void 0:a.autoMix)||(null==a?void 0:a.autoMix),p={inviteSessionId:l,inviterRoomId:t,inviterUserId:r,inviterUserAutoMix:d,inviteeRoomId:this._mainRoomId,inviteeUserId:this._context.getCurrentId(),inviteeUserAutoMix:_},f=Object.assign(p,{inviterUserAutoMix:d}),h=i?Object.assign(p,{MultiRoomKey:"".concat(t,"|").concat(this._mainRoomId),MultiRoomValue:JSON.stringify(f)}):p,!e.isUndefined(null==a?void 0:a.extra)&&Object.assign(h,{extra:a.extra}),b={agree:i,roomId:this._mainRoomId,inviteSessionId:l,inviteRoomId:t,inviteUserId:r,content:JSON.stringify(h),key:"".concat(t,"|").concat(this._mainRoomId),value:JSON.stringify(p)},[4,this._context.responseRoomPK(b)]):(this._logger.error(n.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"User ".concat(r," in room ").concat(t," did not send a request for connection")}),s),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(this._logger.error(n.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> inviterRoomId or inviterUserId"}),s),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return(R=c.sent())!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:R}),s),[2,{code:R}]):(this._logger.info(n.L_LIVING_PK_HANDLER_RESPONSE_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.SUCCESSED}),s),this._PKInfo[t].inviteeUserAutoMix=_,[2,{code:exports.RCRTCCode.SUCCESS}])}}))}))}}),Object.defineProperty(t.prototype,"joinOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,a,s,u;return c(this,(function(c){switch(c.label){case 0:return r=this._logger.createTraceId(),this._logger.info(n.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_T,JSON.stringify({roomId:t}),r),e.validate("roomId",t,e.notEmptyString,!0)?this._context.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED?(this._logger.error(n.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.SIGNAL_DISCONNECTED,msg:"IM disconnected"}),r),[2,{code:exports.RCRTCCode.SIGNAL_DISCONNECTED}]):this._joinedPKRooms[t]?(this._logger.warn(n.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),r),[2,{code:exports.RCRTCCode.REPERT_JOIN_ROOM}]):(i=exports.RCLivingType.VIDEO,a={extra:'{"roomId": "'.concat(this._mainRoomId,'"}')},[4,(s=new cs(this._context,this._runtime,t,this._service,this._initOptions,i,!1,!1,this._clientSessionId)).__innerInit(exports.RTCMode.LIVE,void 0,i,a)]):(this._logger.error(n.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> roomId"}),r),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return(u=c.sent().code)!==exports.RCRTCCode.SUCCESS?(this._logger.error(n.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.FAILED,code:u}),r),[2,{code:u}]):(this._joinedPKRooms[t]=s,[4,this._onJoinedPKRoom(t,r)]);case 2:return c.sent(),this._logger.info(n.L_LIVING_PK_HANDLER_JOIN_OTHER_ROOM_R,JSON.stringify({status:o.SUCCESSED}),r),[2,{room:s,code:exports.RCRTCCode.SUCCESS,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()}]}}))}))}}),Object.defineProperty(t.prototype,"leaveOtherRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r;return c(this,(function(i){return r=this._logger.createTraceId(),this._logger.info(n.L_APP_CALL_LEAVE_PK_ROOM_O,void 0,r),[2,this._invoker.push(this.createLeaveOtherRoomCommand(e,t,r))]}))}))}}),Object.defineProperty(t.prototype,"getPKInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._PKInfo[e]}}),Object.defineProperty(t.prototype,"getAllPKInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._PKInfo}}),Object.defineProperty(t.prototype,"getJoinedPKRooms",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._joinedPKRooms}}),t}();!function(e){e[e.OPEN=1]="OPEN",e[e.STOP=2]="STOP"}($a||($a={}));var is,ns=function(t){function i(e,r){var i=t.call(this)||this;return Object.defineProperty(i,"cdnValues",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(i,"enable",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return Eo.ENABLE_INNER_CDN},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var a,s,u,l,d,_,p;return c(this,(function(c){switch(c.label){case 0:return a=t.logger,s=t.context,u=this.enable,a.info(n.L_LIVING_ROOM_ENABLE_INNER_CDN_T,JSON.stringify({roomId:r.roomId,enable:u})),r.isMainRoom?e.isBoolean(u)?(r.setCDNEnabel(u),l={version:2,output:{inCDNModel:u?$a.OPEN:$a.STOP}},[4,new qa(l,this.cdnValues).execute(t,r,i)]):(a.error(n.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> enable"})),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(a.error(n.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),[2,{code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM}]);case 1:return(d=c.sent().code)!==exports.RCRTCCode.SUCCESS?(a.error(n.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:o.FAILED,code:d,msg:"signal error"})),[2,{code:exports.RCRTCCode.SIGNAL_ERROR}]):(_=r.getCDNUris())&&_.broadcast!==Fo.SPREAD?(a.info(n.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:o.SUCCESSED,enable:u})),[2,{code:exports.RCRTCCode.SUCCESS}]):[4,ca(s,r)];case 2:return(p=c.sent().code)===exports.RCRTCCode.SUCCESS?(a.info(n.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:o.SUCCESSED,enable:u})),[2,{code:exports.RCRTCCode.SUCCESS}]):(a.error(n.L_LIVING_ROOM_ENABLE_INNER_CDN_R,JSON.stringify({status:o.FAILED,code:p})),[2,{code:p}])}}))}))}}),i}(Po);!function(e){e[e.AnchorToViewer=1]="AnchorToViewer",e[e.ViewerToAnchor=2]="ViewerToAnchor"}(is||(is={}));var os,as,ss=function(t){function i(e,r){var i=t.call(this)||this;return Object.defineProperty(i,"livingType",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(i,"traceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return r(i,t),Object.defineProperty(i.prototype,"kind",{get:function(){return Eo.RTC_IDENTITY_CHANGE},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"execute",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){var n;return s(this,void 0,void 0,(function(){var o,a,s,u;return c(this,(function(c){switch(c.label){case 0:return[4,t.context.rtcIdentityChange(r.roomId,is.ViewerToAnchor,this.livingType)];case 1:return o=c.sent(),a=o.code,s=o.data,a===e.ErrorCode.SUCCESS&&s?(r.initWithRoomData(s,this.traceId),r.getResourcesByUserId(r.crtUserId).length>0&&i.push(new Mo),(u=null===(n=s.roomInfo.filter((function(e){return"cdn_uris"===e.key}))[0])||void 0===n?void 0:n.value)&&r.setCDNUris(JSON.parse(u)[0]),[2,{code:a,data:s}]):[2,{code:a}]}}))}))}}),i}(Po),cs=function(t){function i(e,r,i,n,o,a,s,c,u){var l=t.call(this,e,r,i,exports.RTCMode.LIVE,n,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 Xa(l._executeCtx,l._invoker,l._isValidResourceId.bind(l)),l}return r(i,t),Object.defineProperty(i.prototype,"_initRoomPKHandler",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this._store.isMainRoom){var r=(i=this._roomId,n=e.roomInfo,o={},n.forEach((function(e){var t=JSON.parse(e.value),r=t.inviterRoomId,n=t.inviteeRoomId;o[i===r?n:r]=JSON.parse(e.value)})),o);this._roomPKHandler=new rs(this._invoker,r,this._context,this._runtime,this._service,this._initOptions,this,t.prototype._registerPKMsgListener.bind(this),this._onJoinedPKRoom.bind(this),this._clientSessionId)}var i,n,o}}),Object.defineProperty(i.prototype,"__innerInit",{enumerable:!1,configurable:!0,writable:!0,value:function(r,i,a,u,l,d){return s(this,void 0,void 0,(function(){var s,_,p;return c(this,(function(c){switch(c.label){case 0:return e.validate("livingType",a,(function(e){return e===exports.RCLivingType.AUDIO||e===exports.RCLivingType.VIDEO}))?[4,t.prototype.__innerInit.call(this,r,i,a,u,l,d)]:(this._logger.error(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> livingType"}),d),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return s=c.sent(),_=s.code,p=s.data,_===exports.RCRTCCode.SUCCESS&&p&&this._initRoomPKHandler(p),[2,{code:_,data:p}]}}))}))}}),Object.defineProperty(i.prototype,"__innerInitByIdentityChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,a;return c(this,(function(s){switch(s.label){case 0:return[4,this._invoker.push(new ss(this._livingType,t))];case 1:return r=s.sent(),i=r.code,a=r.data,i===e.ErrorCode.SUCCESS&&a?(this._initRoomPKHandler(a),this._initWithRoomData(a.offlineKickTime),this._logger.info(n.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:o.SUCCESSED,roomData:a}),t)):this._logger.error(n.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:o.FAILED,code:i}),t),[2,i]}}))}))}}),Object.defineProperty(i.prototype,"publish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(r){return this._store.isMainRoom?[2,t.prototype.publish.call(this,e)]:(this._logger.error(n.L_ABSTRACT_ROOM_PUBLISH_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),[2,{code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM}])}))}))}}),Object.defineProperty(i.prototype,"unpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(r){return this._store.isMainRoom?[2,t.prototype.unpublish.call(this,e)]:(this._logger.error(n.L_ABSTRACT_ROOM_UNPUBLISH_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),[2,{code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM}])}))}))}}),Object.defineProperty(i.prototype,"_isValidResourceId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,i=dt(e).userId,n=!!(null===(t=this._store.getResourcesByUserId(i))||void 0===t?void 0:t.find((function(t){return lt(t)===e}))),o=this.getRoomPKHandler(),a=o.code,s=o.roomPKHandler;if(a!==exports.RCRTCCode.SUCCESS||!s)return n;var c=s.getJoinedPKRooms(),u=[];return Object.values(c).forEach((function(e){u.push.apply(u,d([],l(e.getRemoteTracks()),!1))})),r=u.some((function(t){return e===t.getTrackId()})),n||r}}),Object.defineProperty(i.prototype,"getLivingType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._livingType}}),Object.defineProperty(i.prototype,"getMCUConfigBuilder",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.isMainRoom?this._mcuConfigBuilder:(this._logger.error(n.L_LIVING_ROOM_GET_MCU_CONFIG_BUILDER_O,"the `getMCUConfigBuilder` is disabled in PK room"),{code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}}),Object.defineProperty(i.prototype,"enableInnerCDN",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this._invoker.push(new ns(this._mcuConfigBuilder.__innerGetValues(),e))]}))}))}}),Object.defineProperty(i.prototype,"_resourceHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i,n,o){return s(this,void 0,void 0,(function(){return c(this,(function(a){return t.prototype._resourceHandle.call(this,e,r,i,n,o),[2]}))}))}}),Object.defineProperty(i.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(i.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(i.prototype,"_onJoinedPKRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){return c(this,(function(r){return this._invoker.push(new es(e,this._roomPKHandler,t)),[2]}))}))}}),Object.defineProperty(i.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 i=t[r].getSessionId(),n=this._roomPKHandler.getPKInfo(r);if(n){var o=n.inviterUserAutoMix,a=n.inviteeUserAutoMix,s=n.inviterUserId,c=this._context.getCurrentId()===s;e.push({roomId:r,sessionId:i,autoMix:c?!!o:!!a})}}return e}}),Object.defineProperty(i.prototype,"getRoomPKHandler",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.isMainRoom?(this._logger.info(n.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:o.SUCCESSED})),{code:exports.RCRTCCode.SUCCESS,roomPKHandler:this._roomPKHandler}):(this._logger.error(n.L_LIVING_ROOM_GET_ROOM_PK_HANDLER_O,JSON.stringify({status:o.SUCCESSED,code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"method not available in PK room"})),{code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM})}}),Object.defineProperty(i.prototype,"_quitAllPKRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var e,t;return c(this,(function(r){for(t in e=this._roomPKHandler.getJoinedPKRooms())this._roomPKHandler.leaveOtherRoom(e[t]);return this._logger.info(n.L_LIVING_ROOM_QUIT_ALL_PK_ROOM_O,JSON.stringify({status:o.SUCCESSED,roomIds:Object.keys(e)})),[2]}))}))}}),Object.defineProperty(i.prototype,"isMainRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._store.isMainRoom}}),i}(za),us=function(e){function t(t,r,i,n,o,a,s){return void 0===a&&(a=exports.RTCMode.RTC),void 0===s&&(s=!1),e.call(this,t,r,i,a,n,o,!1,!1,Wn(),s)||this}return r(t,e),t}(za),ls=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 s(this,void 0,void 0,(function(){var e,t,r,i,n,o;return c(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,i=e.reject,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,r()];case 2:return n=a.sent(),t(n),[3,4];case 3:return o=a.sent(),i(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,i=new Promise((function(t,i){r.queue.push({resolve:t,task:e,reject:i})}));return this.checkToStart(),i}}),e}(),ds=new ls,_s=function(e,t){return void 0===t&&(t=""),ds.push(e,t)},ps=function(){function t(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:Wn()}),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 Zn(t,e,r.mediaServer),this._logger=this._context.logger,this._store=new Uo(this._logger,this._clientSessionId,this._context.getAppkey(),this._crtUserId,this._crtUserId,exports.RTCMode.LIVE)}return Object.defineProperty(t.prototype,"_getReqHeaders",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,n,o;return c(this,(function(a){switch(a.label){case 0:return r=this._crtUserId,this._rtcToken?[3,2]:[4,this._context.getRTCToken(r,exports.RTCMode.LIVE,t)];case 1:if(i=a.sent(),n=i.code,o=i.data,n!==e.ErrorCode.SUCCESS)return[2,{code:exports.RCRTCCode.SIGNAL_ERROR}];this._rtcToken=o.rtcToken,a.label=2;case 2:return[2,{code:exports.RCRTCCode.SUCCESS,headers:{"App-Key":this._context.getAppkey(),UserId:this._crtUserId,RoomId:r,RoomType:exports.RTCMode.LIVE,Token:this._rtcToken,"Client-Session-Id":this._clientSessionId}}]}}))}))}}),Object.defineProperty(t.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(t.prototype,"_reTryExchange",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return s(this,void 0,void 0,(function(){var t;return c(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)===exports.RCRTCCode.SUCCESS&&(null===(e=this._pc)||void 0===e||e.clearReTryExchangeTimer()),[2,{code:t}]}}))}))}}),Object.defineProperty(t.prototype,"subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){return void 0===i&&(i=!1),s(this,void 0,void 0,(function(){var n=this;return c(this,(function(o){return[2,_s((function(){return n.__subscribe(e,t,r,i)}),"audience-client-sub")]}))}))}}),Object.defineProperty(t.prototype,"__subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,a){var u;return void 0===a&&(a=!1),s(this,void 0,void 0,(function(){var s,l,d,_,p,f,h,b,R,g,m,C,v,O=this;return c(this,(function(c){switch(c.label){case 0:return this._logger.info(n.L_AUDIENCE_CLIENT_SUBSCRIBE_T,JSON.stringify({liveUrl:t,livingType:r,mediaType:i,subTiny:a})),s=[],It(this._context.getNaviInfo())?(this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"})),[2,{code:exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR,tracks:s}]):(!this._fromRetry&&(null===(u=this._pc)||void 0===u||u.clearReTryExchangeTimer()),this._fromRetry=!1,e.isString(t)?[exports.RCLivingType.AUDIO,exports.RCLivingType.VIDEO].includes(r)?[exports.RCMediaType.AUDIO_ONLY,exports.RCMediaType.VIDEO_ONLY,exports.RCMediaType.AUDIO_VIDEO].includes(i)?this._liveUrl&&this._liveUrl!==t?(this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.BROADCAST_SUB_LIST_NOT_EMPTY,msg:"repeat subscribe"})),[2,{code:exports.RCRTCCode.BROADCAST_SUB_LIST_NOT_EMPTY,tracks:s}]):(this._pc||(this._pc=new yo(this._context,this._logger,this._reTryExchange.bind(this),this._crtUserId,this._store,void 0,!1),this._pc.on(yo.__INNER_EVENT_TRACK_READY__,this._onTrackReady,this),this._pc.registerReportListener(this._reportListener),this._pc.__reportR3R4ToPolaris()),this._liveUrl=t,[4,this._getReqHeaders(r)]):(this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> -> mediaType: ".concat(i)})),[2,{code:exports.RCRTCCode.PARAMS_ERROR,tracks:s}]):(this._logger.error("livingType is invalid: ".concat(r)),this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> livingType: ".concat(r)})),[2,{code:exports.RCRTCCode.PARAMS_ERROR,tracks:s}]):(this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> liveUrl: ".concat(t)})),[2,{code:exports.RCRTCCode.PARAMS_ERROR,tracks:s}]));case 1:return l=c.sent(),d=l.code,_=l.headers,d!==exports.RCRTCCode.SUCCESS?(this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:d,msg:"getRTCToken failed"})),[2,{code:d,tracks:s}]):(p="rc_mcu_".concat(Date.now()),f="RongCloudRTC",0===this._subTracks.length&&(this._subTracks.push(new rt(this._logger,f,p),new it(this._logger,f,p)),this._pc.updateSubRemoteTracks(this._subTracks.slice())),[4,this._pc.createOffer(!0)]);case 2:return h=c.sent(),b={sdp:h,liveUrl:t,mediaType:i,simulcast:a?Gn.TINY:Gn.NORMAL,switchstream:!1},[4,this._service.broadcastSubscribe(_,b)];case 3:return(R=c.sent()).code!==exports.RCRTCCode.SUCCESS?(this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:R.code})),[2,{code:R.code,tracks:s}]):(g=R.data).resultCode!==exports.RCRTCCode.SUCCESS?(this._logger.error(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:g.resultCode,msg:g.message})),[2,{code:g.resultCode,tracks:s}]):(this._livingType=r,this._mediaType=i,this._subTiny=a,m=g.sdp,C=g.subscribedList,this._subscribedList=C,v=[],C.forEach((function(e){var t=e.mediaType,r=O._subTracks[t];v.push(r),r.__innerSetRemoteMuted(!0)})),this._pc.setRemoteAnswer(m.sdp),v&&this._updateTrackIdSSRCMap(m.sdp,v),this._logger.info(n.L_AUDIENCE_CLIENT_SUBSCRIBE_R,JSON.stringify({status:o.SUCCESSED,liveUrl:t})),[2,{code:exports.RCRTCCode.SUCCESS,tracks:v}])}}))}))}}),Object.defineProperty(t.prototype,"_updateTrackIdSSRCMap",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this;t.forEach((function(t){var i=t.getTrackId(),n=dt(i).mediaType,o=r._subscribedList.filter((function(e){return e.mediaType===n}))[0].msid,a=pa(e,o,n);r._store.setTrackIdSSRCMap(Number(a),i)}))}}),Object.defineProperty(t.prototype,"unsubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var e=this;return c(this,(function(t){return[2,_s((function(){return e.__unsubscribe()}),"audience-client-unsub")]}))}))}}),Object.defineProperty(t.prototype,"__unsubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return s(this,void 0,void 0,(function(){var t,r;return c(this,(function(i){switch(i.label){case 0:return this._logger.info(n.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(n.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:"",msg:"Address does not exist, without unsubscribe"})),[2,{code:exports.RCRTCCode.SUCCESS}]);case 1:return t=i.sent().headers,[4,this._service.broadcastExit(t)];case 2:return(r=i.sent().code)!==exports.RCRTCCode.SUCCESS?this._logger.error(n.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:r})):(this._logger.info(n.L_AUDIENCE_CLIENT_UNSUBSCRIBE_R,JSON.stringify({status:o.SUCCESSED,liveUrl:this._liveUrl})),this._subscribedList=[]),this._clearSubscribeInfo(),[2,{code:r}]}}))}))}}),Object.defineProperty(t.prototype,"registerReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._reportListener=e}}),Object.defineProperty(t.prototype,"registerTrackEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._appListener=e}}),Object.defineProperty(t.prototype,"_onTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,i=e.receiver.track,o="audio"===i.kind?exports.RCMediaType.AUDIO_ONLY:exports.RCMediaType.VIDEO_ONLY,a=this._subTracks[o];a.__innerSetMediaStreamTrack(i);try{this._logger.info(n.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,"trackId: ".concat(a.getTrackId())),null===(r=null===(t=this._appListener)||void 0===t?void 0:t.onTrackReady)||void 0===r||r.call(t,a)}catch(e){this._logger.error(n.L_AUDIENCE_CLIENT_CALL_ONTRACKREADY_O,JSON.stringify(e))}}}),t}();exports.RCInnerCDNPullKind=void 0,(os=exports.RCInnerCDNPullKind||(exports.RCInnerCDNPullKind={})).RTMP="rtmp",os.FLV="flv",os.HLS="hls",exports.RCInnerCDNPullIsHttps=void 0,(as=exports.RCInnerCDNPullIsHttps||(exports.RCInnerCDNPullIsHttps={}))[as.NOT_HTTPS=0]="NOT_HTTPS",as[as.HTTPS=1]="HTTPS";var fs,hs=a(a({},bt(exports.RCResolution.W176_H144)),{frameRate:mt(exports.RCFrameRate.FPS_15)}),bs=function(){function t(e,t,r,i,n,o,a){void 0===a&&(a=Wn());var u=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:i}),Object.defineProperty(this,"_joinResData",{enumerable:!0,configurable:!0,writable:!0,value:n}),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 ka(this._context,this._runtime,this._roomId,this,Aa.Audience),this._reportMediaActionLogger=new wa(this._logger,this._roomId,this._clientSessionId,this._crtUserId),this._service=new Zn(this._runtime,this._context,this._initOptions.mediaServer,this._initOptions.timeout);var l=this._store=new Uo(this._logger,a,e.getAppkey(),i,this._crtUserId,exports.RTCMode.LIVE),d=this._pc=new yo(this._context,this._logger,this._reTryExchange.bind(this),this._crtUserId,l,this._polarisReport,!0);this._audioLevelReport=new Lo(this._store,d),d.on(yo.__INNER_AUDIOLEVEL_CHANGE__,this._audioLevelReport.audioLevelReport,this._audioLevelReport),this._polarisReport.sendR1(),this._context.registerRTCSignalListener((function(e){return s(u,void 0,void 0,(function(){var t,r,i,n;return c(this,(function(o){return t=this._context.decodeRtcNotify(e),r=t.time,i=t.type,n=t.roomId,1===i&&this._startPull(n,r),[2]}))}))})),this._setInitData()}return Object.defineProperty(t.prototype,"_startPull",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return s(this,void 0,void 0,(function(){var i,a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return this._isPulling?[2]:(this._isPulling=!0,this._pullTime>r?(this._isPulling=!1,[2]):(i=this._logger.createTraceId(),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_T,"pullTime: ".concat(this._pullTime),i),[4,this._context.pullRTCRoomEntry(t)]));case 1:return a=c.sent(),s=a.code,u=a.data,s===e.ErrorCode.SUCCESS&&(this._isPulling=!1,this._pullTime=(null==u?void 0:u.syncTime)||0,l=(null==u?void 0:u.kvEntries)||[],this._logger.info(n.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,"status: ".concat(o.SUCCESSED,", kvEntries: ").concat(JSON.stringify(l)),i),this.singalDataChange(l,t,i)),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_PULL_KVENTRIES_R,"status: ".concat(o.FAILED,", code: ").concat(s),i),[2]}}))}))}}),Object.defineProperty(t.prototype,"_setInitData",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=function(e,t,r){var i=t.filter((function(e){return"RC_RTC_SESSIONID"===e.key}))[0],n=i?i.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 i=t.mediaType,n=t.tag,o=i===exports.RCMediaType.AUDIO_ONLY?new rt(r,n,"",e):new it(r,n,"",e);c.push(o)}));var u=[],_=[];a.forEach((function(e){var t=JSON.parse(e.uris||"[]");u.push.apply(u,d([],l(t),!1)),t.forEach((function(e){var t=e.mediaType,i=e.tag,n=e.msid.split("_");n.pop();var o=n.join("_"),a=t===exports.RCMediaType.AUDIO_ONLY?new rt(r,i,o):new it(r,i,o);_.push(a)}))}));var p=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:n,remoteUserIds:o||[],remoteRTCUris:u,remoteMUCUris:s,remoteRTCTracks:_,remoteMCUTracks:c,remoteTracks:d(d([],l(_),!1),l(c),!1),CDNUris:p||{}}}(this._roomId,this._joinResData.kvEntries,this._logger),r=t.sessionId,i=t.remoteUserIds,n=t.remoteRTCUris,o=t.remoteMUCUris,a=t.remoteTracks,s=t.CDNUris;this._sessionId=r,this._roomAnchorList=i,a.forEach((function(t){e._remoteTracks[t.getTrackId()]=t})),this._CDNUris=s,n.forEach((function(t){var r=t.msid.split("_")[0];e._roomAnchorRes[r]?e._roomAnchorRes[r].push(t):e._roomAnchorRes[r]=[t];var i=JSON.parse(t.uri),n=i.ssrc,o=i.resourceId;e._store.setTrackIdSSRCMap(n,o)})),o.forEach((function(t){var r=t.mediaType,i=t.tag,n=[e._roomId,i,r].join("_");e._roomRes[n]=t;var o=JSON.parse(t.uri).ssrc;e._store.setTrackIdSSRCMap(o,n)})),n.forEach((function(t){var r=lt(t);e._roomRes[r]=t}))}}),Object.defineProperty(t.prototype,"_assertRoomDestroyed",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this._destroyed)return exports.RCRTCCode.ROOM_HAS_BEEN_DESTROYED}}),Object.defineProperty(t.prototype,"singalDataChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i,a=this;if(t===this._roomId){var s=[],c=null===(i=e.filter((function(e){return"RC_CDN"===e.key}))[0])||void 0===i?void 0:i.value;c&&this._diffCDNUris(JSON.parse(JSON.parse(c).cdn_uris)[0],r),e.forEach((function(e){var t=e.key,i=e.value,n=e.uid;if(-1!==t.indexOf("RC_RES_")){var o=JSON.parse(i||"{}"),c=JSON.parse(o.mcu_uris||"[]"),u=JSON.parse(o.uris||"[]");return s.push.apply(s,d([],l(c),!1)),void a._diffAnchorResource(u,n,r)}if("RC_ANCHOR_LIST"===t){var _=JSON.parse(i||"[]");a._diffAnchorList(_,r)}})),this._diffRoomResource(s,r)}else this._logger.error(n.L_AUDIENCE_LIVING_ROOM_SINGAL_DATA_CHANGE_P,JSON.stringify({status:o.FAILED,msg:"roomId inconsistency -> params roomId:".concat(t,", current roomId:").concat(this._roomId)}),r)}}),Object.defineProperty(t.prototype,"_diffAnchorList",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,i=e.filter((function(e){return r._roomAnchorList.indexOf(e)<0})),n=this._roomAnchorList.filter((function(t){return e.indexOf(t)<0}));i.length>0&&this._handleNewJoinedAnchor(i,t),n.length>0&&this._handleLeftedAnchor(n,t)}}),Object.defineProperty(t.prototype,"_handleNewJoinedAnchor",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;(r=this._roomAnchorList).push.apply(r,d([],l(e),!1)),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorJoin",list:e}),t),this._callAppListener("onAnchorJoin",e)}}),Object.defineProperty(t.prototype,"_handleLeftedAnchor",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i=this;return c(this,(function(o){switch(o.label){case 0:return this._roomAnchorList=this._roomAnchorList.filter((function(t){return!e.includes(t)})),r=[],e.forEach((function(e){r.push.apply(r,d([],l(i.getRemoteTracksByUserId(e)),!1)),delete i._roomAnchorRes[e]})),r.length?[4,this.unsubscribe(r)]:[3,2];case 1:o.sent(),r.forEach((function(e){return delete i._remoteTracks[e.getTrackId()]})),o.label=2;case 2:return this._logger.info(n.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorLeave",list:e}),t),this._callAppListener("onAnchorLeave",e),[2]}}))}))}}),Object.defineProperty(t.prototype,"_diffRoomResource",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,o,a=this;return c(this,(function(s){return r=[],i=[],o=[],e.forEach((function(e){var t=lt(e),i=dt(t),n=i.tag,s=i.mediaType,c=[a._roomId,n,s].join("_"),u=JSON.parse(e.uri).ssrc;if(a._store.setTrackIdSSRCMap(u,c),!a._remoteTracks[c]){var l=s===exports.RCMediaType.AUDIO_ONLY?new rt(a._logger,n,"",a._roomId):new it(a._logger,n,"",a._roomId);r.push(l),a._remoteTracks[c]=l,a._roomRes[l.getTrackId()]=e}o.push(c)})),Object.keys(this._remoteTracks).forEach((function(e){o.indexOf(e)<0&&a._remoteTracks[e].isMCUTrack()&&i.push(a._remoteTracks[e])})),r.length>0&&(this._logger.info(n.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)),i.length>0&&this._onUserUnpublish(i,"onTrackUnpublish",t),[2]}))}))}}),Object.defineProperty(t.prototype,"_dealPublished",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,a,s,u,l,d=this;return c(this,(function(c){switch(c.label){case 0:return i=e.map(lt),a=[],s=[],t.forEach((function(t){var r=lt(t),n=i.indexOf(r),o=dt(r),c=o.userId,u=o.tag,l=o.mediaType,_=JSON.parse(t.uri).ssrc;d._store.setTrackIdSSRCMap(_,r),n>-1?e[n]=t:e.push(t);var p=d._remoteTracks[r];d._roomRes[r]=t,p?p.isSubscribed()&&a.push(p):(p=l===exports.RCMediaType.AUDIO_ONLY?new rt(d._logger,u,c):new it(d._logger,u,c),d._remoteTracks[r]=p,s.push(p)),p.__innerSetRemoteMuted(0===t.state)})),a.length?(u=a.map((function(e){return e.getTrackId()})),[4,_s((function(){return d._subscribeHandle(a,!0)}))]):[3,2];case 1:(l=c.sent().code)!==exports.RCRTCCode.SUCCESS&&this._logger.error(n.L_RESUB_REPUB_RES_R,JSON.stringify({status:o.FAILED,trackIds:u,code:l})),c.label=2;case 2:return this._logger.info(n.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onAnchorTrackPublish",trackIds:s.map((function(e){return e.getTrackId()}))}),r),this._callAppListener("onAnchorTrackPublish",s),[2]}}))}))}}),Object.defineProperty(t.prototype,"_dealUnpublished",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n,o,a,s=this;return c(this,(function(c){switch(c.label){case 0:for(i=t.map(lt),n=e.length-1;n>=0;n-=1)o=e[n],i.includes(lt(o))&&e.splice(n,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(t.prototype,"_dealModified",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i,o,a=e.map(lt);try{for(var s=u(t),c=s.next();!c.done;c=s.next()){var l=c.value,d=lt(l);e[a.indexOf(d)].state=l.state;var _=this._remoteTracks[d];_.__innerSetRemoteMuted(0===l.state);var p=_.isAudioTrack()?"onAudioMuteChange":"onVideoMuteChange";this._logger.info(n.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:p,trackId:_.getTrackId()}),r),this._callAppListener(p,_)}}catch(e){i={error:e}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}}),Object.defineProperty(t.prototype,"_diffAnchorResource",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n,o,a,s;return c(this,(function(c){switch(c.label){case 0:return i=this._roomAnchorRes[t]||(this._roomAnchorRes[t]=[]),n=ft(i,e),o=n.publishedList,a=n.unpublishedList,s=n.modifiedList,o.length?[4,this._dealPublished(i,o,r)]:[3,2];case 1:c.sent(),c.label=2;case 2:return a.length?[4,this._dealUnpublished(i,a,r)]:[3,4];case 3:c.sent(),c.label=4;case 4:return s.length&&this._dealModified(i,s,r),[2]}}))}))}}),Object.defineProperty(t.prototype,"_onUserUnpublish",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i=this;return c(this,(function(o){switch(o.label){case 0:return[4,this.unsubscribe(e)];case 1:return o.sent(),e.forEach((function(e){i._subscribedList=i._subscribedList.filter((function(t){return t.track.getTrackId()!==e.getTrackId()})),delete i._roomRes[e.getTrackId()],e.__innerDestroy(),delete i._remoteTracks[e.getTrackId()]})),this._logger.info(n.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(t.prototype,"_callAppListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];var o=null===(t=this._appListener)||void 0===t?void 0:t[e];if(o)try{o.apply(void 0,d([],l(r),!1))}catch(e){this._logger.error(n.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify(e))}}}),Object.defineProperty(t.prototype,"_reTryExchange",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var e=this;return c(this,(function(t){return[2,_s((function(){return s(e,void 0,void 0,(function(){var e,t,r,i,n,o,a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return[4,this._createSubscribeParams(this._subscribedList,{},!0)];case 1:return e=c.sent().reqBody,[4,this._exchangeHandle(e)];case 2:return(t=c.sent()).code!==exports.RCRTCCode.SUCCESS?[2,{code:t.code}]:(r=t.data,i=r.sdp,(n=r.resultCode)!==exports.RCRTCCode.SUCCESS?[2,{code:n}]:(this._pc.clearReTryExchangeTimer(),(o=this._subscribedList.filter((function(e){return e.track.isMCUTrack()}))).length>0&&(a=o[0].track.getTrackId(),s=null===(l=this._roomRes[a])||void 0===l?void 0:l.msid,u=[this._roomId,"RongCloudRTC"].join("_"),i.sdp=i.sdp.replace(new RegExp(s,"g"),u)),[4,this._pc.setRemoteAnswer(i.sdp)]));case 3:return[2,{code:c.sent()}]}}))}))}),"audience-retry-exchange")]}))}))}}),Object.defineProperty(t.prototype,"_createSubscribeParams",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n,o,a=this;return c(this,(function(s){switch(s.label){case 0:return[4,this._pc.createOffer(r)];case 1:return i=s.sent(),n={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;i.sdp=null===(a=i.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?ct(c):hs,d=l.width,_=l.height,p=l.frameRate;n.resolutionInfo.push({trackId:c.id,simulcast:u?Gn.NORMAL:Gn.TINY,resolution:"".concat(d,"x").concat(_)});var f=De(d,_),h=Ue(p);o.min+=f.minBitrate*h,o.max+=f.maxBitrate*h}}))})),[2,{reqBody:{sdp:i,switchstream:!1,newVersionFlag:!0,subscribeList:e.map((function(e){return{simulcast:e.subTiny?Gn.TINY:Gn.NORMAL,resolution:"",uri:a._roomRes[e.track.getTrackId()].uri}}))},dynamicBitrate:o,offer:i}]}}))}))}}),Object.defineProperty(t.prototype,"_subscribeHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return void 0===r&&(r=!1),void 0===i&&(i=!1),s(this,void 0,void 0,(function(){var s,u,l,d,_,p;return c(this,(function(c){return s=Date.now(),u=i?ea.SUB:void 0,l=this._logger.createTraceId(),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_T,JSON.stringify({trackIds:t.map(Lt),forceReq:r}),l),this._assertRoomDestroyed()?(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),l),this._reportPubOrSubQualityData(s,t,exports.RCRTCCode.ROOM_HAS_BEEN_DESTROYED,u),[2,{code:exports.RCRTCCode.ROOM_HAS_BEEN_DESTROYED}]):e.validate("tracks",t,(function(){return e.isArray(t)&&t.length>0&&t.every((function(e){return e instanceof tt||e.track instanceof tt}))}),!0)?(this._pc.__reportR3R4ToPolaris(),this._pc.registerReportListener(this._reportListener),this._addPeerCEvent(),d=this._subscribedList.map((function(e){return a({},e)})),_=t.map((function(e){return e instanceof tt?{track:e}:e})),p=[],_.forEach((function(e){var t=e.track.getTrackId();p.push(t);var r=d.find((function(e){return e.track.getTrackId()===t}));r&&r.subTiny===e.subTiny||(r?r.subTiny=e.subTiny:d.push(e))})),this._polarisReport.sendR2(Bo.SUBSCRIBE,Vo.BEGIN,p),[2,this._updateSubListHandle(d,l,s,u,!0)]):(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_SUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> tracks"}),l),this._reportPubOrSubQualityData(s,t,exports.RCRTCCode.PARAMS_ERROR,u),[2,{code:exports.RCRTCCode.PARAMS_ERROR}])}))}))}}),Object.defineProperty(t.prototype,"_addPeerCEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._pc.on(yo.__INNER_EVENT_TRACK_READY__,(function(t){var r=t.streams[0].id,i=t.receiver.track,o=[r,"audio"===i.kind?exports.RCMediaType.AUDIO_ONLY:exports.RCMediaType.VIDEO_ONLY].join("_"),a=e._remoteTracks[o];a?(a.__innerSetMediaStreamTrack(i),e._logger.info(n.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O,JSON.stringify({eventType:"onTrackReady",trackId:a.getTrackId()})),e._callAppListener("onTrackReady",a)):e._logger.warn(n.L_AUDIENCE_LIVING_ROOM_ONTRACKREADY_O,"cannot found RCRemoteTrack: ".concat(i.id))})),this._pc.once(yo.__INNER_ICE_CONNECTED__,(function(){e._reportMediaActionLogger.reportIceFirstConnectData("sub")}),this),this._pc.on(yo.__INNER_ICE_STATE_CHANGE__,(function(t){var r=t.status,i=t.time,n=t.iceCandidatePair;n&&e._reportMediaActionLogger.recordQualityIceStatusData(n,r,i)}))}}),Object.defineProperty(t.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:exports.RTCMode.LIVE,UserId:e,"Session-Id":this._sessionId,"Client-Session-Id":this._clientSessionId}}}),Object.defineProperty(t.prototype,"_exchangeHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._service.broadcastSubscribe(this._getReqHeaders(),e)}}),Object.defineProperty(t.prototype,"_dealSubscribeResult",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){var i,a=this,s=null==t?void 0:t.map((function(e){return"".concat(e.msid,"_").concat(e.mediaType)})),c=e.filter((function(e){if(e.track.isMCUTrack()){var t=a._roomRes[e.track.getTrackId()],r="".concat(t.msid,"_").concat(t.mediaType);return s.includes(r)}return null==s?void 0:s.includes(e.track.getTrackId())})),u=null==c?void 0:c.map((function(e){return"".concat(e.track.getTrackId())})),_=e.filter((function(e){return!(null==u?void 0:u.includes(e.track.getTrackId()))})),p=function(e){var t=c.some((function(t){return t.track.getTrackId()===e}));f._remoteTracks[e].__innerSetSubscribed(t)},f=this;for(var h in this._remoteTracks)p(h);return(i=this._subscribedList).splice.apply(i,d([0,this._subscribedList.length],l(c),!1)),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:o.SUCCESSED,subSuccessTrackIds:s,failedList:_}),r),_}}),Object.defineProperty(t.prototype,"_getParams",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.map((function(e){return e instanceof tt?{track:e}:a({},e)})),r={};return t=t.filter((function(e){var t=e.track.getTrackId();return!r[t]&&(r[t]=!0,!0)})).map((function(e){return a({},e)}))}}),Object.defineProperty(t.prototype,"_reportPubOrSubQualityData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){i&&this._reportMediaActionLogger.reportPubOrSubQualityData(i,e,t,r,this._trackMediaMap)}}),Object.defineProperty(t.prototype,"_updateSubListHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,u){var l;return void 0===u&&(u=!1),s(this,void 0,void 0,(function(){var s,d,_,p,f,h,b,R,g,m,C,v,O=this;return c(this,(function(c){switch(c.label){case 0:return this._logger.info(n.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_T,JSON.stringify({trackIds:e.map(Lt),forceReq:u}),t),s=this._getParams(e),d=this._subscribedList.map((function(e){return a({},e)})),u||fa(s,d)?(this._pc.clearReTryExchangeTimer(),this._pc.updateSubRemoteTracks(s.map((function(e){return e.track}))),[4,this._createSubscribeParams(s,{},!1)]):(this._logger.info(n.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:o.SUCCESSED,msg:"repeat subscribe"}),t),[2,{code:exports.RCRTCCode.SUCCESS}]);case 1:return _=c.sent().reqBody,[4,this._exchangeHandle(_)];case 2:return p=c.sent(),d.length&&(f=[],d.forEach((function(e){f.push(e.track.getTrackId())})),null===(l=this._pc.reportParser)||void 0===l||l.clearLatestPacketsRecv(f)),e.forEach((function(e){var t=e instanceof tt?e.getTrackId():e.track.getTrackId();O._trackMediaMap[t]=p.qualityMsList||[]})),p.code!==exports.RCRTCCode.SUCCESS?(this._reportPubOrSubQualityData(r,e,p.code,i),this._logger.error(n.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:o.FAILED,code:p.code}),t),[2,{code:p.code}]):(h=p.data,b=h.sdp,R=h.resultCode,g=h.message,m=h.subscribedList,R!==exports.RCRTCCode.SUCCESS?(this._reportPubOrSubQualityData(r,e,R,i),this._logger.error(n.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:o.FAILED,code:R,msg:g}),t),[2,{code:R}]):(s.forEach((function(e){var t=e.track;if(t.isMCUTrack()){var r=O._roomRes[t.getTrackId()].msid,i=dt(t.getTrackId()),n=i.tag,o=[i.userId,n].join("_");b.sdp=b.sdp.replace(new RegExp(r,"g"),o)}})),[4,this._pc.setRemoteAnswer(b.sdp)]));case 3:return C=c.sent(),this._reportPubOrSubQualityData(r,e,C,i),C!==exports.RCRTCCode.SUCCESS?(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_UPDATE_SUBSCRIBELIST_R,JSON.stringify({status:o.FAILED,code:C,msg:"set remote answer error"}),t),[2,{code:C}]):[2,(v=this._dealSubscribeResult(s,m,t)).length?{code:exports.RCRTCCode.SUCCESS,failedList:v}:{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),Object.defineProperty(t.prototype,"_diffCDNUris",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,o;return c(this,(function(a){return this._CDNUris.url&&!e.url?(this._logger.info(n.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(n.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,i=this._CDNUris.h&&e.h&&this._CDNUris.h!==e.h,o=this._CDNUris.fps&&e.fps&&this._CDNUris.fps!==e.fps,(r||i||o)&&(this._logger.info(n.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(t.prototype,"_getCDNPlayUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,a,s,u,l,d,_,p,f,h,b,R,g,m,C;return c(this,(function(c){switch(c.label){case 0:return r=e.w,i=e.h,a=e.fps,s=this._initOptions.pullInnerCDNProtocol||exports.RCInnerCDNPullKind.FLV,u=this._initOptions.pullInnerCDNUseHttps===exports.RCInnerCDNPullIsHttps.NOT_HTTPS?exports.RCInnerCDNPullIsHttps.NOT_HTTPS:exports.RCInnerCDNPullIsHttps.HTTPS,this._CDNUris.url?(l={"App-Key":this._context.getAppkey(),Token:this._joinResData.token,RoomId:this.getRoomId(),UserId:this._crtUserId,SessionId:this.getSessionId()},d=[],_=this._CDNUris,p=_.w,f=void 0===p?0:p,h=_.h,f/(void 0===h?1:h)>1?(r&&d.push("w=".concat(r)),i&&d.push("h=".concat(i))):(r&&d.push("h=".concat(r)),i&&d.push("w=".concat(i))),a&&d.push("fps=".concat(a)),d.push("kind=".concat(s)),d.push("is_https=".concat(u)),b=d.join("&"),R="".concat(this._CDNUris.url,"?"),b&&(R+=b),[4,this._service.getCDNResourceInfo(l,R,t)]):(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.CDN_RESOURCE_IS_EMPTY,msg:"cdn_uris url is empty, the anchor need to open or push CDN"}),t),[2,{code:exports.RCRTCCode.CDN_RESOURCE_IS_EMPTY}]);case 1:return g=c.sent(),m=g.code,C=g.res,m!==exports.RCRTCCode.SUCCESS?[2,{code:m}]:[2,{code:m,CDNPlayUrl:null==C?void 0:C.data.pull_url}]}}))}))}}),Object.defineProperty(t.prototype,"getCDNPlayUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,a,s,u,l;return c(this,(function(c){return r=this._logger.createTraceId(),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_T,JSON.stringify({resolution:e,fps:t}),r),e&&!Rt(e)?(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> resolution"}),r),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):t&&!gt(t)?(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_GET_CDN_PLAY_URL_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> fps"}),r),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(i=e?bt(e):{width:null,height:null},a=i.width,s=i.height,u=t?mt(t):null,l={},a&&(l.w=a),s&&(l.h=s),u&&(l.fps=u),[2,this._getCDNPlayUrl(l,r)])}))}))}}),Object.defineProperty(t.prototype,"subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t=this;return c(this,(function(r){return[2,_s((function(){return t._subscribeHandle(e,!1,!0)}),"audience-sub")]}))}))}}),Object.defineProperty(t.prototype,"__unsubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,s,u;return c(this,(function(c){return r=Date.now(),i=ea.UNSUB,s=this._logger.createTraceId(),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_T,JSON.stringify({trackIds:t.map((function(e){return e.getTrackId()}))}),s),this._assertRoomDestroyed()?(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.ROOM_HAS_BEEN_DESTROYED,msg:"room destroyed"}),s),[2,{code:exports.RCRTCCode.ROOM_HAS_BEEN_DESTROYED}]):e.validate("tracks",t,(function(){return e.isArray(t)&&t.length>0&&t.every((function(e){return e instanceof tt}))}),!0)?(u=this._subscribedList.map((function(e){return a({},e)})).filter((function(e){return t.every((function(t){return t.getTrackId()!==e.track.getTrackId()}))})),this._polarisReport.sendR2(Bo.SUBSCRIBE,Vo.END,t.map((function(e){return e.getTrackId()}))),[2,this._updateSubListHandle(u,s,r,i,!1)]):(this._logger.error(n.L_AUDIENCE_LIVING_ROOM_UNSUBSCRIBE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> tracks"}),s),[2,{code:exports.RCRTCCode.PARAMS_ERROR}])}))}))}}),Object.defineProperty(t.prototype,"unsubscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t=this;return c(this,(function(r){return[2,_s((function(){return t.__unsubscribe(e)}),"audience-unsub")]}))}))}}),Object.defineProperty(t.prototype,"__destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;return s(this,void 0,void 0,(function(){return c(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(t.prototype,"getRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._remoteTracks[e]}}),Object.defineProperty(t.prototype,"getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return{}}}),Object.defineProperty(t.prototype,"__onReconnected",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return t=this._logger.createTraceId(),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_T,void 0,t),[4,this._context.joinLivingRoomAsAudience(this._roomId,exports.RTCMode.LIVE)];case 1:return r.sent().code!==e.ErrorCode.SUCCESS&&this._logger.error(n.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,"status: ".concat(o.FAILED),t),this._logger.info(n.L_AUDIENCE_LIVING_ROOM_IM_RECONNECTED_R,"status: ".concat(o.SUCCESSED),t),[2]}}))}))}}),Object.defineProperty(t.prototype,"registerRoomEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._appListener=e}}),Object.defineProperty(t.prototype,"onAudioLevelChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info(n.L_AUDIENCE_LIVING_ROOM_CALL_APP_LISTENER_O),this._audioLevelReport.onAudioLevelChange(e)}}),Object.defineProperty(t.prototype,"registerReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._reportListener=e}}),Object.defineProperty(t.prototype,"getRoomId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._roomId}}),Object.defineProperty(t.prototype,"getCrtUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._crtUserId}}),Object.defineProperty(t.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._sessionId}}),Object.defineProperty(t.prototype,"getRemoteUserIds",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._roomAnchorList}}),Object.defineProperty(t.prototype,"getRemoteTracksByUserId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=[];for(var r in this._remoteTracks){var i=this._remoteTracks[r];i.getUserId()===e&&t.push(i)}return t}}),Object.defineProperty(t.prototype,"getRemoteTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=[],r=[];for(var i in this._remoteTracks){if(2===r.length)break;var n=this._remoteTracks[i];n.isMCUTrack()&&r.push(n)}return this._roomAnchorList.forEach((function(r){t.push.apply(t,d([],l(e.getRemoteTracksByUserId(r)),!1))})),d(d([],l(r),!1),l(t),!1)}}),Object.defineProperty(t.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(t.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(t.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(t.prototype,"getClientSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._clientSessionId}}),t}();!function(e){e[e.AUTOMATIC=0]="AUTOMATIC",e[e.MANUAL=1]="MANUAL"}(fs||(fs={}));var Rs,gs,ms=function(){function t(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(t.prototype,"_getMediaStream",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===t&&(t="getUserMedia"),s(this,void 0,void 0,(function(){var r,i,o;return c(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),r=this.setConstraintsConfig(e),[4,navigator.mediaDevices[t](r)];case 1:return i=a.sent(),[2,{code:exports.RCRTCCode.SUCCESS,stream:i}];case 2:return o=a.sent(),this._logger.error(n.L_GET_MEDIA_STREAM_E,JSON.stringify({name:o.name,message:o.message})),"Permission denied"===o.message?[2,{code:exports.RCRTCCode.BROWSER_PERMISSION_DENIED}]:"Permission denied by system"===o.message?[2,{code:exports.RCRTCCode.SYSTEM_PERMISSION_DENIED}]:[3,3];case 3:return[2,{code:"getUserMedia"===t?exports.RCRTCCode.GET_USER_MEDIA_FAILED:exports.RCRTCCode.GET_DISPLAY_MEDIA_FAILED}]}}))}))}}),Object.defineProperty(t.prototype,"_getMediaStreamErrorReason",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t="";return e===exports.RCRTCCode.BROWSER_PERMISSION_DENIED&&(t="Permission denied"),e===exports.RCRTCCode.SYSTEM_PERMISSION_DENIED&&(t="Permission denied by system"),t}}),Object.defineProperty(t.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 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(n.L_SET_AUDIO_CONSTRAINTS_O,"browser supported -> ".concat(JSON.stringify(i)))}return e}}),Object.defineProperty(t.prototype,"createMicrophoneAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===e&&(e="RongCloudRTC"),s(this,void 0,void 0,(function(){var r,i,a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return at(e)?(r=this._context.getCurrentId())?[4,this._getMediaStream({audio:{deviceId:(null==t?void 0:t.micphoneId)?{exact:null==t?void 0:t.micphoneId}:void 0,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(n.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:exports.RCRTCCode.INVALID_USER_ID}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),[2,{code:exports.RCRTCCode.INVALID_TAGS}]);case 1:return i=c.sent(),a=i.stream,(s=i.code)!==exports.RCRTCCode.SUCCESS?(this._logger.error(n.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:o.FAILED,code:s,msg:this._getMediaStreamErrorReason(s)})),[2,{code:s}]):(u=a.getAudioTracks()[0],l=new Ze(this._logger,e,r,u),this._logger.info(n.L_RTC_CLIENT_CREATE_MICROPHONE_AUDIO_TRACK_O,JSON.stringify({status:o.SUCCESSED,trackId:l.getTrackId()})),[2,{code:s,track:l}])}}))}))}}),Object.defineProperty(t.prototype,"createCameraVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===e&&(e="RongCloudRTC"),s(this,void 0,void 0,(function(){var r,i,a,s,u,l,d,_,p,f;return c(this,(function(c){switch(c.label){case 0:return at(e)?(r=this._context.getCurrentId())?(i=Rt(null==t?void 0:t.resolution)?t.resolution:exports.RCResolution.W640_H480,a=bt(i),s=a.width,u=a.height,[4,this._getMediaStream({video:{deviceId:(null==t?void 0:t.cameraId)?{exact:null==t?void 0:t.cameraId}:void 0,frameRate:mt((null==t?void 0:t.frameRate)||exports.RCFrameRate.FPS_15),width:{ideal:s,max:s},height:{ideal:u,max:u},facingMode:null==t?void 0:t.faceMode}})]):(this._logger.error(n.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:exports.RCRTCCode.INVALID_USER_ID}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),[2,{code:exports.RCRTCCode.INVALID_TAGS}]);case 1:return l=c.sent(),d=l.stream,(_=l.code)!==exports.RCRTCCode.SUCCESS?(this._logger.error(n.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,code:_,msg:this._getMediaStreamErrorReason(_)})),[2,{code:_}]):(p=d.getVideoTracks()[0],[4,this._applyVideoAspectRatio(p,s,u)]);case 2:return c.sent(),f=new Xe(this._logger,e,r,p),this._logger.info(n.L_RTC_CLIENT_CREATE_CAMERA_VIDEO_TRACK_O,JSON.stringify({status:o.SUCCESSED,trackId:f.getTrackId()})),[2,{code:_,track:f}]}}))}))}}),Object.defineProperty(t.prototype,"createMicrophoneAndCameraTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return void 0===e&&(e="RongCloudRTC"),s(this,void 0,void 0,(function(){var i,a,s,u,l,d,_,p,f,h,b,R,g,m;return c(this,(function(c){switch(c.label){case 0:return i=[],at(e)?(a=this._context.getCurrentId())?(s=Rt(null===(r=null==t?void 0:t.video)||void 0===r?void 0:r.resolution)?t.video.resolution:exports.RCResolution.W640_H480,u=bt(s),l=u.width,d=u.height,_=null==t?void 0:t.audio,p=null==t?void 0:t.video,[4,this._getMediaStream({video:{deviceId:(null==p?void 0:p.cameraId)?{exact:null==p?void 0:p.cameraId}:void 0,frameRate:mt((null==p?void 0:p.frameRate)||exports.RCFrameRate.FPS_15),width:{ideal:l,max:l},height:{ideal:d,max:d},facingMode:null==p?void 0:p.faceMode},audio:{deviceId:(null==_?void 0:_.micphoneId)?{exact:null==_?void 0:_.micphoneId}:void 0,sampleRate:null==_?void 0:_.sampleRate,noiseSuppression:null==_?void 0:_.noiseSuppression,echoCancellation:null==_?void 0:_.echoCancellation,autoGainControl:null==_?void 0:_.autoGainControl}})]):(this._logger.error(n.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:exports.RCRTCCode.INVALID_USER_ID,tracks:i}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),[2,{code:exports.RCRTCCode.INVALID_TAGS,tracks:i}]);case 1:if(f=c.sent(),h=f.stream,(b=f.code)!==exports.RCRTCCode.SUCCESS)return this._logger.error(n.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:o.FAILED,code:b,msg:this._getMediaStreamErrorReason(b)})),[2,{code:b,tracks:i}];R=h.getTracks(),g=0,c.label=2;case 2:return g<R.length?"video"!==(m=R[g]).kind?[3,4]:[4,this._applyVideoAspectRatio(m,l,d)]:[3,6];case 3:return c.sent(),i.push(new Xe(this._logger,e,a,m)),[3,5];case 4:i.unshift(new Ze(this._logger,e,a,m)),c.label=5;case 5:return g++,[3,2];case 6:return this._logger.info(n.L_RTC_CLIENT_CREATE_MICROPHONE_AND_CAMERA_TRACKS_O,JSON.stringify({status:o.SUCCESSED,trackIds:i.map((function(e){return e.getTrackId()}))})),[2,{code:b,tracks:i}]}}))}))}}),Object.defineProperty(t.prototype,"createScreenVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===e&&(e="screenshare"),s(this,void 0,void 0,(function(){var r;return c(this,(function(i){switch(i.label){case 0:return[4,this._createScreenTracks(e,!1,n.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,t)];case 1:return(r=i.sent()).code===exports.RCRTCCode.SUCCESS?[2,{code:r.code,track:r.tracks[0]}]:[2,r]}}))}))}}),Object.defineProperty(t.prototype,"createScreenWithAudioTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===e&&(e="screenshare"),s(this,void 0,void 0,(function(){return c(this,(function(r){return[2,this._createScreenTracks(e,!0,n.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_AND_AUDIO_TRACKS_O,t)]}))}))}}),Object.defineProperty(t.prototype,"_createScreenTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){return s(this,void 0,void 0,(function(){var a,s,u,l,d,_,p,f,h,b,R,g;return c(this,(function(c){switch(c.label){case 0:return at(e)?(a=this._context.getCurrentId())?Ot()?(s=/macintosh|mac os x/i.test(navigator.userAgent),u=(!this._isElectron||!s)&&t,l=Rt(null==i?void 0:i.resolution)?i.resolution:exports.RCResolution.W1280_H720,this._isElectron?[4,this._createElectronScreenStream(t,r,l,null==i?void 0:i.chromeMediaSourceId)]:[3,2]):(this._logger.error(n.L_RTC_CLIENT_CREATE_SCREEN_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.BROWSER_NOT_SUPPORT,msg:"browser not support"})),[2,{code:exports.RCRTCCode.BROWSER_NOT_SUPPORT}]):(this._logger.error(r,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:exports.RCRTCCode.INVALID_USER_ID}]):(this._logger.error(r,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),[2,{code:exports.RCRTCCode.INVALID_TAGS}]);case 1:return f=c.sent(),[3,4];case 2:return[4,this._createWebScreenStream(t,l,null==i?void 0:i.frameRate)];case 3:f=c.sent(),c.label=4;case 4:return _=(d=f).stream,(p=d.code)!==exports.RCRTCCode.SUCCESS?(this._logger.error(r,JSON.stringify({status:o.FAILED,code:p,msg:this._getMediaStreamErrorReason(p)})),[2,{code:p}]):(h=_.getVideoTracks()[0],b=new $e(this._logger,e,a,h),R=[b],u&&(g=_.getAudioTracks()[0])&&R.push(new et(this._logger,e,a,g)),this._logger.info(r,JSON.stringify({status:o.SUCCESSED,trackIds:R.map((function(e){return e.getTrackId()}))})),[2,{code:p,tracks:R}])}}))}))}}),Object.defineProperty(t.prototype,"_createElectronScreenStream",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,n){var a,u;return s(this,void 0,void 0,(function(){var s,l,d,_,p,f,h;return c(this,(function(c){return s=/macintosh|mac os x/i.test(navigator.userAgent),this._isElectron&&s&&t&&this._logger.warn(r,JSON.stringify({status:o.INFO,code:exports.RCRTCCode.MAC_IN_ELECTRON_NOT_SUPPORT_SCREEN_SHARE_WITH_AUDIO,msg:"mac in electron not support screen share with audio"})),l=(!this._isElectron||!s)&&t,!this._isElectron||e.isUndefined(n)||e.isString(n)?(d=bt(i),_=d.width,p=d.height,f={mandatory:{chromeMediaSourceId:n,chromeMediaSource:"desktop",minWidth:_,maxWidth:_,minHeight:p,maxHeight:p}},!n&&this._isElectron&&(null===(a=f.mandatory)||void 0===a||delete a.chromeMediaSourceId),h=null,l&&this._isElectron&&(null===(u=f.mandatory)||void 0===u||delete u.chromeMediaSourceId,h={mandatory:{chromeMediaSource:"desktop"}}),[2,this._getMediaStream({video:f,audio:h||l},"getUserMedia")]):(this._logger.error(r,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> options.chromeMediaSourceId type is string"})),[2,{code:exports.RCRTCCode.PARAMS_ERROR}])}))}))}}),Object.defineProperty(t.prototype,"_createWebScreenStream",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,n,o,a;return c(this,(function(s){return i=bt(t),n=i.width,o=i.height,a={frameRate:mt(r||exports.RCFrameRate.FPS_15),width:n,height:o},[2,this._getMediaStream({video:a,audio:e},"getDisplayMedia")]}))}))}}),Object.defineProperty(t.prototype,"createLocalAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i;return c(this,(function(a){return at(e)?t&&"[object MediaStreamTrack]"===t.toString()&&"audio"===t.kind?(r=this._context.getCurrentId())?(i=new We(this._logger,e,r,t),this._logger.info(n.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:o.SUCCESSED,trackId:i.getTrackId()})),[2,{code:exports.RCRTCCode.SUCCESS,track:i}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:exports.RCRTCCode.INVALID_USER_ID}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not audio"})),[2,{code:exports.RCRTCCode.CREATE_CUSTOM_TRACK_FAILED}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_AUDIO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),[2,{code:exports.RCRTCCode.INVALID_TAGS}])}))}))}}),Object.defineProperty(t.prototype,"createLocalVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i;return c(this,(function(a){return at(e)?t&&t instanceof MediaStreamTrack&&"video"===t.kind?(r=this._context.getCurrentId())?(i=new Ye(this._logger,e,r,t),this._logger.info(n.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:o.SUCCESSED,trackId:i.getTrackId()})),[2,{code:exports.RCRTCCode.SUCCESS,track:i}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:exports.RCRTCCode.INVALID_USER_ID}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.CREATE_CUSTOM_TRACK_FAILED,msg:"params track is not MediaStreamTrack or kind is not video"})),[2,{code:exports.RCRTCCode.CREATE_CUSTOM_TRACK_FAILED}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_VIDEO_TRACK_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),[2,{code:exports.RCRTCCode.INVALID_TAGS}])}))}))}}),Object.defineProperty(t.prototype,"_validateCreateLocalFileTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){if(!at(t))return this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),{code:exports.RCRTCCode.INVALID_TAGS,tracks:[]};if(!vt())return this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.BROWSER_NOT_SUPPORT,msg:"browser not support"})),{code:exports.RCRTCCode.BROWSER_NOT_SUPPORT,tracks:[]};var i=r instanceof File?URL.createObjectURL(r):r;return e.isHttpUrl(i)||/^blob:/.test(i)?this._context.getCurrentId()?{code:exports.RCRTCCode.SUCCESS,tracks:[],url:i}:(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),{code:exports.RCRTCCode.INVALID_USER_ID,tracks:[]}):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> file"})),{code:exports.RCRTCCode.PARAMS_ERROR,tracks:[]})}}),Object.defineProperty(t.prototype,"createLocalFileTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i){return s(this,void 0,void 0,(function(){var a,s,u=this;return c(this,(function(c){return(a=this._validateCreateLocalFileTracks(e,r)).code!==exports.RCRTCCode.SUCCESS?[2,a]:(s=this._context.getCurrentId(),[2,new Promise((function(r){var c=document.createElement("video");(null==i?void 0:i.withoutAudio)&&(c.muted=!0),c.onloadedmetadata=function(){var a,d=[];try{var _=c.mozCaptureStream?"mozCaptureStream":"captureStream";a=c[_]()}catch(e){u._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.CREATE_FILE_TRACK_FAILED,msg:"captureSteam error -> ".concat(JSON.stringify(e))})),r({code:exports.RCRTCCode.CREATE_FILE_TRACK_FAILED,tracks:d})}var p=l(t.getTracksWithOptions(a,i),2),f=p[0],h=p[1];f&&d.push(new Qe(u._logger,e,s,f,c)),h&&d.push(new qe(u._logger,e,s,h,c)),0===d.length&&(c.pause(),c.src=""),c.onerror=null,u._logger.info(n.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:o.SUCCESSED,trackIds:d.map((function(e){return e.getTrackId()}))})),r({code:exports.RCRTCCode.SUCCESS,tracks:d})},c.onerror=function(){u._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_FILE_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.CREATE_FILE_TRACK_FAILED,msg:"Failed to create file stream, video onerror"})),r({code:exports.RCRTCCode.CREATE_FILE_TRACK_FAILED,tracks:[]})},c.src=a.url,c.loop=!0,c.play()}))])}))}))}}),Object.defineProperty(t.prototype,"createLocalTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,i){return s(this,void 0,void 0,(function(){var a,s,u,d,_;return c(this,(function(c){return a=[],at(e)?r instanceof MediaStream?(s=this._context.getCurrentId())?(u=l(t.getTracksWithOptions(r,i),2),d=u[0],_=u[1],d&&a.push(new We(this._logger,e,s,d)),_&&a.push(new Ye(this._logger,e,s,_)),this._logger.info(n.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:o.SUCCESSED,trackIds:a.map((function(e){return e.getTrackId()}))})),[2,{code:exports.RCRTCCode.SUCCESS,tracks:a}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_USER_ID,msg:"invalid IM connection,invalid userId"})),[2,{code:exports.RCRTCCode.INVALID_USER_ID,tracks:a}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> stream"})),[2,{code:exports.RCRTCCode.PARAMS_ERROR,tracks:a}]):(this._logger.error(n.L_RTC_CLIENT_CREATE_LOCAL_TRACKS_O,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.INVALID_TAGS,msg:"invalid tag"})),[2,{code:exports.RCRTCCode.INVALID_TAGS,tracks:a}])}))}))}}),Object.defineProperty(t,"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(t.prototype,"_applyVideoAspectRatio",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i,s,u,l,d;return c(this,(function(c){switch(c.label){case 0:if(i=e.getSettings(),s=i.width,u=i.height,s===t&&u===r)return[2];l=t/r>=1?{width:{ideal:s,max:s}}:{height:{ideal:u,max:u}},c.label=1;case 1:return c.trys.push([1,3,,4]),[4,e.applyConstraints(a(a({},l),{aspectRatio:{ideal:t/r}}))];case 2:return c.sent(),this._logger.info(n.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:o.SUCCESSED,msg:"apply aspectRatio success -> ".concat(t," / ").concat(r)})),[3,4];case 3:return d=c.sent(),this._logger.warn(n.L_RTC_CLIENT_APPLY_VIDEO_ASPECT_RATIO_O,JSON.stringify({status:o.FAILED,msg:"apply aspectRatio error -> ".concat(JSON.stringify(d))})),[3,4];case 4:return[2]}}))}))}}),t}(),Cs=function(t){function i(e,r,i){var n=t.call(this,e)||this;return Object.defineProperty(n,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(n,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(n,"_options",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(n,"_service",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"_crtRoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(n,"_audience",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(n,"_crtAudienceLivingRoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),ho.setSdpSemantics(i.sdpSemantics||"unified-plan",n._logger),n._service=new Zn(n._runtime,n._context,n._options.mediaServer,n._options.timeout),n._context.registerConnectionStateChangeListener(n._onIMStatusChange.bind(n)),n._context.registerDestroyListener(n._onIMUninit.bind(n)),n._context.registerMessageListener(n._handleMessage.bind(n)),n._context.getPluginContext().onnavidatachange=n.naviDataChange.bind(n),n}return r(i,t),Object.defineProperty(i.prototype,"_handleMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(t.conversationType!==e.ConversationType.RTC_ROOM)return!1;var r=this._logger.createTraceId();this._crtRoom instanceof cs&&this._getJoinedPKRoomList().forEach((function(e){e.__parseInnerMessage(t,r)}));return this._logger.info(n.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:o.SUCCESSED,message:t}),r),this._crtRoom?(this._crtRoom.__parseInnerMessage(t,r),!0):(this._logger.warn(n.L_RTC_CLIENT_MESSAGE_O,JSON.stringify({status:o.FAILED,message:"the crtRoom is empty"}),r),!0)}}),Object.defineProperty(i.prototype,"naviDataChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info(n.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(i.prototype,"_getJoinedPKRoomList",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._crtRoom.getRoomPKHandler(),t=e.code,r=e.roomPKHandler;if(t===exports.RCRTCCode.SUCCESS&&r){var i=r.getJoinedPKRooms()||{};return Object.values(i)}return[]}}),Object.defineProperty(i.prototype,"getCurrentId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._context.getCurrentId()}}),Object.defineProperty(i.prototype,"joinCrossRTCRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n){return void 0===n&&(n=exports.RTCMode.CROSS_MUTI),s(this,void 0,void 0,(function(){return c(this,(function(i){return console.warn("joinCrossRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),[2,this.joinRTCRoomWithOptions(e,{joinType:t,userData:r,mode:exports.RTCMode.CROSS_MUTI})]}))}))}}),Object.defineProperty(i.prototype,"joinRTCRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n){return void 0===n&&(n=exports.RTCMode.RTC),s(this,void 0,void 0,(function(){return c(this,(function(i){return console.warn("joinRTCRoom is deprecated, use joinRTCRoomWithOptions instead"),[2,this.joinRTCRoomWithOptions(e,{mode:n,joinType:t,userData:r})]}))}))}}),Object.defineProperty(i.prototype,"joinRTCRoomWithOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r,i,a,s=this;return c(this,(function(c){switch(c.label){case 0:return r=this._logger.createTraceId(),this._logger.info(n.L_RTC_CLIENT_JOIN_RTC_ROOM_T,JSON.stringify({roomId:e,options:t}),r),this._crtRoom?(this._logger.error(n.L_RTC_CLIENT_JOIN_RTC_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),r),[2,{code:exports.RCRTCCode.REPERT_JOIN_ROOM}]):[4,(i=this._crtRoom=new us(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)||exports.RTCMode.RTC,null==t?void 0:t.joinType,void 0,void 0,null==t?void 0:t.userData,r)];case 1:return(a=c.sent().code)!==exports.RCRTCCode.SUCCESS?(this._crtRoom=null,[2,{code:a}]):(i.once(Ya,(function(){s._crtRoom=null})),[2,{code:a,room:i,userIds:i.getRemoteUserIds(),tracks:i.getRemoteTracks()}])}}))}))}}),Object.defineProperty(i.prototype,"joinLivingRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,a){return s(this,void 0,void 0,(function(){var a,s,u,l,d=this;return c(this,(function(c){switch(c.label){case 0:return a=this._logger.createTraceId(),this._logger.info(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_T,JSON.stringify({roomId:e,livingType:t,joinType:r,outerUserDatas:i}),a),this._crtRoom?(this._logger.error(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REPERT_JOIN_ROOM,msg:"Join the room repeatedly -> roomId: ".concat(e)}),a),[2,{code:exports.RCRTCCode.REPERT_JOIN_ROOM}]):[4,(s=this._crtRoom=new cs(this._context,this._runtime,e,this._service,this._options,t,!1,!0)).__innerInit(exports.RTCMode.LIVE,r,t,void 0,i,a)];case 1:return(u=c.sent().code)!==exports.RCRTCCode.SUCCESS?(this._crtRoom=null,[2,{code:u}]):(s.once(Ya,(function(){d._crtRoom=null})),l={code:u,room:s,userIds:s.getRemoteUserIds(),tracks:s.getRemoteTracks()},s.__getCDNPushMode()===fs.MANUAL&&Object.assign(l,{CDNEnable:s.__getCDNEnable()}),[2,l])}}))}))}}),Object.defineProperty(i.prototype,"getAudienceClient",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._audience||(this._audience=new ps(this._context,this._runtime,this._options)),this._logger.info(n.L_RTC_CLIENT_GET_AUDIENCE_CLIENT_O),this._audience}}),Object.defineProperty(i.prototype,"_onIMStatusChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){if(this._logger.info(n.L_RTC_CLIENT_IM_CONNECTION_STATE_S,JSON.stringify({status:t,code:r,desc:e.RCConnectionStatus[t]})),t===e.RCConnectionStatus.SUSPENDED&&r===e.ErrorCode.RC_CONN_REDIRECTED&&this._service.clearMSList(),t===e.RCConnectionStatus.DISCONNECTED){if(this._crtRoom){var i=exports.RCKickReason.IM_DISCONNECTED;r===e.ErrorCode.RC_DISCONN_KICK?i=exports.RCKickReason.OTHER_CLIENT_IM_CONNECTED:2===r&&(i=exports.RCKickReason.IM_LOGOUT),this._crtRoom.__kickoff(!0,{users:[{userId:this._context.getCurrentId(),type:i}]})}}else if(t===e.RCConnectionStatus.CONNECTED){if(this._service.isNededDetector()&&this._service.detectorMediaSever(),this._crtRoom instanceof cs)this._getJoinedPKRoomList().forEach((function(e){e.__onReconnected()}));this._crtRoom&&this._crtRoom.__onReconnected()}}}),Object.defineProperty(i.prototype,"_onIMUninit",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;this._logger.info(n.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(i.prototype,"leaveRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;return s(this,void 0,void 0,(function(){var r;return c(this,(function(i){switch(i.label){case 0:return r=this._logger.createTraceId(),this._logger.info(n.L_RTC_CLIENT_LEAVE_ROOM_T,JSON.stringify({roomId:e.getRoomId()}),r),this._crtRoom?[4,this._crtRoom.__destroy(!0)]:(this._logger.warn(n.L_RTC_CLIENT_LEAVE_ROOM_R,JSON.stringify({status:o.FAILED,msg:"Room does not exist, without leave"}),r),[2,{code:exports.RCRTCCode.SUCCESS}]);case 1:return i.sent(),this._service.isNededDetector()&&this._service.detectorMediaSever(),this._logger.info(n.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,[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),Object.defineProperty(i.prototype,"joinLivingRoomAsAudience",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var i,a,s,u,l,d;return c(this,(function(c){switch(c.label){case 0:return i=this._logger.createTraceId(),this._logger.info(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_T,JSON.stringify({roomId:t,livingType:r}),i),this._service.isNededDetector()&&this._service.detectorMediaSever(),It(this._context.getNaviInfo())?(this._logger.error(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR,msg:"package environment error"}),i),[2,{code:exports.RCRTCCode.PACKAGE_ENVIRONMENT_ERROR}]):e.validate("roomId",t,e.notEmptyString,!0)&&e.validate("livingType",r,(function(e){return e===exports.RCLivingType.AUDIO||e===exports.RCLivingType.VIDEO}))?this._crtAudienceLivingRoom?(this._logger.error(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),i),[2,{code:exports.RCRTCCode.REPERT_JOIN_ROOM}]):this._service.getMsList().length?[4,this._context.joinLivingRoomAsAudience(t,exports.RTCMode.LIVE,r)]:(this._logger.error(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER,msg:"No audio / video server address available"}),i),[2,{code:exports.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER}]):(this._logger.error(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> roomId or livingType"}),i),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return a=c.sent(),s=a.code,u=a.data,s!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.FAILED,code:s,msg:"signal error -> audience join room"}),i),[2,{code:exports.RCRTCCode.SIGNAL_AUDIENCE_JOIN_ROOM_FAILED}]):(l=Wn(),d=new bs(this._context,this._runtime,this._options,t,u,r,l),this._crtAudienceLivingRoom=d,this._logger.info(n.L_RTC_CLIENT_JOIN_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.SUCCESSED,roomData:u}),i),[2,{room:d,code:exports.RCRTCCode.SUCCESS,userIds:d.getRemoteUserIds(),RTCTracks:d.getRemoteRTCTracks(),MCUTracks:d.getRemoteMCUTracks(),CDNUris:d.getCDNInfo()}])}}))}))}}),Object.defineProperty(i.prototype,"leaveLivingRoomAsAudience",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return t=this._logger.createTraceId(),this._logger.info(n.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(n.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> room"}),t),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):[4,this._crtAudienceLivingRoom.__destroy(!0)]:(this._logger.warn(n.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.FAILED,msg:"Room does not exist, without leave"}),t),[2,{code:exports.RCRTCCode.SUCCESS}]);case 1:return r.sent(),this._crtAudienceLivingRoom=null,this._logger.info(n.L_RTC_CLIENT_LEAVE_LIVING_ROOM_AS_AUDIENCE_R,JSON.stringify({status:o.SUCCESSED}),t),[2,{code:exports.RCRTCCode.SUCCESS}]}}))}))}}),Object.defineProperty(i.prototype,"upgradeToAnchorRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,a,s,u,l=this;return c(this,(function(c){switch(c.label){case 0:return r=this._logger.createTraceId(),this._logger.info(n.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_T,void 0,r),e.validate("room",t,(function(){return t instanceof bs}),!0)?(i=t.getRoomId(),this._crtRoom?(this._logger.error(n.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REPERT_JOIN_ROOM,msg:"Join the room repeatedly",roomId:i}),r),[2,{code:exports.RCRTCCode.REPERT_JOIN_ROOM}]):[4,(a=this._crtRoom=new cs(this._context,this._runtime,i,this._service,this._options,t.livingType,!0,!0,t.getClientSessionId())).__innerInitByIdentityChange(r)]):(this._logger.error(n.L_RTC_CLIENT_UPGRADE_TO_ANCHOR_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> room"}),r),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]);case 1:return(s=c.sent())!==e.ErrorCode.SUCCESS?(this._crtRoom=null,[2,{code:s}]):(a.once(Ya,(function(){l._crtRoom=null})),[4,this._crtAudienceLivingRoom.__destroy(!1)]);case 2:return c.sent(),this._crtAudienceLivingRoom=null,u={room:a,code:exports.RCRTCCode.SUCCESS,userIds:a.getRemoteUserIds(),tracks:a.getRemoteTracks()},a.__getCDNPushMode()===fs.MANUAL&&Object.assign(u,{CDNEnable:a.__getCDNEnable()}),[2,u]}}))}))}}),Object.defineProperty(i.prototype,"downgradeToAudienceRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return r=this._logger.createTraceId(),this._logger.info(n.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_T,JSON.stringify({roomId:t._roomId,userId:this._context.getCurrentId()}),r),t.isMainRoom()?e.validate("room",t,(function(){return t instanceof cs}),!0)?this._crtAudienceLivingRoom?(this._logger.error(n.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.REPERT_JOIN_ROOM,msg:"Join the room repeatedly"}),r),[2,{code:exports.RCRTCCode.REPERT_JOIN_ROOM}]):[4,this._context.rtcIdentityChange(t._roomId,is.AnchorToViewer,t.getLivingType())]:(this._logger.error(n.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.PARAMS_ERROR,msg:"params error -> room"}),r),[2,{code:exports.RCRTCCode.PARAMS_ERROR}]):(this._logger.error(n.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM,msg:"the `downgradeToAudienceRoom` is disabled in PK room"}),r),[2,{code:exports.RCRTCCode.THE_FUNCTION_IS_DISABLED_IN_PKROOM}]);case 1:return i=c.sent(),a=i.code,s=i.data,a!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:o.FAILED,code:exports.RCRTCCode.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}),r),[2,{code:exports.RCRTCCode.SIGNAL_ROOM_CHANGE_IDENTITY_FAILED}]):(this._logger.info(n.L_RTC_CLIENT_DOWNGRADE_TO_AUDIENCE_ROOM_R,JSON.stringify({status:o.SUCCESSED,roomData:s}),r),u=t.getClientSessionId(),l=new bs(this._context,this._runtime,this._options,t._roomId,s,t.getLivingType(),u),this._crtAudienceLivingRoom=l,this._crtRoom.__destroy(!1),this._crtRoom=null,[2,{room:l,code:exports.RCRTCCode.SUCCESS,userIds:l.getRemoteUserIds(),RTCTracks:l.getRemoteRTCTracks(),MCUTracks:l.getRemoteMCUTracks(),CDNUris:l.getCDNInfo()}])}}))}))}}),Object.defineProperty(i.prototype,"getJoinedRoomInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return s(this,void 0,void 0,(function(){var t,r,i,a,s;return c(this,(function(c){switch(c.label){case 0:return t=this._logger.createTraceId(),r=this._context.getCurrentId(),this._logger.error(n.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_T,JSON.stringify({userId:r}),t),[4,this._context.getRTCJoinedUserInfo(r)];case 1:return i=c.sent(),a=i.code,s=i.data,a!==e.ErrorCode.SUCCESS?(this._logger.error(n.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:o.FAILED,code:a}),t),[2,{code:a}]):(this._logger.info(n.L_RTC_CLIENT_GET_JOINED_ROOM_INFO_R,JSON.stringify({status:o.SUCCESSED,roomInfo:s}),t),[2,{code:exports.RCRTCCode.SUCCESS,data:s}])}}))}))}}),i}(ms);exports.RTCJoinType=void 0,(Rs=exports.RTCJoinType||(exports.RTCJoinType={}))[Rs.KICK=0]="KICK",Rs[Rs.REFUSE=1]="REFUSE";var vs,Os="rtcRJoin_data",Ts="rtcRExit",Es="rtcRInfo",Ss="rtcUData",Is="rtcUDel",ys="rtcSetData",Ls="userSetData",As="rtcQryData",Ps="rtcDelData",Ns="rtcToken",ws="rtcUserState",Ds="rtcUList",ks="viewerJoinR",Us="viewerExitR",Ms="rtcPullKv",xs="rtcIdentityChange",js="rtcInvite",Bs="rtcCancelInvite",Vs="rtcInviteAnswer",Fs="rtcEndInvite",Js="rtcQueryJoined",Gs="rtcPullRoomStatus",Hs="reportsdk",Ks="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",e.AsrTextMsg="AsrTextMsg",e.AsrResTextMsg="AsrResTextMsg"}(vs||(vs={}));var Ws,Ys=((gs={})[vs.RtcInput]=["roomType","broadcastType","extraInnerData","needSysChatroom","identityChangeType","joinType","innerDatas","outerDatas","supportNtf"],gs[vs.RtcOutput]=["version"],gs[vs.RtcUserListOutput]=["users","token","sessionId","roomInfo","version"],gs[vs.SetUserStatusInput]=["status"],gs[vs.RtcSetDataInput]=["interior","target","key","value","objectName","content"],gs[vs.RtcUserSetDataInput]=["valueInfo","objectName","content"],gs[vs.RtcDataInput]=["interior","target","key","objectName","content"],gs[vs.RtcSetOutDataInput]=["target","valueInfo","objectName","content"],gs[vs.MCFollowInput]=["state"],gs[vs.RtcTokenOutput]=["rtcToken"],gs[vs.RtcQryOutput]=["outInfo"],gs[vs.RtcQryUserOutDataInput]=["userId"],gs[vs.RtcUserOutDataOutput]=["user"],gs[vs.RtcQueryListInput]=["order"],gs[vs.RtcRoomInfoOutput]=["roomId","roomData","userCount","list"],gs[vs.RtcValueInfo]=["key","value"],gs[vs.RtcKeyDeleteInput]=["key"],gs[vs.RtcNotifyMsg]=["type","time","roomId"],gs[vs.RtcPullKV]=["timestamp","roomId"],gs[vs.RtcKVOutput]=["entries","bFullUpdate","syncTime"],gs[vs.RtcQueryUserJoinedInput]=["userId"],gs[vs.RtcQueryUserJoinedOutput]=["info"],gs[vs.RtcInviteInput]=["invitedUserId","timeoutTime","invitedRoomId","inviteInfo","inviteSessionId"],gs[vs.RtcCancelInviteInput]=["invitedUserId","invitedRoomId","inviteInfo","inviteSessionId"],gs[vs.RtcInviteAnswerInput]=["inviteUserId","answerCode","inviteRoomId","inviteSessionId","content","key","value"],gs[vs.RtcEndInviteInput]=["inviteRoomId","inviteSessionId","inviteContent","inviteRoomKeys"],gs[vs.RtcRoomStatusInput]=["version"],gs[vs.RtcRoomStatusOutput]=["bFullStatus","version","usersData","roomStatus"],gs[vs.RtcReportSDKInput]=["sdkInfo"],gs[vs.RtcPBPolaris]=["type","appKey","sessionId","roomId","roomCreateTime","userId","userRole","joinTime","signalDataCenter","r1Info","r2Info","r3Info","r4Info"],gs[vs.RtcPBR1Info]=["joinTime","rtcVersion","imVersion","platform","device","os","browserName","browserVersion"],gs[vs.RtcPBR2Info]=["joinTime","sendTime","rtcActionType","rtcActionStatus","trackId"],gs[vs.RtcPBR3Info]=["info"],gs[vs.RtcPBR4Info]=["info"],gs[vs.RtcPBStatusInfo]=["joinTime","receiveTime","totalBitRate","appCPUUsage","systemCPUUsage","systemCPUFrequency","networkStatus","googleRTTNetwork","ipAddress","useReceiveBroadBand","useSendBroadBand","packetLossCount","streams"],gs[vs.RtcPBStreamInfo]=["trackId","codeName","volume","samplingRate","bitRate","packetLossRate","frameRate","resolution","blockTime","jitterData","nAckCount","pliCount","googleRTTTotalTime","isReceiveFirstFrameRate","codeType","isEnabled"],gs[vs.AsrTextMsg]=["bms","t","isEnd","msgId","lang"],gs[vs.AsrResTextMsg]=["type","uid","asr"],gs),zs="\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(vs.SetUserStatusInput,"\n {\n optional int32 status=1;\n }\n message ").concat(vs.MCFollowInput,"\n {\n required string state = 1;\n }\n message ").concat(vs.RtcQueryListInput,"{\n optional int32 order=1;\n }\n message ").concat(vs.RtcKeyDeleteInput,"{\n repeated string key=1;\n }\n message ").concat(vs.RtcValueInfo,"{\n required string key=1;\n required string value=2;\n }\n message RtcUserInfo{\n required string userId=1;\n repeated ").concat(vs.RtcValueInfo," userData=2; //用户资源信息\n }\n message ").concat(vs.RtcRoomStatusInput,"{ // rtc 和 living room 拉房间资源状态使用的参数\n required int64 version =1; //当前客户端最大的房间状态的version\n }\n message ").concat(vs.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(vs.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(vs.RtcValueInfo," roomData = 2;\n optional int32 userCount = 3;\n repeated RtcUserInfo list=4;\n }\n message ").concat(vs.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(vs.RtcValueInfo," innerDatas = 7; //用户内部inner数据,角色或者连麦信息等\n repeated ").concat(vs.RtcValueInfo," outerDatas = 8; //用户内部outer数据,自定义数据结构RtcInput。\n optional bool supportNtf = 9; //是否支持房间状态的变更通过通知拉取的方式获取\n }\n message ").concat(vs.RtcQryOutput,"{\n repeated ").concat(vs.RtcValueInfo," outInfo=1;\n }\n message ").concat(vs.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(vs.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(vs.RtcUserSetDataInput," {\n repeated ").concat(vs.RtcValueInfo," valueInfo = 1;\n required string objectName = 2;\n repeated ").concat(vs.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(vs.RtcTokenOutput,"{\n required string rtcToken=1;\n }\n message ").concat(vs.RtcSetOutDataInput,"{\n required targetType target=1;\n repeated ").concat(vs.RtcValueInfo," valueInfo=2;\n optional string objectName=3;\n optional string content=4;\n }\n message ").concat(vs.RtcQryUserOutDataInput,"{\n repeated string userId = 1;\n }\n message ").concat(vs.RtcUserOutDataOutput,"{\n repeated RtcUserInfo user = 1;\n }\n message ").concat(vs.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(vs.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(vs.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(vs.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(vs.RtcQueryUserJoinedOutput,"\n {\n repeated RtcJoinedInfo info = 1;\n }\n message ").concat(vs.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(vs.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(vs.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(vs.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(vs.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(vs.RtcReportSDKInput,' {\n required string sdkInfo=1; // 用户集成的 sdk 信息,json 格式 {"web-rtc": "4.0.3.7"}\n }\n // ---- 北极星数据上报 -------\n message ').concat(vs.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(vs.RtcPBR1Info," r1Info = 10;\n optional ").concat(vs.RtcPBR2Info," r2Info = 11;\n optional ").concat(vs.RtcPBR3Info," r3Info = 12;\n optional ").concat(vs.RtcPBR4Info," r4Info = 13;\n }\n message ").concat(vs.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(vs.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(vs.RtcPBR3Info," {\n required ").concat(vs.RtcPBStatusInfo," info = 1;\n }\n message ").concat(vs.RtcPBR4Info," {\n required ").concat(vs.RtcPBStatusInfo," info = 1;\n }\n message ").concat(vs.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(vs.RtcPBStreamInfo," streams = 13;\n }\n message ").concat(vs.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 message ").concat(vs.AsrTextMsg," {\n optional int32 bms = 1; //开始转写的时间(毫秒)\n optional string t = 2; //翻译的内容\n optional bool isEnd = 3; //是否监测到完整语句\n optional string msgId = 4; //该消息的ID, 跟转写的msgId 需要一样;\n optional string lang = 5; //翻译的目标语言码\n }\n message ").concat(vs.AsrResTextMsg," {\n optional int32 type = 1; //1 为语音识别,后续会扩展其它类型\n required string uid = 2; //对应转写的用户Id\n repeated ").concat(vs.AsrTextMsg," asr = 3; //识别出的结果列表\n }\n}\n"),qs=function(e,t,r,i,n,o,a){var s=n?Object.keys(n).map((function(t){return e.encode(vs.RtcValueInfo,{key:t,value:n[t]},!0)})):void 0,c=o?Object.keys(o).map((function(t){return e.encode(vs.RtcValueInfo,{key:t,value:o[t]},!0)})):void 0;return e.encode(vs.RtcInput,{roomType:t,broadcastType:r,joinType:i,innerDatas:s,outerDatas:c,supportNtf:a})},Qs=function(t,r){var i=t.decode(vs.RtcUserListOutput,r),n=i.users,o=i.token,a=i.sessionId,s=i.roomInfo,c=i.entries,u=i.offlineKickTime,l=void 0===u?60:u,d=i.codeFormat,_=i.roomCreateTime,p=i.userJoinTime,f=i.version,h={};return e.forEach(n,(function(t){var r=t.userId,i=t.userData,n={};e.forEach(i,(function(e){var t=e.key,r=e.value;n[t]=r})),h[r]=n})),{users:h,token:o,sessionId:a,roomInfo:s,kvEntries:c,offlineKickTime:l,codeFormat:d,roomCreateTime:At(_),userJoinTime:At(p),version:f}};!function(e){e[e.SUBTITLE=1]="SUBTITLE",e[e.TRANSLATION=2]="TRANSLATION"}(Ws||(Ws={}));var Zs,Xs=function(){function t(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(t.prototype,"joinRTCRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,n,o,a,u){return s(this,void 0,void 0,(function(){var s,l,d,_,p,f,h,b,R,g,m,C,v,O;return c(this,(function(c){switch(c.label){case 0:return s=qs(this.codec,r,i,n,o,a,u),[4,this.context.rtcSignaling(t,Os,!0,s)];case 1:return l=c.sent(),d=l.code,_=l.buffer,d===e.ErrorCode.SUCCESS&&_?(p=Qs(this.codec,_),f=p.users,h=p.token,b=p.sessionId,R=p.roomInfo,g=p.kvEntries,m=p.offlineKickTime,C=p.roomCreateTime,v=p.userJoinTime,O=p.version,this.roomCreateTime=C,this.userJoinTime=v,[2,{code:d,data:{users:f,token:h,sessionId:b,roomInfo:R,kvEntries:g,offlineKickTime:m,version:O}}]):[2,{code:d,data:p}]}}))}))}}),Object.defineProperty(t.prototype,"quitRTCRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return t=this.codec.encode(vs.SetUserStatusInput,{status:0}),[4,this.context.rtcSignaling(e,Ts,!0,t)];case 1:return[2,r.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"getRTCRoomInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,n,o,a;return c(this,(function(s){switch(s.label){case 0:return r=this.codec.encode(vs.RtcQueryListInput,{order:2}),[4,this.context.rtcSignaling(t,Es,!0,r)];case 1:return i=s.sent(),n=i.code,o=i.buffer,n===e.ErrorCode.SUCCESS&&o&&(a=this.codec.decode(vs.RtcRoomInfoOutput,o)),[2,{code:n,data:a}]}}))}))}}),Object.defineProperty(t.prototype,"getRTCUserInfoList",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,n,o,a,s;return c(this,(function(c){switch(c.label){case 0:return r=this.codec.encode(vs.RtcQueryListInput,{order:2}),[4,this.context.rtcSignaling(t,Ss,!0,r)];case 1:return i=c.sent(),n=i.code,o=i.buffer,n===e.ErrorCode.SUCCESS&&o&&(s=Qs(this.codec,o),a={users:s.users}),[2,{code:n,data:a}]}}))}))}}),Object.defineProperty(t.prototype,"getRTCUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){throw new Error("Method not implemented.")}}),Object.defineProperty(t.prototype,"removeRTCUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r;return c(this,(function(i){switch(i.label){case 0:return r=this.codec.encode(vs.RtcKeyDeleteInput,{key:t}),[4,this.context.rtcSignaling(e,Is,!1,r)];case 1:return[2,i.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"setRTCData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n,o){return s(this,void 0,void 0,(function(){var a;return c(this,(function(s){switch(s.label){case 0:return a=this.codec.encode(vs.RtcSetDataInput,{interior:i,target:n,key:t,value:r,objectName:null==o?void 0:o.name,content:null==o?void 0:o.content}),[4,this.context.rtcSignaling(e,ys,!1,a)];case 1:return[2,s.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"setRTCTotalRes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n,o){return s(this,void 0,void 0,(function(){var a,s,u=this;return c(this,(function(c){switch(c.label){case 0:return a={objectName:i,content:[],valueInfo:[this.codec.encode(vs.RtcValueInfo,{key:"uris",value:r},!0)]},t.forEach((function(e){var t=u.codec.encode(vs.RtcValueInfo,{key:e.name,value:e.content},!0);a.content.push(t)})),n&&a.valueInfo.push(this.codec.encode(vs.RtcValueInfo,{key:"mcu_uris",value:n},!0)),o&&a.valueInfo.push(this.codec.encode(vs.RtcValueInfo,{key:"cdn_uris",value:o},!0)),s=this.codec.encode(vs.RtcUserSetDataInput,a),[4,this.context.rtcSignaling(e,Ls,!0,s)];case 1:return[2,c.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"setRTCCDNUris",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return s(this,void 0,void 0,(function(){var i;return c(this,(function(n){switch(n.label){case 0:return i=this.codec.encode(vs.RtcUserSetDataInput,{objectName:t,valueInfo:this.codec.encode(vs.RtcValueInfo,{key:"cdn_uris",value:r},!0)}),[4,this.context.rtcSignaling(e,Ls,!0,i)];case 1:return[2,n.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"getRTCData",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,n){return s(this,void 0,void 0,(function(){var o,a,s,u,l,d;return c(this,(function(c){switch(c.label){case 0:return o=this.codec.encode(vs.RtcDataInput,{interior:i,target:n,key:r}),[4,this.context.rtcSignaling(t,As,!0,o)];case 1:return a=c.sent(),s=a.code,u=a.buffer,s===e.ErrorCode.SUCCESS&&u?(l=this.codec.decode(vs.RtcQryOutput,u).outInfo,d={},l.forEach((function(e){d[e.key]=e.value})),[2,{code:s,data:d}]):[2,{code:s}]}}))}))}}),Object.defineProperty(t.prototype,"removeRTCData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i,n){return s(this,void 0,void 0,(function(){var o;return c(this,(function(a){switch(a.label){case 0:return o=this.codec.encode(vs.RtcDataInput,{interior:r,target:i,key:t,objectName:(null==n?void 0:n.name)||"",content:(null==n?void 0:n.content)||""}),[4,this.context.rtcSignaling(e,Ps,!1,o)];case 1:return[2,a.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"setRTCOutData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,i){return s(this,void 0,void 0,(function(){return c(this,(function(e){throw new Error("JSEngine's method not implemented.")}))}))}}),Object.defineProperty(t.prototype,"getRTCOutData",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){return c(this,(function(e){throw new Error("JSEngine's method not implemented.")}))}))}}),Object.defineProperty(t.prototype,"getRTCToken",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var n,o,a,s,u;return c(this,(function(c){switch(c.label){case 0:return n=qs(this.codec,r,i),[4,this.context.rtcSignaling(t,Ns,!0,n)];case 1:return o=c.sent(),a=o.code,s=o.buffer,a===e.ErrorCode.SUCCESS&&s?(u=this.codec.decode(vs.RtcTokenOutput,s).rtcToken,[2,{code:a,data:{rtcToken:u}}]):[2,{code:a}]}}))}))}}),Object.defineProperty(t.prototype,"setRTCState",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return s(this,void 0,void 0,(function(){var r;return c(this,(function(i){switch(i.label){case 0:return r=this.codec.encode(vs.MCFollowInput,{state:t}),[4,this.context.rtcSignaling(e,ws,!0,r)];case 1:return[2,i.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"setRTCStateByHttp",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i,n){var o;return s(this,void 0,void 0,(function(){var s,u,l;return c(this,(function(c){switch(c.label){case 0:s=function(e,t,r){var i=t.type,n=t.appKey,o=t.sessionId,s=t.roomId,c=t.roomCreateTime,u=t.userId,l=t.userRole,d=t.joinTime,_=t.signalDataCenter,p=t.r1Info,f=t.r2Info,h=t.r3Info,b=t.r4Info,R={type:i,appKey:n,sessionId:o,roomId:s,roomCreateTime:c,userId:u,userRole:l,joinTime:d,signalDataCenter:_};if(r===Na.R1&&p){var g=e.encode(vs.RtcPBR1Info,p,!0);return e.encode(vs.RtcPBPolaris,a(a({},R),{r1Info:g}))}if(r===Na.R2&&f){var m=e.encode(vs.RtcPBR2Info,f,!0);return e.encode(vs.RtcPBPolaris,a(a({},R),{r2Info:m}))}if(r===Na.R3&&h){var C=(E=h.info).streams,v=Array.isArray(C)&&C.map((function(t){return t&&e.encode(vs.RtcPBStreamInfo,t,!0)})),O=e.encode(vs.RtcPBStatusInfo,a(a({},E),{streams:v}),!0),T=e.encode(vs.RtcPBR3Info,{info:O},!0);return e.encode(vs.RtcPBPolaris,a(a({},R),{r3Info:T}))}if(r===Na.R4&&b){C=(E=b.info).streams,v=Array.isArray(C)&&C.map((function(t){return t&&e.encode(vs.RtcPBStreamInfo,t,!0)})),O=e.encode(vs.RtcPBStatusInfo,a(a({},E),{streams:v}),!0);var E,S=e.encode(vs.RtcPBR4Info,{info:O},!0);return e.encode(vs.RtcPBPolaris,a(a({},R),{r4Info:S}))}return{}}(this.codec,i,n),u=t,/^https:\/\//.test(t)||(u="https://".concat(t)),c.label=1;case 1:return c.trys.push([1,3,,4]),[4,r.httpReq({url:"".concat(u,"/rtc/logserver/polaris"),body:s,method:e.HttpMethod.POST,headers:{jwt:(null===(o=this.context.getNaviInfo())||void 0===o?void 0:o.jwt)||""},timeout:2e3})];case 2:if(!(l=c.sent()).data)throw new Error("http request fail");return[2,JSON.parse(l.data).resultCode];case 3:return c.sent(),[2,Pa.REPORT_FAIL];case 4:return[2]}}))}))}}),Object.defineProperty(t.prototype,"getRTCUserList",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,n,o,a;return c(this,(function(s){switch(s.label){case 0:return r=this.codec.encode(vs.RtcQueryListInput,{order:2}),[4,this.context.rtcSignaling(t,Ds,!0,r)];case 1:return i=s.sent(),n=i.code,o=i.buffer,n===e.ErrorCode.SUCCESS&&o?(a=Qs(this.codec,o),[2,{code:n,data:a}]):[2,{code:n}]}}))}))}}),Object.defineProperty(t.prototype,"joinLivingRoomAsAudience",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var n,o,a,s,u,l,d,_,p;return c(this,(function(c){switch(c.label){case 0:return n=qs(this.codec,r,i),[4,this.context.rtcSignaling(t,ks,!0,n)];case 1:return o=c.sent(),a=o.code,s=o.buffer,a===e.ErrorCode.SUCCESS&&s?(u=this.codec.decode(vs.RtcViewerJoinedOutput,s),l=u.rtcToken,d=u.entries,_=u.roomCreateTime,p=u.userJoinTime,this.roomCreateTime=At(_),this.userJoinTime=At(p),[2,{code:a,data:{token:l,kvEntries:d}}]):[2,{code:a}]}}))}))}}),Object.defineProperty(t.prototype,"quitLivingRoomAsAudience",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return t=this.codec.encode(vs.SetUserStatusInput,{status:0}),[4,this.context.rtcSignaling(e,Us,!0,t)];case 1:return[2,r.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"rtcIdentityChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var n,o,a,s,u;return c(this,(function(c){switch(c.label){case 0:return n=this.codec.encode(vs.RtcInput,{roomType:exports.RTCMode.LIVE,broadcastType:i,identityChangeType:r,needSysChatroom:!1}),[4,this.context.rtcSignaling(t,xs,!0,n)];case 1:return o=c.sent(),a=o.code,s=o.buffer,a===e.ErrorCode.SUCCESS&&s?(u=Qs(this.codec,s),[2,{code:a,data:u}]):[2,{code:a}]}}))}))}}),Object.defineProperty(t.prototype,"requestRoomPK",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t,r,i,n,o,a,s;return c(this,(function(c){switch(c.label){case 0:return t=e.invitedRoomId,r=e.invitedUserId,i=e.inviteSessionId,n=e.inviteTimeout,o=e.inviteInfo,a=e.roomId,s=this.codec.encode(vs.RtcInviteInput,{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,timeoutTime:n,inviteInfo:o}),[4,this.context.rtcSignaling(a,js,!0,s)];case 1:return[2,c.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"cancelRoomPK",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t,r,i,n,o,a;return c(this,(function(s){switch(s.label){case 0:return t=e.invitedRoomId,r=e.invitedUserId,i=e.inviteSessionId,n=e.inviteInfo,o=e.roomId,a=this.codec.encode(vs.RtcCancelInviteInput,{invitedRoomId:t,invitedUserId:r,inviteSessionId:i,inviteInfo:n}),[4,this.context.rtcSignaling(o,Bs,!0,a)];case 1:return[2,s.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"responseRoomPK",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t,r,i,n,o,a,s,u,l;return c(this,(function(c){switch(c.label){case 0:return t=e.inviteUserId,r=e.inviteRoomId,i=e.inviteSessionId,n=e.content,o=e.key,a=e.value,s=e.agree,u=e.roomId,l=this.codec.encode(vs.RtcInviteAnswerInput,{inviteUserId:t,inviteRoomId:r,inviteSessionId:i,content:n,key:o,value:a,answerCode:s?1:0}),[4,this.context.rtcSignaling(u,Vs,!0,l)];case 1:return[2,c.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"endRoomPK",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return s(this,void 0,void 0,(function(){var t,r,i,n,o,a;return c(this,(function(s){switch(s.label){case 0:return t=e.endRoomId,r=e.sessionId,i=e.content,n=e.keys,o=e.roomId,a=this.codec.encode(vs.RtcEndInviteInput,{inviteRoomId:t,inviteSessionId:r,inviteContent:i,inviteRoomKeys:n}),[4,this.context.rtcSignaling(o,Fs,!0,a)];case 1:return[2,s.sent().code]}}))}))}}),Object.defineProperty(t.prototype,"getRTCJoinedUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,n,o,a;return c(this,(function(s){switch(s.label){case 0:return r=this.codec.encode(vs.RtcQueryUserJoinedInput,{userId:t}),[4,this.context.rtcSignaling("",Js,!0,r)];case 1:return i=s.sent(),n=i.code,o=i.buffer,n===e.ErrorCode.SUCCESS&&o?(a=this.codec.decode(vs.RtcQueryUserJoinedOutput,o).info||[],[2,{code:n,data:a.map((function(e){return{deviceId:e.deviceId,roomId:e.roomId,joinTime:At(e.joinTime)}}))}]):[2,{code:n}]}}))}))}}),Object.defineProperty(t.prototype,"pullRTCRoomEntry",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return s(this,void 0,void 0,(function(){var r,i,n,o,s,u,l;return c(this,(function(c){switch(c.label){case 0:return r=this.codec.encode(vs.RtcPullKV,{timestamp:0,roomId:t}),[4,this.context.rtcSignaling(t,Ms,!0,r)];case 1:return i=c.sent(),n=i.code,o=i.buffer,n!==e.ErrorCode.SUCCESS?[2,{code:n}]:(s=this.codec.decode(vs.RtcKVOutput,o),u=s.entries,l=s.syncTime,u=(u||[]).map((function(e){return a(a({},e),{timestamp:At(e.timestamp)})})),[2,{code:n,data:{kvEntries:u,syncTime:At(l)}}])}}))}))}}),Object.defineProperty(t.prototype,"pullRTCRoomStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return s(this,void 0,void 0,(function(){var i,n,o,a,s;return c(this,(function(c){switch(c.label){case 0:return i=this.codec.encode(vs.RtcRoomStatusInput,{version:r}),[4,this.context.rtcSignaling(t,Gs,!0,i)];case 1:return n=c.sent(),o=n.code,a=n.buffer,o!==e.ErrorCode.SUCCESS?[2,{code:o}]:(s=this.codec.decode(vs.RtcRoomStatusOutput,a),[2,{code:o,data:s}])}}))}))}}),Object.defineProperty(t.prototype,"decodeRtcNotify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.codec.decode(vs.RtcNotifyMsg,e),r=t.time,i=t.type,n=t.roomId;return{time:At(r),type:i,roomId:n}}}),Object.defineProperty(t.prototype,"getCurrentId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context.getCurrentId()}}),Object.defineProperty(t.prototype,"getNaviInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context.getNaviInfo()}}),Object.defineProperty(t.prototype,"getConnectionStatus",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context.getConnectionStatus()}}),Object.defineProperty(t.prototype,"getAppkey",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context.getAppkey()}}),Object.defineProperty(t.prototype,"webRtcPing",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,i){return s(this,void 0,void 0,(function(){var n,o,a,s,u;return c(this,(function(c){switch(c.label){case 0:return n=this.codec.encode(vs.RtcInput,{roomType:r,broadcastType:i}),[4,this.context.rtcSignaling(t,Ks,!0,n)];case 1:return o=c.sent(),a=o.code,s=o.buffer,a!==e.ErrorCode.SUCCESS?[2,{code:a}]:((u=this.codec.decode(vs.RtcOutput,s)).version=At(u.version),[2,{code:a,data:u}])}}))}))}}),Object.defineProperty(t.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(t.prototype,"sendMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r){return this.context.sendMessage(e,t,r)}}),Object.defineProperty(t.prototype,"registerRTCSignalListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.context.registerRTCSignalListener(e)}}),Object.defineProperty(t.prototype,"registerConnectionStateChangeListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.context.onconnectionstatechange=e}}),Object.defineProperty(t.prototype,"registerDisconnectListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.context.ondisconnect=e}}),Object.defineProperty(t.prototype,"registerDestroyListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.context.ondestroy=e}}),Object.defineProperty(t.prototype,"registerMessageListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.context.onmessage=e}}),Object.defineProperty(t.prototype,"getCoreVersion",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context.getCoreVersion()}}),Object.defineProperty(t.prototype,"getPluginContext",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.context}}),Object.defineProperty(t.prototype,"reportSDKInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.codec.encode(vs.RtcReportSDKInput,{sdkInfo:JSON.stringify(e)});this.context.rtcSignaling("",Hs,!0,t)}}),Object.defineProperty(t.prototype,"decodeAsrText",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.codec.decode(vs.AsrResTextMsg,e),r=t.type,i=t.uid;return t.asr.map((function(e){var t=e.bms,n=e.t,o=e.isEnd,s=e.msgId,c=e.lang,u={userID:i,timeUTC:t,msg:n,msgId:s,isEnd:o};return r===Ws.SUBTITLE?u:a(a({},u),{destLangCode:c})}))}}),t}();!function(e){e.RTC="RTC"}(Zs||(Zs={})),e.VersionManage.add("rtclib","5.34.0-alpha.1");var $s={tag:"RCRTC",verify:function(t){return"undefined"==typeof isSecureContext||isSecureContext?!!e.VersionManage.validEngine("5.32.0")||(console.error("The current engine version '".concat(e.VersionManage.getInfo().engine,"' error, plugin-rtc required engine version at least '").concat("5.32.0","'.")),!1):(console.error("Please use the https protocol or use `http://localhost` to open the page!"),!1)},setup:function(t,r,i){void 0===i&&(i={});var o=t.createLogger("RCRTC",Zs.RTC);if(i.logLevel&&o.setOutputLevel(i.logLevel),o.warn(n.L_INDEX_INSTALL_RTC_PLUGIN_O,JSON.stringify({"RCRTC Version":"5.34.0-alpha.1",Commit:"e7405a886c9fa17b3ec60cc6ecc985a934b14e97","browserInfo.browser":Ct.browser,"browserInfo.supportsUnifiedPlan":Ct.supportsUnifiedPlan,"browserInfo.version":Ct.version})),e.assert("options",i,e.AssertRules.OBJECT,!0),e.assert("options.mediaServer",i.mediaServer,(function(t){return!(!e.isHttpUrl(t)||"https:"===location.protocol&&!/^https/.test(t))})),e.assert("options.timeout",i.timeout,(function(t){return e.isNumber(t)&&t>=5e3&&t<=3e4})),e.assert("options.pingGap",i.pingGap,(function(t){return e.isNumber(t)&&t>=3e3&&t<=1e4})),i.AAAWorklet){e.assert("options.AAAWorklet",i.AAAWorklet,e.AssertRules.OBJECT,!0);var a=i.AAAWorklet,s=a.scriptUrl,c=a.wasmUrl;e.assert("AAAWorklet.scriptUrl",s,e.AssertRules.STRING,!0),e.assert("AAAWorklet.wasmUrl",c,e.AssertRules.STRING,!0),He.SCRIPT_URL=s,He.WASM_URL=c}return i.encryptor&&(e.assert("options.encrypt",i.encryptor,e.AssertRules.OBJECT,!0),e.assert("options.encrypt.decodeAudio",i.encryptor.decodeAudio,(function(e){return"function"==typeof e}),!0),e.assert("options.encrypt.decodeVideo",i.encryptor.decodeVideo,(function(e){return"function"==typeof e}),!0),e.assert("options.encrypt.encodeAudio",i.encryptor.encodeAudio,(function(e){return"function"==typeof e}),!0),e.assert("options.encrypt.encodeVideo",i.encryptor.encodeVideo,(function(e){return"function"==typeof e}),!0),lo.init(i.encryptor,o)),new Cs(new Xs(t,o,t.createCodec(Ys,zs)),r,i)}},ec={transResolution:bt,transFrameRate:mt,parseTrackId:dt,ifSupportLocalFileTrack:vt,ifSupportScreenShare:Ot};exports.RCAbstractRoom=za,exports.RCAudienceClient=ps,exports.RCAudienceLivingRoom=bs,exports.RCCameraVideoTrack=Xe,exports.RCLivingRoom=cs,exports.RCLocalAudioTrack=We,exports.RCLocalFileAudioTrack=Qe,exports.RCLocalFileTrack=ze,exports.RCLocalFileVideoTrack=qe,exports.RCLocalTrack=Ke,exports.RCLocalVideoTrack=Ye,exports.RCMCUConfigBuilder=Xa,exports.RCMediaStreamCapture=ms,exports.RCMicphoneAudioTrack=Ze,exports.RCRTCClient=Cs,exports.RCRTCRoom=us,exports.RCRemoteAudioTrack=rt,exports.RCRemoteTrack=tt,exports.RCRemoteVideoTrack=it,exports.RCScreenAudioTrack=et,exports.RCScreenVideoTrack=$e,exports.RCTag={DEFAULT:"RongCloudRTC"},exports.RCTrack=Ve,exports.device=Me,exports.helper=ec,exports.installer=$s;
|