@phenixrts/sdk 2025.2.3-beta.607 → 2025.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/channels/debug/channels.js +1084 -1084
- package/channels/debug/package.json +1 -1
- package/channels/debug.private/channels.js +1001 -1001
- package/channels/debug.private/package.json +1 -1
- package/channels/debug.provideGlobalScope/channels.js +1056 -1056
- package/channels/debug.provideGlobalScope/package.json +1 -1
- package/channels/es5.debug.private/channels.js +2 -2
- package/channels/es5.debug.private/package.json +1 -1
- package/channels/min/channels.js +1 -1
- package/channels/min/channels.js.map +1 -1
- package/channels/min/package.json +1 -1
- package/channels/min.private/channels.js +1 -1
- package/channels/min.private/channels.js.map +1 -1
- package/channels/min.private/package.json +1 -1
- package/channels/min.provideGlobalScope/channels.js +1 -1
- package/channels/min.provideGlobalScope/channels.js.map +1 -1
- package/channels/min.provideGlobalScope/package.json +1 -1
- package/channels/package.json +1 -1
- package/full/debug/full.js +1195 -1195
- package/full/debug/package.json +1 -1
- package/full/debug.private/full.js +1112 -1112
- package/full/debug.private/package.json +1 -1
- package/full/min/full.js +1 -1
- package/full/min/full.js.map +1 -1
- package/full/min/package.json +1 -1
- package/full/min.private/full.js +1 -1
- package/full/min.private/full.js.map +1 -1
- package/full/min.private/package.json +1 -1
- package/full/package.json +1 -1
- package/package.json +1 -1
- package/publish/debug/package.json +1 -1
- package/publish/debug/publish.js +772 -772
- package/publish/debug.private/package.json +1 -1
- package/publish/debug.private/publish.js +772 -772
- package/publish/min/package.json +1 -1
- package/publish/min/publish.js +1 -1
- package/publish/min/publish.js.map +1 -1
- package/publish/min.private/package.json +1 -1
- package/publish/min.private/publish.js +1 -1
- package/publish/min.private/publish.js.map +1 -1
- package/publish/package.json +1 -1
package/full/min.private/full.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see full.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.phenix=t():e.phenix=t()}(self,()=>(()=>{var e={981:(e,t,n)=>{"use strict";n.d(t,{A:()=>f});var r=n(738),i=n.n(r),o=n(383),a=n.n(o),s=n(579),u=n.n(s),c=n(693),l=n.n(c),d=u()(function e(t,n,r){a()(this,e),l()(this,"onFulfilled",void 0),l()(this,"onRejected",void 0),l()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.promise=r}),h=function(){function e(t){if(a()(this,e),l()(this,"_state",void 0),l()(this,"_handled",void 0),l()(this,"_value",void 0),l()(this,"_deferreds",void 0),!(this instanceof e))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=null,this._deferreds=[],this.doResolve(t)}return u()(e,[{key:"doResolve",value:function(e){var t=this,n=!1;try{e(function(e){n||(n=!0,t.promiseResolve(e))},function(e){n||(n=!0,t.promiseReject(e))})}catch(e){if(n)return;n=!0,this.promiseReject(e)}}},{key:"promiseResolve",value:function(t){var n=this;try{if(t===n)throw new TypeError("A Promise cannot be resolved with it self.");if(t&&("object"===i()(t)||"function"==typeof t)){var r=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof r)return void n.doResolve(function(){r.apply(t,arguments)})}n._state=1,n._value=t,n.finale()}catch(e){n.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate(function(){t._handled||e._unhandledRejection(t._value)});for(var n=0,r=this._deferreds.length;n<r;n++)this.handle(this._deferreds[n]);this._deferreds=[]}},{key:"handle",value:function(t){for(var n=this;3===n._state;)n=n._value;0!==n._state?(n._handled=!0,e._immediate(function(){var e=1===n._state?t.onFulfilled:t.onRejected;if(null!==e){var r;try{r=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(r)}else 1===n._state?t.promise.promiseResolve(n._value):t.promise.promiseReject(n._value)})):n._deferreds.push(t)}}],[{key:"all",value:function(t){return new e(function(e,n){if(!Array.isArray(t))return n(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);for(var o=r.length,a=function(t,s){try{if(s&&("object"===i()(s)||"function"==typeof s)){var u=s.then;if("function"==typeof u)return void u.call(s,function(e){return a(t,e)},n)}r[t]=s,0===--o&&e(r)}catch(e){n(e)}},s=0;s<r.length;s++)a(s,r[s])})}},{key:"resolve",value:function(t){return t&&"object"===i()(t)&&t.constructor===e?t:new e(function(e){return e(t)})}},{key:"reject",value:function(t){return new e(function(e,n){return n(t)})}},{key:"race",value:function(t){return new e(function(n,r){if(!Array.isArray(t))return r(new TypeError("Promise.race accepts an array"));for(var i=0,o=t.length;i<o;i++)e.resolve(t[i]).then(n,r)})}},{key:"_immediate",value:function(e){window.setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}])}();h.prototype.catch=function(e){return this.then(null,e)},h.prototype.then=function(e,t){var n=new h(function(){return null});return this.handle(new d(e,t,n)),n},h.prototype.finally=function(e){return this.then(function(t){return h.resolve(e()).then(function(){return t},function(){return null})},function(t){return h.resolve(e()).then(function(){return h.reject(t)},function(){return null})})};var f=h},512:e=>{"use strict";e.exports=function(e,t,n,r){var i=self||window;try{try{var o;try{o=new i.Blob([e])}catch(t){(o=new(i.BlobBuilder||i.WebKitBlobBuilder||i.MozBlobBuilder||i.MSBlobBuilder)).append(e),o=o.getBlob()}var a=i.URL||i.webkitURL,s=a.createObjectURL(o),u=new i[t](s,n);return a.revokeObjectURL(s),u}catch(r){return new i[t]("data:application/javascript,".concat(encodeURIComponent(e)),n)}}catch(e){if(!r)throw Error("Inline worker is not supported");return new i[t](r,n)}}},79:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},987:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},901:(e,t,n)=>{var r=n(79);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},475:e=>{e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},293:(e,t,n)=>{var r=n(981).A;function i(e,t,n,i,o,a,s){try{var u=e[a](s),c=u.value}catch(e){return void n(e)}u.done?t(c):r.resolve(c).then(i,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new r(function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,u,"next",e)}function u(e){i(a,r,o,s,u,"throw",e)}s(void 0)})}},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,n)=>{var r=n(736);function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}e.exports=function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,t,n)=>{var r=n(736);e.exports=function(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},72:e=>{function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},511:(e,t,n)=>{var r=n(636);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},291:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},156:e=>{e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}},e.exports.__esModule=!0,e.exports.default=e.exports},752:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},869:e=>{e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},847:(e,t,n)=>{var r=n(893);e.exports=function(e,t){if(null==e)return{};var n,i,o=r(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)n=a[i],t.indexOf(n)>=0||{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o},e.exports.__esModule=!0,e.exports.default=e.exports},893:e=>{e.exports=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n},e.exports.__esModule=!0,e.exports.default=e.exports},452:(e,t,n)=>{var r=n(738).default,i=n(475);e.exports=function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return i(e)},e.exports.__esModule=!0,e.exports.default=e.exports},636:e=>{function t(n,r){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},715:(e,t,n)=>{var r=n(987),i=n(156),o=n(122),a=n(752);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},132:(e,t,n)=>{var r=n(901),i=n(291),o=n(122),a=n(869);e.exports=function(e){return r(e)||i(e)||o(e)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,t,n)=>{var r=n(738).default;e.exports=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,t,n)=>{var r=n(738).default,i=n(45);e.exports=function(e){var t=i(e,"string");return"symbol"==r(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},122:(e,t,n)=>{var r=n(79);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{ChannelState:()=>Ne,Channels:()=>Cn,PublisherState:()=>Sn,Publishers:()=>Gn,SDK:()=>Ve,default:()=>Bn});var e=n(383),t=n.n(e),i=n(579),o=n.n(i),a=n(693),s=n.n(a),u=n(132),c=n.n(u),l=n(452),d=n.n(l),h=n(72),f=n.n(h),p=n(511),v=n.n(p),m=function(){return o()(function e(n){t()(this,e),s()(this,"_disposed",void 0),s()(this,"_disposable",void 0),this._disposed=!1,this._disposable=n},[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}])}();function g(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(g=function(){return!!e})()}var y,_=function(e){function n(e,r){return t()(this,n),i=this,o=n,a=[function(){var t=e.indexOf(r);t>=0&&e.splice(t,1)}],o=f()(o),d()(i,g()?Reflect.construct(o,a||[],f()(i).constructor):o.apply(i,a));var i,o,a}return v()(n,e),o()(n)}(m),b=function(){return o()(function e(n){t()(this,e),s()(this,"_listeners",void 0),s()(this,"_value",void 0),this._listeners=[],this._value=n},[{key:"value",get:function(){return this._value},set:function(e){var t=this._value!==e;if(t&&e){var n=e;"function"==typeof n.equals&&(t=!n.equals(this._value))}if(t){this._value=e;for(var r=0,i=c()(this._listeners);r<i.length;r++)(0,i[r])(e)}}},{key:"subscribe",value:function(e){return this._listeners.push(e),e(this._value),new _(this._listeners,e)}}])}(),C=function(){return o()(function e(n){t()(this,e),s()(this,"_subject",void 0),this._subject=n},[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}])}(),k={document,location,navigator,window},S=function(){function e(n){t()(this,e),s()(this,"_document",void 0),s()(this,"_location",void 0),s()(this,"_navigator",void 0),s()(this,"_window",void 0),this._document=n.document,this._location=n.location,this._navigator=n.navigator,this._window=n.window}return o()(e,[{key:"FormData",get:function(){return this._window.FormData}},{key:"HTMLVideoElement",get:function(){return this._window.HTMLVideoElement}},{key:"MediaStream",get:function(){return this._window.MediaStream}},{key:"MediaStreamTrack",get:function(){return this._window.MediaStreamTrack}},{key:"MediaSource",get:function(){return this._window.MediaSource}},{key:"RTCPeerConnection",get:function(){return this._window.RTCPeerConnection}},{key:"RTCSessionDescription",get:function(){return this._window.RTCSessionDescription}},{key:"RTCIceCandidate",get:function(){return this._window.RTCIceCandidate}},{key:"URL",get:function(){return this._window.URL}},{key:"URLSearchParams",get:function(){return this._window.URLSearchParams}},{key:"addDocumentEventListener",get:function(){return this._document.addEventListener.bind(this._document)}},{key:"addWindowEventListener",get:function(){return this._window.addEventListener.bind(this._window)}},{key:"clearInterval",get:function(){return this._window.clearInterval.bind(this._window)}},{key:"clearTimeout",get:function(){return this._window.clearTimeout.bind(this._window)}},{key:"documentCreateElement",get:function(){return this._document.createElement.bind(this._document)}},{key:"documentHasFocus",get:function(){return this._document.hasFocus.bind(this._document)}},{key:"documentIsHidden",get:function(){return!!this._document.hidden}},{key:"documentQuerySelector",get:function(){return this._document.querySelector.bind(this._document)}},{key:"fetch",get:function(){return this._window.fetch.bind(this._window)}},{key:"locationHostname",get:function(){return this._location.hostname}},{key:"locationSearch",get:function(){return this._location.search}},{key:"navigatorConnection",get:function(){return this._navigator.connection}},{key:"navigatorIsOnLine",get:function(){return this._navigator.onLine}},{key:"pageLoadTime",get:function(){return this._window.__phenixPageLoadTime||this._window.__pageLoadTime}},{key:"queueMicrotask",get:function(){return this._window.queueMicrotask.bind(this._window)}},{key:"removeDocumentEventListener",get:function(){return this._document.removeEventListener.bind(this._document)}},{key:"requestAnimationFrame",get:function(){return this._window.requestAnimationFrame.bind(this._window)}},{key:"removeWindowEventListener",get:function(){return this._window.removeEventListener.bind(this._window)}},{key:"setInterval",get:function(){return this._window.setInterval.bind(this._window)}},{key:"setTimeout",get:function(){return this._window.setTimeout.bind(this._window)}}],[{key:"setInstance",value:function(e){throw new Error("This build does not support setting the GlobalScope")}},{key:"getInstance",value:function(){return e._readOnlyInstance}},{key:"subscribe",value:function(t){return e._readOnlyInstance.subscribe(t)}}])}();y=S,s()(S,"_instance",new b(new y(k))),s()(S,"_readOnlyInstance",new C(y._instance));var w,T,x,P=S.getInstance(),E=function(){function e(){t()(this,e)}return o()(e,null,[{key:"browserNameAndVersion",get:function(){return e._browserNameAndVersion}},{key:"browserName",get:function(){return this._browserName}},{key:"browserMajorVersion",get:function(){return this._browserMajorVersion}},{key:"isAndroid",get:function(){return e._isAndroid}},{key:"isChrome69",get:function(){return e._isChrome69}},{key:"isChrome70",get:function(){return e._isChrome70}},{key:"isChrome71",get:function(){return e._isChrome71}},{key:"isChrome72",get:function(){return e._isChrome72}},{key:"isChrome74",get:function(){return e._isChrome74}},{key:"isChrome75",get:function(){return e._isChrome75}},{key:"isChrome76",get:function(){return e._isChrome76}},{key:"isChrome77",get:function(){return e._isChrome77}},{key:"isMobile",value:function(){return e._isMobile}},{key:"parseBrowserNameAndVersion",value:function(){if(!navigator||!navigator.userAgent)return"";var t=navigator.userAgent.match(e._browserNameAndVersionRegex);return t&&t[0]?t[0]:e.parseBrowserNameAndVersionForIE()}},{key:"parseBrowserName",value:function(){if(!e._browserNameAndVersion)return"";var t=e._browserNameAndVersion.split("/");return t&&t[0]?t[0]:""}},{key:"parseBrowserMajorVersion",value:function(){if(!e._browserNameAndVersion)return 0;var t=e._browserNameAndVersion.split("/");if(!t||!t[1])return 0;var n=t[1];return n&&Number(n.split(".")[0])||0}},{key:"parseBrowserNameAndVersionForIE",value:function(){if(!navigator||!navigator.userAgent)return"";var e=navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return"IE/".concat(parseInt(e.substring(t+5,e.indexOf(".",t)),10));if(e.indexOf("Trident/")>0){var n=e.indexOf("rv:");return"IE/".concat(parseInt(e.substring(n+3,e.indexOf(".",n)),10))}return""}}])}();w=E,s()(E,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),s()(E,"_browserNameAndVersion",w.parseBrowserNameAndVersion()),s()(E,"_browserName",w.parseBrowserName()),s()(E,"_browserMajorVersion",w.parseBrowserMajorVersion()),s()(E,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(T=navigator)||void 0===T?void 0:T.userAgent)),s()(E,"_isAndroid",/Android/i.test(null===(x=navigator)||void 0===x?void 0:x.userAgent)),s()(E,"_isChrome69",w._browserNameAndVersion.includes("Chrome/69.")),s()(E,"_isChrome70",w._browserNameAndVersion.includes("Chrome/70.")),s()(E,"_isChrome71",w._browserNameAndVersion.includes("Chrome/71.")),s()(E,"_isChrome72",w._browserNameAndVersion.includes("Chrome/72.")),s()(E,"_isChrome74",w._browserNameAndVersion.includes("Chrome/74.")),s()(E,"_isChrome75",w._browserNameAndVersion.includes("Chrome/75.")),s()(E,"_isChrome76",w._browserNameAndVersion.includes("Chrome/76.")),s()(E,"_isChrome77",w._browserNameAndVersion.includes("Chrome/77."));var O=function(){function e(){t()(this,e)}return o()(e,null,[{key:"clientOfferDisabled",get:function(){return E.isChrome74||E.isChrome75||E.isChrome76||E.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return E.isChrome69||E.isChrome70||E.isChrome71||E.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===E.browserName&&E.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===E.browserName&&E.browserMajorVersion<=69||"Firefox"===E.browserName&&E.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===E.browserName&&E.browserMajorVersion<=63||"Firefox"===E.browserName&&E.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===E.browserName&&E.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===E.browserName&&E.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===E.browserName||"SamsungBrowser"===E.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==E.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===E.browserName&&"function"==typeof(null===(e=P.value)||void 0===e?void 0:e.documentCreateElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===E.browserName&&E.browserMajorVersion>=71||"Firefox"===E.browserName&&E.browserMajorVersion>=69||"Safari"===E.browserName}},{key:"isMobile",get:function(){return E.isMobile()}},{key:"isInsertableStreamsSupported",get:function(){return!("undefined"==typeof MediaStreamTrackProcessor||"undefined"==typeof MediaStreamTrackGenerator)}},{key:"isEncodedInsertableStreamsSupported",get:function(){return"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams}},{key:"isRTCRtpScriptTransformSupported",get:function(){return"undefined"!=typeof RTCRtpScriptTransform}},{key:"isRequestVideoFrameCallbackSupported",get:function(){var e;return void 0!==(null===(e=P.value)||void 0===e?void 0:e.HTMLVideoElement.prototype.requestVideoFrameCallback)}},{key:"isRequestAnimationFrameSupported",get:function(){var e;return"function"==typeof(null===(e=P.value)||void 0===e?void 0:e.requestAnimationFrame)}},{key:"isChannelFrameTimingInformationSupported",get:function(){return e.isRequestVideoFrameCallbackSupported&&(e.isEncodedInsertableStreamsSupported||e.isRTCRtpScriptTransformSupported)}},{key:"errorStackAlsoHasErrorMessage",get:function(){return"Firefox"!==E.browserName&&"Safari"!==E.browserName}}])}(),R=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),F=function(){return o()(function e(n,r,i){t()(this,e),s()(this,"_category",void 0),s()(this,"_appenders",void 0),s()(this,"_threshold",void 0),this._category=n,this._appenders=r,this._threshold=i},[{key:"category",get:function(){return this._category}},{key:"appenders",get:function(){return this._appenders}},{key:"threshold",get:function(){return this._threshold}},{key:"trace",value:function(){if(this._threshold.value&&!(this._threshold.value>R.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(R.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>R.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(R.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>R.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(R.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>R.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(R.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>R.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(R.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>R.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(R.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,r=new Date,i=this.replacePlaceholders(t);this._appenders.value.forEach(function(t){t.log(e,i,n.category,r)})}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],r=0;n.indexOf&&e.length>1&&r>=0;)if((r=n.indexOf("%",r))>0)switch(n.substring(r+1,r+2)){case"%":n=n.substring(0,r)+n.substring(r+1),r++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,r),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,r),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce(function(e,n,r,i){return r+1===i.length&&n instanceof Error?O.errorStackAlsoHasErrorMessage?e+"\n"+t.toString(n.stack):e+"\n"+t.toString(n.message)+"\n"+t.toString(n.stack):e+"[".concat(t.toString(n),"]")})),e.toString()}},{key:"stringify",value:function(e){var t=[];try{return JSON.stringify(e instanceof Error?this.toString(e):e,function(e,n){if(n&&n instanceof Object){if(t.includes(n))return"<recursive>";t.push(n)}return n},2)}catch(e){return"[object invalid JSON.stringify]"}}},{key:"replaceArgument",value:function(e,t,n){return t.substring(0,n)+this.toString(e)+t.substring(n+2)}},{key:"toString",value:function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return e.toString();var t="";if(e)if("function"==typeof e)t=e.toString();else if(e instanceof Object)try{t=e.toString()}catch(e){t="[object invalid toString()]"}return t}}])}(),I=function(){return o()(function e(){t()(this,e),s()(this,"_appenders",[])},[{key:"value",get:function(){return this._appenders}},{key:"add",value:function(e){this._appenders.push(e)}},{key:"remove",value:function(e){this._appenders=this._appenders.reduce(function(t,n){return n!==e&&t.push(n),t},[])}}])}(),L=function(){return o()(function e(){t()(this,e)},null,[{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"sendLogs",get:function(){return this._sendLogs}},{key:"sendMetrics",get:function(){return this._sendMetrics}},{key:"logToConsole",get:function(){return this._logToConsole}},{key:"applyFeatures",value:function(){try{var e={sendLocalCandidates:!1,sendLogs:"Off",sendMetrics:"Essential",logToConsole:"Off"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}])}();s()(L,"_sendLocalCandidates",void 0),s()(L,"_sendLogs",void 0),s()(L,"_sendMetrics",void 0),s()(L,"_logToConsole",void 0),L.applyFeatures();var D=function(){return o()(function e(){t()(this,e)},null,[{key:"defaultLoggingLevel",get:function(){return R[L.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return R[L.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return R.Info}}])}(),A=function(){return o()(function e(){t()(this,e),s()(this,"_threshold",D.defaultLoggingLevel)},[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}])}(),j=function(){return o()(function e(n){t()(this,e),s()(this,"_threshold",void 0),this._threshold=n},[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(R[e],"] ").concat(t);e<R.Warn?console.log(i):console.error(i)}}}])}(),M=n(293),V=n.n(M),G=function(){function e(){throw t()(this,e),new Error("Numbers is a static class that may not be instantiated")}return o()(e,null,[{key:"countNumberLength",value:function(t){var n=0,r=t;return r<0&&(r*=-1,n++),e.countDigitsBeforeDecimal(r)+n+(r!==Math.floor(r)?e.countDigitsAfterDecimal(r)+1:0)}},{key:"fixRounding",value:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}},{key:"countDigitsBeforeDecimal",value:function(e){for(var t=1,n=e;n>=10;)n/=10,t++;return t}},{key:"countDigitsAfterDecimal",value:function(t){for(var n=t,r=Math.floor(t),i=0;r!==n&&i<15;)i++,r=e.fixRounding(n,i);return i}}])}(),B=function(){return o()(function e(){t()(this,e)},null,[{key:"sdkVersion",get:function(){try{return"2026-04-01T18:35:31.540Z (2025.2.3-beta.607)"}catch(e){return this._defaultVersion}}}])}();s()(B,"_defaultVersion",(new Date).toISOString());var U=n(981).A;function N(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return z(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(z(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,z(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,z(d,"constructor",c),z(c,"constructor",u),u.displayName="GeneratorFunction",z(c,i,"GeneratorFunction"),z(d),z(d,i,"Generator"),z(d,r,function(){return this}),z(d,"toString",function(){return"[object Generator]"}),(N=function(){return{w:o,m:h}})()}function z(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}z=function(e,t,n,r){function o(t,n){z(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},z(e,t,n,r)}var H=function(){return o()(function e(n){var r=this;t()(this,e),s()(this,"_telemetryConfiguration",void 0),s()(this,"_logs",[]),s()(this,"_isSending",!1),s()(this,"_domain",""),this._telemetryConfiguration=n,this.getLocationHostnameFromGlobalScope().then(function(e){r._domain=e})},[{key:"push",value:function(e,t,n,r){var i=(r.valueOf()-this._telemetryConfiguration.pageLoadTime)/1e3,o={timestamp:r.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:R[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:B.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<R.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new U(function(e){var t=P.subscribe(function(n){n&&(e(n.locationHostname),n.setTimeout(function(){return t.dispose()},0))})})}},{key:"sendLogs",value:(n=V()(N().m(function e(t){var n;return N().w(function(e){for(;;)switch(e.n){case 0:return(n=new P.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.n=1,P.value.fetch(this._telemetryConfiguration.url,{method:"POST",body:n});case 1:return e.a(2,e.v)}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"sendLogsIfAble",value:(e=V()(N().m(function e(){var t,n,r,i,o,a=this;return N().w(function(e){for(;;)switch(e.n){case 0:if(!(this._logs.length<=0||this._isSending)&&P.value){e.n=1;break}return e.a(2);case 1:for(t=0,n=0,this._isSending=!0,r=function(e){return"number"==typeof e?G.countNumberLength(e):e.length},i=function(e){return Object.values(e).reduce(function(e,t){return e+(t?r(t):0)},0)};this._logs.length>t&&i(this._logs[t])+n<8192;)n+=i(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,i(this._logs[t])+(8192-i(this._logs[t]))),t=1),o=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.a(2,this.sendLogs(o).then(function(e){return a._isSending=!1,a.sendLogsIfAble(),e}).catch(function(){a._isSending=!1,a.sendLogsIfAble()}))}},e,this)})),function(){return e.apply(this,arguments)})}]);var e,n}(),q=function(){return o()(function e(n){t()(this,e),s()(this,"_telemetryService",void 0),s()(this,"_tenancy",void 0),s()(this,"_sessionId",void 0),s()(this,"_threshold",void 0),this._tenancy=n.tenancy,this._sessionId=n.sessionId,this._threshold=n.threshold,this._telemetryService=new H(n)},[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}])}(),W=function(){return o()(function e(){t()(this,e),s()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),s()(this,"_tenancy","-"),s()(this,"_sessionId","-"),s()(this,"_environment","-"),s()(this,"_pageLoadTime",0),s()(this,"_threshold",D.defaultTelemetryLoggingLevel)},[{key:"url",get:function(){return this._url},set:function(e){var t=new P.value.URL(e);t.pathname=t.pathname+"/logs",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"pageLoadTime",get:function(){return this._pageLoadTime},set:function(e){this._pageLoadTime=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}])}(),J=function(){return o()(function e(){t()(this,e)},null,[{key:"defaultTelemetryLevel",get:function(){return K[L.sendMetrics]}}])}(),K=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),Q=function(){return o()(function e(){t()(this,e),s()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),s()(this,"_tenancy","-"),s()(this,"_sessionId","-"),s()(this,"_environment","-"),s()(this,"_threshold",J.defaultTelemetryLevel)},[{key:"url",get:function(){return this._url},set:function(e){var t=new P.value.URL(e);t.pathname=t.pathname+"/metrics",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}])}(),Z=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},$=function(){return o()(function e(){t()(this,e)},null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case K.Off:return"Off";case K.Essential:return"Essential";case K.All:return"All";default:Z(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return K.Off;case"Essential":return K.Essential;case"All":return K.All;default:Z(e)}}}])}(),X=function(){return o()(function e(){t()(this,e)},null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case R.Off:return"Off";case R.Trace:return"Trace";case R.Debug:return"Debug";case R.Info:return"Trace";case R.Warn:return"Warn";case R.Error:return"Error";case R.Fatal:return"Fatal";case R.All:return"All";default:Z(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return R.Off;case"Trace":return R.Trace;case"Debug":return R.Debug;case"Info":return R.Info;case"Warn":return R.Warn;case"Error":return R.Error;case"Fatal":return R.Fatal;case"All":return R.All;default:Z(e)}}}])}(),Y=function(){function e(){t()(this,e)}return o()(e,null,[{key:"getStringValue",value:function(t){return e.defaultStringValue[t]}},{key:"getBooleanValue",value:function(t){return e.defaultBooleanValue[t]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":$.convertTelemetryLevelToTelemetryLevelType(J.defaultTelemetryLevel),"phenix-logging-level":X.convertLoggingLevelToLoggingLevelType(D.defaultLoggingLevel),"phenix-console-logging-level":X.convertLoggingLevelToLoggingLevelType(D.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":X.convertLoggingLevelToLoggingLevelType(D.defaultTelemetryLoggingLevel),"phenix-channel-token":"","phenix-uri":"","phenix-base-uri":""}}},{key:"defaultBooleanValue",get:function(){return{"phenix-automatically-retry-on-failure":!0,"phenix-automatically-reconnect-peer-connection":!0,"phenix-force-garbage-collection-on-restart":!0,"phenix-skip-garbage-collection-on-mobile-devices":!0}}}])}(),ee=function(){function e(){throw t()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return o()(e,null,[{key:"telemetryConfiguration",get:function(){return e._telemetryConfiguration}},{key:"getLogger",value:function(t){return"string"!=typeof t&&(t="SDK"),e._loggers[t]||(e._loggers[t]=new F(t,this._appenders,this._threshold))}},{key:"applyLoggerConfigFromParameterConfiguration",value:function(){e.applyLoggingLevel(),e.applyAppenderLoggingLevel("console",e.applyConsoleLogger.bind(this)),e.applyAppenderLoggingLevel("telemetry",e.applyTelemetryLogger.bind(this))}},{key:"applyLoggingLevel",value:function(){var e=Y.getStringValue("phenix-logging-level");R[e]&&this._threshold.setThreshold(R[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=Y.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(R[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new j(e||D.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||D.defaultTelemetryLoggingLevel,this._appenders.add(new q(this._telemetryConfiguration))}}])}();s()(ee,"_loggers",{}),s()(ee,"_appenders",new I),s()(ee,"_threshold",new A),s()(ee,"_telemetryConfiguration",new W),ee.applyLoggerConfigFromParameterConfiguration();var te=function(){return o()(function e(){throw t()(this,e),new Error("Strings is a static class that may not be instantiated")},null,[{key:"random",value:function(e){var t=Math.ceil(e/13);return new Array(t).fill(function(){return Math.random().toString(16).substring(2,15)}).reduce(function(e,t){return e+t()},"").substring(0,e)}}])}(),ne=function(){return o()(function e(n){var r,i;t()(this,e),s()(this,"_applicationId",void 0),s()(this,"_token",void 0),this._applicationId=(null==n?void 0:n.applicationId)||"",this._token={uri:null!=n&&null!==(r=n.token)&&void 0!==r&&r.uri?new P.value.URL(n.token.uri):null,capabilities:(null==n||null===(i=n.token)||void 0===i?void 0:i.capabilities)||[]}},[{key:"uri",get:function(){return this._token.uri}},{key:"capabilities",get:function(){return this._token.capabilities}},{key:"tenancy",get:function(){return this._applicationId}}])}(),re=function(){function e(){t()(this,e)}return o()(e,null,[{key:"parseToken",value:function(t){if(!this.isEncodedEdgeTokenValid(t))return e._logger.error("Token is not valid [%s]",t),new ne(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new ne(r)}catch(t){return e._logger.error("Cannot parse token value",t),new ne(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();s()(re,"_logger",ee.getLogger("EdgeAuthParser"));var ie=function(){return o()(function e(){t()(this,e),s()(this,"_list",[])},[{key:"add",value:function(e){this._list.push(e)}},{key:"dispose",value:function(){this._list.forEach(function(e){return e.dispose()}),this._list.length=0}},{key:"toString",value:function(){return"DisposableList[disposables=".concat(this._list.length,"]")}}])}(),oe="visibilitychange",ae=function(){return o()(function e(){t()(this,e),s()(this,"_disposables",new ie),s()(this,"_readOnlyIsForeground",void 0),s()(this,"_isForeground",void 0),s()(this,"_timeOfLastTabFocusChange",Date.now()),s()(this,"_lastBackgroundDuration",null),this._isForeground=new b(!0),this._readOnlyIsForeground=new C(this._isForeground),this.initialize()},[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"getLastBackgroundDuration",value:function(){return this._lastBackgroundDuration}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"initialize",value:function(){var e=this,t=null,n=function(){var n=!P.value.documentIsHidden;n?t&&(e._lastBackgroundDuration=Date.now()-t):(t=Date.now(),e._lastBackgroundDuration=null),e._isForeground.value=n},r=!1;P.value.addDocumentEventListener(oe,n,r),this._disposables.add(new m(function(){return P.value.removeDocumentEventListener(oe,n,r)}))}}])}(),se=n(981).A;function ue(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return ce(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(ce(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,ce(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,ce(d,"constructor",c),ce(c,"constructor",u),u.displayName="GeneratorFunction",ce(c,i,"GeneratorFunction"),ce(d),ce(d,i,"Generator"),ce(d,r,function(){return this}),ce(d,"toString",function(){return"[object Generator]"}),(ue=function(){return{w:o,m:h}})()}function ce(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}ce=function(e,t,n,r){function o(t,n){ce(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},ce(e,t,n,r)}var le=function(){return o()(function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("VanillaPeerConnection")),s()(this,"_peerConnection",void 0),O.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(n):this._peerConnection=new P.value.RTCPeerConnection(n)},[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.currentLocalDescription)||null}},{key:"currentRemoteDescription",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.currentRemoteDescription)||null}},{key:"connectionState",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.connectionState)||null}},{key:"iceConnectionState",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.iceConnectionState)||null}},{key:"supportsGetConfiguration",get:function(){var e;return"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getConfiguration)}},{key:"supportsSetConfiguration",get:function(){var e;return"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.setConfiguration)}},{key:"supportsGetTransceivers",get:function(){var e;return!O.getTransceiversDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getTransceivers)}},{key:"supportsAddTransceiver",get:function(){var e;return!O.addTranceiverDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.addTransceiver)}},{key:"createOffer",value:(i=V()(ue().m(function e(t){var n=this;return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1:if(!O.promiseBasedPCMethodsDisabled){e.n=2;break}return e.a(2,new se(function(e,r){return n._peerConnection.createOffer(e,r,t)}));case 2:return e.a(2,this._peerConnection.createOffer(t))}},e,this)})),function(e){return i.apply(this,arguments)})},{key:"createAnswer",value:(r=V()(ue().m(function e(t){var n=this;return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1:if(!O.promiseBasedPCMethodsDisabled){e.n=2;break}return e.a(2,new se(function(e,r){return n._peerConnection.createAnswer(e,r,t)}));case 2:return e.a(2,this._peerConnection.createAnswer(t))}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"setLocalDescription",value:(n=V()(ue().m(function e(t){return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1:return e.a(2,this._peerConnection.setLocalDescription(O.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t))}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(e=V()(ue().m(function e(t){var n;return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1:return(null===(n=t.sdp)||void 0===n?void 0:n.match(/a=crypto:/i))&&this._logger.warn("SDP a=crypto is not supported"),e.a(2,this._peerConnection.setRemoteDescription(O.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t))}},e,this)})),function(t){return e.apply(this,arguments)})},{key:"getSenders",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getSenders()}},{key:"getReceivers",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getReceivers()}},{key:"getStats",value:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;if(!this._peerConnection)throw new Error("No PeerConnection initialized");return new se(function(t){e._peerConnection.getStats(t)})}},{key:"addEventListener",value:function(e,t,n){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.removeEventListener(e,t,n)}},{key:"getTransceivers",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getTransceivers()}},{key:"addTransceiver",value:function(e,t){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.addTransceiver(e,t)}},{key:"addStream",value:function(e){var t=this;e.getTracks().forEach(function(e){if(!t._peerConnection)throw new Error("No PeerConnection initialized");t._peerConnection.addTrack(e)})}},{key:"getConfiguration",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.setConfiguration(e)}},{key:"ontrack",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.ontrack},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.ontrack=e}},{key:"onicecandidate",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.onicecandidate},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.onicecandidate=e}},{key:"onconnectionstatechange",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.onconnectionstatechange},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.onconnectionstatechange=e}},{key:"oniceconnectionstatechange",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.oniceconnectionstatechange},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){var e;null===(e=this._peerConnection)||void 0===e||e.close()}},{key:"dispose",value:function(){this._peerConnection=null}}]);var e,n,r,i}(),de=n(981).A;function he(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return fe(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(fe(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,fe(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,fe(d,"constructor",c),fe(c,"constructor",u),u.displayName="GeneratorFunction",fe(c,i,"GeneratorFunction"),fe(d),fe(d,i,"Generator"),fe(d,r,function(){return this}),fe(d,"toString",function(){return"[object Generator]"}),(he=function(){return{w:o,m:h}})()}function fe(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}fe=function(e,t,n,r){function o(t,n){fe(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},fe(e,t,n,r)}var pe=function(){return o()(function e(){t()(this,e)},[{key:"createPeerConnection",value:(e=V()(he().m(function e(t){return he().w(function(e){for(;;)if(0===e.n)return e.a(2,new de(function(e){var n=P.subscribe(function(r){r&&(e(new le(t)),n.dispose())})}))},e)})),function(t){return e.apply(this,arguments)})}]);var e}();function ve(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return me(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(me(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,me(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,me(d,"constructor",c),me(c,"constructor",u),u.displayName="GeneratorFunction",me(c,i,"GeneratorFunction"),me(d),me(d,i,"Generator"),me(d,r,function(){return this}),me(d,"toString",function(){return"[object Generator]"}),(ve=function(){return{w:o,m:h}})()}function me(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}me=function(e,t,n,r){function o(t,n){me(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},me(e,t,n,r)}var ge=function(e){return e[e.Disabled=0]="Disabled",e[e.Enabled=1]="Enabled",e}({}),ye=["audio","video"],_e=function(){function e(){throw t()(this,e),new Error("PeerConnectionService is a static class that may not be instantiated")}return o()(e,null,[{key:"peerConnectionFactory",get:function(){return e._peerConnectionFactory}},{key:"initiateInitialPrecaching",value:function(){O.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch(function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)})}},{key:"precacheCreatePeerConnectionOffer",value:(r=V()(ve().m(function t(){return ve().w(function(t){for(;;)if(0===t.n)return t.a(2,e._cached={direction:"recvonly",peerConnection:e.createPeerConnectionOffer().catch(function(t){throw e._cached=null,t})})},t)})),function(){return r.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(n=V()(ve().m(function t(){var n,r,i,o,a,s=arguments;return ve().w(function(t){for(;;)switch(t.n){case 0:if(n=s.length>0&&void 0!==s[0]?s[0]:"recvonly",r=s.length>1&&void 0!==s[1]?s[1]:ye,i=s.length>2&&void 0!==s[2]?s[2]:ge.Disabled,!e._cached||e._cached.direction!==n||i!==ge.Disabled||!this.isTracksKindsEquivalentToDefault(r)){t.n=1;break}return o=e._cached.peerConnection,e._cached=null,t.a(2,o);case 1:return a=O.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:i===ge.Enabled}:void 0,t.a(2,e._peerConnectionFactory.value.createPeerConnection(a).then(function(){var e=V()(ve().m(function e(t){var i,o,a,s,u,c,l,d,h,f;return ve().w(function(e){for(;;)switch(e.n){case 0:if(i=t.supportsAddTransceiver,o=[],a=[],!i){e.n=2;break}return r.forEach(function(e){"audio"!==e?"video"!==e||a.push(t.addTransceiver(e,{direction:n})):o.push(t.addTransceiver(e,{direction:n}))}),u=o,c=a,l=t,e.n=1,t.createOffer(void 0);case 1:return d=e.v,e.a(2,{audioTransceivers:u,videoTransceivers:c,peerConnection:l,localOffer:d});case 2:return s="recvonly"===n?{offerToReceiveAudio:!0,offerToReceiveVideo:!0}:{},h=t,e.n=3,t.createOffer(s);case 3:return f=e.v,e.a(2,{peerConnection:h,localOffer:f})}},e)}));return function(t){return e.apply(this,arguments)}}()))}},t,this)})),function(){return n.apply(this,arguments)})},{key:"isTracksKindsEquivalentToDefault",value:function(e){if(e.length!==ye.length)return!1;var t=function(e){return e.reduce(function(e,t){return e[t]=(e[t]||0)+1,e},{audio:0,video:0})},n=t(e),r=t(ye);return n.audio===r.audio&&n.video===r.video}}]);var n,r}();s()(_e,"_logger",ee.getLogger("PeerConnectionService")),s()(_e,"_peerConnectionFactory",new b(new pe)),s()(_e,"_cached",void 0),_e.initiateInitialPrecaching();var be=function(){return o()(function e(){t()(this,e)},null,[{key:"getTelemetryUrl",value:function(e){try{var t=new P.value.URL(e),n=t.hostname.split(".");switch(t.protocol){case"ws:":t.protocol="http:";break;case"wss:":t.protocol="https:"}return 2===n.length||3===n.length&&n[n.length-2].length<=2&&n[n.length-1].length<=3?n.unshift("telemetry"):n[0].startsWith("stg-")||n[0].endsWith("-stg")||n[0].includes("-stg-")||"stg"===n[0]?n[0]="telemetry-stg":n[0].startsWith("local")||n[0].endsWith("-local")||(n[0]="telemetry"),t.hostname=n.join("."),"".concat(t.origin,"/telemetry")}catch(t){return e}}}])}(),Ce=function(){return o()(function e(){t()(this,e)},null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new P.value.URL(e).origin}catch(e){return""}}}])}(),ke=function(){return o()(function e(){t()(this,e)},null,[{key:"discoveryParameters",get:function(){return this._discoveryParameters}},{key:"applyParameters",value:function(){try{var e={discovery:{intentions:"contribution,distribution"}};this._discoveryParameters="discovery"in e?e.discovery:{intentions:""}}catch(e){this._discoveryParameters={intentions:""}}}}])}();s()(ke,"_discoveryParameters",void 0),ke.applyParameters();var Se=function(){function e(){throw t()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return o()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new P.value.URL(e.toString()),n=B.sdkVersion,r=ke.discoveryParameters.intentions;return t.searchParams.set("version",n),t.searchParams.set("intentions",r),t.searchParams.set("_","".concat(Date.now())),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}])}();s()(Se,"_discoveryUri",new b("https://pcast.phenixrts.com/pcast/endPoints"));var we=n(738),Te=n.n(we),xe=function(){return o()(function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e5;t()(this,e),s()(this,"_backoffIntervalInMillisecond",void 0),s()(this,"_minBackoffIntervalInMillisecond",void 0),s()(this,"_maxBackoffIntervalInMillisecond",void 0),this._backoffIntervalInMillisecond=n,this._minBackoffIntervalInMillisecond=r,this._maxBackoffIntervalInMillisecond=i},[{key:"getExponentialBackoffIntervalByFailureCount",value:function(e){var t=this._backoffIntervalInMillisecond/1e3,n=.5+.5*Math.random(),r=Math.pow(t,e-2),i=Math.floor(r)*n,o=Math.ceil(Math.max(1e3*i,this._minBackoffIntervalInMillisecond));return Math.min(o,this._maxBackoffIntervalInMillisecond)}}])}(),Pe=function(e){return e[e.TimeToFirstFrame=0]="TimeToFirstFrame",e[e.ChannelCreationTimeToFirstFrame=1]="ChannelCreationTimeToFirstFrame",e[e.Stalled=2]="Stalled",e[e.Buffering=3]="Buffering",e[e.SetupCompleted=4]="SetupCompleted",e[e.SetupFailed=5]="SetupFailed",e[e.RoundTripTime=6]="RoundTripTime",e[e.DownlinkThroughputCapacity=7]="DownlinkThroughputCapacity",e[e.NetworkType=8]="NetworkType",e[e.ResolutionChanged=9]="ResolutionChanged",e[e.ApplicationForeground=10]="ApplicationForeground",e[e.ApplicationBackground=11]="ApplicationBackground",e}(Pe||{}),Ee=Pe,Oe=function(){return o()(function e(n){t()(this,e),s()(this,"_metrics",void 0),this._metrics=n},[{key:"getName",value:function(){return Ee[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case Ee.TimeToFirstFrame:case Ee.ChannelCreationTimeToFirstFrame:return K.Essential;case Ee.Stalled:case Ee.Buffering:case Ee.SetupCompleted:case Ee.SetupFailed:case Ee.RoundTripTime:case Ee.DownlinkThroughputCapacity:case Ee.NetworkType:case Ee.ResolutionChanged:case Ee.ApplicationForeground:case Ee.ApplicationBackground:return K.All;default:Z(this._metrics)}}}])}(),Re=n(981).A;function Fe(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return Ie(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Ie(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Ie(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,Ie(d,"constructor",c),Ie(c,"constructor",u),u.displayName="GeneratorFunction",Ie(c,i,"GeneratorFunction"),Ie(d),Ie(d,i,"Generator"),Ie(d,r,function(){return this}),Ie(d,"toString",function(){return"[object Generator]"}),(Fe=function(){return{w:o,m:h}})()}function Ie(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Ie=function(e,t,n,r){function o(t,n){Ie(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},Ie(e,t,n,r)}var Le,De,Ae=function(){return o()(function e(n){var r=this;t()(this,e),s()(this,"_logger",ee.getLogger("MetricsService")),s()(this,"_metricsConfiguration",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_metrics",[]),s()(this,"_isSending",!1),s()(this,"_failureCount",0),s()(this,"_domain",""),this._metricsConfiguration=n,this._exponentialBackoff=new xe,this.getLocationHostnameFromGlobalScope().then(function(e){r._domain=e})},[{key:"metricsConfiguration",get:function(){return this._metricsConfiguration}},{key:"push",value:function(e){var t=e.streamId,n=e.value,r=e.previousValue,i=e.runtime,o=e.resource,a=e.kind,s=new Oe(e.metricType);if(!(this._metricsConfiguration.threshold>s.getTelemetryLevel())){var u={timestamp:(new Date).toISOString(),tenancy:this._metricsConfiguration.tenancy,sessionId:this._metricsConfiguration.sessionId,streamId:t,metric:s.getName(),value:n,previousValue:r,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:B.sdkVersion,runtime:i,resource:o,kind:a};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new Re(function(e){var t=P.subscribe(function(n){n&&(e(n.locationHostname),n.setTimeout(function(){return t.dispose()},0))})})}},{key:"sendMetrics",value:(n=V()(Fe().m(function e(t){var n;return Fe().w(function(e){for(;;)switch(e.n){case 0:return(n=new P.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.n=1,P.value.fetch(this._metricsConfiguration.url,{method:"POST",body:n});case 1:return e.a(2,e.v)}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(e=V()(Fe().m(function e(){var t,n=this;return Fe().w(function(e){for(;;)switch(e.n){case 0:if(!(this._metrics.length<=0||this._isSending)&&P.value){e.n=1;break}return e.a(2);case 1:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.a(2,this.sendMetrics(t).then(function(e){if(n.isResponseStatusCodeRetryable(e)){if(n._metrics.length<=2048)return n._failureCount++,void P.value.setTimeout(function(){n._metrics=[].concat(c()(t),c()(n._metrics)),n._isSending=!1,n.sendMetricsIfAble()},n._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(n._failureCount));n._logger.error("Too many cached metric records [%s], dropping [%s] records",n._metrics.length,t.length)}return n._isSending=!1,n._failureCount=0,n.sendMetricsIfAble(),e}).catch(function(){n._isSending=!1,n.sendMetricsIfAble()}))}},e,this)})),function(){return e.apply(this,arguments)})},{key:"isResponseStatusCodeRetryable",value:function(e){var t=e.status;return/^5\d{2}$/.test(t.toString())}}]);var e,n}(),je=function(){function e(){throw t()(this,e),new Error("MetricsFactory is a static class that may not be instantiated")}return o()(e,null,[{key:"getMetricsService",value:function(t){if("string"!=typeof t)throw new Error("url must be a string instead received [".concat(Te()(t),"]"));var n=e._metricsServices[t];if(n)return n;var r=new Q;return r.sessionId=Ve.clientSessionId,r.tenancy=Ve.tenancy.value,r.url=be.getTelemetryUrl(t),r.environment=Ce.getEnvironmentFromUrl(t),r.threshold=$.convertTelemetryLevelTypeToTelemetryLevel(Ve.telemetryLevel),e._metricsServices[t]=new Ae(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach(function(e){e.metricsConfiguration.threshold=t})}}])}();s()(je,"_metricsServices",{});var Me=(null===(Le=S.getInstance().value)||void 0===Le?void 0:Le.pageLoadTime)||Date.now(),Ve=function(){function e(){throw t()(this,e),new Error("SDK is a static class that may not be instantiated")}return o()(e,null,[{key:"pageLoadTime",get:function(){return Me}},{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"tenancy",get:function(){return this._tenancy}},{key:"clientSessionId",get:function(){return e._clientSessionId}},{key:"loadedTimestamp",get:function(){return e._loadedTimestamp}},{key:"initialized",get:function(){return e._readOnlyInitialized}},{key:"discoveryUri",get:function(){return e._readOnlyDiscoveryUri}},{key:"peerConnectionFactory",get:function(){return e._readOnlyPeerConnectionFactory}},{key:"automaticRetryOnFailure",get:function(){return e._automaticallyRetryOnFailure}},{key:"automaticallyReconnectPeerConnection",get:function(){return e._automaticallyReconnectPeerConnection}},{key:"automaticallyPlayMediaStream",get:function(){return e._automaticallyPlayMediaStream}},{key:"automaticallyMuteVideoOnPlayFailure",get:function(){return e._automaticallyMuteVideoOnPlayFailure}},{key:"forceGarbageCollectionOnRestart",get:function(){return this._forceGarbageCollectionOnRestart}},{key:"skipGarbageCollectionOnMobileDevices",get:function(){return this._skipGarbageCollectionOnMobileDevices}},{key:"webPlayerLoader",get:function(){return this._webPlayerLoader}},{key:"shakaPlayerLoader",get:function(){return this._shakaPlayerLoader}},{key:"hlsJsLoader",get:function(){return this._hlsJsLoader}},{key:"metricsService",get:function(){return e._metricsService}},{key:"applicationActivityMonitor",get:function(){return this._applicationActivityMonitor}},{key:"telemetryUrl",get:function(){return this._telemetryUrl}},{key:"maximalNumberOfPeerConnectionReconnectAttempts",get:function(){return this._maximalNumberOfPeerConnectionReconnectAttempts},set:function(e){this._maximalNumberOfPeerConnectionReconnectAttempts=e}},{key:"loggingLevel",get:function(){return X.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return $.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return E}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=ee.telemetryConfiguration;n.sessionId=e.clientSessionId,n.pageLoadTime=e.pageLoadTime,e._environment.subscribe(function(e){n.environment=e}),e.telemetryUrl.subscribe(function(e){var r=t._logger.appenders.value.find(function(e){return e instanceof q});r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new q(n)),t._logger.info("Telemetry URL was set to [%s]",n.url))}),e._tenancy.subscribe(function(e){var r=t._logger.appenders.value.find(function(e){return e instanceof q});r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new q(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))})}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=je.getMetricsService(Se.uri.value),e._metricsConfiguration=e._metricsService.metricsConfiguration,e._metricsConfiguration.sessionId=e.clientSessionId,e._environment.subscribe(function(t){e._metricsConfiguration.environment=t}),e.telemetryUrl.subscribe(function(t){e._metricsConfiguration.url=t}),e._tenancy.subscribe(function(t){e._metricsConfiguration.tenancy=t});var t=Y.getStringValue("phenix-metrics-level");t&&je.setTelemetryLevel(K[t]),e._telemetryLevel.subscribe(function(e){je.setTelemetryLevel(e)})}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=Y.getBooleanValue("phenix-automatically-retry-on-failure"),this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure)}},{key:"applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration",value:function(){this._automaticallyReconnectPeerConnection=Y.getBooleanValue("phenix-automatically-reconnect-peer-connection"),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection)}},{key:"applyForceGarbageCollectionOnRestartFromParameterConfiguration",value:function(){this._forceGarbageCollectionOnRestart=Y.getBooleanValue("phenix-force-garbage-collection-on-restart"),this._logger.info("Force garbage collection on restart is set to: [%s]",this._forceGarbageCollectionOnRestart)}},{key:"applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration",value:function(){this._skipGarbageCollectionOnMobileDevices=Y.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices"),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices)}},{key:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe(function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=Ce.getEnvironmentFromUrl(t)});var t=Y.getStringValue("phenix-channel-token");if(t){var n=re.parseToken(t);return e._tenancy.value=n.tenancy,Se.uri.value=(n.uri||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var r=Y.getStringValue("phenix-uri");if(r)return Se.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=Y.getStringValue("phenix-base-uri");if(i){var o=new(S.getInstance().value.URL)(i);return o.pathname="/pcast/endPoints",Se.uri.value=o.toString(),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)}}},{key:"onLoad",value:function(t){t&&(this._initialized.value?this._logger.warn("SDK has already been loaded"):(t.addWindowEventListener("unload",function(){e.dispose()}),e.applyDiscoveryUriDefaultFromParameterConfiguration(),e.applyMetricsConfiguration(),e.applyTelemetryConfiguration(),this._applicationActivityMonitor=new ae,this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection),this._logger.info("Force garbage collection on restart is set to: [%s]",this._forceGarbageCollectionOnRestart),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices),this._initialized.value=!0))}},{key:"init",value:function(t){if(t){var n=t;if(n.globalScope&&S.setInstance(n.globalScope),t.discoveryUri&&(Se.uri.value=t.discoveryUri),t.peerConnectionFactory&&(_e.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&K[t.telemetryLevel]&&(e._telemetryLevel.value=$.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&R[t.loggingLevel]&&this._logger.threshold.setThreshold(X.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&R[t.consoleLoggingLevel]){var r=this._logger.appenders.value.find(function(e){return e instanceof j});r&&this._logger.appenders.remove(r),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new j(X.convertLoggingLevelTypeToLoggingLevel(t.consoleLoggingLevel)))}"boolean"==typeof t.automaticallyPlayMediaStream&&(this._automaticallyPlayMediaStream=t.automaticallyPlayMediaStream),"boolean"==typeof t.automaticallyMuteVideoOnPlayFailure&&(this._automaticallyMuteVideoOnPlayFailure=t.automaticallyMuteVideoOnPlayFailure),t.webPlayerLoader&&(this._webPlayerLoader=t.webPlayerLoader),t.shakaPlayerLoader&&(this._shakaPlayerLoader=t.shakaPlayerLoader),t.hlsJsLoader&&(this._hlsJsLoader=t.hlsJsLoader)}}},{key:"dispose",value:function(){var t;e._initialized.value=!1,null===(t=this._applicationActivityMonitor)||void 0===t||t.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return be.getTelemetryUrl(e)}}])}();De=Ve,s()(Ve,"_automaticallyRetryOnFailure",Y.getBooleanValue("phenix-automatically-retry-on-failure")),s()(Ve,"_automaticallyReconnectPeerConnection",Y.getBooleanValue("phenix-automatically-reconnect-peer-connection")),s()(Ve,"_automaticallyPlayMediaStream",!0),s()(Ve,"_automaticallyMuteVideoOnPlayFailure",!0),s()(Ve,"_forceGarbageCollectionOnRestart",Y.getBooleanValue("phenix-force-garbage-collection-on-restart")),s()(Ve,"_skipGarbageCollectionOnMobileDevices",Y.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices")),s()(Ve,"_webPlayerLoader",void 0),s()(Ve,"_shakaPlayerLoader",void 0),s()(Ve,"_hlsJsLoader",void 0),s()(Ve,"_applicationActivityMonitor",void 0),s()(Ve,"_environment",new b("")),s()(Ve,"_telemetryUrl",new b("https://telemetry.phenixrts.com/telemetry")),s()(Ve,"_maximalNumberOfPeerConnectionReconnectAttempts",8),s()(Ve,"_telemetryLevel",new b(J.defaultTelemetryLevel)),s()(Ve,"_metricsService",void 0),s()(Ve,"_metricsConfiguration",void 0),s()(Ve,"_sendLocalCandidates",new b(L.sendLocalCandidates)),s()(Ve,"_tenancy",new b("")),s()(Ve,"_clientSessionId",te.random(32)),s()(Ve,"_loadedTimestamp",new Date),s()(Ve,"_logger",ee.getLogger("SDK")),s()(Ve,"_initialized",new b(!1)),s()(Ve,"_readOnlyInitialized",new C(De._initialized)),s()(Ve,"_readOnlyDiscoveryUri",new C(Se.uri)),s()(Ve,"_readOnlyPeerConnectionFactory",new C(_e.peerConnectionFactory)),S.subscribe(Ve.onLoad.bind(Ve));var Ge=function(){function e(n,r){t()(this,e),s()(this,"width",void 0),s()(this,"height",void 0),this.width=n,this.height=r}return o()(e,[{key:"equals",value:function(e){return e&&this.width===e.width&&this.height===e.height}},{key:"toString",value:function(){return"".concat(this.width,"x").concat(this.height)}}],[{key:"empty",get:function(){return new e(0,0)}}])}(),Be=function(){return o()(function e(){throw t()(this,e),new Error("GarbageCollectorManager is a static class that may not be instantiated")},null,[{key:"forceGarbageCollection",value:function(){O.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){O.isQueueMicrotaskSupported?P.value.queueMicrotask(this.overloadMemoryToInvokeGarbageCollection.bind(this)):P.value.setTimeout(this.overloadMemoryToInvokeGarbageCollection.bind(this),0)}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=P.value.documentCreateElement("img");e.src=P.value.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){P.value.URL.revokeObjectURL(this.src),e=null}}}])}(),Ue=function(e){return e[e.Initializing=0]="Initializing",e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Paused=3]="Paused",e[e.Playing=4]="Playing",e[e.Recovering=5]="Recovering",e[e.Reconnecting=6]="Reconnecting",e[e.StandBy=7]="StandBy",e[e.Stopped=8]="Stopped",e[e.Unauthorized=9]="Unauthorized",e[e.GeoRestricted=10]="GeoRestricted",e[e.GeoBlocked=11]="GeoBlocked",e[e.UnsupportedFeature=12]="UnsupportedFeature",e[e.ConfigurationError=13]="ConfigurationError",e[e.TransientConfigurationError=14]="TransientConfigurationError",e[e.ConnectionError=15]="ConnectionError",e[e.ClientStartError=16]="ClientStartError",e[e.Error=17]="Error",e}(Ue||{}),Ne=Ue,ze=function(){return o()(function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t()(this,e),s()(this,"_duration",void 0),this._duration=n},[{key:"toIsoString",value:function(){if(0===this._duration)return"P0S";var e=this._duration<0,t=e?Math.abs(this._duration):this._duration,n=Math.floor(t),r=n%1e3,i=(n=Math.floor(n/1e3))%60,o=(n=Math.floor(n/60))%60,a=(n=Math.floor(n/60))%24,s=["PT"];return e&&s.unshift("-"),a&&s.push(a+"H"),o&&s.push(o+"M"),(i||r)&&(s.push(String(i)),r&&s.push("."+this.padStart(r.toString(),3,"0")),s.push("S")),s.join("")}},{key:"padStart",value:function(e,t,n){return t|=0,n=String(void 0!==n?n:" "),e.length>t?e:((t-=e.length)>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}}])}(),He=function(){},qe=function(){return o()(function e(n,r,i,o){t()(this,e),s()(this,"_pageLoadTime",void 0),s()(this,"_channelStartTime",void 0),s()(this,"_logger",ee.getLogger("StreamTelemetry")),s()(this,"_disposables",new ie),s()(this,"_streamId",void 0),s()(this,"_metricsService",void 0),s()(this,"_listenToFirstTime",He),s()(this,"_listenForStall",He),s()(this,"_listenForContinuation",He),s()(this,"_timeToFirstFrame",0),s()(this,"_channelCreationTimeToFirstFrame",0),s()(this,"_startRecordingFirstFrame",0),s()(this,"_videoStalled",null),s()(this,"_lastProgress",0),s()(this,"_videoResolution",""),s()(this,"_clearTimeToFirstFrameListener",new m(function(){return null})),s()(this,"_clearRebufferingListener",new m(function(){return null})),this._streamId=n,this._pageLoadTime=r,this._channelStartTime=i,this._metricsService=o},[{key:"setupListenerForTimeToFirstTime",value:function(e){var t=this;this._startRecordingFirstFrame=Date.now(),this._listenToFirstTime=function(){return t.callTimeToFirstFrame()},e.addEventListener("loadeddata",this._listenToFirstTime),e.addEventListener("loadedmetadata",this._listenToFirstTime),this._clearTimeToFirstFrameListener=new m(function(){e.removeEventListener("loadeddata",t._listenToFirstTime),e.removeEventListener("loadedmetadata",t._listenToFirstTime)}),this._disposables.add(this._clearTimeToFirstFrameListener)}},{key:"setupListenerForRebuffering",value:function(e){var t=this;this._listenForStall=function(){return t.onStall()},this._listenForContinuation=function(n){return t.onContinuation(n,e)},e.addEventListener("stalled",this._listenForStall),e.addEventListener("pause",this._listenForStall),e.addEventListener("suspend",this._listenForStall),e.addEventListener("play",this._listenForContinuation),e.addEventListener("playing",this._listenForContinuation),e.addEventListener("progress",this._listenForContinuation),e.addEventListener("timeupdate",this._listenForContinuation),this._clearRebufferingListener=new m(function(){e.removeEventListener("stalled",t._listenForStall),e.removeEventListener("pause",t._listenForStall),e.removeEventListener("suspend",t._listenForStall),e.removeEventListener("play",t._listenForContinuation),e.removeEventListener("playing",t._listenForContinuation),e.removeEventListener("progress",t._listenForContinuation),e.removeEventListener("timeupdate",t._listenForContinuation)}),this._disposables.add(this._clearRebufferingListener)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"durationSincePageLoad",get:function(){var e=Date.now();return new ze(e-this._pageLoadTime).toIsoString()}},{key:"callTimeToFirstFrame",value:function(){var e=Date.now();this.pushTimeToFirstFrame(e),this.pushChannelCreationTimeToFirstFrame(e),this._clearTimeToFirstFrameListener.dispose()}},{key:"pushTimeToFirstFrame",value:function(e){this._timeToFirstFrame=e-this._startRecordingFirstFrame,this._metricsService.push({metricType:Ee.TimeToFirstFrame,runtime:(e-this._pageLoadTime)/1e3,value:{uint64:this._timeToFirstFrame},streamId:this._streamId}),this._logger.info("[%s] [%s] First frame [%s]",this.durationSincePageLoad,this._streamId,new ze(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:Ee.ChannelCreationTimeToFirstFrame,runtime:(e-this._pageLoadTime)/1e3,value:{uint64:this._channelCreationTimeToFirstFrame},streamId:this._streamId}),this._logger.info("[%s] [%s] Channel creation to first frame [%s]",this.durationSincePageLoad,this._streamId,new ze(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:Ee.Stalled,runtime:(Date.now()-this._pageLoadTime)/1e3,streamId:this._streamId}),this._videoStalled=Date.now(),this._logger.info("[%s] [%s] [buffering] Stream has stalled",this.durationSincePageLoad,this._streamId))}},{key:"onContinuation",value:function(e,t){if(t.buffered){var n=t.buffered.length,r=!("playing"===e.type||n>0)||("progress"===e.type||"timeupdate"===e.type)&&t.buffered.end(n-1)===this._lastProgress;if(this._videoStalled&&!r){"progress"===e.type&&(this._lastProgress=t.buffered.end(n-1));var i=Date.now()-this._videoStalled;this._metricsService.push({metricType:Ee.Buffering,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{uint64:i},streamId:this._streamId}),this._logger.info("[%s] [%s] [buffering] Stream has recovered from stall after [%s]",this.durationSincePageLoad,this._streamId,new ze(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:Ee.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}}])}(),We=function(){return o()(function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("StreamSetupListener")),s()(this,"metricsService",Ve.metricsService),s()(this,"_pageLoadTime",void 0),s()(this,"_startTime",void 0),s()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=n},[{key:"success",value:function(e){this.recordStreamMetric(Ee.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(Ee.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new Oe(e).getName();this.metricsService.push({metricType:e,runtime:(n-this._pageLoadTime)/1e3,value:{uint64:r},streamId:t}),this._logger.info("[%s] [%s] Stream metric [%s] in [%s]",new ze(n-this._pageLoadTime).toIsoString(),t,i,new ze(r).toIsoString())}}}])}(),Je=function(){return o()(function e(){t()(this,e),s()(this,"_disposables",new ie),s()(this,"_isSupported",void 0!==P.value.navigatorConnection),s()(this,"_rtt",new b(void 0)),s()(this,"_effectiveType",new b(void 0)),s()(this,"_downlinkThroughputCapacity",new b(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())},[{key:"isSupported",get:function(){return this._isSupported}},{key:"rtt",get:function(){return this._rtt}},{key:"effectiveType",get:function(){return this._effectiveType}},{key:"downlinkThroughputCapacity",get:function(){return this._downlinkThroughputCapacity}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"getDownlinkThroughputCapacity",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=P.value.navigatorConnection)||void 0===n?void 0:n.downlink)&&void 0!==t?t:null===(r=P.value.navigatorConnection)||void 0===r?void 0:r.downlinkMax)&&void 0!==e?e:-1}},{key:"getEffectiveType",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=P.value.navigatorConnection)||void 0===n?void 0:n.effectiveType)&&void 0!==t?t:null===(r=P.value.navigatorConnection)||void 0===r?void 0:r.type)&&void 0!==e?e:"Unknown"}},{key:"getRoundTripTime",value:function(){var e,t;return null!==(e=null===(t=P.value.navigatorConnection)||void 0===t?void 0:t.rtt)&&void 0!==e?e:-1}},{key:"setupNetworkChangeListeners",value:function(){var e,t=this,n=function(){return t.updateStatistics()};null===(e=P.value.navigatorConnection)||void 0===e||e.addEventListener("change",n),this._disposables.add(new m(function(){var e;return null===(e=P.value.navigatorConnection)||void 0===e?void 0:e.removeEventListener("change",n)}))}},{key:"updateStatistics",value:function(){this._rtt.value=this.getRoundTripTime(),this._effectiveType.value=this.getEffectiveType(),this._downlinkThroughputCapacity.value=this.getDownlinkThroughputCapacity()}}])}(),Ke=function(){return o()(function e(n,r){var i=this;if(t()(this,e),s()(this,"_logger",ee.getLogger("SessionTelemetry")),s()(this,"_metricsService",void 0),s()(this,"_applicationActivityMonitor",Ve.applicationActivityMonitor),s()(this,"_networkMonitor",new Je),s()(this,"_pageLoadTime",void 0),s()(this,"_disposables",new ie),s()(this,"_lastNetworkStatistics",{}),this._pageLoadTime=n,this._disposables.add(this._networkMonitor),this._metricsService=r,!this._applicationActivityMonitor)throw new Error("SessionTelemetry Failed: No application monitor initialized.");this._networkMonitor.isSupported&&(this._disposables.add(this._applicationActivityMonitor.isForeground.subscribe(function(e){i.recordForegroundChange(e)})),this._disposables.add(this._networkMonitor.rtt.subscribe(function(e){e&&i.recordNetworkRTTUpdate(e)})),this._disposables.add(this._networkMonitor.effectiveType.subscribe(function(e){e&&i.recordNetworkTypeChangeUpdate(e)})),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe(function(e){e&&i.recordNetworkDownlinkThroughputCapacityUpdate(e)})))},[{key:"listenOnStreamSetup",value:function(){return new We(this._pageLoadTime)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"recordForegroundChange",value:function(e){var t,n=Date.now(),r=null===(t=this._applicationActivityMonitor)||void 0===t?void 0:t.getTimeSinceLastChange();r&&(this._metricsService.push({metricType:e?Ee.ApplicationForeground:Ee.ApplicationBackground,runtime:(n-this._pageLoadTime)/1e3,value:{uint64:r}}),this._logger.info("Application has gone into the [%s] after [%s] ms",e?"foreground":"background",new ze(r).toIsoString()))}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:Ee.RoundTripTime,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:e},previousValue:n?{uint64:n}:void 0,resource:"navigator"}),this._logger.info("[%s] Network RTT changed to [%s] from [%s]",new ze(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkTypeChangeUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.effectiveType;this._lastNetworkStatistics.effectiveType=e,this._metricsService.push({metricType:Ee.NetworkType,runtime:(t-this._pageLoadTime)/1e3,value:{string:e},previousValue:n?{string:n}:void 0}),this._logger.info("[%s] Network effective type has changed to [%s] from [%s]",new ze(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkDownlinkThroughputCapacityUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.downlinkThroughputCapacity;this._lastNetworkStatistics.downlinkThroughputCapacity=e,this._metricsService.push({metricType:Ee.DownlinkThroughputCapacity,runtime:(t-this._pageLoadTime)/1e3,value:{float:e},previousValue:n?{float:n}:void 0}),this._logger.info("[%s] Network downlink throughput capacity changed to [%s] from [%s]",new ze(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),Qe=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Ze=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),$e=o()(function e(n){t()(this,e),s()(this,"token",void 0),s()(this,"tokenExpiring",void 0),this.token=new b(n),this.tokenExpiring=new b(!1)}),Xe=function(){return o()(function e(n){var r,i,o;t()(this,e),s()(this,"channelInitialization",void 0),s()(this,"disposables",void 0),s()(this,"channelDisposables",void 0),s()(this,"rendererDisposables",void 0),s()(this,"videoElement",void 0),s()(this,"state",void 0),s()(this,"exists",void 0),s()(this,"autoMuted",void 0),s()(this,"autoPaused",void 0),s()(this,"authorized",void 0),s()(this,"online",void 0),s()(this,"loading",void 0),s()(this,"playing",void 0),s()(this,"standby",void 0),s()(this,"stopped",void 0),s()(this,"targetLag",void 0),s()(this,"lag",void 0),s()(this,"bitrateLimit",void 0),s()(this,"resolution",void 0),s()(this,"failureCount",void 0),s()(this,"endPoint",void 0),s()(this,"onRealTimeSubscribeRequestCallback",void 0),s()(this,"onRealTimeSubscribeResponseCallback",void 0),s()(this,"stream",void 0),s()(this,"rtcStatistics",void 0),s()(this,"videoTelemetry",void 0),s()(this,"rtcAudioStatistic",void 0),s()(this,"rtcVideoStatistic",void 0),s()(this,"clearFailureCountTimeout",void 0),this.disposables=new ie,this.channelDisposables=new ie,this.rendererDisposables=new ie,this.channelInitialization=new Date,this.videoElement=new b(null),this.state=new b(Ne.Initializing),this.exists=new b(null),this.autoMuted=new b(!1),this.autoPaused=new b(!1),this.authorized=new b(!0),this.online=new b(!0),this.loading=new b(!1),this.playing=new b(!1),this.standby=new b(!1),this.stopped=new b(!1),this.targetLag=new b(null!==(r=null==n?void 0:n.targetLag)&&void 0!==r?r:0),this.lag=new b(void 0),this.bitrateLimit=new b(0),this.resolution=new b(Ge.empty),this.failureCount=new b(0),this.endPoint=new b(null),this.onRealTimeSubscribeRequestCallback=null!==(i=null==n?void 0:n.onRealTimeSubscribeRequestCallback)&&void 0!==i?i:null,this.onRealTimeSubscribeResponseCallback=null!==(o=null==n?void 0:n.onRealTimeSubscribeResponseCallback)&&void 0!==o?o:null,this.stream=new b(null),this.rtcStatistics=new b(null),this.videoTelemetry=null,this.rtcAudioStatistic=null,this.rtcVideoStatistic=null,this.clearFailureCountTimeout=0},[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":return this.authorized.value=!1,this.failureCount.value=0,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);case"no-stream":case"not-found":return this.failureCount.value=0,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null)}}},{key:"applySessionAndStreamPropertiesToVideoElement",value:function(){this.videoElement.value&&this.videoElement.value.dataset&&(this.videoElement.value.dataset.sessionId=Ve.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return Ne.Starting;case"no-stream":case"not-found":return Ne.StandBy;case"geo-restricted":return Ne.GeoRestricted;case"geo-blocked":return Ne.GeoBlocked;case"unauthorized":return Ne.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Ne.Recovering;case"forbidden-tag":return Ne.ConfigurationError;case"port-in-range-not-found":return Ne.TransientConfigurationError;case"failed":return Ne.Error;default:Z(e)}}},{key:"mapSubscribeStatusToExists",value:function(e){switch(e){case"ok":case"no-stream":case"geo-restricted":case"geo-blocked":case"forbidden-tag":case"port-in-range-not-found":return!0;case"not-found":return!1;case"unauthorized":case"timeout":case"rate-limited":case"capacity":case"failed":return this.exists.value;default:Z(e)}}}])}(),Ye=function(){return o()(function e(){throw t()(this,e),new Error("EncodedStreamSink is a static class that may not be instantiated")},null,[{key:"validateEncodedStreamSink",value:function(e,t){return"function"!=typeof t?{valid:!1,validationResult:"Unexpected ".concat(e," Encoded Stream Sink function type. Found [").concat(Te()(t),"]")}:2!==t.length?{valid:!1,validationResult:"Unexpected ".concat(e," Encoded Stream Sink function parameter length. Expected 2. Found [").concat(t.length,"]")}:{valid:!0,validationResult:"ok"}}}])}(),et=function(){return o()(function e(){t()(this,e)},null,[{key:"validateMediaStreamTrackTransform",value:function(e,t){return"function"!=typeof t?{valid:!1,validationResult:"Unexpected ".concat(e," Media Stream Track transform function type. Found [").concat(Te()(t),"]")}:3!==t.length?{valid:!1,validationResult:"Unexpected ".concat(e," Media Stream Track transform function parameter length. Expected 3. Found [").concat(t.length,"]")}:{valid:!0,validationResult:"ok"}}}])}(),tt=o()(function e(n){t()(this,e),s()(this,"hasInsertableStreams",void 0),s()(this,"hasEncodedInsertableStreams",void 0),s()(this,"videoStreamTransformCallback",void 0),s()(this,"audioStreamTransformCallback",void 0),s()(this,"encodedVideoStreamSink",void 0),s()(this,"encodedAudioStreamSink",void 0),s()(this,"audioTrack",void 0),s()(this,"videoTrack",void 0),this.hasInsertableStreams=new b(n.hasInsertableStreams),this.hasEncodedInsertableStreams=new b(n.hasEncodedInsertableStreams),this.videoStreamTransformCallback=n.videoStreamTransformCallback,this.audioStreamTransformCallback=n.audioStreamTransformCallback,this.encodedVideoStreamSink=n.encodedVideoStreamSink,this.encodedAudioStreamSink=n.encodedAudioStreamSink,this.audioTrack={mediaStreamTrack:null,receiver:null,mid:null,codec:null,transformPipelineWorker:null,transformMessageRouter:null,transformFunctionNames:[]},this.videoTrack={mediaStreamTrack:null,receiver:null,mid:null,codec:null,transformPipelineWorker:null,transformMessageRouter:null,transformFunctionNames:[]}}),nt=o()(function e(){t()(this,e),s()(this,"mediaStream",void 0),s()(this,"peerConnection",void 0),s()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new b(null),this.peerConnection=new b(null),this.peerConnectionReconnectAttempts=0}),rt=o()(function e(){t()(this,e),s()(this,"isStarting",void 0),s()(this,"isDisposed",void 0),this.isStarting=new b(!1),this.isDisposed=!1}),it=o()(function e(){t()(this,e),s()(this,"shouldExtractTimecode",void 0),s()(this,"shouldExtractTimestamps",void 0),s()(this,"isEnabled",void 0),s()(this,"decodedFrameTimingInformation",void 0),s()(this,"renderedFrameTimingInformation",void 0),this.shouldExtractTimecode=new b(!1),this.shouldExtractTimestamps=new b(!1),this.isEnabled=new b(!1),this.decodedFrameTimingInformation=new b(null),this.renderedFrameTimingInformation=new b(null)}),ot=n(715),at=n.n(ot),st=function(){return o()(function e(n){t()(this,e),s()(this,"_sdp",void 0),s()(this,"_audioCodec",void 0),s()(this,"_videoCodec",void 0),s()(this,"_isAudioTrackEnabled",void 0),s()(this,"_isVideoTrackEnabled",void 0),this._sdp=n;var r=this._sdp.split(/(\r\n|\r|\n)/),i=this._sdp.split(/(?:^|[\r\n])m=/);this._audioCodec=this.applyCodec("audio",r),this._videoCodec=this.applyCodec("video",r),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",i),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",i)},[{key:"audioCodec",get:function(){return this._audioCodec}},{key:"videoCodec",get:function(){return this._videoCodec}},{key:"isAudioTrackEnabled",get:function(){return this._isAudioTrackEnabled}},{key:"isVideoTrackEnabled",get:function(){return this._isVideoTrackEnabled}},{key:"isTrackByTypeEnabled",value:function(e,t){var n=t.find(function(t){return t.startsWith(e)});return!!n&&!n.includes("a=inactive")}},{key:"applyCodec",value:function(e,t){var n,r=(null===(n=t.find(function(t){return t.includes("m=".concat(e))}))||void 0===n?void 0:n.split(" ")[3])||"",i=t.find(function(e){return e.includes("a=rtpmap:".concat(r))});return((null==i?void 0:i.split(" ")[1])||"").split("/")[0]}}])}(),ut=function(){return o()(function e(){throw t()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")},null,[{key:"truncateIceServers",value:function(e){var t=[];if(!e.iceServers)return e;for(var n=0;n<e.iceServers.length;n++){for(var r=[],i=0;i<2;i++)e.iceServers[n].urls[i]&&r.push(e.iceServers[n].urls[i]);t.push({urls:r,username:e.iceServers[n].username,credential:e.iceServers[n].credential})}return e.iceServers=t,e}}])}(),ct=n(981).A;function lt(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return dt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(dt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,dt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,dt(d,"constructor",c),dt(c,"constructor",u),u.displayName="GeneratorFunction",dt(c,i,"GeneratorFunction"),dt(d),dt(d,i,"Generator"),dt(d,r,function(){return this}),dt(d,"toString",function(){return"[object Generator]"}),(lt=function(){return{w:o,m:h}})()}function dt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}dt=function(e,t,n,r){function o(t,n){dt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},dt(e,t,n,r)}var ht=function(){return o()(function e(n,r,i,o){var a=this;if(t()(this,e),s()(this,"_logger",ee.getLogger("RtcConnectionMonitor")),s()(this,"_estimatedRoundTripTime",void 0),s()(this,"_estimatedVideoCodec","unknown"),s()(this,"_estimatedAudioCodec","unknown"),s()(this,"_rtcStatistic",new b({})),s()(this,"_disposables",new ie),s()(this,"_peerConnection",void 0),s()(this,"_isMonitorRunning",!0),s()(this,"_updateTimeout",null),s()(this,"_tracksToMonitor",void 0),s()(this,"_monitorGeneration",0),this._peerConnection=n,this._estimatedRoundTripTime=i,this._tracksToMonitor=r.getTracks().map(function(e){return e.kind})||[],this._peerConnection){var u,c;if(!O.getCurrentOfferDisabled&&null!==(u=this._peerConnection)&&void 0!==u&&null!==(c=u.currentRemoteDescription)&&void 0!==c&&c.sdp){var l=new st(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=l.audioCodec,this._estimatedVideoCodec=l.videoCodec}var d=!0;this._disposables.add(o.subscribe(function(e){d?d=!1:e&&a._isMonitorRunning&&(a._monitorGeneration++,a._updateTimeout&&(P.value.clearTimeout(a._updateTimeout),a._updateTimeout=null),a._logger.debug("Restarting stats polling after foreground transition"),a.updateStatistic())})),this.updateStatistic()}},[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._monitorGeneration++,this._isMonitorRunning=!1,this._peerConnection=null,this._disposables.dispose(),this._updateTimeout&&(P.value.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(n=V()(lt().m(function e(){var t,n,r,i,o,a,s,u,c,l,d,h=this;return lt().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!O.getStatsPromiseBasedDisabled){e.n=1;break}return e.a(2,this.updateStatisticLegacy());case 1:if(t=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},n=this._monitorGeneration,e.p=2,o=null===(i=this._peerConnection)||void 0===i?void 0:i.getStats(null)){e.n=3;break}return e.a(2);case 3:return a=new ct(function(e){r=P.value.setTimeout(function(){return e(null)},5e3)}),e.n=4,ct.race([o,a]);case 4:if(s=e.v,n===this._monitorGeneration&&this._isMonitorRunning){e.n=5;break}return e.a(2);case 5:s?(u={},c=this._estimatedRoundTripTime,s.forEach(function(e){if("candidate-pair"===e.type&&e.currentRoundTripTime&&(c=1e3*e.currentRoundTripTime,u.audio&&(u.audio.roundTripTime=c),u.video&&(u.video.roundTripTime=c)),"candidate-pair"===e.type&&e.lastPacketReceivedTimestamp&&(l=e.lastPacketReceivedTimestamp,u.audio&&(u.audio.lastPacketReceivedTimestamp=l),u.video&&(u.video.lastPacketReceivedTimestamp=l)),"inbound-rtp"===e.type){var n=e.kind||e.mediaType||t(e),r="";if(s.forEach(function(t){t.id===e.codecId&&(r=t.mimeType)}),n&&h._tracksToMonitor.includes(n)){var i,o,a,d,f,p,v,m=(e.bytesReceived||0)-(null!==(i=null===(o=h._rtcStatistic.value)||void 0===o||null===(a=o[n])||void 0===a?void 0:a.bytesReceived)&&void 0!==i?i:0),g=e.timestamp-((null===(d=h._rtcStatistic.value)||void 0===d||null===(f=d[n])||void 0===f?void 0:f.timestamp)||0),y=m&&g?Math.floor(8*m/g*1e3):0;if(u[n]={ssrc:e.ssrc,mediaType:n,timestamp:e.timestamp,bitrate:y,bytesReceived:e.bytesReceived,packetsLost:e.packetsLost,packetsReceived:e.packetsReceived,codec:r||h.getCodecByType(n),roundTripTime:c},(e.lastPacketReceivedTimestamp||l)&&(u[n].lastPacketReceivedTimestamp=e.lastPacketReceivedTimestamp||l),"video"===n&&null!==(p=h._rtcStatistic.value)&&void 0!==p&&null!==(v=p.video)&&void 0!==v&&v.framesDecoded){u[n].framesDecoded=e.framesDecoded;var _=(e.framesDecoded-h._rtcStatistic.value.video.framesDecoded)/(u[n].timestamp-h._rtcStatistic.value.video.timestamp)*1e3;u[n].fps=_?Math.round(100*_)/100:0}}}}),this._rtcStatistic.value=u):this._logger.debug("getStats() timed out, skipping stats processing"),e.n=8;break;case 6:if(e.p=6,d=e.v,n===this._monitorGeneration&&this._isMonitorRunning){e.n=7;break}return e.a(2);case 7:this._logger.warn("getStats() rejected",d);case 8:return e.p=8,P.value.clearTimeout(r),e.f(8);case 9:this._isMonitorRunning&&n===this._monitorGeneration&&(this._updateTimeout=P.value.setTimeout(function(){return h.updateStatistic()},1e3));case 10:return e.a(2)}},e,this,[[2,6,8,9]])})),function(){return n.apply(this,arguments)})},{key:"updateStatisticLegacy",value:(e=V()(lt().m(function e(){var t,n,r,i,o,a,s,u,c,l=this;return lt().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=this._monitorGeneration,e.p=1,i=null===(r=this._peerConnection)||void 0===r?void 0:r.getStatsLegacy()){e.n=2;break}return e.a(2);case 2:return o=new ct(function(e){n=P.value.setTimeout(function(){return e(null)},5e3)}),e.n=3,ct.race([i,o]);case 3:if(a=e.v,t===this._monitorGeneration&&this._isMonitorRunning){e.n=4;break}return e.a(2);case 4:a?(s={},u=this._estimatedRoundTripTime,a.result().forEach(function(e){if(e.names().forEach(function(t){"googRTT"===t&&(u=e.stat(t))}),"ssrc"===e.type){var t,n,r=e.stat("mediaType").toString();s[r]={timestamp:Date.now()},s[r].ssrc=e.stat("ssrc").toString(),s[r].mediaType=r,s[r].bytesReceived=e.stat("bytesReceived"),s[r].packetsLost=e.stat("packetsLost"),s[r].packetsReceived=e.stat("packetsReceived"),s[r].codec=e.stat("googCodecName").toString()||l.getCodecByType(r),s[r].roundTripTime=u,"video"===r&&null!==(t=l._rtcStatistic.value)&&void 0!==t&&null!==(n=t.video)&&void 0!==n&&n.framesDecoded&&(s[r].framesDecoded=e.stat("framesDecoded"),s[r].fps=(s[r].framesDecoded-l._rtcStatistic.value.video.framesDecoded)/(s[r].timestamp-l._rtcStatistic.value.video.timestamp)*1e3||0)}}),this._rtcStatistic.value=s):this._logger.debug("getStatsLegacy() timed out, skipping stats processing"),e.n=7;break;case 5:if(e.p=5,c=e.v,t===this._monitorGeneration&&this._isMonitorRunning){e.n=6;break}return e.a(2);case 6:this._logger.warn("getStatsLegacy() rejected",c);case 7:return e.p=7,P.value.clearTimeout(n),e.f(7);case 8:this._isMonitorRunning&&t===this._monitorGeneration&&(this._updateTimeout=P.value.setTimeout(function(){return l.updateStatistic()},1e3));case 9:return e.a(2)}},e,this,[[1,5,7,8]])})),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec||"unknown";case"video":return this._estimatedVideoCodec||"unknown";default:return"unknown"}}}]);var e,n}(),ft=n(847),pt=n.n(ft),vt=function(){return o()(function e(){t()(this,e)},null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Ze.Normal:return"Normal";case Ze.Force:return"Force";case Ze.Reset:return"Reset";default:Z(e)}}}])}(),mt=function(){return o()(function e(){t()(this,e)},null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Qe.Keep:return"Keep";case Qe.Reset:return"Reset";default:Z(e)}}}])}(),gt=n(981).A,yt=["status","streamId","sharedSecret","lag","rtcConfiguration","setRemoteDescriptionResponse","createAnswerDescriptionResponse","createOfferDescriptionResponse"];function _t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function bt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_t(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_t(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ct(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return kt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(kt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,kt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,kt(d,"constructor",c),kt(c,"constructor",u),u.displayName="GeneratorFunction",kt(c,i,"GeneratorFunction"),kt(d),kt(d,i,"Generator"),kt(d,r,function(){return this}),kt(d,"toString",function(){return"[object Generator]"}),(Ct=function(){return{w:o,m:h}})()}function kt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}kt=function(e,t,n,r){function o(t,n){kt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},kt(e,t,n,r)}var St=function(){return o()(function e(n,r){if(t()(this,e),s()(this,"_logger",ee.getLogger("EndPoint")),s()(this,"_uri",void 0),s()(this,"_timeout",void 0),s()(this,"_roundTripTime",0),this._uri=n,this._timeout=r,!r)throw new Error("End point requires a timeout")},[{key:"roundTripTime",get:function(){return this._roundTripTime}},{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:(m=V()(Ct().m(function e(){var t,n,r,i,o=this;return Ct().w(function(e){for(;;)switch(e.n){case 0:return t=this.buildPingUrl(),n=Date.now(),e.n=1,gt.race([P.value.fetch(t,{method:"GET",cache:"no-cache"}),new gt(function(e,n){return P.value.setTimeout(function(){return n(new Error("Ping timed out [".concat(t,"]")))},o._timeout)})]);case 1:if(r=e.v,i=Date.now(),r.ok){e.n=2;break}throw new Error("Ping failed [".concat(t,"] [").concat(r.status,"]"));case 2:return this._roundTripTime=i-n,e.a(2,this._roundTripTime)}},e,this)})),function(){return m.apply(this,arguments)})},{key:"subscribe",value:(v=V()(Ct().m(function e(t,n,r){var i,o,a,s,u,c,l,d,h,f,p,v,m,g,y,_,b,C=this,k=arguments;return Ct().w(function(e){for(;;)switch(e.p=e.n){case 0:if(a=k.length>3&&void 0!==k[3]?k[3]:{},s=re.parseToken(t).tenancy){e.n=1;break}return this._logger.error("Failed to parse token [%s]",t),e.a(2,{status:"unauthorized"});case 1:return u=this.buildUrl([s,"stream","subscribe"]).toString(),c=new P.value.FormData,l=B.sdkVersion,d=0===r&&n?{apiVersion:7,clientVersion:l,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:7,sessionDescription:{type:n.type,sdp:n.sdp}},createAnswerDescription:{apiVersion:7}}:{apiVersion:7,clientVersion:l,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:7}},e.n=2,null===(i=a.onSubscribeRequestCallback)||void 0===i?void 0:i.call(a,d);case 2:return c.append("jsonBody",JSON.stringify(d)),h=Date.now(),e.p=3,p=null,e.n=4,gt.race([P.value.fetch(u,{method:"POST",body:c}),new gt(function(e){return p=P.value.setTimeout(function(){C._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(u,"]"))),e({status:408})},C._timeout)})]).finally(function(){p&&P.value.clearTimeout(p)});case 4:f=e.v,e.n=6;break;case 5:return e.p=5,b=e.v,this._logger.error("Failed to subscribe",b),e.a(2,{status:"failed"});case 6:if("ok"===(v=this.mapHttpStatusToSubscribeStatus(f))){e.n=8;break}return g={status:v},e.n=7,null===(m=a.onSubscribeResponseCallback)||void 0===m?void 0:m.call(a,g);case 7:return e.a(2,g);case 8:return y=Date.now(),e.n=9,this.convertHttpResponseToSubscribeResponse(s,f);case 9:return _=e.v,this._logger.debug("Got subscribe response [%j] in [%s] ms",_,y-h),e.n=10,null===(o=a.onSubscribeResponseCallback)||void 0===o?void 0:o.call(a,_);case 10:return e.a(2,_)}},e,this,[[3,5]])})),function(e,t,n){return v.apply(this,arguments)})},{key:"publish",value:(p=V()(Ct().m(function e(t,n,r,i){var o,a,s,u,c,l,d,h,f,p,v,m,g,y=this;return Ct().w(function(e){for(;;)switch(e.p=e.n){case 0:if(o=re.parseToken(n).tenancy){e.n=1;break}return this._logger.error("Failed to parse token [%s]",n),e.a(2,{status:"unauthorized"});case 1:return a=this.buildUrl([o,"stream","publish"]).toString(),s=new P.value.FormData,u=B.sdkVersion,0===i&&r?(c={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:7,sessionDescription:{type:r.type,sdp:r.sdp}},createAnswerDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(c))):(l={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(l))),d=Date.now(),e.p=2,f=null,e.n=3,gt.race([P.value.fetch(a,{method:"POST",body:s}),new gt(function(e){return f=P.value.setTimeout(function(){y._logger.error("Failed to publish",new Error("Publish timed out [".concat(a,"]"))),e({status:408})},y._timeout)})]).finally(function(){f&&P.value.clearTimeout(f)});case 3:h=e.v,e.n=5;break;case 4:return e.p=4,g=e.v,this._logger.error("Failed to publish",g),e.a(2,{status:"failed"});case 5:if("ok"===(p=this.mapHttpStatusToPublishStatus(h))){e.n=6;break}return e.a(2,{status:p});case 6:return v=Date.now(),e.n=7,this.convertHttpResponseToPublishResponse(o,h);case 7:return m=e.v,this._logger.debug("Got publish response [%j] in [%s] ms",m,v-d),e.a(2,m)}},e,this,[[2,4]])})),function(e,t,n,r){return p.apply(this,arguments)})},{key:"setRemoteDescription",value:(f=V()(Ct().m(function e(t,n){var r,i,o,a,s,u,c,l,d,h,f=this;return Ct().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new P.value.FormData,o={apiVersion:7,sharedSecret:null==t?void 0:t.sharedSecret,sessionDescription:{type:n.type,sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.p=1,u=null,e.n=2,gt.race([P.value.fetch(r,{method:"POST",body:i}),new gt(function(e){return u=P.value.setTimeout(function(){f._logger.error("Failed to set remote description",new Error("Set remote description timed out [".concat(r,"]"))),e({status:408})},f._timeout)})]).finally(function(){u&&P.value.clearTimeout(u)});case 2:s=e.v,e.n=4;break;case 3:return e.p=3,h=e.v,this._logger.error("Failed to set remote description",h),e.a(2,{status:"failed"});case 4:if("ok"===(c=this.mapHttpStatusToSetRemoteDescriptionStatus(s))){e.n=5;break}return e.a(2,{status:c});case 5:return l=Date.now(),e.n=6,this.convertHttpResponseToSetRemoteDescriptionResponse(s);case 6:return d=e.v,this._logger.debug("Got set remote description response [%j] in [%s] ms",d,l-a),e.a(2,d)}},e,this,[[1,3]])})),function(e,t){return f.apply(this,arguments)})},{key:"limitBitrate",value:(h=V()(Ct().m(function e(t,n,r,i,o){var a,s,u,c,l,d,h,f,p,v=this;return Ct().w(function(e){for(;;)switch(e.p=e.n){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new P.value.FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:mt.convertBitrateStateToBitrateStateType(i),bitrateMode:vt.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.p=1,d=null,e.n=2,gt.race([P.value.fetch(a,{method:"POST",body:s}),new gt(function(e){return d=P.value.setTimeout(function(){v._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(a,"]"))),e({status:408})},v._timeout)})]).finally(function(){d&&P.value.clearTimeout(d)});case 2:l=e.v,e.n=4;break;case 3:return e.p=3,p=e.v,this._logger.error("Failed to set limit bitrate timed",p),e.a(2,{status:"failed"});case 4:return h=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),f=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",h,f-c),e.a(2,{status:h})}},e,this,[[1,3]])})),function(e,t,n,r,i){return h.apply(this,arguments)})},{key:"addIceCandidates",value:(d=V()(Ct().m(function e(t,n,r){var i,o,a,s,u,c,l,d,h,f,p,v=this,m=arguments;return Ct().w(function(e){for(;;)switch(e.p=e.n){case 0:return i=m.length>3&&void 0!==m[3]?m[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),a=new P.value.FormData,s={apiVersion:7,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},a.append("jsonBody",JSON.stringify(s)),u=Date.now(),e.p=1,l=null,e.n=2,gt.race([P.value.fetch(o,{method:"POST",body:a}),new gt(function(e){return l=P.value.setTimeout(function(){v._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(o,"]"))),e({status:408})},v._timeout)})]).finally(function(){l&&P.value.clearTimeout(l)});case 2:c=e.v,e.n=4;break;case 3:return e.p=3,p=e.v,this._logger.error("Failed to add ice candidates",p),e.a(2,{status:"failed"});case 4:if("ok"===(d=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.n=5;break}return e.a(2,{status:d});case 5:return h=Date.now(),e.n=6,this.convertHttpResponseToAddIceCandidatesResponse(c);case 6:return f=e.v,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",f,h-u),e.a(2,f)}},e,this,[[1,3]])})),function(e,t,n){return d.apply(this,arguments)})},{key:"destroyStream",value:(l=V()(Ct().m(function e(t,n){var r,i,o,a,s,u,c,l,d,h,f=this;return Ct().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new P.value.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.p=1,u=null,e.n=2,gt.race([P.value.fetch(r,{method:"POST",body:i,cache:"no-cache"}),new gt(function(e){return u=P.value.setTimeout(function(){f._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})},f._timeout)})]).finally(function(){u&&P.value.clearTimeout(u)});case 2:s=e.v,e.n=4;break;case 3:return e.p=3,h=e.v,this._logger.error("Failed to delete stream",h),e.a(2,{status:"failed"});case 4:if("ok"===(c=this.mapHttpStatusToSetDestroyStreamStatus(s))){e.n=5;break}return e.a(2,{status:c});case 5:return l=Date.now(),e.n=6,this.convertHttpResponseToDestroyStreamResponse(s);case 6:return d=e.v,this._logger.info("Got destroy stream response [%j] in [%s] ms",d,l-a),e.a(2,d)}},e,this,[[1,3]])})),function(e,t){return l.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(u=V()(Ct().m(function e(t,n){var r,i,o,a;return Ct().w(function(e){for(;;)switch(e.n){case 0:null!==(r=navigator)&&void 0!==r&&r.sendBeacon||this.destroyStream(t,n),i=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),o=new P.value.FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},o.append("jsonBody",JSON.stringify(a)),navigator.sendBeacon(i,o);case 1:return e.a(2)}},e,this)})),function(e,t){return u.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new P.value.URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,c()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new P.value.URL(this._uri),t=B.sdkVersion,n=ke.discoveryParameters.intentions;return e.searchParams.set("type","http"),e.searchParams.set("version",t),e.searchParams.set("intentions",n),e.searchParams.set("_","".concat(Date.now())),e.toString()}},{key:"mapHttpStatusToPublishStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 406:return"missing-channel-or-room-id";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSubscribeStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetRemoteDescriptionStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetTemporaryMaximalBitrateStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToAddIceCandidatesStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetDestroyStreamStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"convertHttpResponseToSubscribeResponse",value:(a=V()(Ct().m(function e(t,n){var r,i,o,a,s,u,c,l,d,h,f;return Ct().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,n.json();case 1:return r=e.v,i=r.status,o=r.streamId,a=r.sharedSecret,s=r.lag,u=r.rtcConfiguration,c=r.setRemoteDescriptionResponse,l=r.createAnswerDescriptionResponse,d=r.createOfferDescriptionResponse,h=pt()(r,yt),f=bt({status:i,stream:{tenancy:t,streamId:o,sharedSecret:a},lag:s},h),u&&(f.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(u)),null!=c&&c.sessionDescription&&(f.setRemoteDescriptionResponse={sessionDescription:c.sessionDescription}),null!=l&&l.sessionDescription&&(f.createAnswerDescriptionResponse={sessionDescription:l.sessionDescription}),null!=d&&d.sessionDescription&&(f.createOfferDescriptionResponse={sessionDescription:d.sessionDescription}),e.a(2,f)}},e,this)})),function(e,t){return a.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(i=V()(Ct().m(function e(t,n){var r,i;return Ct().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,n.json();case 1:return r=e.v,i={status:r.status,stream:{tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret}},r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.a(2,i)}},e,this)})),function(e,t){return i.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={iceServers:[]};if(e.bundlePolicy&&(t.bundlePolicy=e.bundlePolicy),"number"==typeof e.iceCandidatePoolSize&&(t.iceCandidatePoolSize=e.iceCandidatePoolSize),e.iceServers){for(var n=[],r=0;r<e.iceServers.length;r++)n.push({urls:e.iceServers[r].urls,username:e.iceServers[r].username,credential:e.iceServers[r].credential});t.iceServers=n}return e.iceTransportPolicy&&(t.iceTransportPolicy=e.iceTransportPolicy),e.rtcpMuxPolicy&&(t.rtcpMuxPolicy=e.rtcpMuxPolicy),t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(r=V()(Ct().m(function e(t){var n,r;return Ct().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.json();case 1:return n=e.v,r={status:n.status},n&&n.sessionDescription&&(r.sessionDescription=n.sessionDescription),e.a(2,r)}},e)})),function(e){return r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(n=V()(Ct().m(function e(t){var n,r;return Ct().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.json();case 1:return n=e.v,r={status:n.status,options:[]},n&&n.options&&(r.options=n.options),e.a(2,r)}},e)})),function(e){return n.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(e=V()(Ct().m(function e(t){var n,r;return Ct().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.json();case 1:return n=e.v,r={status:n.status},e.a(2,r)}},e)})),function(t){return e.apply(this,arguments)})}]);var e,n,r,i,a,u,l,d,h,f,p,v,m}(),wt=n(981).A;function Tt(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return xt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(xt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,xt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,xt(d,"constructor",c),xt(c,"constructor",u),u.displayName="GeneratorFunction",xt(c,i,"GeneratorFunction"),xt(d),xt(d,i,"Generator"),xt(d,r,function(){return this}),xt(d,"toString",function(){return"[object Generator]"}),(Tt=function(){return{w:o,m:h}})()}function xt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}xt=function(e,t,n,r){function o(t,n){xt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},xt(e,t,n,r)}var Pt=function(){return o()(function e(n){if(t()(this,e),s()(this,"_logger",ee.getLogger("Discovery")),s()(this,"_metricsService",void 0),s()(this,"_uri",void 0),!n)throw new Error("Discovery requires uri");this._metricsService=je.getMetricsService(n.toString()),this._uri=n},[{key:"discoverNearbyEndPoints",value:(n=V()(Tt().m(function e(t,n){var r,i,o,a;return Tt().w(function(e){for(;;)switch(e.n){case 0:if(n){e.n=1;break}throw new Error("Discovery requires timeout");case 1:return r=t.toString(),e.n=2,wt.race([P.value.fetch(r,{method:"GET",cache:"no-cache"}),new wt(function(e,t){return P.value.setTimeout(function(){return t(new Error("Discovery timed out [".concat(r,"]")))},n)})]);case 2:if((i=e.v).ok){e.n=3;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 3:if(null!==i.body){e.n=4;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 4:return e.n=5,i.text();case 5:return o=e.v,a=o.split(","),e.a(2,a.map(function(e){return new St(e,n)}))}},e)})),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=V()(Tt().m(function e(){var t,n,r,i,o,a,s=this,u=arguments;return Tt().w(function(e){for(;;)switch(e.n){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=Se.buildDiscoveryUrl(this._uri),e.n=1,this.discoverNearbyEndPoints(new P.value.URL(n),t);case 1:return r=e.v,i=0,o=function(){return new wt(function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))})},e.n=2,wt.race(r.map(function(e){return e.ping().catch(function(t){return s._logger.warn("Failed to ping end point [%s]",e,t),i++,o()}).then(function(t){var n=Date.now();return s._logger.info("Discovered end point [%s] with time [%s]",e.toString(),t),s._metricsService.push({metricType:Ee.RoundTripTime,runtime:(n-Ve.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e})}));case 2:return a=e.v,e.a(2,a)}},e,this)})),function(){return e.apply(this,arguments)})}]);var e,n}(),Et=n(981).A;function Ot(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return Rt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Rt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Rt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,Rt(d,"constructor",c),Rt(c,"constructor",u),u.displayName="GeneratorFunction",Rt(c,i,"GeneratorFunction"),Rt(d),Rt(d,i,"Generator"),Rt(d,r,function(){return this}),Rt(d,"toString",function(){return"[object Generator]"}),(Ot=function(){return{w:o,m:h}})()}function Rt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Rt=function(e,t,n,r){function o(t,n){Rt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},Rt(e,t,n,r)}var Ft=function(){function e(){throw t()(this,e),new Error("Discovery is a static class that may not be instantiated")}return o()(e,null,[{key:"precacheClosestEndPointDiscovery",value:(r=V()(Ot().m(function t(){return Ot().w(function(t){for(;;)if(0===t.n)return t.a(2,new Et(function(t){var n=P.subscribe(function(r){if(r){var i=new r.URL(Ve.discoveryUri.value);return e.discoverClosestEndPointWithCaching(i).then(t).then(function(){return n.dispose()})}})}))},t)})),function(){return r.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(n=V()(Ot().m(function t(n){var r,i,o;return Ot().w(function(t){for(;;)switch(t.n){case 0:if(!((r=n.toString())in e._cache)){t.n=1;break}return t.a(2,e._cache[r]);case 1:return i=new Pt(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then(function(){P.value.setTimeout(function(){e._cache[r]===o&&delete e._cache[r]},6e4)}).catch(function(){delete e._cache[r]}),t.a(2,o)}},t)})),function(e){return n.apply(this,arguments)})},{key:"clearCachedClosestEndpoint",value:function(t){var n=t.toString();n in e._cache&&delete e._cache[n]}}]);var n,r}();s()(Ft,"_cache",{}),Ft.precacheClosestEndPointDiscovery();var It=function(e){return e[e.H264=0]="H264",e[e.VP8=1]="VP8",e[e.VP9=2]="VP9",e}({}),Lt=function(e){return e[e.Error=-1]="Error",e[e.AddTransform=0]="AddTransform",e[e.ConfigurePipeline=1]="ConfigurePipeline",e[e.Metadata=2]="Metadata",e[e.Chunk=3]="Chunk",e[e.PipelineConfigured=4]="PipelineConfigured",e}({}),Dt=function(e){return e[e.FrameTimingInformation=0]="FrameTimingInformation",e[e.EncodedVideoChunk=1]="EncodedVideoChunk",e[e.EncodedAudioChunk=2]="EncodedAudioChunk",e[e.SurrogateVideoChunk=3]="SurrogateVideoChunk",e[e.SurrogateAudioChunk=4]="SurrogateAudioChunk",e}({});function At(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function jt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?At(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):At(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Mt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var Vt=function(){function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("FrameTimingInformationManager")),s()(this,"_decodedFrameTimingInformationByRtpTimestamp",new Map),s()(this,"_videoElementDisposables",new ie),s()(this,"_disposables",new ie),s()(this,"_currentPlaybackState","waiting"),s()(this,"_armedVideoFrameCallbackId",null),s()(this,"_disposed",!1),this.initialize(n)}return o()(e,[{key:"dispose",value:function(){this._disposed=!0,this._disposables.dispose()}},{key:"initialize",value:function(e){this.canProcessFrameTimingInformation(e.streamId,e.codec,e.receiver,e.mid)&&(this.setupVideoElementHandling(e.videoElement,e.renderedFrameTimingInformationSubject),this.setupFrameTimingInformationTransform(e.codec,e.mid,e.trackId,e.transformMessageRouter,e.transformFunctionNames,e.decodedFrameTimingInformationSubject),e.isEnabledSubject.value=!0)}},{key:"canProcessFrameTimingInformation",value:function(e,t,n,r){return t!==It.H264?(this._logger.warn("[%s] Skipping frame timing information for video track because video codec is not H264",e),!1):n?!!r||(this._logger.warn("[%s] Skipping frame timing information for video track because no mid was found",e),!1):(this._logger.warn("[%s] Skipping frame timing information for video track because no receiver was found",e),!1)}},{key:"setupFrameTimingInformationTransform",value:function(t,n,r,i,o,a){i.registerRoute(Dt.FrameTimingInformation,this.handleFrameTimingMessage.bind(this,It[t],n,r,a)),o.push(e._transformName)}},{key:"handleFrameTimingMessage",value:function(e,t,n,r,i){if(i)for(var o=0,a=Object.entries(i);o<a.length;o++){var s=at()(a[o],2),u=s[0],c=s[1],l=parseInt(u,10),d=c.decodedFrameTimingInformation;if(d){var h,f,p={timecode:null!==(h=d.timecode)&&void 0!==h?h:null,receiveTimestamp:null!==(f=d.receiveTimestamp)&&void 0!==f?f:null,kind:"video",codec:e,mid:t,trackId:n,sourceTimestamp:null,ingestTimestamp:null,encodeTimestamp:null,transcodeTimestamp:null,playbackState:this._currentPlaybackState};r.value=p,"playing"===this._currentPlaybackState&&this._decodedFrameTimingInformationByRtpTimestamp.set(l,p)}}}},{key:"setupVideoElementHandling",value:function(e,t){var n=this;this._disposables.add(new m(function(){return n._decodedFrameTimingInformationByRtpTimestamp.clear()})),this._disposables.add(this._videoElementDisposables),this._disposables.add(e.subscribe(function(e){n._videoElementDisposables.dispose(),e&&n.setupVideoEventListeners(e,t)}))}},{key:"handleVideoFrameCallback",value:function(e,t,n,r){if(!this._disposed){this._armVideoFrameCallback(e,t);var i=r.rtpTimestamp;if(i){var o,a=[],s=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Mt(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Mt(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(this._decodedFrameTimingInformationByRtpTimestamp);try{for(s.s();!(o=s.n()).done;){var u=at()(o.value,2),c=u[0],l=u[1];if(c>i)break;t.value=jt(jt({},l),{},{renderTimestamp:new Date(performance.timeOrigin+n),playbackState:"playing"}),a.push(c)}}catch(e){s.e(e)}finally{s.f()}for(var d=0,h=a;d<h.length;d++){var f=h[d];this._decodedFrameTimingInformationByRtpTimestamp.delete(f)}}}}},{key:"setupVideoEventListeners",value:function(e,t){var n=this,r=function(){return n._currentPlaybackState="playing"};e.addEventListener("playing",r),this._videoElementDisposables.add(new m(function(){return e.removeEventListener("playing",r)}));var i=function(){return n._currentPlaybackState="paused"};e.addEventListener("pause",i),this._videoElementDisposables.add(new m(function(){return e.removeEventListener("pause",i)}));var o=function(){return n._currentPlaybackState="stalled"};e.addEventListener("stalled",o),this._videoElementDisposables.add(new m(function(){return e.removeEventListener("stalled",o)}));var a=function(){return n._currentPlaybackState="waiting"};e.addEventListener("waiting",a),this._videoElementDisposables.add(new m(function(){return e.removeEventListener("waiting",a)}));var s=function(){return n._currentPlaybackState="ended"};e.addEventListener("ended",s),this._videoElementDisposables.add(new m(function(){return e.removeEventListener("ended",s)}));var u=function(){return n._currentPlaybackState="error"};e.addEventListener("error",u),this._videoElementDisposables.add(new m(function(){return e.removeEventListener("error",u)})),this._armVideoFrameCallback(e,t),this._videoElementDisposables.add(new m(function(){n._armedVideoFrameCallbackId&&e.cancelVideoFrameCallback(n._armedVideoFrameCallbackId)}))}},{key:"_armVideoFrameCallback",value:function(e,t){e.requestVideoFrameCallback&&(this._armedVideoFrameCallbackId=e.requestVideoFrameCallback(this.handleVideoFrameCallback.bind(this,e,t)))}}])}();s()(Vt,"_transformName","frame-timing-information");var Gt=n(512),Bt=n.n(Gt);function Ut(){return Bt()('/*! For license information please see TransformStreamPipeline.worker.worker.js.LICENSE.txt */\n(()=>{var e={981:(e,t,r)=>{"use strict";r.d(t,{A:()=>p});var n=r(738),o=r.n(n),a=r(383),i=r.n(a),u=r(579),s=r.n(u),c=r(693),f=r.n(c),l=s()(function e(t,r,n){i()(this,e),f()(this,"onFulfilled",void 0),f()(this,"onRejected",void 0),f()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof r?r:null,this.promise=n}),d=function(){function e(t){if(i()(this,e),f()(this,"_state",void 0),f()(this,"_handled",void 0),f()(this,"_value",void 0),f()(this,"_deferreds",void 0),!(this instanceof e))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=null,this._deferreds=[],this.doResolve(t)}return s()(e,[{key:"doResolve",value:function(e){var t=this,r=!1;try{e(function(e){r||(r=!0,t.promiseResolve(e))},function(e){r||(r=!0,t.promiseReject(e))})}catch(e){if(r)return;r=!0,this.promiseReject(e)}}},{key:"promiseResolve",value:function(t){var r=this;try{if(t===r)throw new TypeError("A Promise cannot be resolved with it self.");if(t&&("object"===o()(t)||"function"==typeof t)){var n=t.then;if(t instanceof e)return r._state=3,r._value=t,void r.finale();if("function"==typeof n)return void r.doResolve(function(){n.apply(t,arguments)})}r._state=1,r._value=t,r.finale()}catch(e){r.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate(function(){t._handled||e._unhandledRejection(t._value)});for(var r=0,n=this._deferreds.length;r<n;r++)this.handle(this._deferreds[r]);this._deferreds=[]}},{key:"handle",value:function(t){for(var r=this;3===r._state;)r=r._value;0!==r._state?(r._handled=!0,e._immediate(function(){var e=1===r._state?t.onFulfilled:t.onRejected;if(null!==e){var n;try{n=e(r._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(n)}else 1===r._state?t.promise.promiseResolve(r._value):t.promise.promiseReject(r._value)})):r._deferreds.push(t)}}],[{key:"all",value:function(t){return new e(function(e,r){if(!Array.isArray(t))return r(new TypeError("Promise.all accepts an array"));var n=Array.prototype.slice.call(t);if(0===n.length)return e([]);for(var a=n.length,i=function(t,u){try{if(u&&("object"===o()(u)||"function"==typeof u)){var s=u.then;if("function"==typeof s)return void s.call(u,function(e){return i(t,e)},r)}n[t]=u,0===--a&&e(n)}catch(e){r(e)}},u=0;u<n.length;u++)i(u,n[u])})}},{key:"resolve",value:function(t){return t&&"object"===o()(t)&&t.constructor===e?t:new e(function(e){return e(t)})}},{key:"reject",value:function(t){return new e(function(e,r){return r(t)})}},{key:"race",value:function(t){return new e(function(r,n){if(!Array.isArray(t))return n(new TypeError("Promise.race accepts an array"));for(var o=0,a=t.length;o<a;o++)e.resolve(t[o]).then(r,n)})}},{key:"_immediate",value:function(e){window.setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}])}();d.prototype.catch=function(e){return this.then(null,e)},d.prototype.then=function(e,t){var r=new d(function(){return null});return this.handle(new l(e,t,r)),r},d.prototype.finally=function(e){return this.then(function(t){return d.resolve(e()).then(function(){return t},function(){return null})},function(t){return d.resolve(e()).then(function(){return d.reject(t)},function(){return null})})};var p=d},293:(e,t,r)=>{var n=r(981).A;function o(e,t,r,o,a,i,u){try{var s=e[i](u),c=s.value}catch(e){return void r(e)}s.done?t(c):n.resolve(c).then(o,a)}e.exports=function(e){return function(){var t=this,r=arguments;return new n(function(n,a){var i=e.apply(t,r);function u(e){o(i,n,a,u,s,"next",e)}function s(e){o(i,n,a,u,s,"throw",e)}u(void 0)})}},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,r)=>{var n=r(736);function o(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,n(o.key),o)}}e.exports=function(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,t,r)=>{var n=r(736);e.exports=function(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,t,r)=>{var n=r(738).default;e.exports=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,t,r)=>{var n=r(738).default,o=r(45);e.exports=function(e){var t=o(e,"string");return"symbol"==n(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=r(293),t=r.n(e),n=r(383),o=r.n(n),a=r(579),i=r.n(a),u=r(693),s=r.n(u),c=function(e){return e[e.Error=-1]="Error",e[e.AddTransform=0]="AddTransform",e[e.ConfigurePipeline=1]="ConfigurePipeline",e[e.Metadata=2]="Metadata",e[e.Chunk=3]="Chunk",e[e.PipelineConfigured=4]="PipelineConfigured",e}({}),f=function(e){return e[e.FrameTimingInformation=0]="FrameTimingInformation",e[e.EncodedVideoChunk=1]="EncodedVideoChunk",e[e.EncodedAudioChunk=2]="EncodedAudioChunk",e[e.SurrogateVideoChunk=3]="SurrogateVideoChunk",e[e.SurrogateAudioChunk=4]="SurrogateAudioChunk",e}({});function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function d(e,t){for(var r=e.length,n=t;n<r-3;n++)if(0===e[n]&&0===e[n+1]){if(1===e[n+2])return n;if(n+3<r&&0===e[n+2]&&1===e[n+3])return n}return-1}function p(e,t){for(var r=t,n=0;255===e[r];)n++,r++;var o=255*n+e[r++];for(n=0;255===e[r];)n++,r++;var a=255*n+e[r++];return{type:o,payload:e.subarray(r,r+a),length:r+a-t}}function m(e){if(e.getRemainingBits()<10)return null;var t={ctType:e.readBits(2),nuitFieldBasedFlag:1===e.readBits(1),countingType:e.readBits(5),fullTimestampFlag:1===e.readBits(1),discontinuityFlag:1===e.readBits(1),cntDroppedFlag:1===e.readBits(1),nFrames:e.readBits(8)};if(t.fullTimestampFlag){if(e.getRemainingBits()<17)return null;t.seconds=e.readBits(6),t.minutes=e.readBits(6),t.hours=e.readBits(5)}else if(!function(e,t){return e.getRemainingBits()<1||0===e.readBits(1)||!(e.getRemainingBits()<6)&&(t.seconds=e.readBits(6),e.getRemainingBits()<1||0===e.readBits(1)||!(e.getRemainingBits()<6)&&(t.minutes=e.readBits(6),e.getRemainingBits()<1||0===e.readBits(1)||!(e.getRemainingBits()<5)&&(t.hours=e.readBits(5),!0)))}(e,t))return null;return e.getRemainingBits()<24?null:(t.timeOffset=e.readBits(24),t)}function h(e,t){var r,n,o=(r=function(e){var t,r=[],n=0,o=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return l(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(u)throw a}}}}(e);try{for(o.s();!(t=o.n()).done;){var a=t.value;2===n&&3===a?n=0:(0===a?n++:n=0,r.push(a))}}catch(e){o.e(e)}finally{o.f()}return new Uint8Array(r)}(e),n=0,{readBits:function(e){if(n+e>8*r.length)throw new Error("Cannot read [".concat(e,"] bits - out of bounds"));for(var t=0,o=e;o>0;){var a=Math.floor(n/8),i=8-n%8,u=Math.min(o,i),s=(1<<u)-1;t=t<<u|r[a]>>i-u&s,n+=u,o-=u}return t},skipBits:function(e){if(n+e>8*r.length)throw new Error("Cannot skip [".concat(e,"] bits - out of bounds"));n+=e},getRemainingBits:function(){return 8*r.length-n}}),a={picStruct:void 0};if(t.cpbDpbDelaysPresentFlag&&void 0!==t.cpbRemovalDelayLengthMinus1&&void 0!==t.dpbOutputDelayLengthMinus1&&(o.skipBits(t.cpbRemovalDelayLengthMinus1+1),o.skipBits(t.dpbOutputDelayLengthMinus1+1)),t.picStructPresentFlag){for(var i=function(e){switch(e){case 0:case 1:case 2:return 1;case 3:case 4:case 7:return 2;case 5:case 6:case 8:return 3;default:return 0}}(o.readBits(4)),u=[],s=0;s<i&&!(o.getRemainingBits()<1);s++)if(1===o.readBits(1)){var c=m(o);if(!c)break;u.push({clockTimestampFlag:!0,clockTimestamp:c})}else u.push({clockTimestampFlag:!1});a.picStruct={numClockTS:i,clockTimestamps:u}}return a}var v,y=function(){return i()(function e(){o()(this,e)},null,[{key:"createFrameTimingInformationTransform",value:function(){return new TransformStream({transform:function(e,t){(function(e){for(var t=new Date,r=new Uint8Array(e.data),n=d(r,0);-1!==n;){var o=d(r,n+1),a=-1===o?r.length:o,i=n+(1===r[n+2]?3:4);if(6==(31&r[i]))for(var u=i+1,l=r.subarray(u,a),m=0;m<l.length&&!(m+2>l.length);){var v=p(l,m);if(1===v.type){var y,g=null===(y=h(v.payload,{cpbDpbDelaysPresentFlag:!1,picStructPresentFlag:!0}).picStruct)||void 0===y?void 0:y.clockTimestamps[0];if(null!=g&&g.clockTimestampFlag){var b,k,w,_,T=e.timestamp,x={timecode:g.clockTimestamp?{hours:null!==(b=g.clockTimestamp.hours)&&void 0!==b?b:null,minutes:null!==(k=g.clockTimestamp.minutes)&&void 0!==k?k:null,seconds:null!==(w=g.clockTimestamp.seconds)&&void 0!==w?w:null,frames:null!==(_=g.clockTimestamp.nFrames)&&void 0!==_?_:null,isFrameDrop:g.clockTimestamp.cntDroppedFlag}:null,receiveTimestamp:t};self.postMessage({type:c.Metadata,data:{type:f.FrameTimingInformation,data:s()({},T,{decodedFrameTimingInformation:x})}})}}if(m+=v.length,0===v.length)break}n=o}})(e),t.enqueue(e)}})}},{key:"createEncodedVideoStreamTransform",value:function(e){var t=new Map,r=function(e,t,r){var n=r.data;if(n.type===c.Chunk&&n.data.type===f.SurrogateVideoChunk){var o=n.data.data,a=o.surrogate,i=o.timestamp,u=e.get(i);u?(u.data=a,t.enqueue(u),e.delete(i)):console.warn("[WorkerTransforms] Surrogate video chunk not found for timestamp",i)}};return new TransformStream({start:function(n){e.addEventListener("message",r.bind(null,t,n),{once:!1})},transform:function(e){t.set(e.timestamp,e),self.postMessage({type:c.Metadata,data:{type:f.EncodedVideoChunk,data:{timestamp:e.timestamp,data:new Uint8Array(e.data),type:e.type}}},{transfer:[e.data]})}})}},{key:"createEncodedAudioStreamTransform",value:function(e){var t=new Map,r=function(e,t,r){var n=r.data;if(n.type===c.Chunk&&n.data.type===f.SurrogateAudioChunk){var o=n.data.data,a=o.surrogate,i=o.timestamp,u=e.get(i);u?(u.data=a,t.enqueue(u),e.delete(i)):console.warn("[WorkerTransforms] Surrogate audio chunk not found for timestamp",i)}};return new TransformStream({start:function(n){e.addEventListener("message",r.bind(null,t,n),{once:!1})},transform:function(e){t.set(e.timestamp,e),self.postMessage({type:c.Metadata,data:{type:f.EncodedAudioChunk,data:{timestamp:e.timestamp,data:new Uint8Array(e.data),type:e.type}}},{transfer:[e.data]})}})}},{key:"createPassThroughTransform",value:function(){return new TransformStream({transform:function(e,t){return t.enqueue(e)}})}}])}();function g(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,a){var s=n&&n.prototype instanceof u?n:u,c=Object.create(s.prototype);return b(c,"_invoke",function(r,n,o){var a,u,s,c=0,f=o||[],l=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,r){return a=t,u=0,s=e,d.n=r,i}};function p(r,n){for(u=r,s=n,t=0;!l&&c&&!o&&t<f.length;t++){var o,a=f[t],p=d.p,m=a[2];r>3?(o=m===n)&&(s=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=e):a[0]<=p&&((o=r<2&&p<a[1])?(u=0,d.v=n,d.n=a[1]):p<m&&(o=r<3||a[0]>n||n>m)&&(a[4]=r,a[5]=n,d.n=m,u=0))}if(o||r>1)return i;throw l=!0,n}return function(o,f,m){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,m),u=f,s=m;(t=u<2?e:s)||!l;){a||(u?u<3?(u>1&&(d.n=-1),p(u,s)):d.n=s:d.v=s);try{if(c=2,a){if(u||(o="next"),t=a[o]){if(!(t=t.call(a,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,u<2&&(u=0)}else 1===u&&(t=a.return)&&t.call(a),u<2&&(s=TypeError("The iterator does not provide a \'"+o+"\' method"),u=1);a=e}else if((t=(l=d.n<0)?s:r.call(n,d))!==i)break}catch(t){a=e,u=1,s=t}finally{c=1}}return{value:t,done:l}}}(r,o,a),!0),c}var i={};function u(){}function s(){}function c(){}t=Object.getPrototypeOf;var f=[][n]?t(t([][n]())):(b(t={},n,function(){return this}),t),l=c.prototype=u.prototype=Object.create(f);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,b(e,o,"GeneratorFunction")),e.prototype=Object.create(l),e}return s.prototype=c,b(l,"constructor",c),b(c,"constructor",s),s.displayName="GeneratorFunction",b(c,o,"GeneratorFunction"),b(l),b(l,o,"Generator"),b(l,n,function(){return this}),b(l,"toString",function(){return"[object Generator]"}),(g=function(){return{w:a,m:d}})()}function b(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}b=function(e,t,r,n){function a(t,r){b(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(a("next",0),a("throw",1),a("return",2))},b(e,t,r,n)}var k=self,w=function(){function e(){o()(this,e)}return i()(e,null,[{key:"handleAddTransform",value:function(t){if(e._isPipelineConfigured)throw new Error("Error: Pipeline is locked. A transform cannot be added once the pipeline has been configured");switch(t){case"frame-timing-information":e._transforms.push(y.createFrameTimingInformationTransform());break;case"protected-video":e._transforms.push(y.createEncodedVideoStreamTransform(k));break;case"protected-audio":e._transforms.push(y.createEncodedAudioStreamTransform(k));break;case"pass-through":e._transforms.push(y.createPassThroughTransform());break;default:throw new Error("Error: Unknown transform type [".concat(t,"]"))}}},{key:"configurePipeline",value:(r=t()(g().m(function t(r,n){return g().w(function(t){for(;;)switch(t.n){case 0:if(r&&n){t.n=1;break}throw new Error("Error: Configuration of TransformStreamPipeline requires both a readbale source and writable sink");case 1:return 0===e._transforms.length&&e._transforms.push(),t.n=2,e._transforms.reduceRight(function(e,t){return e.pipeThrough(t)},r).pipeTo(n);case 2:e._isPipelineConfigured=!0,k.postMessage({type:c.PipelineConfigured,data:{name:e._workerName}});case 3:return t.a(2)}},t)})),function(e,t){return r.apply(this,arguments)})},{key:"handleMessage",value:function(t){var r=t.data,n=r.type;switch(n){case c.AddTransform:e.handleAddTransform(r.data);break;case c.ConfigurePipeline:e.configurePipeline(r.data.source,r.data.sink);break;case c.Metadata:case c.Chunk:break;default:!function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))}(n)}}}]);var r}();v=w,s()(w,"_transforms",[]),s()(w,"_isPipelineConfigured",!1),s()(w,"_workerName",void 0),k.onerror=function(e){return console.error("[TransformStreamPipelineWorker] Error: [%s]",e)},k.onmessage=v.handleMessage.bind(v),k.RTCTransformEvent&&(k.onrtctransform=function(e){var t=e.transformer;v._workerName=t.options.name;var r=t.readable,n=t.writable;v.configurePipeline(r,n)})})()})();\n',"Worker",void 0,void 0)}var Nt=function(){return o()(function e(n){t()(this,e),s()(this,"_messageRoutes",new Map),this.initialize(n)},[{key:"registerRoute",value:function(e,t){var n=this;return this._messageRoutes.set(e,t),new m(function(){return n._messageRoutes.delete(e)})}},{key:"dispose",value:function(){this._messageRoutes.clear()}},{key:"initialize",value:function(e){var t=this;e.addEventListener("message",function(e){var n,r,i,o,a=e.data;switch(a.type){case Lt.Chunk:case Lt.Metadata:r=(n=a.data).type,i=n.data,(o=t._messageRoutes.get(r))&&o(i)}},{once:!1})}}])}(),zt=n(981).A;function Ht(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return qt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(qt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,qt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,qt(d,"constructor",c),qt(c,"constructor",u),u.displayName="GeneratorFunction",qt(c,i,"GeneratorFunction"),qt(d),qt(d,i,"Generator"),qt(d,r,function(){return this}),qt(d,"toString",function(){return"[object Generator]"}),(Ht=function(){return{w:o,m:h}})()}function qt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}qt=function(e,t,n,r){function o(t,n){qt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},qt(e,t,n,r)}function Wt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Jt(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Jt(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Jt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var Kt=function(){return o()(function e(){throw t()(this,e),new Error("InsertableStreams is a static class that may not be instantiated")},null,[{key:"createEncodedStreamPipeline",value:function(e){var t=new ie,n=e.videoTrack,r=e.audioTrack,i=function(e){var n=e.transformPipelineWorker=new Ut;t.add(new m(function(){return n.terminate()})),t.add(e.transformMessageRouter=new Nt(n))},o=n.receiver,a=n.mediaStreamTrack;o&&a&&i(n);var s=r.receiver,u=r.mediaStreamTrack;return s&&u&&i(r),t}},{key:"configureEncodedStreamPipeline",value:(e=V()(Ht().m(function e(t){var n,r,i,o,a;return Ht().w(function(e){for(;;)switch(e.n){case 0:if(n=t.videoTrack,r=t.audioTrack,(i=function(e){if(e.transformPipelineWorker)if(e.transformFunctionNames.length){var t,n=Wt(e.transformFunctionNames);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.transformPipelineWorker.postMessage({type:Lt.AddTransform,data:r})}}catch(e){n.e(e)}finally{n.f()}}else e.transformPipelineWorker.postMessage({type:Lt.AddTransform,data:"pass-through"})})(n),i(r),o=function(){var e=V()(Ht().m(function e(t){var n,r,i;return Ht().w(function(e){for(;;)switch(e.n){case 0:return n=function(){var e=V()(Ht().m(function e(t){var n,r,i;return Ht().w(function(e){for(;;)switch(e.n){case 0:if(n=t.receiver,r=t.mediaStreamTrack,i=t.transformPipelineWorker,!(n&&r&&i)){e.n=1;break}return n.transform=new RTCRtpScriptTransform(i,{name:"".concat(r.kind,"-transform-pipeline")}),e.a(2,new zt(function(e){i.addEventListener("message",function(t){t.data.type===Lt.PipelineConfigured&&e()},{once:!0})}));case 1:return e.a(2,zt.resolve())}},e)}));return function(t){return e.apply(this,arguments)}}(),r=t.videoTrack,i=t.audioTrack,e.n=1,zt.all([n(r),n(i)]);case 1:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}(),a=function(){var e=V()(Ht().m(function e(t){var n,r,i,o;return Ht().w(function(e){for(;;)switch(e.n){case 0:return n=function(e){var t=e.receiver,n=e.mediaStreamTrack,r=e.transformPipelineWorker;if(t&&n&&r){var i=t.createEncodedStreams();return new zt(function(e){r.addEventListener("message",function(t){t.data.type===Lt.PipelineConfigured&&e()},{once:!0}),r.postMessage({type:Lt.ConfigurePipeline,data:{source:i.readable,sink:i.writable}},{transfer:[i.readable,i.writable]})})}return zt.resolve()},r=t.videoTrack,i=t.audioTrack,o=[],r.receiver&&r.transformPipelineWorker&&o.push(n(r)),i.receiver&&i.transformPipelineWorker&&o.push(n(i)),e.n=1,zt.all(o);case 1:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}(),!O.isRTCRtpScriptTransformSupported){e.n=2;break}return e.n=1,o(t);case 1:case 3:return e.a(2);case 2:return e.n=3,a(t)}},e)})),function(t){return e.apply(this,arguments)})},{key:"configureInsertableStreamTransformation",value:function(e,t,n){var r=new MediaStream,i=new ie;return e.getTracks().forEach(function(e){var o=e.kind;switch(o){case"video":if(t){var a=e,s=new TransformStream({transform:function(n,r){t(e,n,r)}}),u=new MediaStreamTrackProcessor({track:a}),c=new MediaStreamTrackGenerator({kind:a.kind}),l=u.readable,d=c.writable;l.pipeThrough(s).pipeTo(d),r.addTrack(c),i.add(new m(function(){r.removeTrack(c)}))}else r.addTrack(e);break;case"audio":if(n){var h=e,f=new TransformStream({transform:function(t,r){n(e,t,r)}}),p=new MediaStreamTrackProcessor({track:h}),v=new MediaStreamTrackGenerator({kind:h.kind}),g=p.readable,y=v.writable;g.pipeThrough(f).pipeTo(y),r.addTrack(v);var _=new MediaStream,b=new Audio;_.addTrack(e),b.srcObject=_,document.body.appendChild(b),i.add(new m(function(){r.removeTrack(v),document.body.removeChild(b)}))}else r.addTrack(e);break;default:Z(o)}}),{transformedStream:r,disposables:i}}}]);var e}(),Qt=n(981).A,Zt=function(){return o()(function e(){throw t()(this,e),new Error("VideoFrameDetector is a static class that may not be instantiated")},null,[{key:"isRenderingFrames",value:function(e){var t=this;if(!O.isRequestVideoFrameCallbackSupported)return this._logger.debug("requestVideoFrameCallback not supported, assuming rendering"),Qt.resolve(!0);if(!O.isRequestAnimationFrameSupported)return this._logger.debug("requestAnimationFrame not supported, assuming rendering"),Qt.resolve(!0);if(!O.isMobile)return this._logger.debug("Skipping frame detection on desktop, assuming rendering"),Qt.resolve(!0);var n=Date.now();return new Qt(function(r){var i=!1,o=P.value.setTimeout(function(){i||(i=!0,t._logger.info("Frame detection timed out after [%s] ms, assuming rendering",1e3),r(!0))},1e3);e.requestVideoFrameCallback(function(){i||(i=!0,P.value.clearTimeout(o),t._logger.debug("Video frame rendered within [%s] ms — stream is healthy",Date.now()-n),r(!0))}),P.value.requestAnimationFrame(function(){i||(i=!0,P.value.clearTimeout(o),t._logger.debug("No video frame rendered within [%s] ms — stream is stalled",Date.now()-n),r(!1))})})}}])}();s()(Zt,"_logger",ee.getLogger("VideoFrameDetector"));var $t,Xt=function(e){return e[e.OPUS=0]="OPUS",e[e.AAC=1]="AAC",e}({}),Yt=new Uint8Array([0,0,0,1]),en=new Uint8Array([].concat(c()(Yt),[103,66,192,42,218,4,4,232,64,0,0,3,0,64,0,0,15,35,198,12,168],c()(Yt),[104,206,60,128],c()(Yt),[6,3,167],c()(new Uint8Array(150).fill(255)),[128],c()(Yt),[101,136,132,6,191,255,255,15,69,0,1,87,159],c()(new Uint8Array(15).fill(39)),[93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,128])),tn=new Uint8Array([].concat(c()(Yt),[6,3,255,61],c()(new Uint8Array(316).fill(255)),[128],c()(Yt),[65,154,32,26,240,18,48])),nn=Symbol(),rn=function(){function e(){throw t()(this,e),new Error("SurrogateFrameDataManager is a static class that may not be instantiated")}return o()(e,null,[{key:"getSurrogateAudioSilentPerCodec",value:function(t){switch(t){case Xt.OPUS:return e._dummyAudioSilentPerCodec.OPUS.buffer;case Xt.AAC:return;default:Z(t)}}},{key:"getInvalidSurrogateAudioData",value:function(){return e._singleZeroByte.buffer}},{key:"getSurrogateVideoIFramePerCodec",value:function(t){switch(t){case It.H264:return e._isSafari?e._surrogate28x16H264IFrame.buffer:e._dummy2x2VideoIFramePerCodec.H264.buffer;case It.VP8:return e._dummy2x2VideoIFramePerCodec.VP8.buffer;case It.VP9:return e._dummy2x2VideoIFramePerCodec.VP9.buffer;default:Z(t)}}},{key:"getInvalidSurrogateVideoIFrame",value:function(t){return t===It.H264&&e._isAndroidChrome?(e._surrogate28x16PFrameFrameNumber=e._surrogate28x16PFrameFrameNumberReset,nn):e._singleZeroByte.buffer}},{key:"getSurrogateVideoPFramePerCodec",value:function(t){switch(t){case It.H264:return e._isSafari?e._surrogate28x16H264PFrame.buffer:e._dummy2x2VideoPFramePerCodec.H264.buffer;case It.VP8:return e._dummy2x2VideoPFramePerCodec.VP8.buffer;case It.VP9:return e._dummy2x2VideoPFramePerCodec.VP9.buffer;default:Z(t)}}},{key:"getInvalidSurrogateVideoPFrame",value:function(){return e._singleZeroByte.buffer}}])}();function on(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return an(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(an(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,an(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,an(d,"constructor",c),an(c,"constructor",u),u.displayName="GeneratorFunction",an(c,i,"GeneratorFunction"),an(d),an(d,i,"Generator"),an(d,r,function(){return this}),an(d,"toString",function(){return"[object Generator]"}),(on=function(){return{w:o,m:h}})()}function an(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}an=function(e,t,n,r){function o(t,n){an(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},an(e,t,n,r)}$t=rn,s()(rn,"_isSafari","Safari"===E.browserName),s()(rn,"_isAndroidChrome","Chrome"===E.browserName&&E.isAndroid),s()(rn,"_singleZeroByte",new Uint8Array([0])),s()(rn,"_dummyAudioSilentPerCodec",{OPUS:new Uint8Array([104,7,217,171,188,121,135,171,142,74,20,243,167,28,242,154,122,69,167,45,68,37,116,76,173,22,179,14,81,87,234,231,173,42,56,206,51])}),s()(rn,"_dummy2x2VideoIFramePerCodec",{H264:new Uint8Array([].concat(c()(Yt),[9,240],c()(Yt),[103,244,0,10,145,155,43,241,241,248,8,128,0,0,3,0,128,0,0,25,7,137,18,203],c()(Yt),[104,235,227,196,72,68,0,0,1,101,136,130,0,63,112,35,134,230,209,128,9,175,10,65,102,107,84,70,251,113,217,127,255,255,249])),VP8:new Uint8Array([176,2,0,157,1,42,1,0,1,0,57,107,0,39,28,36,12,44,44,68,204,36,65,168,0,19,167,163,122,80,0,254,235,222,47,138,30,107,123,7,114,99,9,164,142,192]),VP9:new Uint8Array([130,73,131,66,0,0,0,0,6,118,56,36,28,25,160,0,0,32,64,0,17,191,221,119,255,64,127,177,0])}),s()(rn,"_dummy2x2VideoPFramePerCodec",{H264:new Uint8Array([].concat(c()(Yt),[9,240],c()(Yt),[65,154,104,73,168,65,104,153,76,15,255,146,129])),VP8:new Uint8Array([49,3,0,228,224,168,155,55,175,16,79,79,177,10,47,228,146,192,31,231,79,70,255,238,81,193,93,0,254,235,222,47,138,30,107,123,7,114,99,9,164,142,192]),VP9:new Uint8Array([134,0,64,146,156,36,72,0,0,3,112,0,0,75,64])}),s()(rn,"_surrogate28x16H264IFrame",en),s()(rn,"_surrogate28x16H264PFrame",tn),s()(rn,"_surrogate28x16PFrameFrameNumberReset",1),s()(rn,"_surrogate28x16PFrameFrameNumber",$t._surrogate28x16PFrameFrameNumberReset);var sn=function(){return o()(function e(n){t()(this,e),s()(this,"_disposables",new ie),this.initialize(n)},[{key:"dispose",value:function(){this._disposables.dispose()}},{key:"initialize",value:function(e){var t=this;e.videoTrack.mediaStreamTrack&&(e.videoTrack.transformFunctionNames.push("protected-video"),this._disposables.add(e.videoTrack.transformMessageRouter.registerRoute(Dt.EncodedVideoChunk,function(n){return t.encodedVideoStreamCallback(e.videoTrack,e.encodedVideoStreamSink,n)}))),e.audioTrack.mediaStreamTrack&&(e.audioTrack.transformFunctionNames.push("protected-audio"),this._disposables.add(e.audioTrack.transformMessageRouter.registerRoute(Dt.EncodedAudioChunk,function(n){return t.encodedAudioStreamCallback(e.audioTrack,e.encodedAudioStreamSink,n)})))}},{key:"encodedAudioStreamCallback",value:(n=V()(on().m(function e(t,n,r){return on().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,n(t.mediaStreamTrack,r);case 1:if(e.v){e.n=2;break}r.data=rn.getInvalidSurrogateAudioData(),e.n=3;break;case 2:r.data=rn.getSurrogateAudioSilentPerCodec(t.codec)||r.data;case 3:return e.a(2,r)}},e)})),function(e,t,r){return n.apply(this,arguments)})},{key:"encodedVideoStreamCallback",value:(e=V()(on().m(function e(t,n,r){var i;return on().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,n(t.mediaStreamTrack,r);case 1:if(e.v){e.n=3;break}if((i="key"===r.type?rn.getInvalidSurrogateVideoIFrame(t.codec):rn.getInvalidSurrogateVideoPFrame())!==nn){e.n=2;break}return e.a(2);case 2:r.data=i||r.data,e.n=4;break;case 3:"key"===r.type?r.data=rn.getSurrogateVideoIFramePerCodec(t.codec)||r.data:r.data=rn.getSurrogateVideoPFramePerCodec(t.codec)||r.data;case 4:return e.a(2,r)}},e)})),function(t,n,r){return e.apply(this,arguments)})}]);var e,n}(),un=function(){return o()(function e(){t()(this,e)},null,[{key:"convertVideoCodecToVideoCodecType",value:function(e){switch(e){case It.H264:return"H264";case It.VP8:return"VP8";case It.VP9:return"VP9";default:Z(e)}}},{key:"convertVideoCodecTypeToVideoCodec",value:function(e){var t=e.toUpperCase();switch(t){case"H264":return It.H264;case"VP8":return It.VP8;case"VP9":return It.VP9;default:Z(t)}}}])}(),cn=function(){return o()(function e(){t()(this,e)},null,[{key:"convertAudioCodecToAudioCodecType",value:function(e){switch(e){case Xt.OPUS:return"OPUS";case Xt.AAC:return"AAC";default:Z(e)}}},{key:"convertAudioCodecTypeToAudioCodec",value:function(e){var t=e.toUpperCase();switch(t){case"OPUS":return Xt.OPUS;case"AAC":return Xt.AAC;default:Z(t)}}}])}(),ln=n(981).A;function dn(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return hn(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(hn(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,hn(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,hn(d,"constructor",c),hn(c,"constructor",u),u.displayName="GeneratorFunction",hn(c,i,"GeneratorFunction"),hn(d),hn(d,i,"Generator"),hn(d,r,function(){return this}),hn(d,"toString",function(){return"[object Generator]"}),(dn=function(){return{w:o,m:h}})()}function hn(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}hn=function(e,t,n,r){function o(t,n){hn(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},hn(e,t,n,r)}function fn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function pn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?fn(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var vn=function(){return o()(function e(n,r,i,o,a){t()(this,e),s()(this,"_logger",ee.getLogger("RealTimeStreamSubscriber")),s()(this,"_disposables",new ie),s()(this,"_channelContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_streamTransformContext",void 0),s()(this,"_frameTimingInformationContext",void 0),s()(this,"_handleStreamFailure",void 0),this._channelContext=n,this._peerConnectionContext=r,this._streamTransformContext=i,this._frameTimingInformationContext=o,this._handleStreamFailure=a},[{key:"start",value:function(e,t,n,r){var i=this;this._disposables.dispose();var o=this._streamTransformContext.hasEncodedInsertableStreams.value||this._frameTimingInformationContext.shouldExtractTimecode.value||this._frameTimingInformationContext.shouldExtractTimestamps.value?ge.Enabled:ge.Disabled;return ln.all([Ft.discoverClosestEndPointWithCaching(e),_e.createPeerConnectionOffer("recvonly",ye,o).then(function(e){var t=e.localOffer,n=e.peerConnection;return i._peerConnectionContext.peerConnection.value=n,{localOffer:t,peerConnection:n}})]).then(function(e){var n=at()(e,2),r=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;i._channelContext.online.value=!0,i._channelContext.endPoint.value=r,i._logger.info("Connecting to [%s]",r.toString()),i._logger.info("Local offer:\n"+a.sdp);var u={};return i._channelContext.onRealTimeSubscribeRequestCallback&&(u.onSubscribeRequestCallback=i._channelContext.onRealTimeSubscribeRequestCallback),i._channelContext.onRealTimeSubscribeResponseCallback&&(u.onSubscribeResponseCallback=i._channelContext.onRealTimeSubscribeResponseCallback),!O.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration?r.subscribe(t,a,i._channelContext.failureCount.value,u):(s.close(),s.dispose(),!Ve.forceGarbageCollectionOnRestart||O.isMobile&&Ve.skipGarbageCollectionOnMobileDevices||Be.forceGarbageCollection(),i._peerConnectionContext.peerConnection.value=null,r.subscribe(t,null,i._channelContext.failureCount.value,u))}).then(function(e){var t=e.status;if(i._channelContext.exists.value=i._channelContext.mapSubscribeStatusToExists(t),i._channelContext.state.value=i._channelContext.mapSubscribeStatusToChannelStatus(t),i._channelContext.applyStatus(t),"ok"!==t)return i._channelContext.stream.value=null,i._channelContext.lag.value=void 0,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),void i._logger.info("[%s] Subscribe failed with status [%s]",i._channelContext.streamId,t);var a=e.stream,s=e.rtcConfiguration,u=e.setRemoteDescriptionResponse,c=e.createOfferDescriptionResponse,l=e.createAnswerDescriptionResponse,d=e.lag;return i._channelContext.stream.value=a,i._channelContext.lag.value=d,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),i._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",i._channelContext.streamId,t,s,u,c,l),i.applyRtcConfiguration(i._peerConnectionContext.peerConnection.value,s).then(function(e){var t,s=!1,d=!1,h=[];i._peerConnectionContext.peerConnection.value||(i._peerConnectionContext.peerConnection.value=e),e.onicecandidate=function(n){i._channelContext.stream.value===a&&i._peerConnectionContext.peerConnection.value===e&&(s||Ve.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?h.push(n.candidate):d=!0,t||(t=P.value.setTimeout(function(){var e;i._channelContext.stream.value!==a||s||null===(e=i._channelContext.endPoint.value)||void 0===e||e.addIceCandidates(a,h,d).then(function(e){var t=e.status,n=e.options;"ok"===t?(null!=n&&n.includes("cancel")&&(s=!0),i._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",i._channelContext.streamId,t,n)):i._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",i._channelContext.streamId,t)}).catch(function(e){i._logger.error("[%s] Failed to add ICE candidates",i._channelContext.streamId,e)})},100),i._disposables.add(new m(function(){return P.value.clearTimeout(t)})))))},i._disposables.add(new m(function(){e.onicecandidate=null,e.oniceconnectionstatechange=null})),e.oniceconnectionstatechange=function(){if(i._channelContext.stream.value===a&&i._peerConnectionContext.peerConnection.value===e){var t=function(){i._handleStreamFailure().catch(function(t){i._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)})};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return void(P.value.navigatorIsOnLine&&(i._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",i._channelContext.streamId,e.iceConnectionState),i.reconnectPeerConnection(i._channelContext.streamId,e,t)));case"closed":return i._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",i._channelContext.streamId,e.iceConnectionState),void t();default:Z(e.iceConnectionState)}}};var f=new ln(function(t,n){if(!O.onTrackDisabled){var r=P.value.setTimeout(function(){return n(new Error("Stream setup timed out"))},3e4);return i._disposables.add(new m(function(){return P.value.clearTimeout(r)})),void(e.ontrack=function(e){P.value.clearTimeout(r),t(e.streams[0])})}var o=function(n){P.value.clearTimeout(a),e.removeEventListener("track",o),e.removeEventListener("addstream",o),t("streams"in n?n.streams[0]:n.stream)},a=P.value.setTimeout(function(){e.removeEventListener("track",o),e.removeEventListener("addstream",o),n(new Error("Stream setup timed out"))},3e4);e.addEventListener("track",o),e.addEventListener("addstream",o),i._disposables.add(new m(function(){return P.value.clearTimeout(a)}))});return new ln(function(e){e()}).then(function(){if(u)return i._logger.info("[%s] Set local SDP offer [%s]",i._channelContext.streamId,u.sessionDescription.sdp),e.setLocalDescription(u.sessionDescription).catch(function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,u.sessionDescription,e.message),e})}).then(function(){if(l)return i._logger.info("[%s] Set remote SDP answer [%s]",i._channelContext.streamId,l.sessionDescription.sdp),e.setRemoteDescription(l.sessionDescription).catch(function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,l.sessionDescription,e.message),e})}).then(function(){if(c)return i._logger.info("[%s] Set remote SDP offer [%s]",i._channelContext.streamId,c.sessionDescription.sdp),e.setRemoteDescription(c.sessionDescription).catch(function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,c.sessionDescription,e.message),e}).then(function(){return e.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})}).then(function(e){return i._logger.info("[%s] Set local SDP answer [%j]",i._channelContext.streamId,e),i._channelContext.endPoint.value.setRemoteDescription(a,e)}).then(function(t){var n=t.status,r=t.sessionDescription;return i._channelContext.state.value=i.mapSetRemoteDescriptionStatusToChannelStatus(n),"ok"!==n?(i._channelContext.playing.value=!1,i._channelContext.standby.value=!0,void(i._channelContext.stopped.value=!1)):e.setLocalDescription(r).catch(function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,r,e.message),e})})}).then(function(){return n.success(i._channelContext.streamId),f}).then(function(t){var n,a;if(o&&null!=e&&null!==(n=e.currentRemoteDescription)&&void 0!==n&&n.sdp){var s,u,c=new st(e.currentRemoteDescription.sdp);i._streamTransformContext.videoTrack.codec=un.convertVideoCodecTypeToVideoCodec(c.videoCodec),i._streamTransformContext.audioTrack.codec=cn.convertAudioCodecTypeToAudioCodec(c.audioCodec);var l=e.getReceivers(),d=i._streamTransformContext.videoTrack.mediaStreamTrack=t.getVideoTracks()[0],h=i._streamTransformContext.videoTrack.receiver=l.filter(function(e){return e.track===d})[0];i._streamTransformContext.videoTrack.mid=e.supportsGetTransceivers?null===(s=e.getTransceivers().filter(function(e){return e.receiver===h})[0])||void 0===s?void 0:s.mid:null;var f=i._streamTransformContext.audioTrack.mediaStreamTrack=t.getAudioTracks()[0],p=i._streamTransformContext.audioTrack.receiver=l.filter(function(e){return e.track===f})[0];if(i._streamTransformContext.audioTrack.mid=e.supportsGetTransceivers?null===(u=e.getTransceivers().filter(function(e){return e.receiver===p})[0])||void 0===u?void 0:u.mid:null,i._disposables.add(Kt.createEncodedStreamPipeline(i._streamTransformContext)),i._frameTimingInformationContext.shouldExtractTimecode.value||i._frameTimingInformationContext.shouldExtractTimestamps.value){var v={streamId:i._channelContext.streamId,codec:i._streamTransformContext.videoTrack.codec,videoElement:i._channelContext.videoElement,decodedFrameTimingInformationSubject:i._frameTimingInformationContext.decodedFrameTimingInformation,renderedFrameTimingInformationSubject:i._frameTimingInformationContext.renderedFrameTimingInformation,isEnabledSubject:i._frameTimingInformationContext.isEnabled,receiver:h,mid:i._streamTransformContext.videoTrack.mid,trackId:i._streamTransformContext.videoTrack.mediaStreamTrack.id,transformMessageRouter:i._streamTransformContext.videoTrack.transformMessageRouter,transformFunctionNames:i._streamTransformContext.videoTrack.transformFunctionNames};i._disposables.add(new Vt(v))}if(i._streamTransformContext.hasEncodedInsertableStreams.value){var m={videoTrack:i._streamTransformContext.videoTrack,audioTrack:i._streamTransformContext.audioTrack,encodedVideoStreamSink:i._streamTransformContext.encodedVideoStreamSink,encodedAudioStreamSink:i._streamTransformContext.encodedAudioStreamSink};i._disposables.add(new sn(m))}Kt.configureEncodedStreamPipeline(i._streamTransformContext)}if(i._streamTransformContext.hasInsertableStreams.value){var g=Kt.configureInsertableStreamTransformation(t,i._streamTransformContext.videoStreamTransformCallback,i._streamTransformContext.audioStreamTransformCallback),y=g.transformedStream,_=g.disposables;i._disposables.add(_),t=y}i._peerConnectionContext.mediaStream.value=t;var b=new ht(e,t,null!==(a=i._channelContext.endPoint.value)&&void 0!==a&&a.roundTripTime?i._channelContext.endPoint.value.roundTripTime/4:0,Ve.applicationActivityMonitor.isForeground);i._disposables.add(b);var C=b.rtcStatistic.subscribe(function(t){if(i._channelContext.rtcStatistics.value=t,t){if(!i._channelContext.rtcVideoStatistic&&!i._channelContext.rtcAudioStatistic)return i._channelContext.rtcAudioStatistic=t.audio,void(i._channelContext.rtcVideoStatistic=t.video);if(!Ve.applicationActivityMonitor.isForeground.value)return i._channelContext.rtcAudioStatistic=t.audio,void(i._channelContext.rtcVideoStatistic=t.video);var n=!1,r=!1;if(t.audio&&i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.timestamp!==t.audio.timestamp&&((n=i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.bytesReceived===t.audio.bytesReceived)&&P.value.navigatorIsOnLine&&i._logger.info("[%s] Audio track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.audio.bytesReceived,i._channelContext.rtcAudioStatistic.bytesReceived,new ze(t.audio.timestamp-i._channelContext.rtcAudioStatistic.timestamp).toIsoString()),i._channelContext.rtcAudioStatistic=t.audio),t.video&&i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.timestamp!==t.video.timestamp&&((r=i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.bytesReceived===t.video.bytesReceived)&&P.value.navigatorIsOnLine&&i._logger.info("[%s] Video track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.video.bytesReceived,i._channelContext.rtcVideoStatistic.bytesReceived,new ze(t.video.timestamp-i._channelContext.rtcVideoStatistic.timestamp).toIsoString()),i._channelContext.rtcVideoStatistic=t.video),P.value.navigatorIsOnLine)if(r||n)i.reconnectPeerConnection(i._channelContext.streamId,e,function(){b.dispose(),i._handleStreamFailure().catch(function(t){i._logger.error("[%s] Failed handling stream failure after track stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)})});else{if(i._peerConnectionContext.peerConnectionReconnectAttempts=0,i._channelContext.state.value!==Ne.Reconnecting&&i._channelContext.state.value!==Ne.Offline)return;i._channelContext.state.value=i._channelContext.playing.value?Ne.Playing:Ne.Paused,i._logger.info("Channel state restored to [%s] after reconnecting",Ne[i._channelContext.state.value])}else i._channelContext.state.value=Ne.Offline}});return i._disposables.add(C),Ve.automaticallyPlayMediaStream?r(t):(i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,void(i._channelContext.state.value=Ne.Paused))})})})}},{key:"applyRtcConfiguration",value:(e=V()(dn().m(function e(t,n){var r;return dn().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return n=ut.truncateIceServers(n),e.a(2,Ve.peerConnectionFactory.value.createPeerConnection(n));case 1:return r=pn(pn({},t.getConfiguration()),n),t.setConfiguration(r),e.a(2,t)}},e)})),function(t,n){return e.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t,n){var r=this;if(Ve.applicationActivityMonitor.isForeground.value){if("closed"!==t.iceConnectionState){switch(this._channelContext.state.value){case Ne.Paused:case Ne.Stopped:case Ne.Unauthorized:case Ne.GeoRestricted:case Ne.GeoBlocked:case Ne.UnsupportedFeature:case Ne.ConfigurationError:return void this._logger.debug("[%s] Skipping peerConnection reconnection in deliberately-terminal state [%s]",e,Ne[this._channelContext.state.value])}if(this._channelContext.state.value=Ne.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Ve.maximalNumberOfPeerConnectionReconnectAttempts||!Ve.automaticallyReconnectPeerConnection){var i;this._peerConnectionContext.peerConnectionReconnectAttempts++;var o="offer"===(null===(i=t.currentLocalDescription)||void 0===i?void 0:i.type);if(O.clientOfferDisabled||!t.supportsSetConfiguration||!t.supportsGetConfiguration||!o)return;this._logger.info("Reconnecting peer connection by restarting ICE");var a=t.currentLocalDescription;t.createOffer({iceRestart:!0}).then(function(e){return t.setLocalDescription(e).then(function(){return t.setLocalDescription(a)})}).catch(function(e){r._logger.error("Failed to reconnect peer connection",e),r._peerConnectionContext.peerConnectionReconnectAttempts=0,n()})}else this._logger.info("Failed to reconnect peer connection after [%s] attempts, performing full recovery",this._peerConnectionContext.peerConnectionReconnectAttempts),this._peerConnectionContext.peerConnectionReconnectAttempts=0,n()}}else this._logger.debug("[%s] Skipping peerConnection reconnection attempt while not in foreground (peerConnection state [%s])",e,t.iceConnectionState)}},{key:"isStreamHealthy",value:function(){var e,t=this._channelContext.videoElement.value;if(!t)return ln.resolve(!1);var n=this._peerConnectionContext.mediaStream.value,r=null!==(e=null==n?void 0:n.getTracks().some(function(e){return"live"===e.readyState}))&&void 0!==e&&e;return t.paused||!r?ln.resolve(!1):Zt.isRenderingFrames(t)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"mapSetRemoteDescriptionStatusToChannelStatus",value:function(e){switch(e){case"ok":return Ne.Starting;case"unauthorized":return Ne.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return Ne.Recovering;case"failed":return Ne.Error;default:Z(e)}}}]);var e}(),mn=function(){return o()(function e(){throw t()(this,e),new Error("RealTimeStreamSubscriberFactory is a static class that may not be instantiated")},null,[{key:"create",value:function(e,t,n,r,i,o){var a=re.parseToken(e).capabilities;return a.includes("on-demand")?(this._logger.error("This build does not support On-Demand Stream playback."),void(t.state.value=Ne.UnsupportedFeature)):a.includes("streaming")?(this._logger.error("This build does not support Live Stream playback."),void(t.state.value=Ne.UnsupportedFeature)):new vn(t,n,r,i,o)}}])}();s()(mn,"_logger",ee.getLogger("Streaming"));var gn=n(981).A;function yn(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return _n(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(_n(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,_n(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,_n(d,"constructor",c),_n(c,"constructor",u),u.displayName="GeneratorFunction",_n(c,i,"GeneratorFunction"),_n(d),_n(d,i,"Generator"),_n(d,r,function(){return this}),_n(d,"toString",function(){return"[object Generator]"}),(yn=function(){return{w:o,m:h}})()}function _n(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}_n=function(e,t,n,r){function o(t,n){_n(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},_n(e,t,n,r)}var bn=function(){return o()(function e(n,r,i){var o=this;t()(this,e),s()(this,"_logger",ee.getLogger("Channel")),s()(this,"_tokenContext",void 0),s()(this,"_channelContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_streamTransformContext",void 0),s()(this,"_stateContext",void 0),s()(this,"_frameTimingInformationContext",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_channelStartTime",void 0),s()(this,"_readOnlyPeerConnection",void 0),s()(this,"_readOnlyState",void 0),s()(this,"_readOnlyExists",void 0),s()(this,"_readOnlyAutoMuted",void 0),s()(this,"_readOnlyAutoPaused",void 0),s()(this,"_readOnlyTokenExpiring",void 0),s()(this,"_readOnlyAuthorized",void 0),s()(this,"_readOnlyOnline",void 0),s()(this,"_readOnlyLoading",void 0),s()(this,"_readOnlyPlaying",void 0),s()(this,"_readOnlyStandby",void 0),s()(this,"_readOnlyStopped",void 0),s()(this,"_readOnlyTargetLag",void 0),s()(this,"_readOnlyLag",void 0),s()(this,"_readOnlyBitrateLimit",void 0),s()(this,"_readOnlyResolution",void 0),s()(this,"_readOnlyFailureCount",void 0),s()(this,"_readOnlyEndPoint",void 0),s()(this,"_readOnlyStream",void 0),s()(this,"_readOnlyRtcStatistics",void 0),s()(this,"_readOnlyMediaStream",void 0),s()(this,"_readOnlyIsFrameTimingInformationEnabled",void 0),s()(this,"_readOnlyDecodedFrameTimingInformation",void 0),s()(this,"_readOnlyRenderedFrameTimingInformation",void 0),s()(this,"_metricsService",void 0),s()(this,"_streamSubscriber",null),s()(this,"_sessionTelemetry",void 0),s()(this,"_videoMetaDataChangedHandler",void 0);var a=re.parseToken(r),u={targetLag:null==i?void 0:i.targetLag,onRealTimeSubscribeRequestCallback:null==i?void 0:i.onRealTimeSubscribeRequestCallback,onRealTimeSubscribeResponseCallback:null==i?void 0:i.onRealTimeSubscribeResponseCallback},c={hasInsertableStreams:a.capabilities.includes("insertable-streams"),hasEncodedInsertableStreams:a.capabilities.includes("encoded-insertable-streams"),videoStreamTransformCallback:null==i?void 0:i.videoStreamTransformCallback,audioStreamTransformCallback:null==i?void 0:i.audioStreamTransformCallback,encodedVideoStreamSink:null==i?void 0:i.encodedVideoStreamSink,encodedAudioStreamSink:null==i?void 0:i.encodedAudioStreamSink};this._tokenContext=new $e(r),this._channelContext=new Xe(u),this._peerConnectionContext=new nt,this._streamTransformContext=new tt(c),this._stateContext=new rt,this._exponentialBackoff=new xe,this._channelStartTime=Date.now(),this._readOnlyPeerConnection=new C(this._peerConnectionContext.peerConnection),this._readOnlyState=new C(this._channelContext.state),this._readOnlyExists=new C(this._channelContext.exists),this._readOnlyAutoMuted=new C(this._channelContext.autoMuted),this._readOnlyAutoPaused=new C(this._channelContext.autoPaused),this._readOnlyTokenExpiring=new C(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new C(this._channelContext.authorized),this._readOnlyOnline=new C(this._channelContext.online),this._readOnlyLoading=new C(this._channelContext.loading),this._readOnlyPlaying=new C(this._channelContext.playing),this._readOnlyStandby=new C(this._channelContext.standby),this._readOnlyStopped=new C(this._channelContext.stopped),this._readOnlyTargetLag=new C(this._channelContext.targetLag),this._readOnlyLag=new C(this._channelContext.lag),this._readOnlyBitrateLimit=new C(this._channelContext.bitrateLimit),this._readOnlyResolution=new C(this._channelContext.resolution),this._readOnlyFailureCount=new C(this._channelContext.failureCount),this._readOnlyEndPoint=new C(this._channelContext.endPoint),this._readOnlyStream=new C(this._channelContext.stream),this._readOnlyRtcStatistics=new C(this._channelContext.rtcStatistics),this._readOnlyMediaStream=new C(this._peerConnectionContext.mediaStream);var l=(a.uri||Ve.discoveryUri.value).toString();Ve.tenancy.value=a.tenancy||Ve.tenancy.value,Se.uri.value=l,this._metricsService=je.getMetricsService(l),this._sessionTelemetry=new Ke(Ve.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=n,this._frameTimingInformationContext=new it,this.configureFrameTimingInformation(a.capabilities),this._readOnlyIsFrameTimingInformationEnabled=new C(this._frameTimingInformationContext.isEnabled),this._readOnlyDecodedFrameTimingInformation=new C(this._frameTimingInformationContext.decodedFrameTimingInformation),this._readOnlyRenderedFrameTimingInformation=new C(this._frameTimingInformationContext.renderedFrameTimingInformation),this._channelContext.channelDisposables.add(this._channelContext.videoElement.subscribe(function(e){o._channelContext.rendererDisposables.dispose(),e&&(o._channelContext.rendererDisposables.add(o._channelContext.stream.subscribe(function(e){o._channelContext.videoTelemetry&&o._channelContext.videoTelemetry.dispose(),e&&o.videoElement&&(o.videoElement.dataset&&(o.videoElement.dataset.sessionId=Ve.clientSessionId,o.videoElement.dataset.streamId=o.streamId),o._channelContext.videoTelemetry=new qe(o.streamId,Ve.pageLoadTime,o._channelStartTime,o._metricsService),o._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(o.videoElement),o._channelContext.videoTelemetry.setupListenerForRebuffering(o.videoElement),o._channelContext.state.value===Ne.Stopped)&&o.restartAfterStop()})),o._channelContext.channelDisposables.add(o._channelContext.rendererDisposables))})),this._channelContext.channelDisposables.add(this._channelContext.state.subscribe(function(e){o._channelContext.clearFailureCountTimeout&&P.value.clearTimeout(o._channelContext.clearFailureCountTimeout),o._channelContext.failureCount.value&&e===Ne.Playing&&(o._channelContext.clearFailureCountTimeout=P.value.setTimeout(function(){o._channelContext.failureCount.value=0},3e3))})),this._channelContext.channelDisposables.add(this._channelContext.resolution.subscribe(function(e){o._channelContext.videoTelemetry&&o._channelContext.videoTelemetry.onVideoResolutionChanges(e.toString())})),this._channelContext.channelDisposables.add(this._channelContext.bitrateLimit.subscribe(function(e){if(e&&o._channelContext.endPoint.value&&o._channelContext.stream.value){var t=Date.now()-o._channelContext.channelInitialization.getTime();o._channelContext.endPoint.value.limitBitrate(o._channelContext.stream.value,t,e,Qe.Keep,Ze.Normal).catch(function(e){o._logger.error("Error while setting limit bitrate",e)})}}));var d=function(){o._channelContext.stream.value&&o._channelContext.endPoint.value&&o._channelContext.endPoint.value.destroyStreamOnUnmount(o._channelContext.stream.value,"client:termination-on-window-unload")};P.value.addWindowEventListener("beforeunload",d),this._channelContext.channelDisposables.add(new m(function(){P.value.removeWindowEventListener("beforeunload",d)})),this.start(),Ve.automaticRetryOnFailure&&this._channelContext.channelDisposables.add(Ve.applicationActivityMonitor.isForeground.subscribe(function(e){if(e){var t=Ve.applicationActivityMonitor.getLastBackgroundDuration(),n=O.isMobile&&null!==t&&t>5e3,r=o._channelContext.state.value===Ne.Reconnecting&&null!==t&&t>3e4;if(n||r)return o._logger.info("[%s] Foregrounded after [%s] ms in background, forcing restart",o._channelContext.streamId,t),void o.restartOnForeground("client:foregrounded:background-timeout");o.isRetryableState()?o.restartOnForeground("client:foregrounded:unhealthy"):o._streamSubscriber&&o.isSubscriberHealthy().then(function(e){e||o._stateContext.isStarting.value||o._channelContext.state.value!==Ne.Playing||(o._channelContext.failureCount.value=0,o._logger.debug("[%s] Reset failureCount to 0 and restarting Channel after returning to foreground",o._channelContext.streamId),o.start())}).catch(function(e){o._logger.error("[%s] Unexpected error occurred when checking subscriber health while foregrounding",o._channelContext.streamId,e)})}}))},[{key:"videoElement",get:function(){return this._channelContext.videoElement.value},set:function(e){this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.removeEventListener("loadeddata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.removeEventListener("loadedmetadata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.removeEventListener("resize",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.dataset&&(this._channelContext.videoElement.value.dataset.sessionId="",this._channelContext.videoElement.value.dataset.streamId=""),this._channelContext.rendererDisposables.dispose(),this._channelContext.videoElement.value.pause(),this._channelContext.videoElement.value.srcObject=null),this._channelContext.autoMuted.value=!1,this._channelContext.autoPaused.value=!1,this._channelContext.loading.value=!1,this._channelContext.playing.value=!1,this._channelContext.state.value!==Ne.Initializing&&(this._channelContext.state.value=Ne.Stopped),this._channelContext.videoElement.value=e,this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.addEventListener("loadeddata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.addEventListener("loadedmetadata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.addEventListener("resize",this._videoMetaDataChangedHandler))}},{key:"handleVideoMetaDataChanged",value:function(){var e=this._channelContext.videoElement.value;e?this.resolution.value.width===e.videoWidth&&this.resolution.value.height===e.videoHeight||(this._channelContext.resolution.value=new Ge(e.videoWidth,e.videoHeight)):this._channelContext.resolution.value=Ge.empty}},{key:"token",get:function(){return this._tokenContext.token.value},set:function(e){this._channelContext.disposables.dispose(),this._tokenContext.token.value=e,this._tokenContext.tokenExpiring.value=!1;var t=re.parseToken(this._tokenContext.token.value),n=(t.uri||Ve.discoveryUri.value).toString();Ve.tenancy.value=t.tenancy||Ve.tenancy.value,Se.uri.value=n,this._metricsService=je.getMetricsService(n),this._streamTransformContext.hasInsertableStreams.value=t.capabilities.includes("insertable-streams"),this._streamTransformContext.hasEncodedInsertableStreams.value=t.capabilities.includes("encoded-insertable-streams"),this.configureFrameTimingInformation(t.capabilities),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"exists",get:function(){return this._readOnlyExists}},{key:"autoMuted",get:function(){return this._readOnlyAutoMuted}},{key:"autoPaused",get:function(){return this._readOnlyAutoPaused}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"playing",get:function(){return this._readOnlyPlaying}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"targetLag",get:function(){return this._readOnlyTargetLag}},{key:"lag",get:function(){return this._readOnlyLag}},{key:"bitrateLimit",get:function(){return this._readOnlyBitrateLimit.value}},{key:"resolution",get:function(){return this._readOnlyResolution}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._channelContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"isFrameTimingInformationEnabled",get:function(){return this._readOnlyIsFrameTimingInformationEnabled}},{key:"decodedFrameTimingInformation",get:function(){return this._readOnlyDecodedFrameTimingInformation}},{key:"renderedFrameTimingInformation",get:function(){return this._readOnlyRenderedFrameTimingInformation}},{key:"setBitrateLimit",value:function(e){this._channelContext.bitrateLimit.value=e}},{key:"clearBitrateLimit",value:function(){var e=this;if(this._channelContext.bitrateLimit.value&&this._channelContext.endPoint.value&&this._channelContext.stream.value){var t=Date.now()-this._channelContext.channelInitialization.getTime();this._channelContext.endPoint.value.limitBitrate(this._channelContext.stream.value,t,0,Qe.Keep,Ze.Reset).then(function(t){"ok"===t.status&&(e._channelContext.bitrateLimit.value=0)}).catch(function(t){e._logger.error("Error while setting limit bitrate",t)})}}},{key:"updateTargetLag",value:function(e){this._channelContext.targetLag.value=e}},{key:"stop",value:(d=V()(yn().m(function e(t){var n=this;return yn().w(function(e){for(;;)if(0===e.n)return e.a(2,new gn(function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._channelContext.rendererDisposables.add(n._stateContext.isStarting.subscribe(function(r){r||(n.processStop(t),e())}))}))},e)})),function(e){return d.apply(this,arguments)})},{key:"processStop",value:function(e){this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.pause(),this._channelContext.videoElement.value.srcObject=null),this._channelContext.rendererDisposables.dispose(),this.cleanUpResources(e),this._channelContext.state.value=Ne.Stopped}},{key:"resume",value:(l=V()(yn().m(function e(){return yn().w(function(e){for(;;)switch(e.n){case 0:if(!this._peerConnectionContext.mediaStream.value){e.n=1;break}return this._channelContext.autoPaused.value=!1,e.a(2,this.playMediaStreamInVideoElement(this._peerConnectionContext.mediaStream.value));case 1:return e.a(2)}},e,this)})),function(){return l.apply(this,arguments)})},{key:"mute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!0)}},{key:"unmute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!1,this._channelContext.autoMuted.value=!1)}},{key:"dispose",value:(c=V()(yn().m(function e(){var t=this;return yn().w(function(e){for(;;)if(0===e.n)return e.a(2,this.stop("client:channel-dispose").then(function(){t._channelContext.channelDisposables.dispose(),t._stateContext.isDisposed=!0}))},e,this)})),function(){return c.apply(this,arguments)})},{key:"getUri",value:function(e){return re.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",Ve.discoveryUri.value),new P.value.URL(Ve.discoveryUri.value))}},{key:"start",value:(u=V()(yn().m(function e(){return yn().w(function(e){for(;;)switch(e.n){case 0:if(!this._stateContext.isDisposed){e.n=1;break}throw new Error("Channel was already disposed");case 1:if(!this._stateContext.isStarting.value){e.n=2;break}return this._logger.info("Channel is already starting, skipping start"),e.a(2);case 2:return this._stateContext.isStarting.value=!0,e.a(2,this.processStart())}},e,this)})),function(){return u.apply(this,arguments)})},{key:"isRetryableState",value:function(){switch(this._channelContext.state.value){case Ne.Error:case Ne.Reconnecting:case Ne.StandBy:case Ne.Offline:case Ne.Recovering:case Ne.TransientConfigurationError:case Ne.ConnectionError:case Ne.ClientStartError:return!0;case Ne.Unauthorized:case Ne.GeoRestricted:case Ne.GeoBlocked:case Ne.Stopped:case Ne.Paused:case Ne.Initializing:case Ne.Starting:case Ne.Playing:case Ne.UnsupportedFeature:case Ne.ConfigurationError:return!1;default:Z(this._channelContext.state.value)}}},{key:"isSubscriberHealthy",value:function(){return this._streamSubscriber?this._streamSubscriber.isStreamHealthy():gn.resolve(!1)}},{key:"restartOnForeground",value:function(e){this._stateContext.isStarting.value?this._logger.debug("[%s] Skipping failureCount reset and Channel restart due to Channel already starting",this._channelContext.streamId):this.isRetryableState()?(this._channelContext.failureCount.value=0,this._logger.debug("[%s] Reset failureCount to 0 and restarting Channel due to [%s]",this._channelContext.streamId,e),this.start()):this._logger.debug("[%s] Skipping failureCount reset and Channel restart due to ChannelState [%s] which is not retryable",this._channelContext.streamId,Ne[this._channelContext.state.value])}},{key:"processStart",value:(a=V()(yn().m(function e(){var t,n,r,i,o,a,s,u,c,l,d,h,f,p,v,g,y,_,b,C=this;return yn().w(function(e){for(;;)switch(e.n){case 0:if(t=this._channelContext.state.value!==Ne.Initializing,this._channelContext.state.value=t?Ne.Recovering:Ne.Starting,this.cleanUpResources(t?"client:recover":"client:start"),n=this._tokenContext.token.value,r=this._sessionTelemetry.listenOnStreamSetup(),re.isEncodedEdgeTokenValid(n)){e.n=1;break}return this._logger.error("Failed to parse token [%s]",n),this._channelContext.state.value=Ne.Unauthorized,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 1:if(!this._streamTransformContext.videoStreamTransformCallback){e.n=2;break}if(i=et.validateMediaStreamTrackTransform("video",this._streamTransformContext.videoStreamTransformCallback),o=i.valid,a=i.validationResult,o){e.n=2;break}return this._logger.error(a),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 2:if(!this._streamTransformContext.audioStreamTransformCallback){e.n=3;break}if(s=et.validateMediaStreamTrackTransform("audio",this._streamTransformContext.audioStreamTransformCallback),u=s.valid,c=s.validationResult,u){e.n=3;break}return this._logger.error(c),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 3:if(!this._streamTransformContext.encodedVideoStreamSink){e.n=4;break}if(l=Ye.validateEncodedStreamSink("video",this._streamTransformContext.encodedVideoStreamSink),d=l.valid,h=l.validationResult,d){e.n=4;break}return this._logger.error(h),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 4:if(!this._streamTransformContext.encodedAudioStreamSink){e.n=5;break}if(f=Ye.validateEncodedStreamSink("audio",this._streamTransformContext.encodedAudioStreamSink),p=f.valid,v=f.validationResult,p){e.n=5;break}return this._logger.error(v),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 5:if(!this._streamTransformContext.hasInsertableStreams.value||!this._streamTransformContext.hasEncodedInsertableStreams.value){e.n=6;break}return this._logger.error("Both insertable-streams and encoded-insertable-streams are enabled, only use one or the other"),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 6:if(g="function"==typeof this._streamTransformContext.videoStreamTransformCallback||"function"==typeof this._streamTransformContext.audioStreamTransformCallback,y="function"==typeof this._streamTransformContext.encodedVideoStreamSink||"function"==typeof this._streamTransformContext.encodedAudioStreamSink,!g||!y){e.n=7;break}return this._logger.error("Both Media Stream Track transform callback and encodedInsertableStreams sink function found, only use one type or the other"),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 7:if(!this._streamTransformContext.hasInsertableStreams.value){e.n=10;break}if(O.isInsertableStreamsSupported){e.n=8;break}return this._logger.error("Browser does not support Media Stream Track API"),this._channelContext.state.value=Ne.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 8:if(g){e.n=9;break}return this._logger.error("CreateChannelOptions transform callback function is missing; however, insertable-streams is enabled"),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 9:e.n=11;break;case 10:if(!g){e.n=11;break}return this._logger.error("CreateChannelOptions transform callback function found; however, insertable-streams is not enabled"),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 11:if(!this._streamTransformContext.hasEncodedInsertableStreams.value){e.n=14;break}if(O.isEncodedInsertableStreamsSupported||O.isRTCRtpScriptTransformSupported){e.n=12;break}return this._logger.error("Browser does not support encodedInsertableStreams API"),this._channelContext.state.value=Ne.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 12:if(y){e.n=13;break}return this._logger.error("CreateChannelOptions transform sink function is missing; however, encoded-insertable-streams is enabled"),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 13:e.n=15;break;case 14:if(!y){e.n=15;break}return this._logger.error("CreateChannelOptions transform sink function found; however, encoded-insertable-streams is not enabled"),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 15:if(this._channelContext.loading.value=!0,_=this.getUri(n),this._channelContext.disposables.add(this._channelContext.state.subscribe(function(e){e!==Ne.Error&&e!==Ne.Recovering||Ft.clearCachedClosestEndpoint(_)})),b=function(){return new gn(function(e){if(!C.isRetryableState())return C._logger.debug("[%s] Ignoring stream failure callback due to ChannelState being [%s]",C._channelContext.streamId,Ne[C._channelContext.state.value]),e();if(C._stateContext.isStarting.value=!1,C._channelContext.state.value=Ne.ConnectionError,C._channelContext.videoElement.value&&(C._channelContext.videoElement.value.pause(),C._channelContext.videoElement.value.srcObject=null),C._channelContext.playing.value=!1,C._channelContext.loading.value=!0,!Ve.applicationActivityMonitor.isForeground.value){C._logger.debug("[%s] Deferring stream failure handling to foreground recovery",C._channelContext.streamId);var t=P.value.setTimeout(function(){C.handleStreamFailure().catch(function(e){C._logger.error("Failed handling stream failure",e)})},5e3);return C._channelContext.disposables.add(new m(function(){P.value.clearTimeout(t)})),e()}return e(C.handleStreamFailure())})},this._streamSubscriber=mn.create(n,this._channelContext,this._peerConnectionContext,this._streamTransformContext,this._frameTimingInformationContext,b),this._streamSubscriber){e.n=16;break}return this._stateContext.isStarting.value=!1,e.a(2);case 16:return this._channelContext.rendererDisposables.add(this._streamSubscriber),e.a(2,this._streamSubscriber.start(_,n,r,this.playMediaStreamInVideoElement.bind(this)).then(function(){C._channelContext.loading.value=!1}).catch(function(e){r.fail(),C._channelContext.failureCount.value++,C._channelContext.online.value=!1,C.cleanUpResources("client:cleanup-after-failed-setup"),C._channelContext.state.value=Ne.ClientStartError,C._logger.error("Failed to start channel",e)}).finally(function(){if(C._stateContext.isStarting.value=!1,C._channelContext.state.value!==Ne.Playing&&C._channelContext.state.value!==Ne.Paused&&C._channelContext.state.value!==Ne.Stopped&&Ve.automaticRetryOnFailure){var e=P.value.setTimeout(function(){C.handleStreamFailure().catch(function(e){C._logger.error("Failed handling stream failure",e)})},C.getRetryInterval());C._channelContext.disposables.add(new m(function(){P.value.clearTimeout(e)}))}}))}},e,this)})),function(){return a.apply(this,arguments)})},{key:"restartAfterStop",value:(i=V()(yn().m(function e(){return yn().w(function(e){for(;;)switch(e.n){case 0:if(!this._stateContext.isDisposed){e.n=1;break}throw new Error("Channel was already disposed");case 1:if(!this._peerConnectionContext.mediaStream.value){e.n=2;break}return e.a(2,this.playMediaStreamInVideoElement(this._peerConnectionContext.mediaStream.value));case 2:this._tokenContext.token.value&&this.start();case 3:return e.a(2)}},e,this)})),function(){return i.apply(this,arguments)})},{key:"play",value:(r=V()(yn().m(function e(){var t;return yn().w(function(e){for(;;)switch(e.n){case 0:if(t=this._peerConnectionContext.mediaStream.value){e.n=1;break}return e.a(2,this.start());case 1:return e.a(2,this.playMediaStreamInVideoElement(t))}},e,this)})),function(){return r.apply(this,arguments)})},{key:"getRetryInterval",value:function(){switch(this._channelContext.state.value){case Ne.Initializing:case Ne.StandBy:case Ne.Offline:return 15e3;case Ne.Error:case Ne.Recovering:case Ne.Unauthorized:case Ne.GeoRestricted:case Ne.GeoBlocked:case Ne.Stopped:case Ne.Starting:case Ne.Playing:case Ne.Paused:case Ne.Reconnecting:case Ne.UnsupportedFeature:case Ne.ConfigurationError:case Ne.TransientConfigurationError:case Ne.ConnectionError:case Ne.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._channelContext.failureCount.value);default:Z(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(n=V()(yn().m(function e(){var t;return yn().w(function(e){for(;;)switch(e.n){case 0:t=this._channelContext.state.value,e.n=t===Ne.Error||t===Ne.Reconnecting||t===Ne.StandBy||t===Ne.Offline||t===Ne.Recovering||t===Ne.TransientConfigurationError||t===Ne.ConnectionError||t===Ne.ClientStartError?1:t===Ne.Unauthorized?2:t===Ne.GeoRestricted?3:t===Ne.GeoBlocked?4:t===Ne.Stopped?5:t===Ne.Initializing?6:t===Ne.Playing?7:t===Ne.Paused?8:t===Ne.Starting?9:t===Ne.UnsupportedFeature?10:t===Ne.ConfigurationError?11:12;break;case 1:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,Ne[this._channelContext.state.value]),e.a(3,13);case 2:return this._logger.info("Channel is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 3:return this._logger.info("Channel is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 4:return this._logger.info("Channel is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 5:return this._logger.info("Channel is stopped, skipping retry of start."),e.a(2);case 6:return this._logger.info("Channel is already initializing, skipping retry of start"),e.a(2);case 7:return this._logger.info("Channel is playing, skipping retry of start"),e.a(2);case 8:return this._logger.info("Channel is paused, skipping retry of start. Please invoke play()"),e.a(2);case 9:return this._logger.info("Channel is already starting, skipping retry of start"),e.a(2);case 10:return this._logger.info("Channel is stopped due to unsupported feature, skipping retry of start."),e.a(2);case 11:return this._logger.info("Channel is stopped due to configuration error, skipping retry of start."),e.a(2);case 12:Z(this._channelContext.state.value);case 13:return e.a(2,this.start())}},e,this)})),function(){return n.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._streamSubscriber=null,this._channelContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!Ve.forceGarbageCollectionOnRestart||O.isMobile&&Ve.skipGarbageCollectionOnMobileDevices||Be.forceGarbageCollection()),this._peerConnectionContext.mediaStream.value&&(this._peerConnectionContext.mediaStream.value.getTracks().forEach(function(e){return e.stop()}),this._peerConnectionContext.mediaStream.value=null),this._channelContext.autoPaused.value=!1,this._channelContext.autoMuted.value=!1,this._channelContext.playing.value=!1,this._channelContext.stopped.value=!0,this._channelContext.standby.value=!1,this._channelContext.stream.value&&this._channelContext.endPoint.value&&this._channelContext.endPoint.value.destroyStream(this._channelContext.stream.value,t).then(function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)}).catch(function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)}),this.videoElement&&this.videoElement.dataset&&(this.videoElement.dataset.sessionId="",this.videoElement.dataset.streamId=""),this._channelContext.stream.value=null,this._channelContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}},{key:"configureFrameTimingInformation",value:function(e){var t=this,n=e.find(function(e){return e.startsWith("frame-timing-information=")});this._frameTimingInformationContext.shouldExtractTimecode.value=!1,this._frameTimingInformationContext.shouldExtractTimestamps.value=!1,this._frameTimingInformationContext.isEnabled.value=!1,n?O.isChannelFrameTimingInformationSupported?(n.split("=")[1].split(",").map(function(e){return e.trim()}).forEach(function(e){switch(e){case"timecode":t._frameTimingInformationContext.shouldExtractTimecode.value=!0;break;case"timestamps":t._frameTimingInformationContext.shouldExtractTimestamps.value=!0;break;default:t._logger.info("Ignoring unknown frame timing information option [%s]",e)}}),this._logger.info("Frame timing information configuration [(timecode [%s], timestamps [%s])]",this._frameTimingInformationContext.shouldExtractTimecode.value,this._frameTimingInformationContext.shouldExtractTimestamps.value)):this._logger.info("Disabling frame timing information as the environment does not support it [%s]",n):this._logger.info("Disabling frame timing information as no capability was found")}},{key:"playMediaStreamInVideoElement",value:(e=V()(yn().m(function e(t){var n,r,i=this;return yn().w(function(e){for(;;)switch(e.n){case 0:if(n=this._channelContext.videoElement.value){e.n=1;break}return this._channelContext.autoMuted.value=!1,this._channelContext.autoPaused.value=!1,this._channelContext.loading.value=!1,this._channelContext.playing.value=!1,this._channelContext.state.value=Ne.Stopped,e.a(2);case 1:if(this._streamTransformContext.hasEncodedInsertableStreams.value||(n.srcObject=t),void 0!==(r=n.play())){e.n=2;break}return this._channelContext.autoMuted.value=!1,this._channelContext.autoPaused.value=!1,this._channelContext.loading.value=!1,this._channelContext.playing.value=!0,this._channelContext.state.value=Ne.Playing,e.a(2);case 2:return e.a(2,r.then(function(){i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!1,i._channelContext.loading.value=!1,i._channelContext.playing.value=!0,i._channelContext.state.value=Ne.Playing}).catch(function(e){var r=!!t.getTracks().filter(function(e){return"audio"===e.kind}).length,o=!Ve.automaticallyMuteVideoOnPlayFailure;return o||n.muted||!r?(n.srcObject=null,i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=Ne.Paused,o?void i._logger.info("[%s] Paused video after play failed. Manual user action required.",i.streamId,e):r?void i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e):void i._logger.info("[%s] Failed to play muted video. Manual user action required.",i.streamId,e)):(n.muted=!0,n.play().then(function(){i._logger.info("[%s] Played video after auto muting. Manual user action required to unmute.",i.streamId),i._channelContext.autoMuted.value=!0,i._channelContext.autoPaused.value=!1,i._channelContext.loading.value=!1,i._channelContext.playing.value=!0,i._channelContext.state.value=Ne.Playing}).catch(function(e){n.muted=!1,i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e),n.srcObject=null,i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=Ne.Paused}))}))}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e,n,r,i,a,u,c,l,d}(),Cn=function(){return o()(function e(){throw t()(this,e),new Error("Channels is a static class that may not be instantiated")},null,[{key:"createChannel",value:function(e){if(!Ve.initialized.value)throw new Error("SDK is not loaded.");var t={targetLag:e.targetLag,videoStreamTransformCallback:e.videoStreamTransformCallback,audioStreamTransformCallback:e.audioStreamTransformCallback,encodedVideoStreamSink:e.encodedVideoStreamSink,encodedAudioStreamSink:e.encodedAudioStreamSink},n=e;return n.onRealTimeSubscribeRequestCallback&&(t.onRealTimeSubscribeRequestCallback=n.onRealTimeSubscribeRequestCallback),n.onRealTimeSubscribeResponseCallback&&(t.onRealTimeSubscribeResponseCallback=n.onRealTimeSubscribeResponseCallback),new bn(e.videoElement,e.token,t)}},{key:"isFrameTimingInformationSupported",get:function(){return O.isChannelFrameTimingInformationSupported}}])}(),kn=function(e){return e[e.Initializing=0]="Initializing",e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Publishing=3]="Publishing",e[e.Recovering=4]="Recovering",e[e.Reconnecting=5]="Reconnecting",e[e.Stopped=6]="Stopped",e[e.Unauthorized=7]="Unauthorized",e[e.GeoRestricted=8]="GeoRestricted",e[e.GeoBlocked=9]="GeoBlocked",e[e.UnsupportedFeature=10]="UnsupportedFeature",e[e.NotFound=11]="NotFound",e[e.ConfigurationError=12]="ConfigurationError",e[e.TransientConfigurationError=13]="TransientConfigurationError",e[e.ConnectionError=14]="ConnectionError",e[e.ClientStartError=15]="ClientStartError",e[e.Error=16]="Error",e}(kn||{}),Sn=kn,wn=function(){return o()(function e(n){t()(this,e),s()(this,"publisherInitialization",void 0),s()(this,"disposables",void 0),s()(this,"publisherDisposables",void 0),s()(this,"state",void 0),s()(this,"authorized",void 0),s()(this,"online",void 0),s()(this,"loading",void 0),s()(this,"publishing",void 0),s()(this,"standby",void 0),s()(this,"stopped",void 0),s()(this,"failureCount",void 0),s()(this,"endPoint",void 0),s()(this,"stream",void 0),s()(this,"rtcStatistics",void 0),s()(this,"clearFailureCountTimeout",void 0),s()(this,"startReconnectionAttemptsTimeInMilliseconds",void 0),s()(this,"name",void 0),this.disposables=new ie,this.publisherDisposables=new ie,this.publisherInitialization=new Date,this.state=new b(Sn.Initializing),this.authorized=new b(!0),this.online=new b(!0),this.loading=new b(!1),this.publishing=new b(!1),this.standby=new b(!1),this.stopped=new b(!1),this.failureCount=new b(0),this.endPoint=new b(null),this.stream=new b(null),this.rtcStatistics=new b(null),this.clearFailureCountTimeout=0,this.name=n&&n.length?n:this.generateScreenName(),this.startReconnectionAttemptsTimeInMilliseconds=0},[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyPublishStatus",value:function(e){switch(e){case"ok":return;case"unauthorized":case"geo-restricted":case"geo-blocked":return void this.applyUnauthorized();case"not-found":return void this.applyNotFound();default:return void this.applyUnhandledError()}}},{key:"applySetRemoteDescriptionStatus",value:function(e){switch(e){case"ok":return;case"unauthorized":return void this.applyUnauthorized();case"not-found":return void this.applyNotFound();default:return void this.applyUnhandledError()}}},{key:"applyAddIceCandidatesStatus",value:function(e){switch(e){case"ok":return;case"unauthorized":return void this.applyUnauthorized();case"not-found":return void this.applyNotFound();default:return void this.applyUnhandledError()}}},{key:"mapPublishStatusToPublisherStatus",value:function(e){switch(e){case"ok":return Sn.Starting;case"not-found":return Sn.NotFound;case"geo-restricted":return Sn.GeoRestricted;case"geo-blocked":return Sn.GeoBlocked;case"unauthorized":return Sn.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Sn.Recovering;case"missing-channel-or-room-id":case"forbidden-tag":return Sn.ConfigurationError;case"port-in-range-not-found":return Sn.TransientConfigurationError;case"failed":return Sn.Error;default:Z(e)}}},{key:"applyUnhandledError",value:function(){this.failureCount.value++,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null}},{key:"applyUnauthorized",value:function(){this.authorized.value=!1,this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null}},{key:"applyNotFound",value:function(){this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null}},{key:"generateScreenName",value:function(){return te.random(12)}}])}(),Tn=n(981).A;function xn(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return Pn(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Pn(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Pn(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,Pn(d,"constructor",c),Pn(c,"constructor",u),u.displayName="GeneratorFunction",Pn(c,i,"GeneratorFunction"),Pn(d),Pn(d,i,"Generator"),Pn(d,r,function(){return this}),Pn(d,"toString",function(){return"[object Generator]"}),(xn=function(){return{w:o,m:h}})()}function Pn(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Pn=function(e,t,n,r){function o(t,n){Pn(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},Pn(e,t,n,r)}var En=function(){return o()(function e(n,r,i){var o,a,u,c,l=this;if(t()(this,e),s()(this,"_logger",ee.getLogger("RtcPublishMonitor")),s()(this,"_estimatedRoundTripTime",void 0),s()(this,"_estimatedVideoCodec","unknown"),s()(this,"_estimatedAudioCodec","unknown"),s()(this,"_rtcStatistic",new b({})),s()(this,"_disposables",new ie),s()(this,"_peerConnection",void 0),s()(this,"_isMonitorRunning",!0),s()(this,"_updateTimeout",void 0),s()(this,"_monitorGeneration",0),s()(this,"_availableTracks",null),this._peerConnection=n,this._estimatedRoundTripTime=r,this._peerConnection&&null!==(o=this._peerConnection)&&void 0!==o&&null!==(a=o.currentLocalDescription)&&void 0!==a&&a.sdp&&null!==(u=this._peerConnection)&&void 0!==u&&null!==(c=u.currentRemoteDescription)&&void 0!==c&&c.sdp){var d=new st(this._peerConnection.currentLocalDescription.sdp),h=new st(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=h.audioCodec,this._estimatedVideoCodec=h.videoCodec,this._availableTracks={audio:d.isAudioTrackEnabled&&h.isAudioTrackEnabled,video:d.isVideoTrackEnabled&&h.isVideoTrackEnabled};var f=!0;this._disposables.add(i.subscribe(function(e){f?f=!1:e&&l._isMonitorRunning&&(l._monitorGeneration++,P.value.clearTimeout(l._updateTimeout),l._logger.debug("Restarting stats polling after foreground transition"),l.updateStatistic())})),this.updateStatistic()}},[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._monitorGeneration++,this._isMonitorRunning=!1,this._peerConnection=null,this._disposables.dispose(),P.value.clearTimeout(this._updateTimeout),this._updateTimeout=void 0}},{key:"updateStatistic",value:(e=V()(xn().m(function e(){var t,n,r,i,o,a,s,u,c,l,d,h=this;return xn().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!O.getStatsPromiseBasedDisabled){e.n=1;break}return e.a(2);case 1:if(t=this._monitorGeneration,n=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.p=2,o=null===(i=this._peerConnection)||void 0===i?void 0:i.getStats(null)){e.n=3;break}return e.a(2);case 3:return a=new Tn(function(e){r=P.value.setTimeout(function(){return e(void 0)},5e3)}),e.n=4,Tn.race([o,a]);case 4:if(s=e.v,t===this._monitorGeneration&&this._isMonitorRunning){e.n=5;break}return e.a(2);case 5:s?(u={},c=this._estimatedRoundTripTime,s.forEach(function(e){if("candidate-pair"===e.type&&e.currentRoundTripTime&&(c=1e3*e.currentRoundTripTime,u.audio&&(u.audio.roundTripTime=c),u.video&&(u.video.roundTripTime=c)),"candidate-pair"===e.type&&e.lastPacketSentTimestamp&&(l=e.lastPacketSentTimestamp,u.audio&&(u.audio.lastPacketSentTimestamp=l),u.video&&(u.video.lastPacketSentTimestamp=l)),"outbound-rtp"===e.type){var t,r=e.kind||e.mediaType||n(e),i="";if(s.forEach(function(t){t.id===e.codecId&&(i=t.mimeType)}),r&&null!==(t=h._availableTracks)&&void 0!==t&&t[r]){var o,a,d,f,p,v,m,g=(e.bytesSent||0)-(null!==(o=null===(a=h._rtcStatistic.value)||void 0===a||null===(d=a[r])||void 0===d?void 0:d.bytesSent)&&void 0!==o?o:0),y=e.timestamp-(null===(f=h._rtcStatistic.value)||void 0===f||null===(p=f[r])||void 0===p?void 0:p.timestamp),_=g&&y?Math.floor(8*g/y*1e3):0;if(u[r]={ssrc:e.ssrc,mediaType:r,timestamp:e.timestamp,bitrate:_,bytesSent:e.bytesSent,packetsSent:e.packetsSent,retransmittedBytesSent:e.retransmittedBytesSent,codec:i||h.getCodecByType(r),roundTripTime:c},(e.lastPacketSentTimestamp||l)&&(u[r].lastPacketSentTimestamp=e.lastPacketSentTimestamp||l),"video"===r&&(u[r].firCount=e.firCount,u[r].frameHeight=e.frameHeight,u[r].frameWidth=e.frameWidth,u[r].framesEncoded=e.framesEncoded,u[r].framesSent=e.framesSent,u[r].headerBytesSent=e.headerBytesSent,u[r].hugeFramesSent=e.hugeFramesSent,u[r].pliCount=e.pliCount,u[r].qpSum=e.qpSum,u[r].totalEncodeTime=e.totalEncodeTime,u[r].totalEncodedBytesTarget=e.totalEncodedBytesTarget,null!==(v=h._rtcStatistic.value)&&void 0!==v&&null!==(m=v.video)&&void 0!==m&&m.framesEncoded)){var b=(e.framesEncoded-h._rtcStatistic.value.video.framesEncoded)/(u[r].timestamp-h._rtcStatistic.value.video.timestamp)*1e3;u[r].fps=b?Math.round(100*b)/100:0}}}}),this._rtcStatistic.value=u):this._logger.debug("getStats() timed out, skipping stats processing"),e.n=8;break;case 6:if(e.p=6,d=e.v,t===this._monitorGeneration&&this._isMonitorRunning){e.n=7;break}return e.a(2);case 7:this._logger.warn("getStats() rejected",d);case 8:return e.p=8,P.value.clearTimeout(r),e.f(8);case 9:this._isMonitorRunning&&t===this._monitorGeneration&&(this._updateTimeout=P.value.setTimeout(function(){return h.updateStatistic()},1e3));case 10:return e.a(2)}},e,this,[[2,6,8,9]])})),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec||"unknown";case"video":return this._estimatedVideoCodec||"unknown";default:return"unknown"}}}]);var e}(),On=n(981).A;function Rn(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return Fn(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Fn(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Fn(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,Fn(d,"constructor",c),Fn(c,"constructor",u),u.displayName="GeneratorFunction",Fn(c,i,"GeneratorFunction"),Fn(d),Fn(d,i,"Generator"),Fn(d,r,function(){return this}),Fn(d,"toString",function(){return"[object Generator]"}),(Rn=function(){return{w:o,m:h}})()}function Fn(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Fn=function(e,t,n,r){function o(t,n){Fn(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},Fn(e,t,n,r)}function In(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ln(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?In(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):In(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Dn=function(){return o()(function e(n,r,i){t()(this,e),s()(this,"_logger",ee.getLogger("RealTimePublisher")),s()(this,"_publisherContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_handleStreamFailure",void 0),this._publisherContext=n,this._peerConnectionContext=r,this._handleStreamFailure=i},[{key:"start",value:function(e,t,n){var r=this;if(!P.value.navigatorIsOnLine)return this._publisherContext.state.value=Sn.Offline,On.resolve();var i=this._peerConnectionContext.mediaStream.value;if(!i)return this._logger.error("Publish failed no media stream provided"),this._publisherContext.state.value=Sn.ConfigurationError,On.resolve();var o=i.getTracks().reduce(function(e,t){return"audio"===t.kind||"video"===t.kind?e.push(t.kind):r._logger.warn("[%s] Track kind is not supported",t.kind),e},[]);return On.all([Ft.discoverClosestEndPointWithCaching(e),_e.createPeerConnectionOffer("sendonly",o).then(function(e){var t=e.localOffer,n=e.peerConnection;return r._peerConnectionContext.peerConnection.value=n,{localOffer:t,peerConnection:n}})]).then(function(e){var n=at()(e,2),i=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;return r._publisherContext.online.value=!0,r._publisherContext.endPoint.value=i,r._logger.info("Connecting to [%s]",i.toString()),r._logger.info("Local offer:\n"+a.sdp),O.clientOfferDisabled||!s.supportsSetConfiguration||!s.supportsGetConfiguration||r._publisherContext.failureCount.value>0?(s.close(),s.dispose(),!Ve.forceGarbageCollectionOnRestart||O.isMobile&&Ve.skipGarbageCollectionOnMobileDevices||Be.forceGarbageCollection(),r._peerConnectionContext.peerConnection.value=null,i.publish(r._publisherContext.name,t,null,r._publisherContext.failureCount.value)):i.publish(r._publisherContext.name,t,a,r._publisherContext.failureCount.value)}).then(function(e){var t=e.status;if(r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyPublishStatus(t),"ok"!==t)return r._publisherContext.stream.value=null,void r._logger.info("[%s] Publish failed with status [%s]",r._publisherContext.streamId,t);var i=e.stream,o=e.rtcConfiguration,a=e.setRemoteDescriptionResponse,s=e.createOfferDescriptionResponse,u=e.createAnswerDescriptionResponse;return r._publisherContext.stream.value=i,r._logger.debug("[%s] Publish completed [%s] [%j] [%j] [%j] [%j]",r._publisherContext.streamId,t,o,a,s,u),r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyPublishStatus(t),r.applyRtcConfiguration(r._peerConnectionContext.peerConnection.value,o).then(function(e){var t,o=!1,c=!1,l=[];return r._peerConnectionContext.peerConnection.value=e,e.addStream(r._peerConnectionContext.mediaStream.value),e.onicecandidate=function(n){r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e&&(o||Ve.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?l.push(n.candidate):c=!0,t||(t=P.value.setTimeout(function(){var t;r._publisherContext.stream.value!==i||o||null===(t=r._publisherContext.endPoint.value)||void 0===t||t.addIceCandidates(i,l,c).then(function(t){var n=t.status,a=t.options;if("ok"===n)null!=a&&a.includes("cancel")&&(o=!0),r._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",r._publisherContext.streamId,n,a);else{if(r._publisherContext.stream.value!==i)return;if(r._peerConnectionContext.peerConnection.value!==e)return;r._publisherContext.state.value=r.mapAddIceCandidatesStatusToPublisherStatus(n),r._publisherContext.applyAddIceCandidatesStatus(n),r._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",r._publisherContext.streamId,n),r._handleStreamFailure().catch(function(e){r._logger.error("[%s] Failed handling stream failure after peer connection failed to add ICE candidates with reason [%s]",r._publisherContext.streamId,n,e)})}}).catch(function(t){r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e&&(r._logger.error("[%s] Failed to add ICE candidates",r._publisherContext.streamId,t),r._publisherContext.state.value=Sn.ConnectionError,r._publisherContext.applyUnhandledError(),r._handleStreamFailure().catch(function(e){r._logger.error("[%s] Failed handling stream failure after peer connection failed to add ICE candidates",r._publisherContext.streamId,e)}))})},100))))},e.oniceconnectionstatechange=function(){if(r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e){var t=function(){r._publisherContext.state.value=Sn.ConnectionError,r._publisherContext.publishing.value=!1,r._publisherContext.loading.value=!0,r._handleStreamFailure().catch(function(t){r._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",r._publisherContext.streamId,e.iceConnectionState,t)})};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return r._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",r._publisherContext.streamId,e.iceConnectionState),void r.reconnectPeerConnection(e,t);case"closed":return r._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",r._publisherContext.streamId,e.iceConnectionState),void t();default:Z(e.iceConnectionState)}}},new On(function(e){e()}).then(function(){if(a)return r._logger.info("[%s] Set local SDP offer [%s]",r._publisherContext.streamId,a.sessionDescription.sdp),e.setLocalDescription(a.sessionDescription).catch(function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,a.sessionDescription,e.message),e})}).then(function(){var t;if(u)return r._logger.info("[%s] Set remote SDP answer [%s]",r._publisherContext.streamId,null==u||null===(t=u.sessionDescription)||void 0===t?void 0:t.sdp),e.setRemoteDescription(u.sessionDescription).catch(function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,null==u?void 0:u.sessionDescription,e.message),e})}).then(function(){if(s)return r._logger.info("[%s] Set remote SDP offer [%s]",r._publisherContext.streamId,s.sessionDescription.sdp),e.setRemoteDescription(s.sessionDescription).catch(function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,null==u?void 0:u.sessionDescription,e.message),e}).then(function(){return e.createAnswer({offerToReceiveAudio:!1,offerToReceiveVideo:!1})}).then(function(e){r._logger.info("[%s] Set local SDP answer [%s]",r._publisherContext.streamId,e.sdp);var t=r._publisherContext.endPoint.value;if(!t)throw new Error("Failed to set remote description, EndPoint is not set");return t.setRemoteDescription(i,e)}).then(function(t){var n=t.status,i=t.sessionDescription;if(r._publisherContext.state.value=r.mapSetRemoteDescriptionStatusToPublisherStatus(n),r._publisherContext.applySetRemoteDescriptionStatus(n),"ok"===n)return r._logger.info("[%s] Set local SDP [%s]",r._publisherContext.streamId,null==i?void 0:i.sdp),e.setLocalDescription(i).catch(function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,i,e.message),e})})}).then(function(){var t;if(n.success(r._publisherContext.streamId),r._publisherContext.state.value!==Sn.Starting)return On.resolve();r._publisherContext.state.value=Sn.Publishing,r._publisherContext.publishing.value=!0;var i=new En(e,null!==(t=r._publisherContext.endPoint.value)&&void 0!==t&&t.roundTripTime?r._publisherContext.endPoint.value.roundTripTime/4:0,Ve.applicationActivityMonitor.isForeground);return r._publisherContext.disposables.add(i),i.rtcStatistic.subscribe(function(e){r._publisherContext.rtcStatistics.value=e}),On.resolve()})})})}},{key:"applyRtcConfiguration",value:(e=V()(Rn().m(function e(t,n){var r;return Rn().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return n=ut.truncateIceServers(n),e.a(2,Ve.peerConnectionFactory.value.createPeerConnection(n));case 1:return r=Ln(Ln({},t.getConfiguration()),n),t.setConfiguration(r),e.a(2,t)}},e)})),function(t,n){return e.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._publisherContext.state.value=Sn.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Ve.maximalNumberOfPeerConnectionReconnectAttempts||!Ve.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(O.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!i){var o=P.value.setTimeout(function(){n.reconnectPeerConnection(e,t)},1e3);return void this._publisherContext.disposables.add(new m(function(){return P.value.clearTimeout(o)}))}this._logger.info("Reconnecting peer connection by restarting ICE");var a=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then(function(r){return e.setLocalDescription(r).then(function(){return e.setLocalDescription(a).then(function(){if("disconnected"===e.iceConnectionState||"failed"===e.iceConnectionState){var r=P.value.setTimeout(function(){n.reconnectPeerConnection(e,t)},1e3);n._publisherContext.disposables.add(new m(function(){return P.value.clearTimeout(r)}))}else n._publisherContext.state.value=Sn.Publishing})})}).catch(function(e){n._logger.error("Failed to reconnect peer connection",e),n._peerConnectionContext.peerConnectionReconnectAttempts=0,t()})}else this._logger.info("Failed to reconnect peer connection after [%s] attempts, performing full recovery",this._peerConnectionContext.peerConnectionReconnectAttempts),this._peerConnectionContext.peerConnectionReconnectAttempts=0,t()}},{key:"mapSetRemoteDescriptionStatusToPublisherStatus",value:function(e){switch(e){case"ok":return Sn.Starting;case"unauthorized":return Sn.Unauthorized;case"not-found":return Sn.NotFound;case"capacity":case"rate-limited":case"timeout":return Sn.Recovering;case"failed":return Sn.Error;default:Z(e)}}},{key:"mapAddIceCandidatesStatusToPublisherStatus",value:function(e){switch(e){case"ok":return this._publisherContext.state.value;case"unauthorized":return Sn.Unauthorized;case"not-found":return Sn.NotFound;case"capacity":case"rate-limited":case"timeout":return Sn.Recovering;case"failed":return Sn.Error;default:Z(e)}}}]);var e}(),An=n(981).A;function jn(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return Mn(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Mn(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Mn(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,Mn(d,"constructor",c),Mn(c,"constructor",u),u.displayName="GeneratorFunction",Mn(c,i,"GeneratorFunction"),Mn(d),Mn(d,i,"Generator"),Mn(d,r,function(){return this}),Mn(d,"toString",function(){return"[object Generator]"}),(jn=function(){return{w:o,m:h}})()}function Mn(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Mn=function(e,t,n,r){function o(t,n){Mn(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},Mn(e,t,n,r)}var Vn=function(){return o()(function e(n,r,i){var o=this;t()(this,e),s()(this,"_logger",ee.getLogger("Publisher")),s()(this,"_tokenContext",void 0),s()(this,"_publisherContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_stateContext",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_publisherStartTime",void 0),s()(this,"_readOnlyToken",void 0),s()(this,"_readOnlyPeerConnection",void 0),s()(this,"_readOnlyState",void 0),s()(this,"_readOnlyTokenExpiring",void 0),s()(this,"_readOnlyAuthorized",void 0),s()(this,"_readOnlyOnline",void 0),s()(this,"_readOnlyLoading",void 0),s()(this,"_readOnlyPublishing",void 0),s()(this,"_readOnlyStandby",void 0),s()(this,"_readOnlyStopped",void 0),s()(this,"_readOnlyFailureCount",void 0),s()(this,"_readOnlyEndPoint",void 0),s()(this,"_readOnlyStream",void 0),s()(this,"_readOnlyRtcStatistics",void 0),s()(this,"_readOnlyMediaStream",void 0),s()(this,"_metricsService",void 0),s()(this,"_sessionTelemetry",void 0),this._tokenContext=new $e(r),this._publisherContext=new wn(i),this._peerConnectionContext=new nt,this._stateContext=new rt,this._exponentialBackoff=new xe,this._publisherStartTime=Date.now(),this._readOnlyToken=new C(this._tokenContext.token),this._readOnlyPeerConnection=new C(this._peerConnectionContext.peerConnection),this._readOnlyState=new C(this._publisherContext.state),this._readOnlyTokenExpiring=new C(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new C(this._publisherContext.authorized),this._readOnlyOnline=new C(this._publisherContext.online),this._readOnlyLoading=new C(this._publisherContext.loading),this._readOnlyPublishing=new C(this._publisherContext.publishing),this._readOnlyStandby=new C(this._publisherContext.standby),this._readOnlyStopped=new C(this._publisherContext.stopped),this._readOnlyFailureCount=new C(this._publisherContext.failureCount),this._readOnlyEndPoint=new C(this._publisherContext.endPoint),this._readOnlyStream=new C(this._publisherContext.stream),this._readOnlyRtcStatistics=new C(this._publisherContext.rtcStatistics),this._readOnlyMediaStream=new C(this._peerConnectionContext.mediaStream),this._peerConnectionContext.mediaStream.value=n;var a=re.parseToken(this._tokenContext.token.value),u=(a.uri||Ve.discoveryUri.value).toString();Ve.tenancy.value=a.tenancy||Ve.tenancy.value,Se.uri.value=u,this._metricsService=je.getMetricsService(u),this._sessionTelemetry=new Ke(Ve.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe(function(e){o._publisherContext.clearFailureCountTimeout&&P.value.clearTimeout(o._publisherContext.clearFailureCountTimeout),o._publisherContext.failureCount.value&&e===Sn.Publishing&&(o._publisherContext.clearFailureCountTimeout=P.value.setTimeout(function(){o._publisherContext.failureCount.value=0},3e3))}));var c=function(){o._publisherContext.stream.value&&o._publisherContext.endPoint.value&&o._publisherContext.endPoint.value.destroyStreamOnUnmount(o._publisherContext.stream.value,"client:termination-on-window-unload")};P.value.addWindowEventListener("beforeunload",c),this._publisherContext.publisherDisposables.add(new m(function(){P.value.removeWindowEventListener("beforeunload",c)})),this.start()},[{key:"token",get:function(){return this._tokenContext.token.value},set:function(e){this._publisherContext.disposables.dispose(),this._tokenContext.token.value=e,this._tokenContext.tokenExpiring.value=!1;var t=re.parseToken(this._tokenContext.token.value),n=(t.uri||Ve.discoveryUri.value).toString();Ve.tenancy.value=t.tenancy||Ve.tenancy.value,Se.uri.value=n,this._metricsService=je.getMetricsService(n),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"publishing",get:function(){return this._readOnlyPublishing}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._publisherContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"stop",value:(a=V()(jn().m(function e(t){var n=this;return jn().w(function(e){for(;;)if(0===e.n)return e.a(2,new An(function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._publisherContext.disposables.add(n._stateContext.isStarting.subscribe(function(r){r||(n.processStop(t),e())}))}))},e)})),function(e){return a.apply(this,arguments)})},{key:"processStop",value:function(e){this.cleanUpResources(e),this._peerConnectionContext.peerConnection.value&&(this._peerConnectionContext.peerConnection.value.close(),this._peerConnectionContext.peerConnection.value=null),this._publisherContext.state.value=Sn.Stopped}},{key:"dispose",value:(i=V()(jn().m(function e(){var t=this;return jn().w(function(e){for(;;)if(0===e.n)return e.a(2,this.stop("client:channel-dispose").then(function(){t._publisherContext.publisherDisposables.dispose(),t._stateContext.isDisposed=!0}))},e,this)})),function(){return i.apply(this,arguments)})},{key:"getUri",value:function(e){return re.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",Ve.discoveryUri.value),new P.value.URL(Ve.discoveryUri.value))}},{key:"start",value:(r=V()(jn().m(function e(){return jn().w(function(e){for(;;)switch(e.n){case 0:if(!this._stateContext.isDisposed){e.n=1;break}throw new Error("Channel was already disposed");case 1:if(!this._stateContext.isStarting.value){e.n=2;break}return this._logger.info("Publisher is already starting, skipping start"),e.a(2);case 2:return this._stateContext.isStarting.value=!0,e.a(2,this.processStart())}},e,this)})),function(){return r.apply(this,arguments)})},{key:"processStart",value:(n=V()(jn().m(function e(){var t,n,r,i,o,a=this;return jn().w(function(e){for(;;)switch(e.n){case 0:if(this._publisherContext.state.value=Sn.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),re.isEncodedEdgeTokenValid(t)){e.n=1;break}return this._logger.error("Failed to parse token [%s]",t),this._publisherContext.state.value=Sn.Unauthorized,this._publisherContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 1:return this._publisherContext.loading.value=!0,r=this.getUri(t),this._publisherContext.disposables.add(this._publisherContext.state.subscribe(function(e){e!==Sn.Error&&e!==Sn.Recovering||Ft.clearCachedClosestEndpoint(r)})),i=function(){return new An(function(e){return a._stateContext.isStarting.value=!1,e(a.handleStreamFailure())})},o=new Dn(this._publisherContext,this._peerConnectionContext,i),e.a(2,o.start(r,t,n).then(function(){a._publisherContext.loading.value=!1}).catch(function(e){n.fail(),a._publisherContext.failureCount.value++,a._publisherContext.online.value=!1,a.cleanUpResources("client:cleanup-after-failed-setup"),a._publisherContext.state.value=Sn.ClientStartError,a._logger.error("Failed to start publishing",e)}).finally(function(){if(a._stateContext.isStarting.value=!1,a._publisherContext.state.value!==Sn.Publishing&&Ve.automaticRetryOnFailure){var e=P.value.setTimeout(function(){a.handleStreamFailure().catch(function(e){a._logger.error("Failed handling stream failure",e)})},a.getRetryInterval());a._publisherContext.disposables.add(new m(function(){P.value.clearTimeout(e)}))}else a._publisherContext.startReconnectionAttemptsTimeInMilliseconds=0}))}},e,this)})),function(){return n.apply(this,arguments)})},{key:"setMediaStream",value:function(e){var t=this;this._peerConnectionContext.mediaStream.value=e,this._peerConnectionContext.peerConnection.value&&e.getTracks().forEach(function(e){var n;null===(n=t._peerConnectionContext.peerConnection.value)||void 0===n||n.getSenders().forEach(function(t){var n;e.kind===(null==t||null===(n=t.track)||void 0===n?void 0:n.kind)&&e.id!==t.track.id&&t.replaceTrack(e)})})}},{key:"getRetryInterval",value:function(){switch(this._publisherContext.state.value){case Sn.Offline:return 15e3;case Sn.Initializing:case Sn.NotFound:case Sn.Error:case Sn.Recovering:case Sn.Unauthorized:case Sn.GeoRestricted:case Sn.GeoBlocked:case Sn.Stopped:case Sn.Starting:case Sn.Publishing:case Sn.Reconnecting:case Sn.UnsupportedFeature:case Sn.ConfigurationError:case Sn.TransientConfigurationError:case Sn.ConnectionError:case Sn.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._publisherContext.failureCount.value);default:Z(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:(e=V()(jn().m(function e(){var t;return jn().w(function(e){for(;;)switch(e.n){case 0:t=this._publisherContext.state.value,e.n=t===Sn.Error||t===Sn.Reconnecting||t===Sn.Offline||t===Sn.Recovering||t===Sn.TransientConfigurationError||t===Sn.ConnectionError||t===Sn.ClientStartError?1:t===Sn.Unauthorized?3:t===Sn.GeoRestricted?4:t===Sn.GeoBlocked?5:t===Sn.Stopped?6:t===Sn.Publishing?7:t===Sn.Initializing?8:t===Sn.Starting?9:t===Sn.UnsupportedFeature?10:t===Sn.NotFound?11:t===Sn.ConfigurationError?12:13;break;case 1:if(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds||(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds=Date.now()),!(72e5<=Date.now()-this._publisherContext.startReconnectionAttemptsTimeInMilliseconds)){e.n=2;break}return this._logger.info("Publisher stopped with state [%s] [%s] after exceeding timeout",this._publisherContext.state.value,Sn[this._publisherContext.state.value]),e.a(2);case 2:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,Sn[this._publisherContext.state.value]),e.a(3,14);case 3:return this._logger.info("Publisher is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 4:return this._logger.info("Publisher is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 5:return this._logger.info("Publisher is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 6:return this._logger.info("Publisher is stopped, skipping retry of start."),e.a(2);case 7:return this._logger.info("Publisher is publishing, skipping retry of start"),e.a(2);case 8:return this._logger.info("Publisher is initializing, skipping retry of start"),e.a(2);case 9:return this._logger.info("Publisher is already starting, skipping retry of start"),e.a(2);case 10:return this._logger.info("Publisher is stopped due to unsupported feature, skipping retry of start."),e.a(2);case 11:return this._logger.info("Publisher is stopped due to channel not found, skipping retry of start."),e.a(2);case 12:return this._logger.info("Publisher is stopped due to configuration error, skipping retry of start."),e.a(2);case 13:Z(this._publisherContext.state.value);case 14:return e.a(2,this.start())}},e,this)})),function(){return e.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._publisherContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!Ve.forceGarbageCollectionOnRestart||O.isMobile&&Ve.skipGarbageCollectionOnMobileDevices||Be.forceGarbageCollection()),this._publisherContext.publishing.value=!1,this._publisherContext.stopped.value=!0,this._publisherContext.standby.value=!1,this._publisherContext.stream.value&&this._publisherContext.endPoint.value&&this._publisherContext.endPoint.value.destroyStream(this._publisherContext.stream.value,t).then(function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)}).catch(function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)}),this._publisherContext.stream.value=null,this._publisherContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}}]);var e,n,r,i,a}(),Gn=function(){return o()(function e(){throw t()(this,e),new Error("Publishers is a static class that may not be instantiated")},null,[{key:"createPublisher",value:function(e){if(!Ve.initialized.value)throw new Error("SDK is not loaded.");return new Vn(e.mediaStream,e.token,e.name)}}])}(),Bn={SDK:Ve,Channels:Cn,ChannelState:Ne,Publishers:Gn,PublisherState:Sn}})(),r})());
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.phenix=t():e.phenix=t()}(self,()=>(()=>{var e={981:(e,t,n)=>{"use strict";n.d(t,{A:()=>f});var r=n(738),i=n.n(r),o=n(383),a=n.n(o),s=n(579),u=n.n(s),c=n(693),l=n.n(c),d=u()(function e(t,n,r){a()(this,e),l()(this,"onFulfilled",void 0),l()(this,"onRejected",void 0),l()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.promise=r}),h=function(){function e(t){if(a()(this,e),l()(this,"_state",void 0),l()(this,"_handled",void 0),l()(this,"_value",void 0),l()(this,"_deferreds",void 0),!(this instanceof e))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=null,this._deferreds=[],this.doResolve(t)}return u()(e,[{key:"doResolve",value:function(e){var t=this,n=!1;try{e(function(e){n||(n=!0,t.promiseResolve(e))},function(e){n||(n=!0,t.promiseReject(e))})}catch(e){if(n)return;n=!0,this.promiseReject(e)}}},{key:"promiseResolve",value:function(t){var n=this;try{if(t===n)throw new TypeError("A Promise cannot be resolved with it self.");if(t&&("object"===i()(t)||"function"==typeof t)){var r=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof r)return void n.doResolve(function(){r.apply(t,arguments)})}n._state=1,n._value=t,n.finale()}catch(e){n.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate(function(){t._handled||e._unhandledRejection(t._value)});for(var n=0,r=this._deferreds.length;n<r;n++)this.handle(this._deferreds[n]);this._deferreds=[]}},{key:"handle",value:function(t){for(var n=this;3===n._state;)n=n._value;0!==n._state?(n._handled=!0,e._immediate(function(){var e=1===n._state?t.onFulfilled:t.onRejected;if(null!==e){var r;try{r=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(r)}else 1===n._state?t.promise.promiseResolve(n._value):t.promise.promiseReject(n._value)})):n._deferreds.push(t)}}],[{key:"all",value:function(t){return new e(function(e,n){if(!Array.isArray(t))return n(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);for(var o=r.length,a=function(t,s){try{if(s&&("object"===i()(s)||"function"==typeof s)){var u=s.then;if("function"==typeof u)return void u.call(s,function(e){return a(t,e)},n)}r[t]=s,0===--o&&e(r)}catch(e){n(e)}},s=0;s<r.length;s++)a(s,r[s])})}},{key:"resolve",value:function(t){return t&&"object"===i()(t)&&t.constructor===e?t:new e(function(e){return e(t)})}},{key:"reject",value:function(t){return new e(function(e,n){return n(t)})}},{key:"race",value:function(t){return new e(function(n,r){if(!Array.isArray(t))return r(new TypeError("Promise.race accepts an array"));for(var i=0,o=t.length;i<o;i++)e.resolve(t[i]).then(n,r)})}},{key:"_immediate",value:function(e){window.setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}])}();h.prototype.catch=function(e){return this.then(null,e)},h.prototype.then=function(e,t){var n=new h(function(){return null});return this.handle(new d(e,t,n)),n},h.prototype.finally=function(e){return this.then(function(t){return h.resolve(e()).then(function(){return t},function(){return null})},function(t){return h.resolve(e()).then(function(){return h.reject(t)},function(){return null})})};var f=h},512:e=>{"use strict";e.exports=function(e,t,n,r){var i=self||window;try{try{var o;try{o=new i.Blob([e])}catch(t){(o=new(i.BlobBuilder||i.WebKitBlobBuilder||i.MozBlobBuilder||i.MSBlobBuilder)).append(e),o=o.getBlob()}var a=i.URL||i.webkitURL,s=a.createObjectURL(o),u=new i[t](s,n);return a.revokeObjectURL(s),u}catch(r){return new i[t]("data:application/javascript,".concat(encodeURIComponent(e)),n)}}catch(e){if(!r)throw Error("Inline worker is not supported");return new i[t](r,n)}}},79:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},987:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},901:(e,t,n)=>{var r=n(79);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},475:e=>{e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},293:(e,t,n)=>{var r=n(981).A;function i(e,t,n,i,o,a,s){try{var u=e[a](s),c=u.value}catch(e){return void n(e)}u.done?t(c):r.resolve(c).then(i,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new r(function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,u,"next",e)}function u(e){i(a,r,o,s,u,"throw",e)}s(void 0)})}},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,n)=>{var r=n(736);function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}e.exports=function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,t,n)=>{var r=n(736);e.exports=function(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},72:e=>{function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},511:(e,t,n)=>{var r=n(636);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},291:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},156:e=>{e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}},e.exports.__esModule=!0,e.exports.default=e.exports},752:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},869:e=>{e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},847:(e,t,n)=>{var r=n(893);e.exports=function(e,t){if(null==e)return{};var n,i,o=r(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)n=a[i],t.indexOf(n)>=0||{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o},e.exports.__esModule=!0,e.exports.default=e.exports},893:e=>{e.exports=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n},e.exports.__esModule=!0,e.exports.default=e.exports},452:(e,t,n)=>{var r=n(738).default,i=n(475);e.exports=function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return i(e)},e.exports.__esModule=!0,e.exports.default=e.exports},636:e=>{function t(n,r){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},715:(e,t,n)=>{var r=n(987),i=n(156),o=n(122),a=n(752);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},132:(e,t,n)=>{var r=n(901),i=n(291),o=n(122),a=n(869);e.exports=function(e){return r(e)||i(e)||o(e)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,t,n)=>{var r=n(738).default;e.exports=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,t,n)=>{var r=n(738).default,i=n(45);e.exports=function(e){var t=i(e,"string");return"symbol"==r(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},122:(e,t,n)=>{var r=n(79);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{ChannelState:()=>Ne,Channels:()=>Cn,PublisherState:()=>Sn,Publishers:()=>Gn,SDK:()=>Ve,default:()=>Bn});var e=n(383),t=n.n(e),i=n(579),o=n.n(i),a=n(693),s=n.n(a),u=n(132),c=n.n(u),l=n(452),d=n.n(l),h=n(72),f=n.n(h),p=n(511),v=n.n(p),m=function(){return o()(function e(n){t()(this,e),s()(this,"_disposed",void 0),s()(this,"_disposable",void 0),this._disposed=!1,this._disposable=n},[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}])}();function g(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(g=function(){return!!e})()}var y,_=function(e){function n(e,r){return t()(this,n),i=this,o=n,a=[function(){var t=e.indexOf(r);t>=0&&e.splice(t,1)}],o=f()(o),d()(i,g()?Reflect.construct(o,a||[],f()(i).constructor):o.apply(i,a));var i,o,a}return v()(n,e),o()(n)}(m),b=function(){return o()(function e(n){t()(this,e),s()(this,"_listeners",void 0),s()(this,"_value",void 0),this._listeners=[],this._value=n},[{key:"value",get:function(){return this._value},set:function(e){var t=this._value!==e;if(t&&e){var n=e;"function"==typeof n.equals&&(t=!n.equals(this._value))}if(t){this._value=e;for(var r=0,i=c()(this._listeners);r<i.length;r++)(0,i[r])(e)}}},{key:"subscribe",value:function(e){return this._listeners.push(e),e(this._value),new _(this._listeners,e)}}])}(),C=function(){return o()(function e(n){t()(this,e),s()(this,"_subject",void 0),this._subject=n},[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}])}(),k={document,location,navigator,window},S=function(){function e(n){t()(this,e),s()(this,"_document",void 0),s()(this,"_location",void 0),s()(this,"_navigator",void 0),s()(this,"_window",void 0),this._document=n.document,this._location=n.location,this._navigator=n.navigator,this._window=n.window}return o()(e,[{key:"FormData",get:function(){return this._window.FormData}},{key:"HTMLVideoElement",get:function(){return this._window.HTMLVideoElement}},{key:"MediaStream",get:function(){return this._window.MediaStream}},{key:"MediaStreamTrack",get:function(){return this._window.MediaStreamTrack}},{key:"MediaSource",get:function(){return this._window.MediaSource}},{key:"RTCPeerConnection",get:function(){return this._window.RTCPeerConnection}},{key:"RTCSessionDescription",get:function(){return this._window.RTCSessionDescription}},{key:"RTCIceCandidate",get:function(){return this._window.RTCIceCandidate}},{key:"URL",get:function(){return this._window.URL}},{key:"URLSearchParams",get:function(){return this._window.URLSearchParams}},{key:"addDocumentEventListener",get:function(){return this._document.addEventListener.bind(this._document)}},{key:"addWindowEventListener",get:function(){return this._window.addEventListener.bind(this._window)}},{key:"clearInterval",get:function(){return this._window.clearInterval.bind(this._window)}},{key:"clearTimeout",get:function(){return this._window.clearTimeout.bind(this._window)}},{key:"documentCreateElement",get:function(){return this._document.createElement.bind(this._document)}},{key:"documentHasFocus",get:function(){return this._document.hasFocus.bind(this._document)}},{key:"documentIsHidden",get:function(){return!!this._document.hidden}},{key:"documentQuerySelector",get:function(){return this._document.querySelector.bind(this._document)}},{key:"fetch",get:function(){return this._window.fetch.bind(this._window)}},{key:"locationHostname",get:function(){return this._location.hostname}},{key:"locationSearch",get:function(){return this._location.search}},{key:"navigatorConnection",get:function(){return this._navigator.connection}},{key:"navigatorIsOnLine",get:function(){return this._navigator.onLine}},{key:"pageLoadTime",get:function(){return this._window.__phenixPageLoadTime||this._window.__pageLoadTime}},{key:"queueMicrotask",get:function(){return this._window.queueMicrotask.bind(this._window)}},{key:"removeDocumentEventListener",get:function(){return this._document.removeEventListener.bind(this._document)}},{key:"requestAnimationFrame",get:function(){return this._window.requestAnimationFrame.bind(this._window)}},{key:"removeWindowEventListener",get:function(){return this._window.removeEventListener.bind(this._window)}},{key:"setInterval",get:function(){return this._window.setInterval.bind(this._window)}},{key:"setTimeout",get:function(){return this._window.setTimeout.bind(this._window)}}],[{key:"setInstance",value:function(e){throw new Error("This build does not support setting the GlobalScope")}},{key:"getInstance",value:function(){return e._readOnlyInstance}},{key:"subscribe",value:function(t){return e._readOnlyInstance.subscribe(t)}}])}();y=S,s()(S,"_instance",new b(new y(k))),s()(S,"_readOnlyInstance",new C(y._instance));var w,T,x,P=S.getInstance(),E=function(){function e(){t()(this,e)}return o()(e,null,[{key:"browserNameAndVersion",get:function(){return e._browserNameAndVersion}},{key:"browserName",get:function(){return this._browserName}},{key:"browserMajorVersion",get:function(){return this._browserMajorVersion}},{key:"isAndroid",get:function(){return e._isAndroid}},{key:"isChrome69",get:function(){return e._isChrome69}},{key:"isChrome70",get:function(){return e._isChrome70}},{key:"isChrome71",get:function(){return e._isChrome71}},{key:"isChrome72",get:function(){return e._isChrome72}},{key:"isChrome74",get:function(){return e._isChrome74}},{key:"isChrome75",get:function(){return e._isChrome75}},{key:"isChrome76",get:function(){return e._isChrome76}},{key:"isChrome77",get:function(){return e._isChrome77}},{key:"isMobile",value:function(){return e._isMobile}},{key:"parseBrowserNameAndVersion",value:function(){if(!navigator||!navigator.userAgent)return"";var t=navigator.userAgent.match(e._browserNameAndVersionRegex);return t&&t[0]?t[0]:e.parseBrowserNameAndVersionForIE()}},{key:"parseBrowserName",value:function(){if(!e._browserNameAndVersion)return"";var t=e._browserNameAndVersion.split("/");return t&&t[0]?t[0]:""}},{key:"parseBrowserMajorVersion",value:function(){if(!e._browserNameAndVersion)return 0;var t=e._browserNameAndVersion.split("/");if(!t||!t[1])return 0;var n=t[1];return n&&Number(n.split(".")[0])||0}},{key:"parseBrowserNameAndVersionForIE",value:function(){if(!navigator||!navigator.userAgent)return"";var e=navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return"IE/".concat(parseInt(e.substring(t+5,e.indexOf(".",t)),10));if(e.indexOf("Trident/")>0){var n=e.indexOf("rv:");return"IE/".concat(parseInt(e.substring(n+3,e.indexOf(".",n)),10))}return""}}])}();w=E,s()(E,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),s()(E,"_browserNameAndVersion",w.parseBrowserNameAndVersion()),s()(E,"_browserName",w.parseBrowserName()),s()(E,"_browserMajorVersion",w.parseBrowserMajorVersion()),s()(E,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(T=navigator)||void 0===T?void 0:T.userAgent)),s()(E,"_isAndroid",/Android/i.test(null===(x=navigator)||void 0===x?void 0:x.userAgent)),s()(E,"_isChrome69",w._browserNameAndVersion.includes("Chrome/69.")),s()(E,"_isChrome70",w._browserNameAndVersion.includes("Chrome/70.")),s()(E,"_isChrome71",w._browserNameAndVersion.includes("Chrome/71.")),s()(E,"_isChrome72",w._browserNameAndVersion.includes("Chrome/72.")),s()(E,"_isChrome74",w._browserNameAndVersion.includes("Chrome/74.")),s()(E,"_isChrome75",w._browserNameAndVersion.includes("Chrome/75.")),s()(E,"_isChrome76",w._browserNameAndVersion.includes("Chrome/76.")),s()(E,"_isChrome77",w._browserNameAndVersion.includes("Chrome/77."));var O=function(){function e(){t()(this,e)}return o()(e,null,[{key:"clientOfferDisabled",get:function(){return E.isChrome74||E.isChrome75||E.isChrome76||E.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return E.isChrome69||E.isChrome70||E.isChrome71||E.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===E.browserName&&E.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===E.browserName&&E.browserMajorVersion<=69||"Firefox"===E.browserName&&E.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===E.browserName&&E.browserMajorVersion<=63||"Firefox"===E.browserName&&E.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===E.browserName&&E.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===E.browserName&&E.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===E.browserName||"SamsungBrowser"===E.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==E.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===E.browserName&&"function"==typeof(null===(e=P.value)||void 0===e?void 0:e.documentCreateElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===E.browserName&&E.browserMajorVersion>=71||"Firefox"===E.browserName&&E.browserMajorVersion>=69||"Safari"===E.browserName}},{key:"isMobile",get:function(){return E.isMobile()}},{key:"isInsertableStreamsSupported",get:function(){return!("undefined"==typeof MediaStreamTrackProcessor||"undefined"==typeof MediaStreamTrackGenerator)}},{key:"isEncodedInsertableStreamsSupported",get:function(){return"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams}},{key:"isRTCRtpScriptTransformSupported",get:function(){return"undefined"!=typeof RTCRtpScriptTransform}},{key:"isRequestVideoFrameCallbackSupported",get:function(){var e;return void 0!==(null===(e=P.value)||void 0===e?void 0:e.HTMLVideoElement.prototype.requestVideoFrameCallback)}},{key:"isRequestAnimationFrameSupported",get:function(){var e;return"function"==typeof(null===(e=P.value)||void 0===e?void 0:e.requestAnimationFrame)}},{key:"isChannelFrameTimingInformationSupported",get:function(){return e.isRequestVideoFrameCallbackSupported&&(e.isEncodedInsertableStreamsSupported||e.isRTCRtpScriptTransformSupported)}},{key:"errorStackAlsoHasErrorMessage",get:function(){return"Firefox"!==E.browserName&&"Safari"!==E.browserName}}])}(),R=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),F=function(){return o()(function e(n,r,i){t()(this,e),s()(this,"_category",void 0),s()(this,"_appenders",void 0),s()(this,"_threshold",void 0),this._category=n,this._appenders=r,this._threshold=i},[{key:"category",get:function(){return this._category}},{key:"appenders",get:function(){return this._appenders}},{key:"threshold",get:function(){return this._threshold}},{key:"trace",value:function(){if(this._threshold.value&&!(this._threshold.value>R.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(R.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>R.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(R.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>R.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(R.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>R.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(R.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>R.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(R.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>R.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(R.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,r=new Date,i=this.replacePlaceholders(t);this._appenders.value.forEach(function(t){t.log(e,i,n.category,r)})}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],r=0;n.indexOf&&e.length>1&&r>=0;)if((r=n.indexOf("%",r))>0)switch(n.substring(r+1,r+2)){case"%":n=n.substring(0,r)+n.substring(r+1),r++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,r),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,r),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce(function(e,n,r,i){return r+1===i.length&&n instanceof Error?O.errorStackAlsoHasErrorMessage?e+"\n"+t.toString(n.stack):e+"\n"+t.toString(n.message)+"\n"+t.toString(n.stack):e+"[".concat(t.toString(n),"]")})),e.toString()}},{key:"stringify",value:function(e){var t=[];try{return JSON.stringify(e instanceof Error?this.toString(e):e,function(e,n){if(n&&n instanceof Object){if(t.includes(n))return"<recursive>";t.push(n)}return n},2)}catch(e){return"[object invalid JSON.stringify]"}}},{key:"replaceArgument",value:function(e,t,n){return t.substring(0,n)+this.toString(e)+t.substring(n+2)}},{key:"toString",value:function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return e.toString();var t="";if(e)if("function"==typeof e)t=e.toString();else if(e instanceof Object)try{t=e.toString()}catch(e){t="[object invalid toString()]"}return t}}])}(),I=function(){return o()(function e(){t()(this,e),s()(this,"_appenders",[])},[{key:"value",get:function(){return this._appenders}},{key:"add",value:function(e){this._appenders.push(e)}},{key:"remove",value:function(e){this._appenders=this._appenders.reduce(function(t,n){return n!==e&&t.push(n),t},[])}}])}(),L=function(){return o()(function e(){t()(this,e)},null,[{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"sendLogs",get:function(){return this._sendLogs}},{key:"sendMetrics",get:function(){return this._sendMetrics}},{key:"logToConsole",get:function(){return this._logToConsole}},{key:"applyFeatures",value:function(){try{var e={sendLocalCandidates:!1,sendLogs:"Off",sendMetrics:"Essential",logToConsole:"Off"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}])}();s()(L,"_sendLocalCandidates",void 0),s()(L,"_sendLogs",void 0),s()(L,"_sendMetrics",void 0),s()(L,"_logToConsole",void 0),L.applyFeatures();var D=function(){return o()(function e(){t()(this,e)},null,[{key:"defaultLoggingLevel",get:function(){return R[L.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return R[L.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return R.Info}}])}(),A=function(){return o()(function e(){t()(this,e),s()(this,"_threshold",D.defaultLoggingLevel)},[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}])}(),j=function(){return o()(function e(n){t()(this,e),s()(this,"_threshold",void 0),this._threshold=n},[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(R[e],"] ").concat(t);e<R.Warn?console.log(i):console.error(i)}}}])}(),M=n(293),V=n.n(M),G=function(){function e(){throw t()(this,e),new Error("Numbers is a static class that may not be instantiated")}return o()(e,null,[{key:"countNumberLength",value:function(t){var n=0,r=t;return r<0&&(r*=-1,n++),e.countDigitsBeforeDecimal(r)+n+(r!==Math.floor(r)?e.countDigitsAfterDecimal(r)+1:0)}},{key:"fixRounding",value:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}},{key:"countDigitsBeforeDecimal",value:function(e){for(var t=1,n=e;n>=10;)n/=10,t++;return t}},{key:"countDigitsAfterDecimal",value:function(t){for(var n=t,r=Math.floor(t),i=0;r!==n&&i<15;)i++,r=e.fixRounding(n,i);return i}}])}(),B=function(){return o()(function e(){t()(this,e)},null,[{key:"sdkVersion",get:function(){try{return"2026-04-02T15:30:55.442Z (2025.2.3)"}catch(e){return this._defaultVersion}}}])}();s()(B,"_defaultVersion",(new Date).toISOString());var U=n(981).A;function N(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return z(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(z(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,z(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,z(d,"constructor",c),z(c,"constructor",u),u.displayName="GeneratorFunction",z(c,i,"GeneratorFunction"),z(d),z(d,i,"Generator"),z(d,r,function(){return this}),z(d,"toString",function(){return"[object Generator]"}),(N=function(){return{w:o,m:h}})()}function z(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}z=function(e,t,n,r){function o(t,n){z(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},z(e,t,n,r)}var H=function(){return o()(function e(n){var r=this;t()(this,e),s()(this,"_telemetryConfiguration",void 0),s()(this,"_logs",[]),s()(this,"_isSending",!1),s()(this,"_domain",""),this._telemetryConfiguration=n,this.getLocationHostnameFromGlobalScope().then(function(e){r._domain=e})},[{key:"push",value:function(e,t,n,r){var i=(r.valueOf()-this._telemetryConfiguration.pageLoadTime)/1e3,o={timestamp:r.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:R[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:B.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<R.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new U(function(e){var t=P.subscribe(function(n){n&&(e(n.locationHostname),n.setTimeout(function(){return t.dispose()},0))})})}},{key:"sendLogs",value:(n=V()(N().m(function e(t){var n;return N().w(function(e){for(;;)switch(e.n){case 0:return(n=new P.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.n=1,P.value.fetch(this._telemetryConfiguration.url,{method:"POST",body:n});case 1:return e.a(2,e.v)}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"sendLogsIfAble",value:(e=V()(N().m(function e(){var t,n,r,i,o,a=this;return N().w(function(e){for(;;)switch(e.n){case 0:if(!(this._logs.length<=0||this._isSending)&&P.value){e.n=1;break}return e.a(2);case 1:for(t=0,n=0,this._isSending=!0,r=function(e){return"number"==typeof e?G.countNumberLength(e):e.length},i=function(e){return Object.values(e).reduce(function(e,t){return e+(t?r(t):0)},0)};this._logs.length>t&&i(this._logs[t])+n<8192;)n+=i(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,i(this._logs[t])+(8192-i(this._logs[t]))),t=1),o=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.a(2,this.sendLogs(o).then(function(e){return a._isSending=!1,a.sendLogsIfAble(),e}).catch(function(){a._isSending=!1,a.sendLogsIfAble()}))}},e,this)})),function(){return e.apply(this,arguments)})}]);var e,n}(),q=function(){return o()(function e(n){t()(this,e),s()(this,"_telemetryService",void 0),s()(this,"_tenancy",void 0),s()(this,"_sessionId",void 0),s()(this,"_threshold",void 0),this._tenancy=n.tenancy,this._sessionId=n.sessionId,this._threshold=n.threshold,this._telemetryService=new H(n)},[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}])}(),W=function(){return o()(function e(){t()(this,e),s()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),s()(this,"_tenancy","-"),s()(this,"_sessionId","-"),s()(this,"_environment","-"),s()(this,"_pageLoadTime",0),s()(this,"_threshold",D.defaultTelemetryLoggingLevel)},[{key:"url",get:function(){return this._url},set:function(e){var t=new P.value.URL(e);t.pathname=t.pathname+"/logs",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"pageLoadTime",get:function(){return this._pageLoadTime},set:function(e){this._pageLoadTime=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}])}(),J=function(){return o()(function e(){t()(this,e)},null,[{key:"defaultTelemetryLevel",get:function(){return K[L.sendMetrics]}}])}(),K=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),Q=function(){return o()(function e(){t()(this,e),s()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),s()(this,"_tenancy","-"),s()(this,"_sessionId","-"),s()(this,"_environment","-"),s()(this,"_threshold",J.defaultTelemetryLevel)},[{key:"url",get:function(){return this._url},set:function(e){var t=new P.value.URL(e);t.pathname=t.pathname+"/metrics",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}])}(),Z=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},$=function(){return o()(function e(){t()(this,e)},null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case K.Off:return"Off";case K.Essential:return"Essential";case K.All:return"All";default:Z(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return K.Off;case"Essential":return K.Essential;case"All":return K.All;default:Z(e)}}}])}(),X=function(){return o()(function e(){t()(this,e)},null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case R.Off:return"Off";case R.Trace:return"Trace";case R.Debug:return"Debug";case R.Info:return"Trace";case R.Warn:return"Warn";case R.Error:return"Error";case R.Fatal:return"Fatal";case R.All:return"All";default:Z(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return R.Off;case"Trace":return R.Trace;case"Debug":return R.Debug;case"Info":return R.Info;case"Warn":return R.Warn;case"Error":return R.Error;case"Fatal":return R.Fatal;case"All":return R.All;default:Z(e)}}}])}(),Y=function(){function e(){t()(this,e)}return o()(e,null,[{key:"getStringValue",value:function(t){return e.defaultStringValue[t]}},{key:"getBooleanValue",value:function(t){return e.defaultBooleanValue[t]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":$.convertTelemetryLevelToTelemetryLevelType(J.defaultTelemetryLevel),"phenix-logging-level":X.convertLoggingLevelToLoggingLevelType(D.defaultLoggingLevel),"phenix-console-logging-level":X.convertLoggingLevelToLoggingLevelType(D.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":X.convertLoggingLevelToLoggingLevelType(D.defaultTelemetryLoggingLevel),"phenix-channel-token":"","phenix-uri":"","phenix-base-uri":""}}},{key:"defaultBooleanValue",get:function(){return{"phenix-automatically-retry-on-failure":!0,"phenix-automatically-reconnect-peer-connection":!0,"phenix-force-garbage-collection-on-restart":!0,"phenix-skip-garbage-collection-on-mobile-devices":!0}}}])}(),ee=function(){function e(){throw t()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return o()(e,null,[{key:"telemetryConfiguration",get:function(){return e._telemetryConfiguration}},{key:"getLogger",value:function(t){return"string"!=typeof t&&(t="SDK"),e._loggers[t]||(e._loggers[t]=new F(t,this._appenders,this._threshold))}},{key:"applyLoggerConfigFromParameterConfiguration",value:function(){e.applyLoggingLevel(),e.applyAppenderLoggingLevel("console",e.applyConsoleLogger.bind(this)),e.applyAppenderLoggingLevel("telemetry",e.applyTelemetryLogger.bind(this))}},{key:"applyLoggingLevel",value:function(){var e=Y.getStringValue("phenix-logging-level");R[e]&&this._threshold.setThreshold(R[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=Y.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(R[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new j(e||D.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||D.defaultTelemetryLoggingLevel,this._appenders.add(new q(this._telemetryConfiguration))}}])}();s()(ee,"_loggers",{}),s()(ee,"_appenders",new I),s()(ee,"_threshold",new A),s()(ee,"_telemetryConfiguration",new W),ee.applyLoggerConfigFromParameterConfiguration();var te=function(){return o()(function e(){throw t()(this,e),new Error("Strings is a static class that may not be instantiated")},null,[{key:"random",value:function(e){var t=Math.ceil(e/13);return new Array(t).fill(function(){return Math.random().toString(16).substring(2,15)}).reduce(function(e,t){return e+t()},"").substring(0,e)}}])}(),ne=function(){return o()(function e(n){var r,i;t()(this,e),s()(this,"_applicationId",void 0),s()(this,"_token",void 0),this._applicationId=(null==n?void 0:n.applicationId)||"",this._token={uri:null!=n&&null!==(r=n.token)&&void 0!==r&&r.uri?new P.value.URL(n.token.uri):null,capabilities:(null==n||null===(i=n.token)||void 0===i?void 0:i.capabilities)||[]}},[{key:"uri",get:function(){return this._token.uri}},{key:"capabilities",get:function(){return this._token.capabilities}},{key:"tenancy",get:function(){return this._applicationId}}])}(),re=function(){function e(){t()(this,e)}return o()(e,null,[{key:"parseToken",value:function(t){if(!this.isEncodedEdgeTokenValid(t))return e._logger.error("Token is not valid [%s]",t),new ne(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new ne(r)}catch(t){return e._logger.error("Cannot parse token value",t),new ne(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();s()(re,"_logger",ee.getLogger("EdgeAuthParser"));var ie=function(){return o()(function e(){t()(this,e),s()(this,"_list",[])},[{key:"add",value:function(e){this._list.push(e)}},{key:"dispose",value:function(){this._list.forEach(function(e){return e.dispose()}),this._list.length=0}},{key:"toString",value:function(){return"DisposableList[disposables=".concat(this._list.length,"]")}}])}(),oe="visibilitychange",ae=function(){return o()(function e(){t()(this,e),s()(this,"_disposables",new ie),s()(this,"_readOnlyIsForeground",void 0),s()(this,"_isForeground",void 0),s()(this,"_timeOfLastTabFocusChange",Date.now()),s()(this,"_lastBackgroundDuration",null),this._isForeground=new b(!0),this._readOnlyIsForeground=new C(this._isForeground),this.initialize()},[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"getLastBackgroundDuration",value:function(){return this._lastBackgroundDuration}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"initialize",value:function(){var e=this,t=null,n=function(){var n=!P.value.documentIsHidden;n?t&&(e._lastBackgroundDuration=Date.now()-t):(t=Date.now(),e._lastBackgroundDuration=null),e._isForeground.value=n},r=!1;P.value.addDocumentEventListener(oe,n,r),this._disposables.add(new m(function(){return P.value.removeDocumentEventListener(oe,n,r)}))}}])}(),se=n(981).A;function ue(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return ce(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(ce(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,ce(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,ce(d,"constructor",c),ce(c,"constructor",u),u.displayName="GeneratorFunction",ce(c,i,"GeneratorFunction"),ce(d),ce(d,i,"Generator"),ce(d,r,function(){return this}),ce(d,"toString",function(){return"[object Generator]"}),(ue=function(){return{w:o,m:h}})()}function ce(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}ce=function(e,t,n,r){function o(t,n){ce(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},ce(e,t,n,r)}var le=function(){return o()(function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("VanillaPeerConnection")),s()(this,"_peerConnection",void 0),O.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(n):this._peerConnection=new P.value.RTCPeerConnection(n)},[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.currentLocalDescription)||null}},{key:"currentRemoteDescription",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.currentRemoteDescription)||null}},{key:"connectionState",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.connectionState)||null}},{key:"iceConnectionState",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.iceConnectionState)||null}},{key:"supportsGetConfiguration",get:function(){var e;return"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getConfiguration)}},{key:"supportsSetConfiguration",get:function(){var e;return"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.setConfiguration)}},{key:"supportsGetTransceivers",get:function(){var e;return!O.getTransceiversDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getTransceivers)}},{key:"supportsAddTransceiver",get:function(){var e;return!O.addTranceiverDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.addTransceiver)}},{key:"createOffer",value:(i=V()(ue().m(function e(t){var n=this;return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1:if(!O.promiseBasedPCMethodsDisabled){e.n=2;break}return e.a(2,new se(function(e,r){return n._peerConnection.createOffer(e,r,t)}));case 2:return e.a(2,this._peerConnection.createOffer(t))}},e,this)})),function(e){return i.apply(this,arguments)})},{key:"createAnswer",value:(r=V()(ue().m(function e(t){var n=this;return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1:if(!O.promiseBasedPCMethodsDisabled){e.n=2;break}return e.a(2,new se(function(e,r){return n._peerConnection.createAnswer(e,r,t)}));case 2:return e.a(2,this._peerConnection.createAnswer(t))}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"setLocalDescription",value:(n=V()(ue().m(function e(t){return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1:return e.a(2,this._peerConnection.setLocalDescription(O.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t))}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(e=V()(ue().m(function e(t){var n;return ue().w(function(e){for(;;)switch(e.n){case 0:if(this._peerConnection){e.n=1;break}throw new Error("No PeerConnection initialized");case 1:return(null===(n=t.sdp)||void 0===n?void 0:n.match(/a=crypto:/i))&&this._logger.warn("SDP a=crypto is not supported"),e.a(2,this._peerConnection.setRemoteDescription(O.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t))}},e,this)})),function(t){return e.apply(this,arguments)})},{key:"getSenders",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getSenders()}},{key:"getReceivers",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getReceivers()}},{key:"getStats",value:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;if(!this._peerConnection)throw new Error("No PeerConnection initialized");return new se(function(t){e._peerConnection.getStats(t)})}},{key:"addEventListener",value:function(e,t,n){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.removeEventListener(e,t,n)}},{key:"getTransceivers",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getTransceivers()}},{key:"addTransceiver",value:function(e,t){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.addTransceiver(e,t)}},{key:"addStream",value:function(e){var t=this;e.getTracks().forEach(function(e){if(!t._peerConnection)throw new Error("No PeerConnection initialized");t._peerConnection.addTrack(e)})}},{key:"getConfiguration",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.setConfiguration(e)}},{key:"ontrack",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.ontrack},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.ontrack=e}},{key:"onicecandidate",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.onicecandidate},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.onicecandidate=e}},{key:"onconnectionstatechange",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.onconnectionstatechange},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.onconnectionstatechange=e}},{key:"oniceconnectionstatechange",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.oniceconnectionstatechange},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){var e;null===(e=this._peerConnection)||void 0===e||e.close()}},{key:"dispose",value:function(){this._peerConnection=null}}]);var e,n,r,i}(),de=n(981).A;function he(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return fe(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(fe(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,fe(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,fe(d,"constructor",c),fe(c,"constructor",u),u.displayName="GeneratorFunction",fe(c,i,"GeneratorFunction"),fe(d),fe(d,i,"Generator"),fe(d,r,function(){return this}),fe(d,"toString",function(){return"[object Generator]"}),(he=function(){return{w:o,m:h}})()}function fe(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}fe=function(e,t,n,r){function o(t,n){fe(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},fe(e,t,n,r)}var pe=function(){return o()(function e(){t()(this,e)},[{key:"createPeerConnection",value:(e=V()(he().m(function e(t){return he().w(function(e){for(;;)if(0===e.n)return e.a(2,new de(function(e){var n=P.subscribe(function(r){r&&(e(new le(t)),n.dispose())})}))},e)})),function(t){return e.apply(this,arguments)})}]);var e}();function ve(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return me(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(me(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,me(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,me(d,"constructor",c),me(c,"constructor",u),u.displayName="GeneratorFunction",me(c,i,"GeneratorFunction"),me(d),me(d,i,"Generator"),me(d,r,function(){return this}),me(d,"toString",function(){return"[object Generator]"}),(ve=function(){return{w:o,m:h}})()}function me(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}me=function(e,t,n,r){function o(t,n){me(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},me(e,t,n,r)}var ge=function(e){return e[e.Disabled=0]="Disabled",e[e.Enabled=1]="Enabled",e}({}),ye=["audio","video"],_e=function(){function e(){throw t()(this,e),new Error("PeerConnectionService is a static class that may not be instantiated")}return o()(e,null,[{key:"peerConnectionFactory",get:function(){return e._peerConnectionFactory}},{key:"initiateInitialPrecaching",value:function(){O.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch(function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)})}},{key:"precacheCreatePeerConnectionOffer",value:(r=V()(ve().m(function t(){return ve().w(function(t){for(;;)if(0===t.n)return t.a(2,e._cached={direction:"recvonly",peerConnection:e.createPeerConnectionOffer().catch(function(t){throw e._cached=null,t})})},t)})),function(){return r.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(n=V()(ve().m(function t(){var n,r,i,o,a,s=arguments;return ve().w(function(t){for(;;)switch(t.n){case 0:if(n=s.length>0&&void 0!==s[0]?s[0]:"recvonly",r=s.length>1&&void 0!==s[1]?s[1]:ye,i=s.length>2&&void 0!==s[2]?s[2]:ge.Disabled,!e._cached||e._cached.direction!==n||i!==ge.Disabled||!this.isTracksKindsEquivalentToDefault(r)){t.n=1;break}return o=e._cached.peerConnection,e._cached=null,t.a(2,o);case 1:return a=O.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:i===ge.Enabled}:void 0,t.a(2,e._peerConnectionFactory.value.createPeerConnection(a).then(function(){var e=V()(ve().m(function e(t){var i,o,a,s,u,c,l,d,h,f;return ve().w(function(e){for(;;)switch(e.n){case 0:if(i=t.supportsAddTransceiver,o=[],a=[],!i){e.n=2;break}return r.forEach(function(e){"audio"!==e?"video"!==e||a.push(t.addTransceiver(e,{direction:n})):o.push(t.addTransceiver(e,{direction:n}))}),u=o,c=a,l=t,e.n=1,t.createOffer(void 0);case 1:return d=e.v,e.a(2,{audioTransceivers:u,videoTransceivers:c,peerConnection:l,localOffer:d});case 2:return s="recvonly"===n?{offerToReceiveAudio:!0,offerToReceiveVideo:!0}:{},h=t,e.n=3,t.createOffer(s);case 3:return f=e.v,e.a(2,{peerConnection:h,localOffer:f})}},e)}));return function(t){return e.apply(this,arguments)}}()))}},t,this)})),function(){return n.apply(this,arguments)})},{key:"isTracksKindsEquivalentToDefault",value:function(e){if(e.length!==ye.length)return!1;var t=function(e){return e.reduce(function(e,t){return e[t]=(e[t]||0)+1,e},{audio:0,video:0})},n=t(e),r=t(ye);return n.audio===r.audio&&n.video===r.video}}]);var n,r}();s()(_e,"_logger",ee.getLogger("PeerConnectionService")),s()(_e,"_peerConnectionFactory",new b(new pe)),s()(_e,"_cached",void 0),_e.initiateInitialPrecaching();var be=function(){return o()(function e(){t()(this,e)},null,[{key:"getTelemetryUrl",value:function(e){try{var t=new P.value.URL(e),n=t.hostname.split(".");switch(t.protocol){case"ws:":t.protocol="http:";break;case"wss:":t.protocol="https:"}return 2===n.length||3===n.length&&n[n.length-2].length<=2&&n[n.length-1].length<=3?n.unshift("telemetry"):n[0].startsWith("stg-")||n[0].endsWith("-stg")||n[0].includes("-stg-")||"stg"===n[0]?n[0]="telemetry-stg":n[0].startsWith("local")||n[0].endsWith("-local")||(n[0]="telemetry"),t.hostname=n.join("."),"".concat(t.origin,"/telemetry")}catch(t){return e}}}])}(),Ce=function(){return o()(function e(){t()(this,e)},null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new P.value.URL(e).origin}catch(e){return""}}}])}(),ke=function(){return o()(function e(){t()(this,e)},null,[{key:"discoveryParameters",get:function(){return this._discoveryParameters}},{key:"applyParameters",value:function(){try{var e={discovery:{intentions:"contribution,distribution"}};this._discoveryParameters="discovery"in e?e.discovery:{intentions:""}}catch(e){this._discoveryParameters={intentions:""}}}}])}();s()(ke,"_discoveryParameters",void 0),ke.applyParameters();var Se=function(){function e(){throw t()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return o()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new P.value.URL(e.toString()),n=B.sdkVersion,r=ke.discoveryParameters.intentions;return t.searchParams.set("version",n),t.searchParams.set("intentions",r),t.searchParams.set("_","".concat(Date.now())),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}])}();s()(Se,"_discoveryUri",new b("https://pcast.phenixrts.com/pcast/endPoints"));var we=n(738),Te=n.n(we),xe=function(){return o()(function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e5;t()(this,e),s()(this,"_backoffIntervalInMillisecond",void 0),s()(this,"_minBackoffIntervalInMillisecond",void 0),s()(this,"_maxBackoffIntervalInMillisecond",void 0),this._backoffIntervalInMillisecond=n,this._minBackoffIntervalInMillisecond=r,this._maxBackoffIntervalInMillisecond=i},[{key:"getExponentialBackoffIntervalByFailureCount",value:function(e){var t=this._backoffIntervalInMillisecond/1e3,n=.5+.5*Math.random(),r=Math.pow(t,e-2),i=Math.floor(r)*n,o=Math.ceil(Math.max(1e3*i,this._minBackoffIntervalInMillisecond));return Math.min(o,this._maxBackoffIntervalInMillisecond)}}])}(),Pe=function(e){return e[e.TimeToFirstFrame=0]="TimeToFirstFrame",e[e.ChannelCreationTimeToFirstFrame=1]="ChannelCreationTimeToFirstFrame",e[e.Stalled=2]="Stalled",e[e.Buffering=3]="Buffering",e[e.SetupCompleted=4]="SetupCompleted",e[e.SetupFailed=5]="SetupFailed",e[e.RoundTripTime=6]="RoundTripTime",e[e.DownlinkThroughputCapacity=7]="DownlinkThroughputCapacity",e[e.NetworkType=8]="NetworkType",e[e.ResolutionChanged=9]="ResolutionChanged",e[e.ApplicationForeground=10]="ApplicationForeground",e[e.ApplicationBackground=11]="ApplicationBackground",e}(Pe||{}),Ee=Pe,Oe=function(){return o()(function e(n){t()(this,e),s()(this,"_metrics",void 0),this._metrics=n},[{key:"getName",value:function(){return Ee[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case Ee.TimeToFirstFrame:case Ee.ChannelCreationTimeToFirstFrame:return K.Essential;case Ee.Stalled:case Ee.Buffering:case Ee.SetupCompleted:case Ee.SetupFailed:case Ee.RoundTripTime:case Ee.DownlinkThroughputCapacity:case Ee.NetworkType:case Ee.ResolutionChanged:case Ee.ApplicationForeground:case Ee.ApplicationBackground:return K.All;default:Z(this._metrics)}}}])}(),Re=n(981).A;function Fe(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return Ie(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Ie(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Ie(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,Ie(d,"constructor",c),Ie(c,"constructor",u),u.displayName="GeneratorFunction",Ie(c,i,"GeneratorFunction"),Ie(d),Ie(d,i,"Generator"),Ie(d,r,function(){return this}),Ie(d,"toString",function(){return"[object Generator]"}),(Fe=function(){return{w:o,m:h}})()}function Ie(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Ie=function(e,t,n,r){function o(t,n){Ie(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},Ie(e,t,n,r)}var Le,De,Ae=function(){return o()(function e(n){var r=this;t()(this,e),s()(this,"_logger",ee.getLogger("MetricsService")),s()(this,"_metricsConfiguration",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_metrics",[]),s()(this,"_isSending",!1),s()(this,"_failureCount",0),s()(this,"_domain",""),this._metricsConfiguration=n,this._exponentialBackoff=new xe,this.getLocationHostnameFromGlobalScope().then(function(e){r._domain=e})},[{key:"metricsConfiguration",get:function(){return this._metricsConfiguration}},{key:"push",value:function(e){var t=e.streamId,n=e.value,r=e.previousValue,i=e.runtime,o=e.resource,a=e.kind,s=new Oe(e.metricType);if(!(this._metricsConfiguration.threshold>s.getTelemetryLevel())){var u={timestamp:(new Date).toISOString(),tenancy:this._metricsConfiguration.tenancy,sessionId:this._metricsConfiguration.sessionId,streamId:t,metric:s.getName(),value:n,previousValue:r,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:B.sdkVersion,runtime:i,resource:o,kind:a};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new Re(function(e){var t=P.subscribe(function(n){n&&(e(n.locationHostname),n.setTimeout(function(){return t.dispose()},0))})})}},{key:"sendMetrics",value:(n=V()(Fe().m(function e(t){var n;return Fe().w(function(e){for(;;)switch(e.n){case 0:return(n=new P.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.n=1,P.value.fetch(this._metricsConfiguration.url,{method:"POST",body:n});case 1:return e.a(2,e.v)}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(e=V()(Fe().m(function e(){var t,n=this;return Fe().w(function(e){for(;;)switch(e.n){case 0:if(!(this._metrics.length<=0||this._isSending)&&P.value){e.n=1;break}return e.a(2);case 1:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.a(2,this.sendMetrics(t).then(function(e){if(n.isResponseStatusCodeRetryable(e)){if(n._metrics.length<=2048)return n._failureCount++,void P.value.setTimeout(function(){n._metrics=[].concat(c()(t),c()(n._metrics)),n._isSending=!1,n.sendMetricsIfAble()},n._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(n._failureCount));n._logger.error("Too many cached metric records [%s], dropping [%s] records",n._metrics.length,t.length)}return n._isSending=!1,n._failureCount=0,n.sendMetricsIfAble(),e}).catch(function(){n._isSending=!1,n.sendMetricsIfAble()}))}},e,this)})),function(){return e.apply(this,arguments)})},{key:"isResponseStatusCodeRetryable",value:function(e){var t=e.status;return/^5\d{2}$/.test(t.toString())}}]);var e,n}(),je=function(){function e(){throw t()(this,e),new Error("MetricsFactory is a static class that may not be instantiated")}return o()(e,null,[{key:"getMetricsService",value:function(t){if("string"!=typeof t)throw new Error("url must be a string instead received [".concat(Te()(t),"]"));var n=e._metricsServices[t];if(n)return n;var r=new Q;return r.sessionId=Ve.clientSessionId,r.tenancy=Ve.tenancy.value,r.url=be.getTelemetryUrl(t),r.environment=Ce.getEnvironmentFromUrl(t),r.threshold=$.convertTelemetryLevelTypeToTelemetryLevel(Ve.telemetryLevel),e._metricsServices[t]=new Ae(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach(function(e){e.metricsConfiguration.threshold=t})}}])}();s()(je,"_metricsServices",{});var Me=(null===(Le=S.getInstance().value)||void 0===Le?void 0:Le.pageLoadTime)||Date.now(),Ve=function(){function e(){throw t()(this,e),new Error("SDK is a static class that may not be instantiated")}return o()(e,null,[{key:"pageLoadTime",get:function(){return Me}},{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"tenancy",get:function(){return this._tenancy}},{key:"clientSessionId",get:function(){return e._clientSessionId}},{key:"loadedTimestamp",get:function(){return e._loadedTimestamp}},{key:"initialized",get:function(){return e._readOnlyInitialized}},{key:"discoveryUri",get:function(){return e._readOnlyDiscoveryUri}},{key:"peerConnectionFactory",get:function(){return e._readOnlyPeerConnectionFactory}},{key:"automaticRetryOnFailure",get:function(){return e._automaticallyRetryOnFailure}},{key:"automaticallyReconnectPeerConnection",get:function(){return e._automaticallyReconnectPeerConnection}},{key:"automaticallyPlayMediaStream",get:function(){return e._automaticallyPlayMediaStream}},{key:"automaticallyMuteVideoOnPlayFailure",get:function(){return e._automaticallyMuteVideoOnPlayFailure}},{key:"forceGarbageCollectionOnRestart",get:function(){return this._forceGarbageCollectionOnRestart}},{key:"skipGarbageCollectionOnMobileDevices",get:function(){return this._skipGarbageCollectionOnMobileDevices}},{key:"webPlayerLoader",get:function(){return this._webPlayerLoader}},{key:"shakaPlayerLoader",get:function(){return this._shakaPlayerLoader}},{key:"hlsJsLoader",get:function(){return this._hlsJsLoader}},{key:"metricsService",get:function(){return e._metricsService}},{key:"applicationActivityMonitor",get:function(){return this._applicationActivityMonitor}},{key:"telemetryUrl",get:function(){return this._telemetryUrl}},{key:"maximalNumberOfPeerConnectionReconnectAttempts",get:function(){return this._maximalNumberOfPeerConnectionReconnectAttempts},set:function(e){this._maximalNumberOfPeerConnectionReconnectAttempts=e}},{key:"loggingLevel",get:function(){return X.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return $.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return E}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=ee.telemetryConfiguration;n.sessionId=e.clientSessionId,n.pageLoadTime=e.pageLoadTime,e._environment.subscribe(function(e){n.environment=e}),e.telemetryUrl.subscribe(function(e){var r=t._logger.appenders.value.find(function(e){return e instanceof q});r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new q(n)),t._logger.info("Telemetry URL was set to [%s]",n.url))}),e._tenancy.subscribe(function(e){var r=t._logger.appenders.value.find(function(e){return e instanceof q});r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new q(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))})}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=je.getMetricsService(Se.uri.value),e._metricsConfiguration=e._metricsService.metricsConfiguration,e._metricsConfiguration.sessionId=e.clientSessionId,e._environment.subscribe(function(t){e._metricsConfiguration.environment=t}),e.telemetryUrl.subscribe(function(t){e._metricsConfiguration.url=t}),e._tenancy.subscribe(function(t){e._metricsConfiguration.tenancy=t});var t=Y.getStringValue("phenix-metrics-level");t&&je.setTelemetryLevel(K[t]),e._telemetryLevel.subscribe(function(e){je.setTelemetryLevel(e)})}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=Y.getBooleanValue("phenix-automatically-retry-on-failure"),this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure)}},{key:"applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration",value:function(){this._automaticallyReconnectPeerConnection=Y.getBooleanValue("phenix-automatically-reconnect-peer-connection"),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection)}},{key:"applyForceGarbageCollectionOnRestartFromParameterConfiguration",value:function(){this._forceGarbageCollectionOnRestart=Y.getBooleanValue("phenix-force-garbage-collection-on-restart"),this._logger.info("Force garbage collection on restart is set to: [%s]",this._forceGarbageCollectionOnRestart)}},{key:"applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration",value:function(){this._skipGarbageCollectionOnMobileDevices=Y.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices"),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices)}},{key:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe(function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=Ce.getEnvironmentFromUrl(t)});var t=Y.getStringValue("phenix-channel-token");if(t){var n=re.parseToken(t);return e._tenancy.value=n.tenancy,Se.uri.value=(n.uri||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var r=Y.getStringValue("phenix-uri");if(r)return Se.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=Y.getStringValue("phenix-base-uri");if(i){var o=new(S.getInstance().value.URL)(i);return o.pathname="/pcast/endPoints",Se.uri.value=o.toString(),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)}}},{key:"onLoad",value:function(t){t&&(this._initialized.value?this._logger.warn("SDK has already been loaded"):(t.addWindowEventListener("unload",function(){e.dispose()}),e.applyDiscoveryUriDefaultFromParameterConfiguration(),e.applyMetricsConfiguration(),e.applyTelemetryConfiguration(),this._applicationActivityMonitor=new ae,this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection),this._logger.info("Force garbage collection on restart is set to: [%s]",this._forceGarbageCollectionOnRestart),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices),this._initialized.value=!0))}},{key:"init",value:function(t){if(t){var n=t;if(n.globalScope&&S.setInstance(n.globalScope),t.discoveryUri&&(Se.uri.value=t.discoveryUri),t.peerConnectionFactory&&(_e.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&K[t.telemetryLevel]&&(e._telemetryLevel.value=$.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&R[t.loggingLevel]&&this._logger.threshold.setThreshold(X.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&R[t.consoleLoggingLevel]){var r=this._logger.appenders.value.find(function(e){return e instanceof j});r&&this._logger.appenders.remove(r),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new j(X.convertLoggingLevelTypeToLoggingLevel(t.consoleLoggingLevel)))}"boolean"==typeof t.automaticallyPlayMediaStream&&(this._automaticallyPlayMediaStream=t.automaticallyPlayMediaStream),"boolean"==typeof t.automaticallyMuteVideoOnPlayFailure&&(this._automaticallyMuteVideoOnPlayFailure=t.automaticallyMuteVideoOnPlayFailure),t.webPlayerLoader&&(this._webPlayerLoader=t.webPlayerLoader),t.shakaPlayerLoader&&(this._shakaPlayerLoader=t.shakaPlayerLoader),t.hlsJsLoader&&(this._hlsJsLoader=t.hlsJsLoader)}}},{key:"dispose",value:function(){var t;e._initialized.value=!1,null===(t=this._applicationActivityMonitor)||void 0===t||t.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return be.getTelemetryUrl(e)}}])}();De=Ve,s()(Ve,"_automaticallyRetryOnFailure",Y.getBooleanValue("phenix-automatically-retry-on-failure")),s()(Ve,"_automaticallyReconnectPeerConnection",Y.getBooleanValue("phenix-automatically-reconnect-peer-connection")),s()(Ve,"_automaticallyPlayMediaStream",!0),s()(Ve,"_automaticallyMuteVideoOnPlayFailure",!0),s()(Ve,"_forceGarbageCollectionOnRestart",Y.getBooleanValue("phenix-force-garbage-collection-on-restart")),s()(Ve,"_skipGarbageCollectionOnMobileDevices",Y.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices")),s()(Ve,"_webPlayerLoader",void 0),s()(Ve,"_shakaPlayerLoader",void 0),s()(Ve,"_hlsJsLoader",void 0),s()(Ve,"_applicationActivityMonitor",void 0),s()(Ve,"_environment",new b("")),s()(Ve,"_telemetryUrl",new b("https://telemetry.phenixrts.com/telemetry")),s()(Ve,"_maximalNumberOfPeerConnectionReconnectAttempts",8),s()(Ve,"_telemetryLevel",new b(J.defaultTelemetryLevel)),s()(Ve,"_metricsService",void 0),s()(Ve,"_metricsConfiguration",void 0),s()(Ve,"_sendLocalCandidates",new b(L.sendLocalCandidates)),s()(Ve,"_tenancy",new b("")),s()(Ve,"_clientSessionId",te.random(32)),s()(Ve,"_loadedTimestamp",new Date),s()(Ve,"_logger",ee.getLogger("SDK")),s()(Ve,"_initialized",new b(!1)),s()(Ve,"_readOnlyInitialized",new C(De._initialized)),s()(Ve,"_readOnlyDiscoveryUri",new C(Se.uri)),s()(Ve,"_readOnlyPeerConnectionFactory",new C(_e.peerConnectionFactory)),S.subscribe(Ve.onLoad.bind(Ve));var Ge=function(){function e(n,r){t()(this,e),s()(this,"width",void 0),s()(this,"height",void 0),this.width=n,this.height=r}return o()(e,[{key:"equals",value:function(e){return e&&this.width===e.width&&this.height===e.height}},{key:"toString",value:function(){return"".concat(this.width,"x").concat(this.height)}}],[{key:"empty",get:function(){return new e(0,0)}}])}(),Be=function(){return o()(function e(){throw t()(this,e),new Error("GarbageCollectorManager is a static class that may not be instantiated")},null,[{key:"forceGarbageCollection",value:function(){O.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){O.isQueueMicrotaskSupported?P.value.queueMicrotask(this.overloadMemoryToInvokeGarbageCollection.bind(this)):P.value.setTimeout(this.overloadMemoryToInvokeGarbageCollection.bind(this),0)}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=P.value.documentCreateElement("img");e.src=P.value.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){P.value.URL.revokeObjectURL(this.src),e=null}}}])}(),Ue=function(e){return e[e.Initializing=0]="Initializing",e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Paused=3]="Paused",e[e.Playing=4]="Playing",e[e.Recovering=5]="Recovering",e[e.Reconnecting=6]="Reconnecting",e[e.StandBy=7]="StandBy",e[e.Stopped=8]="Stopped",e[e.Unauthorized=9]="Unauthorized",e[e.GeoRestricted=10]="GeoRestricted",e[e.GeoBlocked=11]="GeoBlocked",e[e.UnsupportedFeature=12]="UnsupportedFeature",e[e.ConfigurationError=13]="ConfigurationError",e[e.TransientConfigurationError=14]="TransientConfigurationError",e[e.ConnectionError=15]="ConnectionError",e[e.ClientStartError=16]="ClientStartError",e[e.Error=17]="Error",e}(Ue||{}),Ne=Ue,ze=function(){return o()(function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t()(this,e),s()(this,"_duration",void 0),this._duration=n},[{key:"toIsoString",value:function(){if(0===this._duration)return"P0S";var e=this._duration<0,t=e?Math.abs(this._duration):this._duration,n=Math.floor(t),r=n%1e3,i=(n=Math.floor(n/1e3))%60,o=(n=Math.floor(n/60))%60,a=(n=Math.floor(n/60))%24,s=["PT"];return e&&s.unshift("-"),a&&s.push(a+"H"),o&&s.push(o+"M"),(i||r)&&(s.push(String(i)),r&&s.push("."+this.padStart(r.toString(),3,"0")),s.push("S")),s.join("")}},{key:"padStart",value:function(e,t,n){return t|=0,n=String(void 0!==n?n:" "),e.length>t?e:((t-=e.length)>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}}])}(),He=function(){},qe=function(){return o()(function e(n,r,i,o){t()(this,e),s()(this,"_pageLoadTime",void 0),s()(this,"_channelStartTime",void 0),s()(this,"_logger",ee.getLogger("StreamTelemetry")),s()(this,"_disposables",new ie),s()(this,"_streamId",void 0),s()(this,"_metricsService",void 0),s()(this,"_listenToFirstTime",He),s()(this,"_listenForStall",He),s()(this,"_listenForContinuation",He),s()(this,"_timeToFirstFrame",0),s()(this,"_channelCreationTimeToFirstFrame",0),s()(this,"_startRecordingFirstFrame",0),s()(this,"_videoStalled",null),s()(this,"_lastProgress",0),s()(this,"_videoResolution",""),s()(this,"_clearTimeToFirstFrameListener",new m(function(){return null})),s()(this,"_clearRebufferingListener",new m(function(){return null})),this._streamId=n,this._pageLoadTime=r,this._channelStartTime=i,this._metricsService=o},[{key:"setupListenerForTimeToFirstTime",value:function(e){var t=this;this._startRecordingFirstFrame=Date.now(),this._listenToFirstTime=function(){return t.callTimeToFirstFrame()},e.addEventListener("loadeddata",this._listenToFirstTime),e.addEventListener("loadedmetadata",this._listenToFirstTime),this._clearTimeToFirstFrameListener=new m(function(){e.removeEventListener("loadeddata",t._listenToFirstTime),e.removeEventListener("loadedmetadata",t._listenToFirstTime)}),this._disposables.add(this._clearTimeToFirstFrameListener)}},{key:"setupListenerForRebuffering",value:function(e){var t=this;this._listenForStall=function(){return t.onStall()},this._listenForContinuation=function(n){return t.onContinuation(n,e)},e.addEventListener("stalled",this._listenForStall),e.addEventListener("pause",this._listenForStall),e.addEventListener("suspend",this._listenForStall),e.addEventListener("play",this._listenForContinuation),e.addEventListener("playing",this._listenForContinuation),e.addEventListener("progress",this._listenForContinuation),e.addEventListener("timeupdate",this._listenForContinuation),this._clearRebufferingListener=new m(function(){e.removeEventListener("stalled",t._listenForStall),e.removeEventListener("pause",t._listenForStall),e.removeEventListener("suspend",t._listenForStall),e.removeEventListener("play",t._listenForContinuation),e.removeEventListener("playing",t._listenForContinuation),e.removeEventListener("progress",t._listenForContinuation),e.removeEventListener("timeupdate",t._listenForContinuation)}),this._disposables.add(this._clearRebufferingListener)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"durationSincePageLoad",get:function(){var e=Date.now();return new ze(e-this._pageLoadTime).toIsoString()}},{key:"callTimeToFirstFrame",value:function(){var e=Date.now();this.pushTimeToFirstFrame(e),this.pushChannelCreationTimeToFirstFrame(e),this._clearTimeToFirstFrameListener.dispose()}},{key:"pushTimeToFirstFrame",value:function(e){this._timeToFirstFrame=e-this._startRecordingFirstFrame,this._metricsService.push({metricType:Ee.TimeToFirstFrame,runtime:(e-this._pageLoadTime)/1e3,value:{uint64:this._timeToFirstFrame},streamId:this._streamId}),this._logger.info("[%s] [%s] First frame [%s]",this.durationSincePageLoad,this._streamId,new ze(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:Ee.ChannelCreationTimeToFirstFrame,runtime:(e-this._pageLoadTime)/1e3,value:{uint64:this._channelCreationTimeToFirstFrame},streamId:this._streamId}),this._logger.info("[%s] [%s] Channel creation to first frame [%s]",this.durationSincePageLoad,this._streamId,new ze(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:Ee.Stalled,runtime:(Date.now()-this._pageLoadTime)/1e3,streamId:this._streamId}),this._videoStalled=Date.now(),this._logger.info("[%s] [%s] [buffering] Stream has stalled",this.durationSincePageLoad,this._streamId))}},{key:"onContinuation",value:function(e,t){if(t.buffered){var n=t.buffered.length,r=!("playing"===e.type||n>0)||("progress"===e.type||"timeupdate"===e.type)&&t.buffered.end(n-1)===this._lastProgress;if(this._videoStalled&&!r){"progress"===e.type&&(this._lastProgress=t.buffered.end(n-1));var i=Date.now()-this._videoStalled;this._metricsService.push({metricType:Ee.Buffering,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{uint64:i},streamId:this._streamId}),this._logger.info("[%s] [%s] [buffering] Stream has recovered from stall after [%s]",this.durationSincePageLoad,this._streamId,new ze(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:Ee.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}}])}(),We=function(){return o()(function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("StreamSetupListener")),s()(this,"metricsService",Ve.metricsService),s()(this,"_pageLoadTime",void 0),s()(this,"_startTime",void 0),s()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=n},[{key:"success",value:function(e){this.recordStreamMetric(Ee.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(Ee.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new Oe(e).getName();this.metricsService.push({metricType:e,runtime:(n-this._pageLoadTime)/1e3,value:{uint64:r},streamId:t}),this._logger.info("[%s] [%s] Stream metric [%s] in [%s]",new ze(n-this._pageLoadTime).toIsoString(),t,i,new ze(r).toIsoString())}}}])}(),Je=function(){return o()(function e(){t()(this,e),s()(this,"_disposables",new ie),s()(this,"_isSupported",void 0!==P.value.navigatorConnection),s()(this,"_rtt",new b(void 0)),s()(this,"_effectiveType",new b(void 0)),s()(this,"_downlinkThroughputCapacity",new b(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())},[{key:"isSupported",get:function(){return this._isSupported}},{key:"rtt",get:function(){return this._rtt}},{key:"effectiveType",get:function(){return this._effectiveType}},{key:"downlinkThroughputCapacity",get:function(){return this._downlinkThroughputCapacity}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"getDownlinkThroughputCapacity",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=P.value.navigatorConnection)||void 0===n?void 0:n.downlink)&&void 0!==t?t:null===(r=P.value.navigatorConnection)||void 0===r?void 0:r.downlinkMax)&&void 0!==e?e:-1}},{key:"getEffectiveType",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=P.value.navigatorConnection)||void 0===n?void 0:n.effectiveType)&&void 0!==t?t:null===(r=P.value.navigatorConnection)||void 0===r?void 0:r.type)&&void 0!==e?e:"Unknown"}},{key:"getRoundTripTime",value:function(){var e,t;return null!==(e=null===(t=P.value.navigatorConnection)||void 0===t?void 0:t.rtt)&&void 0!==e?e:-1}},{key:"setupNetworkChangeListeners",value:function(){var e,t=this,n=function(){return t.updateStatistics()};null===(e=P.value.navigatorConnection)||void 0===e||e.addEventListener("change",n),this._disposables.add(new m(function(){var e;return null===(e=P.value.navigatorConnection)||void 0===e?void 0:e.removeEventListener("change",n)}))}},{key:"updateStatistics",value:function(){this._rtt.value=this.getRoundTripTime(),this._effectiveType.value=this.getEffectiveType(),this._downlinkThroughputCapacity.value=this.getDownlinkThroughputCapacity()}}])}(),Ke=function(){return o()(function e(n,r){var i=this;if(t()(this,e),s()(this,"_logger",ee.getLogger("SessionTelemetry")),s()(this,"_metricsService",void 0),s()(this,"_applicationActivityMonitor",Ve.applicationActivityMonitor),s()(this,"_networkMonitor",new Je),s()(this,"_pageLoadTime",void 0),s()(this,"_disposables",new ie),s()(this,"_lastNetworkStatistics",{}),this._pageLoadTime=n,this._disposables.add(this._networkMonitor),this._metricsService=r,!this._applicationActivityMonitor)throw new Error("SessionTelemetry Failed: No application monitor initialized.");this._networkMonitor.isSupported&&(this._disposables.add(this._applicationActivityMonitor.isForeground.subscribe(function(e){i.recordForegroundChange(e)})),this._disposables.add(this._networkMonitor.rtt.subscribe(function(e){e&&i.recordNetworkRTTUpdate(e)})),this._disposables.add(this._networkMonitor.effectiveType.subscribe(function(e){e&&i.recordNetworkTypeChangeUpdate(e)})),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe(function(e){e&&i.recordNetworkDownlinkThroughputCapacityUpdate(e)})))},[{key:"listenOnStreamSetup",value:function(){return new We(this._pageLoadTime)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"recordForegroundChange",value:function(e){var t,n=Date.now(),r=null===(t=this._applicationActivityMonitor)||void 0===t?void 0:t.getTimeSinceLastChange();r&&(this._metricsService.push({metricType:e?Ee.ApplicationForeground:Ee.ApplicationBackground,runtime:(n-this._pageLoadTime)/1e3,value:{uint64:r}}),this._logger.info("Application has gone into the [%s] after [%s] ms",e?"foreground":"background",new ze(r).toIsoString()))}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:Ee.RoundTripTime,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:e},previousValue:n?{uint64:n}:void 0,resource:"navigator"}),this._logger.info("[%s] Network RTT changed to [%s] from [%s]",new ze(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkTypeChangeUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.effectiveType;this._lastNetworkStatistics.effectiveType=e,this._metricsService.push({metricType:Ee.NetworkType,runtime:(t-this._pageLoadTime)/1e3,value:{string:e},previousValue:n?{string:n}:void 0}),this._logger.info("[%s] Network effective type has changed to [%s] from [%s]",new ze(t-this._pageLoadTime).toIsoString(),e,n)}},{key:"recordNetworkDownlinkThroughputCapacityUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.downlinkThroughputCapacity;this._lastNetworkStatistics.downlinkThroughputCapacity=e,this._metricsService.push({metricType:Ee.DownlinkThroughputCapacity,runtime:(t-this._pageLoadTime)/1e3,value:{float:e},previousValue:n?{float:n}:void 0}),this._logger.info("[%s] Network downlink throughput capacity changed to [%s] from [%s]",new ze(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),Qe=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Ze=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),$e=o()(function e(n){t()(this,e),s()(this,"token",void 0),s()(this,"tokenExpiring",void 0),this.token=new b(n),this.tokenExpiring=new b(!1)}),Xe=function(){return o()(function e(n){var r,i,o;t()(this,e),s()(this,"channelInitialization",void 0),s()(this,"disposables",void 0),s()(this,"channelDisposables",void 0),s()(this,"rendererDisposables",void 0),s()(this,"videoElement",void 0),s()(this,"state",void 0),s()(this,"exists",void 0),s()(this,"autoMuted",void 0),s()(this,"autoPaused",void 0),s()(this,"authorized",void 0),s()(this,"online",void 0),s()(this,"loading",void 0),s()(this,"playing",void 0),s()(this,"standby",void 0),s()(this,"stopped",void 0),s()(this,"targetLag",void 0),s()(this,"lag",void 0),s()(this,"bitrateLimit",void 0),s()(this,"resolution",void 0),s()(this,"failureCount",void 0),s()(this,"endPoint",void 0),s()(this,"onRealTimeSubscribeRequestCallback",void 0),s()(this,"onRealTimeSubscribeResponseCallback",void 0),s()(this,"stream",void 0),s()(this,"rtcStatistics",void 0),s()(this,"videoTelemetry",void 0),s()(this,"rtcAudioStatistic",void 0),s()(this,"rtcVideoStatistic",void 0),s()(this,"clearFailureCountTimeout",void 0),this.disposables=new ie,this.channelDisposables=new ie,this.rendererDisposables=new ie,this.channelInitialization=new Date,this.videoElement=new b(null),this.state=new b(Ne.Initializing),this.exists=new b(null),this.autoMuted=new b(!1),this.autoPaused=new b(!1),this.authorized=new b(!0),this.online=new b(!0),this.loading=new b(!1),this.playing=new b(!1),this.standby=new b(!1),this.stopped=new b(!1),this.targetLag=new b(null!==(r=null==n?void 0:n.targetLag)&&void 0!==r?r:0),this.lag=new b(void 0),this.bitrateLimit=new b(0),this.resolution=new b(Ge.empty),this.failureCount=new b(0),this.endPoint=new b(null),this.onRealTimeSubscribeRequestCallback=null!==(i=null==n?void 0:n.onRealTimeSubscribeRequestCallback)&&void 0!==i?i:null,this.onRealTimeSubscribeResponseCallback=null!==(o=null==n?void 0:n.onRealTimeSubscribeResponseCallback)&&void 0!==o?o:null,this.stream=new b(null),this.rtcStatistics=new b(null),this.videoTelemetry=null,this.rtcAudioStatistic=null,this.rtcVideoStatistic=null,this.clearFailureCountTimeout=0},[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":return this.authorized.value=!1,this.failureCount.value=0,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);case"no-stream":case"not-found":return this.failureCount.value=0,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null)}}},{key:"applySessionAndStreamPropertiesToVideoElement",value:function(){this.videoElement.value&&this.videoElement.value.dataset&&(this.videoElement.value.dataset.sessionId=Ve.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return Ne.Starting;case"no-stream":case"not-found":return Ne.StandBy;case"geo-restricted":return Ne.GeoRestricted;case"geo-blocked":return Ne.GeoBlocked;case"unauthorized":return Ne.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Ne.Recovering;case"forbidden-tag":return Ne.ConfigurationError;case"port-in-range-not-found":return Ne.TransientConfigurationError;case"failed":return Ne.Error;default:Z(e)}}},{key:"mapSubscribeStatusToExists",value:function(e){switch(e){case"ok":case"no-stream":case"geo-restricted":case"geo-blocked":case"forbidden-tag":case"port-in-range-not-found":return!0;case"not-found":return!1;case"unauthorized":case"timeout":case"rate-limited":case"capacity":case"failed":return this.exists.value;default:Z(e)}}}])}(),Ye=function(){return o()(function e(){throw t()(this,e),new Error("EncodedStreamSink is a static class that may not be instantiated")},null,[{key:"validateEncodedStreamSink",value:function(e,t){return"function"!=typeof t?{valid:!1,validationResult:"Unexpected ".concat(e," Encoded Stream Sink function type. Found [").concat(Te()(t),"]")}:2!==t.length?{valid:!1,validationResult:"Unexpected ".concat(e," Encoded Stream Sink function parameter length. Expected 2. Found [").concat(t.length,"]")}:{valid:!0,validationResult:"ok"}}}])}(),et=function(){return o()(function e(){t()(this,e)},null,[{key:"validateMediaStreamTrackTransform",value:function(e,t){return"function"!=typeof t?{valid:!1,validationResult:"Unexpected ".concat(e," Media Stream Track transform function type. Found [").concat(Te()(t),"]")}:3!==t.length?{valid:!1,validationResult:"Unexpected ".concat(e," Media Stream Track transform function parameter length. Expected 3. Found [").concat(t.length,"]")}:{valid:!0,validationResult:"ok"}}}])}(),tt=o()(function e(n){t()(this,e),s()(this,"hasInsertableStreams",void 0),s()(this,"hasEncodedInsertableStreams",void 0),s()(this,"videoStreamTransformCallback",void 0),s()(this,"audioStreamTransformCallback",void 0),s()(this,"encodedVideoStreamSink",void 0),s()(this,"encodedAudioStreamSink",void 0),s()(this,"audioTrack",void 0),s()(this,"videoTrack",void 0),this.hasInsertableStreams=new b(n.hasInsertableStreams),this.hasEncodedInsertableStreams=new b(n.hasEncodedInsertableStreams),this.videoStreamTransformCallback=n.videoStreamTransformCallback,this.audioStreamTransformCallback=n.audioStreamTransformCallback,this.encodedVideoStreamSink=n.encodedVideoStreamSink,this.encodedAudioStreamSink=n.encodedAudioStreamSink,this.audioTrack={mediaStreamTrack:null,receiver:null,mid:null,codec:null,transformPipelineWorker:null,transformMessageRouter:null,transformFunctionNames:[]},this.videoTrack={mediaStreamTrack:null,receiver:null,mid:null,codec:null,transformPipelineWorker:null,transformMessageRouter:null,transformFunctionNames:[]}}),nt=o()(function e(){t()(this,e),s()(this,"mediaStream",void 0),s()(this,"peerConnection",void 0),s()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new b(null),this.peerConnection=new b(null),this.peerConnectionReconnectAttempts=0}),rt=o()(function e(){t()(this,e),s()(this,"isStarting",void 0),s()(this,"isDisposed",void 0),this.isStarting=new b(!1),this.isDisposed=!1}),it=o()(function e(){t()(this,e),s()(this,"shouldExtractTimecode",void 0),s()(this,"shouldExtractTimestamps",void 0),s()(this,"isEnabled",void 0),s()(this,"decodedFrameTimingInformation",void 0),s()(this,"renderedFrameTimingInformation",void 0),this.shouldExtractTimecode=new b(!1),this.shouldExtractTimestamps=new b(!1),this.isEnabled=new b(!1),this.decodedFrameTimingInformation=new b(null),this.renderedFrameTimingInformation=new b(null)}),ot=n(715),at=n.n(ot),st=function(){return o()(function e(n){t()(this,e),s()(this,"_sdp",void 0),s()(this,"_audioCodec",void 0),s()(this,"_videoCodec",void 0),s()(this,"_isAudioTrackEnabled",void 0),s()(this,"_isVideoTrackEnabled",void 0),this._sdp=n;var r=this._sdp.split(/(\r\n|\r|\n)/),i=this._sdp.split(/(?:^|[\r\n])m=/);this._audioCodec=this.applyCodec("audio",r),this._videoCodec=this.applyCodec("video",r),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",i),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",i)},[{key:"audioCodec",get:function(){return this._audioCodec}},{key:"videoCodec",get:function(){return this._videoCodec}},{key:"isAudioTrackEnabled",get:function(){return this._isAudioTrackEnabled}},{key:"isVideoTrackEnabled",get:function(){return this._isVideoTrackEnabled}},{key:"isTrackByTypeEnabled",value:function(e,t){var n=t.find(function(t){return t.startsWith(e)});return!!n&&!n.includes("a=inactive")}},{key:"applyCodec",value:function(e,t){var n,r=(null===(n=t.find(function(t){return t.includes("m=".concat(e))}))||void 0===n?void 0:n.split(" ")[3])||"",i=t.find(function(e){return e.includes("a=rtpmap:".concat(r))});return((null==i?void 0:i.split(" ")[1])||"").split("/")[0]}}])}(),ut=function(){return o()(function e(){throw t()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")},null,[{key:"truncateIceServers",value:function(e){var t=[];if(!e.iceServers)return e;for(var n=0;n<e.iceServers.length;n++){for(var r=[],i=0;i<2;i++)e.iceServers[n].urls[i]&&r.push(e.iceServers[n].urls[i]);t.push({urls:r,username:e.iceServers[n].username,credential:e.iceServers[n].credential})}return e.iceServers=t,e}}])}(),ct=n(981).A;function lt(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return dt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(dt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,dt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,dt(d,"constructor",c),dt(c,"constructor",u),u.displayName="GeneratorFunction",dt(c,i,"GeneratorFunction"),dt(d),dt(d,i,"Generator"),dt(d,r,function(){return this}),dt(d,"toString",function(){return"[object Generator]"}),(lt=function(){return{w:o,m:h}})()}function dt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}dt=function(e,t,n,r){function o(t,n){dt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},dt(e,t,n,r)}var ht=function(){return o()(function e(n,r,i,o){var a=this;if(t()(this,e),s()(this,"_logger",ee.getLogger("RtcConnectionMonitor")),s()(this,"_estimatedRoundTripTime",void 0),s()(this,"_estimatedVideoCodec","unknown"),s()(this,"_estimatedAudioCodec","unknown"),s()(this,"_rtcStatistic",new b({})),s()(this,"_disposables",new ie),s()(this,"_peerConnection",void 0),s()(this,"_isMonitorRunning",!0),s()(this,"_updateTimeout",null),s()(this,"_tracksToMonitor",void 0),s()(this,"_monitorGeneration",0),this._peerConnection=n,this._estimatedRoundTripTime=i,this._tracksToMonitor=r.getTracks().map(function(e){return e.kind})||[],this._peerConnection){var u,c;if(!O.getCurrentOfferDisabled&&null!==(u=this._peerConnection)&&void 0!==u&&null!==(c=u.currentRemoteDescription)&&void 0!==c&&c.sdp){var l=new st(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=l.audioCodec,this._estimatedVideoCodec=l.videoCodec}var d=!0;this._disposables.add(o.subscribe(function(e){d?d=!1:e&&a._isMonitorRunning&&(a._monitorGeneration++,a._updateTimeout&&(P.value.clearTimeout(a._updateTimeout),a._updateTimeout=null),a._logger.debug("Restarting stats polling after foreground transition"),a.updateStatistic())})),this.updateStatistic()}},[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._monitorGeneration++,this._isMonitorRunning=!1,this._peerConnection=null,this._disposables.dispose(),this._updateTimeout&&(P.value.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(n=V()(lt().m(function e(){var t,n,r,i,o,a,s,u,c,l,d,h=this;return lt().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!O.getStatsPromiseBasedDisabled){e.n=1;break}return e.a(2,this.updateStatisticLegacy());case 1:if(t=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},n=this._monitorGeneration,e.p=2,o=null===(i=this._peerConnection)||void 0===i?void 0:i.getStats(null)){e.n=3;break}return e.a(2);case 3:return a=new ct(function(e){r=P.value.setTimeout(function(){return e(null)},5e3)}),e.n=4,ct.race([o,a]);case 4:if(s=e.v,n===this._monitorGeneration&&this._isMonitorRunning){e.n=5;break}return e.a(2);case 5:s?(u={},c=this._estimatedRoundTripTime,s.forEach(function(e){if("candidate-pair"===e.type&&e.currentRoundTripTime&&(c=1e3*e.currentRoundTripTime,u.audio&&(u.audio.roundTripTime=c),u.video&&(u.video.roundTripTime=c)),"candidate-pair"===e.type&&e.lastPacketReceivedTimestamp&&(l=e.lastPacketReceivedTimestamp,u.audio&&(u.audio.lastPacketReceivedTimestamp=l),u.video&&(u.video.lastPacketReceivedTimestamp=l)),"inbound-rtp"===e.type){var n=e.kind||e.mediaType||t(e),r="";if(s.forEach(function(t){t.id===e.codecId&&(r=t.mimeType)}),n&&h._tracksToMonitor.includes(n)){var i,o,a,d,f,p,v,m=(e.bytesReceived||0)-(null!==(i=null===(o=h._rtcStatistic.value)||void 0===o||null===(a=o[n])||void 0===a?void 0:a.bytesReceived)&&void 0!==i?i:0),g=e.timestamp-((null===(d=h._rtcStatistic.value)||void 0===d||null===(f=d[n])||void 0===f?void 0:f.timestamp)||0),y=m&&g?Math.floor(8*m/g*1e3):0;if(u[n]={ssrc:e.ssrc,mediaType:n,timestamp:e.timestamp,bitrate:y,bytesReceived:e.bytesReceived,packetsLost:e.packetsLost,packetsReceived:e.packetsReceived,codec:r||h.getCodecByType(n),roundTripTime:c},(e.lastPacketReceivedTimestamp||l)&&(u[n].lastPacketReceivedTimestamp=e.lastPacketReceivedTimestamp||l),"video"===n&&null!==(p=h._rtcStatistic.value)&&void 0!==p&&null!==(v=p.video)&&void 0!==v&&v.framesDecoded){u[n].framesDecoded=e.framesDecoded;var _=(e.framesDecoded-h._rtcStatistic.value.video.framesDecoded)/(u[n].timestamp-h._rtcStatistic.value.video.timestamp)*1e3;u[n].fps=_?Math.round(100*_)/100:0}}}}),this._rtcStatistic.value=u):this._logger.debug("getStats() timed out, skipping stats processing"),e.n=8;break;case 6:if(e.p=6,d=e.v,n===this._monitorGeneration&&this._isMonitorRunning){e.n=7;break}return e.a(2);case 7:this._logger.warn("getStats() rejected",d);case 8:return e.p=8,P.value.clearTimeout(r),e.f(8);case 9:this._isMonitorRunning&&n===this._monitorGeneration&&(this._updateTimeout=P.value.setTimeout(function(){return h.updateStatistic()},1e3));case 10:return e.a(2)}},e,this,[[2,6,8,9]])})),function(){return n.apply(this,arguments)})},{key:"updateStatisticLegacy",value:(e=V()(lt().m(function e(){var t,n,r,i,o,a,s,u,c,l=this;return lt().w(function(e){for(;;)switch(e.p=e.n){case 0:if(t=this._monitorGeneration,e.p=1,i=null===(r=this._peerConnection)||void 0===r?void 0:r.getStatsLegacy()){e.n=2;break}return e.a(2);case 2:return o=new ct(function(e){n=P.value.setTimeout(function(){return e(null)},5e3)}),e.n=3,ct.race([i,o]);case 3:if(a=e.v,t===this._monitorGeneration&&this._isMonitorRunning){e.n=4;break}return e.a(2);case 4:a?(s={},u=this._estimatedRoundTripTime,a.result().forEach(function(e){if(e.names().forEach(function(t){"googRTT"===t&&(u=e.stat(t))}),"ssrc"===e.type){var t,n,r=e.stat("mediaType").toString();s[r]={timestamp:Date.now()},s[r].ssrc=e.stat("ssrc").toString(),s[r].mediaType=r,s[r].bytesReceived=e.stat("bytesReceived"),s[r].packetsLost=e.stat("packetsLost"),s[r].packetsReceived=e.stat("packetsReceived"),s[r].codec=e.stat("googCodecName").toString()||l.getCodecByType(r),s[r].roundTripTime=u,"video"===r&&null!==(t=l._rtcStatistic.value)&&void 0!==t&&null!==(n=t.video)&&void 0!==n&&n.framesDecoded&&(s[r].framesDecoded=e.stat("framesDecoded"),s[r].fps=(s[r].framesDecoded-l._rtcStatistic.value.video.framesDecoded)/(s[r].timestamp-l._rtcStatistic.value.video.timestamp)*1e3||0)}}),this._rtcStatistic.value=s):this._logger.debug("getStatsLegacy() timed out, skipping stats processing"),e.n=7;break;case 5:if(e.p=5,c=e.v,t===this._monitorGeneration&&this._isMonitorRunning){e.n=6;break}return e.a(2);case 6:this._logger.warn("getStatsLegacy() rejected",c);case 7:return e.p=7,P.value.clearTimeout(n),e.f(7);case 8:this._isMonitorRunning&&t===this._monitorGeneration&&(this._updateTimeout=P.value.setTimeout(function(){return l.updateStatistic()},1e3));case 9:return e.a(2)}},e,this,[[1,5,7,8]])})),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec||"unknown";case"video":return this._estimatedVideoCodec||"unknown";default:return"unknown"}}}]);var e,n}(),ft=n(847),pt=n.n(ft),vt=function(){return o()(function e(){t()(this,e)},null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Ze.Normal:return"Normal";case Ze.Force:return"Force";case Ze.Reset:return"Reset";default:Z(e)}}}])}(),mt=function(){return o()(function e(){t()(this,e)},null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Qe.Keep:return"Keep";case Qe.Reset:return"Reset";default:Z(e)}}}])}(),gt=n(981).A,yt=["status","streamId","sharedSecret","lag","rtcConfiguration","setRemoteDescriptionResponse","createAnswerDescriptionResponse","createOfferDescriptionResponse"];function _t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function bt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_t(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_t(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ct(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return kt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(kt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,kt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,kt(d,"constructor",c),kt(c,"constructor",u),u.displayName="GeneratorFunction",kt(c,i,"GeneratorFunction"),kt(d),kt(d,i,"Generator"),kt(d,r,function(){return this}),kt(d,"toString",function(){return"[object Generator]"}),(Ct=function(){return{w:o,m:h}})()}function kt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}kt=function(e,t,n,r){function o(t,n){kt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},kt(e,t,n,r)}var St=function(){return o()(function e(n,r){if(t()(this,e),s()(this,"_logger",ee.getLogger("EndPoint")),s()(this,"_uri",void 0),s()(this,"_timeout",void 0),s()(this,"_roundTripTime",0),this._uri=n,this._timeout=r,!r)throw new Error("End point requires a timeout")},[{key:"roundTripTime",get:function(){return this._roundTripTime}},{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:(m=V()(Ct().m(function e(){var t,n,r,i,o=this;return Ct().w(function(e){for(;;)switch(e.n){case 0:return t=this.buildPingUrl(),n=Date.now(),e.n=1,gt.race([P.value.fetch(t,{method:"GET",cache:"no-cache"}),new gt(function(e,n){return P.value.setTimeout(function(){return n(new Error("Ping timed out [".concat(t,"]")))},o._timeout)})]);case 1:if(r=e.v,i=Date.now(),r.ok){e.n=2;break}throw new Error("Ping failed [".concat(t,"] [").concat(r.status,"]"));case 2:return this._roundTripTime=i-n,e.a(2,this._roundTripTime)}},e,this)})),function(){return m.apply(this,arguments)})},{key:"subscribe",value:(v=V()(Ct().m(function e(t,n,r){var i,o,a,s,u,c,l,d,h,f,p,v,m,g,y,_,b,C=this,k=arguments;return Ct().w(function(e){for(;;)switch(e.p=e.n){case 0:if(a=k.length>3&&void 0!==k[3]?k[3]:{},s=re.parseToken(t).tenancy){e.n=1;break}return this._logger.error("Failed to parse token [%s]",t),e.a(2,{status:"unauthorized"});case 1:return u=this.buildUrl([s,"stream","subscribe"]).toString(),c=new P.value.FormData,l=B.sdkVersion,d=0===r&&n?{apiVersion:7,clientVersion:l,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:7,sessionDescription:{type:n.type,sdp:n.sdp}},createAnswerDescription:{apiVersion:7}}:{apiVersion:7,clientVersion:l,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:7}},e.n=2,null===(i=a.onSubscribeRequestCallback)||void 0===i?void 0:i.call(a,d);case 2:return c.append("jsonBody",JSON.stringify(d)),h=Date.now(),e.p=3,p=null,e.n=4,gt.race([P.value.fetch(u,{method:"POST",body:c}),new gt(function(e){return p=P.value.setTimeout(function(){C._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(u,"]"))),e({status:408})},C._timeout)})]).finally(function(){p&&P.value.clearTimeout(p)});case 4:f=e.v,e.n=6;break;case 5:return e.p=5,b=e.v,this._logger.error("Failed to subscribe",b),e.a(2,{status:"failed"});case 6:if("ok"===(v=this.mapHttpStatusToSubscribeStatus(f))){e.n=8;break}return g={status:v},e.n=7,null===(m=a.onSubscribeResponseCallback)||void 0===m?void 0:m.call(a,g);case 7:return e.a(2,g);case 8:return y=Date.now(),e.n=9,this.convertHttpResponseToSubscribeResponse(s,f);case 9:return _=e.v,this._logger.debug("Got subscribe response [%j] in [%s] ms",_,y-h),e.n=10,null===(o=a.onSubscribeResponseCallback)||void 0===o?void 0:o.call(a,_);case 10:return e.a(2,_)}},e,this,[[3,5]])})),function(e,t,n){return v.apply(this,arguments)})},{key:"publish",value:(p=V()(Ct().m(function e(t,n,r,i){var o,a,s,u,c,l,d,h,f,p,v,m,g,y=this;return Ct().w(function(e){for(;;)switch(e.p=e.n){case 0:if(o=re.parseToken(n).tenancy){e.n=1;break}return this._logger.error("Failed to parse token [%s]",n),e.a(2,{status:"unauthorized"});case 1:return a=this.buildUrl([o,"stream","publish"]).toString(),s=new P.value.FormData,u=B.sdkVersion,0===i&&r?(c={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:7,sessionDescription:{type:r.type,sdp:r.sdp}},createAnswerDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(c))):(l={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(l))),d=Date.now(),e.p=2,f=null,e.n=3,gt.race([P.value.fetch(a,{method:"POST",body:s}),new gt(function(e){return f=P.value.setTimeout(function(){y._logger.error("Failed to publish",new Error("Publish timed out [".concat(a,"]"))),e({status:408})},y._timeout)})]).finally(function(){f&&P.value.clearTimeout(f)});case 3:h=e.v,e.n=5;break;case 4:return e.p=4,g=e.v,this._logger.error("Failed to publish",g),e.a(2,{status:"failed"});case 5:if("ok"===(p=this.mapHttpStatusToPublishStatus(h))){e.n=6;break}return e.a(2,{status:p});case 6:return v=Date.now(),e.n=7,this.convertHttpResponseToPublishResponse(o,h);case 7:return m=e.v,this._logger.debug("Got publish response [%j] in [%s] ms",m,v-d),e.a(2,m)}},e,this,[[2,4]])})),function(e,t,n,r){return p.apply(this,arguments)})},{key:"setRemoteDescription",value:(f=V()(Ct().m(function e(t,n){var r,i,o,a,s,u,c,l,d,h,f=this;return Ct().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new P.value.FormData,o={apiVersion:7,sharedSecret:null==t?void 0:t.sharedSecret,sessionDescription:{type:n.type,sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.p=1,u=null,e.n=2,gt.race([P.value.fetch(r,{method:"POST",body:i}),new gt(function(e){return u=P.value.setTimeout(function(){f._logger.error("Failed to set remote description",new Error("Set remote description timed out [".concat(r,"]"))),e({status:408})},f._timeout)})]).finally(function(){u&&P.value.clearTimeout(u)});case 2:s=e.v,e.n=4;break;case 3:return e.p=3,h=e.v,this._logger.error("Failed to set remote description",h),e.a(2,{status:"failed"});case 4:if("ok"===(c=this.mapHttpStatusToSetRemoteDescriptionStatus(s))){e.n=5;break}return e.a(2,{status:c});case 5:return l=Date.now(),e.n=6,this.convertHttpResponseToSetRemoteDescriptionResponse(s);case 6:return d=e.v,this._logger.debug("Got set remote description response [%j] in [%s] ms",d,l-a),e.a(2,d)}},e,this,[[1,3]])})),function(e,t){return f.apply(this,arguments)})},{key:"limitBitrate",value:(h=V()(Ct().m(function e(t,n,r,i,o){var a,s,u,c,l,d,h,f,p,v=this;return Ct().w(function(e){for(;;)switch(e.p=e.n){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new P.value.FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:mt.convertBitrateStateToBitrateStateType(i),bitrateMode:vt.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.p=1,d=null,e.n=2,gt.race([P.value.fetch(a,{method:"POST",body:s}),new gt(function(e){return d=P.value.setTimeout(function(){v._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(a,"]"))),e({status:408})},v._timeout)})]).finally(function(){d&&P.value.clearTimeout(d)});case 2:l=e.v,e.n=4;break;case 3:return e.p=3,p=e.v,this._logger.error("Failed to set limit bitrate timed",p),e.a(2,{status:"failed"});case 4:return h=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),f=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",h,f-c),e.a(2,{status:h})}},e,this,[[1,3]])})),function(e,t,n,r,i){return h.apply(this,arguments)})},{key:"addIceCandidates",value:(d=V()(Ct().m(function e(t,n,r){var i,o,a,s,u,c,l,d,h,f,p,v=this,m=arguments;return Ct().w(function(e){for(;;)switch(e.p=e.n){case 0:return i=m.length>3&&void 0!==m[3]?m[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),a=new P.value.FormData,s={apiVersion:7,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},a.append("jsonBody",JSON.stringify(s)),u=Date.now(),e.p=1,l=null,e.n=2,gt.race([P.value.fetch(o,{method:"POST",body:a}),new gt(function(e){return l=P.value.setTimeout(function(){v._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(o,"]"))),e({status:408})},v._timeout)})]).finally(function(){l&&P.value.clearTimeout(l)});case 2:c=e.v,e.n=4;break;case 3:return e.p=3,p=e.v,this._logger.error("Failed to add ice candidates",p),e.a(2,{status:"failed"});case 4:if("ok"===(d=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.n=5;break}return e.a(2,{status:d});case 5:return h=Date.now(),e.n=6,this.convertHttpResponseToAddIceCandidatesResponse(c);case 6:return f=e.v,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",f,h-u),e.a(2,f)}},e,this,[[1,3]])})),function(e,t,n){return d.apply(this,arguments)})},{key:"destroyStream",value:(l=V()(Ct().m(function e(t,n){var r,i,o,a,s,u,c,l,d,h,f=this;return Ct().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new P.value.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.p=1,u=null,e.n=2,gt.race([P.value.fetch(r,{method:"POST",body:i,cache:"no-cache"}),new gt(function(e){return u=P.value.setTimeout(function(){f._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})},f._timeout)})]).finally(function(){u&&P.value.clearTimeout(u)});case 2:s=e.v,e.n=4;break;case 3:return e.p=3,h=e.v,this._logger.error("Failed to delete stream",h),e.a(2,{status:"failed"});case 4:if("ok"===(c=this.mapHttpStatusToSetDestroyStreamStatus(s))){e.n=5;break}return e.a(2,{status:c});case 5:return l=Date.now(),e.n=6,this.convertHttpResponseToDestroyStreamResponse(s);case 6:return d=e.v,this._logger.info("Got destroy stream response [%j] in [%s] ms",d,l-a),e.a(2,d)}},e,this,[[1,3]])})),function(e,t){return l.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(u=V()(Ct().m(function e(t,n){var r,i,o,a;return Ct().w(function(e){for(;;)switch(e.n){case 0:null!==(r=navigator)&&void 0!==r&&r.sendBeacon||this.destroyStream(t,n),i=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),o=new P.value.FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},o.append("jsonBody",JSON.stringify(a)),navigator.sendBeacon(i,o);case 1:return e.a(2)}},e,this)})),function(e,t){return u.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new P.value.URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,c()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new P.value.URL(this._uri),t=B.sdkVersion,n=ke.discoveryParameters.intentions;return e.searchParams.set("type","http"),e.searchParams.set("version",t),e.searchParams.set("intentions",n),e.searchParams.set("_","".concat(Date.now())),e.toString()}},{key:"mapHttpStatusToPublishStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 406:return"missing-channel-or-room-id";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSubscribeStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetRemoteDescriptionStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetTemporaryMaximalBitrateStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToAddIceCandidatesStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetDestroyStreamStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"convertHttpResponseToSubscribeResponse",value:(a=V()(Ct().m(function e(t,n){var r,i,o,a,s,u,c,l,d,h,f;return Ct().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,n.json();case 1:return r=e.v,i=r.status,o=r.streamId,a=r.sharedSecret,s=r.lag,u=r.rtcConfiguration,c=r.setRemoteDescriptionResponse,l=r.createAnswerDescriptionResponse,d=r.createOfferDescriptionResponse,h=pt()(r,yt),f=bt({status:i,stream:{tenancy:t,streamId:o,sharedSecret:a},lag:s},h),u&&(f.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(u)),null!=c&&c.sessionDescription&&(f.setRemoteDescriptionResponse={sessionDescription:c.sessionDescription}),null!=l&&l.sessionDescription&&(f.createAnswerDescriptionResponse={sessionDescription:l.sessionDescription}),null!=d&&d.sessionDescription&&(f.createOfferDescriptionResponse={sessionDescription:d.sessionDescription}),e.a(2,f)}},e,this)})),function(e,t){return a.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(i=V()(Ct().m(function e(t,n){var r,i;return Ct().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,n.json();case 1:return r=e.v,i={status:r.status,stream:{tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret}},r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.a(2,i)}},e,this)})),function(e,t){return i.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={iceServers:[]};if(e.bundlePolicy&&(t.bundlePolicy=e.bundlePolicy),"number"==typeof e.iceCandidatePoolSize&&(t.iceCandidatePoolSize=e.iceCandidatePoolSize),e.iceServers){for(var n=[],r=0;r<e.iceServers.length;r++)n.push({urls:e.iceServers[r].urls,username:e.iceServers[r].username,credential:e.iceServers[r].credential});t.iceServers=n}return e.iceTransportPolicy&&(t.iceTransportPolicy=e.iceTransportPolicy),e.rtcpMuxPolicy&&(t.rtcpMuxPolicy=e.rtcpMuxPolicy),t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(r=V()(Ct().m(function e(t){var n,r;return Ct().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.json();case 1:return n=e.v,r={status:n.status},n&&n.sessionDescription&&(r.sessionDescription=n.sessionDescription),e.a(2,r)}},e)})),function(e){return r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(n=V()(Ct().m(function e(t){var n,r;return Ct().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.json();case 1:return n=e.v,r={status:n.status,options:[]},n&&n.options&&(r.options=n.options),e.a(2,r)}},e)})),function(e){return n.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(e=V()(Ct().m(function e(t){var n,r;return Ct().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t.json();case 1:return n=e.v,r={status:n.status},e.a(2,r)}},e)})),function(t){return e.apply(this,arguments)})}]);var e,n,r,i,a,u,l,d,h,f,p,v,m}(),wt=n(981).A;function Tt(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return xt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(xt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,xt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,xt(d,"constructor",c),xt(c,"constructor",u),u.displayName="GeneratorFunction",xt(c,i,"GeneratorFunction"),xt(d),xt(d,i,"Generator"),xt(d,r,function(){return this}),xt(d,"toString",function(){return"[object Generator]"}),(Tt=function(){return{w:o,m:h}})()}function xt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}xt=function(e,t,n,r){function o(t,n){xt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},xt(e,t,n,r)}var Pt=function(){return o()(function e(n){if(t()(this,e),s()(this,"_logger",ee.getLogger("Discovery")),s()(this,"_metricsService",void 0),s()(this,"_uri",void 0),!n)throw new Error("Discovery requires uri");this._metricsService=je.getMetricsService(n.toString()),this._uri=n},[{key:"discoverNearbyEndPoints",value:(n=V()(Tt().m(function e(t,n){var r,i,o,a;return Tt().w(function(e){for(;;)switch(e.n){case 0:if(n){e.n=1;break}throw new Error("Discovery requires timeout");case 1:return r=t.toString(),e.n=2,wt.race([P.value.fetch(r,{method:"GET",cache:"no-cache"}),new wt(function(e,t){return P.value.setTimeout(function(){return t(new Error("Discovery timed out [".concat(r,"]")))},n)})]);case 2:if((i=e.v).ok){e.n=3;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 3:if(null!==i.body){e.n=4;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 4:return e.n=5,i.text();case 5:return o=e.v,a=o.split(","),e.a(2,a.map(function(e){return new St(e,n)}))}},e)})),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=V()(Tt().m(function e(){var t,n,r,i,o,a,s=this,u=arguments;return Tt().w(function(e){for(;;)switch(e.n){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=Se.buildDiscoveryUrl(this._uri),e.n=1,this.discoverNearbyEndPoints(new P.value.URL(n),t);case 1:return r=e.v,i=0,o=function(){return new wt(function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))})},e.n=2,wt.race(r.map(function(e){return e.ping().catch(function(t){return s._logger.warn("Failed to ping end point [%s]",e,t),i++,o()}).then(function(t){var n=Date.now();return s._logger.info("Discovered end point [%s] with time [%s]",e.toString(),t),s._metricsService.push({metricType:Ee.RoundTripTime,runtime:(n-Ve.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e})}));case 2:return a=e.v,e.a(2,a)}},e,this)})),function(){return e.apply(this,arguments)})}]);var e,n}(),Et=n(981).A;function Ot(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return Rt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Rt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Rt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,Rt(d,"constructor",c),Rt(c,"constructor",u),u.displayName="GeneratorFunction",Rt(c,i,"GeneratorFunction"),Rt(d),Rt(d,i,"Generator"),Rt(d,r,function(){return this}),Rt(d,"toString",function(){return"[object Generator]"}),(Ot=function(){return{w:o,m:h}})()}function Rt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Rt=function(e,t,n,r){function o(t,n){Rt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},Rt(e,t,n,r)}var Ft=function(){function e(){throw t()(this,e),new Error("Discovery is a static class that may not be instantiated")}return o()(e,null,[{key:"precacheClosestEndPointDiscovery",value:(r=V()(Ot().m(function t(){return Ot().w(function(t){for(;;)if(0===t.n)return t.a(2,new Et(function(t){var n=P.subscribe(function(r){if(r){var i=new r.URL(Ve.discoveryUri.value);return e.discoverClosestEndPointWithCaching(i).then(t).then(function(){return n.dispose()})}})}))},t)})),function(){return r.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(n=V()(Ot().m(function t(n){var r,i,o;return Ot().w(function(t){for(;;)switch(t.n){case 0:if(!((r=n.toString())in e._cache)){t.n=1;break}return t.a(2,e._cache[r]);case 1:return i=new Pt(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then(function(){P.value.setTimeout(function(){e._cache[r]===o&&delete e._cache[r]},6e4)}).catch(function(){delete e._cache[r]}),t.a(2,o)}},t)})),function(e){return n.apply(this,arguments)})},{key:"clearCachedClosestEndpoint",value:function(t){var n=t.toString();n in e._cache&&delete e._cache[n]}}]);var n,r}();s()(Ft,"_cache",{}),Ft.precacheClosestEndPointDiscovery();var It=function(e){return e[e.H264=0]="H264",e[e.VP8=1]="VP8",e[e.VP9=2]="VP9",e}({}),Lt=function(e){return e[e.Error=-1]="Error",e[e.AddTransform=0]="AddTransform",e[e.ConfigurePipeline=1]="ConfigurePipeline",e[e.Metadata=2]="Metadata",e[e.Chunk=3]="Chunk",e[e.PipelineConfigured=4]="PipelineConfigured",e}({}),Dt=function(e){return e[e.FrameTimingInformation=0]="FrameTimingInformation",e[e.EncodedVideoChunk=1]="EncodedVideoChunk",e[e.EncodedAudioChunk=2]="EncodedAudioChunk",e[e.SurrogateVideoChunk=3]="SurrogateVideoChunk",e[e.SurrogateAudioChunk=4]="SurrogateAudioChunk",e}({});function At(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function jt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?At(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):At(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Mt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var Vt=function(){function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("FrameTimingInformationManager")),s()(this,"_decodedFrameTimingInformationByRtpTimestamp",new Map),s()(this,"_videoElementDisposables",new ie),s()(this,"_disposables",new ie),s()(this,"_currentPlaybackState","waiting"),s()(this,"_armedVideoFrameCallbackId",null),s()(this,"_disposed",!1),this.initialize(n)}return o()(e,[{key:"dispose",value:function(){this._disposed=!0,this._disposables.dispose()}},{key:"initialize",value:function(e){this.canProcessFrameTimingInformation(e.streamId,e.codec,e.receiver,e.mid)&&(this.setupVideoElementHandling(e.videoElement,e.renderedFrameTimingInformationSubject),this.setupFrameTimingInformationTransform(e.codec,e.mid,e.trackId,e.transformMessageRouter,e.transformFunctionNames,e.decodedFrameTimingInformationSubject),e.isEnabledSubject.value=!0)}},{key:"canProcessFrameTimingInformation",value:function(e,t,n,r){return t!==It.H264?(this._logger.warn("[%s] Skipping frame timing information for video track because video codec is not H264",e),!1):n?!!r||(this._logger.warn("[%s] Skipping frame timing information for video track because no mid was found",e),!1):(this._logger.warn("[%s] Skipping frame timing information for video track because no receiver was found",e),!1)}},{key:"setupFrameTimingInformationTransform",value:function(t,n,r,i,o,a){i.registerRoute(Dt.FrameTimingInformation,this.handleFrameTimingMessage.bind(this,It[t],n,r,a)),o.push(e._transformName)}},{key:"handleFrameTimingMessage",value:function(e,t,n,r,i){if(i)for(var o=0,a=Object.entries(i);o<a.length;o++){var s=at()(a[o],2),u=s[0],c=s[1],l=parseInt(u,10),d=c.decodedFrameTimingInformation;if(d){var h,f,p={timecode:null!==(h=d.timecode)&&void 0!==h?h:null,receiveTimestamp:null!==(f=d.receiveTimestamp)&&void 0!==f?f:null,kind:"video",codec:e,mid:t,trackId:n,sourceTimestamp:null,ingestTimestamp:null,encodeTimestamp:null,transcodeTimestamp:null,playbackState:this._currentPlaybackState};r.value=p,"playing"===this._currentPlaybackState&&this._decodedFrameTimingInformationByRtpTimestamp.set(l,p)}}}},{key:"setupVideoElementHandling",value:function(e,t){var n=this;this._disposables.add(new m(function(){return n._decodedFrameTimingInformationByRtpTimestamp.clear()})),this._disposables.add(this._videoElementDisposables),this._disposables.add(e.subscribe(function(e){n._videoElementDisposables.dispose(),e&&n.setupVideoEventListeners(e,t)}))}},{key:"handleVideoFrameCallback",value:function(e,t,n,r){if(!this._disposed){this._armVideoFrameCallback(e,t);var i=r.rtpTimestamp;if(i){var o,a=[],s=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Mt(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Mt(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(this._decodedFrameTimingInformationByRtpTimestamp);try{for(s.s();!(o=s.n()).done;){var u=at()(o.value,2),c=u[0],l=u[1];if(c>i)break;t.value=jt(jt({},l),{},{renderTimestamp:new Date(performance.timeOrigin+n),playbackState:"playing"}),a.push(c)}}catch(e){s.e(e)}finally{s.f()}for(var d=0,h=a;d<h.length;d++){var f=h[d];this._decodedFrameTimingInformationByRtpTimestamp.delete(f)}}}}},{key:"setupVideoEventListeners",value:function(e,t){var n=this,r=function(){return n._currentPlaybackState="playing"};e.addEventListener("playing",r),this._videoElementDisposables.add(new m(function(){return e.removeEventListener("playing",r)}));var i=function(){return n._currentPlaybackState="paused"};e.addEventListener("pause",i),this._videoElementDisposables.add(new m(function(){return e.removeEventListener("pause",i)}));var o=function(){return n._currentPlaybackState="stalled"};e.addEventListener("stalled",o),this._videoElementDisposables.add(new m(function(){return e.removeEventListener("stalled",o)}));var a=function(){return n._currentPlaybackState="waiting"};e.addEventListener("waiting",a),this._videoElementDisposables.add(new m(function(){return e.removeEventListener("waiting",a)}));var s=function(){return n._currentPlaybackState="ended"};e.addEventListener("ended",s),this._videoElementDisposables.add(new m(function(){return e.removeEventListener("ended",s)}));var u=function(){return n._currentPlaybackState="error"};e.addEventListener("error",u),this._videoElementDisposables.add(new m(function(){return e.removeEventListener("error",u)})),this._armVideoFrameCallback(e,t),this._videoElementDisposables.add(new m(function(){n._armedVideoFrameCallbackId&&e.cancelVideoFrameCallback(n._armedVideoFrameCallbackId)}))}},{key:"_armVideoFrameCallback",value:function(e,t){e.requestVideoFrameCallback&&(this._armedVideoFrameCallbackId=e.requestVideoFrameCallback(this.handleVideoFrameCallback.bind(this,e,t)))}}])}();s()(Vt,"_transformName","frame-timing-information");var Gt=n(512),Bt=n.n(Gt);function Ut(){return Bt()('/*! For license information please see TransformStreamPipeline.worker.worker.js.LICENSE.txt */\n(()=>{var e={981:(e,t,r)=>{"use strict";r.d(t,{A:()=>p});var n=r(738),o=r.n(n),a=r(383),i=r.n(a),u=r(579),s=r.n(u),c=r(693),f=r.n(c),l=s()(function e(t,r,n){i()(this,e),f()(this,"onFulfilled",void 0),f()(this,"onRejected",void 0),f()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof r?r:null,this.promise=n}),d=function(){function e(t){if(i()(this,e),f()(this,"_state",void 0),f()(this,"_handled",void 0),f()(this,"_value",void 0),f()(this,"_deferreds",void 0),!(this instanceof e))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=null,this._deferreds=[],this.doResolve(t)}return s()(e,[{key:"doResolve",value:function(e){var t=this,r=!1;try{e(function(e){r||(r=!0,t.promiseResolve(e))},function(e){r||(r=!0,t.promiseReject(e))})}catch(e){if(r)return;r=!0,this.promiseReject(e)}}},{key:"promiseResolve",value:function(t){var r=this;try{if(t===r)throw new TypeError("A Promise cannot be resolved with it self.");if(t&&("object"===o()(t)||"function"==typeof t)){var n=t.then;if(t instanceof e)return r._state=3,r._value=t,void r.finale();if("function"==typeof n)return void r.doResolve(function(){n.apply(t,arguments)})}r._state=1,r._value=t,r.finale()}catch(e){r.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate(function(){t._handled||e._unhandledRejection(t._value)});for(var r=0,n=this._deferreds.length;r<n;r++)this.handle(this._deferreds[r]);this._deferreds=[]}},{key:"handle",value:function(t){for(var r=this;3===r._state;)r=r._value;0!==r._state?(r._handled=!0,e._immediate(function(){var e=1===r._state?t.onFulfilled:t.onRejected;if(null!==e){var n;try{n=e(r._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(n)}else 1===r._state?t.promise.promiseResolve(r._value):t.promise.promiseReject(r._value)})):r._deferreds.push(t)}}],[{key:"all",value:function(t){return new e(function(e,r){if(!Array.isArray(t))return r(new TypeError("Promise.all accepts an array"));var n=Array.prototype.slice.call(t);if(0===n.length)return e([]);for(var a=n.length,i=function(t,u){try{if(u&&("object"===o()(u)||"function"==typeof u)){var s=u.then;if("function"==typeof s)return void s.call(u,function(e){return i(t,e)},r)}n[t]=u,0===--a&&e(n)}catch(e){r(e)}},u=0;u<n.length;u++)i(u,n[u])})}},{key:"resolve",value:function(t){return t&&"object"===o()(t)&&t.constructor===e?t:new e(function(e){return e(t)})}},{key:"reject",value:function(t){return new e(function(e,r){return r(t)})}},{key:"race",value:function(t){return new e(function(r,n){if(!Array.isArray(t))return n(new TypeError("Promise.race accepts an array"));for(var o=0,a=t.length;o<a;o++)e.resolve(t[o]).then(r,n)})}},{key:"_immediate",value:function(e){window.setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}])}();d.prototype.catch=function(e){return this.then(null,e)},d.prototype.then=function(e,t){var r=new d(function(){return null});return this.handle(new l(e,t,r)),r},d.prototype.finally=function(e){return this.then(function(t){return d.resolve(e()).then(function(){return t},function(){return null})},function(t){return d.resolve(e()).then(function(){return d.reject(t)},function(){return null})})};var p=d},293:(e,t,r)=>{var n=r(981).A;function o(e,t,r,o,a,i,u){try{var s=e[i](u),c=s.value}catch(e){return void r(e)}s.done?t(c):n.resolve(c).then(o,a)}e.exports=function(e){return function(){var t=this,r=arguments;return new n(function(n,a){var i=e.apply(t,r);function u(e){o(i,n,a,u,s,"next",e)}function s(e){o(i,n,a,u,s,"throw",e)}u(void 0)})}},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,r)=>{var n=r(736);function o(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,n(o.key),o)}}e.exports=function(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,t,r)=>{var n=r(736);e.exports=function(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,t,r)=>{var n=r(738).default;e.exports=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,t,r)=>{var n=r(738).default,o=r(45);e.exports=function(e){var t=o(e,"string");return"symbol"==n(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=r(293),t=r.n(e),n=r(383),o=r.n(n),a=r(579),i=r.n(a),u=r(693),s=r.n(u),c=function(e){return e[e.Error=-1]="Error",e[e.AddTransform=0]="AddTransform",e[e.ConfigurePipeline=1]="ConfigurePipeline",e[e.Metadata=2]="Metadata",e[e.Chunk=3]="Chunk",e[e.PipelineConfigured=4]="PipelineConfigured",e}({}),f=function(e){return e[e.FrameTimingInformation=0]="FrameTimingInformation",e[e.EncodedVideoChunk=1]="EncodedVideoChunk",e[e.EncodedAudioChunk=2]="EncodedAudioChunk",e[e.SurrogateVideoChunk=3]="SurrogateVideoChunk",e[e.SurrogateAudioChunk=4]="SurrogateAudioChunk",e}({});function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function d(e,t){for(var r=e.length,n=t;n<r-3;n++)if(0===e[n]&&0===e[n+1]){if(1===e[n+2])return n;if(n+3<r&&0===e[n+2]&&1===e[n+3])return n}return-1}function p(e,t){for(var r=t,n=0;255===e[r];)n++,r++;var o=255*n+e[r++];for(n=0;255===e[r];)n++,r++;var a=255*n+e[r++];return{type:o,payload:e.subarray(r,r+a),length:r+a-t}}function m(e){if(e.getRemainingBits()<10)return null;var t={ctType:e.readBits(2),nuitFieldBasedFlag:1===e.readBits(1),countingType:e.readBits(5),fullTimestampFlag:1===e.readBits(1),discontinuityFlag:1===e.readBits(1),cntDroppedFlag:1===e.readBits(1),nFrames:e.readBits(8)};if(t.fullTimestampFlag){if(e.getRemainingBits()<17)return null;t.seconds=e.readBits(6),t.minutes=e.readBits(6),t.hours=e.readBits(5)}else if(!function(e,t){return e.getRemainingBits()<1||0===e.readBits(1)||!(e.getRemainingBits()<6)&&(t.seconds=e.readBits(6),e.getRemainingBits()<1||0===e.readBits(1)||!(e.getRemainingBits()<6)&&(t.minutes=e.readBits(6),e.getRemainingBits()<1||0===e.readBits(1)||!(e.getRemainingBits()<5)&&(t.hours=e.readBits(5),!0)))}(e,t))return null;return e.getRemainingBits()<24?null:(t.timeOffset=e.readBits(24),t)}function h(e,t){var r,n,o=(r=function(e){var t,r=[],n=0,o=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return l(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(u)throw a}}}}(e);try{for(o.s();!(t=o.n()).done;){var a=t.value;2===n&&3===a?n=0:(0===a?n++:n=0,r.push(a))}}catch(e){o.e(e)}finally{o.f()}return new Uint8Array(r)}(e),n=0,{readBits:function(e){if(n+e>8*r.length)throw new Error("Cannot read [".concat(e,"] bits - out of bounds"));for(var t=0,o=e;o>0;){var a=Math.floor(n/8),i=8-n%8,u=Math.min(o,i),s=(1<<u)-1;t=t<<u|r[a]>>i-u&s,n+=u,o-=u}return t},skipBits:function(e){if(n+e>8*r.length)throw new Error("Cannot skip [".concat(e,"] bits - out of bounds"));n+=e},getRemainingBits:function(){return 8*r.length-n}}),a={picStruct:void 0};if(t.cpbDpbDelaysPresentFlag&&void 0!==t.cpbRemovalDelayLengthMinus1&&void 0!==t.dpbOutputDelayLengthMinus1&&(o.skipBits(t.cpbRemovalDelayLengthMinus1+1),o.skipBits(t.dpbOutputDelayLengthMinus1+1)),t.picStructPresentFlag){for(var i=function(e){switch(e){case 0:case 1:case 2:return 1;case 3:case 4:case 7:return 2;case 5:case 6:case 8:return 3;default:return 0}}(o.readBits(4)),u=[],s=0;s<i&&!(o.getRemainingBits()<1);s++)if(1===o.readBits(1)){var c=m(o);if(!c)break;u.push({clockTimestampFlag:!0,clockTimestamp:c})}else u.push({clockTimestampFlag:!1});a.picStruct={numClockTS:i,clockTimestamps:u}}return a}var v,y=function(){return i()(function e(){o()(this,e)},null,[{key:"createFrameTimingInformationTransform",value:function(){return new TransformStream({transform:function(e,t){(function(e){for(var t=new Date,r=new Uint8Array(e.data),n=d(r,0);-1!==n;){var o=d(r,n+1),a=-1===o?r.length:o,i=n+(1===r[n+2]?3:4);if(6==(31&r[i]))for(var u=i+1,l=r.subarray(u,a),m=0;m<l.length&&!(m+2>l.length);){var v=p(l,m);if(1===v.type){var y,g=null===(y=h(v.payload,{cpbDpbDelaysPresentFlag:!1,picStructPresentFlag:!0}).picStruct)||void 0===y?void 0:y.clockTimestamps[0];if(null!=g&&g.clockTimestampFlag){var b,k,w,_,T=e.timestamp,x={timecode:g.clockTimestamp?{hours:null!==(b=g.clockTimestamp.hours)&&void 0!==b?b:null,minutes:null!==(k=g.clockTimestamp.minutes)&&void 0!==k?k:null,seconds:null!==(w=g.clockTimestamp.seconds)&&void 0!==w?w:null,frames:null!==(_=g.clockTimestamp.nFrames)&&void 0!==_?_:null,isFrameDrop:g.clockTimestamp.cntDroppedFlag}:null,receiveTimestamp:t};self.postMessage({type:c.Metadata,data:{type:f.FrameTimingInformation,data:s()({},T,{decodedFrameTimingInformation:x})}})}}if(m+=v.length,0===v.length)break}n=o}})(e),t.enqueue(e)}})}},{key:"createEncodedVideoStreamTransform",value:function(e){var t=new Map,r=function(e,t,r){var n=r.data;if(n.type===c.Chunk&&n.data.type===f.SurrogateVideoChunk){var o=n.data.data,a=o.surrogate,i=o.timestamp,u=e.get(i);u?(u.data=a,t.enqueue(u),e.delete(i)):console.warn("[WorkerTransforms] Surrogate video chunk not found for timestamp",i)}};return new TransformStream({start:function(n){e.addEventListener("message",r.bind(null,t,n),{once:!1})},transform:function(e){t.set(e.timestamp,e),self.postMessage({type:c.Metadata,data:{type:f.EncodedVideoChunk,data:{timestamp:e.timestamp,data:new Uint8Array(e.data),type:e.type}}},{transfer:[e.data]})}})}},{key:"createEncodedAudioStreamTransform",value:function(e){var t=new Map,r=function(e,t,r){var n=r.data;if(n.type===c.Chunk&&n.data.type===f.SurrogateAudioChunk){var o=n.data.data,a=o.surrogate,i=o.timestamp,u=e.get(i);u?(u.data=a,t.enqueue(u),e.delete(i)):console.warn("[WorkerTransforms] Surrogate audio chunk not found for timestamp",i)}};return new TransformStream({start:function(n){e.addEventListener("message",r.bind(null,t,n),{once:!1})},transform:function(e){t.set(e.timestamp,e),self.postMessage({type:c.Metadata,data:{type:f.EncodedAudioChunk,data:{timestamp:e.timestamp,data:new Uint8Array(e.data),type:e.type}}},{transfer:[e.data]})}})}},{key:"createPassThroughTransform",value:function(){return new TransformStream({transform:function(e,t){return t.enqueue(e)}})}}])}();function g(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function a(r,n,o,a){var s=n&&n.prototype instanceof u?n:u,c=Object.create(s.prototype);return b(c,"_invoke",function(r,n,o){var a,u,s,c=0,f=o||[],l=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,r){return a=t,u=0,s=e,d.n=r,i}};function p(r,n){for(u=r,s=n,t=0;!l&&c&&!o&&t<f.length;t++){var o,a=f[t],p=d.p,m=a[2];r>3?(o=m===n)&&(s=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=e):a[0]<=p&&((o=r<2&&p<a[1])?(u=0,d.v=n,d.n=a[1]):p<m&&(o=r<3||a[0]>n||n>m)&&(a[4]=r,a[5]=n,d.n=m,u=0))}if(o||r>1)return i;throw l=!0,n}return function(o,f,m){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&p(f,m),u=f,s=m;(t=u<2?e:s)||!l;){a||(u?u<3?(u>1&&(d.n=-1),p(u,s)):d.n=s:d.v=s);try{if(c=2,a){if(u||(o="next"),t=a[o]){if(!(t=t.call(a,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,u<2&&(u=0)}else 1===u&&(t=a.return)&&t.call(a),u<2&&(s=TypeError("The iterator does not provide a \'"+o+"\' method"),u=1);a=e}else if((t=(l=d.n<0)?s:r.call(n,d))!==i)break}catch(t){a=e,u=1,s=t}finally{c=1}}return{value:t,done:l}}}(r,o,a),!0),c}var i={};function u(){}function s(){}function c(){}t=Object.getPrototypeOf;var f=[][n]?t(t([][n]())):(b(t={},n,function(){return this}),t),l=c.prototype=u.prototype=Object.create(f);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,b(e,o,"GeneratorFunction")),e.prototype=Object.create(l),e}return s.prototype=c,b(l,"constructor",c),b(c,"constructor",s),s.displayName="GeneratorFunction",b(c,o,"GeneratorFunction"),b(l),b(l,o,"Generator"),b(l,n,function(){return this}),b(l,"toString",function(){return"[object Generator]"}),(g=function(){return{w:a,m:d}})()}function b(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}b=function(e,t,r,n){function a(t,r){b(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(a("next",0),a("throw",1),a("return",2))},b(e,t,r,n)}var k=self,w=function(){function e(){o()(this,e)}return i()(e,null,[{key:"handleAddTransform",value:function(t){if(e._isPipelineConfigured)throw new Error("Error: Pipeline is locked. A transform cannot be added once the pipeline has been configured");switch(t){case"frame-timing-information":e._transforms.push(y.createFrameTimingInformationTransform());break;case"protected-video":e._transforms.push(y.createEncodedVideoStreamTransform(k));break;case"protected-audio":e._transforms.push(y.createEncodedAudioStreamTransform(k));break;case"pass-through":e._transforms.push(y.createPassThroughTransform());break;default:throw new Error("Error: Unknown transform type [".concat(t,"]"))}}},{key:"configurePipeline",value:(r=t()(g().m(function t(r,n){return g().w(function(t){for(;;)switch(t.n){case 0:if(r&&n){t.n=1;break}throw new Error("Error: Configuration of TransformStreamPipeline requires both a readbale source and writable sink");case 1:return 0===e._transforms.length&&e._transforms.push(),t.n=2,e._transforms.reduceRight(function(e,t){return e.pipeThrough(t)},r).pipeTo(n);case 2:e._isPipelineConfigured=!0,k.postMessage({type:c.PipelineConfigured,data:{name:e._workerName}});case 3:return t.a(2)}},t)})),function(e,t){return r.apply(this,arguments)})},{key:"handleMessage",value:function(t){var r=t.data,n=r.type;switch(n){case c.AddTransform:e.handleAddTransform(r.data);break;case c.ConfigurePipeline:e.configurePipeline(r.data.source,r.data.sink);break;case c.Metadata:case c.Chunk:break;default:!function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))}(n)}}}]);var r}();v=w,s()(w,"_transforms",[]),s()(w,"_isPipelineConfigured",!1),s()(w,"_workerName",void 0),k.onerror=function(e){return console.error("[TransformStreamPipelineWorker] Error: [%s]",e)},k.onmessage=v.handleMessage.bind(v),k.RTCTransformEvent&&(k.onrtctransform=function(e){var t=e.transformer;v._workerName=t.options.name;var r=t.readable,n=t.writable;v.configurePipeline(r,n)})})()})();\n',"Worker",void 0,void 0)}var Nt=function(){return o()(function e(n){t()(this,e),s()(this,"_messageRoutes",new Map),this.initialize(n)},[{key:"registerRoute",value:function(e,t){var n=this;return this._messageRoutes.set(e,t),new m(function(){return n._messageRoutes.delete(e)})}},{key:"dispose",value:function(){this._messageRoutes.clear()}},{key:"initialize",value:function(e){var t=this;e.addEventListener("message",function(e){var n,r,i,o,a=e.data;switch(a.type){case Lt.Chunk:case Lt.Metadata:r=(n=a.data).type,i=n.data,(o=t._messageRoutes.get(r))&&o(i)}},{once:!1})}}])}(),zt=n(981).A;function Ht(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return qt(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(qt(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,qt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,qt(d,"constructor",c),qt(c,"constructor",u),u.displayName="GeneratorFunction",qt(c,i,"GeneratorFunction"),qt(d),qt(d,i,"Generator"),qt(d,r,function(){return this}),qt(d,"toString",function(){return"[object Generator]"}),(Ht=function(){return{w:o,m:h}})()}function qt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}qt=function(e,t,n,r){function o(t,n){qt(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},qt(e,t,n,r)}function Wt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Jt(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Jt(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Jt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var Kt=function(){return o()(function e(){throw t()(this,e),new Error("InsertableStreams is a static class that may not be instantiated")},null,[{key:"createEncodedStreamPipeline",value:function(e){var t=new ie,n=e.videoTrack,r=e.audioTrack,i=function(e){var n=e.transformPipelineWorker=new Ut;t.add(new m(function(){return n.terminate()})),t.add(e.transformMessageRouter=new Nt(n))},o=n.receiver,a=n.mediaStreamTrack;o&&a&&i(n);var s=r.receiver,u=r.mediaStreamTrack;return s&&u&&i(r),t}},{key:"configureEncodedStreamPipeline",value:(e=V()(Ht().m(function e(t){var n,r,i,o,a;return Ht().w(function(e){for(;;)switch(e.n){case 0:if(n=t.videoTrack,r=t.audioTrack,(i=function(e){if(e.transformPipelineWorker)if(e.transformFunctionNames.length){var t,n=Wt(e.transformFunctionNames);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.transformPipelineWorker.postMessage({type:Lt.AddTransform,data:r})}}catch(e){n.e(e)}finally{n.f()}}else e.transformPipelineWorker.postMessage({type:Lt.AddTransform,data:"pass-through"})})(n),i(r),o=function(){var e=V()(Ht().m(function e(t){var n,r,i;return Ht().w(function(e){for(;;)switch(e.n){case 0:return n=function(){var e=V()(Ht().m(function e(t){var n,r,i;return Ht().w(function(e){for(;;)switch(e.n){case 0:if(n=t.receiver,r=t.mediaStreamTrack,i=t.transformPipelineWorker,!(n&&r&&i)){e.n=1;break}return n.transform=new RTCRtpScriptTransform(i,{name:"".concat(r.kind,"-transform-pipeline")}),e.a(2,new zt(function(e){i.addEventListener("message",function(t){t.data.type===Lt.PipelineConfigured&&e()},{once:!0})}));case 1:return e.a(2,zt.resolve())}},e)}));return function(t){return e.apply(this,arguments)}}(),r=t.videoTrack,i=t.audioTrack,e.n=1,zt.all([n(r),n(i)]);case 1:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}(),a=function(){var e=V()(Ht().m(function e(t){var n,r,i,o;return Ht().w(function(e){for(;;)switch(e.n){case 0:return n=function(e){var t=e.receiver,n=e.mediaStreamTrack,r=e.transformPipelineWorker;if(t&&n&&r){var i=t.createEncodedStreams();return new zt(function(e){r.addEventListener("message",function(t){t.data.type===Lt.PipelineConfigured&&e()},{once:!0}),r.postMessage({type:Lt.ConfigurePipeline,data:{source:i.readable,sink:i.writable}},{transfer:[i.readable,i.writable]})})}return zt.resolve()},r=t.videoTrack,i=t.audioTrack,o=[],r.receiver&&r.transformPipelineWorker&&o.push(n(r)),i.receiver&&i.transformPipelineWorker&&o.push(n(i)),e.n=1,zt.all(o);case 1:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}(),!O.isRTCRtpScriptTransformSupported){e.n=2;break}return e.n=1,o(t);case 1:case 3:return e.a(2);case 2:return e.n=3,a(t)}},e)})),function(t){return e.apply(this,arguments)})},{key:"configureInsertableStreamTransformation",value:function(e,t,n){var r=new MediaStream,i=new ie;return e.getTracks().forEach(function(e){var o=e.kind;switch(o){case"video":if(t){var a=e,s=new TransformStream({transform:function(n,r){t(e,n,r)}}),u=new MediaStreamTrackProcessor({track:a}),c=new MediaStreamTrackGenerator({kind:a.kind}),l=u.readable,d=c.writable;l.pipeThrough(s).pipeTo(d),r.addTrack(c),i.add(new m(function(){r.removeTrack(c)}))}else r.addTrack(e);break;case"audio":if(n){var h=e,f=new TransformStream({transform:function(t,r){n(e,t,r)}}),p=new MediaStreamTrackProcessor({track:h}),v=new MediaStreamTrackGenerator({kind:h.kind}),g=p.readable,y=v.writable;g.pipeThrough(f).pipeTo(y),r.addTrack(v);var _=new MediaStream,b=new Audio;_.addTrack(e),b.srcObject=_,document.body.appendChild(b),i.add(new m(function(){r.removeTrack(v),document.body.removeChild(b)}))}else r.addTrack(e);break;default:Z(o)}}),{transformedStream:r,disposables:i}}}]);var e}(),Qt=n(981).A,Zt=function(){return o()(function e(){throw t()(this,e),new Error("VideoFrameDetector is a static class that may not be instantiated")},null,[{key:"isRenderingFrames",value:function(e){var t=this;if(!O.isRequestVideoFrameCallbackSupported)return this._logger.debug("requestVideoFrameCallback not supported, assuming rendering"),Qt.resolve(!0);if(!O.isRequestAnimationFrameSupported)return this._logger.debug("requestAnimationFrame not supported, assuming rendering"),Qt.resolve(!0);if(!O.isMobile)return this._logger.debug("Skipping frame detection on desktop, assuming rendering"),Qt.resolve(!0);var n=Date.now();return new Qt(function(r){var i=!1,o=P.value.setTimeout(function(){i||(i=!0,t._logger.info("Frame detection timed out after [%s] ms, assuming rendering",1e3),r(!0))},1e3);e.requestVideoFrameCallback(function(){i||(i=!0,P.value.clearTimeout(o),t._logger.debug("Video frame rendered within [%s] ms — stream is healthy",Date.now()-n),r(!0))}),P.value.requestAnimationFrame(function(){i||(i=!0,P.value.clearTimeout(o),t._logger.debug("No video frame rendered within [%s] ms — stream is stalled",Date.now()-n),r(!1))})})}}])}();s()(Zt,"_logger",ee.getLogger("VideoFrameDetector"));var $t,Xt=function(e){return e[e.OPUS=0]="OPUS",e[e.AAC=1]="AAC",e}({}),Yt=new Uint8Array([0,0,0,1]),en=new Uint8Array([].concat(c()(Yt),[103,66,192,42,218,4,4,232,64,0,0,3,0,64,0,0,15,35,198,12,168],c()(Yt),[104,206,60,128],c()(Yt),[6,3,167],c()(new Uint8Array(150).fill(255)),[128],c()(Yt),[101,136,132,6,191,255,255,15,69,0,1,87,159],c()(new Uint8Array(15).fill(39)),[93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,128])),tn=new Uint8Array([].concat(c()(Yt),[6,3,255,61],c()(new Uint8Array(316).fill(255)),[128],c()(Yt),[65,154,32,26,240,18,48])),nn=Symbol(),rn=function(){function e(){throw t()(this,e),new Error("SurrogateFrameDataManager is a static class that may not be instantiated")}return o()(e,null,[{key:"getSurrogateAudioSilentPerCodec",value:function(t){switch(t){case Xt.OPUS:return e._dummyAudioSilentPerCodec.OPUS.buffer;case Xt.AAC:return;default:Z(t)}}},{key:"getInvalidSurrogateAudioData",value:function(){return e._singleZeroByte.buffer}},{key:"getSurrogateVideoIFramePerCodec",value:function(t){switch(t){case It.H264:return e._isSafari?e._surrogate28x16H264IFrame.buffer:e._dummy2x2VideoIFramePerCodec.H264.buffer;case It.VP8:return e._dummy2x2VideoIFramePerCodec.VP8.buffer;case It.VP9:return e._dummy2x2VideoIFramePerCodec.VP9.buffer;default:Z(t)}}},{key:"getInvalidSurrogateVideoIFrame",value:function(t){return t===It.H264&&e._isAndroidChrome?(e._surrogate28x16PFrameFrameNumber=e._surrogate28x16PFrameFrameNumberReset,nn):e._singleZeroByte.buffer}},{key:"getSurrogateVideoPFramePerCodec",value:function(t){switch(t){case It.H264:return e._isSafari?e._surrogate28x16H264PFrame.buffer:e._dummy2x2VideoPFramePerCodec.H264.buffer;case It.VP8:return e._dummy2x2VideoPFramePerCodec.VP8.buffer;case It.VP9:return e._dummy2x2VideoPFramePerCodec.VP9.buffer;default:Z(t)}}},{key:"getInvalidSurrogateVideoPFrame",value:function(){return e._singleZeroByte.buffer}}])}();function on(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return an(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(an(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,an(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,an(d,"constructor",c),an(c,"constructor",u),u.displayName="GeneratorFunction",an(c,i,"GeneratorFunction"),an(d),an(d,i,"Generator"),an(d,r,function(){return this}),an(d,"toString",function(){return"[object Generator]"}),(on=function(){return{w:o,m:h}})()}function an(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}an=function(e,t,n,r){function o(t,n){an(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},an(e,t,n,r)}$t=rn,s()(rn,"_isSafari","Safari"===E.browserName),s()(rn,"_isAndroidChrome","Chrome"===E.browserName&&E.isAndroid),s()(rn,"_singleZeroByte",new Uint8Array([0])),s()(rn,"_dummyAudioSilentPerCodec",{OPUS:new Uint8Array([104,7,217,171,188,121,135,171,142,74,20,243,167,28,242,154,122,69,167,45,68,37,116,76,173,22,179,14,81,87,234,231,173,42,56,206,51])}),s()(rn,"_dummy2x2VideoIFramePerCodec",{H264:new Uint8Array([].concat(c()(Yt),[9,240],c()(Yt),[103,244,0,10,145,155,43,241,241,248,8,128,0,0,3,0,128,0,0,25,7,137,18,203],c()(Yt),[104,235,227,196,72,68,0,0,1,101,136,130,0,63,112,35,134,230,209,128,9,175,10,65,102,107,84,70,251,113,217,127,255,255,249])),VP8:new Uint8Array([176,2,0,157,1,42,1,0,1,0,57,107,0,39,28,36,12,44,44,68,204,36,65,168,0,19,167,163,122,80,0,254,235,222,47,138,30,107,123,7,114,99,9,164,142,192]),VP9:new Uint8Array([130,73,131,66,0,0,0,0,6,118,56,36,28,25,160,0,0,32,64,0,17,191,221,119,255,64,127,177,0])}),s()(rn,"_dummy2x2VideoPFramePerCodec",{H264:new Uint8Array([].concat(c()(Yt),[9,240],c()(Yt),[65,154,104,73,168,65,104,153,76,15,255,146,129])),VP8:new Uint8Array([49,3,0,228,224,168,155,55,175,16,79,79,177,10,47,228,146,192,31,231,79,70,255,238,81,193,93,0,254,235,222,47,138,30,107,123,7,114,99,9,164,142,192]),VP9:new Uint8Array([134,0,64,146,156,36,72,0,0,3,112,0,0,75,64])}),s()(rn,"_surrogate28x16H264IFrame",en),s()(rn,"_surrogate28x16H264PFrame",tn),s()(rn,"_surrogate28x16PFrameFrameNumberReset",1),s()(rn,"_surrogate28x16PFrameFrameNumber",$t._surrogate28x16PFrameFrameNumberReset);var sn=function(){return o()(function e(n){t()(this,e),s()(this,"_disposables",new ie),this.initialize(n)},[{key:"dispose",value:function(){this._disposables.dispose()}},{key:"initialize",value:function(e){var t=this;e.videoTrack.mediaStreamTrack&&(e.videoTrack.transformFunctionNames.push("protected-video"),this._disposables.add(e.videoTrack.transformMessageRouter.registerRoute(Dt.EncodedVideoChunk,function(n){return t.encodedVideoStreamCallback(e.videoTrack,e.encodedVideoStreamSink,n)}))),e.audioTrack.mediaStreamTrack&&(e.audioTrack.transformFunctionNames.push("protected-audio"),this._disposables.add(e.audioTrack.transformMessageRouter.registerRoute(Dt.EncodedAudioChunk,function(n){return t.encodedAudioStreamCallback(e.audioTrack,e.encodedAudioStreamSink,n)})))}},{key:"encodedAudioStreamCallback",value:(n=V()(on().m(function e(t,n,r){return on().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,n(t.mediaStreamTrack,r);case 1:if(e.v){e.n=2;break}r.data=rn.getInvalidSurrogateAudioData(),e.n=3;break;case 2:r.data=rn.getSurrogateAudioSilentPerCodec(t.codec)||r.data;case 3:return e.a(2,r)}},e)})),function(e,t,r){return n.apply(this,arguments)})},{key:"encodedVideoStreamCallback",value:(e=V()(on().m(function e(t,n,r){var i;return on().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,n(t.mediaStreamTrack,r);case 1:if(e.v){e.n=3;break}if((i="key"===r.type?rn.getInvalidSurrogateVideoIFrame(t.codec):rn.getInvalidSurrogateVideoPFrame())!==nn){e.n=2;break}return e.a(2);case 2:r.data=i||r.data,e.n=4;break;case 3:"key"===r.type?r.data=rn.getSurrogateVideoIFramePerCodec(t.codec)||r.data:r.data=rn.getSurrogateVideoPFramePerCodec(t.codec)||r.data;case 4:return e.a(2,r)}},e)})),function(t,n,r){return e.apply(this,arguments)})}]);var e,n}(),un=function(){return o()(function e(){t()(this,e)},null,[{key:"convertVideoCodecToVideoCodecType",value:function(e){switch(e){case It.H264:return"H264";case It.VP8:return"VP8";case It.VP9:return"VP9";default:Z(e)}}},{key:"convertVideoCodecTypeToVideoCodec",value:function(e){var t=e.toUpperCase();switch(t){case"H264":return It.H264;case"VP8":return It.VP8;case"VP9":return It.VP9;default:Z(t)}}}])}(),cn=function(){return o()(function e(){t()(this,e)},null,[{key:"convertAudioCodecToAudioCodecType",value:function(e){switch(e){case Xt.OPUS:return"OPUS";case Xt.AAC:return"AAC";default:Z(e)}}},{key:"convertAudioCodecTypeToAudioCodec",value:function(e){var t=e.toUpperCase();switch(t){case"OPUS":return Xt.OPUS;case"AAC":return Xt.AAC;default:Z(t)}}}])}(),ln=n(981).A;function dn(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return hn(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(hn(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,hn(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,hn(d,"constructor",c),hn(c,"constructor",u),u.displayName="GeneratorFunction",hn(c,i,"GeneratorFunction"),hn(d),hn(d,i,"Generator"),hn(d,r,function(){return this}),hn(d,"toString",function(){return"[object Generator]"}),(dn=function(){return{w:o,m:h}})()}function hn(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}hn=function(e,t,n,r){function o(t,n){hn(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},hn(e,t,n,r)}function fn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function pn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?fn(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var vn=function(){return o()(function e(n,r,i,o,a){t()(this,e),s()(this,"_logger",ee.getLogger("RealTimeStreamSubscriber")),s()(this,"_disposables",new ie),s()(this,"_channelContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_streamTransformContext",void 0),s()(this,"_frameTimingInformationContext",void 0),s()(this,"_handleStreamFailure",void 0),this._channelContext=n,this._peerConnectionContext=r,this._streamTransformContext=i,this._frameTimingInformationContext=o,this._handleStreamFailure=a},[{key:"start",value:function(e,t,n,r){var i=this;this._disposables.dispose();var o=this._streamTransformContext.hasEncodedInsertableStreams.value||this._frameTimingInformationContext.shouldExtractTimecode.value||this._frameTimingInformationContext.shouldExtractTimestamps.value?ge.Enabled:ge.Disabled;return ln.all([Ft.discoverClosestEndPointWithCaching(e),_e.createPeerConnectionOffer("recvonly",ye,o).then(function(e){var t=e.localOffer,n=e.peerConnection;return i._peerConnectionContext.peerConnection.value=n,{localOffer:t,peerConnection:n}})]).then(function(e){var n=at()(e,2),r=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;i._channelContext.online.value=!0,i._channelContext.endPoint.value=r,i._logger.info("Connecting to [%s]",r.toString()),i._logger.info("Local offer:\n"+a.sdp);var u={};return i._channelContext.onRealTimeSubscribeRequestCallback&&(u.onSubscribeRequestCallback=i._channelContext.onRealTimeSubscribeRequestCallback),i._channelContext.onRealTimeSubscribeResponseCallback&&(u.onSubscribeResponseCallback=i._channelContext.onRealTimeSubscribeResponseCallback),!O.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration?r.subscribe(t,a,i._channelContext.failureCount.value,u):(s.close(),s.dispose(),!Ve.forceGarbageCollectionOnRestart||O.isMobile&&Ve.skipGarbageCollectionOnMobileDevices||Be.forceGarbageCollection(),i._peerConnectionContext.peerConnection.value=null,r.subscribe(t,null,i._channelContext.failureCount.value,u))}).then(function(e){var t=e.status;if(i._channelContext.exists.value=i._channelContext.mapSubscribeStatusToExists(t),i._channelContext.state.value=i._channelContext.mapSubscribeStatusToChannelStatus(t),i._channelContext.applyStatus(t),"ok"!==t)return i._channelContext.stream.value=null,i._channelContext.lag.value=void 0,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),void i._logger.info("[%s] Subscribe failed with status [%s]",i._channelContext.streamId,t);var a=e.stream,s=e.rtcConfiguration,u=e.setRemoteDescriptionResponse,c=e.createOfferDescriptionResponse,l=e.createAnswerDescriptionResponse,d=e.lag;return i._channelContext.stream.value=a,i._channelContext.lag.value=d,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),i._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",i._channelContext.streamId,t,s,u,c,l),i.applyRtcConfiguration(i._peerConnectionContext.peerConnection.value,s).then(function(e){var t,s=!1,d=!1,h=[];i._peerConnectionContext.peerConnection.value||(i._peerConnectionContext.peerConnection.value=e),e.onicecandidate=function(n){i._channelContext.stream.value===a&&i._peerConnectionContext.peerConnection.value===e&&(s||Ve.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?h.push(n.candidate):d=!0,t||(t=P.value.setTimeout(function(){var e;i._channelContext.stream.value!==a||s||null===(e=i._channelContext.endPoint.value)||void 0===e||e.addIceCandidates(a,h,d).then(function(e){var t=e.status,n=e.options;"ok"===t?(null!=n&&n.includes("cancel")&&(s=!0),i._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",i._channelContext.streamId,t,n)):i._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",i._channelContext.streamId,t)}).catch(function(e){i._logger.error("[%s] Failed to add ICE candidates",i._channelContext.streamId,e)})},100),i._disposables.add(new m(function(){return P.value.clearTimeout(t)})))))},i._disposables.add(new m(function(){e.onicecandidate=null,e.oniceconnectionstatechange=null})),e.oniceconnectionstatechange=function(){if(i._channelContext.stream.value===a&&i._peerConnectionContext.peerConnection.value===e){var t=function(){i._handleStreamFailure().catch(function(t){i._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)})};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return void(P.value.navigatorIsOnLine&&(i._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",i._channelContext.streamId,e.iceConnectionState),i.reconnectPeerConnection(i._channelContext.streamId,e,t)));case"closed":return i._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",i._channelContext.streamId,e.iceConnectionState),void t();default:Z(e.iceConnectionState)}}};var f=new ln(function(t,n){if(!O.onTrackDisabled){var r=P.value.setTimeout(function(){return n(new Error("Stream setup timed out"))},3e4);return i._disposables.add(new m(function(){return P.value.clearTimeout(r)})),void(e.ontrack=function(e){P.value.clearTimeout(r),t(e.streams[0])})}var o=function(n){P.value.clearTimeout(a),e.removeEventListener("track",o),e.removeEventListener("addstream",o),t("streams"in n?n.streams[0]:n.stream)},a=P.value.setTimeout(function(){e.removeEventListener("track",o),e.removeEventListener("addstream",o),n(new Error("Stream setup timed out"))},3e4);e.addEventListener("track",o),e.addEventListener("addstream",o),i._disposables.add(new m(function(){return P.value.clearTimeout(a)}))});return new ln(function(e){e()}).then(function(){if(u)return i._logger.info("[%s] Set local SDP offer [%s]",i._channelContext.streamId,u.sessionDescription.sdp),e.setLocalDescription(u.sessionDescription).catch(function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,u.sessionDescription,e.message),e})}).then(function(){if(l)return i._logger.info("[%s] Set remote SDP answer [%s]",i._channelContext.streamId,l.sessionDescription.sdp),e.setRemoteDescription(l.sessionDescription).catch(function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,l.sessionDescription,e.message),e})}).then(function(){if(c)return i._logger.info("[%s] Set remote SDP offer [%s]",i._channelContext.streamId,c.sessionDescription.sdp),e.setRemoteDescription(c.sessionDescription).catch(function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,c.sessionDescription,e.message),e}).then(function(){return e.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})}).then(function(e){return i._logger.info("[%s] Set local SDP answer [%j]",i._channelContext.streamId,e),i._channelContext.endPoint.value.setRemoteDescription(a,e)}).then(function(t){var n=t.status,r=t.sessionDescription;return i._channelContext.state.value=i.mapSetRemoteDescriptionStatusToChannelStatus(n),"ok"!==n?(i._channelContext.playing.value=!1,i._channelContext.standby.value=!0,void(i._channelContext.stopped.value=!1)):e.setLocalDescription(r).catch(function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,r,e.message),e})})}).then(function(){return n.success(i._channelContext.streamId),f}).then(function(t){var n,a;if(o&&null!=e&&null!==(n=e.currentRemoteDescription)&&void 0!==n&&n.sdp){var s,u,c=new st(e.currentRemoteDescription.sdp);i._streamTransformContext.videoTrack.codec=un.convertVideoCodecTypeToVideoCodec(c.videoCodec),i._streamTransformContext.audioTrack.codec=cn.convertAudioCodecTypeToAudioCodec(c.audioCodec);var l=e.getReceivers(),d=i._streamTransformContext.videoTrack.mediaStreamTrack=t.getVideoTracks()[0],h=i._streamTransformContext.videoTrack.receiver=l.filter(function(e){return e.track===d})[0];i._streamTransformContext.videoTrack.mid=e.supportsGetTransceivers?null===(s=e.getTransceivers().filter(function(e){return e.receiver===h})[0])||void 0===s?void 0:s.mid:null;var f=i._streamTransformContext.audioTrack.mediaStreamTrack=t.getAudioTracks()[0],p=i._streamTransformContext.audioTrack.receiver=l.filter(function(e){return e.track===f})[0];if(i._streamTransformContext.audioTrack.mid=e.supportsGetTransceivers?null===(u=e.getTransceivers().filter(function(e){return e.receiver===p})[0])||void 0===u?void 0:u.mid:null,i._disposables.add(Kt.createEncodedStreamPipeline(i._streamTransformContext)),i._frameTimingInformationContext.shouldExtractTimecode.value||i._frameTimingInformationContext.shouldExtractTimestamps.value){var v={streamId:i._channelContext.streamId,codec:i._streamTransformContext.videoTrack.codec,videoElement:i._channelContext.videoElement,decodedFrameTimingInformationSubject:i._frameTimingInformationContext.decodedFrameTimingInformation,renderedFrameTimingInformationSubject:i._frameTimingInformationContext.renderedFrameTimingInformation,isEnabledSubject:i._frameTimingInformationContext.isEnabled,receiver:h,mid:i._streamTransformContext.videoTrack.mid,trackId:i._streamTransformContext.videoTrack.mediaStreamTrack.id,transformMessageRouter:i._streamTransformContext.videoTrack.transformMessageRouter,transformFunctionNames:i._streamTransformContext.videoTrack.transformFunctionNames};i._disposables.add(new Vt(v))}if(i._streamTransformContext.hasEncodedInsertableStreams.value){var m={videoTrack:i._streamTransformContext.videoTrack,audioTrack:i._streamTransformContext.audioTrack,encodedVideoStreamSink:i._streamTransformContext.encodedVideoStreamSink,encodedAudioStreamSink:i._streamTransformContext.encodedAudioStreamSink};i._disposables.add(new sn(m))}Kt.configureEncodedStreamPipeline(i._streamTransformContext)}if(i._streamTransformContext.hasInsertableStreams.value){var g=Kt.configureInsertableStreamTransformation(t,i._streamTransformContext.videoStreamTransformCallback,i._streamTransformContext.audioStreamTransformCallback),y=g.transformedStream,_=g.disposables;i._disposables.add(_),t=y}i._peerConnectionContext.mediaStream.value=t;var b=new ht(e,t,null!==(a=i._channelContext.endPoint.value)&&void 0!==a&&a.roundTripTime?i._channelContext.endPoint.value.roundTripTime/4:0,Ve.applicationActivityMonitor.isForeground);i._disposables.add(b);var C=b.rtcStatistic.subscribe(function(t){if(i._channelContext.rtcStatistics.value=t,t){if(!i._channelContext.rtcVideoStatistic&&!i._channelContext.rtcAudioStatistic)return i._channelContext.rtcAudioStatistic=t.audio,void(i._channelContext.rtcVideoStatistic=t.video);if(!Ve.applicationActivityMonitor.isForeground.value)return i._channelContext.rtcAudioStatistic=t.audio,void(i._channelContext.rtcVideoStatistic=t.video);var n=!1,r=!1;if(t.audio&&i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.timestamp!==t.audio.timestamp&&((n=i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.bytesReceived===t.audio.bytesReceived)&&P.value.navigatorIsOnLine&&i._logger.info("[%s] Audio track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.audio.bytesReceived,i._channelContext.rtcAudioStatistic.bytesReceived,new ze(t.audio.timestamp-i._channelContext.rtcAudioStatistic.timestamp).toIsoString()),i._channelContext.rtcAudioStatistic=t.audio),t.video&&i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.timestamp!==t.video.timestamp&&((r=i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.bytesReceived===t.video.bytesReceived)&&P.value.navigatorIsOnLine&&i._logger.info("[%s] Video track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.video.bytesReceived,i._channelContext.rtcVideoStatistic.bytesReceived,new ze(t.video.timestamp-i._channelContext.rtcVideoStatistic.timestamp).toIsoString()),i._channelContext.rtcVideoStatistic=t.video),P.value.navigatorIsOnLine)if(r||n)i.reconnectPeerConnection(i._channelContext.streamId,e,function(){b.dispose(),i._handleStreamFailure().catch(function(t){i._logger.error("[%s] Failed handling stream failure after track stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)})});else{if(i._peerConnectionContext.peerConnectionReconnectAttempts=0,i._channelContext.state.value!==Ne.Reconnecting&&i._channelContext.state.value!==Ne.Offline)return;i._channelContext.state.value=i._channelContext.playing.value?Ne.Playing:Ne.Paused,i._logger.info("Channel state restored to [%s] after reconnecting",Ne[i._channelContext.state.value])}else i._channelContext.state.value=Ne.Offline}});return i._disposables.add(C),Ve.automaticallyPlayMediaStream?r(t):(i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,void(i._channelContext.state.value=Ne.Paused))})})})}},{key:"applyRtcConfiguration",value:(e=V()(dn().m(function e(t,n){var r;return dn().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return n=ut.truncateIceServers(n),e.a(2,Ve.peerConnectionFactory.value.createPeerConnection(n));case 1:return r=pn(pn({},t.getConfiguration()),n),t.setConfiguration(r),e.a(2,t)}},e)})),function(t,n){return e.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t,n){var r=this;if(Ve.applicationActivityMonitor.isForeground.value){if("closed"!==t.iceConnectionState){switch(this._channelContext.state.value){case Ne.Paused:case Ne.Stopped:case Ne.Unauthorized:case Ne.GeoRestricted:case Ne.GeoBlocked:case Ne.UnsupportedFeature:case Ne.ConfigurationError:return void this._logger.debug("[%s] Skipping peerConnection reconnection in deliberately-terminal state [%s]",e,Ne[this._channelContext.state.value])}if(this._channelContext.state.value=Ne.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Ve.maximalNumberOfPeerConnectionReconnectAttempts||!Ve.automaticallyReconnectPeerConnection){var i;this._peerConnectionContext.peerConnectionReconnectAttempts++;var o="offer"===(null===(i=t.currentLocalDescription)||void 0===i?void 0:i.type);if(O.clientOfferDisabled||!t.supportsSetConfiguration||!t.supportsGetConfiguration||!o)return;this._logger.info("Reconnecting peer connection by restarting ICE");var a=t.currentLocalDescription;t.createOffer({iceRestart:!0}).then(function(e){return t.setLocalDescription(e).then(function(){return t.setLocalDescription(a)})}).catch(function(e){r._logger.error("Failed to reconnect peer connection",e),r._peerConnectionContext.peerConnectionReconnectAttempts=0,n()})}else this._logger.info("Failed to reconnect peer connection after [%s] attempts, performing full recovery",this._peerConnectionContext.peerConnectionReconnectAttempts),this._peerConnectionContext.peerConnectionReconnectAttempts=0,n()}}else this._logger.debug("[%s] Skipping peerConnection reconnection attempt while not in foreground (peerConnection state [%s])",e,t.iceConnectionState)}},{key:"isStreamHealthy",value:function(){var e,t=this._channelContext.videoElement.value;if(!t)return ln.resolve(!1);var n=this._peerConnectionContext.mediaStream.value,r=null!==(e=null==n?void 0:n.getTracks().some(function(e){return"live"===e.readyState}))&&void 0!==e&&e;return t.paused||!r?ln.resolve(!1):Zt.isRenderingFrames(t)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"mapSetRemoteDescriptionStatusToChannelStatus",value:function(e){switch(e){case"ok":return Ne.Starting;case"unauthorized":return Ne.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return Ne.Recovering;case"failed":return Ne.Error;default:Z(e)}}}]);var e}(),mn=function(){return o()(function e(){throw t()(this,e),new Error("RealTimeStreamSubscriberFactory is a static class that may not be instantiated")},null,[{key:"create",value:function(e,t,n,r,i,o){var a=re.parseToken(e).capabilities;return a.includes("on-demand")?(this._logger.error("This build does not support On-Demand Stream playback."),void(t.state.value=Ne.UnsupportedFeature)):a.includes("streaming")?(this._logger.error("This build does not support Live Stream playback."),void(t.state.value=Ne.UnsupportedFeature)):new vn(t,n,r,i,o)}}])}();s()(mn,"_logger",ee.getLogger("Streaming"));var gn=n(981).A;function yn(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return _n(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(_n(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,_n(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,_n(d,"constructor",c),_n(c,"constructor",u),u.displayName="GeneratorFunction",_n(c,i,"GeneratorFunction"),_n(d),_n(d,i,"Generator"),_n(d,r,function(){return this}),_n(d,"toString",function(){return"[object Generator]"}),(yn=function(){return{w:o,m:h}})()}function _n(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}_n=function(e,t,n,r){function o(t,n){_n(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},_n(e,t,n,r)}var bn=function(){return o()(function e(n,r,i){var o=this;t()(this,e),s()(this,"_logger",ee.getLogger("Channel")),s()(this,"_tokenContext",void 0),s()(this,"_channelContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_streamTransformContext",void 0),s()(this,"_stateContext",void 0),s()(this,"_frameTimingInformationContext",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_channelStartTime",void 0),s()(this,"_readOnlyPeerConnection",void 0),s()(this,"_readOnlyState",void 0),s()(this,"_readOnlyExists",void 0),s()(this,"_readOnlyAutoMuted",void 0),s()(this,"_readOnlyAutoPaused",void 0),s()(this,"_readOnlyTokenExpiring",void 0),s()(this,"_readOnlyAuthorized",void 0),s()(this,"_readOnlyOnline",void 0),s()(this,"_readOnlyLoading",void 0),s()(this,"_readOnlyPlaying",void 0),s()(this,"_readOnlyStandby",void 0),s()(this,"_readOnlyStopped",void 0),s()(this,"_readOnlyTargetLag",void 0),s()(this,"_readOnlyLag",void 0),s()(this,"_readOnlyBitrateLimit",void 0),s()(this,"_readOnlyResolution",void 0),s()(this,"_readOnlyFailureCount",void 0),s()(this,"_readOnlyEndPoint",void 0),s()(this,"_readOnlyStream",void 0),s()(this,"_readOnlyRtcStatistics",void 0),s()(this,"_readOnlyMediaStream",void 0),s()(this,"_readOnlyIsFrameTimingInformationEnabled",void 0),s()(this,"_readOnlyDecodedFrameTimingInformation",void 0),s()(this,"_readOnlyRenderedFrameTimingInformation",void 0),s()(this,"_metricsService",void 0),s()(this,"_streamSubscriber",null),s()(this,"_sessionTelemetry",void 0),s()(this,"_videoMetaDataChangedHandler",void 0);var a=re.parseToken(r),u={targetLag:null==i?void 0:i.targetLag,onRealTimeSubscribeRequestCallback:null==i?void 0:i.onRealTimeSubscribeRequestCallback,onRealTimeSubscribeResponseCallback:null==i?void 0:i.onRealTimeSubscribeResponseCallback},c={hasInsertableStreams:a.capabilities.includes("insertable-streams"),hasEncodedInsertableStreams:a.capabilities.includes("encoded-insertable-streams"),videoStreamTransformCallback:null==i?void 0:i.videoStreamTransformCallback,audioStreamTransformCallback:null==i?void 0:i.audioStreamTransformCallback,encodedVideoStreamSink:null==i?void 0:i.encodedVideoStreamSink,encodedAudioStreamSink:null==i?void 0:i.encodedAudioStreamSink};this._tokenContext=new $e(r),this._channelContext=new Xe(u),this._peerConnectionContext=new nt,this._streamTransformContext=new tt(c),this._stateContext=new rt,this._exponentialBackoff=new xe,this._channelStartTime=Date.now(),this._readOnlyPeerConnection=new C(this._peerConnectionContext.peerConnection),this._readOnlyState=new C(this._channelContext.state),this._readOnlyExists=new C(this._channelContext.exists),this._readOnlyAutoMuted=new C(this._channelContext.autoMuted),this._readOnlyAutoPaused=new C(this._channelContext.autoPaused),this._readOnlyTokenExpiring=new C(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new C(this._channelContext.authorized),this._readOnlyOnline=new C(this._channelContext.online),this._readOnlyLoading=new C(this._channelContext.loading),this._readOnlyPlaying=new C(this._channelContext.playing),this._readOnlyStandby=new C(this._channelContext.standby),this._readOnlyStopped=new C(this._channelContext.stopped),this._readOnlyTargetLag=new C(this._channelContext.targetLag),this._readOnlyLag=new C(this._channelContext.lag),this._readOnlyBitrateLimit=new C(this._channelContext.bitrateLimit),this._readOnlyResolution=new C(this._channelContext.resolution),this._readOnlyFailureCount=new C(this._channelContext.failureCount),this._readOnlyEndPoint=new C(this._channelContext.endPoint),this._readOnlyStream=new C(this._channelContext.stream),this._readOnlyRtcStatistics=new C(this._channelContext.rtcStatistics),this._readOnlyMediaStream=new C(this._peerConnectionContext.mediaStream);var l=(a.uri||Ve.discoveryUri.value).toString();Ve.tenancy.value=a.tenancy||Ve.tenancy.value,Se.uri.value=l,this._metricsService=je.getMetricsService(l),this._sessionTelemetry=new Ke(Ve.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=n,this._frameTimingInformationContext=new it,this.configureFrameTimingInformation(a.capabilities),this._readOnlyIsFrameTimingInformationEnabled=new C(this._frameTimingInformationContext.isEnabled),this._readOnlyDecodedFrameTimingInformation=new C(this._frameTimingInformationContext.decodedFrameTimingInformation),this._readOnlyRenderedFrameTimingInformation=new C(this._frameTimingInformationContext.renderedFrameTimingInformation),this._channelContext.channelDisposables.add(this._channelContext.videoElement.subscribe(function(e){o._channelContext.rendererDisposables.dispose(),e&&(o._channelContext.rendererDisposables.add(o._channelContext.stream.subscribe(function(e){o._channelContext.videoTelemetry&&o._channelContext.videoTelemetry.dispose(),e&&o.videoElement&&(o.videoElement.dataset&&(o.videoElement.dataset.sessionId=Ve.clientSessionId,o.videoElement.dataset.streamId=o.streamId),o._channelContext.videoTelemetry=new qe(o.streamId,Ve.pageLoadTime,o._channelStartTime,o._metricsService),o._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(o.videoElement),o._channelContext.videoTelemetry.setupListenerForRebuffering(o.videoElement),o._channelContext.state.value===Ne.Stopped)&&o.restartAfterStop()})),o._channelContext.channelDisposables.add(o._channelContext.rendererDisposables))})),this._channelContext.channelDisposables.add(this._channelContext.state.subscribe(function(e){o._channelContext.clearFailureCountTimeout&&P.value.clearTimeout(o._channelContext.clearFailureCountTimeout),o._channelContext.failureCount.value&&e===Ne.Playing&&(o._channelContext.clearFailureCountTimeout=P.value.setTimeout(function(){o._channelContext.failureCount.value=0},3e3))})),this._channelContext.channelDisposables.add(this._channelContext.resolution.subscribe(function(e){o._channelContext.videoTelemetry&&o._channelContext.videoTelemetry.onVideoResolutionChanges(e.toString())})),this._channelContext.channelDisposables.add(this._channelContext.bitrateLimit.subscribe(function(e){if(e&&o._channelContext.endPoint.value&&o._channelContext.stream.value){var t=Date.now()-o._channelContext.channelInitialization.getTime();o._channelContext.endPoint.value.limitBitrate(o._channelContext.stream.value,t,e,Qe.Keep,Ze.Normal).catch(function(e){o._logger.error("Error while setting limit bitrate",e)})}}));var d=function(){o._channelContext.stream.value&&o._channelContext.endPoint.value&&o._channelContext.endPoint.value.destroyStreamOnUnmount(o._channelContext.stream.value,"client:termination-on-window-unload")};P.value.addWindowEventListener("beforeunload",d),this._channelContext.channelDisposables.add(new m(function(){P.value.removeWindowEventListener("beforeunload",d)})),this.start(),Ve.automaticRetryOnFailure&&this._channelContext.channelDisposables.add(Ve.applicationActivityMonitor.isForeground.subscribe(function(e){if(e){var t=Ve.applicationActivityMonitor.getLastBackgroundDuration(),n=O.isMobile&&null!==t&&t>5e3,r=o._channelContext.state.value===Ne.Reconnecting&&null!==t&&t>3e4;if(n||r)return o._logger.info("[%s] Foregrounded after [%s] ms in background, forcing restart",o._channelContext.streamId,t),void o.restartOnForeground("client:foregrounded:background-timeout");o.isRetryableState()?o.restartOnForeground("client:foregrounded:unhealthy"):o._streamSubscriber&&o.isSubscriberHealthy().then(function(e){e||o._stateContext.isStarting.value||o._channelContext.state.value!==Ne.Playing||(o._channelContext.failureCount.value=0,o._logger.debug("[%s] Reset failureCount to 0 and restarting Channel after returning to foreground",o._channelContext.streamId),o.start())}).catch(function(e){o._logger.error("[%s] Unexpected error occurred when checking subscriber health while foregrounding",o._channelContext.streamId,e)})}}))},[{key:"videoElement",get:function(){return this._channelContext.videoElement.value},set:function(e){this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.removeEventListener("loadeddata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.removeEventListener("loadedmetadata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.removeEventListener("resize",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.dataset&&(this._channelContext.videoElement.value.dataset.sessionId="",this._channelContext.videoElement.value.dataset.streamId=""),this._channelContext.rendererDisposables.dispose(),this._channelContext.videoElement.value.pause(),this._channelContext.videoElement.value.srcObject=null),this._channelContext.autoMuted.value=!1,this._channelContext.autoPaused.value=!1,this._channelContext.loading.value=!1,this._channelContext.playing.value=!1,this._channelContext.state.value!==Ne.Initializing&&(this._channelContext.state.value=Ne.Stopped),this._channelContext.videoElement.value=e,this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.addEventListener("loadeddata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.addEventListener("loadedmetadata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.addEventListener("resize",this._videoMetaDataChangedHandler))}},{key:"handleVideoMetaDataChanged",value:function(){var e=this._channelContext.videoElement.value;e?this.resolution.value.width===e.videoWidth&&this.resolution.value.height===e.videoHeight||(this._channelContext.resolution.value=new Ge(e.videoWidth,e.videoHeight)):this._channelContext.resolution.value=Ge.empty}},{key:"token",get:function(){return this._tokenContext.token.value},set:function(e){this._channelContext.disposables.dispose(),this._tokenContext.token.value=e,this._tokenContext.tokenExpiring.value=!1;var t=re.parseToken(this._tokenContext.token.value),n=(t.uri||Ve.discoveryUri.value).toString();Ve.tenancy.value=t.tenancy||Ve.tenancy.value,Se.uri.value=n,this._metricsService=je.getMetricsService(n),this._streamTransformContext.hasInsertableStreams.value=t.capabilities.includes("insertable-streams"),this._streamTransformContext.hasEncodedInsertableStreams.value=t.capabilities.includes("encoded-insertable-streams"),this.configureFrameTimingInformation(t.capabilities),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"exists",get:function(){return this._readOnlyExists}},{key:"autoMuted",get:function(){return this._readOnlyAutoMuted}},{key:"autoPaused",get:function(){return this._readOnlyAutoPaused}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"playing",get:function(){return this._readOnlyPlaying}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"targetLag",get:function(){return this._readOnlyTargetLag}},{key:"lag",get:function(){return this._readOnlyLag}},{key:"bitrateLimit",get:function(){return this._readOnlyBitrateLimit.value}},{key:"resolution",get:function(){return this._readOnlyResolution}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._channelContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"isFrameTimingInformationEnabled",get:function(){return this._readOnlyIsFrameTimingInformationEnabled}},{key:"decodedFrameTimingInformation",get:function(){return this._readOnlyDecodedFrameTimingInformation}},{key:"renderedFrameTimingInformation",get:function(){return this._readOnlyRenderedFrameTimingInformation}},{key:"setBitrateLimit",value:function(e){this._channelContext.bitrateLimit.value=e}},{key:"clearBitrateLimit",value:function(){var e=this;if(this._channelContext.bitrateLimit.value&&this._channelContext.endPoint.value&&this._channelContext.stream.value){var t=Date.now()-this._channelContext.channelInitialization.getTime();this._channelContext.endPoint.value.limitBitrate(this._channelContext.stream.value,t,0,Qe.Keep,Ze.Reset).then(function(t){"ok"===t.status&&(e._channelContext.bitrateLimit.value=0)}).catch(function(t){e._logger.error("Error while setting limit bitrate",t)})}}},{key:"updateTargetLag",value:function(e){this._channelContext.targetLag.value=e}},{key:"stop",value:(d=V()(yn().m(function e(t){var n=this;return yn().w(function(e){for(;;)if(0===e.n)return e.a(2,new gn(function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._channelContext.rendererDisposables.add(n._stateContext.isStarting.subscribe(function(r){r||(n.processStop(t),e())}))}))},e)})),function(e){return d.apply(this,arguments)})},{key:"processStop",value:function(e){this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.pause(),this._channelContext.videoElement.value.srcObject=null),this._channelContext.rendererDisposables.dispose(),this.cleanUpResources(e),this._channelContext.state.value=Ne.Stopped}},{key:"resume",value:(l=V()(yn().m(function e(){return yn().w(function(e){for(;;)switch(e.n){case 0:if(!this._peerConnectionContext.mediaStream.value){e.n=1;break}return this._channelContext.autoPaused.value=!1,e.a(2,this.playMediaStreamInVideoElement(this._peerConnectionContext.mediaStream.value));case 1:return e.a(2)}},e,this)})),function(){return l.apply(this,arguments)})},{key:"mute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!0)}},{key:"unmute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!1,this._channelContext.autoMuted.value=!1)}},{key:"dispose",value:(c=V()(yn().m(function e(){var t=this;return yn().w(function(e){for(;;)if(0===e.n)return e.a(2,this.stop("client:channel-dispose").then(function(){t._channelContext.channelDisposables.dispose(),t._stateContext.isDisposed=!0}))},e,this)})),function(){return c.apply(this,arguments)})},{key:"getUri",value:function(e){return re.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",Ve.discoveryUri.value),new P.value.URL(Ve.discoveryUri.value))}},{key:"start",value:(u=V()(yn().m(function e(){return yn().w(function(e){for(;;)switch(e.n){case 0:if(!this._stateContext.isDisposed){e.n=1;break}throw new Error("Channel was already disposed");case 1:if(!this._stateContext.isStarting.value){e.n=2;break}return this._logger.info("Channel is already starting, skipping start"),e.a(2);case 2:return this._stateContext.isStarting.value=!0,e.a(2,this.processStart())}},e,this)})),function(){return u.apply(this,arguments)})},{key:"isRetryableState",value:function(){switch(this._channelContext.state.value){case Ne.Error:case Ne.Reconnecting:case Ne.StandBy:case Ne.Offline:case Ne.Recovering:case Ne.TransientConfigurationError:case Ne.ConnectionError:case Ne.ClientStartError:return!0;case Ne.Unauthorized:case Ne.GeoRestricted:case Ne.GeoBlocked:case Ne.Stopped:case Ne.Paused:case Ne.Initializing:case Ne.Starting:case Ne.Playing:case Ne.UnsupportedFeature:case Ne.ConfigurationError:return!1;default:Z(this._channelContext.state.value)}}},{key:"isSubscriberHealthy",value:function(){return this._streamSubscriber?this._streamSubscriber.isStreamHealthy():gn.resolve(!1)}},{key:"restartOnForeground",value:function(e){this._stateContext.isStarting.value?this._logger.debug("[%s] Skipping failureCount reset and Channel restart due to Channel already starting",this._channelContext.streamId):this.isRetryableState()?(this._channelContext.failureCount.value=0,this._logger.debug("[%s] Reset failureCount to 0 and restarting Channel due to [%s]",this._channelContext.streamId,e),this.start()):this._logger.debug("[%s] Skipping failureCount reset and Channel restart due to ChannelState [%s] which is not retryable",this._channelContext.streamId,Ne[this._channelContext.state.value])}},{key:"processStart",value:(a=V()(yn().m(function e(){var t,n,r,i,o,a,s,u,c,l,d,h,f,p,v,g,y,_,b,C=this;return yn().w(function(e){for(;;)switch(e.n){case 0:if(t=this._channelContext.state.value!==Ne.Initializing,this._channelContext.state.value=t?Ne.Recovering:Ne.Starting,this.cleanUpResources(t?"client:recover":"client:start"),n=this._tokenContext.token.value,r=this._sessionTelemetry.listenOnStreamSetup(),re.isEncodedEdgeTokenValid(n)){e.n=1;break}return this._logger.error("Failed to parse token [%s]",n),this._channelContext.state.value=Ne.Unauthorized,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 1:if(!this._streamTransformContext.videoStreamTransformCallback){e.n=2;break}if(i=et.validateMediaStreamTrackTransform("video",this._streamTransformContext.videoStreamTransformCallback),o=i.valid,a=i.validationResult,o){e.n=2;break}return this._logger.error(a),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 2:if(!this._streamTransformContext.audioStreamTransformCallback){e.n=3;break}if(s=et.validateMediaStreamTrackTransform("audio",this._streamTransformContext.audioStreamTransformCallback),u=s.valid,c=s.validationResult,u){e.n=3;break}return this._logger.error(c),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 3:if(!this._streamTransformContext.encodedVideoStreamSink){e.n=4;break}if(l=Ye.validateEncodedStreamSink("video",this._streamTransformContext.encodedVideoStreamSink),d=l.valid,h=l.validationResult,d){e.n=4;break}return this._logger.error(h),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 4:if(!this._streamTransformContext.encodedAudioStreamSink){e.n=5;break}if(f=Ye.validateEncodedStreamSink("audio",this._streamTransformContext.encodedAudioStreamSink),p=f.valid,v=f.validationResult,p){e.n=5;break}return this._logger.error(v),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 5:if(!this._streamTransformContext.hasInsertableStreams.value||!this._streamTransformContext.hasEncodedInsertableStreams.value){e.n=6;break}return this._logger.error("Both insertable-streams and encoded-insertable-streams are enabled, only use one or the other"),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 6:if(g="function"==typeof this._streamTransformContext.videoStreamTransformCallback||"function"==typeof this._streamTransformContext.audioStreamTransformCallback,y="function"==typeof this._streamTransformContext.encodedVideoStreamSink||"function"==typeof this._streamTransformContext.encodedAudioStreamSink,!g||!y){e.n=7;break}return this._logger.error("Both Media Stream Track transform callback and encodedInsertableStreams sink function found, only use one type or the other"),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 7:if(!this._streamTransformContext.hasInsertableStreams.value){e.n=10;break}if(O.isInsertableStreamsSupported){e.n=8;break}return this._logger.error("Browser does not support Media Stream Track API"),this._channelContext.state.value=Ne.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 8:if(g){e.n=9;break}return this._logger.error("CreateChannelOptions transform callback function is missing; however, insertable-streams is enabled"),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 9:e.n=11;break;case 10:if(!g){e.n=11;break}return this._logger.error("CreateChannelOptions transform callback function found; however, insertable-streams is not enabled"),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 11:if(!this._streamTransformContext.hasEncodedInsertableStreams.value){e.n=14;break}if(O.isEncodedInsertableStreamsSupported||O.isRTCRtpScriptTransformSupported){e.n=12;break}return this._logger.error("Browser does not support encodedInsertableStreams API"),this._channelContext.state.value=Ne.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 12:if(y){e.n=13;break}return this._logger.error("CreateChannelOptions transform sink function is missing; however, encoded-insertable-streams is enabled"),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 13:e.n=15;break;case 14:if(!y){e.n=15;break}return this._logger.error("CreateChannelOptions transform sink function found; however, encoded-insertable-streams is not enabled"),this._channelContext.state.value=Ne.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 15:if(this._channelContext.loading.value=!0,_=this.getUri(n),this._channelContext.disposables.add(this._channelContext.state.subscribe(function(e){e!==Ne.Error&&e!==Ne.Recovering||Ft.clearCachedClosestEndpoint(_)})),b=function(){return new gn(function(e){if(!C.isRetryableState())return C._logger.debug("[%s] Ignoring stream failure callback due to ChannelState being [%s]",C._channelContext.streamId,Ne[C._channelContext.state.value]),e();if(C._stateContext.isStarting.value=!1,C._channelContext.state.value=Ne.ConnectionError,C._channelContext.videoElement.value&&(C._channelContext.videoElement.value.pause(),C._channelContext.videoElement.value.srcObject=null),C._channelContext.playing.value=!1,C._channelContext.loading.value=!0,!Ve.applicationActivityMonitor.isForeground.value){C._logger.debug("[%s] Deferring stream failure handling to foreground recovery",C._channelContext.streamId);var t=P.value.setTimeout(function(){C.handleStreamFailure().catch(function(e){C._logger.error("Failed handling stream failure",e)})},5e3);return C._channelContext.disposables.add(new m(function(){P.value.clearTimeout(t)})),e()}return e(C.handleStreamFailure())})},this._streamSubscriber=mn.create(n,this._channelContext,this._peerConnectionContext,this._streamTransformContext,this._frameTimingInformationContext,b),this._streamSubscriber){e.n=16;break}return this._stateContext.isStarting.value=!1,e.a(2);case 16:return this._channelContext.rendererDisposables.add(this._streamSubscriber),e.a(2,this._streamSubscriber.start(_,n,r,this.playMediaStreamInVideoElement.bind(this)).then(function(){C._channelContext.loading.value=!1}).catch(function(e){r.fail(),C._channelContext.failureCount.value++,C._channelContext.online.value=!1,C.cleanUpResources("client:cleanup-after-failed-setup"),C._channelContext.state.value=Ne.ClientStartError,C._logger.error("Failed to start channel",e)}).finally(function(){if(C._stateContext.isStarting.value=!1,C._channelContext.state.value!==Ne.Playing&&C._channelContext.state.value!==Ne.Paused&&C._channelContext.state.value!==Ne.Stopped&&Ve.automaticRetryOnFailure){var e=P.value.setTimeout(function(){C.handleStreamFailure().catch(function(e){C._logger.error("Failed handling stream failure",e)})},C.getRetryInterval());C._channelContext.disposables.add(new m(function(){P.value.clearTimeout(e)}))}}))}},e,this)})),function(){return a.apply(this,arguments)})},{key:"restartAfterStop",value:(i=V()(yn().m(function e(){return yn().w(function(e){for(;;)switch(e.n){case 0:if(!this._stateContext.isDisposed){e.n=1;break}throw new Error("Channel was already disposed");case 1:if(!this._peerConnectionContext.mediaStream.value){e.n=2;break}return e.a(2,this.playMediaStreamInVideoElement(this._peerConnectionContext.mediaStream.value));case 2:this._tokenContext.token.value&&this.start();case 3:return e.a(2)}},e,this)})),function(){return i.apply(this,arguments)})},{key:"play",value:(r=V()(yn().m(function e(){var t;return yn().w(function(e){for(;;)switch(e.n){case 0:if(t=this._peerConnectionContext.mediaStream.value){e.n=1;break}return e.a(2,this.start());case 1:return e.a(2,this.playMediaStreamInVideoElement(t))}},e,this)})),function(){return r.apply(this,arguments)})},{key:"getRetryInterval",value:function(){switch(this._channelContext.state.value){case Ne.Initializing:case Ne.StandBy:case Ne.Offline:return 15e3;case Ne.Error:case Ne.Recovering:case Ne.Unauthorized:case Ne.GeoRestricted:case Ne.GeoBlocked:case Ne.Stopped:case Ne.Starting:case Ne.Playing:case Ne.Paused:case Ne.Reconnecting:case Ne.UnsupportedFeature:case Ne.ConfigurationError:case Ne.TransientConfigurationError:case Ne.ConnectionError:case Ne.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._channelContext.failureCount.value);default:Z(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(n=V()(yn().m(function e(){var t;return yn().w(function(e){for(;;)switch(e.n){case 0:t=this._channelContext.state.value,e.n=t===Ne.Error||t===Ne.Reconnecting||t===Ne.StandBy||t===Ne.Offline||t===Ne.Recovering||t===Ne.TransientConfigurationError||t===Ne.ConnectionError||t===Ne.ClientStartError?1:t===Ne.Unauthorized?2:t===Ne.GeoRestricted?3:t===Ne.GeoBlocked?4:t===Ne.Stopped?5:t===Ne.Initializing?6:t===Ne.Playing?7:t===Ne.Paused?8:t===Ne.Starting?9:t===Ne.UnsupportedFeature?10:t===Ne.ConfigurationError?11:12;break;case 1:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,Ne[this._channelContext.state.value]),e.a(3,13);case 2:return this._logger.info("Channel is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 3:return this._logger.info("Channel is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 4:return this._logger.info("Channel is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 5:return this._logger.info("Channel is stopped, skipping retry of start."),e.a(2);case 6:return this._logger.info("Channel is already initializing, skipping retry of start"),e.a(2);case 7:return this._logger.info("Channel is playing, skipping retry of start"),e.a(2);case 8:return this._logger.info("Channel is paused, skipping retry of start. Please invoke play()"),e.a(2);case 9:return this._logger.info("Channel is already starting, skipping retry of start"),e.a(2);case 10:return this._logger.info("Channel is stopped due to unsupported feature, skipping retry of start."),e.a(2);case 11:return this._logger.info("Channel is stopped due to configuration error, skipping retry of start."),e.a(2);case 12:Z(this._channelContext.state.value);case 13:return e.a(2,this.start())}},e,this)})),function(){return n.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._streamSubscriber=null,this._channelContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!Ve.forceGarbageCollectionOnRestart||O.isMobile&&Ve.skipGarbageCollectionOnMobileDevices||Be.forceGarbageCollection()),this._peerConnectionContext.mediaStream.value&&(this._peerConnectionContext.mediaStream.value.getTracks().forEach(function(e){return e.stop()}),this._peerConnectionContext.mediaStream.value=null),this._channelContext.autoPaused.value=!1,this._channelContext.autoMuted.value=!1,this._channelContext.playing.value=!1,this._channelContext.stopped.value=!0,this._channelContext.standby.value=!1,this._channelContext.stream.value&&this._channelContext.endPoint.value&&this._channelContext.endPoint.value.destroyStream(this._channelContext.stream.value,t).then(function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)}).catch(function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)}),this.videoElement&&this.videoElement.dataset&&(this.videoElement.dataset.sessionId="",this.videoElement.dataset.streamId=""),this._channelContext.stream.value=null,this._channelContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}},{key:"configureFrameTimingInformation",value:function(e){var t=this,n=e.find(function(e){return e.startsWith("frame-timing-information=")});this._frameTimingInformationContext.shouldExtractTimecode.value=!1,this._frameTimingInformationContext.shouldExtractTimestamps.value=!1,this._frameTimingInformationContext.isEnabled.value=!1,n?O.isChannelFrameTimingInformationSupported?(n.split("=")[1].split(",").map(function(e){return e.trim()}).forEach(function(e){switch(e){case"timecode":t._frameTimingInformationContext.shouldExtractTimecode.value=!0;break;case"timestamps":t._frameTimingInformationContext.shouldExtractTimestamps.value=!0;break;default:t._logger.info("Ignoring unknown frame timing information option [%s]",e)}}),this._logger.info("Frame timing information configuration [(timecode [%s], timestamps [%s])]",this._frameTimingInformationContext.shouldExtractTimecode.value,this._frameTimingInformationContext.shouldExtractTimestamps.value)):this._logger.info("Disabling frame timing information as the environment does not support it [%s]",n):this._logger.info("Disabling frame timing information as no capability was found")}},{key:"playMediaStreamInVideoElement",value:(e=V()(yn().m(function e(t){var n,r,i=this;return yn().w(function(e){for(;;)switch(e.n){case 0:if(n=this._channelContext.videoElement.value){e.n=1;break}return this._channelContext.autoMuted.value=!1,this._channelContext.autoPaused.value=!1,this._channelContext.loading.value=!1,this._channelContext.playing.value=!1,this._channelContext.state.value=Ne.Stopped,e.a(2);case 1:if(this._streamTransformContext.hasEncodedInsertableStreams.value||(n.srcObject=t),void 0!==(r=n.play())){e.n=2;break}return this._channelContext.autoMuted.value=!1,this._channelContext.autoPaused.value=!1,this._channelContext.loading.value=!1,this._channelContext.playing.value=!0,this._channelContext.state.value=Ne.Playing,e.a(2);case 2:return e.a(2,r.then(function(){i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!1,i._channelContext.loading.value=!1,i._channelContext.playing.value=!0,i._channelContext.state.value=Ne.Playing}).catch(function(e){var r=!!t.getTracks().filter(function(e){return"audio"===e.kind}).length,o=!Ve.automaticallyMuteVideoOnPlayFailure;return o||n.muted||!r?(n.srcObject=null,i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=Ne.Paused,o?void i._logger.info("[%s] Paused video after play failed. Manual user action required.",i.streamId,e):r?void i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e):void i._logger.info("[%s] Failed to play muted video. Manual user action required.",i.streamId,e)):(n.muted=!0,n.play().then(function(){i._logger.info("[%s] Played video after auto muting. Manual user action required to unmute.",i.streamId),i._channelContext.autoMuted.value=!0,i._channelContext.autoPaused.value=!1,i._channelContext.loading.value=!1,i._channelContext.playing.value=!0,i._channelContext.state.value=Ne.Playing}).catch(function(e){n.muted=!1,i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e),n.srcObject=null,i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=Ne.Paused}))}))}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e,n,r,i,a,u,c,l,d}(),Cn=function(){return o()(function e(){throw t()(this,e),new Error("Channels is a static class that may not be instantiated")},null,[{key:"createChannel",value:function(e){if(!Ve.initialized.value)throw new Error("SDK is not loaded.");var t={targetLag:e.targetLag,videoStreamTransformCallback:e.videoStreamTransformCallback,audioStreamTransformCallback:e.audioStreamTransformCallback,encodedVideoStreamSink:e.encodedVideoStreamSink,encodedAudioStreamSink:e.encodedAudioStreamSink},n=e;return n.onRealTimeSubscribeRequestCallback&&(t.onRealTimeSubscribeRequestCallback=n.onRealTimeSubscribeRequestCallback),n.onRealTimeSubscribeResponseCallback&&(t.onRealTimeSubscribeResponseCallback=n.onRealTimeSubscribeResponseCallback),new bn(e.videoElement,e.token,t)}},{key:"isFrameTimingInformationSupported",get:function(){return O.isChannelFrameTimingInformationSupported}}])}(),kn=function(e){return e[e.Initializing=0]="Initializing",e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Publishing=3]="Publishing",e[e.Recovering=4]="Recovering",e[e.Reconnecting=5]="Reconnecting",e[e.Stopped=6]="Stopped",e[e.Unauthorized=7]="Unauthorized",e[e.GeoRestricted=8]="GeoRestricted",e[e.GeoBlocked=9]="GeoBlocked",e[e.UnsupportedFeature=10]="UnsupportedFeature",e[e.NotFound=11]="NotFound",e[e.ConfigurationError=12]="ConfigurationError",e[e.TransientConfigurationError=13]="TransientConfigurationError",e[e.ConnectionError=14]="ConnectionError",e[e.ClientStartError=15]="ClientStartError",e[e.Error=16]="Error",e}(kn||{}),Sn=kn,wn=function(){return o()(function e(n){t()(this,e),s()(this,"publisherInitialization",void 0),s()(this,"disposables",void 0),s()(this,"publisherDisposables",void 0),s()(this,"state",void 0),s()(this,"authorized",void 0),s()(this,"online",void 0),s()(this,"loading",void 0),s()(this,"publishing",void 0),s()(this,"standby",void 0),s()(this,"stopped",void 0),s()(this,"failureCount",void 0),s()(this,"endPoint",void 0),s()(this,"stream",void 0),s()(this,"rtcStatistics",void 0),s()(this,"clearFailureCountTimeout",void 0),s()(this,"startReconnectionAttemptsTimeInMilliseconds",void 0),s()(this,"name",void 0),this.disposables=new ie,this.publisherDisposables=new ie,this.publisherInitialization=new Date,this.state=new b(Sn.Initializing),this.authorized=new b(!0),this.online=new b(!0),this.loading=new b(!1),this.publishing=new b(!1),this.standby=new b(!1),this.stopped=new b(!1),this.failureCount=new b(0),this.endPoint=new b(null),this.stream=new b(null),this.rtcStatistics=new b(null),this.clearFailureCountTimeout=0,this.name=n&&n.length?n:this.generateScreenName(),this.startReconnectionAttemptsTimeInMilliseconds=0},[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyPublishStatus",value:function(e){switch(e){case"ok":return;case"unauthorized":case"geo-restricted":case"geo-blocked":return void this.applyUnauthorized();case"not-found":return void this.applyNotFound();default:return void this.applyUnhandledError()}}},{key:"applySetRemoteDescriptionStatus",value:function(e){switch(e){case"ok":return;case"unauthorized":return void this.applyUnauthorized();case"not-found":return void this.applyNotFound();default:return void this.applyUnhandledError()}}},{key:"applyAddIceCandidatesStatus",value:function(e){switch(e){case"ok":return;case"unauthorized":return void this.applyUnauthorized();case"not-found":return void this.applyNotFound();default:return void this.applyUnhandledError()}}},{key:"mapPublishStatusToPublisherStatus",value:function(e){switch(e){case"ok":return Sn.Starting;case"not-found":return Sn.NotFound;case"geo-restricted":return Sn.GeoRestricted;case"geo-blocked":return Sn.GeoBlocked;case"unauthorized":return Sn.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Sn.Recovering;case"missing-channel-or-room-id":case"forbidden-tag":return Sn.ConfigurationError;case"port-in-range-not-found":return Sn.TransientConfigurationError;case"failed":return Sn.Error;default:Z(e)}}},{key:"applyUnhandledError",value:function(){this.failureCount.value++,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null}},{key:"applyUnauthorized",value:function(){this.authorized.value=!1,this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null}},{key:"applyNotFound",value:function(){this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null}},{key:"generateScreenName",value:function(){return te.random(12)}}])}(),Tn=n(981).A;function xn(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return Pn(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Pn(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Pn(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,Pn(d,"constructor",c),Pn(c,"constructor",u),u.displayName="GeneratorFunction",Pn(c,i,"GeneratorFunction"),Pn(d),Pn(d,i,"Generator"),Pn(d,r,function(){return this}),Pn(d,"toString",function(){return"[object Generator]"}),(xn=function(){return{w:o,m:h}})()}function Pn(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Pn=function(e,t,n,r){function o(t,n){Pn(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},Pn(e,t,n,r)}var En=function(){return o()(function e(n,r,i){var o,a,u,c,l=this;if(t()(this,e),s()(this,"_logger",ee.getLogger("RtcPublishMonitor")),s()(this,"_estimatedRoundTripTime",void 0),s()(this,"_estimatedVideoCodec","unknown"),s()(this,"_estimatedAudioCodec","unknown"),s()(this,"_rtcStatistic",new b({})),s()(this,"_disposables",new ie),s()(this,"_peerConnection",void 0),s()(this,"_isMonitorRunning",!0),s()(this,"_updateTimeout",void 0),s()(this,"_monitorGeneration",0),s()(this,"_availableTracks",null),this._peerConnection=n,this._estimatedRoundTripTime=r,this._peerConnection&&null!==(o=this._peerConnection)&&void 0!==o&&null!==(a=o.currentLocalDescription)&&void 0!==a&&a.sdp&&null!==(u=this._peerConnection)&&void 0!==u&&null!==(c=u.currentRemoteDescription)&&void 0!==c&&c.sdp){var d=new st(this._peerConnection.currentLocalDescription.sdp),h=new st(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=h.audioCodec,this._estimatedVideoCodec=h.videoCodec,this._availableTracks={audio:d.isAudioTrackEnabled&&h.isAudioTrackEnabled,video:d.isVideoTrackEnabled&&h.isVideoTrackEnabled};var f=!0;this._disposables.add(i.subscribe(function(e){f?f=!1:e&&l._isMonitorRunning&&(l._monitorGeneration++,P.value.clearTimeout(l._updateTimeout),l._logger.debug("Restarting stats polling after foreground transition"),l.updateStatistic())})),this.updateStatistic()}},[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._monitorGeneration++,this._isMonitorRunning=!1,this._peerConnection=null,this._disposables.dispose(),P.value.clearTimeout(this._updateTimeout),this._updateTimeout=void 0}},{key:"updateStatistic",value:(e=V()(xn().m(function e(){var t,n,r,i,o,a,s,u,c,l,d,h=this;return xn().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!O.getStatsPromiseBasedDisabled){e.n=1;break}return e.a(2);case 1:if(t=this._monitorGeneration,n=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.p=2,o=null===(i=this._peerConnection)||void 0===i?void 0:i.getStats(null)){e.n=3;break}return e.a(2);case 3:return a=new Tn(function(e){r=P.value.setTimeout(function(){return e(void 0)},5e3)}),e.n=4,Tn.race([o,a]);case 4:if(s=e.v,t===this._monitorGeneration&&this._isMonitorRunning){e.n=5;break}return e.a(2);case 5:s?(u={},c=this._estimatedRoundTripTime,s.forEach(function(e){if("candidate-pair"===e.type&&e.currentRoundTripTime&&(c=1e3*e.currentRoundTripTime,u.audio&&(u.audio.roundTripTime=c),u.video&&(u.video.roundTripTime=c)),"candidate-pair"===e.type&&e.lastPacketSentTimestamp&&(l=e.lastPacketSentTimestamp,u.audio&&(u.audio.lastPacketSentTimestamp=l),u.video&&(u.video.lastPacketSentTimestamp=l)),"outbound-rtp"===e.type){var t,r=e.kind||e.mediaType||n(e),i="";if(s.forEach(function(t){t.id===e.codecId&&(i=t.mimeType)}),r&&null!==(t=h._availableTracks)&&void 0!==t&&t[r]){var o,a,d,f,p,v,m,g=(e.bytesSent||0)-(null!==(o=null===(a=h._rtcStatistic.value)||void 0===a||null===(d=a[r])||void 0===d?void 0:d.bytesSent)&&void 0!==o?o:0),y=e.timestamp-(null===(f=h._rtcStatistic.value)||void 0===f||null===(p=f[r])||void 0===p?void 0:p.timestamp),_=g&&y?Math.floor(8*g/y*1e3):0;if(u[r]={ssrc:e.ssrc,mediaType:r,timestamp:e.timestamp,bitrate:_,bytesSent:e.bytesSent,packetsSent:e.packetsSent,retransmittedBytesSent:e.retransmittedBytesSent,codec:i||h.getCodecByType(r),roundTripTime:c},(e.lastPacketSentTimestamp||l)&&(u[r].lastPacketSentTimestamp=e.lastPacketSentTimestamp||l),"video"===r&&(u[r].firCount=e.firCount,u[r].frameHeight=e.frameHeight,u[r].frameWidth=e.frameWidth,u[r].framesEncoded=e.framesEncoded,u[r].framesSent=e.framesSent,u[r].headerBytesSent=e.headerBytesSent,u[r].hugeFramesSent=e.hugeFramesSent,u[r].pliCount=e.pliCount,u[r].qpSum=e.qpSum,u[r].totalEncodeTime=e.totalEncodeTime,u[r].totalEncodedBytesTarget=e.totalEncodedBytesTarget,null!==(v=h._rtcStatistic.value)&&void 0!==v&&null!==(m=v.video)&&void 0!==m&&m.framesEncoded)){var b=(e.framesEncoded-h._rtcStatistic.value.video.framesEncoded)/(u[r].timestamp-h._rtcStatistic.value.video.timestamp)*1e3;u[r].fps=b?Math.round(100*b)/100:0}}}}),this._rtcStatistic.value=u):this._logger.debug("getStats() timed out, skipping stats processing"),e.n=8;break;case 6:if(e.p=6,d=e.v,t===this._monitorGeneration&&this._isMonitorRunning){e.n=7;break}return e.a(2);case 7:this._logger.warn("getStats() rejected",d);case 8:return e.p=8,P.value.clearTimeout(r),e.f(8);case 9:this._isMonitorRunning&&t===this._monitorGeneration&&(this._updateTimeout=P.value.setTimeout(function(){return h.updateStatistic()},1e3));case 10:return e.a(2)}},e,this,[[2,6,8,9]])})),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec||"unknown";case"video":return this._estimatedVideoCodec||"unknown";default:return"unknown"}}}]);var e}(),On=n(981).A;function Rn(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return Fn(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Fn(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Fn(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,Fn(d,"constructor",c),Fn(c,"constructor",u),u.displayName="GeneratorFunction",Fn(c,i,"GeneratorFunction"),Fn(d),Fn(d,i,"Generator"),Fn(d,r,function(){return this}),Fn(d,"toString",function(){return"[object Generator]"}),(Rn=function(){return{w:o,m:h}})()}function Fn(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Fn=function(e,t,n,r){function o(t,n){Fn(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},Fn(e,t,n,r)}function In(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ln(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?In(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):In(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Dn=function(){return o()(function e(n,r,i){t()(this,e),s()(this,"_logger",ee.getLogger("RealTimePublisher")),s()(this,"_publisherContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_handleStreamFailure",void 0),this._publisherContext=n,this._peerConnectionContext=r,this._handleStreamFailure=i},[{key:"start",value:function(e,t,n){var r=this;if(!P.value.navigatorIsOnLine)return this._publisherContext.state.value=Sn.Offline,On.resolve();var i=this._peerConnectionContext.mediaStream.value;if(!i)return this._logger.error("Publish failed no media stream provided"),this._publisherContext.state.value=Sn.ConfigurationError,On.resolve();var o=i.getTracks().reduce(function(e,t){return"audio"===t.kind||"video"===t.kind?e.push(t.kind):r._logger.warn("[%s] Track kind is not supported",t.kind),e},[]);return On.all([Ft.discoverClosestEndPointWithCaching(e),_e.createPeerConnectionOffer("sendonly",o).then(function(e){var t=e.localOffer,n=e.peerConnection;return r._peerConnectionContext.peerConnection.value=n,{localOffer:t,peerConnection:n}})]).then(function(e){var n=at()(e,2),i=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;return r._publisherContext.online.value=!0,r._publisherContext.endPoint.value=i,r._logger.info("Connecting to [%s]",i.toString()),r._logger.info("Local offer:\n"+a.sdp),O.clientOfferDisabled||!s.supportsSetConfiguration||!s.supportsGetConfiguration||r._publisherContext.failureCount.value>0?(s.close(),s.dispose(),!Ve.forceGarbageCollectionOnRestart||O.isMobile&&Ve.skipGarbageCollectionOnMobileDevices||Be.forceGarbageCollection(),r._peerConnectionContext.peerConnection.value=null,i.publish(r._publisherContext.name,t,null,r._publisherContext.failureCount.value)):i.publish(r._publisherContext.name,t,a,r._publisherContext.failureCount.value)}).then(function(e){var t=e.status;if(r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyPublishStatus(t),"ok"!==t)return r._publisherContext.stream.value=null,void r._logger.info("[%s] Publish failed with status [%s]",r._publisherContext.streamId,t);var i=e.stream,o=e.rtcConfiguration,a=e.setRemoteDescriptionResponse,s=e.createOfferDescriptionResponse,u=e.createAnswerDescriptionResponse;return r._publisherContext.stream.value=i,r._logger.debug("[%s] Publish completed [%s] [%j] [%j] [%j] [%j]",r._publisherContext.streamId,t,o,a,s,u),r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyPublishStatus(t),r.applyRtcConfiguration(r._peerConnectionContext.peerConnection.value,o).then(function(e){var t,o=!1,c=!1,l=[];return r._peerConnectionContext.peerConnection.value=e,e.addStream(r._peerConnectionContext.mediaStream.value),e.onicecandidate=function(n){r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e&&(o||Ve.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?l.push(n.candidate):c=!0,t||(t=P.value.setTimeout(function(){var t;r._publisherContext.stream.value!==i||o||null===(t=r._publisherContext.endPoint.value)||void 0===t||t.addIceCandidates(i,l,c).then(function(t){var n=t.status,a=t.options;if("ok"===n)null!=a&&a.includes("cancel")&&(o=!0),r._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",r._publisherContext.streamId,n,a);else{if(r._publisherContext.stream.value!==i)return;if(r._peerConnectionContext.peerConnection.value!==e)return;r._publisherContext.state.value=r.mapAddIceCandidatesStatusToPublisherStatus(n),r._publisherContext.applyAddIceCandidatesStatus(n),r._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",r._publisherContext.streamId,n),r._handleStreamFailure().catch(function(e){r._logger.error("[%s] Failed handling stream failure after peer connection failed to add ICE candidates with reason [%s]",r._publisherContext.streamId,n,e)})}}).catch(function(t){r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e&&(r._logger.error("[%s] Failed to add ICE candidates",r._publisherContext.streamId,t),r._publisherContext.state.value=Sn.ConnectionError,r._publisherContext.applyUnhandledError(),r._handleStreamFailure().catch(function(e){r._logger.error("[%s] Failed handling stream failure after peer connection failed to add ICE candidates",r._publisherContext.streamId,e)}))})},100))))},e.oniceconnectionstatechange=function(){if(r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e){var t=function(){r._publisherContext.state.value=Sn.ConnectionError,r._publisherContext.publishing.value=!1,r._publisherContext.loading.value=!0,r._handleStreamFailure().catch(function(t){r._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",r._publisherContext.streamId,e.iceConnectionState,t)})};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return r._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",r._publisherContext.streamId,e.iceConnectionState),void r.reconnectPeerConnection(e,t);case"closed":return r._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",r._publisherContext.streamId,e.iceConnectionState),void t();default:Z(e.iceConnectionState)}}},new On(function(e){e()}).then(function(){if(a)return r._logger.info("[%s] Set local SDP offer [%s]",r._publisherContext.streamId,a.sessionDescription.sdp),e.setLocalDescription(a.sessionDescription).catch(function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,a.sessionDescription,e.message),e})}).then(function(){var t;if(u)return r._logger.info("[%s] Set remote SDP answer [%s]",r._publisherContext.streamId,null==u||null===(t=u.sessionDescription)||void 0===t?void 0:t.sdp),e.setRemoteDescription(u.sessionDescription).catch(function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,null==u?void 0:u.sessionDescription,e.message),e})}).then(function(){if(s)return r._logger.info("[%s] Set remote SDP offer [%s]",r._publisherContext.streamId,s.sessionDescription.sdp),e.setRemoteDescription(s.sessionDescription).catch(function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,null==u?void 0:u.sessionDescription,e.message),e}).then(function(){return e.createAnswer({offerToReceiveAudio:!1,offerToReceiveVideo:!1})}).then(function(e){r._logger.info("[%s] Set local SDP answer [%s]",r._publisherContext.streamId,e.sdp);var t=r._publisherContext.endPoint.value;if(!t)throw new Error("Failed to set remote description, EndPoint is not set");return t.setRemoteDescription(i,e)}).then(function(t){var n=t.status,i=t.sessionDescription;if(r._publisherContext.state.value=r.mapSetRemoteDescriptionStatusToPublisherStatus(n),r._publisherContext.applySetRemoteDescriptionStatus(n),"ok"===n)return r._logger.info("[%s] Set local SDP [%s]",r._publisherContext.streamId,null==i?void 0:i.sdp),e.setLocalDescription(i).catch(function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,i,e.message),e})})}).then(function(){var t;if(n.success(r._publisherContext.streamId),r._publisherContext.state.value!==Sn.Starting)return On.resolve();r._publisherContext.state.value=Sn.Publishing,r._publisherContext.publishing.value=!0;var i=new En(e,null!==(t=r._publisherContext.endPoint.value)&&void 0!==t&&t.roundTripTime?r._publisherContext.endPoint.value.roundTripTime/4:0,Ve.applicationActivityMonitor.isForeground);return r._publisherContext.disposables.add(i),i.rtcStatistic.subscribe(function(e){r._publisherContext.rtcStatistics.value=e}),On.resolve()})})})}},{key:"applyRtcConfiguration",value:(e=V()(Rn().m(function e(t,n){var r;return Rn().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return n=ut.truncateIceServers(n),e.a(2,Ve.peerConnectionFactory.value.createPeerConnection(n));case 1:return r=Ln(Ln({},t.getConfiguration()),n),t.setConfiguration(r),e.a(2,t)}},e)})),function(t,n){return e.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._publisherContext.state.value=Sn.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Ve.maximalNumberOfPeerConnectionReconnectAttempts||!Ve.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(O.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!i){var o=P.value.setTimeout(function(){n.reconnectPeerConnection(e,t)},1e3);return void this._publisherContext.disposables.add(new m(function(){return P.value.clearTimeout(o)}))}this._logger.info("Reconnecting peer connection by restarting ICE");var a=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then(function(r){return e.setLocalDescription(r).then(function(){return e.setLocalDescription(a).then(function(){if("disconnected"===e.iceConnectionState||"failed"===e.iceConnectionState){var r=P.value.setTimeout(function(){n.reconnectPeerConnection(e,t)},1e3);n._publisherContext.disposables.add(new m(function(){return P.value.clearTimeout(r)}))}else n._publisherContext.state.value=Sn.Publishing})})}).catch(function(e){n._logger.error("Failed to reconnect peer connection",e),n._peerConnectionContext.peerConnectionReconnectAttempts=0,t()})}else this._logger.info("Failed to reconnect peer connection after [%s] attempts, performing full recovery",this._peerConnectionContext.peerConnectionReconnectAttempts),this._peerConnectionContext.peerConnectionReconnectAttempts=0,t()}},{key:"mapSetRemoteDescriptionStatusToPublisherStatus",value:function(e){switch(e){case"ok":return Sn.Starting;case"unauthorized":return Sn.Unauthorized;case"not-found":return Sn.NotFound;case"capacity":case"rate-limited":case"timeout":return Sn.Recovering;case"failed":return Sn.Error;default:Z(e)}}},{key:"mapAddIceCandidatesStatusToPublisherStatus",value:function(e){switch(e){case"ok":return this._publisherContext.state.value;case"unauthorized":return Sn.Unauthorized;case"not-found":return Sn.NotFound;case"capacity":case"rate-limited":case"timeout":return Sn.Recovering;case"failed":return Sn.Error;default:Z(e)}}}]);var e}(),An=n(981).A;function jn(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return Mn(c,"_invoke",function(n,r,i){var o,s,u,c=0,l=i||[],d=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,s=0,u=e,h.n=n,a}};function f(n,r){for(s=n,u=r,t=0;!d&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,p=o[2];n>3?(i=p===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=n<2&&f<o[1])?(s=0,h.v=r,h.n=o[1]):f<p&&(i=n<3||o[0]>r||r>p)&&(o[4]=n,o[5]=r,h.n=p,s=0))}if(i||n>1)return a;throw d=!0,r}return function(i,l,p){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&f(l,p),s=l,u=p;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(d=h.n<0)?u:n.call(r,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(n,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Mn(t={},r,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Mn(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,Mn(d,"constructor",c),Mn(c,"constructor",u),u.displayName="GeneratorFunction",Mn(c,i,"GeneratorFunction"),Mn(d),Mn(d,i,"Generator"),Mn(d,r,function(){return this}),Mn(d,"toString",function(){return"[object Generator]"}),(jn=function(){return{w:o,m:h}})()}function Mn(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Mn=function(e,t,n,r){function o(t,n){Mn(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},Mn(e,t,n,r)}var Vn=function(){return o()(function e(n,r,i){var o=this;t()(this,e),s()(this,"_logger",ee.getLogger("Publisher")),s()(this,"_tokenContext",void 0),s()(this,"_publisherContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_stateContext",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_publisherStartTime",void 0),s()(this,"_readOnlyToken",void 0),s()(this,"_readOnlyPeerConnection",void 0),s()(this,"_readOnlyState",void 0),s()(this,"_readOnlyTokenExpiring",void 0),s()(this,"_readOnlyAuthorized",void 0),s()(this,"_readOnlyOnline",void 0),s()(this,"_readOnlyLoading",void 0),s()(this,"_readOnlyPublishing",void 0),s()(this,"_readOnlyStandby",void 0),s()(this,"_readOnlyStopped",void 0),s()(this,"_readOnlyFailureCount",void 0),s()(this,"_readOnlyEndPoint",void 0),s()(this,"_readOnlyStream",void 0),s()(this,"_readOnlyRtcStatistics",void 0),s()(this,"_readOnlyMediaStream",void 0),s()(this,"_metricsService",void 0),s()(this,"_sessionTelemetry",void 0),this._tokenContext=new $e(r),this._publisherContext=new wn(i),this._peerConnectionContext=new nt,this._stateContext=new rt,this._exponentialBackoff=new xe,this._publisherStartTime=Date.now(),this._readOnlyToken=new C(this._tokenContext.token),this._readOnlyPeerConnection=new C(this._peerConnectionContext.peerConnection),this._readOnlyState=new C(this._publisherContext.state),this._readOnlyTokenExpiring=new C(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new C(this._publisherContext.authorized),this._readOnlyOnline=new C(this._publisherContext.online),this._readOnlyLoading=new C(this._publisherContext.loading),this._readOnlyPublishing=new C(this._publisherContext.publishing),this._readOnlyStandby=new C(this._publisherContext.standby),this._readOnlyStopped=new C(this._publisherContext.stopped),this._readOnlyFailureCount=new C(this._publisherContext.failureCount),this._readOnlyEndPoint=new C(this._publisherContext.endPoint),this._readOnlyStream=new C(this._publisherContext.stream),this._readOnlyRtcStatistics=new C(this._publisherContext.rtcStatistics),this._readOnlyMediaStream=new C(this._peerConnectionContext.mediaStream),this._peerConnectionContext.mediaStream.value=n;var a=re.parseToken(this._tokenContext.token.value),u=(a.uri||Ve.discoveryUri.value).toString();Ve.tenancy.value=a.tenancy||Ve.tenancy.value,Se.uri.value=u,this._metricsService=je.getMetricsService(u),this._sessionTelemetry=new Ke(Ve.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe(function(e){o._publisherContext.clearFailureCountTimeout&&P.value.clearTimeout(o._publisherContext.clearFailureCountTimeout),o._publisherContext.failureCount.value&&e===Sn.Publishing&&(o._publisherContext.clearFailureCountTimeout=P.value.setTimeout(function(){o._publisherContext.failureCount.value=0},3e3))}));var c=function(){o._publisherContext.stream.value&&o._publisherContext.endPoint.value&&o._publisherContext.endPoint.value.destroyStreamOnUnmount(o._publisherContext.stream.value,"client:termination-on-window-unload")};P.value.addWindowEventListener("beforeunload",c),this._publisherContext.publisherDisposables.add(new m(function(){P.value.removeWindowEventListener("beforeunload",c)})),this.start()},[{key:"token",get:function(){return this._tokenContext.token.value},set:function(e){this._publisherContext.disposables.dispose(),this._tokenContext.token.value=e,this._tokenContext.tokenExpiring.value=!1;var t=re.parseToken(this._tokenContext.token.value),n=(t.uri||Ve.discoveryUri.value).toString();Ve.tenancy.value=t.tenancy||Ve.tenancy.value,Se.uri.value=n,this._metricsService=je.getMetricsService(n),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"publishing",get:function(){return this._readOnlyPublishing}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._publisherContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"stop",value:(a=V()(jn().m(function e(t){var n=this;return jn().w(function(e){for(;;)if(0===e.n)return e.a(2,new An(function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._publisherContext.disposables.add(n._stateContext.isStarting.subscribe(function(r){r||(n.processStop(t),e())}))}))},e)})),function(e){return a.apply(this,arguments)})},{key:"processStop",value:function(e){this.cleanUpResources(e),this._peerConnectionContext.peerConnection.value&&(this._peerConnectionContext.peerConnection.value.close(),this._peerConnectionContext.peerConnection.value=null),this._publisherContext.state.value=Sn.Stopped}},{key:"dispose",value:(i=V()(jn().m(function e(){var t=this;return jn().w(function(e){for(;;)if(0===e.n)return e.a(2,this.stop("client:channel-dispose").then(function(){t._publisherContext.publisherDisposables.dispose(),t._stateContext.isDisposed=!0}))},e,this)})),function(){return i.apply(this,arguments)})},{key:"getUri",value:function(e){return re.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",Ve.discoveryUri.value),new P.value.URL(Ve.discoveryUri.value))}},{key:"start",value:(r=V()(jn().m(function e(){return jn().w(function(e){for(;;)switch(e.n){case 0:if(!this._stateContext.isDisposed){e.n=1;break}throw new Error("Channel was already disposed");case 1:if(!this._stateContext.isStarting.value){e.n=2;break}return this._logger.info("Publisher is already starting, skipping start"),e.a(2);case 2:return this._stateContext.isStarting.value=!0,e.a(2,this.processStart())}},e,this)})),function(){return r.apply(this,arguments)})},{key:"processStart",value:(n=V()(jn().m(function e(){var t,n,r,i,o,a=this;return jn().w(function(e){for(;;)switch(e.n){case 0:if(this._publisherContext.state.value=Sn.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),re.isEncodedEdgeTokenValid(t)){e.n=1;break}return this._logger.error("Failed to parse token [%s]",t),this._publisherContext.state.value=Sn.Unauthorized,this._publisherContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.a(2);case 1:return this._publisherContext.loading.value=!0,r=this.getUri(t),this._publisherContext.disposables.add(this._publisherContext.state.subscribe(function(e){e!==Sn.Error&&e!==Sn.Recovering||Ft.clearCachedClosestEndpoint(r)})),i=function(){return new An(function(e){return a._stateContext.isStarting.value=!1,e(a.handleStreamFailure())})},o=new Dn(this._publisherContext,this._peerConnectionContext,i),e.a(2,o.start(r,t,n).then(function(){a._publisherContext.loading.value=!1}).catch(function(e){n.fail(),a._publisherContext.failureCount.value++,a._publisherContext.online.value=!1,a.cleanUpResources("client:cleanup-after-failed-setup"),a._publisherContext.state.value=Sn.ClientStartError,a._logger.error("Failed to start publishing",e)}).finally(function(){if(a._stateContext.isStarting.value=!1,a._publisherContext.state.value!==Sn.Publishing&&Ve.automaticRetryOnFailure){var e=P.value.setTimeout(function(){a.handleStreamFailure().catch(function(e){a._logger.error("Failed handling stream failure",e)})},a.getRetryInterval());a._publisherContext.disposables.add(new m(function(){P.value.clearTimeout(e)}))}else a._publisherContext.startReconnectionAttemptsTimeInMilliseconds=0}))}},e,this)})),function(){return n.apply(this,arguments)})},{key:"setMediaStream",value:function(e){var t=this;this._peerConnectionContext.mediaStream.value=e,this._peerConnectionContext.peerConnection.value&&e.getTracks().forEach(function(e){var n;null===(n=t._peerConnectionContext.peerConnection.value)||void 0===n||n.getSenders().forEach(function(t){var n;e.kind===(null==t||null===(n=t.track)||void 0===n?void 0:n.kind)&&e.id!==t.track.id&&t.replaceTrack(e)})})}},{key:"getRetryInterval",value:function(){switch(this._publisherContext.state.value){case Sn.Offline:return 15e3;case Sn.Initializing:case Sn.NotFound:case Sn.Error:case Sn.Recovering:case Sn.Unauthorized:case Sn.GeoRestricted:case Sn.GeoBlocked:case Sn.Stopped:case Sn.Starting:case Sn.Publishing:case Sn.Reconnecting:case Sn.UnsupportedFeature:case Sn.ConfigurationError:case Sn.TransientConfigurationError:case Sn.ConnectionError:case Sn.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._publisherContext.failureCount.value);default:Z(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:(e=V()(jn().m(function e(){var t;return jn().w(function(e){for(;;)switch(e.n){case 0:t=this._publisherContext.state.value,e.n=t===Sn.Error||t===Sn.Reconnecting||t===Sn.Offline||t===Sn.Recovering||t===Sn.TransientConfigurationError||t===Sn.ConnectionError||t===Sn.ClientStartError?1:t===Sn.Unauthorized?3:t===Sn.GeoRestricted?4:t===Sn.GeoBlocked?5:t===Sn.Stopped?6:t===Sn.Publishing?7:t===Sn.Initializing?8:t===Sn.Starting?9:t===Sn.UnsupportedFeature?10:t===Sn.NotFound?11:t===Sn.ConfigurationError?12:13;break;case 1:if(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds||(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds=Date.now()),!(72e5<=Date.now()-this._publisherContext.startReconnectionAttemptsTimeInMilliseconds)){e.n=2;break}return this._logger.info("Publisher stopped with state [%s] [%s] after exceeding timeout",this._publisherContext.state.value,Sn[this._publisherContext.state.value]),e.a(2);case 2:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,Sn[this._publisherContext.state.value]),e.a(3,14);case 3:return this._logger.info("Publisher is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 4:return this._logger.info("Publisher is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 5:return this._logger.info("Publisher is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.a(2);case 6:return this._logger.info("Publisher is stopped, skipping retry of start."),e.a(2);case 7:return this._logger.info("Publisher is publishing, skipping retry of start"),e.a(2);case 8:return this._logger.info("Publisher is initializing, skipping retry of start"),e.a(2);case 9:return this._logger.info("Publisher is already starting, skipping retry of start"),e.a(2);case 10:return this._logger.info("Publisher is stopped due to unsupported feature, skipping retry of start."),e.a(2);case 11:return this._logger.info("Publisher is stopped due to channel not found, skipping retry of start."),e.a(2);case 12:return this._logger.info("Publisher is stopped due to configuration error, skipping retry of start."),e.a(2);case 13:Z(this._publisherContext.state.value);case 14:return e.a(2,this.start())}},e,this)})),function(){return e.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._publisherContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!Ve.forceGarbageCollectionOnRestart||O.isMobile&&Ve.skipGarbageCollectionOnMobileDevices||Be.forceGarbageCollection()),this._publisherContext.publishing.value=!1,this._publisherContext.stopped.value=!0,this._publisherContext.standby.value=!1,this._publisherContext.stream.value&&this._publisherContext.endPoint.value&&this._publisherContext.endPoint.value.destroyStream(this._publisherContext.stream.value,t).then(function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)}).catch(function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)}),this._publisherContext.stream.value=null,this._publisherContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}}]);var e,n,r,i,a}(),Gn=function(){return o()(function e(){throw t()(this,e),new Error("Publishers is a static class that may not be instantiated")},null,[{key:"createPublisher",value:function(e){if(!Ve.initialized.value)throw new Error("SDK is not loaded.");return new Vn(e.mediaStream,e.token,e.name)}}])}(),Bn={SDK:Ve,Channels:Cn,ChannelState:Ne,Publishers:Gn,PublisherState:Sn}})(),r})());
|
|
3
3
|
//# sourceMappingURL=full.js.map
|