aliyun-aliplayer 2.16.0 → 2.26.1-beta.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.
Files changed (72) hide show
  1. package/README.md +4 -0
  2. package/build/aliplayer-ac-min.js +2 -0
  3. package/build/aliplayer-flash-min.js +2 -0
  4. package/build/aliplayer-h5-min.js +2 -0
  5. package/build/aliplayer-min.js +2 -0
  6. package/build/aliplayer-worker-min.js +2 -0
  7. package/build/dash/aliplayer-dash-min.js +3 -0
  8. package/build/drm/aliplayer-drm-min.js +876 -0
  9. package/build/flv/aliplayer-flv-min.js +7 -0
  10. package/build/hls/aliplayer-hls-min.js +22 -0
  11. package/build/hls/aliplayer-hls2-demuxer-min.js +2 -0
  12. package/build/hls/aliplayer-hls2-min.js +4 -0
  13. package/build/hls/aliplayer-remuxer-min.js +1 -0
  14. package/build/hls/aliplayer-vod-anti-min.js +1 -0
  15. package/build/hls/aliplayer-vod-min.js +1 -0
  16. package/build/hls/aliplayer-vod-p-min.js +1 -0
  17. package/{dist → build}/lang/en-us.json +41 -10
  18. package/{dist → build}/lang/zh-cn.json +41 -10
  19. package/build/rts/aliyun-rts-sdk.js +6 -0
  20. package/build/skins/default/aliplayer-min.css +1 -0
  21. package/package.json +10 -8
  22. package/dist/aliplayer-min.js +0 -2
  23. package/dist/lang/all.json +0 -154
  24. package/dist/skins/default/aliplayer-min.css +0 -1
  25. /package/{dist → build}/json/json.min.js +0 -0
  26. /package/{dist → build}/lang/flash/en-us.json +0 -0
  27. /package/{dist → build}/lang/flash/zh-cn.json +0 -0
  28. /package/{dist → build}/skins/default/img/bigpause.png +0 -0
  29. /package/{dist → build}/skins/default/img/bigplay.png +0 -0
  30. /package/{dist → build}/skins/default/img/bigreplay.png +0 -0
  31. /package/{dist → build}/skins/default/img/cc.png +0 -0
  32. /package/{dist → build}/skins/default/img/cursorhover.png +0 -0
  33. /package/{dist → build}/skins/default/img/cursori.png +0 -0
  34. /package/{dist → build}/skins/default/img/defaultSkin.png +0 -0
  35. /package/{dist → build}/skins/default/img/dragcursor.png +0 -0
  36. /package/{dist → build}/skins/default/img/dragcursorhover.png +0 -0
  37. /package/{dist → build}/skins/default/img/fullscreen.png +0 -0
  38. /package/{dist → build}/skins/default/img/fullscreenhover.png +0 -0
  39. /package/{dist → build}/skins/default/img/pause.png +0 -0
  40. /package/{dist → build}/skins/default/img/pauseanimation.png +0 -0
  41. /package/{dist → build}/skins/default/img/play.png +0 -0
  42. /package/{dist → build}/skins/default/img/playanimation.png +0 -0
  43. /package/{dist → build}/skins/default/img/prismplayer.png +0 -0
  44. /package/{dist → build}/skins/default/img/replaybig.png +0 -0
  45. /package/{dist → build}/skins/default/img/resource-min.css +0 -0
  46. /package/{dist → build}/skins/default/img/resource.css +0 -0
  47. /package/{dist → build}/skins/default/img/retryclick.png +0 -0
  48. /package/{dist → build}/skins/default/img/retryhover.png +0 -0
  49. /package/{dist → build}/skins/default/img/retrynormal.png +0 -0
  50. /package/{dist → build}/skins/default/img/setting.png +0 -0
  51. /package/{dist → build}/skins/default/img/smallpause.png +0 -0
  52. /package/{dist → build}/skins/default/img/smallpausehover.png +0 -0
  53. /package/{dist → build}/skins/default/img/smallplay.png +0 -0
  54. /package/{dist → build}/skins/default/img/smallplayhover.png +0 -0
  55. /package/{dist → build}/skins/default/img/smallscreen.png +0 -0
  56. /package/{dist → build}/skins/default/img/smallscreenhover.png +0 -0
  57. /package/{dist → build}/skins/default/img/snapshot.png +0 -0
  58. /package/{dist → build}/skins/default/img/snapshotback.png +0 -0
  59. /package/{dist → build}/skins/default/img/snapshothover.png +0 -0
  60. /package/{dist → build}/skins/default/img/snapshothoverback.png +0 -0
  61. /package/{dist → build}/skins/default/img/unmutevolume.png +0 -0
  62. /package/{dist → build}/skins/default/img/volume.png +0 -0
  63. /package/{dist → build}/skins/default/img/volumehover.png +0 -0
  64. /package/{dist → build}/skins/default/img/volumemute.png +0 -0
  65. /package/{dist → build}/skins/default/img/volumemutehover.png +0 -0
  66. /package/{dist → build}/skins/default/img/volumncursor.png +0 -0
  67. /package/{dist → build}/skins/default/img/volumncursorhover.png +0 -0
  68. /package/{dist → build}/skins/default/img/volumnsmall.png +0 -0
  69. /package/{dist → build}/skins/default/img/voumnsamllhover.png +0 -0
  70. /package/{dist → build}/skins/default/resource-min.css +0 -0
  71. /package/{dist → build}/skins/sprite/classic/resource-min.css +0 -0
  72. /package/{dist → build}/skins/sprite/classic/resource.css +0 -0
@@ -0,0 +1,6 @@
1
+ /*! aliyun rts sdk - ver2.7.2 created:2023/12/29 10:44:10 */
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=31)}([function(e,t,r){"use strict";var n=r(20),i=Object.prototype.toString;function o(e){return"[object Array]"===i.call(e)}function a(e){return void 0===e}function s(e){return null!==e&&"object"==typeof e}function c(e){if("[object Object]"!==i.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function u(e){return"[object Function]"===i.call(e)}function d(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),o(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}e.exports={isArray:o,isArrayBuffer:function(e){return"[object ArrayBuffer]"===i.call(e)},isBuffer:function(e){return null!==e&&!a(e)&&null!==e.constructor&&!a(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isPlainObject:c,isUndefined:a,isDate:function(e){return"[object Date]"===i.call(e)},isFile:function(e){return"[object File]"===i.call(e)},isBlob:function(e){return"[object Blob]"===i.call(e)},isFunction:u,isStream:function(e){return s(e)&&u(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:d,merge:function e(){var t={};function r(r,n){c(t[n])&&c(r)?t[n]=e(t[n],r):c(r)?t[n]=e({},r):o(r)?t[n]=r.slice():t[n]=r}for(var n=0,i=arguments.length;n<i;n++)d(arguments[n],r);return t},extend:function(e,t,r){return d(t,(function(t,i){e[i]=r&&"function"==typeof t?n(t,r):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},function(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.PUB_RECONNECT_ERROR_LIST=t.SUB_RECONNECT_ERROR_EXCLUDE_LIST=t.SUB_RECONNECT_ERROR_LIST=t.DeviceErrorCode=t.ErrorCode=void 0,function(e){e[e.ERROR_DEVICE_UNKNOWNERROR=1e4]="ERROR_DEVICE_UNKNOWNERROR",e[e.ERROR_DEVICE_AUDIODEVICE_NOTFOUND=10001]="ERROR_DEVICE_AUDIODEVICE_NOTFOUND",e[e.ERROR_DEVICE_VIDEODEVICE_NOTFOUND=10002]="ERROR_DEVICE_VIDEODEVICE_NOTFOUND",e[e.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED=10003]="ERROR_DEVICE_AUDIODEVICE_NOTALLOWED",e[e.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED=10004]="ERROR_DEVICE_VIDEODEVICE_NOTALLOWED",e[e.ERROR_DEVICE_AUDIODEVICE_NOTREADABLE=10005]="ERROR_DEVICE_AUDIODEVICE_NOTREADABLE",e[e.ERROR_DEVICE_VIDEODEVICE_NOTREADABLE=10006]="ERROR_DEVICE_VIDEODEVICE_NOTREADABLE",e[e.ERROR_DEIVCE_CONSTRAINEDERROR=10007]="ERROR_DEIVCE_CONSTRAINEDERROR",e[e.ERROR_SCREENSHARE_UNKNOWNERRO=10010]="ERROR_SCREENSHARE_UNKNOWNERRO",e[e.ERROR_SCREENSHARE_NOTALLOWED=10011]="ERROR_SCREENSHARE_NOTALLOWED",e[e.ERROR_SCREENSHARE_ENDED=10012]="ERROR_SCREENSHARE_ENDED",e[e.ERROR_SCREENSHARE_NOPERMISSION=10013]="ERROR_SCREENSHARE_NOPERMISSION",e[e.ERROR_SCREENSHARE_INVALIDACCESS=10014]="ERROR_SCREENSHARE_INVALIDACCESS",e[e.ERROR_SCREENSHARE_NOTSUPPORT=10018]="ERROR_SCREENSHARE_NOTSUPPORT",e[e.ERROR_DEVICE_NOTSUPPORT=10019]="ERROR_DEVICE_NOTSUPPORT",e[e.ERROR_SIGNAL_ERROR=10101]="ERROR_SIGNAL_ERROR",e[e.ERROR_PLAY_FAILED=10102]="ERROR_PLAY_FAILED",e[e.ERROR_NOTSUPPORT_WEBRTC=10110]="ERROR_NOTSUPPORT_WEBRTC",e[e.ERROR_BROWSER_NOTSUPPORT=10111]="ERROR_BROWSER_NOTSUPPORT",e[e.ERROR_BROWSER_VERSIONLOW=10112]="ERROR_BROWSER_VERSIONLOW",e[e.ERROR_NOTSUPPORT_H264=10113]="ERROR_NOTSUPPORT_H264",e[e.ERROR_CREATEOFFER=10114]="ERROR_CREATEOFFER",e[e.ERROR_NO_DATACHANNEL=10115]="ERROR_NO_DATACHANNEL",e[e.ERROR_INIT_LOCAL_FAIL=10116]="ERROR_INIT_LOCAL_FAIL",e[e.ERROR_HEMLELEMENT_NOTMATCH=10125]="ERROR_HEMLELEMENT_NOTMATCH",e[e.ERROR_AUTOPLAY_ERROR=10201]="ERROR_AUTOPLAY_ERROR",e[e.ERROR_PLAY_URL=10202]="ERROR_PLAY_URL",e[e.ERROR_SUBSCRIBE_NOTHING=10203]="ERROR_SUBSCRIBE_NOTHING",e[e.ERROR_HTMLELEMENT_ERROR=10204]="ERROR_HTMLELEMENT_ERROR",e[e.ERROR_HTTPREQUEST_ERROR=10205]="ERROR_HTTPREQUEST_ERROR",e[e.ERROR_ANSWER_ERROR=10206]="ERROR_ANSWER_ERROR",e[e.ERROR_INBOUND_TIMEOUT=10207]="ERROR_INBOUND_TIMEOUT",e[e.ERROR_STREAM_ENDED=10208]="ERROR_STREAM_ENDED",e[e.ERROR_PC_DISCONNECTED=10209]="ERROR_PC_DISCONNECTED",e[e.ERROR_TRANSPORT_CLOSED=10210]="ERROR_TRANSPORT_CLOSED",e[e.ERROR_SIGNAL_URL=10211]="ERROR_SIGNAL_URL",e[e.ERROR_PUBLISH_URL=10300]="ERROR_PUBLISH_URL",e[e.ERROR_PUBLISH_NOAUDIO=10301]="ERROR_PUBLISH_NOAUDIO",e[e.ERROR_DATACHANNEL_PARAM=10500]="ERROR_DATACHANNEL_PARAM",e[e.ERROR_DATACHANNEL_OPEN=10501]="ERROR_DATACHANNEL_OPEN",e[e.ERROR_MEDIASTREAMTRACK_TYPE_ERROR=11e3]="ERROR_MEDIASTREAMTRACK_TYPE_ERROR",e[e.ERROR_MEDIASTREAMTRACK_KIND_ERROR=11001]="ERROR_MEDIASTREAMTRACK_KIND_ERROR",e[e.ERROR_MEDIASTREAMTRACK_AUDIO_NONE=11002]="ERROR_MEDIASTREAMTRACK_AUDIO_NONE",e[e.ERROR_CUSTOMSTREAM_NONE=11003]="ERROR_CUSTOMSTREAM_NONE",e[e.ERROR_CUSTOMSTREAM_INVALID=11004]="ERROR_CUSTOMSTREAM_INVALID",e[e.ERROR_CUSTOMSTREAM_TRACK_NONE=11005]="ERROR_CUSTOMSTREAM_TRACK_NONE",e[e.ERROR_PREERCONNECTION_UNKNOWN=12e3]="ERROR_PREERCONNECTION_UNKNOWN",e[e.ERROR_SUBADD_NO_RESULT=13e3]="ERROR_SUBADD_NO_RESULT",e[e.ERROR_PUBADD_NO_RESULT=13001]="ERROR_PUBADD_NO_RESULT"}(n=t.ErrorCode||(t.ErrorCode={})),function(e){e[e.ERROR_DEVICE_UNKNOWNERROR=1e4]="ERROR_DEVICE_UNKNOWNERROR",e[e.ERROR_DEVICE_AUDIODEVICE_NOTFOUND=10001]="ERROR_DEVICE_AUDIODEVICE_NOTFOUND",e[e.ERROR_DEVICE_VIDEODEVICE_NOTFOUND=10002]="ERROR_DEVICE_VIDEODEVICE_NOTFOUND",e[e.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED=10003]="ERROR_DEVICE_AUDIODEVICE_NOTALLOWED",e[e.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED=10004]="ERROR_DEVICE_VIDEODEVICE_NOTALLOWED",e[e.ERROR_DEVICE_AUDIODEVICE_NOTREADABLE=10005]="ERROR_DEVICE_AUDIODEVICE_NOTREADABLE",e[e.ERROR_DEVICE_VIDEODEVICE_NOTREADABLE=10006]="ERROR_DEVICE_VIDEODEVICE_NOTREADABLE",e[e.ERROR_SCREENSHARE_NOTSUPPORT=10010]="ERROR_SCREENSHARE_NOTSUPPORT",e[e.ERROR_SCREENSHARE_NOTALLOWED=10011]="ERROR_SCREENSHARE_NOTALLOWED",e[e.ERROR_SCREENSHARE_ENDED=10012]="ERROR_SCREENSHARE_ENDED",e[e.ERROR_SCREENSHARE_NOPERMISSION=10013]="ERROR_SCREENSHARE_NOPERMISSION",e[e.ERROR_SCREENSHARE_SAFARI_INVALIDACCESS=10014]="ERROR_SCREENSHARE_SAFARI_INVALIDACCESS",e[e.ERROR_SCREENSHARE_UNKNOWNERRO=10019]="ERROR_SCREENSHARE_UNKNOWNERRO",e[e.ERROR_DEVICE_NOTSUPPORT=2e4]="ERROR_DEVICE_NOTSUPPORT"}(t.DeviceErrorCode||(t.DeviceErrorCode={})),t.SUB_RECONNECT_ERROR_LIST=[n.ERROR_INBOUND_TIMEOUT,n.ERROR_STREAM_ENDED,n.ERROR_PC_DISCONNECTED],t.SUB_RECONNECT_ERROR_EXCLUDE_LIST=[n.ERROR_AUTOPLAY_ERROR,n.ERROR_PLAY_URL,n.ERROR_SUBSCRIBE_NOTHING,n.ERROR_HTMLELEMENT_ERROR,n.ERROR_HEMLELEMENT_NOTMATCH],t.PUB_RECONNECT_ERROR_LIST=[n.ERROR_PC_DISCONNECTED,n.ERROR_TRANSPORT_CLOSED]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){this._eventMap={}}return e.prototype.listeners=function(e){return this._eventMap[e]||[]},e.prototype.emit=function(e){for(var t=this,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=this._eventMap[e];return!!Array.isArray(i)&&(i.forEach((function(e){return e.apply(t,r)})),!0)},e.prototype.off=function(e,t){var r=this._eventMap[e];return Array.isArray(r)&&(this._eventMap[e]=r.filter((function(e){return e!==t}))),this},e.prototype.removeAllListeners=function(e){return void 0===e?this._eventMap={}:this._eventMap[e]&&(this._eventMap[e]=[]),this},e.prototype.on=function(e,t){return this._eventMap[e]?this._eventMap[e].push(t):this._eventMap[e]=[t],this},e.prototype.once=function(e,t){var r=this,n=function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];r.off(e,n),t.apply(r,i)};return this.on(e,n),this},e}();t.default=n},function(e,t,r){
3
+ /*! useragent-util - ver 1.3.0 created:2023/11/2 21:14:25 */
4
+ self,e.exports=(()=>{"use strict";var e={622:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserUtil=t.BrowserType=void 0;var n,i=r(101);!function(e){e.IE="IE",e.Chrome="Chrome",e.Safari="Safari",e.Firefox="Firefox",e.Opera="Opera",e.Edge="Edge",e.MicroMessenger="MicroMessenger",e.X5Core="X5Core",e.Quark="Quark",e.QQ="QQ",e.QQBrowser="QQBrowser",e.DingTalk="DingTalk",e.Electron="Electron",e.Sogou="Sogou",e.Vivo="VivoBrowser",e.Oppo="OppoBrowser",e.UC="UCBrowser",e.MI="MiBrowser",e.Lenovo="SLBrowser",e.Maxthon="Maxthon",e.Liebao="Liebao",e.Huawei="Huawei",e.Meizu="MZBrowser",e.Finger="FingerBrowser",e.Samsung="SamsungBrowser",e.WebVeiw="WebVeiw",e.Unknown="unknown"}(n=t.BrowserType||(t.BrowserType={}));var o=function(){function e(){}return Object.defineProperty(e,"isBrowser",{get:function(){return"undefined"!=typeof document},enumerable:!1,configurable:!0}),Object.defineProperty(e,"domain",{get:function(){return window.location.protocol+window.location.host},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isHttps",{get:function(){return this.isBrowser&&document.location&&("https:"==document.location.protocol||0===document.location.host.indexOf("127.0.0.1:")||0===document.location.host.indexOf("localhost:"))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isSupportScreenShare",{get:function(){return!!(navigator&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isChrome",{get:function(){return e._getBrowserInfo(),n.Chrome===e._browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isSafari",{get:function(){return e._getBrowserInfo(),n.Safari===e._browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isIE",{get:function(){return e._getBrowserInfo(),n.IE===e._browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isFirefox",{get:function(){return e._getBrowserInfo(),n.Firefox===e._browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isEdge",{get:function(){return e._getBrowserInfo(),n.Edge===e.browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isSogou",{get:function(){return e._getBrowserInfo(),n.Sogou===e.browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isVivoBroswer",{get:function(){return e._getBrowserInfo(),n.Vivo===e.browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isOppoBrowser",{get:function(){return e._getBrowserInfo(),n.Oppo===e.browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isMiBrowser",{get:function(){return e._getBrowserInfo(),n.MI===e.browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isLenovoBrowser",{get:function(){return e._getBrowserInfo(),n.Lenovo===e.browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isMaxthonBrowser",{get:function(){return e._getBrowserInfo(),n.Maxthon===e.browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isLiebaoBrowser",{get:function(){return e._getBrowserInfo(),n.Liebao===e.browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isHuaweiBrowser",{get:function(){return e._getBrowserInfo(),n.Huawei===e.browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isMZBrowser",{get:function(){return e._getBrowserInfo(),n.Meizu===e._browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isSamsungBrowser",{get:function(){return e._getBrowserInfo(),n.Samsung===e._browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isOpera",{get:function(){return e._getBrowserInfo(),n.Opera===e._browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isMicroMessenger",{get:function(){return e._getBrowserInfo(),e._browserName===n.MicroMessenger},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isQQ",{get:function(){return e._getBrowserInfo(),n.QQ===e.browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isQQBrowser",{get:function(){return e._getBrowserInfo(),n.QQBrowser===e.browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isX5Core",{get:function(){return e._getBrowserInfo(),e._browserName===n.X5Core},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isUCBrowser",{get:function(){return e._getBrowserInfo(),e._browserName===n.UC},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isQuarkBrowser",{get:function(){return e._getBrowserInfo(),e._browserName===n.Quark},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isFingerBrowser",{get:function(){return e._getBrowserInfo(),e._browserName===n.Finger},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isChromeCore",{get:function(){return e._getBrowserInfo(),"Chrome"===e._core},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isWebView",{get:function(){return e._getBrowserInfo(),e._browserName===n.WebVeiw},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isDingTalk",{get:function(){return e._getBrowserInfo(),e._browserName===n.DingTalk},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isUnknown",{get:function(){return e._getBrowserInfo(),n.Unknown===e.browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"browserName",{get:function(){return e._getBrowserInfo(),e._browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"browserVersion",{get:function(){return e._getBrowserInfo(),e._browserVersion},enumerable:!1,configurable:!0}),Object.defineProperty(e,"browserMainVersion",{get:function(){return e._getBrowserInfo(),e._browserVersion?parseInt(e._browserVersion.split(".")[0],10):0},enumerable:!1,configurable:!0}),Object.defineProperty(e,"browserCoreVersion",{get:function(){return navigator.userAgent.toLowerCase(),i.SystemUtil.isIos||i.SystemUtil.isMacOS,e.browserMainVersion},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isElectron",{get:function(){return e._getBrowserInfo(),n.Electron===e.browserName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"userAgent",{get:function(){var e=navigator.userAgent.toLowerCase(),t=e.indexOf("gecko");if(t>-1){t=e.indexOf(" ",t);var r=(e=e.substring(t+1,e.length)).split(" ");e="";for(var n=0;n<r.length;++n){var i=r[n].split("/");i&&i.length&&(e+=i[0]+" ")}}return e},enumerable:!1,configurable:!0}),e.compareVersion=function(t){if(e._getBrowserInfo(),e._browserVersion){for(var r=e._browserVersion.split("."),n=t.split("."),i=0,o=0,a=0;a<r.length&&a<n.length;++a){if((i=isNaN(parseInt(r[a],10))?0:parseInt(r[a],10))<(o=isNaN(parseInt(n[a],10))?0:parseInt(n[a],10)))return!1;if(i>o)return!0}return!0}return!0},e._getBrowserInfo=function(){if(!e._browserName||!e._browserVersion)if(navigator&&navigator.userAgent){var t=navigator.userAgent.toLowerCase(),r=void 0;(r=t.match(/edg[e|a]?\/([\d.]+)/))||(r=t.match(/edgios\/([\d.]+)/))?e._updateBrowserInfo(n.Edge,t,r[1]):(r=t.match(/rv:([\d.]+)\) like gecko/))||(r=t.match(/msie ([\d.]+)/))?e._updateBrowserInfo(n.IE,t,r[1]):(r=t.match(/vivobrowser\/([\d.]+)/))?e._updateBrowserInfo(n.Vivo,t,r[1]):(r=t.match(/miuibrowser\/([\d.]+)/))?e._updateBrowserInfo(n.MI,t,r[1]):(r=t.match(/samsungbrowser\/([\d.]+)/))?e._updateBrowserInfo(n.Samsung,t,r[1]):(r=t.match(/heytapbrowser\/([\d.]+)/))?e._updateBrowserInfo(n.Oppo,t,r[1]):(r=t.match(/mzbrowser\/([\d.]+)/))?e._updateBrowserInfo(n.Meizu,t,r[1]):(r=t.match(/ucbrowser\/([\d.]+)/))?e._updateBrowserInfo(n.UC,t,r[1]):(r=t.match(/quark\/([\d.]+)/))?e._updateBrowserInfo(n.Quark,t,r[1]):(r=t.match(/slbrowser\/([\d.]+)/))?e._updateBrowserInfo(n.Lenovo,t,r[1]):(r=t.match(/lbbrowser\/([\d.]+)/))?e._updateBrowserInfo(n.Liebao,t,r[1]):(r=t.match(/fingerbrowser\/([\d.]+)/))?e._updateBrowserInfo(n.Finger,t,r[1]):(r=t.match(/huaweibrowser\/([\d.]+)/))?e._updateBrowserInfo(n.Huawei,t,r[1]):(r=t.match(/maxthon\/([\d.]+)/))?e._updateBrowserInfo(n.Maxthon,t,r[1]):(r=t.match(/firefox\/([\d.]+)/))?e._updateBrowserInfo(n.Firefox,t,r[1]):(r=t.match(/electron\/([\d.]+)/))?e._updateBrowserInfo(n.Electron,t,r[1]):(r=t.match(/chrome\/([\d.]+)/))&&this._isChrome(t)||(r=t.match(/crios\/([\d.]+)/))&&this._isChrome(t)?e._updateBrowserInfo(n.Chrome,t,r[1]):(r=t.match(/metasr\s([\d.]+)/))||(r=t.match(/sogoumobilebrowser\/([\d.]+)/))?e._updateBrowserInfo(n.Sogou,t,r[1]):(r=t.match(/opr.([\d.]+)/))?e._updateBrowserInfo(n.Opera,t,r[1]):(r=t.match(/micromessenger.([\d.]+)/))?e._updateBrowserInfo(n.MicroMessenger,t,r[1]):(r=t.match(/qq\/([\d.]+)/))?e._updateBrowserInfo(n.QQ,t,r[1]):(r=t.match(/m?qqbrowser\/([\d.]+)/))||(r=t.match(/qqbrowserlite\/([\d.]+)/))?e._updateBrowserInfo(n.QQBrowser,t,r[1]):(r=t.match(/dingtalk.([\d.]+)/))?e._updateBrowserInfo(n.DingTalk,t,r[1]):(r=t.match(/tbs\/([\d.]+)/))?e._updateBrowserInfo(n.X5Core,t,r[1]):(r=t.match(/version\/([\d.]+).*safari/))&&this._isSafari(t)&&e._updateBrowserInfo(n.Safari,t,r[1]),e._browserName===n.Unknown&&e._isWebview(t)&&e._updateBrowserInfo(n.WebVeiw,t,"")}else e._browserName=n.Unknown,e._browserVersion="0.0"},e._isChrome=function(t){var r=t.split(/\(|\)/);if(e._core="Chrome",5===r.length){var n=r[4].trim().split(" ");if(2===n.length){if(n[0].indexOf("chrome")>-1&&n[1].indexOf("safari")>-1)return!0}else if(3===n.length){if(n[1].indexOf("mobile")>-1&&n[2].indexOf("safari")>-1&&(n[0].indexOf("chrome")>-1||n[0].indexOf("crios")>-1))return!0}else if(t.indexOf("qianniu")>-1)return!0}return!1},e._isSafari=function(e){var t=e.split(/\(|\)/);if(5===t.length){var r=t[4].trim().split(" ");if(2===r.length){if(r[0].indexOf("version")>-1&&r[1].indexOf("safari")>-1)return!0}else if(3===r.length&&r[0].indexOf("version")>-1&&r[1].indexOf("mobile")>-1&&r[2].indexOf("safari")>-1)return!0}return!1},e._isWebview=function(e){if(e){var t=new RegExp("("+["WebView","(iPhone|iPod|iPad)(?!.*Safari)","Android.*(wv|.0.0.0)","Linux; U; Android"].join("|")+")","ig"),r=new RegExp("("+["VivoBrowser","MZBrowser","MiuiBrowser"].join("|")+")","ig");return!!e.match(t)&&!e.match(r)}},e._updateBrowserInfo=function(t,r,o){e._browserName=t;var a=null;switch(t){case n.QQBrowser:i.SystemUtil.isIos||i.SystemUtil.isMacOS?(a=r.match(/version\/([\d.]+).*safari/),e._browserVersion=a?a[1]:"0.0"):(a=r.match(/chrome\/([\d.]+)/),e._browserVersion=a?a[1]:"0.0");break;case n.Vivo:case n.Oppo:case n.Meizu:case n.Huawei:case n.Sogou:case n.Samsung:a=r.match(/chrome\/([\d.]+)/),e._browserVersion=a?a[1]:"0.0";break;case n.WebVeiw:i.SystemUtil.isAndroid?(a=r.match(/chrome\/([\d.]+)/),e._browserVersion=a?a[1]:"0.0"):i.SystemUtil.isIos&&(e._browserVersion=i.SystemUtil.systemVersion);break;default:e._browserVersion=o}},e._browserName=n.Unknown,e._browserVersion="",e._core="",e}();t.BrowserUtil=o},864:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Guid=void 0;var r=function(){function e(){}return e.create=function(e,t){void 0===t&&(t=16);var r,n,i="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=[];if(t=t||i.length,e)for(r=0;r<e;r++)o[r]=i[0|Math.random()*t];else for(o[8]=o[13]=o[18]=o[23]="-",o[14]="4",r=0;r<36;r++)o[r]||(n=0|16*Math.random(),o[r]=i[19==r?3&n|8:n]);return o.join("")},e}();t.Guid=r},442:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LocalStorage=void 0;var n=r(864),i=function(){function e(){}return Object.defineProperty(e,"uuid",{get:function(){var t="alirtc_uuid",r=e.get(t);return r||(r=n.Guid.create(32),e.set(t,r)),r},enumerable:!1,configurable:!0}),e.get=function(e){var t="";return window&&window.localStorage&&(t=window.localStorage.getItem(e)||""),t},e.set=function(e,t){e&&window&&window.localStorage&&window.localStorage.setItem(e,t)},e}();t.LocalStorage=i},72:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ApiRequest=void 0;var r=function(){function e(){}return e.postBody=function(t,r,n){t=e._getUrl(t,r);var i,o={};return o.headers||(o.headers={}),o.headers.Accept="application/json",o.headers["Content-Type"]="application/json",new Promise((function(r,o){e.requestBody("POST",t,n).then((function(e){return i=e,e.ok?e.json():e.text()})).then((function(t){i.ok?t.code?(t=e._intercept(t),o(t)):r(t.data):o(e._httpErrorMessage(i,t))})).catch((function(t){t=e._httpErrorMessage(t),o(t)}))}))},e.get=function(t,r,n){var i;return void 0===n&&(n={}),t=e._getUrl(t,r),n.headers||(n.headers={}),n.headers["Content-Type"]="application/json",new Promise((function(r,o){e.request("GET",t,n).then((function(e){return i=e,e.ok?e.json():e.text()})).then((function(t){i.ok?t.code?(t=e._intercept(t),o(t)):r(t.data):o(e._httpErrorMessage(i,t))})).catch((function(t){t=e._httpErrorMessage(t),o(t)}))}))},e.post=function(t,r,n,i){var o;return void 0===i&&(i={}),t=e._getUrl(t,r),i.headers||(i.headers={}),i.body=n,i.headers.Accept="application/json",i.headers["Content-Type"]="application/json",new Promise((function(r,n){e.request("POST",t,i).then((function(e){return o=e,e.ok?e.json():e.text()})).then((function(t){o.ok?t.code?(t=e._intercept(t),n(t)):r(t.data):n(e._httpErrorMessage(o,t))})).catch((function(t){t=e._httpErrorMessage(t),n(t)}))}))},e.request=function(e,t,r){void 0===e&&(e="GET");var n=new Headers(r.headers),i=new Request(t,{method:e,headers:n});return fetch(i)},e.requestBody=function(e,t,r){return void 0===e&&(e="GET"),fetch(t,{method:e,body:r,headers:new Headers({"Content-Type":"application/json"})})},e.ajaxPost=function(t,r,n,i){return void 0===i&&(i={}),t=e._getUrl(t,r),i.headers||(i.headers={}),i.headers.Accept="application/json",i.headers["Content-Type"]="application/json",e.ajax("POST",t,n,i)},e.ajax=function(t,r,n,i){void 0===t&&(t="GET"),void 0===i&&(i={});var o=new XMLHttpRequest;return new Promise((function(a,s){o.onreadystatechange=function(){if(4===o.readyState)if(200===o.status){var t=JSON.parse(o.responseText);t.code?(t=e._intercept(t),s(t)):a(t)}else s({message:o.responseText||"请求失败:"+r})},o.open(t,r,!0);try{if(i.withCredentials&&(o.withCredentials=!0),i.headers)for(var c in i.headers)o.setRequestHeader(c,i.headers[c])}catch(e){return void s(e)}try{o.send(n)}catch(e){s(e)}}))},e._getUrl=function(e,t){var r=[];if(t)for(var n in t)r.push(n+"="+t[n]);var i=r.join("&");return(-1!=e.indexOf("?")?e:e+"?")+i},e._httpErrorMessage=function(e,t){return e.message||(e.message="HTTP "+e.status+"("+e.statusText+") : "+t),e},e._intercept=function(e){var t=e.data;return e.code&&((t=t||{}).data=e.data,t.code=e.code,t.description=e.description,t.message="0x"+Number(e.code).toString(16)+", "+e.description,t.tid&&(t.message+=", tid="+t.tid)),t},e}();t.ApiRequest=r},101:(e,t)=>{var r,n;Object.defineProperty(t,"__esModule",{value:!0}),t.SystemUtil=t.WindowsType=t.SystemType=void 0,function(e){e.Unknown="Unknown",e.MacOS="Mac",e.Windows="Windows",e.Android="Android",e.Iphone="iphone",e.Ipad="ipad",e.iOS="iOS",e.Linux="Linux",e.ChromeOS="ChromeOS"}(r=t.SystemType||(t.SystemType={})),function(e){e.Windows10="Windows 10",e.Windows7="Windows 7",e.WindowsVista="Windows vista",e.WindowsXP="Windows xp"}(n=t.WindowsType||(t.WindowsType={}));var i=function(){function e(){}return Object.defineProperty(e,"isMacOS",{get:function(){return r.MacOS===e.systemName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isWindows",{get:function(){return e.systemName.indexOf(r.Windows)>-1},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isIos",{get:function(){return r.Iphone===e.systemName||r.Ipad===e.systemName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isAndroid",{get:function(){return r.Android===e.systemName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isLinux",{get:function(){return r.Linux===e.systemName||r.Linux===e._platform},enumerable:!1,configurable:!0}),Object.defineProperty(e,"systemName",{get:function(){return e._getSystemInfo(),e._systemName},enumerable:!1,configurable:!0}),Object.defineProperty(e,"systemVersion",{get:function(){return e._getSystemInfo(),e._systemVersion},enumerable:!1,configurable:!0}),Object.defineProperty(e,"platform",{get:function(){return e._getSystemInfo(),e._platform},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isUnknown",{get:function(){return!e.platform||e.platform===r.Unknown},enumerable:!1,configurable:!0}),e.compareVersion=function(t){if(e._getSystemInfo(),e._systemVersion){for(var r=e._systemVersion.split("."),n=t.split("."),i=0,o=0,a=0;a<r.length&&a<n.length;++a){if((i=isNaN(parseInt(r[a],10))?0:parseInt(r[a],10))<(o=isNaN(parseInt(n[a],10))?0:parseInt(n[a],10)))return!1;if(i>o)return!0}return!0}return!0},e._getSystemInfo=function(){if(!e._systemName||!e._systemVersion||!e._platform)if(navigator&&navigator.userAgent){var t=navigator.userAgent.toLowerCase();t.indexOf("ipad")>-1?(e._systemName=r.Ipad,e._platform=r.iOS,e._systemVersion=e._getIosSystemVersion(t)):t.indexOf("iphone")>-1?(e._systemName=r.Iphone,e._platform=r.iOS,e._systemVersion=e._getIosSystemVersion(t)):t.indexOf("android")>-1?(e._platform=r.Android,e._systemName=r.Android,e._systemVersion=e._getAndroidSystemVersion(t)):t.indexOf("win")>-1?t.indexOf("windwos nt 10")>-1||t.indexOf("windows 10")?(e._systemName=n.Windows10,e._platform=r.Windows,e._systemVersion="10"):t.indexOf("windows nt 6.1")>-1||t.indexOf("windows 7")>-1?(e._systemName=n.Windows7,e._platform=r.Windows,e._systemVersion="7"):t.indexOf("windows nt 6.0")>-1||t.indexOf("windows vista")>-1?(e._systemName=n.WindowsVista,e._platform=r.Windows,e._systemVersion="vista"):t.indexOf("widows nt 5.1")>-1||t.indexOf("windows xp")>-1?(e._systemName=n.WindowsXP,e._platform=r.Windows,e._systemVersion="xp"):(e._platform=r.Windows,e._systemName=r.Windows,e._systemVersion="0.0"):t.indexOf("mac")>-1?navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0?(e._systemName=r.Ipad,e._platform=r.iOS,e._systemVersion=e._getIosSystemVersion(t)):(e._platform=r.MacOS,e._systemName=r.MacOS,e._systemVersion=e._getMacSystemVersion(t)):t.indexOf("linux")>-1?(e._platform=r.Linux,e._systemName=r.Linux,e._systemVersion="0.0"):t.indexOf("cros")>-1?(e._platform=r.Linux,e._systemName=r.ChromeOS,e._systemVersion="0.0"):(e._systemName=r.Unknown,e._platform=r.Windows,e._systemVersion="0.0")}else e._systemName=r.Unknown,e._platform=r.Unknown,e._systemVersion="0.0"},e._getIosSystemVersion=function(e){return(e.match(/OS [\d._]*/gi)+"").replace(/[^0-9|_.]/gi,"").replace(/_/gi,".")},e._getMacSystemVersion=function(e){return(e.match(/OS X [\d._]*/gi)+"").replace(/[^0-9|_.]/gi,"").replace(/_/gi,".")},e._getAndroidSystemVersion=function(e){return e.substr(e.indexOf("android")+8,e.indexOf(";",e.indexOf("android"))-e.indexOf("android")-8)},e._systemName="",e._systemVersion="",e._platform=r.Unknown,e}();t.SystemUtil=i}},t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}var n={};return(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.ApiRequest=e.LocalStorage=e.Guid=e.BrowserUtil=e.SystemUtil=void 0;var t=r(101);Object.defineProperty(e,"SystemUtil",{enumerable:!0,get:function(){return t.SystemUtil}});var i=r(622);Object.defineProperty(e,"BrowserUtil",{enumerable:!0,get:function(){return i.BrowserUtil}});var o=r(864);Object.defineProperty(e,"Guid",{enumerable:!0,get:function(){return o.Guid}});var a=r(442);Object.defineProperty(e,"LocalStorage",{enumerable:!0,get:function(){return a.LocalStorage}});var s=r(72);Object.defineProperty(e,"ApiRequest",{enumerable:!0,get:function(){return s.ApiRequest}}),window&&(window.SystemUtil=t.SystemUtil,window.BrowserUtil=i.BrowserUtil,window.Guid=o.Guid,window.LocalStorage=a.LocalStorage,window.ApiRequest=s.ApiRequest)})(),n})()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RtsError=void 0;var n=r(1),i=function(){function e(e,t,r,i){this.errorCode=e,this.errorCodeName=n.ErrorCode[e],this.message=t,this.traceId=r,i&&(this.extraInfo=i)}return e.prototype.renameCode=function(e){this.errorCode=e,this.errorCodeName=n.ErrorCode[e]},e}();t.RtsError=i},function(e,t,r){"use strict";var n={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};n.localCName=n.generateIdentifier(),n.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},n.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},n.getDescription=function(e){var t=n.splitSections(e);return t&&t[0]},n.getMediaSections=function(e){var t=n.splitSections(e);return t.shift(),t},n.matchPrefix=function(e,t){return n.splitLines(e).filter((function(e){return 0===e.indexOf(t)}))},n.parseCandidate=function(e){for(var t,r={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},n=8;n<t.length;n+=2)switch(t[n]){case"raddr":r.relatedAddress=t[n+1];break;case"rport":r.relatedPort=parseInt(t[n+1],10);break;case"tcptype":r.tcpType=t[n+1];break;case"ufrag":r.ufrag=t[n+1],r.usernameFragment=t[n+1];break;default:r[t[n]]=t[n+1]}return r},n.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(" ")},n.parseIceOptions=function(e){return e.substr(14).split(" ")},n.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},n.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"},n.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]}},n.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},n.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<n.length;i++)r[(t=n[i].trim().split("="))[0].trim()]=t[1];return r},n.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var n=[];Object.keys(e.parameters).forEach((function(t){e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)})),t+="a=fmtp:"+r+" "+n.join(";")+"\r\n"}return t},n.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},n.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},n.parseSsrcMedia=function(e){var t=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,t-7),10)},n=e.indexOf(":",t);return n>-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},n.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},n.getMid=function(e){var t=n.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},n.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},n.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:n.matchPrefix(e+t,"a=fingerprint:").map(n.parseFingerprint)}},n.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},n.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)}},n.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?n.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},n.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}},n.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},n.getCryptoParameters=function(e,t){return n.matchPrefix(e+t,"a=crypto:").map(n.parseCryptoLine)},n.getIceParameters=function(e,t){var r=n.matchPrefix(e+t,"a=ice-ufrag:")[0],i=n.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substr(12),password:i.substr(10)}:null},n.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},n.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=n.splitLines(e)[0].split(" "),i=3;i<r.length;i++){var o=r[i],a=n.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(a){var s=n.parseRtpMap(a),c=n.matchPrefix(e,"a=fmtp:"+o+" ");switch(s.parameters=c.length?n.parseFmtp(c[0]):{},s.rtcpFeedback=n.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(n.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return n.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(n.parseExtmap(e))})),t},n.writeRtpDescription=function(e,t){var r="";r+="m="+e+" ",r+=t.codecs.length>0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=t.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach((function(e){r+=n.writeRtpMap(e),r+=n.writeFmtp(e),r+=n.writeRtcpFb(e)}));var i=0;return t.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(r+="a=maxptime:"+i+"\r\n"),r+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach((function(e){r+=n.writeExtmap(e)})),r},n.parseRtpEncodingParameters=function(e){var t,r=[],i=n.parseRtpParameters(e),o=-1!==i.fecMechanisms.indexOf("RED"),a=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=n.matchPrefix(e,"a=ssrc:").map((function(e){return n.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=s.length>0&&s[0].ssrc,u=n.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&&(t=u[0][1]),i.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var n={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&t&&(n.rtx={ssrc:t}),r.push(n),o&&((n=JSON.parse(JSON.stringify(n))).fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},r.push(n))}})),0===r.length&&c&&r.push({ssrc:c});var d=n.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substr(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substr(5),10)*.95-16e3:void 0,r.forEach((function(e){e.maxBitrate=d}))),r},n.parseRtcpParameters=function(e){var t={},r=n.matchPrefix(e,"a=ssrc:").map((function(e){return n.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];r&&(t.cname=r.value,t.ssrc=r.ssrc);var i=n.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var o=n.matchPrefix(e,"a=rtcp-mux");return t.mux=o.length>0,t},n.parseMsid=function(e){var t,r=n.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(t=r[0].substr(7).split(" "))[0],track:t[1]};var i=n.matchPrefix(e,"a=ssrc:").map((function(e){return n.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return i.length>0?{stream:(t=i[0].value.split(" "))[0],track:t[1]}:void 0},n.parseSctpDescription=function(e){var t,r=n.parseMLine(e),i=n.matchPrefix(e,"a=max-message-size:");i.length>0&&(t=parseInt(i[0].substr(19),10)),isNaN(t)&&(t=65536);var o=n.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};if(n.matchPrefix(e,"a=sctpmap:").length>0){var a=n.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(a[0],10),protocol:a[1],maxMessageSize:t}}},n.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("")},n.generateSessionId=function(){return Math.random().toString().substr(2,21)},n.writeSessionBoilerplate=function(e,t,r){var i=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||n.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},n.writeMediaSection=function(e,t,r,i){var o=n.writeRtpDescription(e.kind,t);if(o+=n.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":"active"),o+="a=mid:"+e.mid+"\r\n",e.direction?o+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?o+="a=sendrecv\r\n":e.rtpSender?o+="a=sendonly\r\n":e.rtpReceiver?o+="a=recvonly\r\n":o+="a=inactive\r\n",e.rtpSender){var a="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";o+="a="+a,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+n.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"),o},n.getDirection=function(e,t){for(var r=n.splitLines(e),i=0;i<r.length;i++)switch(r[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[i].substr(2)}return t?n.getDirection(t):"sendrecv"},n.getKind=function(e){return n.splitLines(e)[0].split(" ")[0].substr(2)},n.isRejected=function(e){return"0"===e.split(" ",2)[1]},n.parseMLine=function(e){var t=n.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:parseInt(t[1],10),protocol:t[2],fmt:t.slice(3).join(" ")}},n.parseOLine=function(e){var t=n.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:parseInt(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},n.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=n.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},e.exports=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_RETRY_PUBLISH_INTERVAL=t.DEFAULT_RETRY_SUBSCRIBE_INTERVAL=t.DEFAULT_RETRY_PUBLISH_LIMIT=t.DEFAULT_RETRY_SUBSCRIBE_LIMIT=t.EConnectStatus=t.TrackType=void 0,function(e){e.AUDIO="audio",e.VIDEO="video"}(t.TrackType||(t.TrackType={})),function(e){e[e.CONNECT_STATUS_DISCONNECTED=0]="CONNECT_STATUS_DISCONNECTED",e[e.CONNECT_STATUS_CONNECTING=1]="CONNECT_STATUS_CONNECTING",e[e.CONNECT_STATUS_CONNECTED=2]="CONNECT_STATUS_CONNECTED",e[e.CONNECT_STATUS_RECONNECTING=3]="CONNECT_STATUS_RECONNECTING"}(t.EConnectStatus||(t.EConnectStatus={})),t.DEFAULT_RETRY_SUBSCRIBE_LIMIT=5,t.DEFAULT_RETRY_PUBLISH_LIMIT=5,t.DEFAULT_RETRY_SUBSCRIBE_INTERVAL=2e3,t.DEFAULT_RETRY_PUBLISH_INTERVAL=2e3},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={version:"2.7.2",protocol_version:2,sdk_version:"0.0.1"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.evaluateNetworkCondition=t.makeCancelable=t.hasVideoTrack=t.hasAudioTrack=t.getVideoTrack=t.getAudioTrack=t.pruneSubUrl=t.getJitterBufferDelayAvg=void 0;t.getJitterBufferDelayAvg=function(e,t){return e&&t?Number(e)/Number(t)*1e3:-1};t.pruneSubUrl=function(e,t){var r=e||"";return r=r.replace("@subaudio=no","").replace("@subvideo=no",""),t&&(r=r.split("?")[0]),r};t.getAudioTrack=function(e){return e.getAudioTracks()[0]};t.getVideoTrack=function(e){return e.getVideoTracks()[0]};t.hasAudioTrack=function(e){return e.getAudioTracks().length>0};t.hasVideoTrack=function(e){return e.getVideoTracks().length>0};t.makeCancelable=function(e){var t=!1;return{promise:new Promise((function(r,n){e.then((function(e){return t?n({isCanceled:!0}):r(e)})),e.catch((function(e){return n(t?{isCanceled:!0}:e)}))})),cancel:function(){t=!0}}};t.evaluateNetworkCondition=function(e,t,r,n,i){var o=0;if(!navigator.onLine)return o=6;var a=[{loss:0,rtt:0,jbd:1},{loss:0,rtt:1,jbd:0},{loss:0,rtt:.5,jbd:.5},{loss:1,rtt:0,jbd:0},{loss:.8,rtt:0,jbd:.2},{loss:.8,rtt:.2,jbd:0},{loss:.6,rtt:.2,jbd:.2}],s=-1,c=-1,u=-1;if("number"==typeof t&&t>=0||"number"==typeof r&&r>=0){s=0;var d=!1,p=!1;"number"==typeof t&&t>=0&&(s+=t,d=!0),"number"==typeof r&&r>=0&&(s+=r,p=!0),d&&!p&&(s*=2),p&&!d&&(s*=1.8)}if("number"==typeof e&&e>=0&&(u=e),"number"==typeof n&&n>=0||"number"==typeof i&&i>=0){c=0;"number"==typeof n&&n>=0&&(c+=n),"number"==typeof i&&i>=0&&(c+=i)}var l;if((l=4*(-1!==s?1:0)+2*(-1!==u?1:0)+(-1!==c?1:0))>0){var f=1.2*s*a[l-1].loss+u/1500*a[l-1].rtt+c/3e3*a[l-1].jbd;o=f<=.1?1:f<=.23?2:f<=.36?3:f<=.49?4:5}else o=0;return o}},function(e,t,r){var n;self,n=()=>(()=>{var e={692:e=>{var t=e.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),(t+=null!=e["network-id"]?" network-id %d":"%v")+(null!=e["network-cost"]?" network-cost %d":"%v")}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",(t+=null!=e.rateNumerator?" rate=%s":"")+(null!=e.rateDenominator?"/%s":"")}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(t).forEach((function(e){t[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))},766:(e,t,r)=>{var n=r(962),i=r(627);t.write=i,t.parse=n.parse,t.parseParams=n.parseParams,t.parseFmtpConfig=n.parseFmtpConfig,t.parsePayloads=n.parsePayloads,t.parseRemoteCandidates=n.parseRemoteCandidates,t.parseImageAttributes=n.parseImageAttributes,t.parseSimulcastStreamList=n.parseSimulcastStreamList},962:(e,t,r)=>{var n=function(e){return String(Number(e))===e?Number(e):e},i=function(e,t,r){var i=e.name&&e.names;e.push&&!t[e.push]?t[e.push]=[]:i&&!t[e.name]&&(t[e.name]={});var o=e.push?{}:i?t[e.name]:t;!function(e,t,r,i){if(i&&!r)t[i]=n(e[1]);else for(var o=0;o<r.length;o+=1)null!=e[o+1]&&(t[r[o]]=n(e[o+1]))}(r.match(e.reg),o,e.names,e.name),e.push&&t[e.push].push(o)},o=r(692),a=RegExp.prototype.test.bind(/^([a-z])=(.*)/);t.parse=function(e){var t={},r=[],n=t;return e.split(/(\r\n|\r|\n)/).filter(a).forEach((function(e){var t=e[0],a=e.slice(2);"m"===t&&(r.push({rtp:[],fmtp:[]}),n=r[r.length-1]);for(var s=0;s<(o[t]||[]).length;s+=1){var c=o[t][s];if(c.reg.test(a))return i(c,n,a)}})),t.media=r,t};var s=function(e,t){var r=t.split(/=(.+)/,2);return 2===r.length?e[r[0]]=n(r[1]):1===r.length&&t.length>1&&(e[r[0]]=void 0),e};t.parseParams=function(e){return e.split(/;\s?/).reduce(s,{})},t.parseFmtpConfig=t.parseParams,t.parsePayloads=function(e){return e.toString().split(" ").map(Number)},t.parseRemoteCandidates=function(e){for(var t=[],r=e.split(" ").map(n),i=0;i<r.length;i+=3)t.push({component:r[i],ip:r[i+1],port:r[i+2]});return t},t.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(s,{})}))},t.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var t,r=!1;return"~"!==e[0]?t=n(e):(t=n(e.substring(1,e.length)),r=!0),{scid:t,paused:r}}))}))}},627:(e,t,r)=>{var n=r(692),i=/%[sdv%]/g,o=function(e){var t=1,r=arguments,n=r.length;return e.replace(i,(function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},a=function(e,t,r){var n=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var a=t.names[i];t.name?n.push(r[t.name][a]):n.push(r[t.names[i]])}else n.push(r[t.name]);return o.apply(null,n)},s=["v","o","s","i","u","e","p","c","b","t","r","z","a"],c=["i","c","b","a"];e.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||s,i=t.innerOrder||c,o=[];return r.forEach((function(t){n[t].forEach((function(r){r.name in e&&null!=e[r.name]?o.push(a(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){o.push(a(t,r,e))}))}))})),e.media.forEach((function(e){o.push(a("m",n.m[0],e)),i.forEach((function(t){n[t].forEach((function(r){r.name in e&&null!=e[r.name]?o.push(a(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){o.push(a(t,r,e))}))}))}))})),o.join("\r\n")+"\r\n"}},776:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},a=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.PeerConnectionCore=t.EDatachannelStatus=void 0;var s=r(887),c=r(248),u=r(237),d=r(619),p=r(628),l=r(961),f=r(844),h=r(651);Object.defineProperty(t,"EDatachannelStatus",{enumerable:!0,get:function(){return h.EDatachannelStatus}});var m="rts video",v="rts audio",E=function(){function e(e){this.removeTwcc=!1,this.streamManager=new p.StreamManager,e.pc?(this.pc=e.pc,this.signal=new d.Signal({pc:e.pc,onDatachannelEvent:e.onDatachannelEvent})):console.error("peerconnetion is required")}return e.prototype.getStreamManager=function(){return this.streamManager},e.prototype.getSignal=function(){return this.signal},e.prototype.setPrevOfferSdp=function(e){this.prevOfferSdp=e},e.prototype.setPrevAnswerSdp=function(e){this.prevAnswerSdp=e},e.prototype.getTrackIds=function(e){return e.reduce((function(e,t){return a(a([],e,!0),[t.id],!1)}),[])},e.prototype.setRemoveTwcc=function(e){this.removeTwcc=e},e.prototype.subscribeAdd=function(e){return i(this,void 0,void 0,(function(){var t,r,u,d,p,h,m,v,E=this;return o(this,(function(R){switch(R.label){case 0:if(this.log("SUB LIST: ",e),t=(new Date).getTime(),r=(new Date).getTime(),u=(new Date).getTime(),d=this,p=this.extendUrl(e),h=p.map((function(e){var t=e.urlData,r=e.vMsid,n=e.aMsid;if(E.streamManager.has(t.url)){var i=E.streamManager.get(t.url),o=i.videoInfoList.map((function(e){return e.msid})),a=i.audioInfoList.map((function(e){return e.msid})),c=(0,s.intersection)(o,r),u=(0,s.intersection)(a,n);if(u.length||c.length)return{url:t.url,vMsid:c,aMsid:u}}})).filter((function(e){return e})),this.log("DELETE LIST: ",h),!(null==h?void 0:h.length))return[3,4];R.label=1;case 1:return R.trys.push([1,3,,4]),[4,this.subscribeDeleteTracks(h,!0)];case 2:return R.sent(),[3,4];case 3:throw m=R.sent(),(v=m).extraInfo=n(n({},v.extraInfo),{api:"subscribeAdd",signal_api:"subscribeDeleteTracks",configList:e}),v;case 4:return t=(new Date).getTime(),[2,new Promise((function(s,h){return i(E,void 0,void 0,(function(){var m,v,E,R,y,g,S,b,_,T,C,O,w,P=this;return o(this,(function(D){switch(D.label){case 0:if(!this.pc)return[2,h(new l.RtsError(f.ErrorCode.CORE_NO_PC_ERROR,"subscribeAdd: no peerconnection",""))];this.pc.addEventListener("track",(function a(c){var l;return i(this,void 0,void 0,(function(){var i,c;return o(this,(function(o){switch(o.label){case 0:null===(l=d.pc)||void 0===l||l.removeEventListener("track",a),i=d.buildUrlStreamMap(p),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,d.subscribeActive(e)];case 2:return o.sent(),[3,4];case 3:return(c=o.sent()).extraInfo=n(n({},c.extraInfo),{api:"subscribeAdd",signal_api:"subscribeActive"}),[2,h(c)];case 4:return r=(new Date).getTime(),s({deleteRspTime:t,subAddRspTime:u,activeRspTime:r,streamList:i}),[2]}}))}))})),p.forEach((function(e){var t=e.urlData,r=e.vMsid,n=e.aMsid;if(P.pc){if(P.streamManager.init(t.url),t.subVideo&&!P.streamManager.isMsidSubPubDone(t.url,{vMsid:r[0]})){var i=P.pc.addTransceiver("video",{direction:"recvonly"});P.streamManager.update(t.url,{vMsid:r[0],vTransceiver:i})}if(t.subAudio&&!P.streamManager.isMsidSubPubDone(t.url,{aMsid:n[0]})){var o=P.pc.addTransceiver("audio",{direction:"recvonly"});P.streamManager.update(t.url,{aMsid:n[0],aTransceiver:o})}}})),D.label=1;case 1:return D.trys.push([1,3,,4]),[4,this.pc.createOffer()];case 2:return m=D.sent(),[3,4];case 3:return v=D.sent(),[2,h(new l.RtsError(f.ErrorCode.DATACHANNEL_CREATE_OFFER_ERROR,"CreateOffer Error: ".concat(v),"",{api:"subscribeAdd",err:v}))];case 4:E=new c.SdpUtil({sdp:m.sdp||""}),this.restorePublishedSsrc(E),E.addNack(),E.updateBundle(),m=new RTCSessionDescription({type:"offer",sdp:E.generate()}),R=this.findNewSubPubMids((null==m?void 0:m.sdp)||"",this.prevOfferSdp||""),this.setPrevOfferSdp(m.sdp||""),D.label=5;case 5:return D.trys.push([5,7,,8]),[4,this.pc.setLocalDescription(m)];case 6:return D.sent(),[3,8];case 7:return y=D.sent(),[2,h(new l.RtsError(f.ErrorCode.DATACHANNEL_SET_OFFER_ERROR,"SetLocalDescription error: ".concat(y),"",{api:"subscribeAdd",sdp:m}))];case 8:g=[],p.forEach((function(){var e=new c.SdpUtil({sdp:(null==m?void 0:m.sdp)||""});e.keepMedia(R),g.push(e.generate())})),this.log("ADD LIST: ",p),D.label=9;case 9:return D.trys.push([9,11,,12]),[4,null===(w=this.signal)||void 0===w?void 0:w.subscribeAdd(p,g,this.streamManager)];case 10:return S=D.sent(),[3,12];case 11:return(b=D.sent()).extraInfo=n({api:"subscribeAdd",signal_api:"subscribeAdd"},b.extraInfo),[2,h(b)];case 12:_=[],S.streams.forEach((function(e,t){P.log("Sub TraceId[".concat(t,"]: "),e.traceid);var r=new c.SdpUtil({sdp:e.sdp});_=a(a([],_,!0),r.detail.media,!0);var n=p.find((function(t){return t.urlData.url===e.url}));n&&(n.traceId=e.traceid)})),(T=new c.SdpUtil({sdp:this.prevAnswerSdp||""})).addOrUpdateMedia(_),this.alignAnswerMidsWithOffer(T),C=T.generate(),this.setPrevAnswerSdp(C),D.label=13;case 13:return D.trys.push([13,15,,16]),[4,this.pc.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:C}))];case 14:return D.sent(),p.forEach((function(e){P.streamManager.markAlreadySubPub(e.urlData.url,{vMsid:e.vMsid[0],aMsid:e.aMsid[0]})})),[3,16];case 15:return O=D.sent(),[2,h(new l.RtsError(f.ErrorCode.DATACHANNEL_SET_ANSWER_ERROR,"SetRemoteDescription error: ".concat(O),"",{api:"subscribeAdd",sdp:C}))];case 16:return u=(new Date).getTime(),[2]}}))}))}))]}}))}))},e.prototype.subscribeActive=function(e){var t;return i(this,void 0,void 0,(function(){return o(this,(function(r){return[2,null===(t=this.signal)||void 0===t?void 0:t.subscribeActive(this.extendUrl(e))]}))}))},e.prototype.subscribeDeleteTracks=function(e,t){var r,a,c,u;return i(this,void 0,void 0,(function(){var d,p,l,h,m=this;return o(this,(function(v){switch(v.label){case 0:e.forEach((function(e){e.rawUrl=e.url,e.url=m.streamManager.getOriginUrl(e.url)})),v.label=1;case 1:return v.trys.push([1,3,,4]),[4,null===(r=this.signal)||void 0===r?void 0:r.subscribeDelete(e)];case 2:return v.sent(),[3,4];case 3:if(d=v.sent(),p=d,!t||p.errorCode!==f.ErrorCode.DATACHANNEL_RESPONSE_ERROR||!(null===(c=null===(a=p.extraInfo)||void 0===a?void 0:a.parsedData)||void 0===c?void 0:c.streams)||404!==(null===(u=p.extraInfo.parsedData.streams[0])||void 0===u?void 0:u.res_code))throw p.extraInfo=n({api:"subscribeDeleteTracks"},p.extraInfo),p;return[3,4];case 4:return l=[],h=e.map((function(e){var t=e.url,r=e.vMsid,a=e.aMsid,c=e.rawUrl;return i(m,void 0,void 0,(function(){var e,i,u,d,p,f,h,m;return o(this,(function(o){switch(o.label){case 0:t=(0,s.pruneSubUrl)(t),this.streamManager.has(t)&&(r&&(u=this.streamManager.getTransceiver(t,{vMsid:r[0]}))&&(i=u.receiver.track).stop(),a&&(d=this.streamManager.getTransceiver(t,{aMsid:a[0]}))&&(e=d.receiver.track).stop()),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.simulateOfferAnswer()];case 2:return o.sent(),[3,4];case 3:throw(p=o.sent()).extraInfo=n({api:"subscribeDeleteTracks"},p.extraInfo),p;case 4:return(f=this.streamManager.getStreamByMsid({url:t,vMsid:null==r?void 0:r[0],aMsid:null==a?void 0:a[0]}))&&(e&&(null===(h=f.mediastream)||void 0===h||h.removeTrack(e)),i&&(null===(m=f.mediastream)||void 0===m||m.removeTrack(i))),this.streamManager.pruneStreamList(t),this.streamManager.removeMsid(t,{vMsid:(null==r?void 0:r.length)?this.unifyMsid(r,"video"):void 0,aMsid:(null==a?void 0:a.length)?this.unifyMsid(a,"audio"):void 0}),l.push({url:c||"",stream:f}),[2]}}))}))})),[4,Promise.all(h)];case 5:return v.sent(),[2,l]}}))}))},e.prototype.subscribeStop=function(e){var t;return i(this,void 0,void 0,(function(){var r,a=this;return o(this,(function(c){switch(c.label){case 0:try{null===(t=this.signal)||void 0===t||t.subscribeStop(this.extendUrl(e))}catch(e){throw e.extraInfo=n({api:"subscribeStop"},e.extraInfo),e}return e.forEach((function(e){e.rawUrl=e.url,e.url=a.streamManager.getOriginUrl(e.url)})),r=e.map((function(e){var t=e.url;return e.rawUrl,e.targetStreams,i(a,void 0,void 0,(function(){var e;return o(this,(function(r){switch(r.label){case 0:t=(0,s.pruneSubUrl)(t),this.streamManager.getAllTransceivers(t).forEach((function(e){var t;null===(t=null==e?void 0:e.receiver.track)||void 0===t||t.stop()})),this.streamManager.get(t).streamList.forEach((function(e){return e.release()})),this.streamManager.remove(t),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.simulateOfferAnswer()];case 2:return r.sent(),[3,4];case 3:throw(e=r.sent()).extraInfo=n({api:"subscribeStop"},e.extraInfo),e;case 4:return[2]}}))}))})),[4,Promise.all(r)];case 1:return c.sent(),[2]}}))}))},e.prototype.publishAdd=function(e){var t;return i(this,void 0,void 0,(function(){var r,i,s,u,d,h,m,v,E,R,y,g,S,b,_,T,C,O,w,P,D,M,A,I,N,k,L=this;return o(this,(function(o){switch(o.label){case 0:if(e.length>1)throw console.error("Only one stream is supported."),new l.RtsError(f.ErrorCode.CORE_PUBLIST_EXCEED_ERROR,"publishAdd: publishList exceed limit","",{api:"publishAdd"});if(!this.pc)throw new l.RtsError(f.ErrorCode.CORE_NO_PC_ERROR,"publishAdd: no peerconnection","",{api:"publishAdd"});r=e[0],i=r.stream,s=this.unifyMsid(r.aMsid,"audio"),u=this.unifyMsid(r.vMsid,"video"),r.rawUrl=r.url,r.url=this.streamManager.getOriginUrl(r.url),"boolean"!=typeof r.updateSourceStream&&(r.updateSourceStream=!0),d=i.videoTrack,h=i.audioTrack,m=this.streamManager.getStreamByMsid({url:r.url,vMsid:u,aMsid:s}),this.streamManager.init(r.url,p.EStreamType.Publish),h&&(v=this.pc.addTransceiver(i.audioTrack,{direction:"sendonly"}),this.streamManager.update(r.url,{aMsid:s,aTransceiver:v,stream:i})),d&&(v=this.pc.addTransceiver(i.videoTrack,{direction:"sendonly"}),this.streamManager.update(r.url,{vMsid:u,vTransceiver:v,stream:i})),m&&r.updateSourceStream&&m.mergeStream(i),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.pc.createOffer()];case 2:return E=o.sent(),[3,4];case 3:throw R=o.sent(),new l.RtsError(f.ErrorCode.DATACHANNEL_CREATE_OFFER_ERROR,"CreateOffer Error: ".concat(R),"",{api:"publishAdd",err:R});case 4:y=new c.SdpUtil({sdp:E.sdp||""}),g=this.parseMsidString(u),S=this.parseMsidString(s),b=this.findNewSubPubMids(E.sdp||"",this.prevOfferSdp||""),g.stream&&y.detail.msidSemantic&&(y.detail.msidSemantic.token=g.stream),_=y.detail.media.reduce((function(e,t){return"inactive"===t.direction?a(a([],e,!0),[String(t.mid)],!1):e}),[]),y.detail.media.forEach((function(e){var t;if("recvonly"!==e.direction&&"application"!==e.type&&b.includes(String(e.mid))){var r="video"===e.type?g:S,n=L.parseMsidString(e.msid);n.stream=r.stream||n.stream,n.track=r.track||n.track;var i=L.stringifyMsid(n);e.msid=i,null===(t=e.ssrcs)||void 0===t||t.forEach((function(e){switch(e.attribute){case"cname":case"label":e.value=r.track||e.value;break;case"msid":e.value=i;break;case"mslabel":e.value=r.stream||e.value}}))}})),this.restorePublishedSsrc(y),this.restorePublishMsid(y),y.addNack(),T=y.generate(),this.setPrevOfferSdp(T),o.label=5;case 5:return o.trys.push([5,7,,8]),[4,this.pc.setLocalDescription(new RTCSessionDescription({type:"offer",sdp:T}))];case 6:return o.sent(),[3,8];case 7:throw C=o.sent(),new l.RtsError(f.ErrorCode.DATACHANNEL_SET_OFFER_ERROR,"SetLocalDescription error: ".concat(C),"",{api:"publishAdd",sdp:T});case 8:y.keepMedia(b),this.updateTrackInfoList({url:r.rawUrl,stream:r.stream,vMsid:u,aMsid:s,sdpMediaList:y.detail.media}),o.label=9;case 9:return o.trys.push([9,11,,12]),[4,null===(t=this.signal)||void 0===t?void 0:t.publishAdd([r.url],[y.generate()],[d?[this.stringifyMsid(g)]:[]],[h?[this.stringifyMsid(S)]:[]])];case 10:return O=o.sent(),[3,12];case 11:throw w=o.sent(),(P=w).extraInfo=n({api:"publishAdd"},P.extraInfo),P;case 12:D=O.streams[0],r.traceId=D.traceid,this.log("Pub TraceId: ",r.traceId),(M=new c.SdpUtil({sdp:D.sdp})).detail.media.forEach((function(e){"application"!==e.type&&"sendrecv"===e.direction&&(e.direction="recvonly")})),(A=new c.SdpUtil({sdp:this.prevAnswerSdp||""})).detail.media.forEach((function(e){"application"===e.type&&(delete e.candidates,delete e.endOfCandidates)})),A.setMediaInactive(_),A.addOrUpdateMedia(M.detail.media,{isPublish:!0}),this.alignAnswerMidsWithOffer(A),this.removeTwcc&&(I=["http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"],A.detail.media.forEach((function(e){var t;e.ext=null===(t=e.ext)||void 0===t?void 0:t.filter((function(e){return!I.includes(e.uri)}))}))),N=A.generate(),this.setPrevAnswerSdp(N),o.label=13;case 13:return o.trys.push([13,15,,16]),[4,this.pc.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:N}))];case 14:return o.sent(),this.streamManager.markAlreadySubPub(r.url,{vMsid:u,aMsid:s,isPub:!0}),[3,16];case 15:throw k=o.sent(),new l.RtsError(f.ErrorCode.DATACHANNEL_SET_ANSWER_ERROR,"SetRemoteDescription error: ".concat(k),"",{api:"publishAdd",sdp:N});case 16:return[2,e.map((function(e){return{url:e.rawUrl,trackInfoList:L.streamManager.getAllMediaInfoList(r.url),traceId:e.traceId}}))]}}))}))},e.prototype.publishDeleteTracks=function(e){var t,r,a,c,u,d,p;return i(this,void 0,void 0,(function(){var i,l,f,h,m,v,E,R,y,g,S=this;return o(this,(function(o){switch(o.label){case 0:e.forEach((function(e){e.rawUrl=e.url,e.url=S.streamManager.getOriginUrl(e.url)})),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,null===(t=this.signal)||void 0===t?void 0:t.publishDelete(e)];case 2:return o.sent(),[3,4];case 3:throw(i=o.sent()).extraInfo=n({api:"publishDeleteTracks"},i.extraInfo),i;case 4:if(l=e[0],f=(0,s.pruneSubUrl)(l.url),"boolean"!=typeof l.updateSourceStream&&(l.updateSourceStream=!0),h=!1,m=!1,!this.streamManager.has(f))return[3,9];(null===(r=l.vMsid)||void 0===r?void 0:r.length)&&((null==(v=this.streamManager.getTransceiver(f,{vMsid:l.vMsid[0]}))?void 0:v.sender)&&(null===(a=this.pc)||void 0===a||a.removeTrack(null==v?void 0:v.sender)),h=!0),(null===(c=l.aMsid)||void 0===c?void 0:c.length)&&((null==(E=this.streamManager.getTransceiver(f,{aMsid:l.aMsid[0]}))?void 0:E.sender)&&(null===(u=this.pc)||void 0===u||u.removeTrack(null==E?void 0:E.sender)),m=!0),o.label=5;case 5:return o.trys.push([5,7,,8]),[4,this.simulateOfferAnswer()];case 6:return o.sent(),[3,8];case 7:throw(R=o.sent()).extraInfo=n({api:"publishDeleteTracks"},R.extraInfo),R;case 8:return(y=this.streamManager.getStreamByMsid({url:f,vMsid:null===(d=l.vMsid)||void 0===d?void 0:d[0],aMsid:null===(p=l.aMsid)||void 0===p?void 0:p[0]}))&&l.updateSourceStream&&y.deleteTracks({video:h,audio:m}),this.streamManager.removeMsid(f,{vMsid:h?this.unifyMsid(l.vMsid,"video"):void 0,aMsid:m?this.unifyMsid(l.aMsid,"audio"):void 0}),this.streamManager.pruneStreamList(f),g=this.streamManager.getAllMediaInfoList(l.url),[2,e.map((function(e){return{url:e.rawUrl,trackInfoList:g}}))];case 9:return[2]}}))}))},e.prototype.publishReplaceTracks=function(e){var t,r,n,a,s;return i(this,void 0,void 0,(function(){var i,c,u,d,p,h,m,v,E,R,y=this;return o(this,(function(o){switch(o.label){case 0:if(i=e[0],c=i.stream,u=i.vMsid,d=i.aMsid,i.rawUrl=i.url,i.url=this.streamManager.getOriginUrl(i.url),!this.streamManager.has(i.url))throw new l.RtsError(f.ErrorCode.CORE_PUB_REPLACE_URL_NOT_FOUND,"No stream found for this url: ".concat(i.url),"",{api:"publishReplaceTracks",configList:e});return"boolean"!=typeof i.updateSourceStream&&(i.updateSourceStream=!0),p=c.audioTrack,h=c.videoTrack,m=this.streamManager.getAllMediaInfoList(i.url,!0),p&&(E=null===(t=m.find((function(e){return"audio"===e.type&&(!d||e.msid===d)})))||void 0===t?void 0:t.transceiver)&&p.id!==(null===(n=null===(r=E.sender)||void 0===r?void 0:r.track)||void 0===n?void 0:n.id)?[4,E.sender.replaceTrack(p)]:[3,2];case 1:o.sent(),o.label=2;case 2:return h?(v=m.find((function(e){return"video"===e.type&&(!u||e.msid===u)})),(E=null==v?void 0:v.transceiver)&&h.id!==(null===(s=null===(a=E.sender)||void 0===a?void 0:a.track)||void 0===s?void 0:s.id)?[4,E.sender.replaceTrack(h)]:[3,4]):[3,4];case 3:o.sent(),c.isCustomStream||(v.from=c.hasScreen?"screen":"camera"),o.label=4;case 4:return(R=this.streamManager.getStreamByMsid({url:i.url,vMsid:u,aMsid:d}))&&i.updateSourceStream&&R.mergeStream(c),[2,e.map((function(e){return{url:e.rawUrl,trackInfoList:y.streamManager.getAllMediaInfoList(i.url)}}))]}}))}))},e.prototype.publishStop=function(e){var t;return i(this,void 0,void 0,(function(){var r,a,c=this;return o(this,(function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),[4,null===(t=this.signal)||void 0===t?void 0:t.publishStop(e.map((function(e){return c.streamManager.getOriginUrl(e.url)})))];case 1:return u.sent(),[3,3];case 2:throw(r=u.sent()).extraInfo=n({api:"publishStop"},r.extraInfo),r;case 3:return a=e.map((function(e){var t=e.url;return i(c,void 0,void 0,(function(){var e,r=this;return o(this,(function(i){switch(i.label){case 0:t=(0,s.pruneSubUrl)(t),this.streamManager.getAllTransceivers(t).forEach((function(e){var t;(null==e?void 0:e.sender)&&(null===(t=r.pc)||void 0===t||t.removeTrack(null==e?void 0:e.sender))})),this.streamManager.get(t).streamList.forEach((function(e){return e.deleteTracks({video:!0,audio:!0})})),this.streamManager.remove(t),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.simulateOfferAnswer()];case 2:return i.sent(),[3,4];case 3:throw(e=i.sent()).extraInfo=n({api:"publishStop"},e.extraInfo),e;case 4:return[2]}}))}))})),[4,Promise.all(a)];case 4:return u.sent(),[2]}}))}))},e.prototype.buildUrlStreamMap=function(e){var t=this,r=[];return e.forEach((function(e){var n=e.urlData,i=e.traceId,o=e.url,a=e.vMsid,s=e.aMsid,c=n.url,u=new MediaStream;t.streamManager.getAllMediaInfoList(c,!0).forEach((function(e){var t,r;if("video"===e.type&&e.msid===a[0]||"audio"===e.type&&e.msid===s[0]){var n=null===(r=null===(t=e.transceiver)||void 0===t?void 0:t.receiver)||void 0===r?void 0:r.track;n&&u.addTrack(n)}})),r.push({url:o,stream:u,traceId:i})})),r},e.prototype.extendUrl=function(e){var t=this;return e.map((function(e){var r=e.url,i=e.subAudio,o=e.subVideo,a=e.aMsid,s=e.vMsid,c=t.streamManager.getOriginUrl(r),d=new u.UrlData({url:c,subAudio:i,subVideo:o});return n(n({},e),{urlData:d,aMsid:d.subAudio?a||[v]:[],vMsid:d.subVideo?s||[m]:[]})}))},e.prototype.parseSdp=function(e){return new c.SdpUtil({sdp:e})},e.prototype.getTrackInfoList=function(e,t,r){void 0===e&&(e=[]);var n=[];return e.forEach((function(e){var i,o,a,s;if("application"!==e.type){var c,u=Number(e.ssrcs&&(null===(i=e.ssrcs[0])||void 0===i?void 0:i.id))||-1,d=e.rtp.find((function(e){var t;return["opus","h264"].includes(null===(t=e.codec)||void 0===t?void 0:t.toLowerCase())})),p=(null==d?void 0:d.codec)||"",l=(null==d?void 0:d.payload)||0;t.isCustomStream||"video"===e.type&&(c=t.hasScreen?"screen":"camera");var f=e.msid;if((null==r?void 0:r.aMsid)||(null==r?void 0:r.vMsid)){var h=("video"===e.type?r.vMsid:r.aMsid)||"";(null==h?void 0:h.trim().includes(" "))||(f=null===(o=e.msid)||void 0===o?void 0:o.split(" ")[1])}var m="video"===e.type?null===(a=t.videoTrack)||void 0===a?void 0:a.id:null===(s=t.audioTrack)||void 0===s?void 0:s.id;n.push({ssrc:u,codec:p,type:e.type,pt:l,msid:f,from:c,trackId:m})}})),n},e.prototype.patchSubscribeStreamManagerRecord=function(e,t){var r=this;this.extendUrl([{url:e,vMsid:t.vMsid,aMsid:t.aMsid}]).forEach((function(e){var n=e.urlData,i=e.vMsid,o=e.aMsid;if(r.pc){r.streamManager.remove(n.url),r.streamManager.init(n.url);var a=r.pc.getTransceivers()||[];if(n.subVideo){var s=a.find((function(e){return"video"===e.receiver.track.kind}));r.streamManager.update(n.url,{vMsid:i[0],vTransceiver:s,stream:t.stream})}if(n.subAudio){var c=a.find((function(e){return"audio"===e.receiver.track.kind}));r.streamManager.update(n.url,{aMsid:o[0],aTransceiver:c,stream:t.stream})}}}))},e.prototype.patchPublishStreamManagerRecord=function(e,t){if(this.pc){var r=t.stream,n=r.videoTrack,i=r.audioTrack,o=this.unifyMsid(t.aMsid,"audio"),a=this.unifyMsid(t.vMsid,"video");this.streamManager.init(e,p.EStreamType.Publish);var s=this.pc.getTransceivers()||[];if(n){var c=s.find((function(e){var t,r;return(null===(r=null===(t=e.sender)||void 0===t?void 0:t.track)||void 0===r?void 0:r.id)===n.id}));c&&this.streamManager.update(e,{vMsid:a,vTransceiver:c,stream:t.stream})}if(i){var u=s.find((function(e){var t,r;return(null===(r=null===(t=e.sender)||void 0===t?void 0:t.track)||void 0===r?void 0:r.id)===i.id}));u&&this.streamManager.update(e,{aMsid:o,aTransceiver:u,stream:t.stream})}}},e.prototype.updateTrackInfoList=function(e){var t=e.url,r=e.stream,i=e.vMsid,o=e.aMsid,a=e.sdpMediaList;t||console.error("[updateTrackInfoList] url is required");var s=this.getTrackInfoList(a,r,{vMsid:i,aMsid:o}),c=s.find((function(e){return"video"===e.type})),u=s.find((function(e){return"audio"===e.type}));return i&&c&&this.streamManager.updateSdpInfo(t,n({vMsid:i},c)),o&&u&&this.streamManager.updateSdpInfo(t,n({aMsid:o},u)),s},e.prototype.unifyMsid=function(e,t){var r="video"===t?m:v;return(null==e?void 0:e[0])||r},e.prototype.dispose=function(){var e,t;this.pc=void 0,this.prevOfferSdp=void 0,this.prevAnswerSdp=void 0,null===(e=this.signal)||void 0===e||e.dispose(),null===(t=this.streamManager)||void 0===t||t.dispose()},e.prototype.findNewSubPubMids=function(e,t){var r=new c.SdpUtil({sdp:e}),n=new c.SdpUtil({sdp:t}),i=r.detail.media.filter((function(e){return"inactive"!==e.direction})).map((function(e){return e.mid})),o=n.detail.media.map((function(e){return e.mid}));return this.findDiff(i,o).map((function(e){return String(e)}))},e.prototype.findDiff=function(e,t){return Array.from(new Set(a([],e,!0).filter((function(e){return!t.includes(e)}))))},e.prototype.parseMsidString=function(e){var t={stream:"",track:""};if(!e)return t;var r=e.trim().split(" "),n=r[0],i=r[1];return i?(t.stream=n,t.track=i):t.track=n,t},e.prototype.stringifyMsid=function(e){var t=e.stream,r=e.track;return"".concat(t).concat(t?" ":"").concat(r)},e.prototype.restorePublishedSsrc=function(e){var t=new c.SdpUtil({sdp:this.prevOfferSdp||""}).getPublishSsrcs();e.detail.media.forEach((function(e){var r;"recvonly"!==e.direction&&(null===(r=e.ssrcs)||void 0===r||r.forEach((function(r){var n,i=null===(n=t.find((function(t){return t.mid===String(e.mid)})))||void 0===n?void 0:n.ssrc;i&&(r.id=String(i))})))}))},e.prototype.restorePublishMsid=function(e){var t=this,r=new c.SdpUtil({sdp:this.prevOfferSdp||""}).getPublishMsids();(null==r?void 0:r.length)&&e.detail.media.forEach((function(e){var n,i;if("recvonly"!==e.direction){var o=null===(n=r.find((function(t){return t.mid===String(e.mid)})))||void 0===n?void 0:n.msid;if(!o)return;var a=t.parseMsidString(o);e.msid=o||e.msid,null===(i=e.ssrcs)||void 0===i||i.forEach((function(e){switch(e.attribute){case"cname":e.value=a.track||e.value;break;case"msid":e.value=o||e.value}}))}}))},e.prototype.alignAnswerMidsWithOffer=function(e){var t=new c.SdpUtil({sdp:this.prevOfferSdp||""}).detail.media.map((function(e){return String(e.mid)})),r=e.detail.media.map((function(e){return String(e.mid)})),n=this.findDiff(r,t);e.removeMedia(n);var i=[];t.forEach((function(t){var r=e.detail.media.find((function(e){return String(e.mid)===t}));r&&i.push(r)})),e.detail.media=i.filter((function(e){return e}))},e.prototype.simulateOfferAnswer=function(){var e,t,r;return i(this,void 0,void 0,(function(){var n,i,a,s,u,d,p;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,null===(e=this.pc)||void 0===e?void 0:e.createOffer()];case 1:return n=o.sent(),i=new c.SdpUtil({sdp:(null==n?void 0:n.sdp)||""}),a=i.detail.media.filter((function(e){return"inactive"===e.direction})).map((function(e){return String(e.mid)})),this.restorePublishedSsrc(i),this.restorePublishMsid(i),this.prevOfferSdp=i.generate(),(s=new c.SdpUtil({sdp:this.prevAnswerSdp||""})).setMediaInactive(a),this.prevAnswerSdp=s.generate(),[3,3];case 2:throw u=o.sent(),new l.RtsError(f.ErrorCode.DATACHANNEL_CREATE_OFFER_ERROR,"CreateOffer error: ".concat(u),"",{pc:this.pc});case 3:return o.trys.push([3,5,,6]),[4,null===(t=this.pc)||void 0===t?void 0:t.setLocalDescription(new RTCSessionDescription({type:"offer",sdp:this.prevOfferSdp}))];case 4:return o.sent(),[3,6];case 5:throw d=o.sent(),new l.RtsError(f.ErrorCode.DATACHANNEL_SET_OFFER_ERROR,"SetLocalDescription error: ".concat(d),"",{sdp:this.prevOfferSdp});case 6:return o.trys.push([6,8,,9]),[4,null===(r=this.pc)||void 0===r?void 0:r.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:this.prevAnswerSdp}))];case 7:return o.sent(),[3,9];case 8:throw p=o.sent(),new l.RtsError(f.ErrorCode.DATACHANNEL_SET_ANSWER_ERROR,"SetRemoteDescription error: ".concat(p),"",{sdp:this.prevAnswerSdp});case 9:return[2]}}))}))},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];window.RTS_DATACHANNEL_DEBUG&&console.log.apply(console,a(["[PC-Core]"],e,!1))},e}();t.PeerConnectionCore=E},651:function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DataChannelCore=t.EDatachannelStatus=void 0;var a,s=r(844),c=r(961),u=r(854),d=o(r(885)),p=o(r(973)),l=o(r(985)),f=o(r(372));function h(){}!function(e){e[e.DATACHANNEL_STATUS_CLOSE=0]="DATACHANNEL_STATUS_CLOSE",e[e.DATACHANNEL_STATUS_OPEN=1]="DATACHANNEL_STATUS_OPEN"}(a=t.EDatachannelStatus||(t.EDatachannelStatus={}));var m=function(e){function t(t){var r=e.call(this)||this;return r.pendingPromiseMap=new Map,r.mutexSendData=!1,r.timerSendData=null,r.eventQueue=new u.CacheBuffer("send tasks"),r.datachannelList=[],r.pc=t.pc,r.eventHandler=t.onDatachannelEvent||h,r.datachannelList=t.datachannelList||[],r.createDatachannel(t.label),r}return i(t,e),t.prototype.getNextId=function(){var e=0,t=this.datachannelList.reduce((function(t,r){return"open"===r.readyState?t+1:(e||(e=r.id),t)}),0);return e||2*(t+1)},t.prototype.createDatachannel=function(e){var t=this,r={ordered:!0};(l.default.isIos||f.default.isSafari)&&"connected"===this.pc.connectionState&&(r.id=this.getNextId()),this.datachannel=this.pc.createDataChannel(e||"GRTN_RTC_DATACHANNEL"+"_".concat(Date.now()),r),this.datachannel.addEventListener("open",(function(){setTimeout((function(){t.eventHandler(a.DATACHANNEL_STATUS_OPEN),t.emit("statusChange",a.DATACHANNEL_STATUS_OPEN)}),200)})),this.datachannel.addEventListener("close",(function(){t.eventHandler(a.DATACHANNEL_STATUS_CLOSE),t.emit("statusChange",a.DATACHANNEL_STATUS_CLOSE)})),this.datachannel.addEventListener("closing",(function(){})),this.datachannel.addEventListener("error",(function(e){console.log(">> error",e),t.emit("error",e)})),this.datachannel.addEventListener("bufferedamountlow",(function(){})),this.datachannel.addEventListener("message",(function(e){t.emit("message",e.data)}))},Object.defineProperty(t.prototype,"id",{get:function(){return this.datachannel.id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"label",{get:function(){return this.datachannel.label},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"readyState",{get:function(){return this.datachannel.readyState},enumerable:!1,configurable:!0}),t.prototype.send=function(e){if("open"!==this.datachannel.readyState)throw new Error("Datachannel(label:".concat(this.datachannel.label,",id:").concat(this.datachannel.id,") is closed."));return this.datachannel.send(e)},t.prototype.sendData=function(e){var t=this;return new Promise((function(r,n){var i=new p.default(t.datachannel);if(t.mutexSendData){var o={sender:i,res:r,rej:n,data:e};t.eventQueue.cache(o)}else t.atomSend(i,r,n,e)}))},t.prototype.dispose=function(){var e;this.emit("dispose"),this.mutexSendData=!1,null!==this.timerSendData&&clearTimeout(this.timerSendData),this.timerSendData=null,this.eventQueue=new u.CacheBuffer("send tasks"),null===(e=this.datachannel)||void 0===e||e.close()},t.prototype.atomSend=function(e,r,n,i){var o=this;this.mutexSendData=!0,e.on("onSendDataDone",(function(){if(null!==o.timerSendData&&clearTimeout(o.timerSendData),o.timerSendData=null,o.mutexSendData=!1,!o.eventQueue.isEmpty()){var e=o.eventQueue.getFirst();o.atomSend(e.sender,e.res,e.rej,e.data)}})),this.timerSendData=setTimeout((function(){n(new c.RtsError(s.ErrorCode.DATACHANNEL_TIMEOUT_ERROR,"request timeout after ".concat(t.REQUEST_TIMEOUT,"ms"),"",i)),o.timerSendData=null,o.mutexSendData=!1,e.emit("onSendDataDone")}),t.REQUEST_TIMEOUT),e.sendingProcess(r,n,i)},t.REQUEST_TIMEOUT=5e3,t}(d.default);t.DataChannelCore=m},973:function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.EDatachannelSignalResCode=void 0;var s,c=r(844),u=r(961),d=a(r(885));!function(e){e[e.NGX_RTC_PUBLISH_ALREADY=402]="NGX_RTC_PUBLISH_ALREADY",e[e.NGX_RTC_REQUEST_FORBIDDEN=403]="NGX_RTC_REQUEST_FORBIDDEN",e[e.NGX_RTC_STREAM_NO_FOUND=404]="NGX_RTC_STREAM_NO_FOUND",e[e.NGX_RTC_SUBSCRIBE_ALREADY=410]="NGX_RTC_SUBSCRIBE_ALREADY",e[e.NGX_RTC_NORMAL_CLOSED=200]="NGX_RTC_NORMAL_CLOSED",e[e.NGX_RTC_LIMITED=508]="NGX_RTC_LIMITED",e[e.NGX_RTC_INTERNAL_SERVER_ERROR=500]="NGX_RTC_INTERNAL_SERVER_ERROR",e[e.NGX_RTC_BAD_REQUEST=400]="NGX_RTC_BAD_REQUEST",e[e.NGX_RTC_NEED_RETRY=213]="NGX_RTC_NEED_RETRY"}(s=t.EDatachannelSignalResCode||(t.EDatachannelSignalResCode={}));var p=function(e){function t(t){var r=e.call(this)||this;return r.datachannel=t,r}return i(t,e),t.prototype.sendingProcess=function(e,t,r){var n,i=this,o=performance.now();this.datachannel.onmessage=function(n){try{var a=JSON.parse(n.data),d=i.checkResponse(a);if(i.log("<<< Received:","".concat(Math.ceil(performance.now()-o),"ms"),a),d.pass)e(a);else{if(d.code===s.NGX_RTC_NEED_RETRY)return void setTimeout((function(){i.log(">>> Send:",r),i.datachannel.send(JSON.stringify(r))}),200);t(new u.RtsError(c.ErrorCode.DATACHANNEL_RESPONSE_ERROR,"[code]".concat(d.code,"; [msg]").concat(d.msg),d.traceId,{parsedData:a}))}}catch(e){t(new u.RtsError(c.ErrorCode.DATACHANNEL_PARSE_ERROR,"datachannel message parse error","",{data:n.data,err:e}))}i.emit("onSendDataDone")};try{this.log(">>> Sent:","".concat(r.type,"-").concat((null===(n=r.streams)||void 0===n?void 0:n.length)?r.streams[0].method:"-"),r)}catch(e){}this.datachannel.send(JSON.stringify(r))},t.prototype.checkResponse=function(e){var t={pass:!0,code:0,msg:"",traceId:""};0!==e.recode&&(t.pass=!1,t.code=e.recode,t.msg=e.msg);var r=e.streams;return r&&r.length>0&&r.forEach((function(e){200!==e.res_code&&(t.pass=!1,t.code=e.res_code,t.msg=e.res_msg,t.traceId=e.traceid)})),t},t.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];window.RTS_DATACHANNEL_DEBUG&&console.log.apply(console,o(["".concat(this.now()," [datachannel|").concat(this.datachannel.label,"|").concat(this.datachannel.id,"]")],e,!1))},t.prototype.now=function(){var e=new Date;return"".concat(e.getHours(),":").concat(e.getMinutes(),":").concat(e.getSeconds(),".").concat(e.getMilliseconds())},t}(d.default);t.default=p},844:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorCode=void 0,function(e){e[e.DATACHANNEL_SIGNAL_ERROR=15e3]="DATACHANNEL_SIGNAL_ERROR",e[e.DATACHANNEL_SET_OFFER_ERROR=15001]="DATACHANNEL_SET_OFFER_ERROR",e[e.DATACHANNEL_SET_ANSWER_ERROR=15002]="DATACHANNEL_SET_ANSWER_ERROR",e[e.DATACHANNEL_CREATE_OFFER_ERROR=15003]="DATACHANNEL_CREATE_OFFER_ERROR",e[e.DATACHANNEL_RESPONSE_ERROR=15004]="DATACHANNEL_RESPONSE_ERROR",e[e.DATACHANNEL_PARSE_ERROR=15005]="DATACHANNEL_PARSE_ERROR",e[e.DATACHANNEL_TIMEOUT_ERROR=15006]="DATACHANNEL_TIMEOUT_ERROR",e[e.CORE_NO_PC_ERROR=15007]="CORE_NO_PC_ERROR",e[e.CORE_PUBLIST_EXCEED_ERROR=15008]="CORE_PUBLIST_EXCEED_ERROR",e[e.CORE_PUB_REPLACE_URL_NOT_FOUND=15009]="CORE_PUB_REPLACE_URL_NOT_FOUND",e[e.CORE_TRANSCEIVERS_NOT_FOUND=15010]="CORE_TRANSCEIVERS_NOT_FOUND"}(t.ErrorCode||(t.ErrorCode={}))},961:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RtsError=void 0;var n=r(844);t.RtsError=function(e,t,r,i){this.errorCode=e,this.errorCodeName=n.ErrorCode[e],this.message=t,this.traceId=r,i&&(this.extraInfo=i)}},854:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CacheBuffer=void 0;var r=function(){function e(e){this.data=[],this.tag=e||"unknown",this.maxBufferLength=90}return e.prototype.setMaxCapacity=function(e){this.maxBufferLength=90,e>=0&&(this.maxBufferLength=e),this.maxBufferLength>200&&(this.maxBufferLength=200)},e.prototype.cache=function(e){this.data.length>this.maxBufferLength&&(this.data.shift(),console.log(this.tag+" CACHE: Reach Max Capacity")),this.data.push(e)},e.prototype.getFirst=function(){return this.data.shift()},e.prototype.isEmpty=function(){return this.data.length<=0},e}();t.CacheBuffer=r},885:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){this._eventMap={}}return e.prototype.listeners=function(e){return this._eventMap[e]||[]},e.prototype.emit=function(e){for(var t=this,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var i=this._eventMap[e];return!!Array.isArray(i)&&(i.forEach((function(e){return e.apply(t,r)})),!0)},e.prototype.off=function(e,t){var r=this._eventMap[e];return Array.isArray(r)&&(this._eventMap[e]=r.filter((function(e){return e!==t}))),this},e.prototype.removeAllListeners=function(e){return void 0===e?this._eventMap={}:this._eventMap[e]&&(this._eventMap[e]=[]),this},e.prototype.on=function(e,t){return this._eventMap[e]?this._eventMap[e].push(t):this._eventMap[e]=[t],this},e.prototype.once=function(e,t){var r=this,n=function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];r.off(e,n),t.apply(r,i)};return this.on(e,n),this},e}();t.default=r},887:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.intersection=t.pruneSubUrl=t.parseUrlSubParams=void 0,t.parseUrlSubParams=function(e){var t={subVideo:!0,subAudio:!0};return e?(e.includes("@subvideo=no")&&(t.subVideo=!1),e.includes("@subaudio=no")&&(t.subAudio=!1),t):t},t.pruneSubUrl=function(e,t){var r=e||"";return r=r.replace("@subaudio=no","").replace("@subvideo=no",""),t&&(r=r.split("?")[0]),r},t.intersection=function(e,t){return e.filter((function(e){return t.includes(e)}))}},248:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.SdpUtil=void 0;var o=r(766),a=function(){function e(e){if(this.rawSdp=e.sdp,!e.sdp)throw new Error("No sdp to parse");this.sdpDetail=this.parse()}return Object.defineProperty(e.prototype,"detail",{get:function(){return this.sdpDetail},enumerable:!1,configurable:!0}),e.prototype.removeMedia=function(e){return this.removeMediaInner(e)},e.prototype.keepMedia=function(e){return this.removeMediaInner(e,{revert:!0})},e.prototype.removeMediaInner=function(e,t){void 0===t&&(t={revert:!1}),e.length&&this.sdpDetail.media&&this.sdpDetail.media.length&&(t.revert?this.sdpDetail.media=this.sdpDetail.media.filter((function(t){return e.includes(String(t.mid)||"")})):this.sdpDetail.media=this.sdpDetail.media.filter((function(t){return!e.includes(String(t.mid)||"")})),this.updateBundle())},e.prototype.addOrUpdateMedia=function(e,t){void 0===t&&(t={}),e=e.map((function(e){return n(n({},e),{setup:"passive"})}));var r=[];this.sdpDetail.media=this.sdpDetail.media.map((function(n){var i=e.find((function(e){return e.mid===n.mid}));if(i){r.push(n.mid);var o=i,a=n;return t.isPublish&&(o.ssrcs=a.ssrcs,o.ssrcGroups=a.ssrcGroups),i}return n})),this.sdpDetail.media=i(i([],this.sdpDetail.media,!0),e.filter((function(e){return!r.includes(e.mid)})),!0),this.updateBundle()},e.prototype.addMedia=function(e){var t;e=e.map((function(e){return n(n({},e),{setup:"passive"})})),this.sdpDetail.media=i(i([],this.sdpDetail.media,!0),e,!0);var r=e.reduce((function(e,t){return e+" "+t.mid}),""),o=null===(t=this.sdpDetail.groups)||void 0===t?void 0:t.find((function(e){return"BUNDLE"===e.type}));o&&(o.mids+="".concat(r))},e.prototype.setMediaInactive=function(e){this.sdpDetail.media.forEach((function(t){e.includes(String(t.mid))&&(t.direction="inactive")})),this.updateBundle()},e.prototype.getPublishSsrcs=function(){var e=[];return this.sdpDetail.media.forEach((function(t){"recvonly"!==t.direction&&t.ssrcs&&e.push({type:t.type,ssrc:t.ssrcs[0].id||"ERR_NOT_FOUND",mid:String(t.mid)})})),e},e.prototype.getPublishMsids=function(){var e=[];return this.sdpDetail.media.forEach((function(t){"recvonly"!==t.direction&&t.msid&&e.push({type:t.type,msid:t.msid,mid:String(t.mid)})})),e},e.prototype.generate=function(){return(0,o.write)(this.sdpDetail)},e.prototype.updateBundle=function(){var e,t=null===(e=this.sdpDetail.groups)||void 0===e?void 0:e.find((function(e){return"BUNDLE"===e.type}));t&&(t.mids=this.sdpDetail.media.reduce((function(e,t){return e+t.mid+" "}),"").trim())},e.prototype.addNack=function(){this.sdpDetail.media.forEach((function(e){var t,r,n;if("audio"===e.type){if(null===(t=e.rtcpFb)||void 0===t?void 0:t.some((function(e){return"nack"===e.type})))return;var i=null===(r=e.rtp.find((function(e){return"opus"===e.codec})))||void 0===r?void 0:r.payload;i&&(null===(n=e.rtcpFb)||void 0===n||n.push({payload:i,type:"nack"}))}}))},e.prototype.parse=function(){var e=(0,o.parse)(this.rawSdp);return this.patchMsid(e)},e.prototype.getMids=function(e){return(null==e?void 0:e.length)?e.reduce((function(e,t){return i(i([],e,!0),[String(t.mid)],!1)}),[]):[]},e.prototype.patchMsid=function(e){return e.media.forEach((function(e){var t,r;"application"===e.type||e.msid||(e.msid=null===(r=null===(t=e.ssrcs)||void 0===t?void 0:t.find((function(e){return"msid"===e.attribute})))||void 0===r?void 0:r.value)})),e},e}();t.SdpUtil=a},237:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UrlData=void 0;var n=r(887),i=function(){function e(e){var t=(0,n.parseUrlSubParams)(e.url);this.data={url:e.url,subAudio:t.subAudio,subVideo:t.subVideo},"boolean"==typeof e.subAudio&&(this.data.subAudio=e.subAudio),"boolean"==typeof e.subVideo&&(this.data.subVideo=e.subVideo)}return Object.defineProperty(e.prototype,"subVideo",{get:function(){return this.data.subVideo},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subAudio",{get:function(){return this.data.subAudio},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){return(0,n.pruneSubUrl)(this.data.url)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"originalUrl",{get:function(){return this.data.url},enumerable:!1,configurable:!0}),e}();t.UrlData=i},619:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},a=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.Signal=void 0;var s,c,u,d=r(651),p=r(887);!function(e){e.Sub="sub",e.Pub="pub"}(s||(s={})),function(e){e.Add="add",e.Active="active",e.Stop="stop",e.Delete="delete"}(c||(c={})),function(e){e.Audio="audio",e.Video="video",e.Data="data"}(u||(u={}));var l=function(){function e(e){this.latestMsgId=0,this.latestSubAddMsgId=0,this.pc=e.pc,this.datachannel=new d.DataChannelCore({pc:this.pc,onDatachannelEvent:e.onDatachannelEvent})}return e.prototype.getDatachannelCore=function(){return this.datachannel},e.prototype.subscribeAdd=function(e,t,r){var a;return i(this,void 0,void 0,(function(){var i;return o(this,(function(o){switch(o.label){case 0:return i=n(n({},this.baseParams({type:s.Sub,method:c.Add})),{streams:e.map((function(e,n){var i=e.urlData,o=[];return i.subAudio&&!r.isMsidSubPubDone(i.url,{aMsid:e.aMsid[0]})&&o.push({type:u.Audio,name:e.aMsid[0]}),i.subVideo&&!r.isMsidSubPubDone(i.url,{vMsid:e.vMsid[0]})&&o.push({type:u.Video,name:e.vMsid[0]}),{method:c.Add,url:i.url,msid:o,sdp:t[n],ttl:300}}))}),[4,null===(a=this.datachannel)||void 0===a?void 0:a.sendData(i)];case 1:return[2,o.sent()]}}))}))},e.prototype.subscribeActive=function(e){var t;return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=n(n({},this.baseParams({type:s.Sub,method:c.Active})),{streams:e.map((function(e){var t=e.urlData;return{method:c.Active,url:t.url}}))}),[4,null===(t=this.datachannel)||void 0===t?void 0:t.sendData(r)];case 1:return i.sent(),[2]}}))}))},e.prototype.subscribeDelete=function(e){var t;return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=n(n({},this.baseParams()),{streams:e.map((function(e){var t=e.url,r=e.aMsid,n=e.vMsid,i=[];return(null==r?void 0:r.length)&&(i=a(a([],i,!0),r.map((function(e){return{name:e}})),!0)),(null==n?void 0:n.length)&&(i=a(a([],i,!0),n.map((function(e){return{name:e}})),!0)),{method:c.Delete,url:(0,p.pruneSubUrl)(t),msid:i}}))}),[4,null===(t=this.datachannel)||void 0===t?void 0:t.sendData(r)];case 1:return[2,i.sent()]}}))}))},e.prototype.subscribeStop=function(e){var t;return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=n(n({},this.baseParams()),{streams:e.map((function(e){var t=e.urlData;return{method:c.Stop,url:t.url}}))}),[4,null===(t=this.datachannel)||void 0===t?void 0:t.sendData(r)];case 1:return[2,i.sent()]}}))}))},e.prototype.subscribeAddDatachannel=function(e){var t;return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=n(n({},this.baseParams({type:s.Sub,method:c.Add})),{streams:e.map((function(e){var t=e.url,r=e.msid;return{method:c.Add,url:t,msid:[{type:u.Data,name:r}]}}))}),[4,null===(t=this.datachannel)||void 0===t?void 0:t.sendData(r)];case 1:return[2,i.sent()]}}))}))},e.prototype.subscribeActiveDatachannel=function(e){var t;return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=n(n({},this.baseParams({type:s.Sub,method:c.Active})),{streams:e.map((function(e){var t=e.url,r=e.datachannelId,n=e.msid;return{method:c.Active,url:t,msid:[{type:u.Data,name:n,channel:r}]}}))}),[4,null===(t=this.datachannel)||void 0===t?void 0:t.sendData(r)];case 1:return[2,i.sent()]}}))}))},e.prototype.subscribeStopDatachannel=function(e){var t;return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:return r=n(n({},this.baseParams()),{streams:e.map((function(e){var t=e.url;return{method:c.Stop,url:t}}))}),[4,null===(t=this.datachannel)||void 0===t?void 0:t.sendData(r)];case 1:return[2,i.sent()]}}))}))},e.prototype.publishAdd=function(e,t,r,a){var u;return i(this,void 0,void 0,(function(){var i;return o(this,(function(o){return i=n(n({},this.baseParams({type:s.Pub})),{streams:e.map((function(e,n){var i=r[n],o=a[n],s=[];return i.length&&s.push({type:"video",name:i[0].trim()}),o.length&&s.push({type:"audio",name:o[0].trim()}),{method:c.Add,url:e,msid:s,sdp:t[n]}}))}),[2,null===(u=this.datachannel)||void 0===u?void 0:u.sendData(i)]}))}))},e.prototype.publishDelete=function(e){var t;return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){return r=n(n({},this.baseParams({type:s.Pub})),{streams:e.map((function(e){var t=e.url,r=e.aMsid,n=e.vMsid,i=[];return(null==r?void 0:r.length)&&(i=a(a([],i,!0),r.map((function(e){return{name:e}})),!0)),(null==n?void 0:n.length)&&(i=a(a([],i,!0),n.map((function(e){return{name:e}})),!0)),{method:c.Delete,url:(0,p.pruneSubUrl)(t),msid:i}}))}),[2,null===(t=this.datachannel)||void 0===t?void 0:t.sendData(r)]}))}))},e.prototype.publishStop=function(e){var t;return i(this,void 0,void 0,(function(){var r;return o(this,(function(i){return r=n(n({},this.baseParams({type:s.Pub})),{streams:e.map((function(e){return{method:c.Stop,url:e}}))}),[2,null===(t=this.datachannel)||void 0===t?void 0:t.sendData(r)]}))}))},e.prototype.dispose=function(){this.datachannel.dispose()},e.prototype.baseParams=function(e){void 0===e&&(e={type:s.Sub});var t=0;return e.type===s.Sub&&e.method===c.Add?(t=++this.latestMsgId,this.latestSubAddMsgId=this.latestMsgId):t=e.type===s.Sub&&e.method===c.Active?this.latestSubAddMsgId:++this.latestMsgId,{msg_id:t,version:2,type:e.type}},e}();t.Signal=l},628:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.StreamManager=t.EStreamType=void 0;var o,a=r(887);!function(e){e.Subscribe="sub",e.Publish="pub"}(o=t.EStreamType||(t.EStreamType={}));var s=function(){function e(e){this.streamMap={}}return e.prototype.init=function(e,t){void 0===t&&(t=o.Subscribe);var r=(0,a.pruneSubUrl)(e);e=(0,a.pruneSubUrl)(e,!0),this.has(e)||(this.streamMap[e]={type:t,videoInfoList:[],audioInfoList:[],streamList:[],originUrl:r})},e.prototype.remove=function(e){delete this.streamMap[(0,a.pruneSubUrl)(e,!0)]},e.prototype.update=function(e,t){var r=this.get(e);if(!r)throw new Error("No url found");if(t.aMsid){var n=r.audioInfoList.find((function(e){return e.msid===t.aMsid}))||this.createMediaItem(t.aMsid,"audio");t.aTransceiver&&(n.transceiver=t.aTransceiver),t.stream&&(n.streamId=t.stream.id),this.updateMediaInfoList(n,r.audioInfoList)}if(t.vMsid){var o=r.videoInfoList.find((function(e){return e.msid===t.vMsid}))||this.createMediaItem(t.vMsid,"video");t.vTransceiver&&(o.transceiver=t.vTransceiver),t.stream&&(o.streamId=t.stream.id),this.updateMediaInfoList(o,r.videoInfoList)}t.stream&&(r.streamList.some((function(e){return e.id===t.stream.id}))||(r.streamList=i(i([],r.streamList,!0),[t.stream],!1)))},e.prototype.pruneStreamList=function(e){var t=this.get(e);t&&(t.streamList=t.streamList.filter((function(e){var t;return(null===(t=e.mediaStream)||void 0===t?void 0:t.getTracks().length)>0})))},e.prototype.updateSdpInfo=function(e,t){var r,n=this.get(e);if(!n)throw new Error("No url found");if(t.aMsid?r=n.audioInfoList.find((function(e){return e.msid===t.aMsid})):t.vMsid&&(r=n.videoInfoList.find((function(e){return e.msid===t.vMsid}))),!r)throw new Error("No target media found");r.ssrc=t.ssrc,r.codec=t.codec,r.pt=t.pt,r.from=t.from},e.prototype.get=function(e){return this.streamMap[(0,a.pruneSubUrl)(e,!0)]},e.prototype.has=function(e){return!!this.get(e)},e.prototype.removeMsid=function(e,t){e=(0,a.pruneSubUrl)(e,!0);var r=this.get(e);r&&(t.vMsid&&(r.videoInfoList=r.videoInfoList.filter((function(e){return e.msid!==t.vMsid}))),t.aMsid&&(r.audioInfoList=r.audioInfoList.filter((function(e){return e.msid!==t.aMsid}))))},e.prototype.getMids=function(e,t){void 0===t&&(t={filterSubDone:!1}),e=(0,a.pruneSubUrl)(e,!0);var r=this.streamMap[e];return r?i(i([],r.audioInfoList.reduce((function(e,r){return r.transceiver&&(!t.filterSubDone||t.filterSubDone&&!r.subDone)?i(i([],e,!0),[String(r.transceiver.mid)],!1):e}),[]),!0),r.videoInfoList.reduce((function(e,r){return r.transceiver&&(!t.filterSubDone||t.filterSubDone&&!r.subDone)?i(i([],e,!0),[String(r.transceiver.mid)],!1):e}),[]),!0):[]},e.prototype.getAllTransceivers=function(e){if(!e)return[];e=(0,a.pruneSubUrl)(e,!0);var t=this.get(e);return t?i(i([],t.videoInfoList.map((function(e){return e.transceiver})),!0),t.audioInfoList.map((function(e){return e.transceiver})),!0):[]},e.prototype.getTransceiver=function(e,t){if(void 0===t&&(t={}),e){e=(0,a.pruneSubUrl)(e,!0);var r=t.vMsid,n=t.aMsid,i=this.get(e);if(i){var o;if(r)return null==(o=i.videoInfoList.find((function(e){return e.msid===r})))?void 0:o.transceiver;if(n)return null==(o=i.audioInfoList.find((function(e){return e.msid===n})))?void 0:o.transceiver}}},e.prototype.getStreamByMsid=function(e){var t,r,n=this.get(e.url);if(n){if(e.vMsid){var i=null===(t=n.videoInfoList.find((function(t){return t.msid===e.vMsid})))||void 0===t?void 0:t.streamId;return n.streamList.find((function(e){return e.id===i}))}if(e.aMsid){var o=null===(r=n.audioInfoList.find((function(t){return t.msid===e.aMsid})))||void 0===r?void 0:r.streamId;return n.streamList.find((function(e){return e.id===o}))}return n.streamList[0]}},e.prototype.hasTransceiver=function(e,t){return void 0===t&&(t={}),!!this.getTransceiver(e,t)},e.prototype.removeTransceiver=function(e,t){e=(0,a.pruneSubUrl)(e,!0);var r,n=this.get(e);n&&(t.vMsid&&(r=n.videoInfoList.find((function(e){return e.msid===t.vMsid})))&&(r.transceiver=void 0),t.aMsid&&(r=n.audioInfoList.find((function(e){return e.msid===t.aMsid})))&&(r.transceiver=void 0))},e.prototype.markAlreadySubPub=function(e,t){void 0===t&&(t={}),e=(0,a.pruneSubUrl)(e,!0);var r,n=this.streamMap[e];n&&(t.vMsid&&(r=n.videoInfoList.find((function(e){return e.msid===t.vMsid})))&&(r[t.isPub?"pubDone":"subDone"]=!t.reset),t.aMsid&&(r=n.audioInfoList.find((function(e){return e.msid===t.aMsid})))&&(r[t.isPub?"pubDone":"subDone"]=!t.reset))},e.prototype.isMsidSubPubDone=function(e,t){void 0===t&&(t={}),e=(0,a.pruneSubUrl)(e,!0);var r=this.streamMap[e];if(!r)return!1;if(t.vMsid){var n=r.videoInfoList.find((function(e){return e.msid===t.vMsid}));return t.isPub?null==n?void 0:n.pubDone:null==n?void 0:n.subDone}return t.aMsid?(n=r.audioInfoList.find((function(e){return e.msid===t.aMsid})),t.isPub?null==n?void 0:n.pubDone:null==n?void 0:n.subDone):void 0},e.prototype.getAllMediaInfoList=function(e,t){var r=this.get(e);return r?i(i([],r.audioInfoList.map((function(e){var i,a,s,c,u=e.type,d=e.msid,p=e.ssrc,l=e.pt,f=e.codec,h=e.from,m=e.transceiver,v={type:u,msid:d,ssrc:p,pt:l,codec:f,from:h,trackId:r.type===o.Subscribe?null===(a=null===(i=null==m?void 0:m.receiver)||void 0===i?void 0:i.track)||void 0===a?void 0:a.id:null===(c=null===(s=null==m?void 0:m.sender)||void 0===s?void 0:s.track)||void 0===c?void 0:c.id};return t?n(n({},v),{transceiver:m}):v})),!0),r.videoInfoList.map((function(e){var i,a,s,c,u=e.type,d=e.msid,p=e.ssrc,l=e.pt,f=e.codec,h=e.from,m=e.transceiver,v={type:u,msid:d,ssrc:p,pt:l,codec:f,from:h,trackId:r.type===o.Subscribe?null===(a=null===(i=null==m?void 0:m.receiver)||void 0===i?void 0:i.track)||void 0===a?void 0:a.id:null===(c=null===(s=null==m?void 0:m.sender)||void 0===s?void 0:s.track)||void 0===c?void 0:c.id};return t?n(n({},v),{transceiver:m}):v})),!0):[]},e.prototype.getOriginUrl=function(e){var t=(0,a.pruneSubUrl)(e,!0),r=this.get(t);return r?r.originUrl:e},e.prototype.getAllTrackPairList=function(e){var t,r,n,i,a=[];for(var s in this.streamMap){var c=this.streamMap[s];if(c.type===e)for(var u=Math.max(c.audioInfoList.length,c.videoInfoList.length),d=0;d<u;d++){var p={url:s};d<c.audioInfoList.length&&(p.aTransceiver=e===o.Subscribe?null===(t=c.audioInfoList[d].transceiver)||void 0===t?void 0:t.receiver:null===(r=c.audioInfoList[d].transceiver)||void 0===r?void 0:r.sender,p.aMsid=c.audioInfoList[d].msid),d<c.videoInfoList.length&&(p.vTransceiver=e===o.Subscribe?null===(n=c.videoInfoList[d].transceiver)||void 0===n?void 0:n.receiver:null===(i=c.videoInfoList[d].transceiver)||void 0===i?void 0:i.sender,p.vMsid=c.videoInfoList[d].msid),a.push(p)}}return a},e.prototype.getSender=function(e,t,r){var n,i,o=void 0,a=this.getAllMediaInfoList(e,!0);return r?a.forEach((function(e){var n,i,a,s=null===(i=null===(n=e.transceiver)||void 0===n?void 0:n.sender)||void 0===i?void 0:i.track;(null==s?void 0:s.kind)===t&&e.msid===r&&(o=null===(a=e.transceiver)||void 0===a?void 0:a.sender)})):o=null===(i=null===(n=null==a?void 0:a.find((function(e){var r,n,i;return(null===(i=null===(n=null===(r=e.transceiver)||void 0===r?void 0:r.sender)||void 0===n?void 0:n.track)||void 0===i?void 0:i.kind)===t})))||void 0===n?void 0:n.transceiver)||void 0===i?void 0:i.sender,o},e.prototype.getReceiver=function(e,t,r){var n,i,o=void 0,a=this.getAllMediaInfoList(e,!0);return r?a.forEach((function(e){var n,i,a,s=null===(i=null===(n=e.transceiver)||void 0===n?void 0:n.receiver)||void 0===i?void 0:i.track;(null==s?void 0:s.kind)===t&&e.msid===r&&(o=null===(a=e.transceiver)||void 0===a?void 0:a.receiver)})):o=null===(i=null===(n=null==a?void 0:a.find((function(e){var r,n,i;return(null===(i=null===(n=null===(r=e.transceiver)||void 0===r?void 0:r.receiver)||void 0===n?void 0:n.track)||void 0===i?void 0:i.kind)===t})))||void 0===n?void 0:n.transceiver)||void 0===i?void 0:i.receiver,o},e.prototype.dispose=function(){this.streamMap={}},e.prototype.updateMediaInfoList=function(e,t){var r=t.findIndex((function(t){return t.msid===e.msid}));-1!==r?t.splice(r,1,e):t.push(e)},e.prototype.findMediaItemByMsid=function(e,t){return t.find((function(t){return t.msid===e}))},e.prototype.createMediaItem=function(e,t){return{msid:e,ssrc:void 0,transceiver:void 0,subDone:!1,pubDone:!1,type:t,streamId:void 0}},e}();t.StreamManager=s},372:e=>{"use strict";e.exports=window.BrowserUtil},985:e=>{"use strict";e.exports=window.SystemUtil}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}var n={};return(()=>{"use strict";var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.DataChannelCore=e.EDatachannelStatus=e.PeerConnectionCore=void 0;var t=r(776);Object.defineProperty(e,"PeerConnectionCore",{enumerable:!0,get:function(){return t.PeerConnectionCore}}),Object.defineProperty(e,"EDatachannelStatus",{enumerable:!0,get:function(){return t.EDatachannelStatus}});var i=r(651);Object.defineProperty(e,"DataChannelCore",{enumerable:!0,get:function(){return i.DataChannelCore}})})(),n})(),e.exports=n()},function(e,t,r){
5
+ /*! media-device - ver 1.2.0 created:2023/9/6 16:39:39 */
6
+ self,e.exports=(()=>{"use strict";var e={304:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserDeviceManager=void 0;var n=r(101),i=r(853),o=r(62),a=r(913),s=r(331),c=r(1),u=r(935),d=r(603),p=function(){function e(){this.systemUtil=new n.SystemUtil,this.deviceManager=this.createDeviceManager()}return e.prototype.getCameraList=function(){return this.deviceManager.getCameraList()},e.prototype.getMicList=function(){return this.deviceManager.getMicList()},e.prototype.getSpeakerList=function(){return this.deviceManager.getSpeakerList()},e.prototype.getAudioTrack=function(e){return this.deviceManager.getAudioTrack(e)},e.prototype.getVideoTrack=function(e){return this.deviceManager.getVideoTrack(e)},e.prototype.getScreenTrack=function(e){return this.deviceManager.getScreenTrack(e)},e.prototype.getAudioStream=function(e){return this.deviceManager.getAudioStream(e)},e.prototype.getVideoStream=function(e){return this.deviceManager.getVideoStream(e)},e.prototype.getScreenStream=function(e){return this.deviceManager.getScreenStream(e)},e.prototype.checkSupportScreenShare=function(){return this.deviceManager.checkSupportScreenShare()},e.prototype.createDeviceManager=function(){return this.systemUtil.isWindows?new u.WindowsDeviceManager:this.systemUtil.isAndroid?new i.AndroidDeviceManager:this.systemUtil.isIos?new a.IosDeviceManager:this.systemUtil.isMacOS?new c.MacDeviceManager:this.systemUtil.isLinux?new s.LinuxDeviceManager:new o.BaseDeviceManager},e.isDeviceManagerError=d.DeviceError.isDeviceManagerError,e}();t.BrowserDeviceManager=p},603:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DeviceError=t.DeviceErrorDescription=t.DeviceErrorCode=void 0;var n=r(610);!function(e){e[e.ERROR_DEVICE_UNKNOWNERROR=1e4]="ERROR_DEVICE_UNKNOWNERROR",e[e.ERROR_DEVICE_AUDIODEVICE_NOTFOUND=10001]="ERROR_DEVICE_AUDIODEVICE_NOTFOUND",e[e.ERROR_DEVICE_VIDEODEVICE_NOTFOUND=10002]="ERROR_DEVICE_VIDEODEVICE_NOTFOUND",e[e.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED=10003]="ERROR_DEVICE_AUDIODEVICE_NOTALLOWED",e[e.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED=10004]="ERROR_DEVICE_VIDEODEVICE_NOTALLOWED",e[e.ERROR_DEVICE_AUDIODEVICE_NOTREADABLE=10005]="ERROR_DEVICE_AUDIODEVICE_NOTREADABLE",e[e.ERROR_DEVICE_VIDEODEVICE_NOTREADABLE=10006]="ERROR_DEVICE_VIDEODEVICE_NOTREADABLE",e[e.ERROR_DEIVCE_CONSTRAINEDERROR=10007]="ERROR_DEIVCE_CONSTRAINEDERROR",e[e.ERROR_SCREENSHARE_UNKNOWNERRO=10010]="ERROR_SCREENSHARE_UNKNOWNERRO",e[e.ERROR_SCREENSHARE_NOTALLOWED=10011]="ERROR_SCREENSHARE_NOTALLOWED",e[e.ERROR_SCREENSHARE_ENDED=10012]="ERROR_SCREENSHARE_ENDED",e[e.ERROR_SCREENSHARE_NOPERMISSION=10013]="ERROR_SCREENSHARE_NOPERMISSION",e[e.ERROR_SCREENSHARE_INVALIDACCESS=10014]="ERROR_SCREENSHARE_INVALIDACCESS",e[e.ERROR_SCREENSHARE_NOTSUPPORT=10018]="ERROR_SCREENSHARE_NOTSUPPORT",e[e.ERROR_DEVICE_NOTSUPPORT=10019]="ERROR_DEVICE_NOTSUPPORT"}(t.DeviceErrorCode||(t.DeviceErrorCode={})),function(e){e.ERRORMESSAGE_DEVICENOTFOUND="Requested device not found",e.ERRORMESSAGE_DEVICENOTALLOWED="Permission denied",e.ERRORMESSAGE_MACCHROME_DEVICENOTREADABLE="Permission denied by system",e.ERRORMESSAGE_MACSAFARI_DEVICENOTALLOWED="The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.",e.ERRORMESSAGE_MOBILEDEVICE_NOTALLOWED="video device not allowed",e.ERRORMESSAGE_AUDIODEVICENOTREADABLE="Could not start audio source",e.ERRORMESSAGE_VIDEODEVICENOTREADABLE="Could not start video source",e.ERRORNAME_DEVICENOTFOUND="NotFoundError",e.ERRORNAME_DEVICENOTALLOWED="NotAllowedError",e.ERRORNAME_DEVICENOTREADABLE="NotReadableError",e.ERRORNAME_DEVICEOVERCONSTRAINED="OverconstrainedError",e.ERRORNAME_INVALID_ACCESS="InvalidAccessError"}(t.DeviceErrorDescription||(t.DeviceErrorDescription={}));var i=function(){function e(e,t){this.linkUtil=new n.LinkUtil,this.code=e,this.reason=t,this.relatedLink=this.linkUtil.getRelatedLink(e)}return e.isDeviceManagerError=function(e){return!!(e&&"object"==typeof e&&"code"in e&&"reason"in e)},e}();t.DeviceError=i},873:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FacingMode=t.DeviceType=t.MobileCameraType=void 0,function(e){e[e.USER=0]="USER",e[e.ENV=1]="ENV"}(t.MobileCameraType||(t.MobileCameraType={})),function(e){e.Camera="videoinput",e.Mic="audioinput",e.Screen="screen",e.Speaker="audiooutput"}(t.DeviceType||(t.DeviceType={})),function(e){e.USER="user",e.ENVIRONMENT="environment"}(t.FacingMode||(t.FacingMode={}))},853:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.AndroidDeviceManager=void 0;var o=function(e){function t(){return e.call(this)||this}return i(t,e),t}(r(583).MobileDeviceManager);t.AndroidDeviceManager=o},62:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BaseDeviceManager=void 0;var n=r(603),i=r(873),o=function(){function e(){}return e.prototype.checkSupportScreenShare=function(){return!!(navigator&&navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia&&navigator.mediaDevices.getDisplayMedia)},e.prototype.getCameraList=function(){var e=this;return new Promise((function(t,r){e.checkSupport()?e.getDeviceRight(i.DeviceType.Camera).then((function(){e.getDeviceList(i.DeviceType.Camera).then((function(e){t(e)})).catch((function(t){r(e.parseError(i.DeviceType.Camera,t))}))})).catch((function(t){r(e.parseError(i.DeviceType.Camera,t))})):r(new n.DeviceError(n.DeviceErrorCode.ERROR_DEVICE_NOTSUPPORT,"not support navigator.mediaDevices"))}))},e.prototype.getMicList=function(){var e=this;return new Promise((function(t,r){e.checkSupport()?e.getDeviceRight(i.DeviceType.Mic).then((function(){e.getDeviceList(i.DeviceType.Mic).then((function(e){t(e)})).catch((function(t){r(e.parseError(i.DeviceType.Mic,t))}))})).catch((function(t){r(e.parseError(i.DeviceType.Mic,t))})):r(new n.DeviceError(n.DeviceErrorCode.ERROR_DEVICE_NOTSUPPORT,"not support navigator.mediaDevices"))}))},e.prototype.getSpeakerList=function(){var e=this;return new Promise((function(t,r){e.checkSupport()?e.getDeviceRight(i.DeviceType.Speaker).then((function(){e.getDeviceList(i.DeviceType.Speaker).then((function(e){t(e)})).catch((function(t){r(e.parseError(i.DeviceType.Speaker,t))}))})).catch((function(t){r(e.parseError(i.DeviceType.Speaker,t))})):r(new n.DeviceError(n.DeviceErrorCode.ERROR_DEVICE_NOTSUPPORT,"not support navigator.mediaDevices"))}))},e.prototype.getAudioTrack=function(e){return this.getAudioStream(e).then((function(e){return e.getAudioTracks()[0]}))},e.prototype.getAudioStream=function(e){var t=this;return new Promise((function(r,o){var a;t.checkSupport()?(a=e&&e.deviceId?{audio:{deviceId:e.deviceId}}:{audio:!0},navigator.mediaDevices.getUserMedia(a).then((function(e){r(e)})).catch((function(e){o(t.parseError(i.DeviceType.Mic,e))}))):o(new n.DeviceError(n.DeviceErrorCode.ERROR_DEVICE_NOTSUPPORT,"not support navigator.mediaDevices"))}))},e.prototype.getVideoTrack=function(e){return this.getVideoStream(e).then((function(e){return e.getVideoTracks()[0]}))},e.prototype.getVideoStream=function(e){var t=this;return new Promise((function(r,o){if(t.checkSupport()){var a=t.createVideoConstraints(e);navigator.mediaDevices.getUserMedia(a).then((function(e){r(e)})).catch((function(e){o(t.parseError(i.DeviceType.Camera,e))}))}else o(new n.DeviceError(n.DeviceErrorCode.ERROR_DEVICE_NOTSUPPORT,"not support navigator.mediaDevices"))}))},e.prototype.getScreenTrack=function(e){return this.getScreenStream(e).then((function(e){return e.getTracks()}))},e.prototype.getScreenStream=function(e){var t=this;return new Promise((function(r,o){t.checkSupportScreenShare()?navigator.mediaDevices.getDisplayMedia(e).then((function(e){r(e)})).catch((function(e){o(t.parseError(i.DeviceType.Screen,e))})):o(new n.DeviceError(n.DeviceErrorCode.ERROR_SCREENSHARE_NOTSUPPORT,"browser not support screenshare"))}))},e.prototype.checkSupport=function(){return!!(navigator&&navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices&&navigator.mediaDevices.getUserMedia)},e.prototype.getDeviceList=function(e){return new Promise((function(t,r){navigator.mediaDevices.enumerateDevices().then((function(r){var n=[];r.forEach((function(t){t.kind===e&&n.push(t)})),t(n)})).catch((function(e){r(e)}))}))},e.prototype.getDeviceRight=function(e){return new Promise((function(t,r){var n;i.DeviceType.Camera===e?n={video:!0}:i.DeviceType.Mic!==e&&i.DeviceType.Speaker!==e||(n={audio:!0}),navigator.mediaDevices.getUserMedia(n).then((function(e){e.getTracks().forEach((function(e){e.stop()})),t(void 0)})).catch((function(e){t(void 0)}))}))},e.prototype.parseError=function(e,t){var r=null;return i.DeviceType.Mic===e?r=this.parseAudioError(t):i.DeviceType.Camera===e?r=this.parseVideoError(t):i.DeviceType.Screen===e&&(r=this.parseScreenError(t)),null===r?new n.DeviceError(n.DeviceErrorCode.ERROR_DEVICE_UNKNOWNERROR,""):r},e.prototype.parseAudioError=function(e){return e.message===n.DeviceErrorDescription.ERRORMESSAGE_DEVICENOTFOUND||e.name===n.DeviceErrorDescription.ERRORNAME_DEVICENOTFOUND?new n.DeviceError(n.DeviceErrorCode.ERROR_DEVICE_AUDIODEVICE_NOTFOUND,"audio device not found"):e.message===n.DeviceErrorDescription.ERRORMESSAGE_DEVICENOTALLOWED||e.message===n.DeviceErrorDescription.ERRORMESSAGE_MACSAFARI_DEVICENOTALLOWED?new n.DeviceError(n.DeviceErrorCode.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED,"audio device not allowed"):e.message===n.DeviceErrorDescription.ERRORMESSAGE_MACCHROME_DEVICENOTREADABLE||e.message===n.DeviceErrorDescription.ERRORMESSAGE_AUDIODEVICENOTREADABLE||e.message===n.DeviceErrorDescription.ERRORNAME_DEVICENOTREADABLE?new n.DeviceError(n.DeviceErrorCode.ERROR_DEVICE_AUDIODEVICE_NOTREADABLE,"audio device not readable"):null},e.prototype.parseVideoError=function(e){return e.message===n.DeviceErrorDescription.ERRORMESSAGE_DEVICENOTFOUND||e.name===n.DeviceErrorDescription.ERRORNAME_DEVICENOTFOUND?new n.DeviceError(n.DeviceErrorCode.ERROR_DEVICE_VIDEODEVICE_NOTFOUND,"video device not found"):e.message===n.DeviceErrorDescription.ERRORMESSAGE_DEVICENOTALLOWED||e.message===n.DeviceErrorDescription.ERRORMESSAGE_MOBILEDEVICE_NOTALLOWED||e.message===n.DeviceErrorDescription.ERRORMESSAGE_MACSAFARI_DEVICENOTALLOWED?new n.DeviceError(n.DeviceErrorCode.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED,"video device not allowed"):e.message===n.DeviceErrorDescription.ERRORMESSAGE_MACCHROME_DEVICENOTREADABLE||e.message===n.DeviceErrorDescription.ERRORMESSAGE_VIDEODEVICENOTREADABLE||e.name===n.DeviceErrorDescription.ERRORNAME_DEVICENOTREADABLE?new n.DeviceError(n.DeviceErrorCode.ERROR_DEVICE_VIDEODEVICE_NOTREADABLE,"video device not readable"):null},e.prototype.parseScreenError=function(e){return e.name===n.DeviceErrorDescription.ERRORNAME_DEVICENOTALLOWED?e.message===n.DeviceErrorDescription.ERRORMESSAGE_DEVICENOTALLOWED?new n.DeviceError(n.DeviceErrorCode.ERROR_SCREENSHARE_NOTALLOWED,e.message):new n.DeviceError(n.DeviceErrorCode.ERROR_SCREENSHARE_NOPERMISSION,e.message):e.name===n.DeviceErrorDescription.ERRORNAME_INVALID_ACCESS?new n.DeviceError(n.DeviceErrorCode.ERROR_SCREENSHARE_INVALIDACCESS,e.message):null},e.prototype.createVideoConstraints=function(e){return e.deviceId||e.width||e.height||e.frameRate?{video:{deviceId:{exact:e.deviceId},width:e.width,height:e.height,frameRate:e.frameRate}}:{video:!0}},e}();t.BaseDeviceManager=o},913:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.IosDeviceManager=void 0;var o=function(e){function t(){return e.call(this)||this}return i(t,e),t}(r(583).MobileDeviceManager);t.IosDeviceManager=o},331:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.LinuxDeviceManager=void 0;var o=function(e){function t(){return e.call(this)||this}return i(t,e),t}(r(62).BaseDeviceManager);t.LinuxDeviceManager=o},1:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.MacDeviceManager=void 0;var o=function(e){function t(){return e.call(this)||this}return i(t,e),t}(r(62).BaseDeviceManager);t.MacDeviceManager=o},583:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.MobileDeviceManager=void 0;var o=r(603),a=function(e){function t(){return e.call(this)||this}return i(t,e),t.prototype.checkSupportScreenShare=function(){return!1},t.prototype.getScreenTrack=function(e){return new Promise((function(e,t){t(new o.DeviceError(o.DeviceErrorCode.ERROR_SCREENSHARE_NOTSUPPORT,"mobile not support screenshare"))}))},t.prototype.getScreenStream=function(e){return new Promise((function(e,t){t(new o.DeviceError(o.DeviceErrorCode.ERROR_SCREENSHARE_NOTSUPPORT,"mobile not support screenshare"))}))},t.prototype.createVideoConstraints=function(e){return e.deviceId||e.facingMode||e.width||e.height||e.aspectRatio?{video:{deviceId:e.deviceId,facingMode:e.facingMode,width:e.width,height:e.height,aspectRatio:e.aspectRatio}}:{video:!0}},t}(r(62).BaseDeviceManager);t.MobileDeviceManager=a},935:function(e,t,r){var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.WindowsDeviceManager=void 0;var o=function(e){function t(){return e.call(this)||this}return i(t,e),t}(r(62).BaseDeviceManager);t.WindowsDeviceManager=o},607:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserDeviceManager=void 0;var o=r(304);Object.defineProperty(t,"BrowserDeviceManager",{enumerable:!0,get:function(){return o.BrowserDeviceManager}}),i(r(873),t),window&&(window.BrowserDeviceManager=o.BrowserDeviceManager)},610:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LinkUtil=void 0;var n,i=r(603),o=r(261),a=r(54);!function(e){e[e.Windows=0]="Windows",e[e.MacOS=1]="MacOS",e[e.Other=2]="Other"}(n||(n={}));var s="ms-settings:",c="x-apple.systempreferences:com.apple.preference.security?",u={SYS_MIC:[s+"privacy-microphone",c+"Privacy_Microphone"],SYS_CAMERA:[s+"privacy-webcam",c+"Privacy_Camera"],SYS_SCREENSHARE:["",c+"Privacy_ScreenCapture"]},d=function(){function e(){o||console.error("SystemUtil is not found"),this.systemType=this.getSystemType()}return e.prototype.getRelatedLink=function(e){var t="",r=this.systemType;switch(e){case i.DeviceErrorCode.ERROR_DEVICE_AUDIODEVICE_NOTFOUND:case i.DeviceErrorCode.ERROR_DEVICE_AUDIODEVICE_NOTREADABLE:t=u.SYS_MIC[r];break;case i.DeviceErrorCode.ERROR_DEVICE_VIDEODEVICE_NOTFOUND:case i.DeviceErrorCode.ERROR_DEVICE_VIDEODEVICE_NOTREADABLE:t=u.SYS_CAMERA[r];break;case i.DeviceErrorCode.ERROR_SCREENSHARE_UNKNOWNERRO:case i.DeviceErrorCode.ERROR_SCREENSHARE_NOPERMISSION:t=u.SYS_SCREENSHARE[r];break;case i.DeviceErrorCode.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED:case i.DeviceErrorCode.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED:a.isChrome?t=this.getChromeResetLink():a.isEdge&&(t=this.getEdgeResetLink());break;default:t=""}return t},e.prototype.getSystemType=function(){return o.isWindows?n.Windows:o.isMacOS?n.MacOS:n.Other},e.prototype.getChromeResetLink=function(){return"chrome://settings/content/siteDetails?site="+encodeURIComponent(window.location.origin)},e.prototype.getEdgeResetLink=function(){return"edge://settings/content/siteDetails?site="+encodeURIComponent(window.location.origin)},e}();t.LinkUtil=d},101:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.SystemUtil=void 0,function(e){e[e.Unknown=0]="Unknown",e[e.MacOS=1]="MacOS",e[e.Windows=2]="Windows",e[e.Android=3]="Android",e[e.Iphone=4]="Iphone",e[e.Ipad=5]="Ipad",e[e.Linux=6]="Linux"}(r||(r={}));var n=function(){function e(){this.systemType=r.Unknown,this.getSystemInfo()}return Object.defineProperty(e.prototype,"isIos",{get:function(){return this.systemType===r.Ipad||this.systemType===r.Iphone},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAndroid",{get:function(){return this.systemType===r.Android},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isMacOS",{get:function(){return this.systemType===r.MacOS},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isWindows",{get:function(){return this.systemType===r.Windows},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLinux",{get:function(){return this.systemType===r.Linux},enumerable:!1,configurable:!0}),e.prototype.getSystemInfo=function(){if(navigator&&navigator.userAgent){var e=navigator.userAgent.toLocaleLowerCase();e.indexOf("ipad")>-1?this.systemType=r.Ipad:e.indexOf("iphone")>-1?this.systemType=r.Iphone:e.indexOf("android")>-1?this.systemType=r.Android:e.indexOf("win")>-1?this.systemType=r.Windows:e.indexOf("mac")>-1?this.systemType=r.MacOS:e.indexOf("linux")>-1?this.systemType=r.Linux:e.indexOf("")>-1&&(this.systemType=r.Unknown)}},e}();t.SystemUtil=n},54:e=>{e.exports=window.BrowserUtil},261:e=>{e.exports=window.SystemUtil}},t={};return function r(n){if(t[n])return t[n].exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}(607)})()},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},a=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.RtsPeerconnection=void 0;var u=r(9),d=r(39),p=r(8),l=c(r(2)),f=r(6),h=r(40),m=r(43),v=r(45),E=r(1),R=r(4),y=r(46),g=c(r(47)),S=function(e){function t(){var t=e.call(this)||this;return t.connectingEventSent=!1,t.reused=!1,t.subMonitor=new h.SubMonitor,t.subMonitor.on("onMonitorEvent",(function(e){t.emit("onMonitorEvent",e)})),t.subMonitor.on("streamEnded",(function(){t.emit("streamEnded")})),t.subMonitor.on("canPlay",(function(){})),t.pubMonitor=new m.PubMonitor,t.pubMonitor.on("onMonitorEvent",(function(e){t.emit("onMonitorEvent",e)})),t.pubMonitor.on("onTransportStateEvent",(function(e){t.emit("onTransportStateEvent",e)})),t}return i(t,e),Object.defineProperty(t.prototype,"isConnected",{get:function(){var e;return"connected"===(null===(e=this.pc)||void 0===e?void 0:e.connectionState)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isReused",{get:function(){return this.reused},set:function(e){this.reused=!!e},enumerable:!1,configurable:!0}),t.prototype.getPc=function(){return this.pc},t.prototype.getPeerCore=function(){return this.peerCore},t.prototype.getSubMonitor=function(){return this.subMonitor},t.prototype.getPubMonitor=function(){return this.pubMonitor},t.prototype.playStart=function(){this.subMonitor.resetTimer(1e3)},t.prototype.pushStart=function(){this.pc&&this.peerCore&&this.pubMonitor.startHeartbeat(this.pc,this.peerCore)},t.prototype.sample=function(){return a(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.subMonitor.onMonitorTimer()];case 1:return e.sent(),[2]}}))}))},t.prototype.subAdd=function(e){var t;return null===(t=this.peerCore)||void 0===t?void 0:t.subscribeAdd(e)},t.prototype.subActive=function(e){var t;return null===(t=this.peerCore)||void 0===t?void 0:t.subscribeActive(e)},t.prototype.subStop=function(e){var t;return null===(t=this.peerCore)||void 0===t?void 0:t.subscribeStop(e)},t.prototype.subDeleteTracks=function(e){var t;return null===(t=this.peerCore)||void 0===t?void 0:t.subscribeDeleteTracks(e)},t.prototype.pubAdd=function(e){var t;return null===(t=this.peerCore)||void 0===t?void 0:t.publishAdd(e)},t.prototype.pubDeleteTracks=function(e){var t;return null===(t=this.peerCore)||void 0===t?void 0:t.publishDeleteTracks(e)},t.prototype.pubReplaceTracks=function(e){var t;return null===(t=this.peerCore)||void 0===t?void 0:t.publishReplaceTracks(e)},t.prototype.pubStop=function(e){var t;return null===(t=this.peerCore)||void 0===t?void 0:t.publishStop(e)},t.prototype.createOffer=function(e,r,n,i){var a=this;return void 0===i&&(i={publishUrl:""}),new Promise((function(s,c){var l;if(null===(l=a.cancelable)||void 0===l||l.cancel(),a.pc=new RTCPeerConnection({googCpuOveruseDetection:!1,sdpSemantics:"unified-plan",encodedInsertableStreams:i.encodedInsertableStreams}),a.encodedInsertableStreams=i.encodedInsertableStreams,a.peerCore=new u.PeerConnectionCore({pc:a.pc,onDatachannelEvent:function(e){a.emit("datachannelStatusChange",{status:e})}}),a.pc.onconnectionstatechange=function(){var e=(a.pc||{}).connectionState;switch(a.connectingEventSent||(a.connectingEventSent=!0,a.emit("connectStatusChange",{status:f.EConnectStatus.CONNECT_STATUS_CONNECTING})),"connecting"!==e&&a.clearStatusTimer(),e){case"connected":a.emit("onConnected"),a.emit("connectStatusChange",{status:f.EConnectStatus.CONNECT_STATUS_CONNECTED});break;case"disconnected":a.emit("connectStatusChange",{status:f.EConnectStatus.CONNECT_STATUS_RECONNECTING});break;case"failed":case"closed":a.handleClosed()}},a.statusTimer=window.setTimeout((function(){a.handleClosed()}),t.CONNECT_TIMEOUT),n){a.localStream=n,a.sdpUtil=new d.SdpUtil(a.localStream);var h=a.addStream();if(0!==h)return a.pc=void 0,void c(new R.RtsError(h,h===E.ErrorCode.ERROR_MEDIASTREAMTRACK_AUDIO_NONE?"need audio track":"",""))}else a.sdpUtil=new d.SdpUtil;var m=a.pc.createOffer({offerToReceiveAudio:!n&&e,offerToReceiveVideo:!n&&r});a.cancelable=(0,p.makeCancelable)(m),a.cancelable.promise.then((function(e){var t,r,u,d,p,l,f;if(a.cancelable=void 0,a.sdpUtil){if(a.sdpUtil.init(String(e.sdp)),a.sdpUtil.addNack(),a.sdpUtil.addSps(),n&&a.sdpUtil.modifyTrackName({vMsid:i.vMsid&&i.vMsid[0],aMsid:i.aMsid&&i.aMsid[0]}),a.pc){e.sdp=a.sdpUtil.sdp,n&&n.sdpHook&&"function"==typeof n.sdpHook&&(e.sdp=n.sdpHook(e.sdp)),null===(t=a.peerCore)||void 0===t||t.setPrevOfferSdp(e.sdp||"");var h=[];if(n)try{null===(r=a.peerCore)||void 0===r||r.patchPublishStreamManagerRecord(i.publishUrl||"",o(o({},i),{stream:n}));var m=null===(u=a.peerCore)||void 0===u?void 0:u.parseSdp(e.sdp||"");h=null===(d=a.peerCore)||void 0===d?void 0:d.updateTrackInfoList({url:i.publishUrl||"",stream:n,vMsid:null===(p=a.peerCore)||void 0===p?void 0:p.unifyMsid(i.vMsid,"video"),aMsid:null===(l=a.peerCore)||void 0===l?void 0:l.unifyMsid(i.aMsid,"audio"),sdpMediaList:null===(f=null==m?void 0:m.detail)||void 0===f?void 0:f.media})}catch(e){console.log(e)}i.offerSdpHook&&"function"==typeof i.offerSdpHook&&(e.sdp=i.offerSdpHook(e.sdp||"")),a.pc.setLocalDescription(e).then((function(){a.pc?s({desp:a.pc.localDescription,publishTrackInfoList:h}):c(new R.RtsError(E.ErrorCode.ERROR_CREATEOFFER,"no pc",""))})).catch((function(e){c(new R.RtsError(E.ErrorCode.ERROR_CREATEOFFER,"setLocalDescription error "+e.message,""))}))}}else c(new R.RtsError(E.ErrorCode.ERROR_CREATEOFFER,"no sdp",""))})).catch((function(e){e.isCanceled||c(new R.RtsError(E.ErrorCode.ERROR_CREATEOFFER,e.message?e.message:"create offer error",""))}))}))},t.prototype.recvAnswer=function(e,t){var r,n,i=this;return void 0===t&&(t={}),null===(r=this.peerCore)||void 0===r||r.setPrevAnswerSdp(null===(n=null==e?void 0:e.jsep)||void 0===n?void 0:n.sdp),new Promise((function(r,n){var a,s,c,u,p,l;if(i.pc){if(i.pc.ontrack=function(e){if(i.pc&&i.peerCore&&i.subMonitor.start(i.pc,i.peerCore),!i.isReused&&(i.emit("onTrackEvent",e),"video"===e.track.kind&&i.encodedInsertableStreams)){var t=window.RTCRtpReceiver&&"createEncodedStreams"in RTCRtpReceiver.prototype,r=window.RTCRtpReceiver&&"transform"in RTCRtpReceiver.prototype&&"RTCRtpScriptTransform"in window;if(t){var n=e.receiver.createEncodedStreams(),a=(0,y.createReceiverTransformStream)({onFrame:function(e){i.emit("encodedFrame",e)}});n.readable.pipeThrough(a).pipeTo(n.writable)}else if(r){var s=new g.default;e.receiver.transform=new RTCRtpScriptTransform(s,{name:"receiver"}),s.onmessage=function(e){var t=e.data,r=t.type,n=t.data,a=t.frameInfo;"encodedFrame"===r&&i.emit("encodedFrame",o({data:n},a))},i.transformWorker=s}}},"closed"===i.pc.signalingState)return void n({message:"PeerConnection signalingState is closed"});if(null===(a=e.jsep)||void 0===a?void 0:a.sdp){var f=new d.SdpUtil;f.init(String(null===(s=e.jsep)||void 0===s?void 0:s.sdp)),i.localStream&&(i.localStream.audioTrack&&!i.localStream.videoTrack&&(f.removeTwccRtcpFb(),null===(c=i.peerCore)||void 0===c||c.setRemoveTwcc(!0)),f.setDirection()),t.tcpOnly&&f.hasTcpCandidate&&f.removeUdpCandidate(),e.jsep.sdp=f.sdp,null===(u=i.peerCore)||void 0===u||u.setPrevAnswerSdp(null===(p=null==e?void 0:e.jsep)||void 0===p?void 0:p.sdp)}(null===(l=e.jsep)||void 0===l?void 0:l.sdp)&&t.answerSdpHook&&"function"==typeof t.answerSdpHook&&(e.jsep.sdp=t.answerSdpHook(e.jsep.sdp)),i.pc.setRemoteDescription(new RTCSessionDescription(e.jsep)).then((function(e){i.pc&&i.localStream&&i.localStream.setEncodeParam(i.pc),r(e)})).catch((function(t){t.sdp=e.jsep.sdp,n(t)}))}else n({message:"no PeerConnection"})}))},t.prototype.removeTrack=function(e,t){var r=this;return new Promise((function(n,i){r.pc&&r.dataChannel&&r.dataChannel.removeTrack(e,t).then((function(){})).catch((function(e){i(e)}))}))},t.prototype.replaceTrack=function(e,t,r){var n=this;return new Promise((function(i,o){r||n.pc&&n.dataChannel&&n.dataChannel.removeTrack(e,t).then((function(){})).catch((function(e){o(e)}))}))},t.prototype.dispose=function(){this.cancelable&&(this.cancelable.cancel(),this.cancelable=void 0),this.peerCore&&(this.peerCore.dispose(),this.peerCore=void 0),this.pc&&(this.pc.onconnectionstatechange=function(){},this.pc.ontrack=function(){},this.pc.close(),this.pc=void 0,this.clearStatusTimer()),this.sdpUtil&&(this.sdpUtil.dispose(),this.sdpUtil=void 0),this.localStream&&(this.localStream=void 0),this.transformWorker&&(this.transformWorker.terminate(),this.transformWorker=void 0),this.subMonitor.stop(),this.pubMonitor.stopHeartbeat(),this.isReused=!1,this.encodedInsertableStreams=void 0},t.prototype.addStream=function(){return this.localStream?this.pc?(this.localStream.audioTrack&&this.pc.addTransceiver(this.localStream.audioTrack,{direction:"sendonly",streams:[this.localStream.mediaStream]}),this.localStream.videoTrack&&this.pc.addTransceiver(this.localStream.videoTrack,{direction:"sendonly",streams:[this.localStream.mediaStream]}),0):E.ErrorCode.ERROR_PREERCONNECTION_UNKNOWN:E.ErrorCode.ERROR_MEDIASTREAMTRACK_AUDIO_NONE},t.prototype.initDataChannel=function(){!this.dataChannel&&this.pc&&(this.dataChannel=new v.Datachannel(this.pc))},t.prototype.handleClosed=function(){this.subMonitor.stop(),this.emit("connectStatusChange",{status:f.EConnectStatus.CONNECT_STATUS_DISCONNECTED}),this.emit("onEnd")},t.prototype.clearStatusTimer=function(){this.statusTimer&&clearTimeout(this.statusTimer),this.statusTimer=void 0},t.CONNECT_TIMEOUT=1e4,t}(l.default);t.RtsPeerconnection=S},function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=n(r(48));t.default=i.default.create({baseURL:"",timeout:5e3,headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}})},function(e,t,r){"use strict";(function(t){var n=r(0),i=r(55),o=r(22),a={"Content-Type":"application/x-www-form-urlencoded"};function s(e,t){!n.isUndefined(e)&&n.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var c,u={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==t&&"[object process]"===Object.prototype.toString.call(t))&&(c=r(23)),c),transformRequest:[function(e,t){return i(t,"Accept"),i(t,"Content-Type"),n.isFormData(e)||n.isArrayBuffer(e)||n.isBuffer(e)||n.isStream(e)||n.isFile(e)||n.isBlob(e)?e:n.isArrayBufferView(e)?e.buffer:n.isURLSearchParams(e)?(s(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):n.isObject(e)||t&&"application/json"===t["Content-Type"]?(s(t,"application/json"),function(e,t,r){if(n.isString(e))try{return(t||JSON.parse)(e),n.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,i=t&&t.forcedJSONParsing,a=!r&&"json"===this.responseType;if(a||i&&n.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(a){if("SyntaxError"===e.name)throw o(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],(function(e){u.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){u.headers[e]=n.merge(a)})),e.exports=u}).call(this,r(54))},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.SupportUtil=void 0;var o=r(3),a=r(10),s=r(1),c=r(68),u=function(){this.errorCode=0,this.message=""},d=function(){function e(){this.deviceManager=new a.BrowserDeviceManager}return e.prototype.isSupport=function(e){var t=this;return new Promise((function(r,o){return n(t,void 0,void 0,(function(){var t,n,a,d;return i(this,(function(i){switch(i.label){case 0:return t=new u,this.checkWebRtcSupport()?e.onlyCheckUA?this.checkBrowser(t)?[3,3]:[2,o(t)]:[3,1]:(t.errorCode=s.ErrorCode.ERROR_NOTSUPPORT_WEBRTC,t.message=c.EN.MESSAGE_NOTSUPPORT_WEBRTC,[2,o(t)]);case 1:return[4,this.checkWebrtcAbilities()];case 2:if(n=i.sent(),a=n[0],n[1],n[2],d=n[3],!a)return t.errorCode=s.ErrorCode.ERROR_NOTSUPPORT_WEBRTC,t.message=c.EN.MESSAGE_NOTSUPPORT_WEBRTC,[2,o(t)];if(d)return t.errorCode=s.ErrorCode.ERROR_BROWSER_NOTSUPPORT,t.message=c.EN.MESSAGE_BROWSER_NOTSUPPORT,[2,o(t)];i.label=3;case 3:return e.isReceiveVideo?this.checkH264Decode(t).then((function(){r(t)})).catch((function(){o(t)})):r(t),[2]}}))}))}))},e.prototype.checkEncodedTransformSupport=function(){var e=window.RTCRtpReceiver&&"createEncodedStreams"in RTCRtpReceiver.prototype,t=window.RTCRtpReceiver&&"transform"in RTCRtpReceiver.prototype&&"RTCRtpScriptTransform"in window;return e||t},e.prototype.checkWebrtcAbilities=function(e){return n(this,void 0,void 0,(function(){var t,r,n,o,a,s,c,u,d;return i(this,(function(i){switch(i.label){case 0:t=window.RTCPeerConnection,r=!1,n=!1,o=null,a=!1,i.label=1;case 1:return i.trys.push([1,4,,5]),t?(s=new t,n="createDataChannel"in s,e&&(c=this.createBlankStream()).getTracks().forEach((function(e){null==s||s.addTrack(e,c)})),[4,s.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0,iceRestart:!0})]):[3,3];case 2:u=i.sent(),d=(u||{}).sdp,o=e?!!(d&&d.indexOf("a=sendrecv")>-1):null,s.close(),s=void 0,r=!0,i.label=3;case 3:return[3,5];case 4:return i.sent(),r=!1,n=!1,o=!1,[3,5];case 5:return a=this.checkBlackList(),[2,[r,n,o,a]]}}))}))},e.prototype.checkPublishSupport=function(){return n(this,void 0,void 0,(function(){var e,t,r,n,o,a,s,c;return i(this,(function(i){switch(i.label){case 0:return e={isWebRTCSupported:!1,isH264EncodeSupported:!1,isMediaDevicesSupported:!1,isScreenCaptureSupported:!1,isAudioMixSupported:!1,cameraList:[],micList:[],speakerList:[]},this.checkWebRtcSupport()?[3,1]:(e.isWebRTCSupported=!1,e.isH264EncodeSupported=!1,[3,5]);case 1:return[4,this.checkWebrtcAbilities(!0)];case 2:return t=i.sent(),r=t[0],t[1],n=t[2],e.isWebRTCSupported=!(!r||!n),e.isWebRTCSupported?[3,3]:(e.isH264EncodeSupported=!1,[3,5]);case 3:return o=e,[4,this.checkH264Encode()];case 4:o.isH264EncodeSupported=i.sent(),i.label=5;case 5:if(e.isMediaDevicesSupported=this.checkMediaDevices(),e.isScreenCaptureSupported=this.checkScreenCapture(),e.isAudioMixSupported=this.checkAudioMix(),!e.isMediaDevicesSupported)return[3,11];i.label=6;case 6:return i.trys.push([6,10,,11]),a=e,[4,this.deviceManager.getCameraList()];case 7:return a.cameraList=i.sent().filter((function(e){return e.deviceId})),s=e,[4,this.deviceManager.getMicList()];case 8:return s.micList=i.sent().filter((function(e){return e.deviceId})),c=e,[4,this.deviceManager.getSpeakerList()];case 9:return c.speakerList=i.sent().filter((function(e){return e.deviceId})),[3,11];case 10:return i.sent(),[3,11];case 11:return[2,e]}}))}))},e.prototype.checkWebRtcSupport=function(){return!!window.RTCPeerConnection},e.prototype.checkMediaDevices=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)},e.prototype.checkScreenCapture=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},e.prototype.checkAudioMix=function(){if(!window.AudioContext)return!1;var e=new AudioContext;return!!e.createMediaStreamDestination&&!!e.createMediaStreamSource},e.prototype.checkBlackList=function(){var e=!1;if(o.BrowserUtil.isOppoBrowser&&o.SystemUtil.isAndroid){var t=(this.getUa().toLowerCase().match(/heytapbrowser\/([\d.]+)/)||[])[1]||"";e=!this.compareVersion(t,"40.7.39.1")}else(o.BrowserUtil.isUCBrowser||o.BrowserUtil.isQuarkBrowser)&&o.SystemUtil.isIos?e=!0:o.BrowserUtil.isWebView&&o.SystemUtil.isAndroid&&(e=!(o.BrowserUtil.browserMainVersion>=79));return e},e.prototype.checkBrowser=function(e){if(o.SystemUtil.isIos){if(o.BrowserUtil.isUCBrowser||o.BrowserUtil.isQuarkBrowser)return e.errorCode=s.ErrorCode.ERROR_BROWSER_NOTSUPPORT,e.message=c.EN.MESSAGE_BROWSER_NOTSUPPORT,!1;if(o.BrowserUtil.isSafari||o.BrowserUtil.isQQBrowser)return o.BrowserUtil.browserMainVersion>=11||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isEdge||o.BrowserUtil.isChrome)return o.BrowserUtil.browserMainVersion>=79||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isMicroMessenger)return!!this.compareVersion(o.SystemUtil.systemVersion,"12.1.4")||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isDingTalk)return!!o.SystemUtil.compareVersion("11.2.5")||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isWebView)return!!this.compareVersion(o.SystemUtil.systemVersion,"14.3")||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1)}else if(o.SystemUtil.isAndroid){if(this.checkPrivateUcWebview())return!0;if(o.BrowserUtil.isChrome||o.BrowserUtil.isQQBrowser||o.BrowserUtil.isHuaweiBrowser||o.BrowserUtil.isSamsungBrowser)return o.BrowserUtil.browserMainVersion>=63||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isEdge)return o.BrowserUtil.browserMainVersion>=79||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isMicroMessenger)return!!this.compareVersion(this.getChromeCoreVersion(),"63")||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isDingTalk)return!!this.compareVersion(this.getChromeCoreVersion(),"69")||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isOppoBrowser){var t=(this.getUa().toLowerCase().match(/heytapbrowser\/([\d.]+)/)||[])[1]||"";return!!this.compareVersion(t,"40.7.39.1")||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1)}if(o.BrowserUtil.isX5Core)return!0;if(o.BrowserUtil.isWebView)return o.BrowserUtil.browserMainVersion>=79||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1)}else if(o.SystemUtil.isMacOS){if(o.BrowserUtil.isElectron)return!0;if(o.BrowserUtil.isSafari)return o.BrowserUtil.browserMainVersion>=11||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isChrome)return o.BrowserUtil.browserMainVersion>=63||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isEdge)return o.BrowserUtil.browserMainVersion>=79||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isFirefox)return o.BrowserUtil.browserMainVersion>=62||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isOpera)return o.BrowserUtil.browserMainVersion>=15||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1)}else if(o.SystemUtil.isWindows){if(o.BrowserUtil.isElectron)return!0;if(o.BrowserUtil.isMicroMessenger)return!0;if(o.BrowserUtil.isChrome||o.BrowserUtil.isQQBrowser)return o.BrowserUtil.browserMainVersion>=63||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isEdge)return o.BrowserUtil.browserMainVersion>=79||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isFirefox)return o.BrowserUtil.browserMainVersion>=62||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isOpera)return o.BrowserUtil.browserMainVersion>=15||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1)}else if(o.SystemUtil.isLinux){if(o.BrowserUtil.isChrome)return o.BrowserUtil.browserMainVersion>=63||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isEdge)return o.BrowserUtil.browserMainVersion>=79||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1);if(o.BrowserUtil.isFirefox)return o.BrowserUtil.browserMainVersion>=62||(e.errorCode=s.ErrorCode.ERROR_BROWSER_VERSIONLOW,e.message=c.EN.MESSAGE_BROWSER_VERSIONLOW,!1)}return 0===e.errorCode&&(e.errorCode=s.ErrorCode.ERROR_BROWSER_NOTSUPPORT,e.message=c.EN.MESSAGE_BROWSER_NOTSUPPORT),!1},e.prototype.checkH264Decode=function(e){var t=this;return new Promise((function(r,o){return n(t,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.tryFindH264FromSdp(e)];case 1:if(t=n.sent())return r(!0),[2];n.label=2;case 2:return n.trys.push([2,4,,5]),[4,this.loadH264(3)];case 3:return t=n.sent(),[3,5];case 4:return n.sent(),[3,5];case 5:return t?r(!0):(e&&0===e.errorCode&&(e.errorCode=s.ErrorCode.ERROR_NOTSUPPORT_H264,e.message=c.EN.MESSAGE_NOTSUPPORT_H264),o(!1)),[2]}}))}))}))},e.prototype.checkSDPSupportH264=function(e){return e.indexOf("H264")>0||e.indexOf("h264")>0||e.indexOf("H.264")>0||e.indexOf("h.264")>0},e.prototype.checkPrivateUcWebview=function(){return this.getUa().indexOf("UniqueCode")>0},e.prototype.getUa=function(){return navigator&&navigator.userAgent||""},e.prototype.getChromeCoreVersion=function(){return(this.getUa().toLowerCase().match(/chrome\/([\d.]+)/)||[])[1]||""},e.prototype.compareVersion=function(e,t){void 0===e&&(e=""),void 0===t&&(t="");for(var r=(e||"").split("."),n=(t||"").split("."),i=0,o=0,a=0;a<r.length&&a<n.length;++a){if((i=isNaN(parseInt(r[a],10))?0:parseInt(r[a],10))<(o=isNaN(parseInt(n[a],10))?0:parseInt(n[a],10)))return!1;if(i>o)return!0}return!0},e.prototype.tryFindH264FromSdp=function(e){return n(this,void 0,void 0,(function(){var t,r,n;return i(this,(function(i){switch(i.label){case 0:t=!1,r=new RTCPeerConnection,n=void 0,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,r.createOffer({offerToReceiveVideo:!0,offerToReceiveAudio:!0})];case 2:return(n=i.sent())&&n.sdp&&(t=this.checkSDPSupportH264(n.sdp)),[3,4];case 3:return i.sent(),t=!1,e&&(e.errorCode=s.ErrorCode.ERROR_CREATEOFFER,e.message=c.EN.MESSAGE_CREATEOFFER),[3,4];case 4:return r.close(),r=void 0,[2,t]}}))}))},e.prototype.loadH264=function(e){var t=this;return new Promise((function(r,a){return n(t,void 0,void 0,(function(){var t,a,s,c,u=this;return i(this,(function(d){if(!o.SystemUtil.isAndroid||!o.BrowserUtil.isChrome&&!o.BrowserUtil.isWebView)return r(!1),[2];for(t=0,a=[],s=0;t<e;)c=setTimeout((function(){return n(u,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return s++,[4,this.tryFindH264FromSdp()];case 1:return t.sent()?(a.forEach((function(e){clearTimeout(e)})),a=[],r(!0),[2]):(s===e&&r(!1),[2])}}))}))}),1e3*t),a.push(c),t++;return[2]}))}))}))},e.prototype.checkH264Encode=function(){var e;return n(this,void 0,void 0,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:return[4,this.loadH264(3)];case 1:return!(t=n.sent())&&RTCRtpSender&&RTCRtpSender.getCapabilities&&(r=JSON.stringify(null===(e=RTCRtpSender.getCapabilities("video"))||void 0===e?void 0:e.codecs),t=r.toLowerCase().includes("video/h264")),[2,!!t]}}))}))},e.prototype.createBlankStream=function(){var e,t,r,n=(e=new AudioContext,t=e.createOscillator(),r=t.connect(e.createMediaStreamDestination()),t.start(),Object.assign(r.stream.getAudioTracks()[0],{enabled:!1}));n.stop();var i=function(e){var t,r=void 0===e?{}:e,n=r.width,i=void 0===n?160:n,o=r.height,a=void 0===o?90:o,s=document.createElement("canvas");s.width=i,s.height=a,null===(t=s.getContext("2d"))||void 0===t||t.fillRect(0,0,i,a);var c=s.captureStream();return Object.assign(c.getVideoTracks()[0],{enabled:!1})}();return i.stop(),new MediaStream([n,i])},e}();t.SupportUtil=d},function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o,a=r(3),s=i(r(7)),c=r(1),u=i(r(75));!function(e){e[e.UA=101]="UA",e[e.SUB_STATS=107]="SUB_STATS",e[e.PUB_STATS=108]="PUB_STATS",e[e.CONNECT_STATE_CHANGE=109]="CONNECT_STATE_CHANGE",e[e.START_PLAY=120]="START_PLAY",e[e.STOP_PLAY=121]="STOP_PLAY",e[e.SUBSCRIBE_START=125]="SUBSCRIBE_START",e[e.SUBSCRIBE_OK=126]="SUBSCRIBE_OK",e[e.FIRST_FRAME_TIME=137]="FIRST_FRAME_TIME",e[e.DC_HTTP_CONNECT=140]="DC_HTTP_CONNECT",e[e.DC_HTTP_CONNECT_OK=141]="DC_HTTP_CONNECT_OK",e[e.DC_SUB_ADD=142]="DC_SUB_ADD",e[e.DC_SUB_ADD_OK=143]="DC_SUB_ADD_OK",e[e.DC_CONNECT_STATE_CHANGE=144]="DC_CONNECT_STATE_CHANGE",e[e.DC_SUB_STOP=145]="DC_SUB_STOP",e[e.DC_SUB_STOP_OK=146]="DC_SUB_STOP_OK",e[e.DC_DISPOSE=147]="DC_DISPOSE",e[e.ERROR_INFO=150]="ERROR_INFO",e[e.RECONNECT=160]="RECONNECT",e[e.CREATE_CLIENT=200]="CREATE_CLIENT",e[e.LOCALSTREAM_INITED=201]="LOCALSTREAM_INITED",e[e.START_PUBLISH=220]="START_PUBLISH",e[e.STOP_PUBLISH=221]="STOP_PUBLISH",e[e.PUBLISH_OK=222]="PUBLISH_OK",e[e.SET_VIDEOPROFILE=230]="SET_VIDEOPROFILE",e[e.SET_SCREENPROFILE=231]="SET_SCREENPROFILE",e[e.ENABLE_AUDIO=232]="ENABLE_AUDIO",e[e.DISABLE_AUDIO=233]="DISABLE_AUDIO",e[e.ENABLE_VIDEO=234]="ENABLE_VIDEO",e[e.DISABLE_VIDEO=235]="DISABLE_VIDEO",e[e.STOP=236]="STOP",e[e.PLAY=237]="PLAY"}(o||(o={}));var d=function(){function e(e){this.customReporter=null==e?void 0:e.customReporter,this.ct=e&&e.customTag?e.customTag:"",this.enableLog=!e||0!=e.trackLog,this._initParam(),this.slsTracker=new u.default({host:"cn-hangzhou.log.aliyuncs.com",project:"videocloud",logstore:"live-client-log",time:10,count:10})}return e.prototype.updateTid=function(){this.param?this.param.tid=a.Guid.create(32):this._initParam()},e.prototype.updateUrl=function(e){this.param&&(this.param.pu=e)},e.prototype.reportUA=function(e){this.reporter({msgid:o.UA,args:JSON.stringify({ua:e})})},e.prototype.reportPullStats=function(e){this.reporter({msgid:o.SUB_STATS,args:JSON.stringify(n({},e))})},e.prototype.reportPushStats=function(e){this.reporter({msgid:o.PUB_STATS,args:JSON.stringify(n({},e))})},e.prototype.reportStartPlay=function(e){this.reporter({msgid:o.START_PLAY,args:JSON.stringify({vurl:e})})},e.prototype.reportStopPlay=function(){this.reporter({msgid:o.STOP_PLAY})},e.prototype.reportSubscribeStart=function(e,t,r,n,i){this.reporter({msgid:o.SUBSCRIBE_START,args:JSON.stringify({vurl:e,surl:t,vMsid:r?r.join(", "):"",aMsid:n?n.join(", "):"",isSubAdd:!!i})})},e.prototype.reportSubscribeOk=function(e){void 0===e&&(e={}),this.reporter({msgid:o.SUBSCRIBE_OK,args:JSON.stringify({vurl:e.vurl||"",surl:e.surl||"",hrct:e.hrct,tcid:e.traceId,rslt:e.rslt,isSubAdd:!!e.isSubAdd})})},e.prototype.reportFirstFrameTime=function(e,t,r,n,i,a,s,c,u,d,p,l,f,h){this.reporter({msgid:o.FIRST_FRAME_TIME,args:JSON.stringify({vurl:e,cpct:r,hrct:n,tcid:t,ffct:i,rslt:a,cnct:s,stats:c,delct:u,addct:d,actct:p,vMsid:l?l.join(", "):"",aMsid:f?f.join(", "):"",isSubAdd:!!h})})},e.prototype.reportErrorInfo=function(e,t,r,n){e!==c.ErrorCode.ERROR_AUTOPLAY_ERROR&&this.reporter({msgid:o.ERROR_INFO,args:JSON.stringify({errorCode:e,message:t,tcid:r,extraInfo:n})})},e.prototype.reportReconnect=function(e,t,r,n,i){this.reporter({msgid:o.RECONNECT,args:JSON.stringify({errorCode:e,message:t,tcid:r,retryTimes:n,useTcp:i})})},e.prototype.reportCreateClient=function(){this.reporter({msgid:o.CREATE_CLIENT})},e.prototype.reportStartPublish=function(e,t,r){this.reporter({msgid:o.START_PUBLISH,args:JSON.stringify({purl:e,surl:t,isPubAdd:!!r})})},e.prototype.reportPublishOk=function(e,t,r,n,i,a,s,c){this.reporter({msgid:o.PUBLISH_OK,args:JSON.stringify({purl:e,surl:t,coct:r,hrct:n,act:i,tcid:a,totalct:s||r+n+i,isPubAdd:!!c})})},e.prototype.reportStopPublish=function(e,t){this.reporter({msgid:o.STOP_PUBLISH,args:JSON.stringify({url:e,isPubStop:!!t})})},e.prototype.reportVideoProfile=function(e){this.reporter({msgid:o.SET_VIDEOPROFILE,args:JSON.stringify({vp:e})})},e.prototype.reportScreenProfile=function(e){this.reporter({msgid:o.SET_SCREENPROFILE,args:JSON.stringify({sp:e})})},e.prototype.reportEnableAudio=function(){this.reporter({msgid:o.ENABLE_AUDIO})},e.prototype.reportDisableAudio=function(){this.reporter({msgid:o.DISABLE_AUDIO})},e.prototype.reportEnableVideo=function(){this.reporter({msgid:o.ENABLE_VIDEO})},e.prototype.reportDisableVideo=function(){this.reporter({msgid:o.DISABLE_VIDEO})},e.prototype.reportStop=function(e){this.reporter({msgid:o.STOP,args:JSON.stringify({tp:e})})},e.prototype.reportPlay=function(e){this.reporter({msgid:o.PLAY,args:JSON.stringify({tp:e})})},e.prototype.reportStreamCreated=function(e,t){this.reporter({msgid:o.LOCALSTREAM_INITED,args:JSON.stringify({userConfig:e,localStreamInfo:t})})},e.prototype.reportConnectionChange=function(e,t){this.reporter({msgid:o.CONNECT_STATE_CHANGE,args:JSON.stringify({connectionState:e,direction:t})})},e.prototype.reportDatachannelHttpConnect=function(e){this.reporter({msgid:o.DC_HTTP_CONNECT,args:JSON.stringify({url:e})})},e.prototype.reportDatachannelHttpConnectOk=function(e){this.reporter({msgid:o.DC_HTTP_CONNECT_OK,args:JSON.stringify(n({},e))})},e.prototype.reportDatachannelSubAdd=function(e){this.reporter({msgid:o.DC_SUB_ADD,args:JSON.stringify(n({},e))})},e.prototype.reportDatachannelSubAddOk=function(e){this.reporter({msgid:o.DC_SUB_ADD_OK,args:JSON.stringify(n({},e))})},e.prototype.reportDatachannelStatusChange=function(e){this.reporter({msgid:o.DC_CONNECT_STATE_CHANGE,args:JSON.stringify(n({},e))})},e.prototype.reportDatachannelSubStop=function(e){this.reporter({msgid:o.DC_SUB_STOP,args:JSON.stringify(n({},e))})},e.prototype.reportDatachannelSubStopOk=function(e){this.reporter({msgid:o.DC_SUB_STOP_OK,args:JSON.stringify(n({},e))})},e.prototype.reportDatachannelDispose=function(e){this.reporter({msgid:o.DC_DISPOSE,args:JSON.stringify(n({},e))})},e.prototype._initParam=function(){this.param||(this.param={APIVersion:"0.6.0",os:a.SystemUtil.platform,osv:a.SystemUtil.systemVersion,bt:a.BrowserUtil.browserName,bv:a.BrowserUtil.browserVersion,host:window.location.origin,uid:a.LocalStorage.uuid,tid:a.Guid.create(32),ver:s.default.version,ct:this.ct,dt:"",lv:"1.0.0",ua:navigator&&navigator.userAgent||"",pu:""})},e.prototype.reporter=function(e){var t=n(n(n(n({},this.param||{}),{tm:(new Date).getTime()}),e||{}),{msgname:o[e.msgid]});if(this.customReporter&&"function"==typeof this.customReporter)try{this.customReporter(t)}catch(e){console.error("[Error in customReporter] ",e)}this.enableLog&&this.slsTracker.send(t)},e.prototype.data2String=function(e){var t="";for(var r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=r+"="+e[r]);return t},e.HEARTHEAT_INTERVAL=4,e}();t.default=d},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Stream=void 0;var a=r(3),s=function(e){function t(){var t=e.call(this)||this;return t.traceid="",t.id=a.Guid.create(32),t}return i(t,e),Object.defineProperty(t.prototype,"traceId",{get:function(){return this.traceid},set:function(e){this.traceid=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mediaElement",{get:function(){return this.element},enumerable:!1,configurable:!0}),t.prototype.setReporter=function(e){this.reporter=e},t.prototype.play=function(e){},t.prototype.stop=function(){this.traceid="",this.reporter=void 0},t}(o(r(2)).default);t.Stream=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VideoProfileMap=t.ScreenProfileMap=void 0,t.ScreenProfileMap=new Map,t.ScreenProfileMap.set("480p_1",{width:640,height:480,frameRate:5,maxBitrate:300}),t.ScreenProfileMap.set("480p_2",{width:640,height:480,frameRate:30,maxBitrate:1e3}),t.ScreenProfileMap.set("720p_1",{width:1280,height:720,frameRate:5,maxBitrate:800}),t.ScreenProfileMap.set("720p_2",{width:1280,height:720,frameRate:30,maxBitrate:2e3}),t.ScreenProfileMap.set("1080p_1",{width:1920,height:1080,frameRate:5,maxBitrate:1e3}),t.ScreenProfileMap.set("1080p_2",{width:1920,height:1080,frameRate:30,maxBitrate:3e3}),t.VideoProfileMap=new Map,t.VideoProfileMap.set("120p_1",{width:160,height:120,frameRate:15,maxBitrate:65}),t.VideoProfileMap.set("120p_3",{width:120,height:120,frameRate:15,maxBitrate:50}),t.VideoProfileMap.set("180p_1",{width:320,height:180,frameRate:15,maxBitrate:140}),t.VideoProfileMap.set("180p_3",{width:180,height:180,frameRate:15,maxBitrate:100}),t.VideoProfileMap.set("180p_4",{width:240,height:180,frameRate:15,maxBitrate:120}),t.VideoProfileMap.set("240p_1",{width:320,height:240,frameRate:15,maxBitrate:200}),t.VideoProfileMap.set("240p_3",{width:240,height:240,frameRate:15,maxBitrate:140}),t.VideoProfileMap.set("240p_4",{width:424,height:240,frameRate:15,maxBitrate:220}),t.VideoProfileMap.set("360p_1",{width:640,height:360,frameRate:15,maxBitrate:400}),t.VideoProfileMap.set("360p_3",{width:360,height:360,frameRate:15,maxBitrate:260}),t.VideoProfileMap.set("360p_4",{width:640,height:360,frameRate:30,maxBitrate:600}),t.VideoProfileMap.set("360p_6",{width:360,height:360,frameRate:30,maxBitrate:400}),t.VideoProfileMap.set("360p_7",{width:480,height:360,frameRate:15,maxBitrate:320}),t.VideoProfileMap.set("360p_8",{width:480,height:360,frameRate:30,maxBitrate:490}),t.VideoProfileMap.set("360p_9",{width:640,height:360,frameRate:15,maxBitrate:800}),t.VideoProfileMap.set("360p_10",{width:640,height:360,frameRate:24,maxBitrate:800}),t.VideoProfileMap.set("360p_11",{width:640,height:360,frameRate:24,maxBitrate:1e3}),t.VideoProfileMap.set("480p_1",{width:640,height:480,frameRate:15,maxBitrate:500}),t.VideoProfileMap.set("480p_2",{width:640,height:480,frameRate:30,maxBitrate:1e3}),t.VideoProfileMap.set("480p_3",{width:480,height:480,frameRate:15,maxBitrate:400}),t.VideoProfileMap.set("480p_4",{width:640,height:480,frameRate:30,maxBitrate:750}),t.VideoProfileMap.set("480p_6",{width:480,height:480,frameRate:30,maxBitrate:600}),t.VideoProfileMap.set("480p_8",{width:848,height:480,frameRate:15,maxBitrate:610}),t.VideoProfileMap.set("480p_9",{width:848,height:480,frameRate:30,maxBitrate:930}),t.VideoProfileMap.set("480p_10",{width:640,height:480,frameRate:10,maxBitrate:400}),t.VideoProfileMap.set("720p_1",{width:1280,height:720,frameRate:15,maxBitrate:1130}),t.VideoProfileMap.set("720p_2",{width:1280,height:720,frameRate:30,maxBitrate:2e3}),t.VideoProfileMap.set("720p_3",{width:1280,height:720,frameRate:30,maxBitrate:1710}),t.VideoProfileMap.set("720p_5",{width:960,height:720,frameRate:15,maxBitrate:910}),t.VideoProfileMap.set("720p_6",{width:960,height:720,frameRate:30,maxBitrate:1380}),t.VideoProfileMap.set("1080p_1",{width:1920,height:1080,frameRate:15,maxBitrate:2080}),t.VideoProfileMap.set("1080p_2",{width:1920,height:1080,frameRate:30,maxBitrate:3e3}),t.VideoProfileMap.set("1080p_3",{width:1920,height:1080,frameRate:30,maxBitrate:3150}),t.VideoProfileMap.set("1080p_5",{width:1920,height:1080,frameRate:60,maxBitrate:4780}),t.VideoProfileMap.set("1440p_1",{width:2560,height:1440,frameRate:30,maxBitrate:4850}),t.VideoProfileMap.set("1440p_2",{width:2560,height:1440,frameRate:60,maxBitrate:7350}),t.VideoProfileMap.set("4K_1",{width:3840,height:2160,frameRate:30,maxBitrate:8910}),t.VideoProfileMap.set("4K_3",{width:3840,height:2160,frameRate:60,maxBitrate:13500})},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ReceiverMonitorData=t.ReceiverMonitorType=void 0;var a,s=r(3),c=o(r(2)),u=r(19);!function(e){e.AUDIO="audio",e.VIDEO="video"}(a=t.ReceiverMonitorType||(t.ReceiverMonitorType={}));var d=function(e){function t(t){var r=e.call(this)||this;return r.streamEnded=!1,r.currentTimeGap=0,r.lastTimeStamp=0,r.transportStats={},r.remoteCandidate={},r.localCandidate={},r.inboundRtpStreamStats={},r.inboundRtpStreamStatsDiff={},r.receiver=null,r.pc=null,r.canplay=!1,r.type=t,r}return i(t,e),Object.defineProperty(t.prototype,"rtpReceiver",{set:function(e){this.receiver=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"RTCPeerconnection",{set:function(e){this.pc=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isExist",{get:function(){return null!=this.receiver},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isPlaying",{get:function(){return this.canplay},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isStreamEnded",{get:function(){return this.streamEnded},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"monitorData",{get:function(){var e=this.inboundRtpStreamStatsDiff||{},t=(this.inboundRtpStreamStats,this.currentTimeGap),r=0;return void 0!==e.nackCount&&void 0!==e.packetsReceived&&(r=Math.round(e.nackCount/(e.packetsReceived+e.nackCount)*1e3)/1e3),{inboundRtpStats:this.inboundRtpStreamStats,inboundRtpStatsPerSec:{bytesReceivedPerSecond:e.bytesReceived/t||0,framesDecodedPerSecond:e.framesDecoded/t||0,packetsLostRate:r>0?r:0},transportStats:this.transportStats,remoteCandidate:this.remoteCandidate,localCandidate:this.localCandidate}},enumerable:!1,configurable:!0}),t.prototype.getInfo=function(){var e=this;if(this.receiver&&this.receiver.transport&&"closed"===this.receiver.transport.state&&this.canplay&&(this.streamEnded=!0,this.emit("streamEnded"),this.canplay=!1),this.receiver&&"getStats"in this.receiver||this.pc&&"getStats"in this.pc)return new Promise((function(t,r){var n=null,i=!1;e.receiver&&"getStats"in e.receiver?n=e.receiver.getStats():e.pc&&"getStats"in e.pc&&(n=e.pc.getStats(),i=!0),null==n||n.then((function(r){r.forEach((function(t){var r,n;if(t)switch(t.type){case u.RTCStatsType.CandidatePair:e.onCandidatePair(t);break;case u.RTCStatsType.InboundRtp:s.SystemUtil.isIos&&i?(null===(r=t.id)||void 0===r?void 0:r.toLowerCase().includes(e.type))&&e.onInBoundRtp(t):s.BrowserUtil.isFirefox?t.kind===e.type&&e.onInBoundRtp(t):e.onInBoundRtp(t);break;case u.RTCStatsType.RemoteCandidate:e.onRemoteCandidate(t);break;case u.RTCStatsType.LocalCandidate:e.onLocalCandidate(t);break;case u.RTCStatsType.Track:if(e.type!==a.VIDEO)break;s.SystemUtil.isIos&&i?((null===(n=t.id)||void 0===n?void 0:n.toLowerCase().includes(e.type))||t.trackIdentifier.toLowerCase()===e.type)&&e.onTrack(t):e.onTrack(t)}})),t("")})).catch((function(e){r(e)}))}))},t.prototype.dispose=function(){this.reset()},t.prototype.onCandidatePair=function(e){("succeeded"===e.state||e.bytesReceived)&&(this.transportStats={timestamp:Math.floor(e.timestamp),rtt:e.currentRoundTripTime||-1,bytesReceived:e.bytesReceived,bytesSent:e.bytesSent})},t.prototype.onInBoundRtp=function(e){this.currentTimeGap=(e.timestamp-this.lastTimeStamp)/1e3,this.lastTimeStamp=e.timestamp,this.inboundRtpStreamStatsDiff=this.calcDiff(e,this.inboundRtpStreamStats,["bytesReceived","framesDecoded","packetsReceived","nackCount"]),this.inboundRtpStreamStats=e,!this.canplay&&Number(e.bytesReceived)>0&&(this.canplay=!0,this.emit("canPlay"))},t.prototype.calcDiff=function(e,t,r){var n={};return r.forEach((function(r){n[r]=Number(e[r]||0)-Number(t[r]||0)})),n},t.prototype.onRemoteCandidate=function(e){this.remoteCandidate=e||{}},t.prototype.onLocalCandidate=function(e){this.localCandidate=e||{}},t.prototype.onTrack=function(e){e.frameWidth&&(this.inboundRtpStreamStats.frameWidth=e.frameWidth,this.inboundRtpStreamStats.frameHeight=e.frameHeight)},t.prototype.reset=function(){this.currentTimeGap=0,this.lastTimeStamp=0,this.transportStats={},this.remoteCandidate={},this.localCandidate={},this.inboundRtpStreamStats={},this.inboundRtpStreamStatsDiff={},this.receiver=null,this.canplay=!1,this.streamEnded=!1},t}(c.default);t.ReceiverMonitorData=d},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RTCStatsType=void 0;var n=function(){function e(){}return e.CandidatePair="candidate-pair",e.Certificate="certificate",e.Codec="codec",e.Csrc="csrc",e.DataCahnnel="data-channel",e.InboundRtp="inbound-rtp",e.LocalCandidate="local-candidate",e.OutboundRtp="outbound-rtp",e.PeerConnection="peer-connection",e.Receiver="receiver",e.RemoteCandidate="remote-candidate",e.RemoteInboundRtp="remote-inbound-rtp",e.RemoteOutboundRtp="remote-outbound-rtp",e.Sender="sender",e.Stream="stream",e.Track="track",e.Transport="transport",e.MediaSource="media-source",e}();t.RTCStatsType=n},function(e,t,r){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}}},function(e,t,r){"use strict";var n=r(0);function i(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,r){if(!t)return e;var o;if(r)o=r(t);else if(n.isURLSearchParams(t))o=t.toString();else{var a=[];n.forEach(t,(function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,(function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),a.push(i(t)+"="+i(e))})))})),o=a.join("&")}if(o){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}},function(e,t,r){"use strict";e.exports=function(e,t,r,n,i){return e.config=t,r&&(e.code=r),e.request=n,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,r){"use strict";var n=r(0),i=r(56),o=r(57),a=r(21),s=r(58),c=r(61),u=r(62),d=r(24);e.exports=function(e){return new Promise((function(t,r){var p=e.data,l=e.headers,f=e.responseType;n.isFormData(p)&&delete l["Content-Type"];var h=new XMLHttpRequest;if(e.auth){var m=e.auth.username||"",v=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";l.Authorization="Basic "+btoa(m+":"+v)}var E=s(e.baseURL,e.url);function R(){if(h){var n="getAllResponseHeaders"in h?c(h.getAllResponseHeaders()):null,o={data:f&&"text"!==f&&"json"!==f?h.response:h.responseText,status:h.status,statusText:h.statusText,headers:n,config:e,request:h};i(t,r,o),h=null}}if(h.open(e.method.toUpperCase(),a(E,e.params,e.paramsSerializer),!0),h.timeout=e.timeout,"onloadend"in h?h.onloadend=R:h.onreadystatechange=function(){h&&4===h.readyState&&(0!==h.status||h.responseURL&&0===h.responseURL.indexOf("file:"))&&setTimeout(R)},h.onabort=function(){h&&(r(d("Request aborted",e,"ECONNABORTED",h)),h=null)},h.onerror=function(){r(d("Network Error",e,null,h)),h=null},h.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(d(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",h)),h=null},n.isStandardBrowserEnv()){var y=(e.withCredentials||u(E))&&e.xsrfCookieName?o.read(e.xsrfCookieName):void 0;y&&(l[e.xsrfHeaderName]=y)}"setRequestHeader"in h&&n.forEach(l,(function(e,t){void 0===p&&"content-type"===t.toLowerCase()?delete l[t]:h.setRequestHeader(t,e)})),n.isUndefined(e.withCredentials)||(h.withCredentials=!!e.withCredentials),f&&"json"!==f&&(h.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&h.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&h.upload&&h.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){h&&(h.abort(),r(e),h=null)})),p||(p=null),h.send(p)}))}},function(e,t,r){"use strict";var n=r(22);e.exports=function(e,t,r,i,o){var a=new Error(e);return n(a,t,r,i,o)}},function(e,t,r){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e,t){t=t||{};var r={},i=["url","method","data"],o=["headers","auth","proxy","params"],a=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],s=["validateStatus"];function c(e,t){return n.isPlainObject(e)&&n.isPlainObject(t)?n.merge(e,t):n.isPlainObject(t)?n.merge({},t):n.isArray(t)?t.slice():t}function u(i){n.isUndefined(t[i])?n.isUndefined(e[i])||(r[i]=c(void 0,e[i])):r[i]=c(e[i],t[i])}n.forEach(i,(function(e){n.isUndefined(t[e])||(r[e]=c(void 0,t[e]))})),n.forEach(o,u),n.forEach(a,(function(i){n.isUndefined(t[i])?n.isUndefined(e[i])||(r[i]=c(void 0,e[i])):r[i]=c(void 0,t[i])})),n.forEach(s,(function(n){n in t?r[n]=c(e[n],t[n]):n in e&&(r[n]=c(void 0,e[n]))}));var d=i.concat(o).concat(a).concat(s),p=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===d.indexOf(e)}));return n.forEach(p,u),r}},function(e,t,r){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PlayEvent=t.PlayType=void 0,t.PlayType={PLAY_CANPLAY:"canplay",PLAY_WAITING:"waiting",PLAY_PLAYING:"playing",PLAY_MEDIA:"media",PLAY_ENDED:"ended",PLAY_TIMEOUT:"timeout"};var n=function(e){this.event=e};t.PlayEvent=n},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.RemoteStream=void 0;var o=r(16),a=r(3),s=r(4),c=r(1),u=function(e){function t(){var t=e.call(this)||this;return t.recvCanPlay=!1,t.autoplay=!0,t.onCanPlay=t.onCanPlay.bind(t),t}return i(t,e),Object.defineProperty(t.prototype,"muted",{get:function(){return!!this.element&&this.element.muted},set:function(e){this.element&&(this.element.muted=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"audioTrack",{get:function(){var e;return null===(e=this.mediastream)||void 0===e?void 0:e.getAudioTracks()[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"videoTrack",{get:function(){var e;return null===(e=this.mediastream)||void 0===e?void 0:e.getVideoTracks()[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasVideo",{get:function(){return!!this.videoTrack},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasAudio",{get:function(){return!!this.audioTrack},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mediaStream",{get:function(){return this.mediastream},enumerable:!1,configurable:!0}),t.prototype.updateMediaStream=function(e){var t=this.mediastream||new MediaStream;e.getTracks().forEach((function(e){return t.addTrack(e)})),this.mediastream=t,this.element&&this.play(this.element)},t.prototype.getMediaStream=function(){return this.mediastream},t.prototype.mergeStream=function(e){if(this.mediaStream){var t=e.getVideoTracks()[0],r=e.getAudioTracks()[0];t&&(this.videoTrack&&this.mediaStream.removeTrack(this.videoTrack),this.mediaStream.addTrack(t),this.videotrack=t),r&&(this.audioTrack&&this.mediaStream.removeTrack(this.audioTrack),this.mediaStream.addTrack(r),this.audiotrack=r)}},t.prototype.play=function(e,t){if(this.autoplay=Boolean(!t||t.autoplay),e){if(e instanceof HTMLMediaElement==!1)throw new s.RtsError(c.ErrorCode.ERROR_HTMLELEMENT_ERROR,"Param is not a HTMLMediaElement","",{element:e});this.recvCanPlay=!1,this.emit("mediaElementBinded"),this.element=e,this.element.addEventListener("canplay",this.onCanPlay),"VIDEO"===this.element.nodeName&&(this.element.setAttribute("playsinline",""),a.BrowserUtil.isMicroMessenger&&(this.element.setAttribute("x5-video-player-type","h5-page"),this.element.setAttribute("x5-playsinline",""),a.SystemUtil.isAndroid||a.SystemUtil.isIos&&this.element.setAttribute("x-webkit-airplay","allow"))),this.autoplay&&a.BrowserUtil.isSafari&&this.element.setAttribute("autoplay",""),this.mediastream&&this.bindMediaStream(this.mediastream)}else this.release()},t.prototype.disableVideo=function(){var e=this.getMediaStream();e&&e.getVideoTracks().forEach((function(e){e.enabled&&(e.enabled=!1)}))},t.prototype.enableVideo=function(){var e=this.getMediaStream();e&&e.getVideoTracks().forEach((function(e){e.enabled||(e.enabled=!0)}))},t.prototype.disableAudio=function(){var e=this.getMediaStream();e&&e.getAudioTracks().forEach((function(e){e.enabled&&(e.enabled=!1)}))},t.prototype.enableAudio=function(){var e=this.getMediaStream();e&&e.getAudioTracks().forEach((function(e){e.enabled||(e.enabled=!0)}))},t.prototype.stop=function(){e.prototype.stop.call(this),this.release()},t.prototype.onCanPlay=function(){var e=this;if(!this.recvCanPlay&&(this.emit("onCanPlay"),this.recvCanPlay=!0,this.autoplay))if(this.element)if(a.BrowserUtil.isMicroMessenger){var t=window.top!==window.self,r=window.WeixinJSBridge||window.top.WeixinJSBridge;if(r)r.invoke("getNetworkType",{},(function(){e.tryToPlay()}));else(t?window.top.document:document).addEventListener("WeixinJSBridgeReady",(function(){r.invoke("getNetworkType",{},(function(){e.tryToPlay()}))}))}else this.tryToPlay();else this.tryToPlay()},t.prototype.release=function(){this.element&&(this.element.pause(),this.element.srcObject=null,this.element.load(),this.element.removeEventListener("canplay",this.onCanPlay)),this.recvCanPlay=!1,this.mediastream=void 0},t.prototype.bindMediaStream=function(e){this.element&&("AUDIO"===this.element.nodeName&&e.getVideoTracks()[0]&&e.removeTrack(e.getVideoTracks()[0]),this.element.srcObject=e),this.mediastream=e},t.prototype.tryToPlay=function(){var e=this;if(this.element){var t=this.element.play();void 0!==t&&t.then((function(){})).catch((function(t){console.log("playPromise err",t),e.element&&e.element.srcObject&&e.emit("onAutoPlayError")}))}},t}(o.Stream);t.RemoteStream=u},function(e,t,r){"use strict";var n=r(5);function i(e,t,r,i,o){var a=n.writeRtpDescription(e.kind,t);if(a+=n.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":o||"active"),a+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?a+="a=sendrecv\r\n":e.rtpSender?a+="a=sendonly\r\n":e.rtpReceiver?a+="a=recvonly\r\n":a+="a=inactive\r\n",e.rtpSender){var s=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=s;var c="msid:"+(i?i.id:"-")+" "+s+"\r\n";a+="a="+c,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+c,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+c,a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+n.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"),a}function o(e,t){var r={codecs:[],headerExtensions:[],fecMechanisms:[]},n=function(e,t){e=parseInt(e,10);for(var r=0;r<t.length;r++)if(t[r].payloadType===e||t[r].preferredPayloadType===e)return t[r]},i=function(e,t,r,i){var o=n(e.parameters.apt,r),a=n(t.parameters.apt,i);return o&&a&&o.name.toLowerCase()===a.name.toLowerCase()};return e.codecs.forEach((function(n){for(var o=0;o<t.codecs.length;o++){var a=t.codecs[o];if(n.name.toLowerCase()===a.name.toLowerCase()&&n.clockRate===a.clockRate){if("rtx"===n.name.toLowerCase()&&n.parameters&&a.parameters.apt&&!i(n,a,e.codecs,t.codecs))continue;(a=JSON.parse(JSON.stringify(a))).numChannels=Math.min(n.numChannels,a.numChannels),r.codecs.push(a),a.rtcpFeedback=a.rtcpFeedback.filter((function(e){for(var t=0;t<n.rtcpFeedback.length;t++)if(n.rtcpFeedback[t].type===e.type&&n.rtcpFeedback[t].parameter===e.parameter)return!0;return!1}));break}}})),e.headerExtensions.forEach((function(e){for(var n=0;n<t.headerExtensions.length;n++){var i=t.headerExtensions[n];if(e.uri===i.uri){r.headerExtensions.push(i);break}}})),r}function a(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 s(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 c(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}e.exports=function(e,t){function r(t,r){r.addTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function u(t,r,n,i){var o=new Event("track");o.track=r,o.receiver=n,o.transceiver={receiver:n},o.streams=i,e.setTimeout((function(){t._dispatchEvent("track",o)}))}var d=function(r){var i=this,o=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach((function(e){i[e]=o[e].bind(o)})),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 c("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(r.rtcpMuxPolicy||(r.rtcpMuxPolicy="require"),r.iceTransportPolicy){case"all":case"relay":break;default:r.iceTransportPolicy="all"}switch(r.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:r.bundlePolicy="balanced"}if(r.iceServers=function(e,t){var r=!1;return(e=JSON.parse(JSON.stringify(e))).filter((function(e){if(e&&(e.urls||e.url)){var n=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var i="string"==typeof n;return i&&(n=[n]),n=n.filter((function(e){return 0===e.indexOf("turn:")&&-1!==e.indexOf("transport=udp")&&-1===e.indexOf("turn:[")&&!r?(r=!0,!0):0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp")})),delete e.url,e.urls=i?n[0]:n,!!n.length}}))}(r.iceServers||[],t),this._iceGatherers=[],r.iceCandidatePoolSize)for(var a=r.iceCandidatePoolSize;a>0;a--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:r.iceServers,gatherPolicy:r.iceTransportPolicy}));else r.iceCandidatePoolSize=0;this._config=r,this.transceivers=[],this._sdpSessionId=n.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(d.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(d.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),d.prototype.onicecandidate=null,d.prototype.onaddstream=null,d.prototype.ontrack=null,d.prototype.onremovestream=null,d.prototype.onsignalingstatechange=null,d.prototype.oniceconnectionstatechange=null,d.prototype.onconnectionstatechange=null,d.prototype.onicegatheringstatechange=null,d.prototype.onnegotiationneeded=null,d.prototype.ondatachannel=null,d.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},d.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},d.prototype.getConfiguration=function(){return this._config},d.prototype.getLocalStreams=function(){return this.localStreams},d.prototype.getRemoteStreams=function(){return this.remoteStreams},d.prototype._createTransceiver=function(e,t){var r=this.transceivers.length>0,n={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&r)n.iceTransport=this.transceivers[0].iceTransport,n.dtlsTransport=this.transceivers[0].dtlsTransport;else{var i=this._createIceAndDtlsTransports();n.iceTransport=i.iceTransport,n.dtlsTransport=i.dtlsTransport}return t||this.transceivers.push(n),n},d.prototype.addTrack=function(t,r){if(this._isClosed)throw c("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var n;if(this.transceivers.find((function(e){return e.track===t})))throw c("InvalidAccessError","Track already exists.");for(var i=0;i<this.transceivers.length;i++)this.transceivers[i].track||this.transceivers[i].kind!==t.kind||(n=this.transceivers[i]);return n||(n=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(r)&&this.localStreams.push(r),n.track=t,n.stream=r,n.rtpSender=new e.RTCRtpSender(t,n.dtlsTransport),n.rtpSender},d.prototype.addStream=function(e){var r=this;if(t>=15025)e.getTracks().forEach((function(t){r.addTrack(t,e)}));else{var n=e.clone();e.getTracks().forEach((function(e,t){var r=n.getTracks()[t];e.addEventListener("enabled",(function(e){r.enabled=e.enabled}))})),n.getTracks().forEach((function(e){r.addTrack(e,n)}))}},d.prototype.removeTrack=function(t){if(this._isClosed)throw c("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 c("InvalidAccessError","Sender was not created by this connection.");var n=r.stream;r.rtpSender.stop(),r.rtpSender=null,r.track=null,r.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(n)&&this.localStreams.indexOf(n)>-1&&this.localStreams.splice(this.localStreams.indexOf(n),1),this._maybeFireNegotiationNeeded()},d.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)}))},d.prototype.getSenders=function(){return this.transceivers.filter((function(e){return!!e.rtpSender})).map((function(e){return e.rtpSender}))},d.prototype.getReceivers=function(){return this.transceivers.filter((function(e){return!!e.rtpReceiver})).map((function(e){return e.rtpReceiver}))},d.prototype._createIceGatherer=function(t,r){var n=this;if(r&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(i,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var r=!e.candidate||0===Object.keys(e.candidate).length;i.state=r?"completed":"gathering",null!==n.transceivers[t].bufferedCandidateEvents&&n.transceivers[t].bufferedCandidateEvents.push(e)},i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),i},d.prototype._gather=function(t,r){var i=this,o=this.transceivers[r].iceGatherer;if(!o.onlocalcandidate){var a=this.transceivers[r].bufferedCandidateEvents;this.transceivers[r].bufferedCandidateEvents=null,o.removeEventListener("localcandidate",this.transceivers[r].bufferCandidates),o.onlocalcandidate=function(e){if(!(i.usingBundle&&r>0)){var a=new Event("icecandidate");a.candidate={sdpMid:t,sdpMLineIndex:r};var s=e.candidate,c=!s||0===Object.keys(s).length;if(c)"new"!==o.state&&"gathering"!==o.state||(o.state="completed");else{"new"===o.state&&(o.state="gathering"),s.component=1,s.ufrag=o.getLocalParameters().usernameFragment;var u=n.writeCandidate(s);a.candidate=Object.assign(a.candidate,n.parseCandidate(u)),a.candidate.candidate=u,a.candidate.toJSON=function(){return{candidate:a.candidate.candidate,sdpMid:a.candidate.sdpMid,sdpMLineIndex:a.candidate.sdpMLineIndex,usernameFragment:a.candidate.usernameFragment}}}var d=n.getMediaSections(i._localDescription.sdp);d[a.candidate.sdpMLineIndex]+=c?"a=end-of-candidates\r\n":"a="+a.candidate.candidate+"\r\n",i._localDescription.sdp=n.getDescription(i._localDescription.sdp)+d.join("");var p=i.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),c||i._dispatchEvent("icecandidate",a),p&&(i._dispatchEvent("icecandidate",new Event("icecandidate")),i.iceGatheringState="complete",i._emitGatheringStateChange())}},e.setTimeout((function(){a.forEach((function(e){o.onlocalcandidate(e)}))}),0)}},d.prototype._createIceAndDtlsTransports=function(){var t=this,r=new e.RTCIceTransport(null);r.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var n=new e.RTCDtlsTransport(r);return n.ondtlsstatechange=function(){t._updateConnectionState()},n.onerror=function(){Object.defineProperty(n,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:r,dtlsTransport:n}},d.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var r=this.transceivers[e].iceTransport;r&&(delete r.onicestatechange,delete this.transceivers[e].iceTransport);var n=this.transceivers[e].dtlsTransport;n&&(delete n.ondtlsstatechange,delete n.onerror,delete this.transceivers[e].dtlsTransport)},d.prototype._transceive=function(e,r,i){var a=o(e.localCapabilities,e.remoteCapabilities);r&&e.rtpSender&&(a.encodings=e.sendEncodingParameters,a.rtcp={cname:n.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(a.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(a)),i&&e.rtpReceiver&&a.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach((function(e){delete e.rtx})),e.recvEncodingParameters.length?a.encodings=e.recvEncodingParameters:a.encodings=[{}],a.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(a.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(a.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(a))},d.prototype.setLocalDescription=function(e){var t,r,i=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(c("TypeError",'Unsupported type "'+e.type+'"'));if(!a("setLocalDescription",e.type,i.signalingState)||i._isClosed)return Promise.reject(c("InvalidStateError","Can not set local "+e.type+" in state "+i.signalingState));if("offer"===e.type)t=n.splitSections(e.sdp),r=t.shift(),t.forEach((function(e,t){var r=n.parseRtpParameters(e);i.transceivers[t].localCapabilities=r})),i.transceivers.forEach((function(e,t){i._gather(e.mid,t)}));else if("answer"===e.type){t=n.splitSections(i._remoteDescription.sdp),r=t.shift();var s=n.matchPrefix(r,"a=ice-lite").length>0;t.forEach((function(e,t){var a=i.transceivers[t],c=a.iceGatherer,u=a.iceTransport,d=a.dtlsTransport,p=a.localCapabilities,l=a.remoteCapabilities;if(!(n.isRejected(e)&&0===n.matchPrefix(e,"a=bundle-only").length)&&!a.rejected){var f=n.getIceParameters(e,r),h=n.getDtlsParameters(e,r);s&&(h.role="server"),i.usingBundle&&0!==t||(i._gather(a.mid,t),"new"===u.state&&u.start(c,f,s?"controlling":"controlled"),"new"===d.state&&d.start(h));var m=o(p,l);i._transceive(a,m.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()},d.prototype.setRemoteDescription=function(i){var d=this;if(-1===["offer","answer"].indexOf(i.type))return Promise.reject(c("TypeError",'Unsupported type "'+i.type+'"'));if(!a("setRemoteDescription",i.type,d.signalingState)||d._isClosed)return Promise.reject(c("InvalidStateError","Can not set remote "+i.type+" in state "+d.signalingState));var p={};d.remoteStreams.forEach((function(e){p[e.id]=e}));var l=[],f=n.splitSections(i.sdp),h=f.shift(),m=n.matchPrefix(h,"a=ice-lite").length>0,v=n.matchPrefix(h,"a=group:BUNDLE ").length>0;d.usingBundle=v;var E=n.matchPrefix(h,"a=ice-options:")[0];return d.canTrickleIceCandidates=!!E&&E.substr(14).split(" ").indexOf("trickle")>=0,f.forEach((function(a,c){var u=n.splitLines(a),f=n.getKind(a),E=n.isRejected(a)&&0===n.matchPrefix(a,"a=bundle-only").length,R=u[0].substr(2).split(" ")[2],y=n.getDirection(a,h),g=n.parseMsid(a),S=n.getMid(a)||n.generateIdentifier();if(E||"application"===f&&("DTLS/SCTP"===R||"UDP/DTLS/SCTP"===R))d.transceivers[c]={mid:S,kind:f,protocol:R,rejected:!0};else{var b,_,T,C,O,w,P,D,M;!E&&d.transceivers[c]&&d.transceivers[c].rejected&&(d.transceivers[c]=d._createTransceiver(f,!0));var A,I,N=n.parseRtpParameters(a);E||(A=n.getIceParameters(a,h),(I=n.getDtlsParameters(a,h)).role="client"),P=n.parseRtpEncodingParameters(a);var k=n.parseRtcpParameters(a),L=n.matchPrefix(a,"a=end-of-candidates",h).length>0,x=n.matchPrefix(a,"a=candidate:").map((function(e){return n.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===i.type||"answer"===i.type)&&!E&&v&&c>0&&d.transceivers[c]&&(d._disposeIceAndDtlsTransports(c),d.transceivers[c].iceGatherer=d.transceivers[0].iceGatherer,d.transceivers[c].iceTransport=d.transceivers[0].iceTransport,d.transceivers[c].dtlsTransport=d.transceivers[0].dtlsTransport,d.transceivers[c].rtpSender&&d.transceivers[c].rtpSender.setTransport(d.transceivers[0].dtlsTransport),d.transceivers[c].rtpReceiver&&d.transceivers[c].rtpReceiver.setTransport(d.transceivers[0].dtlsTransport)),"offer"!==i.type||E){if("answer"===i.type&&!E){_=(b=d.transceivers[c]).iceGatherer,T=b.iceTransport,C=b.dtlsTransport,O=b.rtpReceiver,w=b.sendEncodingParameters,D=b.localCapabilities,d.transceivers[c].recvEncodingParameters=P,d.transceivers[c].remoteCapabilities=N,d.transceivers[c].rtcpParameters=k,x.length&&"new"===T.state&&(!m&&!L||v&&0!==c?x.forEach((function(e){s(b.iceTransport,e)})):T.setRemoteCandidates(x)),v&&0!==c||("new"===T.state&&T.start(_,A,"controlling"),"new"===C.state&&C.start(I)),!o(b.localCapabilities,b.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&b.sendEncodingParameters[0].rtx&&delete b.sendEncodingParameters[0].rtx,d._transceive(b,"sendrecv"===y||"recvonly"===y,"sendrecv"===y||"sendonly"===y),!O||"sendrecv"!==y&&"sendonly"!==y?delete b.rtpReceiver:(M=O.track,g?(p[g.stream]||(p[g.stream]=new e.MediaStream),r(M,p[g.stream]),l.push([M,O,p[g.stream]])):(p.default||(p.default=new e.MediaStream),r(M,p.default),l.push([M,O,p.default])))}}else{(b=d.transceivers[c]||d._createTransceiver(f)).mid=S,b.iceGatherer||(b.iceGatherer=d._createIceGatherer(c,v)),x.length&&"new"===b.iceTransport.state&&(!L||v&&0!==c?x.forEach((function(e){s(b.iceTransport,e)})):b.iceTransport.setRemoteCandidates(x)),D=e.RTCRtpReceiver.getCapabilities(f),t<15019&&(D.codecs=D.codecs.filter((function(e){return"rtx"!==e.name}))),w=b.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var U,B=!1;if("sendrecv"===y||"sendonly"===y){if(B=!b.rtpReceiver,O=b.rtpReceiver||new e.RTCRtpReceiver(b.dtlsTransport,f),B)M=O.track,g&&"-"===g.stream||(g?(p[g.stream]||(p[g.stream]=new e.MediaStream,Object.defineProperty(p[g.stream],"id",{get:function(){return g.stream}})),Object.defineProperty(M,"id",{get:function(){return g.track}}),U=p[g.stream]):(p.default||(p.default=new e.MediaStream),U=p.default)),U&&(r(M,U),b.associatedRemoteMediaStreams.push(U)),l.push([M,O,U])}else b.rtpReceiver&&b.rtpReceiver.track&&(b.associatedRemoteMediaStreams.forEach((function(t){var r=t.getTracks().find((function(e){return e.id===b.rtpReceiver.track.id}));r&&function(t,r){r.removeTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(r,t)})),b.associatedRemoteMediaStreams=[]);b.localCapabilities=D,b.remoteCapabilities=N,b.rtpReceiver=O,b.rtcpParameters=k,b.sendEncodingParameters=w,b.recvEncodingParameters=P,d._transceive(d.transceivers[c],!1,B)}}})),void 0===d._dtlsRole&&(d._dtlsRole="offer"===i.type?"active":"passive"),d._remoteDescription={type:i.type,sdp:i.sdp},"offer"===i.type?d._updateSignalingState("have-remote-offer"):d._updateSignalingState("stable"),Object.keys(p).forEach((function(t){var r=p[t];if(r.getTracks().length){if(-1===d.remoteStreams.indexOf(r)){d.remoteStreams.push(r);var n=new Event("addstream");n.stream=r,e.setTimeout((function(){d._dispatchEvent("addstream",n)}))}l.forEach((function(e){var t=e[0],n=e[1];r.id===e[2].id&&u(d,t,n,[r])}))}})),l.forEach((function(e){e[2]||u(d,e[0],e[1],[])})),e.setTimeout((function(){d&&d.transceivers&&d.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()},d.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")},d.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},d.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))},d.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)}},d.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)}},d.prototype.createOffer=function(){var r=this;if(r._isClosed)return Promise.reject(c("InvalidStateError","Can not call createOffer after close"));var o=r.transceivers.filter((function(e){return"audio"===e.kind})).length,a=r.transceivers.filter((function(e){return"video"===e.kind})).length,s=arguments[0];if(s){if(s.mandatory||s.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==s.offerToReceiveAudio&&(o=!0===s.offerToReceiveAudio?1:!1===s.offerToReceiveAudio?0:s.offerToReceiveAudio),void 0!==s.offerToReceiveVideo&&(a=!0===s.offerToReceiveVideo?1:!1===s.offerToReceiveVideo?0:s.offerToReceiveVideo)}for(r.transceivers.forEach((function(e){"audio"===e.kind?--o<0&&(e.wantReceive=!1):"video"===e.kind&&--a<0&&(e.wantReceive=!1)}));o>0||a>0;)o>0&&(r._createTransceiver("audio"),o--),a>0&&(r._createTransceiver("video"),a--);var u=n.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.transceivers.forEach((function(i,o){var a=i.track,s=i.kind,c=i.mid||n.generateIdentifier();i.mid=c,i.iceGatherer||(i.iceGatherer=r._createIceGatherer(o,r.usingBundle));var u=e.RTCRtpSender.getCapabilities(s);t<15019&&(u.codecs=u.codecs.filter((function(e){return"rtx"!==e.name}))),u.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)}))})),u.headerExtensions.forEach((function(e){(i.remoteCapabilities&&i.remoteCapabilities.headerExtensions||[]).forEach((function(t){e.uri===t.uri&&(e.id=t.id)}))}));var d=i.sendEncodingParameters||[{ssrc:1001*(2*o+1)}];a&&t>=15019&&"video"===s&&!d[0].rtx&&(d[0].rtx={ssrc:d[0].ssrc+1}),i.wantReceive&&(i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,s)),i.localCapabilities=u,i.sendEncodingParameters=d})),"max-compat"!==r._config.bundlePolicy&&(u+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),u+="a=ice-options:trickle\r\n",r.transceivers.forEach((function(e,t){u+=i(e,e.localCapabilities,"offer",e.stream,r._dtlsRole),u+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===r.iceGatheringState||0!==t&&r.usingBundle||(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,u+="a="+n.writeCandidate(e)+"\r\n"})),"completed"===e.iceGatherer.state&&(u+="a=end-of-candidates\r\n"))}));var d=new e.RTCSessionDescription({type:"offer",sdp:u});return Promise.resolve(d)},d.prototype.createAnswer=function(){var r=this;if(r._isClosed)return Promise.reject(c("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==r.signalingState&&"have-local-pranswer"!==r.signalingState)return Promise.reject(c("InvalidStateError","Can not call createAnswer in signalingState "+r.signalingState));var a=n.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.usingBundle&&(a+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),a+="a=ice-options:trickle\r\n";var s=n.getMediaSections(r._remoteDescription.sdp).length;r.transceivers.forEach((function(e,n){if(!(n+1>s)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?a+="m=application 0 DTLS/SCTP 5000\r\n":a+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?a+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(a+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(a+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var c;if(e.stream)"audio"===e.kind?c=e.stream.getAudioTracks()[0]:"video"===e.kind&&(c=e.stream.getVideoTracks()[0]),c&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var u=o(e.localCapabilities,e.remoteCapabilities);!u.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,a+=i(e,u,"answer",e.stream,r._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(a+="a=rtcp-rsize\r\n")}}));var u=new e.RTCSessionDescription({type:"answer",sdp:a});return Promise.resolve(u)},d.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,o){if(!r._remoteDescription)return o(c("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var a=e.sdpMLineIndex;if(e.sdpMid)for(var u=0;u<r.transceivers.length;u++)if(r.transceivers[u].mid===e.sdpMid){a=u;break}var d=r.transceivers[a];if(!d)return o(c("OperationError","Can not add ICE candidate"));if(d.rejected)return i();var p=Object.keys(e.candidate).length>0?n.parseCandidate(e.candidate):{};if("tcp"===p.protocol&&(0===p.port||9===p.port))return i();if(p.component&&1!==p.component)return i();if((0===a||a>0&&d.iceTransport!==r.transceivers[0].iceTransport)&&!s(d.iceTransport,p))return o(c("OperationError","Can not add ICE candidate"));var l=e.candidate.trim();0===l.indexOf("a=")&&(l=l.substr(2)),(t=n.getMediaSections(r._remoteDescription.sdp))[a]+="a="+(p.type?l:"end-of-candidates")+"\r\n",r._remoteDescription.sdp=n.getDescription(r._remoteDescription.sdp)+t.join("")}else for(var f=0;f<r.transceivers.length&&(r.transceivers[f].rejected||(r.transceivers[f].iceTransport.addRemoteCandidate({}),(t=n.getMediaSections(r._remoteDescription.sdp))[f]+="a=end-of-candidates\r\n",r._remoteDescription.sdp=n.getDescription(r._remoteDescription.sdp)+t.join(""),!r.usingBundle));f++);i()}))},d.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 c("InvalidAccessError","Invalid selector.");return r.getStats()}var n=[];return this.transceivers.forEach((function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach((function(t){e[t]&&n.push(e[t].getStats())}))})),Promise.all(n).then((function(e){var t=new Map;return e.forEach((function(e){e.forEach((function(e){t.set(e.id,e)}))})),t}))};["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach((function(t){var r=e[t];if(r&&r.prototype&&r.prototype.getStats){var n=r.prototype.getStats;r.prototype.getStats=function(){return n.apply(this).then((function(e){var t=new Map;return Object.keys(e).forEach((function(r){var n;e[r].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(n=e[r]).type]||n.type,t.set(r,e[r])})),t}))}}}));var p=["createOffer","createAnswer"];return p.forEach((function(e){var t=d.prototype[e];d.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)}})),(p=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach((function(e){var t=d.prototype[e];d.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=d.prototype[e];d.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)}})),d}},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.EDatachannelStatus=t.EConnectStatus=t.AliRTS=void 0,r(74);var o=r(32);Object.defineProperty(t,"AliRTS",{enumerable:!0,get:function(){return o.AliRTS}}),window&&(window.AliRTS=o.AliRTS);var a=r(6);Object.defineProperty(t,"EConnectStatus",{enumerable:!0,get:function(){return a.EConnectStatus}});var s=r(9);Object.defineProperty(t,"EDatachannelStatus",{enumerable:!0,get:function(){return s.EDatachannelStatus}}),i(r(73),t)},function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AliRTS=void 0;var o=r(33),a=r(1),s=r(10),c=r(37),u=r(3),d=i(r(15)),p=r(17),l=r(14),f=function(){function e(){}return e.createClient=function(t){var r=t||{};return r.customReporter||(r.customReporter=e.customReporter),void 0===r.trackLog&&(r.trackLog=e.trackLog),new c.RtsClient(r)},e.getMicList=function(){var e=this;return new Promise((function(t,r){e.deviceManager.getMicList().then((function(e){t(e)})).catch((function(e){r(e)}))}))},e.getCameraList=function(){var e=this;return new Promise((function(t,r){e.deviceManager.getCameraList().then((function(e){t(e)})).catch((function(e){r(e)}))}))},e.getSpeakerList=function(){var e=this;return new Promise((function(t,r){e.deviceManager.getSpeakerList().then((function(e){t(e)})).catch((function(e){r(e)}))}))},e.createStream=function(t){return new Promise((function(r,i){var s=new o.LocalStream,c=new d.default({customReporter:e.customReporter,trackLog:e.trackLog});s.init(t).then((function(){r(s),c.reportStreamCreated(t,{videoTrack:!!s.videoTrack,audioTrack:!!s.audioTrack,screenAudio:!!s.screenAudioTrack,surface:s.screenSurfaceType})})).catch((function(e){var r=n(n({},e),{relatedLink:e.extraInfo});delete r.extraInfo,i(r),c.reportErrorInfo(a.ErrorCode.ERROR_INIT_LOCAL_FAIL,e.message,e.traceId,{config:t,originErr:e})}))}))},e.deviceManager=new s.BrowserDeviceManager,e.BrowserUtil=u.BrowserUtil,e.SystenUtil=u.SystemUtil,e.SupportUtil=l.SupportUtil,e.VideoProfileMap=p.VideoProfileMap,e.ScreenProfileMap=p.ScreenProfileMap,e.ErrorCode=a.ErrorCode,e.customReporter=function(){},e.trackLog=!0,e}();t.AliRTS=f},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},a=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},c=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LocalStream=void 0;var d=r(16),p=r(10),l=r(4),f=r(1),h=r(17),m=r(3),v=u(r(34)),E=r(35),R=r(8),y=function(e){function t(){var t=e.call(this)||this;return t.screenSurfaceType="",t.VideoProfileMap=new Map(h.VideoProfileMap),t.ScreenProfileMap=new Map(h.ScreenProfileMap),t.deviceManager=new p.BrowserDeviceManager,t.mediastream=new MediaStream,t.hasVideo=!1,t.hasScreen=!1,t.videoProfile="360p_1",t.screenProfile="720p_1",t.isCustomStream=!1,t.handleVideoTrackEnded=t.handleVideoTrackEnded.bind(t),t.handleAudioTrackEnded=t.handleAudioTrackEnded.bind(t),t}return i(t,e),Object.defineProperty(t.prototype,"mediaStream",{get:function(){return this.mediastream},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"audioTrack",{get:function(){return this.audiotrack},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"videoTrack",{get:function(){return this.videotrack},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasAudio",{get:function(){return!!this.audioTrack},enumerable:!1,configurable:!0}),t.prototype.getVideoProfile=function(){if(this.hasVideo)return this.videoProfile},t.prototype.getScreenProfile=function(){if(this.hasScreen)return this.screenProfile},t.prototype.init=function(e){return e.custom?this.createCustomStream(e.mediaStream):this.initWithRetry(e)},t.prototype.initWithRetry=function(e,t,r){var n=this;return new Promise((function(i,a){i=t||i,a=r||a;var s=[];s.push(n.initMicAudio(e)),e.video?s.push(n.initCameraVideo(e)):e.screen&&s.push(n.initScreenVideoAudio(e)),Promise.all(s).then((function(){n.tryMixMicAndScreenAudio(e),n.initTracks(e),e.skipProfile?i():n.tryToSetProfile(e).then((function(){i()})).catch((function(t){console.log(t),n.resetLocalStream(),n.initWithRetry(o(o({},e),{skipProfile:!0}),i,a)}))})).catch((function(e){n.stopAllTracks(),a(e)}))}))},t.prototype.initMicAudio=function(e){var t=this;return new Promise((function(r,n){if(!e||!e.audio)return r();var i={deviceId:!0===e.audio?"":String(e.audio.deviceId)};t.deviceManager.getAudioTrack(i).then((function(e){t.micAudioTrack=e,t.audiotrack=e,r()})).catch((function(e){n(new l.RtsError(e.code,e.reason,"",e.relatedLink))}))}))},t.prototype.initCameraVideo=function(e){var t=this;return new Promise((function(r,n){if(!e||!e.video)return r();var i={};!0===e.video?i.deviceId="":i=e.video,t.deviceManager.getVideoTrack(i).then((function(e){t.videotrack=e,t.hasVideo=!0,r()})).catch((function(e){n(new l.RtsError(e.code,e.reason,"",e.relatedLink))}))}))},t.prototype.initScreenVideoAudio=function(e){var t=this;return new Promise((function(r,n){if(e.screen){var i=!0,a=!1,s={};if("boolean"!=typeof e.screen){var u=e.screen,d=u.video,p=u.audio;s=c(u,["video","audio"]),i="object"!=typeof d||d,"boolean"!=typeof p&&"object"!=typeof p||(a=p)}m.SystemUtil.isMacOS&&m.BrowserUtil.isSafari&&["16.1","16.2","16.3"].indexOf(m.BrowserUtil.browserVersion)>-1&&"object"==typeof i&&("number"==typeof i.width&&(i.width={max:i.width}),"number"==typeof i.height&&(i.height={max:i.height})),t.deviceManager.getScreenStream(o({video:i,audio:a},s)).then((function(e){t.videotrack=e.getVideoTracks()[0],t.videotrack&&t.videotrack.getSettings&&(t.screenSurfaceType=t.videotrack.getSettings().displaySurface),t.hasScreen=!0;var n=e.getAudioTracks()[0];n&&(t.screenAudioTrack=n),r()})).catch((function(e){n(new l.RtsError(e.code,e.reason,"",e.relatedLink))}))}}))},t.prototype.tryMixMicAndScreenAudio=function(e){e.audio&&this.micAudioTrack&&this.hasScreenAudioConfig(e)&&this.screenAudioTrack?(this.audioMixer||(this.audioMixer=new v.default({useGainNode:!1,trackList:[]})),this.audioMixer.updateTrackList([this.screenAudioTrack,this.micAudioTrack]),this.audiotrack=this.audioMixer.getMixedAudioTrack()):e.audio&&this.micAudioTrack?this.audiotrack=this.micAudioTrack:this.hasScreenAudioConfig(e)&&this.screenAudioTrack&&(this.audiotrack=this.screenAudioTrack)},t.prototype.initTracks=function(e){this.hasAudioTrackReady(e)&&this.audiotrack&&this.mediastream.addTrack(this.audiotrack),this.hasVideoTrackReady(e)&&this.videotrack&&this.mediastream.addTrack(this.videotrack),this.addTrackListener()},t.prototype.tryToSetProfile=function(e){var t=this;return new Promise((function(r,n){return a(t,void 0,void 0,(function(){var t;return s(this,(function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),e.video?[4,this.setVideoProfile(this.videoProfile)]:[3,2];case 1:return i.sent(),[3,3];case 2:e.screen&&this.setScreenProfile(this.screenProfile).catch((function(e){console.log(e)})),i.label=3;case 3:return r(),[3,5];case 4:return t=i.sent(),n(new l.RtsError(f.ErrorCode.ERROR_DEIVCE_CONSTRAINEDERROR,"apply constraint failed","",{originErr:t,config:e})),[3,5];case 5:return[2]}}))}))}))},t.prototype.stopAllTracks=function(){this.screenAudioTrack&&(this.screenAudioTrack.stop(),this.screenAudioTrack=void 0),this.micAudioTrack&&(this.micAudioTrack.stop(),this.micAudioTrack=void 0),this.audioTrack&&(this.audioTrack.stop(),this.audiotrack=void 0),this.videoTrack&&(this.videoTrack.stop(),this.videotrack=void 0)},t.prototype.resetLocalStream=function(){this.deviceManager=new p.BrowserDeviceManager,this.mediastream=new MediaStream,this.hasVideo=!1,this.hasScreen=!1,this.videoProfile="360p_1",this.screenProfile="720p_1",this.isCustomStream=!1,this.stopAllTracks(),this.audioMixer=void 0,this.screenSurfaceType=""},t.prototype.setEncodeParam=function(e){var t=this;this.pc=e,this.pc.getSenders().forEach((function(e){var r,n,i=e.track;if("video"===(null==i?void 0:i.kind)&&(null==i?void 0:i.id)===(null===(r=t.videoTrack)||void 0===r?void 0:r.id)&&(e.setParameters&&e.getParameters&&(t.hasVideo?n=t.VideoProfileMap.get(t.videoProfile):t.hasScreen&&(n=t.ScreenProfileMap.get(t.screenProfile)),n))){var o=e.getParameters();o.degradationPreference="maintain-resolution",o.encodings.forEach((function(e){(null==n?void 0:n.maxBitrate)&&(e.maxBitrate=1024*n.maxBitrate),(null==n?void 0:n.frameRate)&&(e.maxFramerate=n.frameRate)})),e.setParameters(o)}}))},t.prototype.play=function(e,t){var r,n=this;if(null===(r=this.reporter)||void 0===r||r.reportPlay(e?e.nodeName:String(e)),e&&(this.element=e,this.mediastream)){if(this.element.srcObject=this.mediastream,(m.SystemUtil.isIos&&0===m.SystemUtil.systemVersion.indexOf("15.1")&&(m.BrowserUtil.isSafari||m.BrowserUtil.isChrome||m.BrowserUtil.isMicroMessenger)||(null==t?void 0:t.canvasStream))&&this.hasVideo){if(this.canvasRenderer)return;this.canvasRenderer=new E.CanvasRenderer({video:this.element});var i=this;this.element.addEventListener("loadeddata",(function e(){if(i.element&&(i.element.removeEventListener("loadeddata",e),i.canvasRenderer)){i.canvasRenderer.start();var t=i.canvasRenderer.mediaStream;t&&(i.mediastream=t,i.videotrack=t.getVideoTracks()[0])}})),this.element.addEventListener("resize",(function(){var e;if(n){var t=n.element;t&&(null===(e=n.canvasRenderer)||void 0===e||e.resize(t.videoWidth,t.videoHeight))}}))}if(t&&!1===t.autoplay)return;this.element.play()}},t.prototype.setVideoProfile=function(e){var t=this;return new Promise((function(r,n){return a(t,void 0,void 0,(function(){var t,i,o;return s(this,(function(a){switch(a.label){case 0:if(null===(o=this.reporter)||void 0===o||o.reportVideoProfile(e),!(t=this.VideoProfileMap.get(e)))return[3,5];if(this.isCustomStream||!this.hasVideo||!this.videotrack||!this.videotrack.applyConstraints)return[3,4];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.videotrack.applyConstraints(t)];case 2:return a.sent(),[3,4];case 3:return i=a.sent(),[2,n(i)];case 4:return this.videoProfile=e,this.pc&&this.setEncodeParam(this.pc),r(this.videoProfile),[3,6];case 5:n("Profile not found"),a.label=6;case 6:return[2]}}))}))}))},t.prototype.setScreenProfile=function(e){var t=this;return new Promise((function(r,n){return a(t,void 0,void 0,(function(){var t,i,o;return s(this,(function(a){switch(a.label){case 0:if(null===(o=this.reporter)||void 0===o||o.reportScreenProfile(e),!(t=this.ScreenProfileMap.get(e)))return[3,5];if(!(this.hasScreen&&this.videotrack&&this.videotrack.applyConstraints))return[3,4];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.videotrack.applyConstraints(t)];case 2:return a.sent(),[3,4];case 3:return i=a.sent(),[2,n(i)];case 4:return this.screenProfile=e,this.pc&&this.setEncodeParam(this.pc),r(this.screenProfile),[3,6];case 5:n("Profile not found"),a.label=6;case 6:return[2]}}))}))}))},t.prototype.enableAudio=function(){var e;return null===(e=this.reporter)||void 0===e||e.reportEnableAudio(),!!this.audiotrack&&(this.audiotrack.enabled=!0,!0)},t.prototype.disableAudio=function(){var e;return null===(e=this.reporter)||void 0===e||e.reportDisableAudio(),!!this.audiotrack&&(this.audiotrack.enabled=!1,!0)},t.prototype.enableVideo=function(){var e;return null===(e=this.reporter)||void 0===e||e.reportEnableVideo(),!!this.videotrack&&(this.videotrack.enabled=!0,!0)},t.prototype.disableVideo=function(){var e;return null===(e=this.reporter)||void 0===e||e.reportDisableVideo(),!!this.videotrack&&(this.videotrack.enabled=!1,!0)},t.prototype.stop=function(){var t;e.prototype.stop.call(this),this.hasVideo=!1,this.hasScreen=!1,this.isCustomStream=!1,this.canvasRenderer&&(this.canvasRenderer.stop(),this.canvasRenderer=void 0),this.audiotrack&&(this.audiotrack.stop(),this.audiotrack=void 0),this.videotrack&&(this.videotrack.stop(),this.videotrack=void 0),this.micAudioTrack&&(this.micAudioTrack.stop(),this.micAudioTrack=void 0),this.screenAudioTrack&&(this.screenAudioTrack.stop(),this.screenAudioTrack=void 0),null===(t=this.reporter)||void 0===t||t.reportStop(0)},t.prototype.mergeStream=function(e){var t=e.videoTrack,r=e.audioTrack;t&&(this.videoTrack&&(this.videoTrack.removeEventListener("ended",this.handleVideoTrackEnded),this.mediaStream.removeTrack(this.videoTrack)),this.mediaStream.addTrack(t),this.videotrack=t,this.listenVideoEnded(),this.hasVideo=e.hasVideo,this.hasScreen=e.hasScreen,this.isCustomStream=e.isCustomStream,this.hasVideo&&(this.videoProfile=e.videoProfile),this.hasScreen&&(this.screenProfile=e.screenProfile)),r&&(this.audioTrack&&(this.audioTrack.removeEventListener("ended",this.handleAudioTrackEnded),this.mediaStream.removeTrack(this.audioTrack)),this.mediaStream.addTrack(r),this.audiotrack=r,this.listenAudioEnded())},t.prototype.deleteTracks=function(e){e.audio&&this.audioTrack&&(this.mediaStream.removeTrack(this.audioTrack),this.audiotrack=void 0),e.video&&this.videoTrack&&(this.mediaStream.removeTrack(this.videoTrack),this.videotrack=void 0,this.hasScreen=!1,this.hasVideo=!1)},t.prototype.createCustomStream=function(e){var t=this;return new Promise((function(r,n){if(!e)return n(new l.RtsError(f.ErrorCode.ERROR_CUSTOMSTREAM_NONE,"MediaStream is required.",""));if(!(e instanceof MediaStream))return n(new l.RtsError(f.ErrorCode.ERROR_CUSTOMSTREAM_INVALID,"MediaStream is invalid.",""));if(0===e.getTracks().length)return n(new l.RtsError(f.ErrorCode.ERROR_CUSTOMSTREAM_TRACK_NONE,"MediaStream has no track.",""));var i=(0,R.getVideoTrack)(e),o=(0,R.getAudioTrack)(e);i&&(t.hasVideo=!0,t.videotrack=i,t.mediastream.addTrack(i)),o&&(t.audiotrack=o,t.mediastream.addTrack(o)),t.isCustomStream=!0,t.setVideoProfile(t.videoProfile),t.addTrackListener(),r()}))},t.prototype.releaseMediaStream=function(){var e=this;this.mediastream.getTracks().forEach((function(t){t.stop(),e.mediastream.removeTrack(t)}))},t.prototype.hasVideoTrackReady=function(e){return!(!e.video&&!e.screen||!this.videotrack)||!e.video&&!e.screen},t.prototype.hasScreenAudioConfig=function(e){return"object"==typeof e.screen&&e.screen.audio},t.prototype.hasAudioTrackReady=function(e){return!(e.audio&&(!this.hasMicAudioAndReady(e)&&!this.hasScreenAudioAndReady(e)||!this.audiotrack))},t.prototype.hasMicAudioAndReady=function(e){return e.audio&&this.micAudioTrack},t.prototype.hasScreenAudioAndReady=function(e){return this.hasScreenAudioConfig(e)&&this.screenAudioTrack},t.prototype.addTrackListener=function(){this.listenVideoEnded(),this.listenAudioEnded()},t.prototype.listenVideoEnded=function(){var e=this;this.videotrack&&this.videotrack.addEventListener("ended",this.handleVideoTrackEnded),this.micAudioTrack&&this.micAudioTrack.addEventListener("ended",(function(){var t;e.emit("micAudioTrackEnded"),e.screenAudioTrack&&"ended"===e.screenAudioTrack.readyState&&(null===(t=e.audioMixer)||void 0===t||t.destroy(),e.emit("audioTrackEnded"))})),this.screenAudioTrack&&this.screenAudioTrack.addEventListener("ended",(function(){var t;e.emit("screenAudioTrackEnded"),e.micAudioTrack&&"ended"===e.micAudioTrack.readyState&&(null===(t=e.audioMixer)||void 0===t||t.destroy(),e.emit("audioTrackEnded"))}))},t.prototype.listenAudioEnded=function(){this.audiotrack&&this.audiotrack.addEventListener("ended",this.handleAudioTrackEnded)},t.prototype.handleVideoTrackEnded=function(){this.hasScreen=!1,this.hasVideo=!1,this.emit("videoTrackEnded")},t.prototype.handleAudioTrackEnded=function(){this.emit("audioTrackEnded")},t}(d.Stream);t.LocalStream=y},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.useGainNode=!0,this.audioContext=new AudioContext,this.audioDestination=this.audioContext.createMediaStreamDestination(),this.audioSource=[],this.gainNode=null,this.audioTrack=null,this.audioTrackArr=e.trackList||[],this.useGainNode="boolean"!=typeof e.useGainNode||e.useGainNode,this.useGainNode&&(this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination),this.gainNode.gain.value=0),this.getMixedAudioTrack()}return e.prototype.destroy=function(){var e;null===(e=this.getMixedAudioTrack())||void 0===e||e.stop(),this.disconnectSourceNode(),this.audioContext.close(),this.audioTrackArr=[]},e.prototype.updateTrackList=function(e){e.length&&(this.disconnectSourceNode(),this.audioTrackArr=e,this.connectNode())},e.prototype.getMixedAudioTrack=function(){return this.audioTrack||(this.connectNode(),this.audioTrack=this.audioDestination.stream.getAudioTracks()[0]),this.audioTrack},e.prototype.connectNode=function(){var e=this;this.audioTrackArr.forEach((function(t){var r=new MediaStream;r.addTrack(t);var n=e.audioContext.createMediaStreamSource(r);e.gainNode&&n.connect(e.gainNode),e.audioSource.push(n)})),this.audioSource.forEach((function(t){t.connect(e.audioDestination)}))},e.prototype.disconnectSourceNode=function(){var e=this;this.audioSource.forEach((function(t){e.gainNode&&t.disconnect(e.gainNode),t.disconnect(e.audioDestination)})),this.audioSource=[]},e}();t.default=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CanvasRenderer=void 0;var n=r(36),i=function(){function e(e){this.video=e.video,this.canvas=this.initCanvas(),this.activeRenderer=this.initRenderer()}return Object.defineProperty(e.prototype,"mediaStream",{get:function(){var e;return this.ms||(this.ms=(null===(e=this.canvas)||void 0===e?void 0:e.captureStream())||void 0),this.ms},enumerable:!1,configurable:!0}),e.prototype.start=function(){this.render()},e.prototype.stop=function(){this.activeRenderer.stop()},e.prototype.initCanvas=function(){var e=document.createElement("canvas"),t=this.video;return e.width=1*t.videoWidth,e.height=1*t.videoHeight,e},e.prototype.initRenderer=function(){return new n.TwoDRenderer({video:this.video,canvas:this.canvas})},e.prototype.render=function(){this.activeRenderer.render()},e.prototype.resize=function(e,t){this.canvas&&(this.canvas.width=e,this.canvas.height=t)},e}();t.CanvasRenderer=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TwoDRenderer=void 0;var n=function(){function e(e){this.video=e.video,this.canvas=e.canvas,this.ctx=this.canvas.getContext("2d")}return e.prototype.render=function(){var e,t,r=this.video,n=this.canvas;r&&n&&(null===(e=this.ctx)||void 0===e||e.clearRect(0,0,n.width,n.height),null===(t=this.ctx)||void 0===t||t.drawImage(r,0,0,1*r.videoWidth,1*r.videoHeight),this.requestId=requestAnimationFrame(this.render.bind(this)))},e.prototype.stop=function(){this.requestId&&cancelAnimationFrame(this.requestId)},e}();t.TwoDRenderer=n},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},a=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},c=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.RtsClient=void 0;var d=u(r(2)),p=r(6),l=r(38),f=r(70),h=r(71),m=u(r(15)),v=u(r(7)),E=r(14),R=r(1),y=function(e){function t(t){var r=e.call(this)||this;return r.pullH264Checked=!1,r.reporter=new m.default(t),r.subscriber=new l.Subscriber(r.reporter,t?t.playConfig:void 0),r.publisher=new f.Publisher(r.reporter),r.commonController=new h.CommonController(r.reporter),r.subscriber.on("onError",(function(e){var t,n;r.reporter.reportErrorInfo(e.errorCode,e.message,e.traceId,{sdp:null===(t=e.extraInfo)||void 0===t?void 0:t.sdp}),R.SUB_RECONNECT_ERROR_LIST.includes(e.errorCode)?r.subscriber.isConnecting||(r.subscriber.retrySubscribe(e)?(r.reporter.reportReconnect(e.errorCode,e.message,e.traceId,null===(n=e.extraInfo)||void 0===n?void 0:n.retryTimes),r.emit("reconnect",r.makeReconnectEvent("sub",e))):r.emit("onError",e)):r.emit("onError",e)})),r.subscriber.on("encodedFrame",(function(e){r.emit("encodedFrame",e)})),r.subscriber.on("reconnect",(function(e){var t;r.reporter.reportReconnect(e.errorCode,e.message,e.traceId,null===(t=e.extraInfo)||void 0===t?void 0:t.retryTimes),r.emit("reconnect",r.makeReconnectEvent("sub",e))})),r.subscriber.on("onPlayEvent",(function(e){r.emit("onPlayEvent",e)})),r.subscriber.on("connectStatusChange",(function(e){r.emit("connectStatusChange",e),r.reporter.reportConnectionChange(p.EConnectStatus[e.status],"sub")})),r.publisher.on("connectStatusChange",(function(e){r.emit("connectStatusChange",e),r.reporter.reportConnectionChange(p.EConnectStatus[e.status],"pub")})),r.publisher.on("onError",(function(e){var t,n,i;if(r.reporter.reportErrorInfo(e.errorCode,e.message,e.traceId,{sdp:null===(t=e.extraInfo)||void 0===t?void 0:t.sdp}),R.PUB_RECONNECT_ERROR_LIST.includes(e.errorCode)){if(!r.publisher.isConnecting){var o=e.errorCode===R.ErrorCode.ERROR_TRANSPORT_CLOSED&&"tcp"!==(null===(n=e.extraInfo)||void 0===n?void 0:n.protocol);console.log("Retrying with ",o?"TCP":"UDP"),r.publisher.retryPublish(e,o)?(r.reporter.reportReconnect(e.errorCode,e.message,e.traceId,null===(i=e.extraInfo)||void 0===i?void 0:i.retryTimes,o),r.emit("reconnect",r.makeReconnectEvent("pub",e))):r.emit("onError",e)}}else r.emit("onError",e)})),r.publisher.on("reconnect",(function(e){var t;r.reporter.reportReconnect(e.errorCode,e.message,e.traceId,null===(t=e.extraInfo)||void 0===t?void 0:t.retryTimes),r.emit("reconnect",r.makeReconnectEvent("pub",e))})),r.commonController.on("connectStatusChange",(function(e){r.emit("connectStatusChange",e),r.reporter.reportConnectionChange(p.EConnectStatus[e.status],"signalChannel")})),r.commonController.on("onError",(function(e){r.reporter.reportErrorInfo(e.errorCode,e.message,e.traceId),r.emit("onError",e)})),r.commonController.on("datachannelStatusChange",(function(e){r.emit("datachannelStatusChange",e)})),r.commonController.on("onPlayEvent",(function(e){r.emit("onPlayEvent",e)})),r.reporter.reportCreateClient(),r}return i(t,e),t.prototype.getVersion=function(){return v.default.version},t.prototype.isSupport=function(e){var t=new E.SupportUtil;return this.pullH264Checked=!0,t.isSupport(e)},t.prototype.checkPublishSupport=function(){return(new E.SupportUtil).checkPublishSupport()},t.prototype.checkEncodedTransformSupport=function(){return(new E.SupportUtil).checkEncodedTransformSupport()},t.prototype.subscribe=function(e,t){return this.reporter.updateUrl(e),this.commonController.setPeerconnection(this.subscriber.getPeerConnection()),this.subscriber.resetResubscribeStatus(),this.subscriber.subscribeWithReconnect(e,o(o({},t),{isH264Checked:this.pullH264Checked}))},t.prototype.subscribeAdd=function(e){return this.commonController.subscribeAdd(e)},t.prototype.subscribeActive=function(e){return this.commonController.subscribeActive(e)},t.prototype.subscribeDeleteTracks=function(e){return this.commonController.subscribeDeleteTracks(e)},t.prototype.subscribeStop=function(e){return this.commonController.subscribeStop(e)},t.prototype.publishAdd=function(e){return this.commonController.publishAdd(e)},t.prototype.publishDeleteTracks=function(e){return this.commonController.publishDeleteTracks(e)},t.prototype.publishReplaceTracks=function(e){return this.commonController.publishReplaceTracks(e)},t.prototype.publishStop=function(e){return this.commonController.publishStop(e)},t.prototype.subscribeAddDatachannel=function(e){return this.commonController.subscribeAddDatachannel(e)},t.prototype.subscribeStopDatachannel=function(e){return this.commonController.subscribeStopDatachannel(e)},t.prototype.unsubscribe=function(){this.subscriber.resetResubscribeStatus(),this.subscriber.unsubscribe()},t.prototype.startLiveStream=function(e,t,r){return this.reporter.reportStartPlay(e),this.subscriber.startLiveStream(e,t,r)},t.prototype.stopLiveStream=function(){this.reporter.reportStopPlay(),this.subscriber.stopLiveStream()},t.prototype.muteLiveStream=function(e){this.subscriber.muteLiveStream(e)},t.prototype.publish=function(e,t,r){return a(this,void 0,void 0,(function(){return s(this,(function(n){return this.reporter.updateUrl(e),this.commonController.setPeerconnection(this.publisher.getPeerConnection()),this.publisher.resetRepublishStatus(),[2,this.publisher.publishWithReconnect(e,t,r)]}))}))},t.prototype.unpublish=function(){return this.publisher.resetRepublishStatus(),this.publisher.unpublish()},t.prototype.getPublishTrackInfoList=function(){return this.publisher.getTrackInfoList()},t.prototype.getTransportStats=function(){return this.subscriber.getPeerConnection().getSubMonitor().getTransportStats()},t.prototype.getRemoteVideoStats=function(){return this.subscriber.getPeerConnection().getSubMonitor().getRemoteVideoStats()},t.prototype.getRemoteAudioStats=function(){return this.subscriber.getPeerConnection().getSubMonitor().getRemoteAudioStats()},t.prototype.getSubscribeVideoStats=function(e,t){return this.commonController.getSubscribeVideoStats(e,t)},t.prototype.getSubscribeAudioStats=function(e,t){return this.commonController.getSubscribeAudioStats(e,t)},t.prototype.getPublishVideoStats=function(e,t){return this.commonController.getPublishVideoStats(e,t)},t.prototype.getPublishAudioStats=function(e,t){return this.commonController.getPublishAudioStats(e,t)},t.prototype.makeReconnectEvent=function(e,t){var r=t||{},n=r.extraInfo||{};return{type:e,reason:c(r,["extraInfo"]),retryTimes:n.retryTimes,extraInfo:c(n,["retryTimes"])}},t}(d.default);t.RtsClient=y},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},a=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Subscriber=void 0;var u,d=r(11),p=r(6),l=r(1),f=c(r(12)),h=c(r(2)),m=r(4),v=r(14),E=r(69),R=c(r(15)),y=c(r(7)),g=r(28),S=r(29),b=r(8);!function(e){e[e.Init=0]="Init",e[e.Requesting=1]="Requesting",e[e.Playing=2]="Playing",e[e.Waiting=3]="Waiting"}(u||(u={}));var _=function(e){function t(t,r){var n=e.call(this)||this;return n.monitorStatsHistory=[],n.playTimeIndex=0,n.playCatonIndex=0,n.reportPubFlag=!1,n.state=u.Init,n.subscribeAudio=!0,n.subscribeVideo=!0,n.signalingUrl="",n.pullStreamUrl="",n.noParsePullStreamUrl="",n.subReconnectTimes=0,n.isConnecting=!1,n.reconnectTimerHandle=null,n.reporter=t,n.playTimer=0,n.config=r||{playTimeOut:5e3},n.remoteStream=new S.RemoteStream,n.remoteStream.on("onAutoPlayError",(function(){n.emit("onError",new m.RtsError(l.ErrorCode.ERROR_AUTOPLAY_ERROR,"auto play failed",""))})),n.remoteStream.on("onCanPlay",(function(){return a(n,void 0,void 0,(function(){var e,t,r,n,i,o,a,c,u,d,p;return s(this,(function(s){switch(s.label){case 0:return e=(new Date).getTime(),[4,this.peerconnection.sample()];case 1:return s.sent(),t=-1,r=[],n=-1,this.monitorStatsHistory&&this.monitorStatsHistory.length&&(i=this.monitorStatsHistory[this.monitorStatsHistory.length-1],this.monitorStatsHistory.forEach((function(e){var t=e.rtt;t&&t>0&&r.push(t)})),t=Number((r.reduce((function(e,t){return e+t}),0)/r.length).toFixed(3)),n=i.packetsLost,this.monitorStatsHistory=null),this.stopPlayTimer(),this.peerconnection.playStart(),this.subReconnectTimes=0,o=this._cnend||e,this.reporter.reportFirstFrameTime(this.noParsePullStreamUrl,this.remoteStream.traceId,this._cpend-this._cpstart,this._hrend-this._cpend,e-this._cpstart,0,o-this._hrend,{rttAvg:t,packetsLost:n},-1,-1,-1,null===(c=this.subscribeConfig)||void 0===c?void 0:c.vMsid,null===(u=this.subscribeConfig)||void 0===u?void 0:u.aMsid),(a=new g.PlayEvent(g.PlayType.PLAY_CANPLAY)).data={url:this.noParsePullStreamUrl,vMsid:null===(d=this.subscribeConfig)||void 0===d?void 0:d.vMsid,aMsid:null===(p=this.subscribeConfig)||void 0===p?void 0:p.aMsid},this.emit("onPlayEvent",a),[2]}}))}))})),n.peerconnection=new d.RtsPeerconnection,n.peerconnection.on("onConnected",(function(){n._cnend=(new Date).getTime()})),n.peerconnection.on("streamEnded",(function(e){var t=new g.PlayEvent(g.PlayType.PLAY_ENDED);t.data=o({},e),n.emit("onPlayEvent",t),n.emit("onError",new m.RtsError(l.ErrorCode.ERROR_STREAM_ENDED,"Stream Receiver Transport is Closed",n.remoteStream.traceId))})),n.peerconnection.on("onTrackEvent",(function(e){e.streams&&e.streams.length&&(n.remoteStream.updateMediaStream(e.streams[0]),n.onTrackFunction&&n.onTrackFunction())})),n.peerconnection.on("connectStatusChange",(function(e){e.status!==p.EConnectStatus.CONNECT_STATUS_DISCONNECTED&&e.status!==p.EConnectStatus.CONNECT_STATUS_RECONNECTING||!n.hasRetries()?n.emit("connectStatusChange",e):n.emit("onError",new m.RtsError(l.ErrorCode.ERROR_PC_DISCONNECTED,"PC disconnected",n.remoteStream.traceId))})),n.peerconnection.on("encodedFrame",(function(e){n.emit("encodedFrame",e)})),n.mediaObserver=new E.MediaObserver({handler:function(e,t,r){var i,o=new g.PlayEvent(g.PlayType.PLAY_TIMEOUT),a={url:e};t&&(a.vMsid=t),r&&(a.aMsid=r),o.data=a,n.emit("onPlayEvent",o);var s=new m.RtsError(l.ErrorCode.ERROR_INBOUND_TIMEOUT,"Media data timeout after ".concat(null===(i=n.mediaObserver)||void 0===i?void 0:i.actTimeout," ms."),n.remoteStream.traceId);n.emit("onError",s)}}),n.peerconnection.on("onMonitorEvent",(function(e){var t=e.eventList;if("pub"!==e.type){if(t.length){for(var r=void 0,i=0;i<t.length;i++)if(t[i].url===(0,b.pruneSubUrl)(n.noParsePullStreamUrl,!0)){r=t[i];break}if(r){n.lastMeidaEventData=r;var a=r.video,s=r.audio;a&&n.monitorStatsHistory?n.monitorStatsHistory.push({rtt:a.transportStats.rtt,packetsLost:a.inboundRtpStats.packetsLost}):s&&n.monitorStatsHistory&&n.monitorStatsHistory.push({rtt:s.transportStats.rtt,packetsLost:s.inboundRtpStats.packetsLost}),u.Requesting===n.state?r.video?r.video.inboundRtpStatsPerSec.framesDecodedPerSecond>5&&(n.state=u.Playing):r.audio&&r.audio.inboundRtpStatsPerSec.bytesReceivedPerSecond>0&&(n.state=u.Playing):n.state!==u.Playing&&n.state!==u.Waiting||(++n.playTimeIndex,r.video&&(r.video.inboundRtpStatsPerSec.framesDecodedPerSecond<=5?(++n.playCatonIndex,u.Waiting!==n.state&&(n.state=u.Waiting,n.emit("onPlayEvent",new g.PlayEvent(g.PlayType.PLAY_WAITING)))):u.Waiting===n.state&&(n.state=u.Playing,n.emit("onPlayEvent",new g.PlayEvent(g.PlayType.PLAY_PLAYING)))),R.default.HEARTHEAT_INTERVAL===n.playTimeIndex&&(n.reportPubFlag=!0,t.forEach((function(e){n.doReportPullStats(e)})),n.playTimeIndex=0,n.playCatonIndex=0))}var c=new g.PlayEvent(g.PlayType.PLAY_MEDIA);c.data=[],t.forEach((function(e){var t={};t.url=e.url;var r=n.calcStreamPullStats(e);if(e.audio&&(t.audio={bytesReceivedPerSecond:e.audio.inboundRtpStatsPerSec.bytesReceivedPerSecond,rtt:e.audio.transportStats.rtt,lossRate:r.aloss},t.aMsid=e.aMsid),e.video){var i=e.video,o=i.inboundRtpStats,a=i.inboundRtpStatsPerSec,s=i.transportStats;t.video={bytesReceivedPerSecond:a.bytesReceivedPerSecond,fps:o.framesPerSecond||a.framesDecodedPerSecond,framesDecodedPerSecond:a.framesDecodedPerSecond,rtt:s.rtt,width:o.frameWidth,height:o.frameHeight,lossRate:r.vloss},t.vMsid=e.vMsid}t.networkQuality=r.net_qual||0,c.data.push(t)})),c.data&&c.data.length&&(c.data.forEach((function(e){var t;null===(t=n.mediaObserver)||void 0===t||t.check({audio:e.audio,video:e.video},e.url,e.vMsid,e.aMsid)})),1===c.data.length&&(c.data[0].audio||c.data[0].video)&&(c.data=o({},c.data[0])),n.emit("onPlayEvent",c))}}else n.reportPubFlag&&(n.handlePubMonitorEvent(t),n.reportPubFlag=!1)})),n.playTimer=0,n._cpstart=0,n._cpend=0,n._hrend=0,n._cnend=0,n}return i(t,e),t.prototype.getPeerConnection=function(){return this.peerconnection},t.prototype.subscribe=function(e,t){var r=this;return new Promise((function(n,i){return a(r,void 0,void 0,(function(){var r,a,c=this;return s(this,(function(s){switch(s.label){case 0:return this.monitorStatsHistory=[],this.unsubscribe(),this.subscribeConfig=t,this.state=u.Requesting,this.noParsePullStreamUrl=e,this.parseUrl(e),null===(a=this.mediaObserver)||void 0===a||a.updateConfig({timeout:null==t?void 0:t.mediaTimeout}),r=null==t?void 0:t.signalUrl,this.signalingUrl=r||this.signalingUrl,this.pullStreamUrl?[3,1]:(i(new m.RtsError(l.ErrorCode.ERROR_PLAY_URL,"url need artc://","")),[3,8]);case 1:return this.subscribeAudio||this.subscribeVideo?[3,2]:(i(new m.RtsError(l.ErrorCode.ERROR_SUBSCRIBE_NOTHING,"subscribe nothing","")),[3,8]);case 2:if(this._cpstart=(new Date).getTime(),!this.subscribeVideo||(null==t?void 0:t.isH264Checked))return[3,7];s.label=3;case 3:return s.trys.push([3,5,,6]),[4,(new v.SupportUtil).loadH264(3)];case 4:return s.sent(),[3,6];case 5:return s.sent(),[3,6];case 6:s.label=7;case 7:this.peerconnection.createOffer(this.subscribeAudio,this.subscribeVideo,void 0,{offerSdpHook:null==t?void 0:t.offerSdpHook,encodedInsertableStreams:null==t?void 0:t.encodedInsertableStreams}).then((function(e){var r=e.desp;c._cpend=(new Date).getTime(),c.reporter.reportSubscribeStart(c.noParsePullStreamUrl,c.signalingUrl,null==t?void 0:t.vMsid,null==t?void 0:t.aMsid),c.excuteSignal(r).then((function(e){var t;c.remoteStream.traceId=e,n(c.remoteStream);try{null===(t=c.peerconnection.getPeerCore())||void 0===t||t.patchSubscribeStreamManagerRecord(c.noParsePullStreamUrl,o(o({},c.subscribeConfig),{stream:c.remoteStream}))}catch(e){console.log(e)}c.peerconnection.getSubMonitor().updateTranceiversController()})).catch((function(e){c._hrend=(new Date).getTime();var t=new m.RtsError(e.errorCode?e.errorCode:l.ErrorCode.ERROR_HTTPREQUEST_ERROR,e.message,e?e.traceid:"",{response:e.response,sdp:e.sdp});i(t)}))})).catch((function(e){c._cpend=(new Date).getTime();var t=new m.RtsError(l.ErrorCode.ERROR_CREATEOFFER,e.message,"");i(t)})),s.label=8;case 8:return[2]}}))}))}))},t.prototype.unsubscribe=function(){var e;this.lastMeidaEventData&&this.doReportPullStats(this.lastMeidaEventData),this.stopPlayTimer(),this.peerconnection.dispose(),this.remoteStream.stop(),this.subscribeVideo=!0,this.subscribeAudio=!0,this.subscribeConfig=void 0,this.state=u.Init,this.signalingUrl="",this.pullStreamUrl="",this.noParsePullStreamUrl="",this.onTrackFunction=void 0,this.playTimer=0,this._cpstart=0,this._cpend=0,this._hrend=0,this._cnend=0,this.monitorStatsHistory=[],null===(e=this.mediaObserver)||void 0===e||e.reset()},t.prototype.startLiveStream=function(e,t,r){var n=this;return console.error("此API可能存在稳定性问题,并将在未来的版本移除。请使用subscribe替代,详细用法请参考官方文档。"),new Promise((function(i,o){n.unsubscribe(),n.state=u.Requesting,n.noParsePullStreamUrl=e,n.parseUrl(e);var a=null==r?void 0:r.signalUrl;n.signalingUrl=a||n.signalingUrl,""===n.pullStreamUrl?o(new m.RtsError(l.ErrorCode.ERROR_PLAY_URL,"url need artc://","")):n.subscribeAudio||n.subscribeVideo?!t||"AUDIO"!==t.nodeName&&"VIDEO"!==t.nodeName?o(new m.RtsError(l.ErrorCode.ERROR_HTMLELEMENT_ERROR,"need htmlaudioelement or htmlvideoelement","")):(n.subscribeAudio&&n.subscribeVideo?"VIDEO"!==t.nodeName&&n.emit("onError",new m.RtsError(l.ErrorCode.ERROR_HEMLELEMENT_NOTMATCH,"need htmlvideoelement","")):n.subscribeAudio?"AUDIO"!==t.nodeName&&n.emit("onError",new m.RtsError(l.ErrorCode.ERROR_HEMLELEMENT_NOTMATCH,"need htmlaudioelement","")):"VIDEO"!==t.nodeName&&n.emit("onError",new m.RtsError(l.ErrorCode.ERROR_HEMLELEMENT_NOTMATCH,"need htmlvieoelement","")),n._cpstart=(new Date).getTime(),n.reporter.updateTid(),n.peerconnection.createOffer(n.subscribeAudio,n.subscribeVideo).then((function(e){var r=e.desp;n._cpend=(new Date).getTime(),n.excuteSignal(r).then((function(e){n.remoteStream.traceId=e,n._hrend=(new Date).getTime(),n.remoteStream.play(t),i(e)})).catch((function(e){n._hrend=(new Date).getTime(),n.reporter.reportFirstFrameTime(n.noParsePullStreamUrl,e?e.traceid:"",n._cpend-n._cpstart,n._hrend-n._cpend,-1,-1,n._cnend-n._hrend),o(new m.RtsError(e.errorCode?e.errorCode:l.ErrorCode.ERROR_HTTPREQUEST_ERROR,e.message,""))}))})).catch((function(e){n._cpend=(new Date).getTime(),n.reporter.reportFirstFrameTime(n.noParsePullStreamUrl,e?e.traceid:"",n._cpend-n._cpstart,-1,-1,-1,n._cnend-n._hrend),o(new m.RtsError(l.ErrorCode.ERROR_CREATEOFFER,e.message,""))}))):o(new m.RtsError(l.ErrorCode.ERROR_SUBSCRIBE_NOTHING,"subscribe nothing",""))}))},t.prototype.stopLiveStream=function(){this.unsubscribe()},t.prototype.muteLiveStream=function(e){return this.remoteStream.muted=e,!0},t.prototype.excuteSignal=function(e){var t=this;return new Promise((function(r,n){var i,o,a,s,c={url:t.pullStreamUrl,amsid:(null===(i=t.subscribeConfig)||void 0===i?void 0:i.aMsid)||["rts audio"],vmsid:(null===(o=t.subscribeConfig)||void 0===o?void 0:o.vMsid)||["rts video"]};t.subscribeAudio||delete c.amsid,t.subscribeVideo||delete c.vmsid,f.default.post(t.signalingUrl,{version:(null===(a=t.subscribeConfig)||void 0===a?void 0:a.signalVersion)||y.default.protocol_version,sdk_version:y.default.sdk_version,mode:(null===(s=t.subscribeConfig)||void 0===s?void 0:s.signalMode)||"live",pull_streams:[c],jsep:e}).then((function(i){var o,a,s,c;if(i&&200===i.status){t._hrend=(new Date).getTime();var u=null===(o=i.data)||void 0===o?void 0:o.trace_id;t.reporter.reportSubscribeOk({vurl:t.noParsePullStreamUrl,surl:t.signalingUrl,traceId:u,hrct:t._hrend-t._cpend,rslt:null===(a=i.data)||void 0===a?void 0:a.code}),t.peerconnection.recvAnswer(i.data,{answerSdpHook:null===(s=t.subscribeConfig)||void 0===s?void 0:s.answerSdpHook}).then((function(){r(u)})).catch((function(e){e.traceid=i.data?i.data.trace_id:"",n({errorCode:l.ErrorCode.ERROR_ANSWER_ERROR,message:e.message?e.message:"set answer error",traceid:e.traceid,sdp:e.sdp})}))}else n({message:i?"response status:"+i.status:"response is null",traceid:null===(c=null==i?void 0:i.data)||void 0===c?void 0:c.trace_id,sdp:e.sdp})})).catch((function(t){var r;[400,500].includes(null===(r=t.response)||void 0===r?void 0:r.status)&&(t.sdp=e.sdp),n(t)}))}))},t.prototype.parseUrl=function(e){if(void 0===e&&(e=""),0===e.indexOf("artc://")){var t=e.indexOf("@");if(t>-1){var r=e.substring(t+1,e.length);this.pullStreamUrl=e.substring(0,t);for(var n=r.split("&"),i=0;i<n.length;++i)"subaudio=no"===n[i]&&(this.subscribeAudio=!1),"subvideo=no"===n[i]&&(this.subscribeVideo=!1)}else this.pullStreamUrl=e;var o=window.location.protocol,a=(["http:","https:"].indexOf(o)>-1?o:"https:")+"//";this.signalingUrl=this.pullStreamUrl.replace("artc://",a)}},t.prototype.stopPlayTimer=function(){this.playTimer&&clearTimeout(this.playTimer),this.playTimer=0},t.prototype.calcStreamPullStats=function(e){var t={},r=e.video,n=e.audio;if(r){var i=r.transportStats,a=r.inboundRtpStats,s=r.inboundRtpStatsPerSec,c=r.localCandidate,u=r.remoteCandidate;t=o(o({},t),{rtt:-1!==(null==i?void 0:i.rtt)?1e3*((null==i?void 0:i.rtt)||0):-1,cand_re_prot:u.protocol,cand_lo_prot:c.protocol,cand_re_addr:"".concat(u.ip||u.address,":").concat(u.port),cand_lo_addr:"".concat(c.ip||c.address,":").concat(c.port),w:null==a?void 0:a.frameWidth,h:null==a?void 0:a.frameHeight,vbps:Math.floor(8*s.bytesReceivedPerSecond),fps:null==a?void 0:a.framesPerSecond,dfps:Math.floor(null==s?void 0:s.framesDecodedPerSecond),vjb:Math.floor((0,b.getJitterBufferDelayAvg)(null==a?void 0:a.jitterBufferDelay,null==a?void 0:a.jitterBufferEmittedCount)),vMsid:e.vMsid,vloss:s.packetsLostRate})}if(n){i=n.transportStats,a=n.inboundRtpStats,s=n.inboundRtpStatsPerSec,c=n.localCandidate,u=n.remoteCandidate;t=o(o({},t),{rtt:-1!==(null==i?void 0:i.rtt)?1e3*((null==i?void 0:i.rtt)||0):-1,cand_re_prot:u.protocol,cand_lo_prot:c.protocol,cand_re_addr:"".concat(u.ip||u.address,":").concat(u.port),cand_lo_addr:"".concat(c.ip||c.address,":").concat(c.port),abps:Math.floor(8*s.bytesReceivedPerSecond),ajb:Math.floor((0,b.getJitterBufferDelayAvg)(null==a?void 0:a.jitterBufferDelay,a.jitterBufferEmittedCount)),aMsid:e.aMsid,aloss:s.packetsLostRate})}return t=o(o({},t),{net_qual:(0,b.evaluateNetworkCondition)(t.rtt,t.aloss,t.vloss,t.ajb,t.vjb)})},t.prototype.doReportPullStats=function(e){var t=this.calcStreamPullStats(e),r={ct:1e3*this.playCatonIndex,tt:1e3*this.playTimeIndex,url:e.url};r.tt&&(r=o(o({},r),t),this.reporter.reportPullStats(r),this.lastMeidaEventData=void 0)},t.prototype.retrySubscribe=function(e){return this.hasRetries()?(this.emit("connectStatusChange",{status:p.EConnectStatus.CONNECT_STATUS_RECONNECTING}),this.subReconnectTimes++,e.extraInfo=o(o({},e.extraInfo),{retryTimes:this.subReconnectTimes}),this.subscribeWithReconnect(this.noParsePullStreamUrl,this.subscribeConfig).catch((function(e){})),!0):(e.extraInfo=o(o({},e.extraInfo),{retryTimes:this.subReconnectTimes}),!1)},t.prototype.subscribeWithReconnect=function(e,t,r,n){var i=this;return new Promise((function(a,s){a=r||a,s=n||s,i.isConnecting=!0,i.subscribe(e,t).then((function(e){i.isConnecting=!1,a(e)})).catch((function(r){var n;if(!i.isConnecting)return s(r);if(!l.SUB_RECONNECT_ERROR_EXCLUDE_LIST.includes(r.errorCode)&&i.hasRetries(!0)){var c=(null===(n=i.subscribeConfig)||void 0===n?void 0:n.retryInterval)||p.DEFAULT_RETRY_SUBSCRIBE_INTERVAL;i.reconnectTimerHandle=setTimeout((function(){r.extraInfo=o(o({},r.extraInfo),{retryTimes:i.subReconnectTimes}),i.emit("reconnect",r),i.subscribeWithReconnect(e,t,a,s)}),c)}else s(r),r.extraInfo=o(o({},r.extraInfo),{retryTimes:i.subReconnectTimes}),i.isConnecting=!1,i.emit("onError",r)}))}))},t.prototype.hasRetries=function(e){var t,r,n=p.DEFAULT_RETRY_SUBSCRIBE_LIMIT;"number"==typeof(null===(t=this.subscribeConfig)||void 0===t?void 0:t.retryTimes)&&(n=Math.floor(null===(r=this.subscribeConfig)||void 0===r?void 0:r.retryTimes));var i=this.subReconnectTimes<n;return e&&i&&this.subReconnectTimes++,i},t.prototype.resetResubscribeStatus=function(){this.subReconnectTimes=0,this.isConnecting=!1,this.reporter.updateTid(),null!==this.reconnectTimerHandle&&(clearTimeout(this.reconnectTimerHandle),this.reconnectTimerHandle=null)},t.prototype.handlePubMonitorEvent=function(e){var t=this;e.forEach((function(e){t.reporter.reportPushStats(e)}))},t}(h.default);t.Subscriber=_},function(e,t,r){"use strict";var n=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.SdpUtil=void 0;var i=r(3),o=function(){this.stramId="",this.audioTrackId="",this.videoTrackId="",this.screenTrackId="",this.customTrackId=""},a=function(){function e(e){this.sdpLines=new Array,this.localStream=e,this.publishStreamInfo=new o}return Object.defineProperty(e.prototype,"sdp",{get:function(){return this.sdpLines.join("\r\n")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"videoTrackId",{get:function(){return this.publishStreamInfo.videoTrackId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"screenTrackId",{get:function(){return this.publishStreamInfo.videoTrackId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"videoName",{get:function(){return"rts video"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"screenName",{get:function(){return"rts screen"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasTcpCandidate",{get:function(){return this.sdpLines.some((function(e){return-1!==e.indexOf("tcptype")}))},enumerable:!1,configurable:!0}),e.prototype.init=function(e){this.sdpLines=e.split("\r\n")},e.prototype.addNack=function(){for(var e=0;e<this.sdpLines.length;++e)if(-1!=this.sdpLines[e].indexOf("opus")&&-1!=this.sdpLines[e+1].indexOf("rtcp-fb")){var t=this.sdpLines[e+1].split(" ");2==t.length&&(-1!=this.sdpLines[e+2].indexOf("rtcp-fb")?this.sdpLines.splice(e+3,0,t[0]+" nack"):this.sdpLines.splice(e+2,0,t[0]+" nack"))}},e.prototype.parseCustomMsid=function(e){var t={stream:"",track:""};if(!e)return t;var r=e.trim().split(" ");return 2==r.length?(t.stream=r[0],t.track=r[1]):t.track=r[0],t},e.prototype.modifyTrackName=function(e){void 0===e&&(e={});var t=e.vMsid,r=e.aMsid,n=t?this.parseCustomMsid(t):{stream:"rts",track:"video"},o=r?this.parseCustomMsid(r):{stream:"rts",track:"audio"},a="";if(this.localStream){this.publishStreamInfo.stramId=this.localStream.mediaStream.id,this.localStream.audioTrack&&(this.publishStreamInfo.audioTrackId=this.localStream.audioTrack.id,a=o.stream||"-"),this.localStream.videoTrack&&(this.publishStreamInfo.videoTrackId=this.localStream.videoTrack.id,a=n.stream||"-");for(var s=!1,c=!1,u=0;u<this.sdpLines.length;++u){var d=this.sdpLines[u],p=d.indexOf(this.publishStreamInfo.stramId);this.publishStreamInfo.stramId&&-1!=p&&(this.sdpLines[u]=this.sdpLines[u].replace(this.publishStreamInfo.stramId,a),i.BrowserUtil.isFirefox&&(s?this.sdpLines[u]=this.sdpLines[u].substring(0,p+a.length+1)+o.track:c&&(this.sdpLines[u]=this.sdpLines[u].substring(0,p+a.length+1)+n.track))),this.publishStreamInfo.audioTrackId&&-1!=d.indexOf(this.publishStreamInfo.audioTrackId)?this.sdpLines[u]=this.sdpLines[u].replace(this.publishStreamInfo.audioTrackId,o.track):this.publishStreamInfo.videoTrackId&&-1!=d.indexOf(this.publishStreamInfo.videoTrackId)&&(this.sdpLines[u]=this.sdpLines[u].replace(this.publishStreamInfo.videoTrackId,n.track)),-1!=d.indexOf("m=audio")?(s=!0,c=!1):-1!=d.indexOf("m=video")&&(c=!0,s=!1),-1!=d.indexOf("a=ssrc")&&-1!==(p=d.indexOf("cname:"))&&(s?this.sdpLines[u]=d.substr(0,p+6)+o.track:c&&(this.sdpLines[u]=d.substr(0,p+6)+n.track))}}},e.prototype.getPublishVideoSdp=function(){for(var e=-1,t=-1,r=!1,n=0;n<this.sdpLines.length;++n){if(r&&this.sdpLines[n].indexOf("m=application")>-1){t=n-1;break}if(this.sdpLines[n].indexOf("m=video")>-1){if(r){t=n-1;break}e=n}this.sdpLines[n].indexOf("rts video")>-1&&(r=!0)}return r?(-1===t&&(t=this.sdpLines.length-1),this.sdpLines.splice(e,t-e).join("\r\n")):""},e.prototype.removeVideoTrack=function(e){for(var t="rts "+e,r=-1,n=-1,i=!1,o=0;o<this.sdpLines.length;++o){if(i&&this.sdpLines[o].indexOf("m=application")>-1){n=o-1;break}if(this.sdpLines[o].indexOf("m=video")>-1){if(i){n=o-1;break}r=o}this.sdpLines[o].indexOf(t)>-1&&(i=!0)}return!!i&&(-1===n&&(n=this.sdpLines.length-1),this.sdpLines.splice(r,n-r),!0)},e.prototype.ios15PushHack=function(){var e=!1,t=-1;if(this.sdpLines.forEach((function(r,n){r.includes("m=video")&&(e=!0),e&&-1===t&&r.includes("a=")&&(t=n)})),-1!==t){var r=this.getExtmapIds(),n=Math.max.apply(Math,r)+1;this.sdpLines.splice(t,0,"a=extmap:".concat(n," urn:3gpp:video-orientation"))}},e.prototype.addSps=function(){this.sdpLines=this.sdpLines.map((function(e){return e.includes("a=fmtp:")&&e.includes("level-asymmetry-allowed")?e+=";sps-pps-idr-in-keyframe=1":e}))},e.prototype.removeTwccRtcpFb=function(){this.sdpLines=this.sdpLines.filter((function(e){return!e.includes("http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01")}))},e.prototype.removeUdpCandidate=function(){this.sdpLines=this.sdpLines.filter((function(e){return!e.includes("a=candidate:")||!e.includes("UDP")}))},e.prototype.setDirection=function(e){void 0===e&&(e={direction:"recvonly"});var t=["sendonly","recvonly","sendrecv"].filter((function(t){return t!==e.direction})),r=!1,n=!1;this.sdpLines=this.sdpLines.map((function(i,o){if(i.includes("m=video"))r=!0,n=!1,!1;else if(i.includes("m=audio"))n=!0,r=!1,!1;else if(i.includes("m=application"))!0,r=!1,n=!1;else if(r||n){var a;if(t.some((function(e){if(i.includes(e))return a=e,!0}))&&a)return i.replace(a,e.direction)}return i}))},e.prototype.removeSDES=function(){var e=["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"];this.sdpLines=this.sdpLines.filter((function(t){return!e.some((function(e){return t.includes(e)}))}))},e.prototype.dispose=function(){this.localStream&&(this.localStream=void 0),this.sdpLines=new Array,this.publishStreamInfo=new o},e.prototype.getExtmapIds=function(){return this.sdpLines.reduce((function(e,t){if(t.includes("a=extmap")){var r=Number(t.replace("a=extmap:","").split(" ")[0]);return n(n([],e,!0),[r],!1)}return e}),[]).filter((function(e){return e}))},e}();t.SdpUtil=a},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},s=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SubMonitor=void 0;var u=r(41),d=r(42),p=c(r(2)),l=function(){function e(){this.trackPairDataList=[]}return e.prototype.reset=function(){this.trackPairDataList=[]},e.prototype.addTrackPair=function(e,t,r,n,i,o){var a=new u.AudioReceiverMonitorData,s=new d.VideoReceiverMonitorData;n&&(s.rtpReceiver=n),i&&(a.rtpReceiver=i),o&&(s.RTCPeerconnection=o,a.RTCPeerconnection=o),this.trackPairDataList.push({url:e,vMsid:t,aMsid:r,audioReceiverMonitorData:a,videoReceiverMonitorData:s})},e}(),f=function(e){function t(){var t=e.call(this)||this;return t.canplay=!1,t.pc=null,t.pcCore=null,t.monitorTimerId=null,t.audioReceiverMonitorData=new u.AudioReceiverMonitorData,t.videoReceiverMonitorData=new d.VideoReceiverMonitorData,t.receiverMonitorController=new l,t}return i(t,e),t.prototype.start=function(e,t){this.pc=e,this.pcCore=t,this.updateTranceiversController(),this.startMonitorTimer(200)},t.prototype.updateTranceiversController=function(){var e=this;if(this.pc&&this.pcCore){var t=this.pcCore.getStreamManager().getAllTrackPairList("sub");this.receiverMonitorController.reset(),t.forEach((function(t){t.url&&e.receiverMonitorController.addTrackPair(t.url,t.vMsid,t.aMsid,t.vTransceiver,t.aTransceiver,e.pc)})),this.receiverMonitorController.trackPairDataList.forEach((function(t){e.initEvent(t)}))}},t.prototype.resetTimer=function(e){this.updateTranceiversController(),this.stopMonitorTimer(),this.startMonitorTimer(e)},t.prototype.stop=function(){this.canplay=!1,this.stopMonitorTimer(),this.audioReceiverMonitorData.dispose(),this.videoReceiverMonitorData.dispose()},t.prototype.startMonitorTimer=function(e){var t=this;this.monitorTimerId||(this.monitorTimerId=window.setInterval((function(){t.onMonitorTimer()}),e))},t.prototype.stopMonitorTimer=function(){this.monitorTimerId&&clearInterval(this.monitorTimerId),this.monitorTimerId=null},t.prototype.onMonitorTimer=function(){return o(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return[4,this.updateMonitorData()];case 1:return t.sent(),e=[],this.receiverMonitorController.trackPairDataList.forEach((function(t){var r,n;if(t.url){var i={url:t.url};t.audioReceiverMonitorData.isExist&&(i.audio=null===(r=t.audioReceiverMonitorData)||void 0===r?void 0:r.monitorData,i.aMsid=t.aMsid),t.videoReceiverMonitorData.isExist&&(i.video=null===(n=t.videoReceiverMonitorData)||void 0===n?void 0:n.monitorData,i.vMsid=t.vMsid),e.push(i)}})),this.emit("onMonitorEvent",{eventList:e,type:"sub"}),[2]}}))}))},t.prototype.initEvent=function(e){var t=this,r={url:e.url||"url unknown",vMsid:e.vMsid||"vMsid unknown",aMsid:e.aMsid||"aMsid unknown"};e.audioReceiverMonitorData.isExist&&(e.audioReceiverMonitorData.on("streamEnded",(function(){e.videoReceiverMonitorData&&!e.videoReceiverMonitorData.isStreamEnded||(t.emit("streamEnded",r),t.stopMonitorTimer())})),e.audioReceiverMonitorData.on("canPlay",(function(){t.emitCanPlay()}))),e.videoReceiverMonitorData.isExist&&(e.videoReceiverMonitorData.on("streamEnded",(function(){e.audioReceiverMonitorData&&!e.audioReceiverMonitorData.isStreamEnded||(t.emit("streamEnded",r),t.stopMonitorTimer())})),e.videoReceiverMonitorData.on("canPlay",(function(){t.emitCanPlay()})))},t.prototype.updateMonitorData=function(){return Promise.all(this.receiverMonitorController.trackPairDataList.reduce((function(e,t){var r,n;return s(s([],e,!0),[null===(r=t.audioReceiverMonitorData)||void 0===r?void 0:r.getInfo(),null===(n=t.videoReceiverMonitorData)||void 0===n?void 0:n.getInfo()],!1)}),[]))},t.prototype.emitCanPlay=function(){this.canplay||(this.canplay=!0,this.emit("canPlay"))},t.prototype.copyMonitorData=function(){var e,t;(null===(t=null===(e=this.receiverMonitorController)||void 0===e?void 0:e.trackPairDataList)||void 0===t?void 0:t.length)&&(this.audioReceiverMonitorData=this.receiverMonitorController.trackPairDataList[0].audioReceiverMonitorData,this.videoReceiverMonitorData=this.receiverMonitorController.trackPairDataList[0].videoReceiverMonitorData)},t.prototype.getTransportStats=function(){return o(this,void 0,void 0,(function(){var e;return a(this,(function(t){switch(t.label){case 0:return[4,this.updateMonitorData()];case 1:return t.sent(),this.copyMonitorData(),e={},this.videoReceiverMonitorData.isExist?e=this.videoReceiverMonitorData.monitorData.transportStats:this.audioReceiverMonitorData.isExist&&(e=this.audioReceiverMonitorData.monitorData.transportStats),[2,e]}}))}))},t.prototype.getRemoteVideoStats=function(){return o(this,void 0,void 0,(function(){var e,t;return a(this,(function(r){switch(r.label){case 0:return[4,this.updateMonitorData()];case 1:return r.sent(),this.copyMonitorData(),e={},this.videoReceiverMonitorData.isExist&&(t=this.videoReceiverMonitorData.monitorData.inboundRtpStats,e={timestamp:Math.floor(t.timestamp||0),framesDecodedPerSecond:t.framesPerSecond,framesDecoded:t.framesDecoded,frameWidth:t.frameWidth,frameHeight:t.frameHeight,bytesReceived:t.bytesReceived,jitter:t.jitter,jitterBufferDelayAvg:Number(t.jitterBufferDelay)/Number(t.jitterBufferEmittedCount),packetsLost:t.packetsLost,packetsReceived:t.packetsReceived}),[2,e]}}))}))},t.prototype.getRemoteAudioStats=function(){return o(this,void 0,void 0,(function(){var e,t;return a(this,(function(r){switch(r.label){case 0:return[4,this.updateMonitorData()];case 1:return r.sent(),this.copyMonitorData(),e={},this.audioReceiverMonitorData.isExist&&(t=this.audioReceiverMonitorData.monitorData.inboundRtpStats,e={timestamp:Math.floor(t.timestamp||0),bytesReceived:t.bytesReceived,jitter:t.jitter,jitterBufferDelayAvg:Number(t.jitterBufferDelay)/Number(t.jitterBufferEmittedCount),packetsLost:t.packetsLost,packetsReceived:t.packetsReceived}),[2,e]}}))}))},t}(p.default);t.SubMonitor=f},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.AudioReceiverMonitorData=void 0;var o=r(18),a=function(e){function t(){return e.call(this,o.ReceiverMonitorType.AUDIO)||this}return i(t,e),t}(o.ReceiverMonitorData);t.AudioReceiverMonitorData=a},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.VideoReceiverMonitorData=void 0;var o=r(18),a=function(e){function t(){return e.call(this,o.ReceiverMonitorType.VIDEO)||this}return i(t,e),t}(o.ReceiverMonitorData);t.VideoReceiverMonitorData=a},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},a=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PubMonitor=void 0;var c=s(r(2)),u=r(44),d=function(e){function t(){var t=e.call(this)||this;return t.heartbeatHandle=null,t.pc=null,t.pcCore=null,t.senderMonitorDataList=[],t}return i(t,e),t.prototype.startHeartbeat=function(e,t,r){var n=this;this.pc=e,this.pcCore=t,this.updateSenders(),this.stopHeartbeat(),this.heartbeatHandle=setInterval((function(){n.emitHeartBeat()}),r||1e3)},t.prototype.stopHeartbeat=function(){null!==this.heartbeatHandle&&clearInterval(this.heartbeatHandle),this.heartbeatHandle=null},t.prototype.addTrackPair=function(e,t,r,n,i){var o=this;if(e){var a=new u.SenderMonitorData;if(t){a.videoSender=t;var s=t.transport;s&&(s.onstatechange=function(){var t,r,n,i;o.emit("onTransportStateEvent",{url:e,type:"pub",kind:"video",state:s.state,protocol:null===(i=null===(n=null===(r=null===(t=s.iceTransport)||void 0===t?void 0:t.getSelectedCandidatePair)||void 0===r?void 0:r.call(t))||void 0===n?void 0:n.local)||void 0===i?void 0:i.protocol})})}if(r){a.audioSender=r;var c=r.transport;c&&(c.onstatechange=function(){var t,r,n,i;o.emit("onTransportStateEvent",{url:e,type:"pub",kind:"audio",state:c.state,protocol:null===(i=null===(n=null===(r=null===(t=c.iceTransport)||void 0===t?void 0:t.getSelectedCandidatePair)||void 0===r?void 0:r.call(t))||void 0===n?void 0:n.local)||void 0===i?void 0:i.protocol})})}this.senderMonitorDataList.push({url:e,vMsid:n,aMsid:i,senderData:a})}},t.prototype.updateSenders=function(){var e,t=this,r=null===(e=this.pcCore)||void 0===e?void 0:e.getStreamManager().getAllTrackPairList("pub");this.senderMonitorDataList=[],null==r||r.forEach((function(e){t.addTrackPair(e.url,e.vTransceiver,e.aTransceiver,e.vMsid,e.aMsid)}))},t.prototype.emitHeartBeat=function(){var e=this;Promise.all(this.senderMonitorDataList.reduce((function(e,t){return a(a([],e,!0),[t.senderData.getInfo()],!1)}),[])).then((function(){})).catch((function(e){})).finally((function(){var t=e.senderMonitorDataList.map((function(e){return o(o({},e.senderData.monitorData),{url:e.url,vMsid:e.vMsid,aMsid:e.aMsid})}));e.emit("onMonitorEvent",{eventList:t,type:"pub"})}))},t}(c.default);t.PubMonitor=d},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SenderMonitorData=void 0;var n=r(19),i=function(){function e(){this._audiosender=null,this._videosender=null,this.timeStamp=0,this.curTimeStamp=0,this.audioBytesSent=0,this.curAudioBytesSent=0,this.videoBytesSent=0,this.curVideoBytesSent=0,this.audioRetransmittedBytesSent=0,this.curAudioRetransmittedBytesSent=0,this.videoRetransmiitedBytesSent=0,this.curVideoRetransmiitedBytesSent=0,this.framesSent=0,this.curFramesSent=0,this.framesEncoded=0,this.curFramesEncoded=0,this.rtt=0,this.localProtocol="",this.remoteProtocol="",this.localTransportAddr="",this.remoteTransportAddr="",this.frameHeight=0,this.frameWidth=0,this.efps=0,this.sfps=0,this.timeGap=0,this.abps=0,this.vbps=0,this.rt_abps=0,this.rt_vbps=0,this.stashedData={}}return Object.defineProperty(e.prototype,"videoSender",{set:function(e){this._videosender=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"audioSender",{set:function(e){this._audiosender=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"monitorData",{get:function(){return this.doCalc(),{tt:parseFloat(this.timeGap.toFixed(0)),rtt:this.rtt,cand_re_prot:this.remoteProtocol,cand_lo_prot:this.localProtocol,cand_re_addr:this.remoteTransportAddr,cand_lo_addr:this.localTransportAddr,w:this.frameWidth,h:this.frameHeight,efps:parseFloat(this.efps.toFixed(0)),fps:parseFloat(this.sfps.toFixed(0)),abps:parseFloat(this.abps.toFixed(0)),vbps:parseFloat(this.vbps.toFixed(0)),rt_abps:parseFloat(this.rt_abps.toFixed(0)),rt_vbps:parseFloat(this.rt_vbps.toFixed(0))}},enumerable:!1,configurable:!0}),e.prototype.doCalc=function(){0!==this.timeStamp&&(this.timeGap=this.curTimeStamp-this.timeStamp,this.timeGap>0&&(this.efps=1e3*(this.curFramesEncoded-this.framesEncoded)/this.timeGap,this.sfps=1e3*(this.curFramesSent-this.framesSent)/this.timeGap,this.abps=1e3*(this.curAudioBytesSent-this.audioBytesSent)/this.timeGap,this.vbps=1e3*(this.curVideoBytesSent-this.videoBytesSent)/this.timeGap,this.rt_abps=1e3*(this.curAudioRetransmittedBytesSent-this.audioRetransmittedBytesSent)/this.timeGap,this.rt_vbps=1e3*(this.curVideoRetransmiitedBytesSent-this.videoRetransmiitedBytesSent)/this.timeGap)),this.timeStamp=this.curTimeStamp,this.audioBytesSent=this.curAudioBytesSent,this.videoBytesSent=this.curVideoBytesSent,this.audioRetransmittedBytesSent=this.curAudioRetransmittedBytesSent,this.videoRetransmiitedBytesSent=this.curVideoRetransmiitedBytesSent,this.framesSent=this.curFramesSent,this.framesEncoded=this.curFramesEncoded},e.prototype.getInfo=function(){var e=this,t=new Promise((function(t,r){e._videosender&&e._videosender.getStats?e._videosender.getStats().then((function(r){r.forEach((function(t){if(t)switch(t.type){case n.RTCStatsType.CandidatePair:e.onCandidatePair(t);break;case n.RTCStatsType.OutboundRtp:e.onOutBoundRtp(t,"video");break;case n.RTCStatsType.RemoteCandidate:e.onRemoteCandidate(t);break;case n.RTCStatsType.LocalCandidate:e.onLocalCandidate(t)}})),t()})).catch((function(e){r(e)})):r("no video sender")})),r=new Promise((function(t,r){e._audiosender&&e._audiosender.getStats?e._audiosender.getStats().then((function(r){r.forEach((function(t){if(t)switch(t.type){case n.RTCStatsType.CandidatePair:e.onCandidatePair(t);break;case n.RTCStatsType.OutboundRtp:e.onOutBoundRtp(t,"audio");break;case n.RTCStatsType.RemoteCandidate:e.onRemoteCandidate(t);break;case n.RTCStatsType.LocalCandidate:e.onLocalCandidate(t)}})),t()})).catch((function(e){r(e)})):r("no audio sender")}));return Promise.all([t,r])},e.prototype.onCandidatePair=function(e){this.curTimeStamp=e.timestamp,this.rtt=e.currentRoundTripTime},e.prototype.onOutBoundRtp=function(e,t){this.curTimeStamp=e.timestamp,"video"===t?(this.curVideoBytesSent=e.bytesSent,this.curVideoRetransmiitedBytesSent=e.retransmittedBytesSent,this.curFramesEncoded=e.framesEncoded,this.curFramesSent=e.framesSent,this.frameWidth=e.frameWidth,this.frameHeight=e.frameHeight):"audio"===t&&(this.curAudioBytesSent=e.bytesSent,this.curAudioRetransmittedBytesSent=e.retransmittedBytesSent)},e.prototype.onRemoteCandidate=function(e){this.curTimeStamp=e.timestamp,this.remoteProtocol=e.protocol,this.remoteTransportAddr=(e.ip||e.address)+(e.port?":"+e.port.toFixed(0):"")},e.prototype.onLocalCandidate=function(e){this.curTimeStamp=e.timestamp,this.localProtocol=e.protocol,this.localTransportAddr=(e.ip||e.address)+(e.port?":"+e.port.toFixed(0):"")},e}();t.SenderMonitorData=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Datachannel=void 0;var n=function(){function e(e){this.pc=e,this.messageId=1,this.dataChannel=this.pc.createDataChannel("GRTNDataChannel"),this.dataChannel.onopen=function(e){},this.dataChannel.onmessage=function(e){e.data},this.dataChannel.onclose=function(e){},this.dataChannel.onerror=function(e){}}return e.prototype.addTrack=function(e,t){return new Promise((function(e,t){}))},e.prototype.removeTrack=function(e,t){return new Promise((function(e,t){}))},e.prototype.createPublishPacket=function(){var e={type:"pub",version:1,msg_id:this.messageId,streams:[]};return++this.messageId,e},e}();t.Datachannel=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createReceiverTransformStream=void 0;t.createReceiverTransformStream=function(e){return new TransformStream({transform:function(t,r){e.onFrame(t),r.enqueue(t)}})}},function(e,t,r){"use strict";function n(){return new Worker(r.p+"aliyun-rts-sdk.worker.js")}r.r(t),r.d(t,"default",(function(){return n}))},function(e,t,r){e.exports=r(49)},function(e,t,r){"use strict";var n=r(0),i=r(20),o=r(50),a=r(26);function s(e){var t=new o(e),r=i(o.prototype.request,t);return n.extend(r,o.prototype,t),n.extend(r,t),r}var c=s(r(13));c.Axios=o,c.create=function(e){return s(a(c.defaults,e))},c.Cancel=r(27),c.CancelToken=r(65),c.isCancel=r(25),c.all=function(e){return Promise.all(e)},c.spread=r(66),c.isAxiosError=r(67),e.exports=c,e.exports.default=c},function(e,t,r){"use strict";var n=r(0),i=r(21),o=r(51),a=r(52),s=r(26),c=r(63),u=c.validators;function d(e){this.defaults=e,this.interceptors={request:new o,response:new o}}d.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=s(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&c.assertOptions(t,{silentJSONParsing:u.transitional(u.boolean,"1.0.0"),forcedJSONParsing:u.transitional(u.boolean,"1.0.0"),clarifyTimeoutError:u.transitional(u.boolean,"1.0.0")},!1);var r=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))}));var i,o=[];if(this.interceptors.response.forEach((function(e){o.push(e.fulfilled,e.rejected)})),!n){var d=[a,void 0];for(Array.prototype.unshift.apply(d,r),d=d.concat(o),i=Promise.resolve(e);d.length;)i=i.then(d.shift(),d.shift());return i}for(var p=e;r.length;){var l=r.shift(),f=r.shift();try{p=l(p)}catch(e){f(e);break}}try{i=a(p)}catch(e){return Promise.reject(e)}for(;o.length;)i=i.then(o.shift(),o.shift());return i},d.prototype.getUri=function(e){return e=s(this.defaults,e),i(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){d.prototype[e]=function(t,r){return this.request(s(r||{},{method:e,url:t,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){d.prototype[e]=function(t,r,n){return this.request(s(n||{},{method:e,url:t,data:r}))}})),e.exports=d},function(e,t,r){"use strict";var n=r(0);function i(){this.handlers=[]}i.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},i.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},i.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=i},function(e,t,r){"use strict";var n=r(0),i=r(53),o=r(25),a=r(13);function s(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return s(e),e.headers=e.headers||{},e.data=i.call(e,e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||a.adapter)(e).then((function(t){return s(e),t.data=i.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return o(t)||(s(e),t&&t.response&&(t.response.data=i.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,r){"use strict";var n=r(0),i=r(13);e.exports=function(e,t,r){var o=this||i;return n.forEach(r,(function(r){e=r.call(o,e,t)})),e}},function(e,t){var r,n,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var c,u=[],d=!1,p=-1;function l(){d&&c&&(d=!1,c.length?u=c.concat(u):p=-1,u.length&&f())}function f(){if(!d){var e=s(l);d=!0;for(var t=u.length;t;){for(c=u,u=[];++p<t;)c&&c[p].run();p=-1,t=u.length}c=null,d=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function m(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new h(e,t)),1!==u.length||d||s(f)},h.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},function(e,t,r){"use strict";var n=r(24);e.exports=function(e,t,r){var i=r.config.validateStatus;r.status&&i&&!i(r.status)?t(n("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}},function(e,t,r){"use strict";var n=r(0);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,i,o,a){var s=[];s.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),n.isString(i)&&s.push("path="+i),n.isString(o)&&s.push("domain="+o),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,r){"use strict";var n=r(59),i=r(60);e.exports=function(e,t){return e&&!n(t)?i(e,t):t}},function(e,t,r){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,r){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,r){"use strict";var n=r(0),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,o,a={};return e?(n.forEach(e.split("\n"),(function(e){if(o=e.indexOf(":"),t=n.trim(e.substr(0,o)).toLowerCase(),r=n.trim(e.substr(o+1)),t){if(a[t]&&i.indexOf(t)>=0)return;a[t]="set-cookie"===t?(a[t]?a[t]:[]).concat([r]):a[t]?a[t]+", "+r:r}})),a):a}},function(e,t,r){"use strict";var n=r(0);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function i(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=i(window.location.href),function(t){var r=n.isString(t)?i(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},function(e,t,r){"use strict";var n=r(64),i={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){i[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var o={},a=n.version.split(".");function s(e,t){for(var r=t?t.split("."):a,n=e.split("."),i=0;i<3;i++){if(r[i]>n[i])return!0;if(r[i]<n[i])return!1}return!1}i.transitional=function(e,t,r){var i=t&&s(t);function a(e,t){return"[Axios v"+n.version+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,n,s){if(!1===e)throw new Error(a(n," has been removed in "+t));return i&&!o[n]&&(o[n]=!0,console.warn(a(n," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,n,s)}},e.exports={isOlderVersion:s,assertOptions:function(e,t,r){if("object"!=typeof e)throw new TypeError("options must be an object");for(var n=Object.keys(e),i=n.length;i-- >0;){var o=n[i],a=t[o];if(a){var s=e[o],c=void 0===s||a(s,o,e);if(!0!==c)throw new TypeError("option "+o+" must be "+c)}else if(!0!==r)throw Error("Unknown option "+o)}},validators:i}},function(e){e.exports=JSON.parse('{"name":"axios","version":"0.21.4","description":"Promise based HTTP client for the browser and node.js","main":"index.js","scripts":{"test":"grunt test","start":"node ./sandbox/server.js","build":"NODE_ENV=production grunt build","preversion":"npm test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json","postversion":"git push && git push --tags","examples":"node ./examples/server.js","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","fix":"eslint --fix lib/**/*.js"},"repository":{"type":"git","url":"https://github.com/axios/axios.git"},"keywords":["xhr","http","ajax","promise","node"],"author":"Matt Zabriskie","license":"MIT","bugs":{"url":"https://github.com/axios/axios/issues"},"homepage":"https://axios-http.com","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"jsdelivr":"dist/axios.min.js","unpkg":"dist/axios.min.js","typings":"./index.d.ts","dependencies":{"follow-redirects":"^1.14.0"},"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}],"__npminstall_done":true,"_from":"axios@0.21.4","_resolved":"https://registry.anpm.alibaba-inc.com/axios/-/axios-0.21.4.tgz"}')},function(e,t,r){"use strict";var n=r(27);function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.source=function(){var e;return{token:new i((function(t){e=t})),cancel:e}},e.exports=i},function(e,t,r){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,r){"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EN=void 0,function(e){e.MESSAGE_NOTSUPPORT_WEBRTC="not support webrtc",e.MESSAGE_BROWSER_NOTSUPPORT="browser not support",e.MESSAGE_BROWSER_VERSIONLOW="browser version too low",e.MESSAGE_NOTSUPPORT_H264="not support h264",e.MESSAGE_CREATEOFFER="create offer error"}(t.EN||(t.EN={}))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MediaObserver=void 0;var n=function(){function e(t){this.timeout=t.timeout||e.DEFAULT_TIMEOUT,this.handler=t.handler||function(){},this.watchTimer=null}return Object.defineProperty(e.prototype,"actTimeout",{get:function(){return this.timeout},enumerable:!1,configurable:!0}),e.prototype.check=function(e,t,r,n){var i=this;this.hasNoData(e)?this.watchTimer||(this.watchTimer=window.setTimeout((function(){i.handler(t,r,n)}),this.timeout)):this.watchTimer&&(clearTimeout(this.watchTimer),this.watchTimer=null)},e.prototype.hasNoData=function(e){return!e||(e.video?!(Number(e.video.bytesReceivedPerSecond)>0):!e.audio||!(Number(e.audio.bytesReceivedPerSecond)>0))},e.prototype.updateConfig=function(e){this.timeout=e.timeout||this.timeout,this.handler=e.handler||this.handler},e.prototype.reset=function(){this.watchTimer&&(clearTimeout(this.watchTimer),this.watchTimer=null)},e.prototype.dispose=function(){this.timeout=e.DEFAULT_TIMEOUT,this.handler=function(){},this.watchTimer&&(clearTimeout(this.watchTimer),this.watchTimer=null)},e.DEFAULT_TIMEOUT=6e3,e}();t.MediaObserver=n},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Publisher=void 0;var s=r(6),c=r(11),u=a(r(7)),d=r(1),p=r(4),l=a(r(2)),f=a(r(12)),h=r(8),m=function(e){function t(t){var r=e.call(this)||this;return r.publishStartTimeStamp=0,r.pubReconnectTimes=0,r.isConnecting=!1,r.reconnectTimerHandle=null,r.reportMonitorTimes=0,r.reportSubFlag=!1,r.reporter=t,r.peerconnection=new c.RtsPeerconnection,r.peerconnection.on("connectStatusChange",(function(e){e.status!==s.EConnectStatus.CONNECT_STATUS_DISCONNECTED&&e.status!==s.EConnectStatus.CONNECT_STATUS_RECONNECTING||!r.hasRetries()?r.emit("connectStatusChange",e):r.emit("onError",new p.RtsError(d.ErrorCode.ERROR_PC_DISCONNECTED,"PC disconnected",""))})),r.peerconnection.on("onMonitorEvent",(function(e){var t=e.eventList;"pub"===e.type?(r.reportMonitorTimes++,r.reportMonitorTimes%4==0&&(t.forEach((function(e){r.reporter.reportPushStats(e)})),r.reportSubFlag=!0,r.reportMonitorTimes=0)):"sub"===e.type&&r.reportSubFlag&&(r.handleSubMonitorEvent(t),r.reportSubFlag=!1)})),r.peerconnection.on("onTransportStateEvent",(function(e){var t;r.peerconnection.isReused||"closed"!==(null===(t=r.peerconnection.getPc())||void 0===t?void 0:t.connectionState)&&"closed"===e.state&&r.hasRetries()&&r.emit("onError",new p.RtsError(d.ErrorCode.ERROR_TRANSPORT_CLOSED,"Transport has been closed. ".concat(e.kind,"|").concat(e.type,"|").concat(e.url),"",{protocol:e.protocol}))})),r.signalingUrl="",r.publishUrl="",r.publishConfig={},r}return i(t,e),t.prototype.publish=function(e,t,r){var n=this;return new Promise((function(i,a){if(n.unpublish(),n.localStream=t,n.publishUrl=e,n.publishConfig=r||{},n.checkPublishUrl())if(null===t.audioTrack)a(new p.RtsError(d.ErrorCode.ERROR_PUBLISH_NOAUDIO,"publish need audiotrack",""));else{var s=null==r?void 0:r.signalUrl;n.signalingUrl=s||n.signalingUrl,n.publishStartTimeStamp=(new Date).getTime(),t.setReporter(n.reporter),n.peerconnection.createOffer(t.hasAudio,t.hasVideo||t.hasScreen,t,o(o({},r),{publishUrl:e})).then((function(e){var t=e.desp,o=e.publishTrackInfoList;n.publishTrackInfoList=o;var s=(new Date).getTime();n.reporter.reportStartPublish(n.publishUrl,n.signalingUrl),n.excuteSignal(t).then((function(e){var t=(new Date).getTime();n.peerconnection.recvAnswer(e.data,{answerSdpHook:null==r?void 0:r.answerSdpHook,tcpOnly:null==r?void 0:r.tcpOnly}).then((function(){n.reporter.reportPublishOk(n.publishUrl,n.signalingUrl,s-n.publishStartTimeStamp,t-s,(new Date).getTime()-t,e.data.trace_id),i(e.data.trace_id),n.pubReconnectTimes=0,n.peerconnection.pushStart()})).catch((function(t){t.traceid=e.data?e.data.trace_id:"";var r=new p.RtsError(t.errorCode||d.ErrorCode.ERROR_ANSWER_ERROR,t.message||"set answer error",t.traceid,{sdp:t.sdp});a(r)}))})).catch((function(e){var t=new p.RtsError(e.errorCode||d.ErrorCode.ERROR_HTTPREQUEST_ERROR,e.message||"","",{sdp:e.sdp});a(t)}))})).catch((function(e){var t=new p.RtsError(e.errorCode||d.ErrorCode.ERROR_CREATEOFFER,e.message||"","");a(t)}))}else a(new p.RtsError(d.ErrorCode.ERROR_PUBLISH_URL,"url need artc://",""))}))},t.prototype.unpublish=function(){this.peerconnection.dispose(),this.reporter.reportStopPublish(),this.signalingUrl="",this.publishUrl="",this.publishTrackInfoList=null},t.prototype.getTrackInfoList=function(){return this.publishTrackInfoList||[]},t.prototype.getPeerConnection=function(){return this.peerconnection},t.prototype.replaceTrack=function(e,t){return this.peerconnection.replaceTrack(this.publishUrl,e,t)},t.prototype.excuteSignal=function(e){var t=this,r={type:e.type,sdp:e.sdp};return this.isSingleMsid()&&(r.sdp=r.sdp.replace(/msid\:-? /g,"msid:")),new Promise((function(n,i){f.default.post(t.signalingUrl,{version:u.default.protocol_version,sdk_version:u.default.sdk_version,mode:"rtc",push_stream:t.publishUrl,jsep:r}).then((function(e){e&&200===e.status?n(e):i({message:e?"response status:"+e.status:"response is null",sdp:r.sdp})})).catch((function(t){var r;[400,500].includes(null===(r=t.response)||void 0===r?void 0:r.status)&&(t.sdp=e.sdp),i(t)}))}))},t.prototype.checkPublishUrl=function(){if(!this.publishUrl)return!1;if(0!==this.publishUrl.indexOf("artc://"))return!1;var e=window.location.protocol,t=(["http:","https:"].indexOf(e)>-1?e:"https:")+"//";return this.signalingUrl=this.publishUrl.replace("artc://",t),!0},t.prototype.isSingleMsid=function(){if(!this.publishConfig)return!1;var e=this.publishConfig,t=e.vMsid,r=e.aMsid;return!(!t||!t[0]||-1!==t[0].indexOf(" "))||!(!r||!r[0]||-1!==r[0].indexOf(" "))},t.prototype.retryPublish=function(e,t){return this.hasRetries()&&this.localStream?(this.emit("connectStatusChange",{status:s.EConnectStatus.CONNECT_STATUS_RECONNECTING}),this.pubReconnectTimes++,e.extraInfo=o(o({},e.extraInfo),{retryTimes:this.pubReconnectTimes,tcpOnly:!!t}),this.publishWithReconnect(this.publishUrl,this.localStream,o(o({},this.publishConfig),{tcpOnly:!!t})).catch((function(e){})),!0):(e.extraInfo=o(o({},e.extraInfo),{retryTimes:this.pubReconnectTimes}),!1)},t.prototype.publishWithReconnect=function(e,t,r,n,i){var a=this;return new Promise((function(c,u){c=n||c,u=i||u,a.isConnecting=!0,a.publish(e,t,r).then((function(e){a.isConnecting=!1,c(e)})).catch((function(n){var i;if(!a.isConnecting)return u(n);if(a.hasRetries(!0)){var d=(null===(i=a.publishConfig)||void 0===i?void 0:i.retryInterval)||s.DEFAULT_RETRY_PUBLISH_INTERVAL;a.reconnectTimerHandle=setTimeout((function(){n.extraInfo=o(o({},n.extraInfo),{retryTimes:a.pubReconnectTimes}),a.emit("reconnect",n),a.publishWithReconnect(e,t,r,c,u)}),d)}else u(n),n.extraInfo=o(o({},n.extraInfo),{retryTimes:a.pubReconnectTimes}),a.isConnecting=!1,a.emit("onError",n)}))}))},t.prototype.hasRetries=function(e){var t,r,n=s.DEFAULT_RETRY_PUBLISH_LIMIT;"number"==typeof(null===(t=this.publishConfig)||void 0===t?void 0:t.retryTimes)&&(n=Math.floor(null===(r=this.publishConfig)||void 0===r?void 0:r.retryTimes));var i=this.pubReconnectTimes<n;return e&&i&&this.pubReconnectTimes++,i},t.prototype.resetRepublishStatus=function(){this.pubReconnectTimes=0,this.isConnecting=!1,this.reporter.updateTid(),null!==this.reconnectTimerHandle&&(clearTimeout(this.reconnectTimerHandle),this.reconnectTimerHandle=null)},t.prototype.handleSubMonitorEvent=function(e){var t=this;e.forEach((function(e){var r={ct:0,tt:4e3,url:e.url},n=e.video,i=e.audio;if(n){var a=n.transportStats,s=n.inboundRtpStats,c=n.inboundRtpStatsPerSec,u=n.localCandidate,d=n.remoteCandidate;r=o(o({},r),{rtt:-1!==(null==a?void 0:a.rtt)?1e3*((null==a?void 0:a.rtt)||0):-1,cand_re_prot:d.protocol,cand_lo_prot:u.protocol,cand_re_addr:"".concat(d.ip||d.address,":").concat(d.port),cand_lo_addr:"".concat(u.ip||u.address,":").concat(u.port),w:null==s?void 0:s.frameWidth,h:null==s?void 0:s.frameHeight,vbps:Math.floor(8*c.bytesReceivedPerSecond),fps:null==s?void 0:s.framesPerSecond,dfps:Math.floor(null==c?void 0:c.framesDecodedPerSecond),vjb:Math.floor((0,h.getJitterBufferDelayAvg)(null==s?void 0:s.jitterBufferDelay,null==s?void 0:s.jitterBufferEmittedCount)),vMsid:e.vMsid})}if(i){a=i.transportStats,s=i.inboundRtpStats,c=i.inboundRtpStatsPerSec,u=i.localCandidate,d=i.remoteCandidate;r=o(o({},r),{rtt:-1!==(null==a?void 0:a.rtt)?1e3*((null==a?void 0:a.rtt)||0):-1,cand_re_prot:d.protocol,cand_lo_prot:u.protocol,cand_re_addr:"".concat(d.ip||d.address,":").concat(d.port),cand_lo_addr:"".concat(u.ip||u.address,":").concat(u.port),abps:Math.floor(8*c.bytesReceivedPerSecond),ajb:Math.floor((0,h.getJitterBufferDelayAvg)(null==s?void 0:s.jitterBufferDelay,s.jitterBufferEmittedCount)),aMsid:e.aMsid})}t.reporter.reportPullStats(r)}))},t}(l.default);t.Publisher=m},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CommonController=void 0;var c=r(29),u=s(r(2)),d=r(4),p=r(1),l=r(28),f=r(72),h=r(9),m=function(e){function t(t){var r=e.call(this)||this;return r.datachannelList=new v,r.reporter=t,r.signalChannel=new f.SignalChannel(t),r.proxySignalChannelEvents(),r}return i(t,e),t.prototype.setPeerconnection=function(e){var t=this;this.peerconnection||(this.peerconnection=e,this.peerconnection.on("datachannelStatusChange",(function(e){t.emit("datachannelStatusChange",e)})))},Object.defineProperty(t.prototype,"peerCore",{get:function(){var e;return null===(e=this.peerconnection)||void 0===e?void 0:e.getPeerCore()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"streamManager",{get:function(){var e;return null===(e=this.peerCore)||void 0===e?void 0:e.getStreamManager()},enumerable:!1,configurable:!0}),t.prototype.subscribeAdd=function(e){var t;return o(this,void 0,void 0,(function(){var r,n,i,o,s,u,f,h=this;return a(this,(function(a){switch(a.label){case 0:if(e.forEach((function(e){var t;null===(t=h.reporter)||void 0===t||t.reportSubscribeStart(e.url,"",e.vMsid,e.aMsid,!0)})),!this.peerconnection)throw this.makeRtsError("subscribeAdd");this.peerconnection.isReused=!0,r=(new Date).getTime(),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.peerconnection.subAdd(e)];case 2:if(!(n=a.sent()).streamList)throw new d.RtsError(p.ErrorCode.ERROR_SUBADD_NO_RESULT,"subAdd streamList not found","",{api:"subscribeAdd",configList:e,response:n});return[3,4];case 3:throw i=a.sent(),o=i,null===(t=this.reporter)||void 0===t||t.reportErrorInfo(o.errorCode,o.message,o.traceId,o.extraInfo),o;case 4:return s=n.deleteRspTime-r,u=n.subAddRspTime-n.deleteRspTime,f=n.activeRspTime-n.subAddRspTime,n.streamList.forEach((function(t,n){var i,o,a;null===(i=h.reporter)||void 0===i||i.reportSubscribeOk({vurl:t.url||void 0,isSubAdd:!0});var d,p=e[n]||{},m=p.targetStream,v=p.vMsid,E=p.aMsid,R=t.stream;if(m)return m.mergeStream(R),void(t.stream=m);var y=null===(o=h.streamManager)||void 0===o?void 0:o.getStreamByMsid({url:t.url,vMsid:null==v?void 0:v[0],aMsid:null==E?void 0:E[0]});if(y)y.mergeStream(R),d=y;else{(d=new c.RemoteStream).updateMediaStream(R),null===(a=h.streamManager)||void 0===a||a.update(t.url,{stream:d,vMsid:null==v?void 0:v[0],aMsid:null==E?void 0:E[0]}),d.on("onCanPlay",(function(){var e,n,i=(new Date).getTime();null===(e=h.reporter)||void 0===e||e.reportFirstFrameTime(t.url,t.traceId,-1,-1,i-r,0,-1,{},s,u,f,v,E,!0),null===(n=h.peerconnection)||void 0===n||n.playStart()}));var g=new l.PlayEvent(l.PlayType.PLAY_CANPLAY);g.data={url:t.url,vMsid:(null==v?void 0:v[0])||"vMsid unknown",aMsid:(null==E?void 0:E[0])||"aMsid unknown"},h.emit("onPlayEvent",g)}t.stream=d})),[2,n.streamList]}}))}))},t.prototype.subscribeActive=function(e){var t;return o(this,void 0,void 0,(function(){return a(this,(function(r){if(!this.peerconnection)throw this.makeRtsError("subscribeActive");return[2,null===(t=this.peerconnection)||void 0===t?void 0:t.subActive(e)]}))}))},t.prototype.subscribeStop=function(e){var t;return o(this,void 0,void 0,(function(){var r,n,i;return a(this,(function(o){switch(o.label){case 0:if(!this.peerconnection)throw this.makeRtsError("subscribeStop");o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.peerconnection.subStop(e)];case 2:return r=o.sent(),this.peerconnection.getSubMonitor().updateTranceiversController(),[3,4];case 3:throw n=o.sent(),i=n,null===(t=this.reporter)||void 0===t||t.reportErrorInfo(i.errorCode,i.message,i.traceId,i.extraInfo),n;case 4:return[2,r]}}))}))},t.prototype.subscribeDeleteTracks=function(e){var t;return o(this,void 0,void 0,(function(){var r,n,i;return a(this,(function(o){switch(o.label){case 0:if(!this.peerconnection)throw this.makeRtsError("subscribeDeleteTracks");o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.peerconnection.subDeleteTracks(e)];case 2:if(!(r=o.sent()))throw this.makeRtsError("subscribeDeleteTracks");return this.peerconnection.getSubMonitor().updateTranceiversController(),[3,4];case 3:throw n=o.sent(),i=n,null===(t=this.reporter)||void 0===t||t.reportErrorInfo(i.errorCode,i.message,i.traceId,i.extraInfo),n;case 4:return[2,r]}}))}))},t.prototype.publishAdd=function(e){var t,r,n,i;return o(this,void 0,void 0,(function(){var o,s,c,u,l,f,h,m=this;return a(this,(function(a){switch(a.label){case 0:if(e.forEach((function(e){var t;null===(t=m.reporter)||void 0===t||t.reportStartPublish(e.url,"",!0)})),o=(new Date).getTime(),!this.peerconnection)throw this.makeRtsError("publishAdd");a.label=1;case 1:return a.trys.push([1,3,,4]),[4,null===(t=this.peerconnection)||void 0===t?void 0:t.pubAdd(e)];case 2:if(!(s=a.sent()))throw new d.RtsError(p.ErrorCode.ERROR_PUBADD_NO_RESULT,"pubAdd streamList not found","",{api:"publishAdd",publishInfoList:e});return[3,4];case 3:throw c=a.sent(),u=c,null===(r=this.reporter)||void 0===r||r.reportErrorInfo(u.errorCode,u.message,u.traceId,u.extraInfo),u;case 4:return this.peerconnection.isReused=!0,l=(new Date).getTime(),f=l-o,s.forEach((function(e){var t;null===(t=m.reporter)||void 0===t||t.reportPublishOk(e.url||"","",-1,-1,-1,e.traceId||"",f,!0)})),(h=null===(n=this.peerconnection)||void 0===n?void 0:n.getPc())&&(e.forEach((function(e){m.peerconnection&&e.stream.setEncodeParam(h)})),this.peerCore&&(null===(i=this.peerconnection)||void 0===i||i.getPubMonitor().startHeartbeat(h,this.peerCore))),[2,s]}}))}))},t.prototype.publishDeleteTracks=function(e){var t;return o(this,void 0,void 0,(function(){var r,n,i;return a(this,(function(o){switch(o.label){case 0:if(!this.peerconnection)throw this.makeRtsError("publishDeleteTracks");o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.peerconnection.pubDeleteTracks(e)];case 2:if(!(r=o.sent()))throw this.makeRtsError("publishDeleteTracks");return this.peerconnection.getPubMonitor().updateSenders(),[3,4];case 3:throw n=o.sent(),i=n,null===(t=this.reporter)||void 0===t||t.reportErrorInfo(i.errorCode,i.message,i.traceId,i.extraInfo),n;case 4:return[2,r]}}))}))},t.prototype.publishReplaceTracks=function(e){var t;return o(this,void 0,void 0,(function(){var r,n,i;return a(this,(function(o){switch(o.label){case 0:if(!this.peerconnection)throw this.makeRtsError("publishReplaceTracks");o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.peerconnection.pubReplaceTracks(e)];case 2:if(!(r=o.sent()))throw this.makeRtsError("publishReplaceTracks");return this.peerconnection.getPubMonitor().updateSenders(),[3,4];case 3:throw n=o.sent(),i=n,null===(t=this.reporter)||void 0===t||t.reportErrorInfo(i.errorCode,i.message,i.traceId,i.extraInfo),n;case 4:return[2,r]}}))}))},t.prototype.publishStop=function(e){var t;return o(this,void 0,void 0,(function(){var r,n,i,o=this;return a(this,(function(a){switch(a.label){case 0:if(e.forEach((function(e){var t;null===(t=o.reporter)||void 0===t||t.reportStopPublish(e.url,!0)})),!this.peerconnection)throw this.makeRtsError("publishStop");a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.peerconnection.pubStop(e)];case 2:return r=a.sent(),this.peerconnection.getPubMonitor().updateSenders(),[3,4];case 3:throw n=a.sent(),i=n,null===(t=this.reporter)||void 0===t||t.reportErrorInfo(i.errorCode,i.message,i.traceId,i.extraInfo),n;case 4:return[2,r]}}))}))},t.prototype.subscribeAddDatachannel=function(e){var t,r,n,i;return o(this,void 0,void 0,(function(){var s,c,u,l,f=this;return a(this,(function(m){switch(m.label){case 0:if(!e.url||!e.signalUrl||!e.msid)throw s=new d.RtsError(p.ErrorCode.ERROR_DATACHANNEL_PARAM,"url, signalUrl, msid is required by subscribeAddDatachannel",""),null===(t=this.reporter)||void 0===t||t.reportErrorInfo(s.errorCode,s.message,s.traceId,s.extraInfo),s;if(this.signalChannel.isOpen)return[3,2];if(console.warn("Creating a new signal channel"),!e.signalUrl)throw s=new d.RtsError(p.ErrorCode.ERROR_SIGNAL_URL,"signal url is required",""),null===(r=this.reporter)||void 0===r||r.reportErrorInfo(s.errorCode,s.message,s.traceId,s.extraInfo),s;return[4,this.initSignalChannel(e.signalUrl)];case 1:m.sent(),m.label=2;case 2:if(c=performance.now(),null===(n=this.reporter)||void 0===n||n.reportDatachannelSubAdd({url:e.url,label:e.label,surl:e.signalUrl,msid:e.msid}),!(u=null===(i=this.peerconnection)||void 0===i?void 0:i.getPc()))throw new Error("No avaliable peerconnection");return l=new h.DataChannelCore({pc:u,label:e.label,datachannelList:this.datachannelList.list}),this.datachannelList.update(l),[2,new Promise((function(t,r){return o(f,void 0,void 0,(function(){var n,i,o,s,u,d,p,f,m,v=this;return a(this,(function(a){switch(a.label){case 0:n="",i=!1,o=!1,l.on("statusChange",(function(r){var a;null===(a=v.reporter)||void 0===a||a.reportDatachannelStatusChange({state:h.EDatachannelStatus[r],url:e.url,label:l.label,id:l.id,msid:e.msid}),r===h.EDatachannelStatus.DATACHANNEL_STATUS_OPEN&&(i=!0,o&&t({datachannel:l,traceId:n}))})),l.on("dispose",(function(){var t;null===(t=v.reporter)||void 0===t||t.reportDatachannelDispose({url:e.url,label:l.label,id:l.id,msid:e.msid})})),s=null===(p=this.peerCore)||void 0===p?void 0:p.getSignal(),a.label=1;case 1:return a.trys.push([1,4,,5]),[4,null==s?void 0:s.subscribeAddDatachannel([{url:e.url,msid:e.msid}])];case 2:return a.sent(),[4,null==s?void 0:s.subscribeActiveDatachannel([{url:e.url,datachannelId:l.id,msid:e.msid}])];case 3:return u=a.sent(),n=null===(f=null==u?void 0:u.streams)||void 0===f?void 0:f[0].traceid,null===(m=this.reporter)||void 0===m||m.reportDatachannelSubAddOk({url:e.url,drct:Math.floor(performance.now()-c),tcid:n,label:l.label,id:l.id,msid:e.msid}),o=!0,i&&t({datachannel:l,traceId:n}),[3,5];case 4:return d=a.sent(),r(d),[3,5];case 5:return[2]}}))}))}))]}}))}))},t.prototype.subscribeStopDatachannel=function(e){var t,r,n,i,s;return o(this,void 0,void 0,(function(){var o,c;return a(this,(function(a){switch(a.label){case 0:if(!e.url||!e.datachannel)throw o=new d.RtsError(p.ErrorCode.ERROR_DATACHANNEL_PARAM,"url, datachannel is required by subscribeStopDatachannel",""),null===(t=this.reporter)||void 0===t||t.reportErrorInfo(o.errorCode,o.message,o.traceId,o.extraInfo),o;if(!this.signalChannel.isOpen)throw o=new d.RtsError(p.ErrorCode.ERROR_NO_DATACHANNEL,"Signal channel is closed",""),null===(r=this.reporter)||void 0===r||r.reportErrorInfo(o.errorCode,o.message,o.traceId,o.extraInfo),o;c=null===(n=this.peerCore)||void 0===n?void 0:n.getSignal(),null===(i=this.reporter)||void 0===i||i.reportDatachannelSubStop({url:e.url,label:e.datachannel.label,id:e.datachannel.id}),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,null==c?void 0:c.subscribeStopDatachannel([{url:e.url}])];case 2:return a.sent(),[3,4];case 3:throw a.sent();case 4:return null===(s=this.reporter)||void 0===s||s.reportDatachannelSubStopOk({url:e.url,label:e.datachannel.label,id:e.datachannel.id}),e.datachannel.dispose(),[2]}}))}))},t.prototype.getSubscribeVideoStats=function(e,t){return this.getSubscribeMediaStats(e,"video",t)},t.prototype.getSubscribeAudioStats=function(e,t){return this.getSubscribeMediaStats(e,"audio",t)},t.prototype.getPublishVideoStats=function(e,t){return this.getPublishMediaStats(e,"video",t)},t.prototype.getPublishAudioStats=function(e,t){return this.getPublishMediaStats(e,"audio",t)},t.prototype.getSubscribeMediaStats=function(e,t,r){var n=this;return new Promise((function(i){return o(n,void 0,void 0,(function(){var n,o,s,c;return a(this,(function(a){switch(a.label){case 0:return this.streamManager?(n=void 0,o=this.streamManager.getAllMediaInfoList(e,!0),r?o.forEach((function(e){var i,o,a,s=null===(o=null===(i=e.transceiver)||void 0===i?void 0:i.receiver)||void 0===o?void 0:o.track;(null==s?void 0:s.kind)===t&&e.msid===r&&(n=null===(a=e.transceiver)||void 0===a?void 0:a.receiver)})):n=null===(c=null===(s=null==o?void 0:o.find((function(e){var r,n,i;return(null===(i=null===(n=null===(r=e.transceiver)||void 0===r?void 0:r.receiver)||void 0===n?void 0:n.track)||void 0===i?void 0:i.kind)===t})))||void 0===s?void 0:s.transceiver)||void 0===c?void 0:c.receiver,n?[4,n.getStats()]:[2,i({})]):[2,i({})];case 1:return a.sent().forEach((function(e){"inbound-rtp"===e.type&&i(e)})),[2]}}))}))}))},t.prototype.getPublishMediaStats=function(e,t,r){var n=this;return new Promise((function(i){return o(n,void 0,void 0,(function(){var n,o,s,c;return a(this,(function(a){switch(a.label){case 0:return this.streamManager?(n=void 0,o=this.streamManager.getAllMediaInfoList(e,!0),r?o.forEach((function(e){var i,o,a,s=null===(o=null===(i=e.transceiver)||void 0===i?void 0:i.sender)||void 0===o?void 0:o.track;(null==s?void 0:s.kind)===t&&e.msid===r&&(n=null===(a=e.transceiver)||void 0===a?void 0:a.sender)})):n=null===(c=null===(s=null==o?void 0:o.find((function(e){var r,n,i;return(null===(i=null===(n=null===(r=e.transceiver)||void 0===r?void 0:r.sender)||void 0===n?void 0:n.track)||void 0===i?void 0:i.kind)===t})))||void 0===s?void 0:s.transceiver)||void 0===c?void 0:c.sender,n?[4,n.getStats()]:[2,i({})]):[2,i({})];case 1:return a.sent().forEach((function(e){"outbound-rtp"===e.type&&i(e)})),[2]}}))}))}))},t.prototype.proxySignalChannelEvents=function(){var e=this;this.signalChannel.on("connectStatusChange",(function(t){e.emit("connectStatusChange",t)})),this.signalChannel.on("onError",(function(t){e.emit("onError",t)}))},t.prototype.initSignalChannel=function(e){return this.setPeerconnection(this.signalChannel.getPeerConnection()),this.signalChannel.createDatachannel(e)},t.prototype.makeRtsError=function(e){var t,r=new d.RtsError(p.ErrorCode.ERROR_NO_DATACHANNEL,"No avaliable datachannel, you should subscribe/publish first.","",{api:e});return null===(t=this.reporter)||void 0===t||t.reportErrorInfo(r.errorCode,r.message,r.traceId,r.extraInfo),r},t}(u.default);t.CommonController=m;var v=function(){function e(){this._list=[]}return Object.defineProperty(e.prototype,"list",{get:function(){return this._list},enumerable:!1,configurable:!0}),e.prototype.update=function(e){var t=this._list.findIndex((function(t){return t.id===e.id}));-1!==t?this._list.splice(t,1,e):this._list.push(e)},e}()},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SignalChannel=void 0;var c=s(r(7)),u=r(11),d=s(r(2)),p=s(r(12)),l=r(1),f=r(4),h=r(9),m=function(e){function t(t){var r=e.call(this)||this;return r.reporter=t,r.peerconnection=new u.RtsPeerconnection,r.peerconnection.on("connectStatusChange",(function(e){r.emit("connectStatusChange",e)})),r}return i(t,e),Object.defineProperty(t.prototype,"isOpen",{get:function(){return"open"===this.readyState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"readyState",{get:function(){var e,t;return this.peerconnection.isConnected&&(null===(t=null===(e=this.peerconnection.getPeerCore())||void 0===e?void 0:e.getSignal())||void 0===t?void 0:t.getDatachannelCore().readyState)},enumerable:!1,configurable:!0}),t.prototype.getPeerConnection=function(){return this.peerconnection},t.prototype.createDatachannel=function(e){var t;return o(this,void 0,void 0,(function(){var r,n,i,o,s,c,u,d;return a(this,(function(a){switch(a.label){case 0:if(!this.checkUrl(e))throw new f.RtsError(l.ErrorCode.ERROR_DATACHANNEL_PARAM,"url need artc://","");this.closeDatachannel(),this.reporter.updateUrl(e),this.reporter.reportDatachannelHttpConnect(e),r=performance.now(),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.peerconnection.createOffer(!1,!1)];case 2:return n=a.sent(),[3,4];case 3:return i=a.sent(),this.throwRtsError(new f.RtsError(i.errorCode||l.ErrorCode.ERROR_CREATEOFFER,i.message||"","")),[3,4];case 4:s="",a.label=5;case 5:return a.trys.push([5,7,,8]),[4,this.excuteSignal(n.desp)];case 6:return o=a.sent(),s=(null===(t=null==o?void 0:o.data)||void 0===t?void 0:t.trace_id)||"",this.reporter.reportDatachannelHttpConnectOk({url:e,hrct:Math.floor(performance.now()-r),tcid:s}),[3,8];case 7:return c=a.sent(),this.throwRtsError(new f.RtsError(c.errorCode||l.ErrorCode.ERROR_HTTPREQUEST_ERROR,c.message||"",s)),[3,8];case 8:return a.trys.push([8,10,,11]),[4,this.peerconnection.recvAnswer(null==o?void 0:o.data)];case 9:return a.sent(),[3,11];case 10:return u=a.sent(),this.throwRtsError(new f.RtsError(u.errorCode||l.ErrorCode.ERROR_ANSWER_ERROR,u.message||"set answer error",s)),[3,11];case 11:return a.trys.push([11,13,,14]),[4,this.waitForOpen()];case 12:return a.sent(),[3,14];case 13:return d=a.sent(),this.throwRtsError(new f.RtsError(l.ErrorCode.ERROR_DATACHANNEL_OPEN,"datachannel open failed: ".concat(d),s)),[3,14];case 14:return[2,s]}}))}))},t.prototype.waitForOpen=function(){var e,t=this;return new Promise((function(r,n){e=window.setTimeout((function(){t.peerconnection.off("datachannelStatusChange",i),e=void 0,n("timeout")}),5e3);var i=function(t){e&&(clearTimeout(e),e=void 0),t.status===h.EDatachannelStatus.DATACHANNEL_STATUS_OPEN?r(!0):n("status is ".concat(t.status))};t.peerconnection.once("datachannelStatusChange",i)}))},t.prototype.excuteSignal=function(e){return o(this,void 0,void 0,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return[4,p.default.post(this.signalUrl,{version:c.default.protocol_version,sdk_version:c.default.sdk_version,mode:"live",jsep:e})];case 1:if(200!==(null==(t=r.sent())?void 0:t.status))throw new f.RtsError(l.ErrorCode.ERROR_SIGNAL_ERROR,t?"response status:"+t.status:"response is null","");return[2,t]}}))}))},t.prototype.closeDatachannel=function(){this.peerconnection.dispose()},t.prototype.checkUrl=function(e){if(e&&0===e.indexOf("artc://")){var t=window.location.protocol,r=(["http:","https:"].indexOf(t)>-1?t:"https:")+"//";return this.signalUrl=e.replace("artc://",r),!0}},t.prototype.throwRtsError=function(e){throw this.emit("onError",e),e},t}(d.default);t.SignalChannel=m},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},function(e,t,r){"use strict";r.r(t);var n={};r.r(n),r.d(n,"shimGetUserMedia",(function(){return g})),r.d(n,"shimGetDisplayMedia",(function(){return S})),r.d(n,"shimMediaStream",(function(){return b})),r.d(n,"shimOnTrack",(function(){return _})),r.d(n,"shimGetSendersWithDtmf",(function(){return T})),r.d(n,"shimGetStats",(function(){return C})),r.d(n,"shimSenderReceiverGetStats",(function(){return O})),r.d(n,"shimAddTrackRemoveTrackWithNative",(function(){return w})),r.d(n,"shimAddTrackRemoveTrack",(function(){return P})),r.d(n,"shimPeerConnection",(function(){return D})),r.d(n,"fixNegotiationNeeded",(function(){return M}));var i={};r.r(i),r.d(i,"shimGetUserMedia",(function(){return N})),r.d(i,"shimGetDisplayMedia",(function(){return k})),r.d(i,"shimPeerConnection",(function(){return L})),r.d(i,"shimReplaceTrack",(function(){return x}));var o={};r.r(o),r.d(o,"shimGetUserMedia",(function(){return U})),r.d(o,"shimGetDisplayMedia",(function(){return B})),r.d(o,"shimOnTrack",(function(){return j})),r.d(o,"shimPeerConnection",(function(){return V})),r.d(o,"shimSenderGetStats",(function(){return H})),r.d(o,"shimReceiverGetStats",(function(){return W})),r.d(o,"shimRemoveStream",(function(){return F})),r.d(o,"shimRTCDataChannel",(function(){return G})),r.d(o,"shimAddTransceiver",(function(){return J})),r.d(o,"shimGetParameters",(function(){return q})),r.d(o,"shimCreateOffer",(function(){return Y})),r.d(o,"shimCreateAnswer",(function(){return z}));var a={};r.r(a),r.d(a,"shimLocalStreamsAPI",(function(){return K})),r.d(a,"shimRemoteStreamsAPI",(function(){return Q})),r.d(a,"shimCallbacksAPI",(function(){return X})),r.d(a,"shimGetUserMedia",(function(){return $})),r.d(a,"shimConstraints",(function(){return Z})),r.d(a,"shimRTCIceServerUrls",(function(){return ee})),r.d(a,"shimTrackEventTransceiver",(function(){return te})),r.d(a,"shimCreateOfferLegacy",(function(){return re})),r.d(a,"shimAudioContext",(function(){return ne}));var s={};r.r(s),r.d(s,"shimRTCIceCandidate",(function(){return ae})),r.d(s,"shimMaxMessageSize",(function(){return se})),r.d(s,"shimSendThrowTypeError",(function(){return ce})),r.d(s,"shimConnectionState",(function(){return ue})),r.d(s,"removeExtmapAllowMixed",(function(){return de})),r.d(s,"shimAddIceCandidateNullOrEmpty",(function(){return pe}));let c=!0,u=!0;function d(e,t,r){const n=e.match(t);return n&&n.length>=r&&parseInt(n[r],10)}function p(e,t,r){if(!e.RTCPeerConnection)return;const n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return i.apply(this,arguments);const o=e=>{const t=r(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(n,o),i.apply(this,[e,o])};const o=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(r))return o.apply(this,arguments);const n=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},Object.defineProperty(n,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function l(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(c=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function f(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(u=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function h(){if("object"==typeof window){if(c)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function m(e,t){u&&console.warn(e+" is deprecated, please use "+t+" instead.")}function v(e){return"[object Object]"===Object.prototype.toString.call(e)}function E(e){return v(e)?Object.keys(e).reduce((function(t,r){const n=v(e[r]),i=n?E(e[r]):e[r],o=n&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,{[r]:i})}),{}):e}function R(e,t,r){const n=r?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;const o=[];return e.forEach(e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)}),o.forEach(t=>{e.forEach(r=>{r.type===n&&r.trackId===t.id&&function e(t,r,n){r&&!n.has(r.id)&&(n.set(r.id,r),Object.keys(r).forEach(i=>{i.endsWith("Id")?e(t,t.get(r[i]),n):i.endsWith("Ids")&&r[i].forEach(r=>{e(t,t.get(r),n)})}))}(e,r,i)})}),i}const y=h;function g(e,t){const r=e&&e.navigator;if(!r.mediaDevices)return;const n=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach(r=>{if("require"===r||"advanced"===r||"mediaSource"===r)return;const n="object"==typeof e[r]?e[r]:{ideal:e[r]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];let e={};"number"==typeof n.ideal?(e[i("min",r)]=n.ideal,t.optional.push(e),e={},e[i("max",r)]=n.ideal,t.optional.push(e)):(e[i("",r)]=n.ideal,t.optional.push(e))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",r)]=n.exact):["min","max"].forEach(e=>{void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,r)]=n[e])})}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});const a=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||a)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return r.mediaDevices.enumerateDevices().then(r=>{let a=(r=r.filter(e=>"videoinput"===e.kind)).find(e=>t.some(t=>e.label.toLowerCase().includes(t)));return!a&&r.length&&t.includes("back")&&(a=r[r.length-1]),a&&(e.video.deviceId=o.exact?{exact:a.deviceId}:{ideal:a.deviceId}),e.video=n(e.video),y("chrome: "+JSON.stringify(e)),i(e)})}e.video=n(e.video)}return y("chrome: "+JSON.stringify(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(r.getUserMedia=function(e,t,n){i(e,e=>{r.webkitGetUserMedia(e,t,e=>{n&&n(o(e))})})}.bind(r),r.mediaDevices.getUserMedia){const e=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(t){return i(t,t=>e(t).then(e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach(e=>{e.stop()}),new DOMException("","NotFoundError");return e},e=>Promise.reject(o(e))))}}}function S(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then(t=>{const n=r.video&&r.video.width,i=r.video&&r.video.height,o=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}function b(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function _(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",r=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===r.track.id):{track:r.track};const i=new Event("track");i.track=r.track,i.receiver=n,i.transceiver={receiver:n},i.streams=[t.stream],this.dispatchEvent(i)}),t.stream.getTracks().forEach(r=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===r.id):{track:r};const i=new Event("track");i.track=r,i.receiver=n,i.transceiver={receiver:n},i.streams=[t.stream],this.dispatchEvent(i)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else p(e,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function T(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){let i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};const n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach(e=>{this._senders.push(t(this,e))})};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach(e=>{const t=this._senders.find(t=>t.track===e);t&&this._senders.splice(this._senders.indexOf(t),1)})}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function C(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,r,n]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const i=function(e){const t={};return e.result().forEach(e=>{const r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(t=>{r[t]=e.stat(t)}),t[r.id]=r}),t},o=function(e){return new Map(Object.keys(e).map(t=>[t,e[t]]))};if(arguments.length>=2){const n=function(e){r(o(i(e)))};return t.apply(this,[n,e])}return new Promise((e,r)=>{t.apply(this,[function(t){e(o(i(t)))},r])}).then(r,n)}}function O(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=>R(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}),p(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then(t=>R(t,e.track,!1))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,r,n;return this.getSenders().forEach(r=>{r.track===e&&(t?n=!0:t=r)}),this.getReceivers().forEach(t=>(t.track===e&&(r?n=!0:r=t),t.track===e)),n||t&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function w(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(e=>this._shimmedLocalStreams[e][0])};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const n=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===this._shimmedLocalStreams[r.id].indexOf(n)&&this._shimmedLocalStreams[r.id].push(n):this._shimmedLocalStreams[r.id]=[r,n],n};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException("Track already exists.","InvalidAccessError")});const t=this.getSenders();r.apply(this,arguments);const n=this.getSenders().filter(e=>-1===t.indexOf(e));this._shimmedLocalStreams[e.id]=[e].concat(n)};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(t=>{const r=this._shimmedLocalStreams[t].indexOf(e);-1!==r&&this._shimmedLocalStreams[t].splice(r,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]}),i.apply(this,arguments)}}function P(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return w(e);const r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=r.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map(e=>this._reverseStreams[e.id])};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[t.id]){const r=new e.MediaStream(t.getTracks());this._streams[t.id]=r,this._reverseStreams[r.id]=t,t=r}n.apply(this,[t])};const i=e.RTCPeerConnection.prototype.removeStream;function o(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)}),new RTCSessionDescription({type:t.type,sdp:r})}function a(e,t){let r=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:r})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,r){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const n=[].slice.call(arguments,1);if(1!==n.length||!n[0].getTracks().find(e=>e===t))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");const i=this.getSenders().find(e=>e.track===t);if(i)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const o=this._streams[r.id];if(o)o.addTrack(t),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const n=new e.MediaStream([t]);this._streams[r.id]=n,this._reverseStreams[n.id]=r,this.addStream(n)}return this.getSenders().find(e=>e.track===t)},["createOffer","createAnswer"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?r.apply(this,[t=>{const r=o(this,t);e[0].apply(null,[r])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):r.apply(this,arguments).then(e=>o(this,e))}};e.RTCPeerConnection.prototype[t]=n[t]}));const s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=a(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};const c=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=c.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],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}))}function M(e,t){p(e,"negotiationneeded",e=>{const r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e})}var A=r(30),I=r.n(A);function N(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 k(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 L(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=I()(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=function(e,t){let r=!1;return(e=JSON.parse(JSON.stringify(e))).filter(e=>{if(e&&(e.urls||e.url)){let t=e.urls||e.url;e.url&&!e.urls&&m("RTCIceServer.url","RTCIceServer.urls");const n="string"==typeof t;return n&&(t=[t]),t=t.filter(e=>{if(0===e.indexOf("stun:"))return!1;const t=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return t&&!r?(r=!0,!0):t&&!r}),delete e.url,e.urls=n?t[0]:t,!!t.length}})}(e.iceServers,t.version),h("ICE servers after filtering:",e.iceServers)),new r(e)},e.RTCPeerConnection.prototype=r.prototype}function x(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}function U(e,t){const r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){m("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){const e=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},t=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(r){return"object"==typeof r&&"object"==typeof r.audio&&(r=JSON.parse(JSON.stringify(r)),e(r.audio,"autoGainControl","mozAutoGainControl"),e(r.audio,"noiseSuppression","mozNoiseSuppression")),t(r)},n&&n.prototype.getSettings){const t=n.prototype.getSettings;n.prototype.getSettings=function(){const r=t.apply(this,arguments);return e(r,"mozAutoGainControl","autoGainControl"),e(r,"mozNoiseSuppression","noiseSuppression"),r}}if(n&&n.prototype.applyConstraints){const t=n.prototype.applyConstraints;n.prototype.applyConstraints=function(r){return"audio"===this.kind&&"object"==typeof r&&(r=JSON.parse(JSON.stringify(r)),e(r,"autoGainControl","mozAutoGainControl"),e(r,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[r])}}}}function B(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 j(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 V(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}));const r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,o]=arguments;return n.apply(this,[e||null]).then(e=>{if(t.version<53&&!i)try{e.forEach(e=>{e.type=r[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach((t,n)=>{e.set(n,Object.assign({},t,{type:r[t.type]||t.type}))})}return e}).then(i,o)}}function H(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 W(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}),p(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function F(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 G(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function J(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],r=e&&"sendEncodings"in e;r&&e.sendEncodings.forEach(e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const n=t.apply(this,arguments);if(r){const{sender:t}=n,r=t.getParameters();(!("encodings"in r)||1===r.encodings.length&&0===Object.keys(r.encodings[0]).length)&&(r.encodings=e.sendEncodings,t.sendEncodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(r).then(()=>{delete t.sendEncodings}).catch(()=>{delete t.sendEncodings})))}return n})}function q(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 Y(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 z(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)}}function K(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 Q(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 X(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i};let s=function(e,t,r){const n=i.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){const n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){const n=a.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=s}function $(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(Z(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function Z(e){return e&&void 0!==e.video?Object.assign({},e,{video:E(e.video)}):e}function ee(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){const t=[];for(let r=0;r<e.iceServers.length;r++){let n=e.iceServers[r];!n.hasOwnProperty("urls")&&n.hasOwnProperty("url")?(m("RTCIceServer.url","RTCIceServer.urls"),n=JSON.parse(JSON.stringify(n)),n.urls=n.url,delete n.url,t.push(n)):t.push(e.iceServers[r])}e.iceServers=t}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function te(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 re(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 ne(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var ie=r(5),oe=r.n(ie);function ae(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const r=new t(e),n=oe.a.parseCandidate(e.candidate),i=Object.assign(r,n);return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,p(e,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t))}function se(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=function(e){if(!e||!e.sdp)return!1;const t=oe.a.splitSections(e.sdp);return t.shift(),t.some(e=>{const t=oe.a.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})},n=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},i=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},o=function(e,r){let n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);const i=oe.a.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=parseInt(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n},a=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(r(arguments[0])){const e=n(arguments[0]),t=i(e),r=o(arguments[0],e);let a;a=0===t&&0===r?Number.POSITIVE_INFINITY:0===t||0===r?Math.max(t,r):Math.min(t,r);const s={};Object.defineProperty(s,"maxMessageSize",{get:()=>a}),this._sctp=s}return a.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 n=arguments[0],i=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}const r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=r.apply(this,arguments);return t(e,this),e},p(e,"datachannel",e=>(t(e.channel,e.target),e))}function ue(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 de(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 pe(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())})}const le=function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const r=h,c=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=d(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=d(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(r.mediaDevices&&r.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=d(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=d(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),u={browserDetails:c,commonShim:s,extractVersion:d,disableLog:l,disableWarnings:f};switch(c.browser){case"chrome":if(!n||!D||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),u;if(null===c.version)return r("Chrome shim can not determine version, not shimming."),u;r("adapter.js shimming chrome."),u.browserShim=n,pe(e,c),g(e,c),b(e),D(e,c),_(e),P(e,c),T(e),C(e),O(e),M(e,c),ae(e),ue(e),se(e,c),ce(e),de(e,c);break;case"firefox":if(!o||!V||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),u;r("adapter.js shimming firefox."),u.browserShim=o,pe(e,c),U(e,c),V(e,c),j(e),F(e),H(e),W(e),G(e),J(e),q(e),Y(e),z(e),ae(e),ue(e),se(e,c),ce(e);break;case"edge":if(!i||!L||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),u;r("adapter.js shimming edge."),u.browserShim=i,N(e),k(e),L(e,c),x(e),se(e,c),ce(e);break;case"safari":if(!a||!t.shimSafari)return r("Safari shim is not included in this adapter release."),u;r("adapter.js shimming safari."),u.browserShim=a,pe(e,c),ee(e),re(e),X(e),K(e),Q(e),te(e),$(e),ne(e),ae(e),se(e,c),ce(e),de(e,c);break;default:r("Unsupported browser!")}return u}({window:"undefined"==typeof window?void 0:window});t.default=le},function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return d}));function n(e,t,r){Object.defineProperty(e,t,{writable:!0,enumerable:!0,configurable:!0,value:r})}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;Array(32);Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;var i,o,a,s;Object.defineProperty,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;function c(e,t){const r=new window.XMLHttpRequest;r.open("POST",e+"?APIVersion=0.6.0",!0),r.send(t)}function u(e,t){try{if(t.length>=32768)return void c(e,t);(function(e,t){return!(!navigator||!navigator.sendBeacon)&&navigator.sendBeacon(e+"?APIVersion=0.6.0",t)})(e,t)||c(e,t)}catch(t){window&&window.console&&"function"==typeof window.console.error&&(console.error("Failed to log to ali log service because of this exception:\n"+t),console.error("Failed log data:",e))}}class d extends class{constructor(e){var t,r;this.timer=null,this.time=10,this.count=10,this.arr=[],this.time=null!=(t=e.time)?t:10,this.count=null!=(r=e.count)?r:10,e.host.startsWith("http://")||e.host.startsWith("https://")?this.url=e.host+"/logstores/"+e.logstore+"/track":this.url="https://"+e.project+"."+e.host+"/logstores/"+e.logstore+"/track",this.opt=e,e.installUnloadHook&&"function"==typeof e.installUnloadHook&&e.installUnloadHook(()=>{this.sendImmediateInner()})}assemblePayload(e=this.arr){const t={__logs__:e};return this.opt.tags&&(t.__tags__=this.opt.tags),this.opt.topic&&(t.__topic__=this.opt.topic),this.opt.source&&(t.__source__=this.opt.source),JSON.stringify(t)}platformSend(){if(this.opt.sendPayload&&"function"==typeof this.opt.sendPayload){const e=this.assemblePayload();this.opt.sendPayload(this.url,e)}}transString(e){let t={};for(let r in e)"object"==typeof e[r]?t[r]=JSON.stringify(e[r]):t[r]=String(e[r]);return t}sendImmediateInner(){this.arr&&this.arr.length>0&&(this.platformSend(),null!=this.timer&&(clearTimeout(this.timer),this.timer=null),this.arr=[])}sendInner(){if(this.timer)this.arr.length>=this.count&&(clearTimeout(this.timer),this.timer=null,this.sendImmediateInner());else{const e=this;this.arr.length>=this.count||this.time<=0?this.sendImmediateInner():this.timer=setTimeout((function(){e.sendImmediateInner()}),1e3*this.time)}}send(e){const t=this.transString(e);this.arr.push(t),this.sendInner()}sendImmediate(e){const t=this.transString(e);this.arr.push(t),this.sendImmediateInner()}sendBatchLogs(e){const t=e.map(e=>this.transString(e));this.arr.push(...t),this.sendInner()}sendBatchLogsImmediate(e){const t=e.map(e=>this.transString(e));this.arr.push(...t),this.sendImmediateInner()}}{constructor(e){super(Object.assign({},e,{installUnloadHook:e=>{window.addEventListener("beforeunload",()=>{e()})},sendPayload:(e,t)=>{u(e,t)}}))}}i=window,o="SLS_Tracker",a=d,s?s(()=>{n(i,o,a)}):n(i,o,a)}])}));