@phenixrts/sdk 2025.2.4-beta.727 → 2025.2.4-beta.729

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/channels/debug/channels.js +348 -13
  2. package/channels/debug/package.json +1 -1
  3. package/channels/debug.private/channels.js +122 -13
  4. package/channels/debug.private/package.json +1 -1
  5. package/channels/debug.provideGlobalScope/channels.js +348 -13
  6. package/channels/debug.provideGlobalScope/package.json +1 -1
  7. package/channels/es5.debug.private/channels.js +122 -13
  8. package/channels/es5.debug.private/package.json +1 -1
  9. package/channels/min/channels.js +1 -1
  10. package/channels/min/channels.js.map +1 -1
  11. package/channels/min/package.json +1 -1
  12. package/channels/min.private/channels.js +1 -1
  13. package/channels/min.private/channels.js.map +1 -1
  14. package/channels/min.private/package.json +1 -1
  15. package/channels/min.provideGlobalScope/channels.js +1 -1
  16. package/channels/min.provideGlobalScope/channels.js.map +1 -1
  17. package/channels/min.provideGlobalScope/package.json +1 -1
  18. package/channels/package.json +1 -1
  19. package/full/debug/full.js +348 -13
  20. package/full/debug/package.json +1 -1
  21. package/full/debug.private/full.js +122 -13
  22. package/full/debug.private/package.json +1 -1
  23. package/full/min/full.js +1 -1
  24. package/full/min/full.js.map +1 -1
  25. package/full/min/package.json +1 -1
  26. package/full/min.private/full.js +1 -1
  27. package/full/min.private/full.js.map +1 -1
  28. package/full/min.private/package.json +1 -1
  29. package/full/package.json +1 -1
  30. package/package.json +1 -1
  31. package/publish/debug/package.json +1 -1
  32. package/publish/debug/publish.js +1 -1
  33. package/publish/debug.private/package.json +1 -1
  34. package/publish/debug.private/publish.js +1 -1
  35. package/publish/min/package.json +1 -1
  36. package/publish/min/publish.js +1 -1
  37. package/publish/min.private/package.json +1 -1
  38. package/publish/min.private/publish.js +1 -1
  39. package/publish/package.json +1 -1
  40. package/types/sdk/streaming/ChunkedAudioTrackSelector.d.ts +22 -0
  41. package/types/sdk/streaming/ChunkedStreamSubscriber.d.ts +3 -0
  42. package/types/sdk/streaming/IShakaPlayer.d.ts +14 -0
  43. package/types/sdk/streaming/IStreamSubscriber.d.ts +1 -0
  44. package/types/sdk/streaming/ShakaPlayer.d.ts +19 -1
package/full/min/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),l=n(693),c=n.n(l),d=u()(function e(t,n,r){a()(this,e),c()(this,"onFulfilled",void 0),c()(this,"onRejected",void 0),c()(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),c()(this,"_state",void 0),c()(this,"_handled",void 0),c()(this,"_value",void 0),c()(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),l=u.value}catch(e){return void n(e)}u.done?t(l):r.resolve(l).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},646:(e,t,n)=>{var r=n(550),i=n(636);e.exports=function(e,t,n){if(r())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,t);var a=new(e.bind.apply(e,o));return n&&i(a,n.prototype),a},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},892:(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},691:e=>{e.exports=function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}},e.exports.__esModule=!0,e.exports.default=e.exports},550:e=>{function t(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(n){}return(e.exports=t=function(){return!!n},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=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,l=!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){l=!0,i=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)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},837:(e,t,n)=>{var r=n(72),i=n(636),o=n(691),a=n(646);function s(t){var n="function"==typeof Map?new Map:void 0;return e.exports=s=function(e){if(null===e||!o(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,t)}function t(){return a(e,arguments,r(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),i(t,e)},e.exports.__esModule=!0,e.exports.default=e.exports,s(t)}e.exports=s,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:()=>ze,Channels:()=>Wr,PublisherState:()=>Jr,Publishers:()=>li,ReplayState:()=>Xn,SDK:()=>Be,default:()=>ci});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),l=n.n(u),c=n(452),d=n.n(c),h=n(72),f=n.n(h),p=n(892),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=l()(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},w=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:"AbortController",get:function(){return this._window.AbortController}},{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:"sendBeacon",get:function(){var e=this;return this._navigator.sendBeacon?function(t,n){return e._navigator.sendBeacon(t,void 0===n?null:n)}:void 0}},{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=w,s()(w,"_instance",new b(new y(k))),s()(w,"_readOnlyInstance",new C(y._instance));var S,T,x,E=w.getInstance(),R=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""}}])}();S=R,s()(R,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),s()(R,"_browserNameAndVersion",S.parseBrowserNameAndVersion()),s()(R,"_browserName",S.parseBrowserName()),s()(R,"_browserMajorVersion",S.parseBrowserMajorVersion()),s()(R,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(T=navigator)||void 0===T?void 0:T.userAgent)),s()(R,"_isAndroid",/Android/i.test(null===(x=navigator)||void 0===x?void 0:x.userAgent)),s()(R,"_isChrome69",S._browserNameAndVersion.includes("Chrome/69.")),s()(R,"_isChrome70",S._browserNameAndVersion.includes("Chrome/70.")),s()(R,"_isChrome71",S._browserNameAndVersion.includes("Chrome/71.")),s()(R,"_isChrome72",S._browserNameAndVersion.includes("Chrome/72.")),s()(R,"_isChrome74",S._browserNameAndVersion.includes("Chrome/74.")),s()(R,"_isChrome75",S._browserNameAndVersion.includes("Chrome/75.")),s()(R,"_isChrome76",S._browserNameAndVersion.includes("Chrome/76.")),s()(R,"_isChrome77",S._browserNameAndVersion.includes("Chrome/77."));var O=function(){function e(){t()(this,e)}return o()(e,null,[{key:"clientOfferDisabled",get:function(){return R.isChrome74||R.isChrome75||R.isChrome76||R.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return R.isChrome69||R.isChrome70||R.isChrome71||R.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===R.browserName&&R.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===R.browserName&&R.browserMajorVersion<=69||"Firefox"===R.browserName&&R.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===R.browserName&&R.browserMajorVersion<=63||"Firefox"===R.browserName&&R.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===R.browserName&&R.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===R.browserName&&R.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===R.browserName||"SamsungBrowser"===R.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==R.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===R.browserName&&"function"==typeof(null===(e=E.value)||void 0===e?void 0:e.documentCreateElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===R.browserName&&R.browserMajorVersion>=71||"Firefox"===R.browserName&&R.browserMajorVersion>=69||"Safari"===R.browserName}},{key:"isMobile",get:function(){return R.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:"isProtectedChannelSupported",get:function(){return"Firefox"!==R.browserName&&"Safari"!==R.browserName}},{key:"isRequestVideoFrameCallbackSupported",get:function(){var e;return void 0!==(null===(e=E.value)||void 0===e?void 0:e.HTMLVideoElement.prototype.requestVideoFrameCallback)}},{key:"isRequestAnimationFrameSupported",get:function(){var e;return"function"==typeof(null===(e=E.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"!==R.browserName&&"Safari"!==R.browserName}}])}(),P=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>P.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.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},[])}}])}(),A=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:!0,sendLogs:"All",sendMetrics:"All",logToConsole:"All"};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()(A,"_sendLocalCandidates",void 0),s()(A,"_sendLogs",void 0),s()(A,"_sendMetrics",void 0),s()(A,"_logToConsole",void 0),A.applyFeatures();var L=function(){return o()(function e(){t()(this,e)},null,[{key:"defaultLoggingLevel",get:function(){return P[A.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return P[A.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return P.Info}}])}(),D=function(){return o()(function e(){t()(this,e),s()(this,"_threshold",L.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(P[e],"] ").concat(t);e<P.Warn?console.log(i):console.error(i)}}}])}(),M=n(293),N=n.n(M),V=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-12-01T02:48:11.672Z (2025.2.4-beta.727)"}catch(e){return this._defaultVersion}}}])}();s()(B,"_defaultVersion",(new Date).toISOString());var G=n(981).A;function U(){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,l=Object.create(u.prototype);return z(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(z(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,z(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,z(d,"constructor",l),z(l,"constructor",u),u.displayName="GeneratorFunction",z(l,i,"GeneratorFunction"),z(d),z(d,i,"Generator"),z(d,r,function(){return this}),z(d,"toString",function(){return"[object Generator]"}),(U=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:P[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:B.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<P.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new G(function(e){var t=E.subscribe(function(n){n&&(e(n.locationHostname),n.setTimeout(function(){return t.dispose()},0))})})}},{key:"sendLogs",value:(n=N()(U().m(function e(t){var n;return U().w(function(e){for(;;)switch(e.n){case 0:return(n=new E.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.n=1,E.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=N()(U().m(function e(){var t,n,r,i,o,a=this;return U().w(function(e){for(;;)switch(e.n){case 0:if(!(this._logs.length<=0||this._isSending)&&E.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?V.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}(),W=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)}}])}(),q=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",L.defaultTelemetryLoggingLevel)},[{key:"url",get:function(){return this._url},set:function(e){var t=new E.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(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},K=function(){return o()(function e(){t()(this,e)},null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case P.Off:return"Off";case P.Trace:return"Trace";case P.Debug:return"Debug";case P.Info:return"Info";case P.Warn:return"Warn";case P.Error:return"Error";case P.Fatal:return"Fatal";case P.All:return"All";default:J(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return P.Off;case"Trace":return P.Trace;case"Debug":return P.Debug;case"Info":return P.Info;case"Warn":return P.Warn;case"Error":return P.Error;case"Fatal":return P.Fatal;case"All":return P.All;default:J(e)}}}])}(),Z=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),$=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",Q.defaultTelemetryLevel)},[{key:"url",get:function(){return this._url},set:function(e){var t=new E.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}}])}(),Q=function(){return o()(function e(){t()(this,e)},null,[{key:"defaultTelemetryLevel",get:function(){return Z[A.sendMetrics]}}])}(),Y=function(){return o()(function e(){t()(this,e)},null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case Z.Off:return"Off";case Z.Essential:return"Essential";case Z.All:return"All";default:J(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return Z.Off;case"Essential":return Z.Essential;case"All":return Z.All;default:J(e)}}}])}(),X=function(){function e(){t()(this,e)}return o()(e,null,[{key:"getStringValue",value:function(t){return e.readConfigurationParameterValue(t)||e.readConfigurationParameterURIValue("".concat(t,"-uri-parameter-name"))||e.defaultStringValue[t]}},{key:"getBooleanValue",value:function(t){var n=e.readConfigurationParameterValue(t);if(n)return"true"===n||"1"===n||"On"===n;var r=e.readConfigurationParameterURIValue("".concat(t,"-uri-parameter-name"));return r?"true"===r||"1"===r||"On"===r:!0===e.defaultBooleanValue[t]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":Y.convertTelemetryLevelToTelemetryLevelType(Q.defaultTelemetryLevel),"phenix-logging-level":K.convertLoggingLevelToLoggingLevelType(L.defaultLoggingLevel),"phenix-console-logging-level":K.convertLoggingLevelToLoggingLevelType(L.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":K.convertLoggingLevelToLoggingLevelType(L.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}}},{key:"readConfigurationParameterValue",value:function(e){var t=E.value.documentQuerySelector("meta[name='".concat(e,"']"));if(t){var n=t.getAttribute("value");if(n)return n}}},{key:"readConfigurationParameterURIValue",value:function(t){var n=e.readConfigurationParameterValue(t);if(n){var r=new E.value.URLSearchParams(E.value.locationSearch).get(n)||void 0;if(r)return r}}}])}(),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=X.getStringValue("phenix-logging-level");P[e]&&this._threshold.setThreshold(P[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=X.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(P[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new j(e||L.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||L.defaultTelemetryLoggingLevel,this._appenders.add(new W(this._telemetryConfiguration))}}])}();s()(ee,"_loggers",{}),s()(ee,"_appenders",new I),s()(ee,"_threshold",new D),s()(ee,"_telemetryConfiguration",new q),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 E.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=!E.value.documentIsHidden;n?t&&(e._lastBackgroundDuration=Date.now()-t):(t=Date.now(),e._lastBackgroundDuration=null),e._isForeground.value=n},r=!1;E.value.addDocumentEventListener(oe,n,r),this._disposables.add(new m(function(){return E.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,l=Object.create(u.prototype);return le(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(le(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,le(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,le(d,"constructor",l),le(l,"constructor",u),u.displayName="GeneratorFunction",le(l,i,"GeneratorFunction"),le(d),le(d,i,"Generator"),le(d,r,function(){return this}),le(d,"toString",function(){return"[object Generator]"}),(ue=function(){return{w:o,m:h}})()}function le(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}le=function(e,t,n,r){function o(t,n){le(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))},le(e,t,n,r)}var ce=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 E.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=N()(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=N()(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=N()(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=N()(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,l=Object.create(u.prototype);return fe(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(fe(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,fe(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,fe(d,"constructor",l),fe(l,"constructor",u),u.displayName="GeneratorFunction",fe(l,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=N()(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=E.subscribe(function(r){r&&(e(new ce(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,l=Object.create(u.prototype);return me(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(me(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,me(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,me(d,"constructor",l),me(l,"constructor",u),u.displayName="GeneratorFunction",me(l,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=N()(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=N()(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=N()(ve().m(function e(t){var i,o,a,s,u,l,c,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,l=a,c=t,e.n=1,t.createOffer(void 0);case 1:return d=e.v,e.a(2,{audioTransceivers:u,videoTransceivers:l,peerConnection:c,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 E.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 E.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 we="/pcast/endPoints",Se=function(){return o()(function e(){throw t()(this,e),new Error("PcastUri is a static class that may not be instantiated")},null,[{key:"discoveryPath",get:function(){return we}},{key:"normalizeDiscoveryUri",value:function(e){var t=new E.value.URL(e.toString());return""!==t.pathname&&"/"!==t.pathname||(t.pathname=we),t.search="",t.hash="",t}},{key:"buildRouteUrl",value:function(e,t){var n=new E.value.URL(e.toString()),r=n.pathname.split("/");return r.length=r.length-1,n.pathname=r.concat.apply(r,l()(t)).join("/"),n}}])}(),Te=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 E.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=Se.discoveryPath),t.toString()}}])}();s()(Te,"_discoveryUri",new b("https://pcast.phenixrts.com/pcast/endPoints"));var xe=n(738),Ee=n.n(xe),Re=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)}}])}(),Oe=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}(Oe||{}),Pe=Oe,Fe=function(){return o()(function e(n){t()(this,e),s()(this,"_metrics",void 0),this._metrics=n},[{key:"getName",value:function(){return Pe[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case Pe.TimeToFirstFrame:case Pe.ChannelCreationTimeToFirstFrame:return Z.Essential;case Pe.Stalled:case Pe.Buffering:case Pe.SetupCompleted:case Pe.SetupFailed:case Pe.RoundTripTime:case Pe.DownlinkThroughputCapacity:case Pe.NetworkType:case Pe.ResolutionChanged:case Pe.ApplicationForeground:case Pe.ApplicationBackground:return Z.All;default:J(this._metrics)}}}])}(),Ie=n(981).A;function Ae(){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,l=Object.create(u.prototype);return Le(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Le(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Le(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Le(d,"constructor",l),Le(l,"constructor",u),u.displayName="GeneratorFunction",Le(l,i,"GeneratorFunction"),Le(d),Le(d,i,"Generator"),Le(d,r,function(){return this}),Le(d,"toString",function(){return"[object Generator]"}),(Ae=function(){return{w:o,m:h}})()}function Le(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Le=function(e,t,n,r){function o(t,n){Le(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))},Le(e,t,n,r)}var De,je,Me=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 Re,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 Fe(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 Ie(function(e){var t=E.subscribe(function(n){n&&(e(n.locationHostname),n.setTimeout(function(){return t.dispose()},0))})})}},{key:"sendMetrics",value:(n=N()(Ae().m(function e(t){var n;return Ae().w(function(e){for(;;)switch(e.n){case 0:return(n=new E.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.n=1,E.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=N()(Ae().m(function e(){var t,n=this;return Ae().w(function(e){for(;;)switch(e.n){case 0:if(!(this._metrics.length<=0||this._isSending)&&E.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 E.value.setTimeout(function(){n._metrics=[].concat(l()(t),l()(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}(),Ne=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(Ee()(t),"]"));var n=e._metricsServices[t];if(n)return n;var r=new $;return r.sessionId=Be.clientSessionId,r.tenancy=Be.tenancy.value,r.url=be.getTelemetryUrl(t),r.environment=Ce.getEnvironmentFromUrl(t),r.threshold=Y.convertTelemetryLevelTypeToTelemetryLevel(Be.telemetryLevel),e._metricsServices[t]=new Me(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach(function(e){e.metricsConfiguration.threshold=t})}}])}();s()(Ne,"_metricsServices",{});var Ve=(null===(De=w.getInstance().value)||void 0===De?void 0:De.pageLoadTime)||Date.now(),Be=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 Ve}},{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 K.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return Y.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return R}},{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 W});r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new W(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 W});r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new W(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))})}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=Ne.getMetricsService(Te.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=X.getStringValue("phenix-metrics-level");t&&Ne.setTelemetryLevel(Z[t]),e._telemetryLevel.subscribe(function(e){Ne.setTelemetryLevel(e)})}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=X.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=X.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=X.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=X.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=X.getStringValue("phenix-channel-token");if(t){var n=re.parseToken(t);return e._tenancy.value=n.tenancy,Te.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=X.getStringValue("phenix-uri");if(r)return Te.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=X.getStringValue("phenix-base-uri");if(i){var o=new(w.getInstance().value.URL)(i);return o.pathname="/pcast/endPoints",Te.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&&w.setInstance(n.globalScope),t.discoveryUri&&(Te.uri.value=t.discoveryUri),t.peerConnectionFactory&&(_e.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&Z[t.telemetryLevel]&&(e._telemetryLevel.value=Y.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&P[t.loggingLevel]&&this._logger.threshold.setThreshold(K.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&P[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(K.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)}}])}();je=Be,s()(Be,"_automaticallyRetryOnFailure",X.getBooleanValue("phenix-automatically-retry-on-failure")),s()(Be,"_automaticallyReconnectPeerConnection",X.getBooleanValue("phenix-automatically-reconnect-peer-connection")),s()(Be,"_automaticallyPlayMediaStream",!0),s()(Be,"_automaticallyMuteVideoOnPlayFailure",!0),s()(Be,"_forceGarbageCollectionOnRestart",X.getBooleanValue("phenix-force-garbage-collection-on-restart")),s()(Be,"_skipGarbageCollectionOnMobileDevices",X.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices")),s()(Be,"_webPlayerLoader",void 0),s()(Be,"_shakaPlayerLoader",void 0),s()(Be,"_hlsJsLoader",void 0),s()(Be,"_applicationActivityMonitor",void 0),s()(Be,"_environment",new b("")),s()(Be,"_telemetryUrl",new b("https://telemetry.phenixrts.com/telemetry")),s()(Be,"_maximalNumberOfPeerConnectionReconnectAttempts",8),s()(Be,"_telemetryLevel",new b(Q.defaultTelemetryLevel)),s()(Be,"_metricsService",void 0),s()(Be,"_metricsConfiguration",void 0),s()(Be,"_sendLocalCandidates",new b(A.sendLocalCandidates)),s()(Be,"_tenancy",new b("")),s()(Be,"_clientSessionId",te.random(32)),s()(Be,"_loadedTimestamp",new Date),s()(Be,"_logger",ee.getLogger("SDK")),s()(Be,"_initialized",new b(!1)),s()(Be,"_readOnlyInitialized",new C(je._initialized)),s()(Be,"_readOnlyDiscoveryUri",new C(Te.uri)),s()(Be,"_readOnlyPeerConnectionFactory",new C(_e.peerConnectionFactory)),w.subscribe(Be.onLoad.bind(Be));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)}}])}(),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||{}),ze=Ue,He=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)}}])}(),We=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",We),s()(this,"_listenForStall",We),s()(this,"_listenForContinuation",We),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 He(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:Pe.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 He(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:Pe.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 He(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:Pe.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:Pe.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 He(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:Pe.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}}])}(),Je=function(){return o()(function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("StreamSetupListener")),s()(this,"metricsService",Be.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(Pe.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(Pe.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new Fe(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 He(n-this._pageLoadTime).toIsoString(),t,i,new He(r).toIsoString())}}}])}(),Ke=function(){return o()(function e(){t()(this,e),s()(this,"_disposables",new ie),s()(this,"_isSupported",void 0!==E.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=E.value.navigatorConnection)||void 0===n?void 0:n.downlink)&&void 0!==t?t:null===(r=E.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=E.value.navigatorConnection)||void 0===n?void 0:n.effectiveType)&&void 0!==t?t:null===(r=E.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=E.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=E.value.navigatorConnection)||void 0===e||e.addEventListener("change",n),this._disposables.add(new m(function(){var e;return null===(e=E.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()}}])}(),Ze=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",Be.applicationActivityMonitor),s()(this,"_networkMonitor",new Ke),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 Je(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?Pe.ApplicationForeground:Pe.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 He(r).toIsoString()))}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:Pe.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 He(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:Pe.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 He(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:Pe.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 He(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),$e=function(){return o()(function e(){t()(this,e)},null,[{key:"applyToMediaStream",value:function(e,t,n,r){var i=!1;return e.forEach(function(e){var o,a=e.receiver.track;if("audio"===a.kind){var s=e.mid===t,u=null!==(o=r.get(a))&&void 0!==o?o:a;a.enabled=s;var l=n.getAudioTracks().some(function(e){return e.id===u.id});s&&!l?(n.addTrack(u),i=!0):!s&&l&&(n.removeTrack(u),i=!0)}}),i}}])}(),Qe=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Ye=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),Xe=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)}),et=function(){function e(){t()(this,e)}return o()(e,null,[{key:"orderByRequestedLanguages",value:function(t,n){var r=l()(t).sort(function(e,t){return e.sourceIndex-t.sourceIndex}),i=[];return n.forEach(function(t){var n=e.findMatch(r,t);n&&(i.push(n),r.splice(r.indexOf(n),1))}),[].concat(l()(i),l()(r))}},{key:"findSectionToPlay",value:function(e,t){var n,r,i,o=null==t||null===(n=t.language)||void 0===n?void 0:n.toLowerCase(),a=t?e.find(function(e){var n;return String(e.sourceIndex)===t.id&&(null===(n=e.language)||void 0===n?void 0:n.toLowerCase())===o}):void 0,s=o?e.find(function(e){var t;return(null===(t=e.language)||void 0===t?void 0:t.toLowerCase())===o}):void 0;return null!==(r=null!==(i=null!=a?a:s)&&void 0!==i?i:e[0])&&void 0!==r?r:null}},{key:"findMatch",value:function(t,n){for(var r,i=function(){var e=o.toLowerCase(),n=t.find(function(t){var n;return(null===(n=t.language)||void 0===n?void 0:n.toLowerCase())===e});if(n)return{v:n}},o=n;o;o=e.truncate(o))if(r=i())return r.v;var a="".concat(n.toLowerCase(),"-");return t.find(function(e){var t;return null===(t=e.language)||void 0===t?void 0:t.toLowerCase().startsWith(a)})}},{key:"truncate",value:function(e){var t=e.lastIndexOf("-");if(t<0)return null;var n=e.slice(0,t),r=n.lastIndexOf("-");return r>=0&&r+2===n.length?n.slice(0,r):n}}])}(),tt=function(){return o()(function e(n){var r,i,o,a,u;t()(this,e),s()(this,"maxAudioTracks",void 0),s()(this,"audioLanguages",void 0),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,"audioSections",void 0),s()(this,"audioTracks",void 0),s()(this,"selectedAudioMid",void 0),s()(this,"selectedAudioTrack",void 0),s()(this,"requestedAudioTrack",void 0),s()(this,"videoTelemetry",void 0),s()(this,"rtcAudioStatistic",void 0),s()(this,"rtcVideoStatistic",void 0),s()(this,"clearFailureCountTimeout",void 0);var c=null!==(r=null==n?void 0:n.maxAudioTracks)&&void 0!==r?r:1;if(!Number.isSafeInteger(c)||c<1)throw new Error("Invalid maximum audio track count [".concat(c,"]"));var d=null!==(i=null==n?void 0:n.audioLanguages)&&void 0!==i?i:[];e.assertValidAudioLanguages(d,c),this.maxAudioTracks=c,this.audioLanguages=l()(d),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(ze.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!==(o=null==n?void 0:n.targetLag)&&void 0!==o?o: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!==(a=null==n?void 0:n.onRealTimeSubscribeRequestCallback)&&void 0!==a?a:null,this.onRealTimeSubscribeResponseCallback=null!==(u=null==n?void 0:n.onRealTimeSubscribeResponseCallback)&&void 0!==u?u:null,this.stream=new b(null),this.rtcStatistics=new b(null),this.audioSections=new b([]),this.audioTracks=new b([]),this.selectedAudioMid=new b(null),this.selectedAudioTrack=new b(null),this.requestedAudioTrack=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:"setAudioSections",value:function(e){var t=et.orderByRequestedLanguages(e,this.audioLanguages);this.audioSections.value=t,this.audioTracks.value=t.map(function(e){return{id:String(e.sourceIndex),language:e.language}})}},{key:"findAudioMidsToAccept",value:function(e,t){return e.slice(0,this.findMaxAudioTracks(t)).map(function(e){return e.mid})}},{key:"findMaxAudioTracks",value:function(e){return e===ge.Enabled?1:this.maxAudioTracks}},{key:"findAudioSection",value:function(e){return this.audioSections.value.find(function(t){return String(t.sourceIndex)===e})}},{key:"findAudioSectionToPlay",value:function(){return et.findSectionToPlay(this.audioSections.value,this.requestedAudioTrack)}},{key:"setSelectedAudioSection",value:function(e){var t,n,r,i=e?this.audioSections.value.findIndex(function(t){return t.sourceIndex===e.sourceIndex}):-1;this.selectedAudioMid.value=null!==(t=null===(n=this.audioSections.value[i])||void 0===n?void 0:n.mid)&&void 0!==t?t:null,this.selectedAudioTrack.value=null!==(r=this.audioTracks.value[i])&&void 0!==r?r:null}},{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=Be.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return ze.Starting;case"no-stream":case"not-found":return ze.StandBy;case"geo-restricted":return ze.GeoRestricted;case"geo-blocked":return ze.GeoBlocked;case"unauthorized":return ze.Unauthorized;case"capacity":case"rate-limited":case"timeout":return ze.Recovering;case"forbidden-tag":return ze.ConfigurationError;case"port-in-range-not-found":return ze.TransientConfigurationError;case"failed":return ze.Error;default:J(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:J(e)}}}],[{key:"assertValidAudioLanguages",value:function(e,t){var n=/^[A-Za-z0-9]+(-[A-Za-z0-9]+)*$/;if(e.length>t||e.some(function(e){return!n.test(e)}))throw new Error("Invalid requested audio languages [".concat(JSON.stringify(e),"]. Maximum [").concat(t,"]"))}}])}(),nt=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(Ee()(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"}}}])}(),rt=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(Ee()(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"}}}])}(),it=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:[]}}),ot=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.isMobile&&Be.skipGarbageCollectionOnMobileDevices||O.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){O.isQueueMicrotaskSupported?E.value.queueMicrotask(this.overloadMemoryToInvokeGarbageCollection.bind(this)):E.value.setTimeout(this.overloadMemoryToInvokeGarbageCollection.bind(this),0)}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=E.value.documentCreateElement("img");e.src=E.value.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){E.value.URL.revokeObjectURL(this.src),e=null}}}])}(),at=function(){return o()(function e(n){t()(this,e),s()(this,"_forceGarbageCollectionOnRestart",void 0),s()(this,"mediaStream",void 0),s()(this,"peerConnection",void 0),s()(this,"peerConnectionReconnectAttempts",void 0),s()(this,"renderedTracks",void 0),this._forceGarbageCollectionOnRestart=n.forceGarbageCollectionOnRestart,this.mediaStream=new b(null),this.peerConnection=new b(null),this.peerConnectionReconnectAttempts=0,this.renderedTracks=new Map},[{key:"disposePeerConnection",value:function(){var e=this.peerConnection.value;e&&(this.peerConnection.value=null,e.close(),e.dispose(),this._forceGarbageCollectionOnRestart&&ot.forceGarbageCollection())}},{key:"disposeMediaStream",value:function(){var e;null===(e=this.mediaStream.value)||void 0===e||e.getTracks().forEach(function(e){return e.stop()}),this.mediaStream.value=null,this.renderedTracks=new Map}}])}(),st=o()(function e(){t()(this,e),s()(this,"isStarting",void 0),s()(this,"isDisposed",void 0),this.isStarting=new b(!1),this.isDisposed=!1}),ut=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)}),lt=n(847),ct=n.n(lt),dt=n(837),ht=n.n(dt),ft=function(){return o()(function e(){t()(this,e)},null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Ye.Normal:return"Normal";case Ye.Force:return"Force";case Ye.Reset:return"Reset";default:J(e)}}}])}(),pt=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:J(e)}}}])}(),vt=n(981).A,mt=["status","streamId","sharedSecret","lag","rtcConfiguration","setRemoteDescriptionResponse","createAnswerDescriptionResponse","createOfferDescriptionResponse","streamResponseContext"];function gt(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 yt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?gt(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _t(){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,l=Object.create(u.prototype);return bt(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(bt(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,bt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,bt(d,"constructor",l),bt(l,"constructor",u),u.displayName="GeneratorFunction",bt(l,i,"GeneratorFunction"),bt(d),bt(d,i,"Generator"),bt(d,r,function(){return this}),bt(d,"toString",function(){return"[object Generator]"}),(_t=function(){return{w:o,m:h}})()}function bt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}bt=function(e,t,n,r){function o(t,n){bt(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))},bt(e,t,n,r)}function Ct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Ct=function(){return!!e})()}var kt=function(e){function n(){return t()(this,n),e=this,r=n,i=arguments,r=f()(r),d()(e,Ct()?Reflect.construct(r,i||[],f()(e).constructor):r.apply(e,i));var e,r,i}return v()(n,e),o()(n)}(ht()(Error)),wt=function(){return o()(function e(n,r){if(t()(this,e),s()(this,"_logger",ee.getLogger("EndPoint")),s()(this,"_uri",void 0),s()(this,"_timeoutDuration",void 0),s()(this,"_roundTripTime",0),this._uri=n,this._timeoutDuration=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:(g=N()(_t().m(function e(){var t,n,r,i;return _t().w(function(e){for(;;)switch(e.n){case 0:return t=this.buildPingUrl(),n=Date.now(),r={method:"GET",cache:"no-cache"},e.n=1,this.fetchWithTimeout(t,r,this._timeoutDuration).catch(function(e){if(e instanceof kt)throw new Error("Ping timed out [".concat(t,"]"));throw e});case 1:if((i=e.v).ok){e.n=2;break}throw new Error("Ping failed [".concat(t,"] [").concat(i.status,"]"));case 2:return this._roundTripTime=Date.now()-n,e.a(2,this._roundTripTime)}},e,this)})),function(){return g.apply(this,arguments)})},{key:"subscribe",value:(m=N()(_t().m(function e(t,n,r){var i,o,a,s,u,c,d,h,f,p,v,m,g,y,_,b,C,k,w,S,T,x=arguments;return _t().w(function(e){for(;;)switch(e.n){case 0:if(a=x.length>3&&void 0!==x[3]?x[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 E.value.FormData,d=B.sdkVersion,0===r&&n?h={apiVersion:7,clientVersion:d,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:7,sessionDescription:{type:n.type,sdp:n.sdp}},createAnswerDescription:{apiVersion:7}}:(p=[].concat(l()(a.maxAudioTracks?["max-audio-tracks=".concat(a.maxAudioTracks)]:[]),l()(null!==(f=a.audioLanguages)&&void 0!==f&&f.length?["audio-languages=".concat(a.audioLanguages.join(","))]:[])),h={apiVersion:7,clientVersion:d,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:7,options:p.length?p:void 0}}),e.n=2,null===(i=a.onSubscribeRequestCallback)||void 0===i?void 0:i.call(a,h);case 2:return c.append("jsonBody",JSON.stringify(h)),v=Date.now(),m={method:"POST",body:c},e.n=3,this.executeFetchRequest(u,m,"subscribe");case 3:return g=e.v,e.n=4,this.parseJsonBody(g);case 4:if(y=e.v,this.handleStreamResponseContext(null==y?void 0:y.streamResponseContext),"ok"===(_=this.mapHttpStatusToSubscribeStatus(g))){e.n=6;break}return C={status:_},e.n=5,null===(b=a.onSubscribeResponseCallback)||void 0===b?void 0:b.call(a,C);case 5:return e.a(2,C);case 6:if(y){e.n=8;break}return w={status:"failed"},e.n=7,null===(k=a.onSubscribeResponseCallback)||void 0===k?void 0:k.call(a,w);case 7:return e.a(2,w);case 8:return S=Date.now(),T=this.normalizeSubscribeResponse(s,y),this._logger.debug("Got subscribe response [%j] in [%s] ms",T,S-v),e.n=9,null===(o=a.onSubscribeResponseCallback)||void 0===o?void 0:o.call(a,T);case 9:return e.a(2,T)}},e,this)})),function(e,t,n){return m.apply(this,arguments)})},{key:"publish",value:(v=N()(_t().m(function e(t,n,r,i){var o,a,s,u,l,c,d,h,f,p,v,m,g;return _t().w(function(e){for(;;)switch(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 E.value.FormData,u=B.sdkVersion,0===i&&r?(l={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(l))):(c={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(c))),d=Date.now(),h={method:"POST",body:s},e.n=2,this.executeFetchRequest(a,h,"publish");case 2:return f=e.v,e.n=3,this.parseJsonBody(f);case 3:if(p=e.v,this.handleStreamResponseContext(null==p?void 0:p.streamResponseContext),"ok"===(v=this.mapHttpStatusToPublishStatus(f))){e.n=4;break}return e.a(2,{status:v});case 4:if(p){e.n=5;break}return e.a(2,{status:"failed"});case 5:return m=Date.now(),g=this.normalizePublishResponse(o,p),this._logger.debug("Got publish response [%j] in [%s] ms",g,m-d),e.a(2,g)}},e,this)})),function(e,t,n,r){return v.apply(this,arguments)})},{key:"setRemoteDescription",value:(p=N()(_t().m(function e(t,n){var r,i,o,a,s,u,l,c,d;return _t().w(function(e){for(;;)switch(e.n){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new E.value.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,sessionDescription:{type:n.type,sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),s={method:"POST",body:i},e.n=1,this.executeFetchRequest(r,s,"set remote description");case 1:if(u=e.v,"ok"===(l=this.mapHttpStatusToSetRemoteDescriptionStatus(u))){e.n=2;break}return e.a(2,{status:l});case 2:return c=Date.now(),e.n=3,this.convertHttpResponseToSetRemoteDescription(u);case 3:return d=e.v,this._logger.debug("Got set remote description response [%j] in [%s] ms",d,c-a),e.a(2,d)}},e,this)})),function(e,t){return p.apply(this,arguments)})},{key:"limitBitrate",value:(f=N()(_t().m(function e(t,n,r,i,o){var a,s,u,l,c,d,h,f;return _t().w(function(e){for(;;)switch(e.n){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new E.value.FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:pt.convertBitrateStateToBitrateStateType(i),bitrateMode:ft.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),l=Date.now(),c={method:"POST",body:s},e.n=1,this.executeFetchRequest(a,c,"set limit bitrate");case 1:return d=e.v,h=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(d),f=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",h,f-l),e.a(2,{status:h})}},e,this)})),function(e,t,n,r,i){return f.apply(this,arguments)})},{key:"addIceCandidates",value:(h=N()(_t().m(function e(t,n,r){var i,o,a,s,u,l,c,d,h,f,p=arguments;return _t().w(function(e){for(;;)switch(e.n){case 0:return i=p.length>3&&void 0!==p[3]?p[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),a=new E.value.FormData,s={apiVersion:7,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},a.append("jsonBody",JSON.stringify(s)),u=Date.now(),l={method:"POST",body:a},e.n=1,this.executeFetchRequest(o,l,"add ice candidates");case 1:if(c=e.v,"ok"===(d=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.n=2;break}return e.a(2,{status:d});case 2:return h=Date.now(),e.n=3,this.convertHttpResponseToAddIceCandidates(c);case 3: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)})),function(e,t,n){return h.apply(this,arguments)})},{key:"destroyStream",value:(d=N()(_t().m(function e(t,n){var r,i,o,a,s,u,l,c,d;return _t().w(function(e){for(;;)switch(e.n){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new E.value.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},a={method:"POST",body:i,cache:"no-cache"},i.append("jsonBody",JSON.stringify(o)),s=Date.now(),e.n=1,this.executeFetchRequest(r,a,"destroy stream");case 1:if(u=e.v,"ok"===(l=this.mapHttpStatusToSetDestroyStreamStatus(u))){e.n=2;break}return e.a(2,{status:l});case 2:return c=Date.now(),e.n=3,this.convertHttpResponseToDestroyStream(u);case 3:return d=e.v,this._logger.info("Got destroy stream response [%j] in [%s] ms",d,c-s),e.a(2,d)}},e,this)})),function(e,t){return d.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(c=N()(_t().m(function e(t,n){var r,i,o,a,s=this;return _t().w(function(e){for(;;)switch(e.n){case 0:if(r=E.value.sendBeacon){e.n=1;break}return this.destroyStream(t,n).catch(function(e){s._logger.error("Failed to destroy stream on unmount",e)}),e.a(2);case 1:i=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),o=new E.value.FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},o.append("jsonBody",JSON.stringify(a)),r(i,o);case 2:return e.a(2)}},e,this)})),function(e,t){return c.apply(this,arguments)})},{key:"fetchWithTimeout",value:(u=N()(_t().m(function e(t,n,r){var i,o;return _t().w(function(e){for(;;)switch(e.p=e.n){case 0:return i=new E.value.AbortController,o=null,e.p=1,e.n=2,vt.race([E.value.fetch(t,yt(yt({},n),{},{signal:i.signal})),new vt(function(e,n){o=E.value.setTimeout(function(){i.abort(),n(new kt("Timed out [".concat(t,"]")))},r)})]);case 2:return e.a(2,e.v);case 3:return e.p=3,o&&E.value.clearTimeout(o),e.f(3);case 4:return e.a(2)}},e,null,[[1,,3,4]])})),function(e,t,n){return u.apply(this,arguments)})},{key:"executeFetchRequest",value:(a=N()(_t().m(function e(t,n,r){var i;return _t().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,this.fetchWithTimeout(t,n,this._timeoutDuration);case 1:return e.a(2,e.v);case 2:return e.p=2,i=e.v,this._logger.error("Failed to ".concat(r," [").concat(n.method||"GET","] [").concat(t,"]"),i),e.a(2,{status:i instanceof kt?408:500})}},e,this,[[0,2]])})),function(e,t,n){return a.apply(this,arguments)})},{key:"buildUrl",value:function(e){return Se.buildRouteUrl(this._uri,e)}},{key:"buildPingUrl",value:function(){var e=new E.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:"parseJsonBody",value:(i=N()(_t().m(function e(t){return _t().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,t.json();case 1:return e.a(2,e.v);case 2:return e.p=2,e.v,e.a(2,void 0)}},e,null,[[0,2]])})),function(e){return i.apply(this,arguments)})},{key:"handleStreamResponseContext",value:function(e){e&&this._logger.info("stream response context [%j]",e)}},{key:"mapHttpStatusToPublishStatus",value:function(e){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){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){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){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){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){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:"normalizeSubscribeResponse",value:function(e,t){var n=t.status,r=t.streamId,i=t.sharedSecret,o=t.lag,a=t.rtcConfiguration,s=t.setRemoteDescriptionResponse,u=t.createAnswerDescriptionResponse,l=t.createOfferDescriptionResponse,c=(t.streamResponseContext,yt(yt({},ct()(t,mt)),{},{status:n,stream:{tenancy:e,streamId:r,sharedSecret:i},lag:o}));return a&&(c.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(a)),null!=s&&s.sessionDescription&&(c.setRemoteDescriptionResponse={sessionDescription:s.sessionDescription}),null!=u&&u.sessionDescription&&(c.createAnswerDescriptionResponse={sessionDescription:u.sessionDescription}),null!=l&&l.sessionDescription&&(c.createOfferDescriptionResponse={sessionDescription:l.sessionDescription}),c}},{key:"normalizePublishResponse",value:function(e,t){var n={status:t.status,stream:{tenancy:e,streamId:t.streamId,sharedSecret:t.sharedSecret}};return t.rtcConfiguration&&(n.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(t.rtcConfiguration)),t.setRemoteDescriptionResponse&&t.setRemoteDescriptionResponse.sessionDescription&&(n.setRemoteDescriptionResponse={sessionDescription:t.setRemoteDescriptionResponse.sessionDescription}),t.createAnswerDescriptionResponse&&t.createAnswerDescriptionResponse.sessionDescription&&(n.createAnswerDescriptionResponse={sessionDescription:t.createAnswerDescriptionResponse.sessionDescription}),t.createOfferDescriptionResponse&&t.createOfferDescriptionResponse.sessionDescription&&(n.createOfferDescriptionResponse={sessionDescription:t.createOfferDescriptionResponse.sessionDescription}),n}},{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:"convertHttpResponseToSetRemoteDescription",value:(r=N()(_t().m(function e(t){var n,r,i;return _t().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.parseJsonBody(t);case 1:return n=e.v,r=n?n.status:this.mapHttpStatusToSetRemoteDescriptionStatus(t),i={status:r},n&&n.sessionDescription&&(i.sessionDescription=n.sessionDescription),e.a(2,i)}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidates",value:(n=N()(_t().m(function e(t){var n,r,i;return _t().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.parseJsonBody(t);case 1:return n=e.v,r=n?n.status:this.mapHttpStatusToAddIceCandidatesStatus(t),i={status:r,options:[]},n&&n.options&&(i.options=n.options),e.a(2,i)}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStream",value:(e=N()(_t().m(function e(t){var n,r,i;return _t().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.parseJsonBody(t);case 1:return n=e.v,r=n?n.status:this.mapHttpStatusToSetDestroyStreamStatus(t),i={status:r},e.a(2,i)}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e,n,r,i,a,u,c,d,h,f,p,v,m,g}(),St=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,l=Object.create(u.prototype);return xt(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(xt(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,xt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,xt(d,"constructor",l),xt(l,"constructor",u),u.displayName="GeneratorFunction",xt(l,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 Et=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=Ne.getMetricsService(n.toString()),this._uri=n},[{key:"discoverNearbyEndPoints",value:(n=N()(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,St.race([E.value.fetch(r,{method:"GET",cache:"no-cache"}),new St(function(e,t){return E.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 wt(e,n)}))}},e)})),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=N()(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=Te.buildDiscoveryUrl(this._uri),e.n=1,this.discoverNearbyEndPoints(new E.value.URL(n),t);case 1:return r=e.v,i=0,o=function(){return new St(function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))})},e.n=2,St.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:Pe.RoundTripTime,runtime:(n-Be.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}(),Rt=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,l=Object.create(u.prototype);return Pt(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Pt(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Pt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Pt(d,"constructor",l),Pt(l,"constructor",u),u.displayName="GeneratorFunction",Pt(l,i,"GeneratorFunction"),Pt(d),Pt(d,i,"Generator"),Pt(d,r,function(){return this}),Pt(d,"toString",function(){return"[object Generator]"}),(Ot=function(){return{w:o,m:h}})()}function Pt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Pt=function(e,t,n,r){function o(t,n){Pt(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))},Pt(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=N()(Ot().m(function t(){return Ot().w(function(t){for(;;)if(0===t.n)return t.a(2,new Rt(function(t){var n=E.subscribe(function(r){if(r){var i=new r.URL(Be.discoveryUri.value);return e.discoverClosestEndPointWithCaching(i).then(t).then(function(){return n.dispose()})}})}))},t)})),function(){return r.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(n=N()(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 Et(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then(function(){E.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.NetworkEmpty=0]="NetworkEmpty",e[e.NetworkIdle=1]="NetworkIdle",e[e.NetworkLoading=2]="NetworkLoading",e[e.NetworkNoSource=3]="NetworkNoSource",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 Lt(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}var Dt=function(){return o()(function e(n,r,i,o,a,u){t()(this,e),s()(this,"_logger",ee.getLogger("WebPlayer")),s()(this,"_videoElement",void 0),s()(this,"_kind",void 0),s()(this,"_streamId",void 0),s()(this,"_manifestURI",void 0),s()(this,"_options",void 0),s()(this,"_handleStreamFailure",void 0),s()(this,"_player",void 0),s()(this,"_lastReloadTime",void 0),this._videoElement=n,this._kind=r,this._streamId=i,this._manifestURI=encodeURI(o).replace(/[#]/g,"%23"),this._options=a,this._player=null,this._lastReloadTime=0,this._handleStreamFailure=u},[{key:"start",value:function(){var e=this;if(Zt.phenixWebPlayer){var t,n,r=Lt(Lt({},this._options),{},{bandwidthToStartAt:3e6});return this._player=new Zt.phenixWebPlayer.WebPlayer(this._logger,this._videoElement,r),null===(t=this._player)||void 0===t||t.start(this._manifestURI),void(null===(n=this._player)||void 0===n||n.addEventListener("error",function(t){e.canReload()&&t&&(3===t.code||t.severity===Zt.phenixWebPlayer.errors.severity.RECOVERABLE)&&(e._logger.warn("Reloading unhealthy stream after error event [%j]",t),e.reloadIfAble()),e._logger.error("Cannot reload with error [%j]",t),e._handleStreamFailure()}))}}},{key:"isSupported",value:function(){return Zt.phenixWebPlayer&&Zt.phenixWebPlayer.isSupported}},{key:"getStats",value:function(){var e,t;if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:It.NetworkNoSource,dataBuffered:0};var n=this._player.getStats(),r=n.currentTime||this._videoElement.currentTime,i=(Date.now()-this._options.originStartTime)/1e3;return null!==(e=this._videoElement.buffered)&&void 0!==e&&e.length&&(n.dataBuffered=this._videoElement.buffered.end(0)),n.isNative&&"Hls"===n.deliveryType&&(n.currentTime=r-n.lag),n.currentTime||(n.currentTime=r),n.isNative||(n.lag=Math.max(0,i-r)),null!==(t=this._videoElement.buffered)&&void 0!==t&&t.length?n.networkState=It.NetworkLoading:n.currentTime>0?n.networkState=It.NetworkIdle:n.video?n.networkState=It.NetworkEmpty:n.networkState=It.NetworkNoSource,n}},{key:"dispose",value:function(){this._player&&this._player.dispose(),this._player=null}},{key:"canReload",value:function(){var e=!this._lastReloadTime||Date.now()-this._lastReloadTime>15e3;return!!this._videoElement&&!!this._player&&0!==this._videoElement.buffered.length&&e}},{key:"reloadIfAble",value:function(){this.canReload()&&(this._logger.warn("[%s] Reloading unhealthy stream that was active for at least [%s] seconds",this._streamId,15),this._lastReloadTime=Date.now(),this.reload())}},{key:"reload",value:function(){this._player&&this._player.dispose(),this._player=null,this.start()}}])}();function jt(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 Mt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jt(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Nt=function(){return o()(function e(n,r,i,o,a,u){t()(this,e),s()(this,"_logger",ee.getLogger("ShakaPlayer")),s()(this,"_videoElement",void 0),s()(this,"_kind",void 0),s()(this,"_streamId",void 0),s()(this,"_manifestURI",void 0),s()(this,"_options",void 0),s()(this,"_handleStreamFailure",void 0),s()(this,"_disposables",void 0),s()(this,"_monitoredStatistics",void 0),s()(this,"_player",void 0),this._videoElement=n,this._kind=r,this._streamId=i,this._manifestURI=encodeURI(o).replace(/[#]/g,"%23"),this._options=a,this._handleStreamFailure=u,this._disposables=new ie,this._monitoredStatistics={estimatedBandwidth:0,playTime:0},this._player=null},[{key:"start",value:function(){if(Zt.shaka)return this._player=new Zt.shaka.Player(this._videoElement),void this.loadPlayer({abr:{defaultBandwidthEstimate:2e6},manifest:{retryParameters:{timeout:1e4}},streaming:{liveSyncPanicThreshold:1,bufferingGoal:60,bufferBehind:30,retryParameters:{timeout:1e4,maxAttempts:10,backoffFactor:1.1}}})}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:It.NetworkNoSource,dataBuffered:0};var e=Mt(Mt({},this._player.getStats()),{},{currentTime:0,lag:0}),t=this._videoElement.currentTime||0,n=(Date.now()-this._options.originStartTime)/1e3,r=Math.max(0,n-t);return this._videoElement&&(e.currentTime=t,e.lag=r,this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0))),e.estimatedBandwidth&&(e.estimatedBandwidth&&e.estimatedBandwidth>0&&this._monitoredStatistics.estimatedBandwidth&&this._monitoredStatistics.estimatedBandwidth<e.estimatedBandwidth?e.networkState=It.NetworkLoading:e.playTime&&e.playTime>0&&this._monitoredStatistics.playTime&&this._monitoredStatistics.playTime<e.playTime?e.networkState=It.NetworkIdle:e.video?e.networkState=It.NetworkEmpty:e.networkState=It.NetworkNoSource),this._monitoredStatistics.estimatedBandwidth=e.estimatedBandwidth,this._monitoredStatistics.playTime=e.playTime,e}},{key:"dispose",value:function(){this._disposables.dispose(),this._player&&(this._player.unload(),this._player.destroy()),this._player=null}},{key:"loadPlayer",value:function(e){var t,n,r,i=this;null===(t=this._player)||void 0===t||t.configure(e);var o=function(){return i._handleStreamFailure()};null===(n=this._player)||void 0===n||n.addEventListener("error",o),this._disposables.add(new m(function(){var e;return null===(e=i._player)||void 0===e?void 0:e.removeEventListener("error",o)})),null===(r=this._player)||void 0===r||r.load(this._manifestURI).then(function(){i._logger.info("[%s] DASH live stream has been loaded",i._streamId),i._videoElement.play&&i._videoElement.play()}).catch(function(e){i._logger.error("[%s] Error while loading DASH live stream [%s]",i._streamId,e.code,e)})}}])}(),Vt=function(){return o()(function e(n){var r=n.names,i=n.carriesAudio;t()(this,e),s()(this,"names",void 0),s()(this,"carriesAudio",void 0),this.names=r.filter(function(e,t){return e&&r.indexOf(e)===t}),this.carriesAudio=i},[{key:"equals",value:function(e){var t=this;return!!e&&e.carriesAudio===this.carriesAudio&&e.names.length===this.names.length&&e.names.every(function(e,n){return e===t.names[n]})}}])}(),Bt=["addtrack","removetrack"],Gt=function(){function e(){t()(this,e)}return o()(e,null,[{key:"listen",value:function(t,n){var r=e.getTrackList(t);return t.addEventListener("loadedmetadata",n),Bt.forEach(function(e){return null==r?void 0:r.addEventListener(e,n)}),new m(function(){t.removeEventListener("loadedmetadata",n),Bt.forEach(function(e){return null==r?void 0:r.removeEventListener(e,n)})})}},{key:"keepSelection",value:function(t,n,r){var i=e.getTrackList(t),o=function(){var o=n();if(i&&o){var a=e.toArray(i).filter(function(e){return e.enabled}).map(function(e){return e.label});a.length>1?e.select(t,o):1===a.length&&a[0]&&a[0]!==o&&r(a[0])}};return null==i||i.addEventListener("change",o),new m(function(){return null==i?void 0:i.removeEventListener("change",o)})}},{key:"readRenditions",value:function(t){var n=e.getTrackList(t);if(!n||t.readyState<1)return null;var r=e.toArray(n);return new Vt({names:r.map(function(e){return e.label}),carriesAudio:r.length>0})}},{key:"select",value:function(t,n){var r=e.getTrackList(t),i=r?e.toArray(r):[];i.some(function(e){return e.label===n})&&i.forEach(function(e){e.enabled=e.label===n})}},{key:"getTrackList",value:function(e){var t=e.audioTracks;return"function"==typeof(null==t?void 0:t.addEventListener)&&"number"==typeof t.length?t:void 0}},{key:"toArray",value:function(e){for(var t=[],n=0;n<e.length;n++)t.push(e[n]);return t}}])}(),Ut=["levelEmptyError","fragParsingError"],zt=function(){function e(n,r,i,o,a){t()(this,e),s()(this,"_videoElement",void 0),s()(this,"_kind",void 0),s()(this,"_streamId",void 0),s()(this,"_manifestURI",void 0),s()(this,"_options",void 0),s()(this,"_audioRenditions",new b(null)),s()(this,"_readOnlyAudioRenditions",new C(this._audioRenditions)),s()(this,"_audioRenditionFailure",new b(null)),s()(this,"_readOnlyAudioRenditionFailure",new C(this._audioRenditionFailure)),s()(this,"_audioRenditionSelectedByViewer",new b(null)),s()(this,"_readOnlyAudioRenditionSelectedByViewer",new C(this._audioRenditionSelectedByViewer)),s()(this,"_disposables",new ie),s()(this,"_player",void 0),s()(this,"_isNative",!1),s()(this,"_selectedAudioRenditionName",null),s()(this,"_failedAudioRenditionName",null),s()(this,"_audioRenditionFailureTimeout",null),this._videoElement=n,this._kind=r,this._streamId=i,this._manifestURI=encodeURI(o).replace(/[#]/g,"%23"),this._options=a,this._player=null}return o()(e,[{key:"audioRenditions",get:function(){return this._readOnlyAudioRenditions}},{key:"audioRenditionFailure",get:function(){return this._readOnlyAudioRenditionFailure}},{key:"audioRenditionSelectedByViewer",get:function(){return this._readOnlyAudioRenditionSelectedByViewer}},{key:"start",value:function(){var e=this;Zt.hlsPlayer&&(Zt.hlsPlayer.isSupported()?(this._player=new Zt.hlsPlayer({enableWorker:!0,maxBufferLength:1,backBufferLength:0,liveSyncDuration:7,liveDurationInfinity:!0,liveMaxLatencyDuration:1/0,highBufferWatchdogPeriod:1}),this.listenToAudioRenditions(this._player,Zt.hlsPlayer.Events),this._player.loadSource(this._manifestURI),this._player.attachMedia(this._videoElement)):this._videoElement.canPlayType("application/vnd.apple.mpegurl")&&(this._isNative=!0,this._disposables.add(Gt.listen(this._videoElement,function(){return e.readNativeAudioRenditions()})),this._disposables.add(Gt.keepSelection(this._videoElement,function(){return e._selectedAudioRenditionName},function(t){return e.followViewerSelection(t)})),this._videoElement.src=this._manifestURI))}},{key:"selectAudioRendition",value:function(e){this._selectedAudioRenditionName=e,this._isNative?Gt.select(this._videoElement,e):this.applyAudioRenditionSelection()}},{key:"isSupported",value:function(){return Zt.hlsPlayer&&Zt.hlsPlayer.isSupported()}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:It.NetworkNoSource,dataBuffered:0};var e={width:this._player.media.offsetWidth,height:this._player.media.offsetHeight,currentTime:this._player.media.currentTime,lag:0,networkState:It.NetworkIdle,dataBuffered:0};this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0)),"IDLE"===this._player.streamController.state?e.networkState=It.NetworkIdle:"ERROR"===this._player.streamController.state||"ENDED"===this._player.streamController.state?e.networkState=It.NetworkNoSource:this._player.streamController.state.includes("LOADING")||this._player.streamController.state.includes("WAITING")?e.networkState=It.NetworkLoading:e.networkState=It.NetworkEmpty;var t=this._videoElement.currentTime||0,n=(Date.now()-this._options.originStartTime)/1e3;return e.lag=Math.max(0,t+this._options.lag/1e3-n),e}},{key:"dispose",value:function(){this._disposables.dispose(),this._isNative=!1,null!==this._audioRenditionFailureTimeout&&(E.value.clearTimeout(this._audioRenditionFailureTimeout),this._audioRenditionFailureTimeout=null),this._player&&this._player.destroy&&(this._player.destroy(),this._player=null)}},{key:"listenToAudioRenditions",value:function(t,n){var r=this;t.on(n.MANIFEST_PARSED,function(e,t){var n,i,o=(null!==(n=t.audioTracks)&&void 0!==n?n:[]).map(function(e){return e.name}),a=o.length>0||(null!==(i=t.levels)&&void 0!==i?i:[]).some(function(e){return!!e.audioCodec});r._audioRenditions.value=new Vt({names:o,carriesAudio:a})}),t.on(n.AUDIO_TRACKS_UPDATED,function(){return r.applyAudioRenditionSelection()}),t.on(n.ERROR,function(n,i){var o=e.findFailedAudioRenditionName(t,i);o&&o===r._selectedAudioRenditionName&&r.reportAudioRenditionFailureAfterTheErrorEvent(o)})}},{key:"reportAudioRenditionFailureAfterTheErrorEvent",value:function(e){var t=this;this._failedAudioRenditionName=e,null===this._audioRenditionFailureTimeout&&(this._audioRenditionFailureTimeout=E.value.setTimeout(function(){var e=t._failedAudioRenditionName;t._audioRenditionFailureTimeout=null,t._failedAudioRenditionName=null,e&&e===t._selectedAudioRenditionName&&(t._audioRenditionFailure.value={name:e})},0))}},{key:"applyAudioRenditionSelection",value:function(){var e=this._player,t=this._selectedAudioRenditionName;if(e&&t){var n=e.audioTracks.findIndex(function(e){return e.name===t});n>=0&&e.audioTrack!==n&&(e.audioTrack=n)}}},{key:"readNativeAudioRenditions",value:function(){this.applyNativeAudioRenditionSelection(),this._audioRenditions.value=Gt.readRenditions(this._videoElement)}},{key:"applyNativeAudioRenditionSelection",value:function(){this._selectedAudioRenditionName&&Gt.select(this._videoElement,this._selectedAudioRenditionName)}},{key:"followViewerSelection",value:function(e){this._selectedAudioRenditionName=e,this._audioRenditionSelectedByViewer.value={name:e}}}],[{key:"findFailedAudioRenditionName",value:function(e,t){var n,r,i,o;if("string"!=typeof t.details||!Ut.includes(t.details))return null;var a="audioTrack"===(null===(n=t.context)||void 0===n?void 0:n.type)?t.context.id:void 0,s="audio"===(null===(r=t.frag)||void 0===r?void 0:r.type)?t.frag.level:void 0,u=null!=a?a:s;return"number"==typeof u&&null!==(i=null===(o=e.audioTracks[u])||void 0===o?void 0:o.name)&&void 0!==i?i:null}}])}(),Ht=n(981).A;function Wt(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 qt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wt(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Jt(){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,l=Object.create(u.prototype);return Kt(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Kt(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Kt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Kt(d,"constructor",l),Kt(l,"constructor",u),u.displayName="GeneratorFunction",Kt(l,i,"GeneratorFunction"),Kt(d),Kt(d,i,"Generator"),Kt(d,r,function(){return this}),Kt(d,"toString",function(){return"[object Generator]"}),(Jt=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 Zt=function(){return o()(function e(){t()(this,e)},null,[{key:"hlsPlayer",get:function(){return this._hlsPlayer}},{key:"phenixWebPlayer",get:function(){return this._phenixWebPlayer}},{key:"shaka",get:function(){return this._shaka}},{key:"start",value:(n=N()(Jt().m(function e(t,n,r,i,o){var a=this;return Jt().w(function(e){for(;;)switch(e.n){case 0:if(this._options=i,!(this._hlsPlayer||this._shaka||this._phenixWebPlayer)){e.n=1;break}return e.a(2,this.loaded(t,n,r,o));case 1:if(Be.webPlayerLoader||Be.shakaPlayerLoader||Be.hlsJsLoader){e.n=2;break}throw new Error("Unsupported-feature, add stream player");case 2:return e.a(2,new Ht(function(e){Be.hlsJsLoader&&(a._pending=!0,Be.hlsJsLoader(function(i){a._hlsPlayer=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))})),Be.webPlayerLoader&&(a._pending=!0,Be.webPlayerLoader(function(i){a._phenixWebPlayer=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))})),Be.shakaPlayerLoader&&(a._pending=!0,Be.shakaPlayerLoader(function(i){a._shaka=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))}))}))}},e,this)})),function(e,t,r,i,o){return n.apply(this,arguments)})},{key:"getStats",value:function(){return this._player?this._player.getStats():null}},{key:"play",value:(e=N()(Jt().m(function e(t,n,r,i,o,a){var s,u,l,c;return Jt().w(function(e){for(;;)switch(e.n){case 0:if(s=i.match(/a=x-playlist:([^\n]*[.]mpd\??[^\s]*)/m),u=i.match(/a=x-playlist:([^\n]*[.]m3u8\??[^\s]*)/m),l=s&&s[1]?s[1]:"",!(c=u&&u[1]?u[1]:"")){e.n=1;break}if(this._phenixWebPlayer&&!O.shouldUseNativeHls){e.n=1;break}return this._player=new t(n,"hls",r,c,o,a),this._player.start(),e.a(2,this._player);case 1:if(!l){e.n=2;break}if(this._hlsPlayer||this._phenixWebPlayer&&O.shouldUseNativeHls){e.n=2;break}return this._player=new t(n,"dash",r,l,o,a),this._player.start(),e.a(2,this._player);case 2:if(!l&&!c){e.n=3;break}throw new Error("[".concat(r,"] Cannot play [").concat(c?"HLS":"DASH","] stream with included player"));case 3:throw new Error("No stream playlist found");case 4:return e.a(2)}},e,this)})),function(t,n,r,i,o,a){return e.apply(this,arguments)})},{key:"loaded",value:function(e,t,n,r){return this._hlsPlayer?this.play(zt,e,t,n,qt(qt({},this._options),{},{preferNative:O.shouldUseNativeHls}),r):this._phenixWebPlayer?this.play(Dt,e,t,n,qt(qt({},this._options),{},{preferNative:O.shouldUseNativeHls}),r):this.play(Nt,e,t,n,qt(qt({},this._options),{},{preferNative:O.shouldUseNativeHls}),r)}}]);var e,n}();s()(Zt,"_pending",!1),s()(Zt,"_hlsPlayer",void 0),s()(Zt,"_phenixWebPlayer",void 0),s()(Zt,"_shaka",void 0),s()(Zt,"_options",void 0),s()(Zt,"_player",void 0);var $t=function(e){return e[e.Live=1]="Live",e[e.OndDemand=2]="OndDemand",e}($t||{}),Qt=$t,Yt=n(981).A,Xt=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"),Yt.resolve(!0);if(!O.isRequestAnimationFrameSupported)return this._logger.debug("requestAnimationFrame not supported, assuming rendering"),Yt.resolve(!0);if(!O.isMobile)return this._logger.debug("Skipping frame detection on desktop, assuming rendering"),Yt.resolve(!0);var n=Date.now();return new Yt(function(r){var i=!1,o=E.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,E.value.clearTimeout(o),t._logger.debug("Video frame rendered within [%s] ms — stream is healthy",Date.now()-n),r(!0))}),E.value.requestAnimationFrame(function(){i||(i=!0,E.value.clearTimeout(o),t._logger.debug("No video frame rendered within [%s] ms — stream is stalled",Date.now()-n),r(!1))})})}}])}();s()(Xt,"_logger",ee.getLogger("VideoFrameDetector"));var en=n(981).A,tn=function(){return o()(function e(n,r,i){t()(this,e),s()(this,"_logger",ee.getLogger("ChunkedStreamSubscriber")),s()(this,"_channelContext",void 0),s()(this,"_chunkedStreamPlaybackMode",void 0),s()(this,"_disposables",new ie),s()(this,"_monitorDisposables",new ie),s()(this,"_handleStreamFailure",void 0),s()(this,"_streamStatistics",null),s()(this,"_monitorFailureCount",0),this._channelContext=n,this._chunkedStreamPlaybackMode=r,this._handleStreamFailure=i,this._channelContext.rendererDisposables.add(this)},[{key:"start",value:function(e,t){var n=this;return Ft.discoverClosestEndPointWithCaching(e).then(function(e){return n._channelContext.online.value=!0,n._channelContext.endPoint.value=e,n._logger.info("Connecting to [%s]",e.toString()),e.subscribe(t,null,n._channelContext.failureCount.value)}).then(function(e){var t,r=e.status,i=n._channelContext.endPoint.value;if(!i)return n._logger.error("Subscribe failed: end point service is missing"),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,void(n._channelContext.state.value=ze.Error);if(n._channelContext.exists.value=n._channelContext.mapSubscribeStatusToExists(r),n._channelContext.state.value=n._channelContext.mapSubscribeStatusToChannelStatus(r),n._channelContext.applyStatus(r),"ok"!==r)return n._channelContext.stream.value=null,n._channelContext.lag.value=void 0,n._channelContext.applySessionAndStreamPropertiesToVideoElement(),void n._logger.debug("[%s] Subscribe failed with status [%s]",n._channelContext.streamId,r);var o=e.stream,a=e.createOfferDescriptionResponse,s=e.lag;n._channelContext.stream.value=o,n._channelContext.lag.value=s,n._channelContext.applySessionAndStreamPropertiesToVideoElement(),n._logger.debug("[%s] Subscribe completed [%s] [%j]",n._channelContext.streamId,r,a);var u=null==a||null===(t=a.sessionDescription)||void 0===t?void 0:t.sdp,l={originStartTime:Date.now()-s+i.roundTripTime/2,lag:s};return n._channelContext.videoElement.value?u?Zt.start(n._channelContext.videoElement.value,n._channelContext.streamId,u,l,function(){return n.retryOnStreamFailure()}).then(function(e){return n.monitor(e),n._disposables.add(e),e}).catch(function(e){n._logger.error("ChunkedStreaming failed",e),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,n._channelContext.state.value=ze.Stopped}):(n._logger.error("Subscribe failed: offer SDP is missing"),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,void(n._channelContext.state.value=ze.Error)):(n._logger.error("Subscribe failed: video element is missing"),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,void(n._channelContext.state.value=ze.Stopped))})}},{key:"retryOnStreamFailure",value:function(){var e=this;this._monitorFailureCount=0,this._channelContext.state.value=ze.ConnectionError,this._channelContext.playing.value=!1,this._channelContext.loading.value=!0,this._disposables.dispose(),this._monitorDisposables.dispose(),this._handleStreamFailure().catch(function(t){e._logger.error("Failed handling stream failure",t)})}},{key:"monitor",value:function(e){var t=this;this._monitorDisposables.dispose();var n=E.value.setTimeout(function(){var n,r,i,o,a,s=Zt.getStats();if(t._chunkedStreamPlaybackMode!==Qt.Live||(null==s?void 0:s.networkState)!==It.NetworkNoSource||(null===(n=t._channelContext.videoElement.value)||void 0===n?void 0:n.currentTime)!==(null===(r=t._channelContext.videoElement.value)||void 0===r?void 0:r.duration)){if(t._streamStatistics&&(null===(i=t._channelContext.videoElement.value)||void 0===i||!i.paused)&&null!=s&&s.currentTime&&t._streamStatistics.currentTime>=s.currentTime&&(null==s||!s.dataBuffered||t._streamStatistics.dataBuffered>=s.dataBuffered)){if(t._monitorFailureCount++,t._monitorFailureCount>4)return void t.retryOnStreamFailure()}else t._monitorFailureCount=0;null!==(o=t._channelContext.videoElement.value)&&void 0!==o&&o.paused&&t._channelContext.state.value===ze.Playing&&(t._channelContext.state.value=ze.Paused),null!==(a=t._channelContext.videoElement.value)&&void 0!==a&&a.paused||t._channelContext.state.value===ze.Playing||(t._channelContext.state.value=ze.Playing),t._streamStatistics=s,t.monitor(e)}else t.retryOnStreamFailure()},1e3);this._monitorDisposables.add(new m(function(){E.value.clearTimeout(n)}))}},{key:"isStreamHealthy",value:function(){var e=this._channelContext.videoElement.value;return e?e.paused?en.resolve(!1):Xt.isRenderingFrames(e):en.resolve(!1)}},{key:"dispose",value:function(){this._disposables.dispose(),this._monitorDisposables.dispose()}}])}(),nn=n(715),rn=n.n(nn);function on(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 an=function(){return o()(function e(n){t()(this,e),s()(this,"_sdp",void 0),s()(this,"_sdpSplitByTracks",void 0),s()(this,"_audioSections",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,this._sdpSplitByTracks=this._sdp.split(/(?:^|[\r\n])m=/);var r=this._sdp.split(/(\r\n|\r|\n)/);this._audioCodec=this.applyCodec("audio",r),this._videoCodec=this.applyCodec("video",r),this._audioSections=this.parseAudioSections(),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio"),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video")},[{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:"audioSections",get:function(){return this._audioSections}},{key:"withAudioLanguages",value:function(e){for(var t=this._sdp.includes("\r\n")?"\r\n":this._sdp.includes("\n")?"\n":"\r",n=this._sdp.split(/\r\n|\r|\n/),r=-1,i=!1,o=0;o<n.length;o++)n[o].startsWith("m=")&&(i=n[o].startsWith("m=audio "))&&r++,i&&n[o].startsWith("a=lang:")?(n.splice(o,1),o--):i&&n[o].startsWith("a=mid:")&&e[r]&&(n.splice(o+1,0,"a=lang:".concat(e[r])),o++);return n.join(t)}},{key:"parseAudioSections",value:function(){var e,t=[],n=0,r=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 on(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)?on(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._sdpSplitByTracks.slice(1));try{for(r.s();!(e=r.n()).done;){var i,o,a,s=e.value.split(/\r\n|\r|\n/);if(s[0].startsWith("audio ")){var u=null===(i=s.find(function(e){return e.startsWith("a=mid:")}))||void 0===i?void 0:i.slice(6),l=n++,c=null===(o=s.find(function(e){return e.startsWith("a=x-source-index:")}))||void 0===o?void 0:o.slice(17);u&&t.push({mid:u,sourceIndex:c&&/^\d+$/.test(c)?Number(c):l,language:null===(a=s.find(function(e){return e.startsWith("a=lang:")}))||void 0===a?void 0:a.slice(7),receivesMedia:"0"!==s[0].split(" ")[1]&&!s.includes("a=inactive")&&!s.includes("a=recvonly")})}}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"isTrackByTypeEnabled",value:function(e){var t=this._sdpSplitByTracks.find(function(t){return t.startsWith(e)});return!!t&&!t.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]}}])}(),sn=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}}])}(),un=n(981).A;function ln(){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,l=Object.create(u.prototype);return cn(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(cn(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,cn(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,cn(d,"constructor",l),cn(l,"constructor",u),u.displayName="GeneratorFunction",cn(l,i,"GeneratorFunction"),cn(d),cn(d,i,"Generator"),cn(d,r,function(){return this}),cn(d,"toString",function(){return"[object Generator]"}),(ln=function(){return{w:o,m:h}})()}function cn(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}cn=function(e,t,n,r){function o(t,n){cn(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))},cn(e,t,n,r)}function dn(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 hn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?dn(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var fn=function(){return o()(function e(n,r,i,o){var a=this,u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:new C(new b(null));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,"_audioTrackMids",void 0),s()(this,"_selectedAudioMid",void 0),s()(this,"_peerConnection",void 0),s()(this,"_isMonitorRunning",!0),s()(this,"_updateTimeout",null),s()(this,"_tracksToMonitor",void 0),s()(this,"_monitorGeneration",0),s()(this,"_hasWarnedUnresolvedAudio",!1),this._peerConnection=n,this._audioTrackMids=u,this._selectedAudioMid=l,this._estimatedRoundTripTime=i,this._tracksToMonitor=r.getTracks().map(function(e){return e.kind})||[],this._peerConnection){var c,d;if(!O.getCurrentOfferDisabled&&null!==(c=this._peerConnection)&&void 0!==c&&null!==(d=c.currentRemoteDescription)&&void 0!==d&&d.sdp){var h=new an(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=h.audioCodec,this._estimatedVideoCodec=h.videoCodec}var f=!0;this._disposables.add(o.subscribe(function(e){f?f=!1:e&&a._isMonitorRunning&&(a._monitorGeneration++,a._updateTimeout&&(E.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&&(E.value.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(n=N()(ln().m(function e(){var t,n,r,i,o,a,s,u,l,c,d,h,f,p=this;return ln().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 un(function(e){r=E.value.setTimeout(function(){return e(null)},5e3)}),e.n=4,un.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={},l=this._estimatedRoundTripTime,s.forEach(function(e){if("candidate-pair"===e.type&&e.currentRoundTripTime&&(l=1e3*e.currentRoundTripTime,Object.values(u).forEach(function(e){e.roundTripTime=l})),"candidate-pair"===e.type&&e.lastPacketReceivedTimestamp&&(c=e.lastPacketReceivedTimestamp,Object.values(u).forEach(function(e){e.lastPacketReceivedTimestamp=c})),"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&&p._tracksToMonitor.includes(n)){var i,o,a,d,h,f,v,m="audio"===n?p.getAudioSectionMid(e):void 0;if("audio"===n&&p._audioTrackMids.length&&!m)return void(p._hasWarnedUnresolvedAudio||(p._hasWarnedUnresolvedAudio=!0,p._logger.warn("Unable to match inbound audio report to one of [%s] audio tracks",p._audioTrackMids.length)));var g=m?p.getAudioStatisticKey(m):n,y=(e.bytesReceived||0)-(null!==(i=null===(o=p._rtcStatistic.value)||void 0===o||null===(a=o[g])||void 0===a?void 0:a.bytesReceived)&&void 0!==i?i:0),_=e.timestamp-((null===(d=p._rtcStatistic.value)||void 0===d||null===(h=d[g])||void 0===h?void 0:h.timestamp)||0),b=y&&_?Math.floor(8*y/_*1e3):0;if(u[g]={ssrc:e.ssrc,mediaType:n,timestamp:e.timestamp,bitrate:b,bytesReceived:e.bytesReceived,packetsLost:e.packetsLost,packetsReceived:e.packetsReceived,codec:r||p.getCodecByType(n),roundTripTime:l},(e.lastPacketReceivedTimestamp||c)&&(u[g].lastPacketReceivedTimestamp=e.lastPacketReceivedTimestamp||c),"video"===n&&null!==(f=p._rtcStatistic.value)&&void 0!==f&&null!==(v=f.video)&&void 0!==v&&v.framesDecoded){u[g].framesDecoded=e.framesDecoded;var C=(e.framesDecoded-p._rtcStatistic.value.video.framesDecoded)/(u[g].timestamp-p._rtcStatistic.value.video.timestamp)*1e3;u[g].fps=C?Math.round(100*C)/100:0}}}}),d=this._selectedAudioMid.value,(h=d?this.getAudioStatisticKey(d):null)&&u[h]&&(u.audio=hn({},u[h])),this._rtcStatistic.value=u):this._logger.debug("getStats() timed out, skipping stats processing"),e.n=8;break;case 6:if(e.p=6,f=e.v,n===this._monitorGeneration&&this._isMonitorRunning){e.n=7;break}return e.a(2);case 7:this._logger.warn("getStats() rejected",f);case 8:return e.p=8,E.value.clearTimeout(r),e.f(8);case 9:this._isMonitorRunning&&n===this._monitorGeneration&&(this._updateTimeout=E.value.setTimeout(function(){return p.updateStatistic()},1e3));case 10:return e.a(2)}},e,this,[[2,6,8,9]])})),function(){return n.apply(this,arguments)})},{key:"updateStatisticLegacy",value:(e=N()(ln().m(function e(){var t,n,r,i,o,a,s,u,l,c=this;return ln().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 un(function(e){n=E.value.setTimeout(function(){return e(null)},5e3)}),e.n=3,un.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()||c.getCodecByType(r),s[r].roundTripTime=u,"video"===r&&null!==(t=c._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-c._rtcStatistic.value.video.framesDecoded)/(s[r].timestamp-c._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,l=e.v,t===this._monitorGeneration&&this._isMonitorRunning){e.n=6;break}return e.a(2);case 6:this._logger.warn("getStatsLegacy() rejected",l);case 7:return e.p=7,E.value.clearTimeout(n),e.f(7);case 8:this._isMonitorRunning&&t===this._monitorGeneration&&(this._updateTimeout=E.value.setTimeout(function(){return c.updateStatistic()},1e3));case 9:return e.a(2)}},e,this,[[1,5,7,8]])})),function(){return e.apply(this,arguments)})},{key:"getAudioSectionMid",value:function(e){var t,n;if(this._audioTrackMids.length){var r=null!==(t=this._peerConnection)&&void 0!==t&&t.supportsGetTransceivers?null===(n=this._peerConnection.getTransceivers().find(function(t){var n;return(null===(n=t.receiver.track)||void 0===n?void 0:n.id)===e.trackIdentifier}))||void 0===n?void 0:n.mid:void 0;return e.mid||r||(1===this._audioTrackMids.length?this._audioTrackMids[0]:void 0)}}},{key:"getAudioStatisticKey",value:function(e){return"audio:".concat(e)}},{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}(),pn=function(e){return e[e.H264=0]="H264",e[e.VP8=1]="VP8",e[e.VP9=2]="VP9",e}({}),vn=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}({}),mn=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[e.DropVideoChunk=5]="DropVideoChunk",e[e.DropAudioChunk=6]="DropAudioChunk",e}({});function gn(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 yn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?gn(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _n(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 bn=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!==pn.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){this._disposables.add(i.registerRoute(mn.FrameTimingInformation,this.handleFrameTimingMessage.bind(this,pn[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=rn()(a[o],2),u=s[0],l=s[1],c=parseInt(u,10),d=l.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(c,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 _n(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)?_n(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=rn()(o.value,2),l=u[0],c=u[1];if(l>i)break;t.value=yn(yn({},c),{},{renderTimestamp:new Date(performance.timeOrigin+n),playbackState:"playing"}),a.push(l)}}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()(bn,"_transformName","frame-timing-information");var Cn=n(512),kn=n.n(Cn);function wn(){return kn()('(()=>{var e={383:e=>{e.exports=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,r,t)=>{var n=t(736);function o(e,r){for(var t=0;t<r.length;t++){var o=r[t];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,r,t){return r&&o(e.prototype,r),t&&o(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,r,t)=>{var n=t(736);e.exports=function(e,r,t){return(r=n(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,r,t)=>{var n=t(738).default;e.exports=function(e,r){if("object"!=n(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,r||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,r,t)=>{var n=t(738).default,o=t(45);e.exports=function(e){var r=o(e,"string");return"symbol"==n(r)?r:r+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function r(t){return e.exports=r="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,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}},r={};function t(n){var o=r[n];if(void 0!==o)return o.exports;var a=r[n]={exports:{}};return e[n](a,a.exports,t),a.exports}t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{"use strict";var e=t(383),r=t.n(e),n=t(579),o=t.n(n),a=t(693),i=t.n(a),s=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}({}),u=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[e.DropVideoChunk=5]="DropVideoChunk",e[e.DropAudioChunk=6]="DropAudioChunk",e}({});function l(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function c(e,r){for(var t=e.length,n=r;n<t-3;n++)if(0===e[n]&&0===e[n+1]){if(1===e[n+2])return n;if(n+3<t&&0===e[n+2]&&1===e[n+3])return n}return-1}function f(e,r){for(var t=r,n=0;255===e[t];)n++,t++;var o=255*n+e[t++];for(n=0;255===e[t];)n++,t++;var a=255*n+e[t++];return{type:o,payload:e.subarray(t,t+a),length:t+a-r}}function d(e){if(e.getRemainingBits()<10)return null;var r={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(r.fullTimestampFlag){if(e.getRemainingBits()<17)return null;r.seconds=e.readBits(6),r.minutes=e.readBits(6),r.hours=e.readBits(5)}else if(!function(e,r){return e.getRemainingBits()<1||0===e.readBits(1)||!(e.getRemainingBits()<6)&&(r.seconds=e.readBits(6),e.getRemainingBits()<1||0===e.readBits(1)||!(e.getRemainingBits()<6)&&(r.minutes=e.readBits(6),e.getRemainingBits()<1||0===e.readBits(1)||!(e.getRemainingBits()<5)&&(r.hours=e.readBits(5),!0)))}(e,r))return null;return e.getRemainingBits()<24?null:(r.timeOffset=e.readBits(24),r)}function p(e,r){var t,n,o=(t=function(e){var r,t=[],n=0,o=function(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return l(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?l(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);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,s=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){s=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(s)throw a}}}}(e);try{for(o.s();!(r=o.n()).done;){var a=r.value;2===n&&3===a?n=0:(0===a?n++:n=0,t.push(a))}}catch(e){o.e(e)}finally{o.f()}return new Uint8Array(t)}(e),n=0,{readBits:function(e){if(n+e>8*t.length)throw new Error("Cannot read [".concat(e,"] bits - out of bounds"));for(var r=0,o=e;o>0;){var a=Math.floor(n/8),i=8-n%8,s=Math.min(o,i),u=(1<<s)-1;r=r<<s|t[a]>>i-s&u,n+=s,o-=s}return r},skipBits:function(e){if(n+e>8*t.length)throw new Error("Cannot skip [".concat(e,"] bits - out of bounds"));n+=e},getRemainingBits:function(){return 8*t.length-n}}),a={picStruct:void 0};if(r.cpbDpbDelaysPresentFlag&&void 0!==r.cpbRemovalDelayLengthMinus1&&void 0!==r.dpbOutputDelayLengthMinus1&&(o.skipBits(r.cpbRemovalDelayLengthMinus1+1),o.skipBits(r.dpbOutputDelayLengthMinus1+1)),r.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)),s=[],u=0;u<i&&!(o.getRemainingBits()<1);u++)if(1===o.readBits(1)){var c=d(o);if(!c)break;s.push({clockTimestampFlag:!0,clockTimestamp:c})}else s.push({clockTimestampFlag:!1});a.picStruct={numClockTS:i,clockTimestamps:s}}return a}var m,g=function(){return o()(function e(){r()(this,e)},null,[{key:"createFrameTimingInformationTransform",value:function(){return new TransformStream({transform:function(e,r){(function(e){for(var r=new Date,t=new Uint8Array(e.data),n=c(t,0);-1!==n;){var o=c(t,n+1),a=-1===o?t.length:o,l=n+(1===t[n+2]?3:4);if(6==(31&t[l]))for(var d=l+1,m=t.subarray(d,a),g=0;g<m.length&&!(g+2>m.length);){var h=f(m,g);if(1===h.type){var v,y=null===(v=p(h.payload,{cpbDpbDelaysPresentFlag:!1,picStructPresentFlag:!0}).picStruct)||void 0===v?void 0:v.clockTimestamps[0];if(null!=y&&y.clockTimestampFlag){var k,b,T,w,C=e.timestamp,x={timecode:y.clockTimestamp?{hours:null!==(k=y.clockTimestamp.hours)&&void 0!==k?k:null,minutes:null!==(b=y.clockTimestamp.minutes)&&void 0!==b?b:null,seconds:null!==(T=y.clockTimestamp.seconds)&&void 0!==T?T:null,frames:null!==(w=y.clockTimestamp.nFrames)&&void 0!==w?w:null,isFrameDrop:y.clockTimestamp.cntDroppedFlag}:null,receiveTimestamp:r},B={type:s.Metadata,data:{type:u.FrameTimingInformation,data:i()({},C,{decodedFrameTimingInformation:x})}};self.postMessage(B)}}if(g+=h.length,0===h.length)break}n=o}})(e),r.enqueue(e)}})}},{key:"createEncodedStreamTransform",value:function(e,r,t,n){var o=new Map,a=0,i=0,u=0,l=function(e,r){var i=r.data;if(i.type===s.Chunk&&(i.data.type===t||i.data.type===n)){var u=i.data,l=u.type,c=u.data,f=c.timestamp,d=o.get(f);if(d){if(o.delete(f),l!==n){var p=c.surrogate;d.data=p,e.enqueue(d)}}else a++%100==0&&console.warn("[WorkerTransforms] Reply chunk not found for timestamp",f)}};return new TransformStream({start:function(r){e.addEventListener("message",l.bind(null,r),{once:!1})},transform:function(t){var n=function(e){var r,t,n=null!==(r=null===(t=e.getMetadata)||void 0===t?void 0:t.call(e).rtpTimestamp)&&void 0!==r?r:e.timestamp;return"number"==typeof n?n:void 0}(t);if(void 0!==n){for(o.set(n,t);o.size>480;){var a=o.keys().next().value;o.delete(a),i++%100==0&&console.warn("[WorkerTransforms] Pending chunk map exceeded cap of [%s]; evicted oldest timestamp",480,a)}var l=t.data;e.postMessage({type:s.Chunk,data:{type:r,data:{timestamp:n,data:new Uint8Array(l),type:t.type}}},{transfer:[l]})}else u++%100==0&&console.warn("[WorkerTransforms] Unable to resolve a correlation timestamp for chunk; dropping")}})}},{key:"createPassThroughTransform",value:function(){return new TransformStream({transform:function(e,r){return r.enqueue(e)}})}}])}(),h=self,v=function(){function e(){r()(this,e)}return o()(e,null,[{key:"postError",value:function(r){h.postMessage({type:s.Error,data:{name:e._workerName,error:r}})}},{key:"handleAddTransform",value:function(r){if(e._isPipelineConfigured)throw new Error("Error: Pipeline is locked. A transform cannot be added once the pipeline has been configured");switch(r){case"frame-timing-information":e._transforms.push(g.createFrameTimingInformationTransform());break;case"protected-video":e._transforms.push(g.createEncodedStreamTransform(h,u.EncodedVideoChunk,u.SurrogateVideoChunk,u.DropVideoChunk));break;case"protected-audio":e._transforms.push(g.createEncodedStreamTransform(h,u.EncodedAudioChunk,u.SurrogateAudioChunk,u.DropAudioChunk));break;case"pass-through":e._transforms.push(g.createPassThroughTransform());break;default:throw new Error("Error: Unknown transform type [".concat(r,"]"))}}},{key:"configurePipeline",value:function(r,t){if(!r||!t)throw new Error("Error: Configuration of TransformStreamPipeline requires both a readbale source and writable sink");(function(e,r,t){return r.reduce(function(e,r){return e.pipeThrough(r)},e).pipeTo(t)})(r,e._transforms,t).catch(function(r){e.postError(r)}),e._isPipelineConfigured=!0,h.postMessage({type:s.PipelineConfigured,data:{name:e._workerName}})}},{key:"handleMessage",value:function(r){var t=r.data,n=t.type;try{switch(n){case s.AddTransform:e.handleAddTransform(t.data);break;case s.ConfigurePipeline:e._workerName=t.data.name,e.configurePipeline(t.data.source,t.data.sink);break;case s.Chunk:break;default:!function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))}(n)}}catch(r){e.postError(r)}}}])}();m=v,i()(v,"_transforms",[]),i()(v,"_isPipelineConfigured",!1),i()(v,"_workerName","unconfigured-transform-pipeline"),h.onerror=function(e){var r,t;return m.postError(null!==(r=null!==(t=e.error)&&void 0!==t?t:e.message)&&void 0!==r?r:e)},h.onmessage=m.handleMessage.bind(m),h.RTCTransformEvent&&(h.onrtctransform=function(e){var r=e.transformer;try{m._workerName=r.options.name;var t=r.readable,n=r.writable;m.configurePipeline(t,n)}catch(e){m.postError(e)}})})()})();\n',"Worker",void 0,void 0)}var Sn=n(981).A,Tn=["transferable"],xn=function(){return o()(function e(n,r){t()(this,e),s()(this,"_logger",ee.getLogger("TransformPipelineMessageRouter")),s()(this,"_unknownRouteLogCounts",new Map),s()(this,"_worker",void 0),s()(this,"_messageRoutes",new Map),s()(this,"_replyChains",new Map),s()(this,"_onError",void 0),s()(this,"_isDisposed",!1),s()(this,"_pendingConfiguration",void 0),this._worker=n,this._onError=r,this.initialize(n)},[{key:"registerRoute",value:function(e,t,n){var r=this;return this._messageRoutes.set(e,{handler:t,onErrorReply:n}),new m(function(){return r._messageRoutes.delete(e)})}},{key:"waitForConfiguration",value:function(){var e=this;return this._isDisposed?Sn.reject(new Error("Transform pipeline worker has already been disposed")):new Sn(function(t,n){e._pendingConfiguration={resolve:t,reject:n}})}},{key:"dispose",value:function(){var e;this._isDisposed=!0,null===(e=this._pendingConfiguration)||void 0===e||e.reject(new Error("Transform pipeline worker was disposed before it finished configuring")),this._pendingConfiguration=void 0,this._messageRoutes.clear(),this._replyChains.clear(),this._unknownRouteLogCounts.clear(),this._worker.terminate()}},{key:"initialize",value:function(e){var t=this;e.addEventListener("message",function(e){var n,r,i,o=e.data;switch(o.type){case vn.Chunk:case vn.Metadata:!function(e){var n=e.type,r=e.data,i=t._messageRoutes.get(n);if(i){var o=(t._replyChains.get(n)||Sn.resolve()).then(function(){return i.handler(r)}).then(function(e){return t.postReply(e)}).catch(function(e){t._logger.error("Route handler rejected for message type [%s]",n,e),i.onErrorReply&&t.postReply(i.onErrorReply(r))});t._replyChains.set(n,o)}else t.logThrottledErrorForUnknownRoute(n)}(o.data);break;case vn.PipelineConfigured:null===(n=t._pendingConfiguration)||void 0===n||n.resolve(),t._pendingConfiguration=void 0;break;case vn.Error:t._logger.error("An error occurred in [%s] worker",o.data.name,o.data.error),null===(r=t._pendingConfiguration)||void 0===r||r.reject(o.data.error),t._pendingConfiguration=void 0,t.dispose(),null===(i=t._onError)||void 0===i||i.call(t,o.data.error)}},{once:!1})}},{key:"postReply",value:function(e){if(e&&!this._isDisposed){var t=e.transferable,n=ct()(e,Tn),r=t&&"surrogate"in n.data?[n.data.surrogate]:[],i={type:vn.Chunk,data:n};this._worker.postMessage(i,r)}}},{key:"logThrottledErrorForUnknownRoute",value:function(e){var t,n=(null!==(t=this._unknownRouteLogCounts.get(e))&&void 0!==t?t:0)+1;this._unknownRouteLogCounts.set(e,n),(n-1)%100==0&&this._logger.error("Dropping message: No route registered for message type [%s]",e)}}])}(),En=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,l=Object.create(u.prototype);return On(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(On(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,On(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,On(d,"constructor",l),On(l,"constructor",u),u.displayName="GeneratorFunction",On(l,i,"GeneratorFunction"),On(d),On(d,i,"Generator"),On(d,r,function(){return this}),On(d,"toString",function(){return"[object Generator]"}),(Rn=function(){return{w:o,m:h}})()}function On(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}On=function(e,t,n,r){function o(t,n){On(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))},On(e,t,n,r)}function Pn(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 Fn(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)?Fn(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 Fn(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 In,An=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,t){var n=new ie,r=e.videoTrack,i=e.audioTrack,o=function(e){var r=e.transformPipelineWorker=new wn;n.add(new m(function(){return r.terminate()})),n.add(e.transformMessageRouter=new xn(r,t))},a=r.receiver,s=r.mediaStreamTrack;a&&s&&o(r);var u=i.receiver,l=i.mediaStreamTrack;return u&&l&&o(i),n}},{key:"configureEncodedStreamPipeline",value:(e=N()(Rn().m(function e(t){var n,r,i,o,a;return Rn().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=Pn(e.transformFunctionNames);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.transformPipelineWorker.postMessage({type:vn.AddTransform,data:r})}}catch(e){n.e(e)}finally{n.f()}}else e.transformPipelineWorker.postMessage({type:vn.AddTransform,data:"pass-through"})})(n),i(r),o=function(){var e=N()(Rn().m(function e(t){var n,r,i;return Rn().w(function(e){for(;;)switch(e.n){case 0:return n=function(){var e=N()(Rn().m(function e(t){var n,r,i,o;return Rn().w(function(e){for(;;)switch(e.n){case 0:if(n=t.receiver,r=t.mediaStreamTrack,i=t.transformPipelineWorker,o=t.transformMessageRouter,!(n&&r&&i&&o)){e.n=1;break}return n.transform=new RTCRtpScriptTransform(i,{name:"".concat(r.kind,"-transform-pipeline")}),e.a(2,o.waitForConfiguration());case 1:return e.a(2,En.resolve())}},e)}));return function(t){return e.apply(this,arguments)}}(),r=t.videoTrack,i=t.audioTrack,e.n=1,En.all([n(r),n(i)]);case 1:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}(),a=function(){var e=N()(Rn().m(function e(t){var n,r,i,o;return Rn().w(function(e){for(;;)switch(e.n){case 0:return n=function(e){var t=e.receiver,n=e.mediaStreamTrack,r=e.transformPipelineWorker,i=e.transformMessageRouter;if(t&&n&&r&&i){var o=t.createEncodedStreams(),a=i.waitForConfiguration();return r.postMessage({type:vn.ConfigurePipeline,data:{name:"".concat(n.kind,"-transform-pipeline"),source:o.readable,sink:o.writable}},{transfer:[o.readable,o.writable]}),a}return En.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,En.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 Map,o=new ie;return e.getTracks().forEach(function(e){var a=e.kind;switch(a){case"video":if(t){var s=e,u=new TransformStream({transform:function(n,r){t(e,n,r)}}),l=new MediaStreamTrackProcessor({track:s}),c=new MediaStreamTrackGenerator({kind:s.kind}),d=l.readable,h=c.writable;d.pipeThrough(u).pipeTo(h),r.addTrack(c),i.set(e,c),o.add(new m(function(){r.removeTrack(c)}))}else r.addTrack(e);break;case"audio":if(n){var f=e,p=new TransformStream({transform:function(t,r){n(e,t,r)}}),v=new MediaStreamTrackProcessor({track:f}),g=new MediaStreamTrackGenerator({kind:f.kind}),y=v.readable,_=g.writable;y.pipeThrough(p).pipeTo(_),r.addTrack(g),i.set(e,g);var b=new MediaStream,C=new Audio;b.addTrack(e),C.srcObject=b,document.body.appendChild(C),o.add(new m(function(){r.removeTrack(g),document.body.removeChild(C)}))}else r.addTrack(e);break;default:J(a)}}),{transformedStream:r,renderedTracks:i,disposables:o}}}]);var e}(),Ln=function(e){return e[e.OPUS=0]="OPUS",e[e.AAC=1]="AAC",e}({}),Dn=new Uint8Array([0,0,0,1]),jn=new Uint8Array([].concat(l()(Dn),[103,66,192,42,218,4,4,232,64,0,0,3,0,64,0,0,15,35,198,12,168],l()(Dn),[104,206,60,128],l()(Dn),[6,3,167],l()(new Uint8Array(150).fill(255)),[128],l()(Dn),[101,136,132,6,191,255,255,15,69,0,1,87,159],l()(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])),Mn=new Uint8Array([].concat(l()(Dn),[6,3,255,61],l()(new Uint8Array(316).fill(255)),[128],l()(Dn),[65,154,32,26,240,18,48])),Nn=Symbol(),Vn=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 Ln.OPUS:return e._dummyAudioSilentPerCodec.OPUS.buffer;case Ln.AAC:return;default:J(t)}}},{key:"getInvalidSurrogateAudioData",value:function(){return e._singleZeroByte.buffer}},{key:"getSurrogateVideoIFramePerCodec",value:function(t){switch(t){case pn.H264:return e._isSafari?e._surrogate28x16H264IFrame.buffer:e._dummy2x2VideoIFramePerCodec.H264.buffer;case pn.VP8:return e._dummy2x2VideoIFramePerCodec.VP8.buffer;case pn.VP9:return e._dummy2x2VideoIFramePerCodec.VP9.buffer;default:J(t)}}},{key:"getInvalidSurrogateVideoIFrame",value:function(t){return t===pn.H264&&e._isAndroidChrome?(e._surrogate28x16PFrameFrameNumber=e._surrogate28x16PFrameFrameNumberReset,Nn):e._singleZeroByte.buffer}},{key:"getSurrogateVideoPFramePerCodec",value:function(t){switch(t){case pn.H264:return e._isSafari?e._surrogate28x16H264PFrame.buffer:e._dummy2x2VideoPFramePerCodec.H264.buffer;case pn.VP8:return e._dummy2x2VideoPFramePerCodec.VP8.buffer;case pn.VP9:return e._dummy2x2VideoPFramePerCodec.VP9.buffer;default:J(t)}}},{key:"getInvalidSurrogateVideoPFrame",value:function(){return e._singleZeroByte.buffer}}])}();function Bn(){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,l=Object.create(u.prototype);return Gn(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Gn(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Gn(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Gn(d,"constructor",l),Gn(l,"constructor",u),u.displayName="GeneratorFunction",Gn(l,i,"GeneratorFunction"),Gn(d),Gn(d,i,"Generator"),Gn(d,r,function(){return this}),Gn(d,"toString",function(){return"[object Generator]"}),(Bn=function(){return{w:o,m:h}})()}function Gn(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Gn=function(e,t,n,r){function o(t,n){Gn(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))},Gn(e,t,n,r)}In=Vn,s()(Vn,"_isSafari","Safari"===R.browserName),s()(Vn,"_isAndroidChrome","Chrome"===R.browserName&&R.isAndroid),s()(Vn,"_singleZeroByte",new Uint8Array([0])),s()(Vn,"_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()(Vn,"_dummy2x2VideoIFramePerCodec",{H264:new Uint8Array([].concat(l()(Dn),[9,240],l()(Dn),[103,244,0,10,145,155,43,241,241,248,8,128,0,0,3,0,128,0,0,25,7,137,18,203],l()(Dn),[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()(Vn,"_dummy2x2VideoPFramePerCodec",{H264:new Uint8Array([].concat(l()(Dn),[9,240],l()(Dn),[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()(Vn,"_surrogate28x16H264IFrame",jn),s()(Vn,"_surrogate28x16H264PFrame",Mn),s()(Vn,"_surrogate28x16PFrameFrameNumberReset",1),s()(Vn,"_surrogate28x16PFrameFrameNumber",In._surrogate28x16PFrameFrameNumberReset);var Un=function(){function e(n){t()(this,e),s()(this,"_disposables",new ie),this.initialize(n)}return o()(e,[{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(mn.EncodedVideoChunk,function(n){return t.encodedVideoStreamCallback(e.videoTrack,e.encodedVideoStreamSink,n)},function(e){return{type:mn.DropVideoChunk,data:{timestamp:e.timestamp}}}))),e.audioTrack.mediaStreamTrack&&(e.audioTrack.transformFunctionNames.push("protected-audio"),this._disposables.add(e.audioTrack.transformMessageRouter.registerRoute(mn.EncodedAudioChunk,function(n){return t.encodedAudioStreamCallback(e.audioTrack,e.encodedAudioStreamSink,n)},function(e){return{type:mn.DropAudioChunk,data:{timestamp:e.timestamp}}})))}},{key:"encodedAudioStreamCallback",value:(r=N()(Bn().m(function t(n,r,i){var o;return Bn().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,r(n.mediaStreamTrack,i);case 1:if(t.v){t.n=2;break}o=Vn.getInvalidSurrogateAudioData(),t.n=3;break;case 2:o=Vn.getSurrogateAudioSilentPerCodec(n.codec);case 3:if(!o){t.n=4;break}return t.a(2,{type:mn.SurrogateAudioChunk,data:{surrogate:o,timestamp:i.timestamp}});case 4:return t.a(2,{type:mn.SurrogateAudioChunk,data:{surrogate:e.toTransferableSurrogate(i.data),timestamp:i.timestamp},transferable:!0})}},t)})),function(e,t,n){return r.apply(this,arguments)})},{key:"encodedVideoStreamCallback",value:(n=N()(Bn().m(function t(n,r,i){var o,a;return Bn().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,r(n.mediaStreamTrack,i);case 1:if(t.v){t.n=3;break}if((o="key"===i.type?Vn.getInvalidSurrogateVideoIFrame(n.codec):Vn.getInvalidSurrogateVideoPFrame())!==Nn&&void 0!==o){t.n=2;break}return t.a(2,{type:mn.DropVideoChunk,data:{timestamp:i.timestamp}});case 2:return t.a(2,{type:mn.SurrogateVideoChunk,data:{surrogate:o,timestamp:i.timestamp}});case 3:if(!(a="key"===i.type?Vn.getSurrogateVideoIFramePerCodec(n.codec):Vn.getSurrogateVideoPFramePerCodec(n.codec))){t.n=4;break}return t.a(2,{type:mn.SurrogateVideoChunk,data:{surrogate:a,timestamp:i.timestamp}});case 4:return t.a(2,{type:mn.SurrogateVideoChunk,data:{surrogate:e.toTransferableSurrogate(i.data),timestamp:i.timestamp},transferable:!0})}},t)})),function(e,t,r){return n.apply(this,arguments)})}],[{key:"toTransferableSurrogate",value:function(e){return e.buffer}}]);var n,r}(),zn=function(){return o()(function e(){t()(this,e)},null,[{key:"convertVideoCodecToVideoCodecType",value:function(e){switch(e){case pn.H264:return"H264";case pn.VP8:return"VP8";case pn.VP9:return"VP9";default:J(e)}}},{key:"convertVideoCodecTypeToVideoCodec",value:function(e){var t=e.toUpperCase();switch(t){case"H264":return pn.H264;case"VP8":return pn.VP8;case"VP9":return pn.VP9;default:J(t)}}}])}(),Hn=function(){return o()(function e(){t()(this,e)},null,[{key:"convertAudioCodecToAudioCodecType",value:function(e){switch(e){case Ln.OPUS:return"OPUS";case Ln.AAC:return"AAC";default:J(e)}}},{key:"convertAudioCodecTypeToAudioCodec",value:function(e){var t=e.toUpperCase();switch(t){case"OPUS":return Ln.OPUS;case"AAC":return Ln.AAC;default:J(t)}}}])}(),Wn=n(981).A;function qn(){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,l=Object.create(u.prototype);return Jn(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Jn(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Jn(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Jn(d,"constructor",l),Jn(l,"constructor",u),u.displayName="GeneratorFunction",Jn(l,i,"GeneratorFunction"),Jn(d),Jn(d,i,"Generator"),Jn(d,r,function(){return this}),Jn(d,"toString",function(){return"[object Generator]"}),(qn=function(){return{w:o,m:h}})()}function Jn(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Jn=function(e,t,n,r){function o(t,n){Jn(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))},Jn(e,t,n,r)}function Kn(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 Zn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Kn(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Kn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var $n=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,a=this._channelContext.findMaxAudioTracks(o),s=Array.from({length:a},function(){return"audio"});return a<this._channelContext.maxAudioTracks&&this._logger.warn("Encoded insertable streams support one audio track. Requesting [%s] instead of [%s] audio tracks",a,this._channelContext.maxAudioTracks),s.push("video"),Wn.all([Ft.discoverClosestEndPointWithCaching(e),_e.createPeerConnectionOffer("recvonly",s,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=rn()(e,2),r=n[0],o=n[1],s=o.localOffer,u=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"+s.sdp);var l={};return a>1&&(l.maxAudioTracks=a),l.audioLanguages=i._channelContext.audioLanguages,i._channelContext.onRealTimeSubscribeRequestCallback&&(l.onSubscribeRequestCallback=i._channelContext.onRealTimeSubscribeRequestCallback),i._channelContext.onRealTimeSubscribeResponseCallback&&(l.onSubscribeResponseCallback=i._channelContext.onRealTimeSubscribeResponseCallback),!O.clientOfferDisabled&&u.supportsSetConfiguration&&u.supportsGetConfiguration?(s.sdp&&i._channelContext.audioLanguages.length&&(s.sdp=new an(s.sdp).withAudioLanguages(i._channelContext.audioLanguages)),r.subscribe(t,s,i._channelContext.failureCount.value,l)):(u.close(),u.dispose(),!Be.forceGarbageCollectionOnRestart||O.isMobile&&Be.skipGarbageCollectionOnMobileDevices||ot.forceGarbageCollection(),i._peerConnectionContext.peerConnection.value=null,r.subscribe(t,null,i._channelContext.failureCount.value,l))}).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,d=e.createAnswerDescriptionResponse,h=e.lag,f=(null==d?void 0:d.sessionDescription.sdp)||(null==c?void 0:c.sessionDescription.sdp),p=f?new an(f).audioSections:[],v=p.filter(function(e){return e.receivesMedia}).length,g=null;return i._channelContext.stream.value=a,i._channelContext.lag.value=h,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),i._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",i._channelContext.streamId,t,s,u,c,d),i.applyRtcConfiguration(i._peerConnectionContext.peerConnection.value,s).then(function(e){var t,s=!1,h=!1,f=[];i._peerConnectionContext.peerConnection.value||(i._peerConnectionContext.peerConnection.value=e),e.onicecandidate=function(n){i._channelContext.stream.value===a&&i._peerConnectionContext.peerConnection.value===e&&(s||Be.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?f.push(n.candidate):h=!0,t||(t=E.value.setTimeout(function(){var e;i._channelContext.stream.value!==a||s||null===(e=i._channelContext.endPoint.value)||void 0===e||e.addIceCandidates(a,f,h).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 E.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(E.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:J(e.iceConnectionState)}}};var y=function(){},_=new Wn(function(t,n){if(!O.onTrackDisabled){var r,o=E.value.setTimeout(function(){return n(new Error("Stream setup timed out"))},3e4),a=new Set,s=!0;return i._disposables.add(new m(function(){return E.value.clearTimeout(o)})),y=function(){var e=g&&s?l()(g).every(function(e){return a.has(e)}):a.size>=v;r&&e&&(E.value.clearTimeout(o),t(r))},void(e.ontrack=function(e){var t,n,i;r=e.streams[0]||r,"audio"===e.track.kind&&(s=s&&!(null===(t=e.transceiver)||void 0===t||!t.mid),a.add(null!==(n=null===(i=e.transceiver)||void 0===i?void 0:i.mid)&&void 0!==n?n:e.track.id)),y()})}var u=function(n){E.value.clearTimeout(c),e.removeEventListener("track",u),e.removeEventListener("addstream",u),t("streams"in n?n.streams[0]:n.stream)},c=E.value.setTimeout(function(){e.removeEventListener("track",u),e.removeEventListener("addstream",u),n(new Error("Stream setup timed out"))},3e4);e.addEventListener("track",u),e.addEventListener("addstream",u),i._disposables.add(new m(function(){return E.value.clearTimeout(c)}))});return new Wn(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(d)return i._logger.info("[%s] Set remote SDP answer [%s]",i._channelContext.streamId,d.sessionDescription.sdp),e.setRemoteDescription(d.sessionDescription).catch(function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,d.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(){var t=p.filter(function(e){return e.receivesMedia});if(g=new Set(i._channelContext.findAudioMidsToAccept(t,o)),v=g.size,e.supportsGetTransceivers)e.getTransceivers().forEach(function(e){var t,n;"audio"!==e.receiver.track.kind||null!==(t=g)&&void 0!==t&&t.has(null!==(n=e.mid)&&void 0!==n?n:"")||(e.direction="inactive")});else if(g.size!==t.length)throw new Error("Audio track selection requires transceivers");return y(),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),_}).then(function(t){var n,a;if(p.length&&e.supportsGetTransceivers){var s,u=e.getTransceivers(),l=p.filter(function(e){return e.receivesMedia&&(!g||g.has(e.mid))}).filter(function(e){return u.some(function(t){return t.mid===e.mid&&"audio"===t.receiver.track.kind})});i._channelContext.setAudioSections(l);var c=i._channelContext.findAudioSectionToPlay(),d=null!==(s=null==c?void 0:c.mid)&&void 0!==s?s:null;u.forEach(function(e){"audio"===e.receiver.track.kind&&(e.receiver.track.enabled=e.mid===d)}),i._channelContext.setSelectedAudioSection(c)}if(o&&null!=e&&null!==(n=e.currentRemoteDescription)&&void 0!==n&&n.sdp){var h,f,v,m=new an(e.currentRemoteDescription.sdp);i._streamTransformContext.videoTrack.codec=zn.convertVideoCodecTypeToVideoCodec(m.videoCodec),i._streamTransformContext.audioTrack.codec=Hn.convertAudioCodecTypeToAudioCodec(m.audioCodec);var y=e.getReceivers(),_=i._streamTransformContext.videoTrack.mediaStreamTrack=t.getVideoTracks()[0],b=i._streamTransformContext.videoTrack.receiver=y.filter(function(e){return e.track===_})[0];i._streamTransformContext.videoTrack.mid=e.supportsGetTransceivers?null===(h=e.getTransceivers().filter(function(e){return e.receiver===b})[0])||void 0===h?void 0:h.mid:null;var k=i._channelContext.selectedAudioMid.value,w=k&&e.supportsGetTransceivers?null===(f=e.getTransceivers().find(function(e){return e.mid===k}))||void 0===f?void 0:f.receiver.track:void 0,S=i._streamTransformContext.audioTrack.mediaStreamTrack=null!=w?w:t.getAudioTracks()[0],T=i._streamTransformContext.audioTrack.receiver=y.filter(function(e){return e.track===S})[0];i._streamTransformContext.audioTrack.mid=e.supportsGetTransceivers?null===(v=e.getTransceivers().filter(function(e){return e.receiver===T})[0])||void 0===v?void 0:v.mid:null;var x=!1,R=function(e,t){i._logger.error(e,i._channelContext.streamId,t),x||(x=!0,i._handleStreamFailure().catch(function(e){i._logger.error("[%s] Failed handling stream failure after encoded stream transform pipeline error",i._channelContext.streamId,e)}))};if(i._disposables.add(An.createEncodedStreamPipeline(i._streamTransformContext,function(e){R("[%s] Encoded stream transform pipeline failed",e)})),i._frameTimingInformationContext.shouldExtractTimecode.value||i._frameTimingInformationContext.shouldExtractTimestamps.value){var O={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:b,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 bn(O))}if(i._streamTransformContext.hasEncodedInsertableStreams.value){var P={videoTrack:i._streamTransformContext.videoTrack,audioTrack:i._streamTransformContext.audioTrack,encodedVideoStreamSink:i._streamTransformContext.encodedVideoStreamSink,encodedAudioStreamSink:i._streamTransformContext.encodedAudioStreamSink};i._disposables.add(new Un(P))}An.configureEncodedStreamPipeline(i._streamTransformContext).catch(function(e){R("[%s] Failed to configure encoded stream transform pipeline",e)})}var F=new Map;if(i._streamTransformContext.hasInsertableStreams.value){var I=An.configureInsertableStreamTransformation(t,i._streamTransformContext.videoStreamTransformCallback,i._streamTransformContext.audioStreamTransformCallback);i._disposables.add(I.disposables),t=I.transformedStream,F=I.renderedTracks}i._peerConnectionContext.renderedTracks=F,i._peerConnectionContext.mediaStream.value=t;var A=new fn(e,t,null!==(a=i._channelContext.endPoint.value)&&void 0!==a&&a.roundTripTime?i._channelContext.endPoint.value.roundTripTime/4:0,Be.applicationActivityMonitor.isForeground,i._channelContext.audioSections.value.map(function(e){return e.mid}).filter(function(e){return void 0!==e}),new C(i._channelContext.selectedAudioMid));i._disposables.add(A);var L=A.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(!Be.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)&&E.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 He(t.audio.timestamp-i._channelContext.rtcAudioStatistic.timestamp).toIsoString()),i._channelContext.rtcAudioStatistic=t.audio):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)&&E.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 He(t.video.timestamp-i._channelContext.rtcVideoStatistic.timestamp).toIsoString()),i._channelContext.rtcVideoStatistic=t.video),E.value.navigatorIsOnLine)if(r||n)i.reconnectPeerConnection(i._channelContext.streamId,e,function(){A.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!==ze.Reconnecting&&i._channelContext.state.value!==ze.Offline)return;i._channelContext.state.value=i._channelContext.playing.value?ze.Playing:ze.Paused,i._logger.info("Channel state restored to [%s] after reconnecting",ze[i._channelContext.state.value])}else i._channelContext.state.value=ze.Offline}});return i._disposables.add(L),Be.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=ze.Paused))})})})}},{key:"applyRtcConfiguration",value:(e=N()(qn().m(function e(t,n){var r;return qn().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return n=sn.truncateIceServers(n),e.a(2,Be.peerConnectionFactory.value.createPeerConnection(n));case 1:return r=Zn(Zn({},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(Be.applicationActivityMonitor.isForeground.value){if("closed"!==t.iceConnectionState){switch(this._channelContext.state.value){case ze.Paused:case ze.Stopped:case ze.Unauthorized:case ze.GeoRestricted:case ze.GeoBlocked:case ze.UnsupportedFeature:case ze.ConfigurationError:return void this._logger.debug("[%s] Skipping peerConnection reconnection in deliberately-terminal state [%s]",e,ze[this._channelContext.state.value])}if(this._channelContext.state.value=ze.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Be.maximalNumberOfPeerConnectionReconnectAttempts||!Be.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 Wn.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&&!t.muted||!r?Wn.resolve(!1):Xt.isRenderingFrames(t)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"mapSetRemoteDescriptionStatusToChannelStatus",value:function(e){switch(e){case"ok":return ze.Starting;case"unauthorized":return ze.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return ze.Recovering;case"failed":return ze.Error;default:J(e)}}}]);var e}(),Qn=function(){return o()(function e(){throw t()(this,e),new Error("StreamSubscriberFactory 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,s=a.includes("streaming"),u=a.includes("on-demand");return s||u?new tn(t,u?Qt.OndDemand:Qt.Live,o):new $n(t,n,r,i,o)}}])}(),Yn=function(e){return e[e.Idle=0]="Idle",e[e.Loading=1]="Loading",e[e.Playing=2]="Playing",e[e.Ended=3]="Ended",e[e.ReturningToRealTime=4]="ReturningToRealTime",e[e.Unauthorized=5]="Unauthorized",e[e.GeoRestricted=6]="GeoRestricted",e[e.GeoBlocked=7]="GeoBlocked",e[e.NoCoverage=8]="NoCoverage",e[e.NotFound=9]="NotFound",e[e.InvalidWindow=10]="InvalidWindow",e[e.UnsupportedFeature=11]="UnsupportedFeature",e[e.RealTimeUnavailable=12]="RealTimeUnavailable",e[e.Error=13]="Error",e}(Yn||{}),Xn=Yn,er=function(){return o()(function e(){t()(this,e),s()(this,"isSupported",new b(!1)),s()(this,"isReplaying",new b(!1)),s()(this,"state",new b(Xn.Idle)),s()(this,"window",new b(null)),s()(this,"error",new b(null)),s()(this,"autoMuted",new b(!1)),s()(this,"videoElement",new b(null))},[{key:"resetSession",value:function(){this.videoElement.value=null,this.autoMuted.value=!1,this.window.value=null,this.error.value=null,this.state.value=Xn.Idle,this.isReplaying.value=!1}}])}(),tr=function(){return o()(function e(){throw t()(this,e),new Error("ReplayStatusMapping is a static class that may not be instantiated")},null,[{key:"convertReplayStatusToReplayError",value:function(e){switch(e){case"no-stream":case"missing-index":case"segment-not-found":return"no-coverage";case"not-found":return"manifest-not-found";case"excessive-replay-interval":return"window-too-long";case"period-end-must-be-after-start":return"invalid-window";default:return e}}},{key:"convertReplayStatusToReplayState",value:function(e){switch(e){case"unauthorized":return Xn.Unauthorized;case"geo-restricted":return Xn.GeoRestricted;case"geo-blocked":return Xn.GeoBlocked;case"no-stream":case"missing-index":case"segment-not-found":return Xn.NoCoverage;case"not-found":return Xn.NotFound;case"period-end-must-be-after-start":case"excessive-replay-interval":case"invalid-window":return Xn.InvalidWindow;case"unsupported-feature":return Xn.UnsupportedFeature;case"real-time-unavailable":return Xn.RealTimeUnavailable;default:return Xn.Error}}}])}(),nr=n(981).A,rr=function(){function e(){throw t()(this,e),new Error("ReplayHlsLoader is a static class that may not be instantiated")}return o()(e,null,[{key:"isAvailable",value:function(){return Boolean(e.resolveLoaded()||Be.hlsJsLoader)}},{key:"load",value:function(){var t=e.resolveLoaded();if(t)return nr.resolve(t);if(e._pending)return e._pending;var n=Be.hlsJsLoader;if(!n)return nr.resolve(null);var r=e._generation;return e._pending=new nr(function(t){var i=0,o=!1,a=function(n){o||(o=!0,E.value.clearTimeout(i),n&&r===e._generation&&(e._cached=n),t(n))};i=E.value.setTimeout(function(){e._logger.warn("The registered hlsJsLoader did not call back within [%s] ms",1e4),a(null)},1e4);try{n(function(t){if("function"!=typeof t)return e._logger.error("The registered hlsJsLoader called back without an hls.js constructor"),void a(null);a(t)})}catch(t){e._logger.error("The registered hlsJsLoader threw while loading hls.js",t),a(null)}}).finally(function(){r===e._generation&&(e._pending=null)}),e._pending}},{key:"reset",value:function(){e._cached=null,e._pending=null,e._generation++}},{key:"resolveLoaded",value:function(){var t,n;return null!==(t=null!==(n=e._cached)&&void 0!==n?n:Zt.hlsPlayer)&&void 0!==t?t:null}}])}();function ir(e,t,n){return t=f()(t),d()(e,or()?Reflect.construct(t,n||[],f()(e).constructor):t.apply(e,n))}function or(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(or=function(){return!!e})()}s()(rr,"_logger",ee.getLogger("ReplayHlsLoader")),s()(rr,"_cached",null),s()(rr,"_pending",null),s()(rr,"_generation",0);var ar=function(e){function n(e,r){var i;return t()(this,n),i=ir(this,n,[e]),s()(i,"status",void 0),s()(i,"reason",void 0),i.name="ReplaySessionError",i.status=r,i.reason=tr.convertReplayStatusToReplayError(r),i}return v()(n,e),o()(n)}(ht()(Error)),sr=function(e){function n(e,r){var i;return t()(this,n),(i=ir(this,n,[e,r])).name="ReplayRefusedError",i}return v()(n,e),o()(n)}(ar),ur=function(e){function n(e,r){var i;return t()(this,n),(i=ir(this,n,[e,r])).name="ReplayPlaybackError",i}return v()(n,e),o()(n)}(ar),lr=function(e){function n(){var e;return t()(this,n),(e=ir(this,n,["Replay playback was cancelled."])).name="ReplayPlaybackCancelledError",e}return v()(n,e),o()(n)}(ht()(Error));function cr(e,t,n,r){return e.addEventListener(t,n,r),new m(function(){e.removeEventListener(t,n,r)})}function dr(){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,l=Object.create(u.prototype);return hr(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(hr(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,hr(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,hr(d,"constructor",l),hr(l,"constructor",u),u.displayName="GeneratorFunction",hr(l,i,"GeneratorFunction"),hr(d),hr(d,i,"Generator"),hr(d,r,function(){return this}),hr(d,"toString",function(){return"[object Generator]"}),(dr=function(){return{w:o,m:h}})()}function hr(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}hr=function(e,t,n,r){function o(t,n){hr(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))},hr(e,t,n,r)}var fr=function(){return o()(function e(n,r){var i=this;t()(this,e),s()(this,"_source",void 0),s()(this,"_lifetime",new ie),s()(this,"_ended",new b(!1)),s()(this,"_readOnlyEnded",new C(this._ended)),s()(this,"_fatalError",new b(null)),s()(this,"_readOnlyFatalError",new C(this._fatalError)),s()(this,"_session",null),s()(this,"_isDisposed",!1),this._source=r,this._lifetime.add(cr(n,"ended",function(){return i.markEnded()}))},[{key:"ended",get:function(){return this._readOnlyEnded}},{key:"fatalError",get:function(){return this._readOnlyFatalError}},{key:"play",value:(e=N()(dr().m(function e(t){var n;return dr().w(function(e){for(;;)switch(e.n){case 0:if(this.stop(),!this._isDisposed){e.n=1;break}throw new ur("The replay player has been disposed","failed");case 1:return this._fatalError.value=null,n=new ie,this._session=n,e.a(2,this._source.load(t,n))}},e,this)})),function(t){return e.apply(this,arguments)})},{key:"stop",value:function(){var e;null===(e=this._session)||void 0===e||e.dispose(),this._session=null,this._source.release(),this._ended.value=!1}},{key:"markEnded",value:function(){this._ended.value=!0}},{key:"reportFatalError",value:function(e){this._fatalError.value=e}},{key:"dispose",value:function(){this._isDisposed||(this._isDisposed=!0,this.stop(),this._lifetime.dispose())}}]);var e}(),pr=n(981).A;function vr(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}var mr=function(e,t,n,r){return{default:{maxTimeToFirstByteMs:e,maxLoadTimeMs:t,timeoutRetry:{maxNumRetry:n,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:r,retryDelayMs:1e3,maxRetryDelayMs:8e3}}}},gr={enableWorker:!0,lowLatencyMode:!1,backBufferLength:1/0,maxBufferLength:30,maxMaxBufferLength:120,startPosition:0,testBandwidth:!0,manifestLoadPolicy:mr(1/0,2e4,2,2),playlistLoadPolicy:mr(1e4,2e4,2,2),fragLoadPolicy:mr(1e4,12e4,4,4)},yr=function(){function e(n,r){t()(this,e),s()(this,"_logger",ee.getLogger("ReplayHlsJsPlayer")),s()(this,"_videoElement",void 0),s()(this,"_Hls",void 0),s()(this,"_lifecycle",void 0),s()(this,"_hls",null),s()(this,"_lastSegmentNumber",null),s()(this,"_isTailMissing",!1),this._videoElement=n,this._Hls=r,this._lifecycle=new fr(n,this)}return o()(e,[{key:"ended",get:function(){return this._lifecycle.ended}},{key:"fatalError",get:function(){return this._lifecycle.fatalError}},{key:"load",value:function(t,n){var r=this,i=this._Hls,o=new i(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vr(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({},gr));return this._hls=o,this._lastSegmentNumber=null,this._isTailMissing=!1,this._videoElement.srcObject=null,this._videoElement.removeAttribute("src"),new pr(function(a,s){var u=!1,l=function(e){u||(u=!0,e())},c=function(t,n){var o,a,c,d,h=e.errorDetails(n);if(n.fatal){var f,p;if(u&&r.isMissingTailSegment(n,h))return r._logger.info("Replay window is missing its final segment [%s]; the window ends when the buffered media has played out",null!==(f=null===(p=n.frag)||void 0===p?void 0:p.sn)&&void 0!==f?f:"n/a"),r._isTailMissing=!0,void r.endIfPlayedOut();var v=e.mapHlsErrorToStatus(n,i.ErrorTypes),m=new ur("Replay playback failed (".concat(null!=h?h:n.type,")"),v);r._logger.error("Fatal replay playback error [%s] [%s] on level [%s] fragment [%s], mapped to [%s]",n.type,h,null!==(o=null===(a=n.frag)||void 0===a?void 0:a.level)&&void 0!==o?o:"n/a",null!==(c=null===(d=n.frag)||void 0===d?void 0:d.sn)&&void 0!==c?c:"n/a",v),u?r._lifecycle.reportFatalError(m):l(function(){return s(m)})}else{var g,y,_,b;r._logger.warn("Recoverable replay playback error [%s] [%s] on level [%s] fragment [%s]",n.type,h,null!==(g=null===(y=n.frag)||void 0===y?void 0:y.level)&&void 0!==g?g:"n/a",null!==(_=null===(b=n.frag)||void 0===b?void 0:b.sn)&&void 0!==_?_:"n/a")}},d=function(){return l(a)},h=function(e,t){var n;r.selectStartLevel(o,null!==(n=t.levels)&&void 0!==n?n:[])},f=function(e,t){var n="object"===Ee()(t.details)?t.details.endSN:void 0;r._lastSegmentNumber="number"==typeof n?n:null},p=function(){return r._lifecycle.markEnded()};o.on(i.Events.ERROR,c),o.on(i.Events.FRAG_BUFFERED,d),o.on(i.Events.MANIFEST_PARSED,h),o.on(i.Events.LEVEL_LOADED,f),o.on(i.Events.MEDIA_ENDED,p),n.add(cr(r._videoElement,"timeupdate",function(){return r.endIfPlayedOut()})),n.add(cr(r._videoElement,"waiting",function(){return r.endIfPlayedOut()})),n.add(new m(function(){o.off(i.Events.ERROR,c),o.off(i.Events.FRAG_BUFFERED,d),o.off(i.Events.MANIFEST_PARSED,h),o.off(i.Events.LEVEL_LOADED,f),o.off(i.Events.MEDIA_ENDED,p),l(function(){return s(new lr)})})),o.attachMedia(r._videoElement),o.loadSource(t)})}},{key:"play",value:function(e){return this._lifecycle.play(e)}},{key:"release",value:function(){var e=this._hls;this._hls=null,e&&(e.stopLoad(),e.detachMedia(),e.destroy())}},{key:"stop",value:function(){this._lifecycle.stop()}},{key:"dispose",value:function(){this._lifecycle.dispose()}},{key:"selectStartLevel",value:function(t,n){var r,i,o=e.findHighestLevel(n);o<0||(this._logger.info("Starting replay on the highest level [%s] of [%s] [%sp]",o,n.length,null!==(r=null===(i=n[o])||void 0===i?void 0:i.height)&&void 0!==r?r:"unknown"),t.startLevel=o,t.nextAutoLevel=o)}},{key:"isMissingTailSegment",value:function(t,n){var r,i=null===(r=t.frag)||void 0===r?void 0:r.sn;return null!==this._lastSegmentNumber&&"number"==typeof i&&"fragLoadError"===n&&404===e.httpStatusOf(t)&&i>=this._lastSegmentNumber}},{key:"endIfPlayedOut",value:function(){if(this._isTailMissing&&!this._lifecycle.ended.value){var e=this.reachableBufferedEnd();null!==e?this._videoElement.currentTime>=e-.4&&(this._logger.info("Replay window played out the media that exists; treating the window as ended"),this._lifecycle.markEnded()):this._lifecycle.markEnded()}}},{key:"reachableBufferedEnd",value:function(){var e=this._videoElement.buffered;if(0===e.length)return null;for(var t=this._videoElement.currentTime,n=0;n<e.length;n++)if(t>=e.start(n)-.4&&t<=e.end(n)+.4)return e.end(n);return e.end(e.length-1)}}],[{key:"findHighestLevel",value:function(e){return e.length<2?-1:e.reduce(function(t,n,r){var i,o,a,s,u,l,c=null!==(i=n.height)&&void 0!==i?i:0,d=null!==(o=null===(a=e[t])||void 0===a?void 0:a.height)&&void 0!==o?o:0;return c!==d?c>d?r:t:(null!==(s=n.bitrate)&&void 0!==s?s:0)>(null!==(u=null===(l=e[t])||void 0===l?void 0:l.bitrate)&&void 0!==u?u:0)?r:t},0)}},{key:"isMediaRequest",value:function(e){return!!e&&(e.startsWith("frag")||e.startsWith("key"))}},{key:"errorDetails",value:function(e){return"string"==typeof e.details?e.details:void 0}},{key:"httpStatusOf",value:function(e){var t,n,r;return null!==(t=null===(n=e.response)||void 0===n?void 0:n.code)&&void 0!==t?t:null===(r=e.networkDetails)||void 0===r?void 0:r.status}},{key:"mapHlsErrorToStatus",value:function(t,n){switch(e.httpStatusOf(t)){case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 404:return e.isMediaRequest(e.errorDetails(t))?"segment-not-found":"not-found";case 408:return"timeout";case 429:case 504:return"rate-limited";case 503:return"capacity"}return n&&t.type===n.KEY_SYSTEM_ERROR?"unauthorized":"failed"}}])}(),_r=n(981).A,br=function(){return o()(function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("ReplayNativeHlsPlayer")),s()(this,"_videoElement",void 0),s()(this,"_lifecycle",void 0),this._videoElement=n,this._lifecycle=new fr(n,this)},[{key:"ended",get:function(){return this._lifecycle.ended}},{key:"fatalError",get:function(){return this._lifecycle.fatalError}},{key:"play",value:function(e){return this._lifecycle.play(e)}},{key:"load",value:function(e,t){var n=this;return this._logger.info("Playing replay window with native HLS playback"),this._videoElement.srcObject=null,this._videoElement.src=e,new _r(function(e,r){var i=!1;t.add(cr(n._videoElement,"loadedmetadata",function(){i||(i=!0,e())},{once:!0})),t.add(cr(n._videoElement,"error",function(){var e=new ur("Native HLS playback failed to load the replay window.","failed");i?n._lifecycle.reportFatalError(e):(i=!0,r(e))})),t.add(new m(function(){i||(i=!0,r(new lr))}))})}},{key:"release",value:function(){this._videoElement.hasAttribute("src")&&(this._videoElement.removeAttribute("src"),this._videoElement.load())}},{key:"stop",value:function(){this._lifecycle.stop()}},{key:"dispose",value:function(){this._lifecycle.dispose()}}],[{key:"isSupportedBy",value:function(e){return""!==e.canPlayType("application/vnd.apple.mpegurl")}}])}();function Cr(){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,l=Object.create(u.prototype);return kr(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(kr(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,kr(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,kr(d,"constructor",l),kr(l,"constructor",u),u.displayName="GeneratorFunction",kr(l,i,"GeneratorFunction"),kr(d),kr(d,i,"Generator"),kr(d,r,function(){return this}),kr(d,"toString",function(){return"[object Generator]"}),(Cr=function(){return{w:o,m:h}})()}function kr(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}kr=function(e,t,n,r){function o(t,n){kr(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))},kr(e,t,n,r)}var wr=function(){function e(){throw t()(this,e),new Error("ReplayPlayerFactory is a static class that may not be instantiated")}return o()(e,null,[{key:"isSupported",value:function(){return rr.isAvailable()||e.playsNatively()}},{key:"playsNatively",value:function(){return br.isSupportedBy(E.value.documentCreateElement("video"))}},{key:"create",value:(n=N()(Cr().m(function t(n){var r;return Cr().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,rr.load();case 1:if(!(r=t.v)||!r.isSupported()){t.n=2;break}return t.a(2,new yr(n,r));case 2:if(!br.isSupportedBy(n)){t.n=3;break}return e._logger.info("hls.js is unavailable; falling back to native HLS playback"),t.a(2,new br(n));case 3:throw new ur("Replay requires hls.js (register one with SDK.init({hlsJsLoader})) or native HLS playback support","unsupported-feature");case 4:return t.a(2)}},t)})),function(e){return n.apply(this,arguments)})}]);var n}();s()(wr,"_logger",ee.getLogger("ReplayPlayerFactory"));var Sr=function(){function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("ReplayPresentation")),s()(this,"_replayVideoElement",void 0),s()(this,"_element",null),s()(this,"_geometrySubscriptions",null),this._replayVideoElement=n}return o()(e,[{key:"element",get:function(){return this._element}},{key:"attach",value:function(){var e;if(this._element)return this._element;var t=this._replayVideoElement,n=document.createElement("video");return n.dataset.rtsReplay="true",n.playsInline=!0,n.autoplay=!1,n.controls=t.controls,n.muted=t.muted,n.volume=t.volume,this.applyLayout(n),(null!==(e=t.parentElement)&&void 0!==e?e:document.body).appendChild(n),this._element=n,this._geometrySubscriptions=new ie,this.observeGeometry(),this.syncGeometry(),n}},{key:"detach",value:function(){var e;null===(e=this._geometrySubscriptions)||void 0===e||e.dispose(),this._geometrySubscriptions=null;var t=this._element;if(this._element=null,t){try{t.pause()}catch(e){this._logger.debug("Replay element rejected pause() during teardown",e)}t.removeAttribute("src"),t.srcObject=null;try{t.load()}catch(e){this._logger.debug("Replay element rejected load() during teardown",e)}t.remove()}}},{key:"dispose",value:function(){this.detach()}},{key:"applyLayout",value:function(t){var n=t.style;n.position="absolute",n.margin="0",n.padding="0",n.border="none",n.backgroundColor="#000",n.objectFit=e.readComputedStyle(this._replayVideoElement,"objectFit")||"contain",n.zIndex=e.overlayZIndex(this._replayVideoElement)}},{key:"observeGeometry",value:function(){var e=this,t=this._geometrySubscriptions;if(t){var n=function(){return e.syncGeometry()},r=window.ResizeObserver;if(r){var i=new r(n);i.observe(this._replayVideoElement),t.add(new m(function(){return i.disconnect()}))}E.value.addWindowEventListener("resize",n),E.value.addWindowEventListener("scroll",n,!0),t.add(new m(function(){E.value.removeWindowEventListener("resize",n),E.value.removeWindowEventListener("scroll",n,!0)})),t.add(cr(this._replayVideoElement,"loadedmetadata",n)),t.add(cr(this._replayVideoElement,"resize",n))}}},{key:"syncGeometry",value:function(){var e=this._element;if(e){var t=this._replayVideoElement.getBoundingClientRect(),n=e.offsetParent,r=t.left,i=t.top;if(n){var o=n.getBoundingClientRect();r=t.left-o.left-n.clientLeft+n.scrollLeft,i=t.top-o.top-n.clientTop+n.scrollTop}else r=t.left+(window.scrollX||0),i=t.top+(window.scrollY||0);e.style.left="".concat(r,"px"),e.style.top="".concat(i,"px"),e.style.width="".concat(t.width,"px"),e.style.height="".concat(t.height,"px")}}}],[{key:"readComputedStyle",value:function(e,t){var n,r;return"function"!=typeof window.getComputedStyle?"":null!==(n=null===(r=window.getComputedStyle(e))||void 0===r?void 0:r[t])&&void 0!==n?n:""}},{key:"overlayZIndex",value:function(t){var n=Number.parseInt(e.readComputedStyle(t,"zIndex"),10);return String(Number.isFinite(n)?n+1:1)}}])}(),Tr=["ok","no-stream","missing-index","period-end-must-be-after-start","excessive-replay-interval","unauthorized","geo-restricted","geo-blocked","not-found","capacity","rate-limited","timeout","failed"],xr=function(){function e(){throw t()(this,e),new Error("ReplayWindows is a static class that may not be instantiated")}return o()(e,null,[{key:"defaultEndSkewMs",get:function(){return 8e3}},{key:"toIsoString",value:function(e){return new Date(e).toISOString()}},{key:"resolve",value:function(t,n){var r,i,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=e.toEpochMs(t);if(!Number.isFinite(a)||!Number.isFinite(n))throw new sr("Replay window startTime and duration must be finite","invalid-window");if(n<=0)throw new sr("Replay window duration must be greater than zero","invalid-window");var s=a+n;if(!e.isRepresentable(a)||!e.isRepresentable(s))throw new sr("Replay window lies outside the range a date can represent","invalid-window");var u=(null!==(r=o.nowMs)&&void 0!==r?r:Date.now())-(null!==(i=o.endSkewMs)&&void 0!==i?i:8e3);if(a>=u)throw new sr("Replay window does not overlap the available range","invalid-window");var l=Math.min(s,u);return{startTime:a,endTime:l,requestedStartTime:a,requestedEndTime:s,wasAdjusted:l!==s}}},{key:"toEpochMs",value:function(e){return e instanceof Date?e.getTime():e}},{key:"isRepresentable",value:function(e){return!Number.isNaN(new Date(e).getTime())}}])}();function Er(){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,l=Object.create(u.prototype);return Rr(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Rr(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Rr(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Rr(d,"constructor",l),Rr(l,"constructor",u),u.displayName="GeneratorFunction",Rr(l,i,"GeneratorFunction"),Rr(d),Rr(d,i,"Generator"),Rr(d,r,function(){return this}),Rr(d,"toString",function(){return"[object Generator]"}),(Er=function(){return{w:o,m:h}})()}function Rr(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Rr=function(e,t,n,r){function o(t,n){Rr(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))},Rr(e,t,n,r)}var Or=["edgeAuthToken"],Pr=function(){function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e4;t()(this,e),s()(this,"_logger",ee.getLogger("ReplayApi")),s()(this,"_baseUri",void 0),s()(this,"_timeoutMs",void 0),this._baseUri=n,this._timeoutMs=r}return o()(e,[{key:"buildReplayManifestUrl",value:function(e,t,n){var r=re.parseToken(e).tenancy;if(!r)throw new Error("Replay token is missing an applicationId");return this.buildManifestUrl(r,e,t,n)}},{key:"getReplayManifest",value:(n=N()(Er().m(function t(n,r,i){var o,a,s,u,l,c,d,h;return Er().w(function(t){for(;;)switch(t.p=t.n){case 0:if(o=re.parseToken(n).tenancy){t.n=1;break}return this._logger.error("Replay token is missing an applicationId"),t.a(2,{status:"unauthorized"});case 1:return a=this.buildManifestUrl(o,n,r,i),s=new E.value.AbortController,u=E.value.setTimeout(function(){return s.abort()},this._timeoutMs),t.p=2,t.n=3,E.value.fetch(a.toString(),{method:"GET",cache:"no-cache",signal:s.signal});case 3:if(l=t.v,c=e.mapHttpStatusToReplayStatus(l.status),this._logger.debug("Replay manifest fetch status [%s]",c),"timeout"!==c){t.n=4;break}return t.a(2,{status:c});case 4:return t.n=5,l.text();case 5:if(d=t.v,"ok"===c){t.n=6;break}return this.logNonManifestBody(d),t.a(2,{status:e.statusFromBody(d,c)});case 6:if(!d.trim().startsWith("#EXTM3U")){t.n=7;break}return t.a(2,{status:"ok",manifest:d,url:l.url||a.toString()});case 7:return this.logNonManifestBody(d),t.a(2,{status:e.statusFromBody(d,"no-stream")});case 8:if(t.p=8,"AbortError"!==(null==(h=t.v)?void 0:h.name)){t.n=9;break}return t.a(2,{status:"timeout"});case 9:return this._logger.error("Failed to fetch replay manifest [%s]",a.pathname,h),t.a(2,{status:"failed"});case 10:return t.p=10,E.value.clearTimeout(u),t.f(10);case 11:return t.a(2)}},t,this,[[2,8,10,11]])})),function(e,t,r){return n.apply(this,arguments)})},{key:"buildManifestUrl",value:function(e,t,n,r){var i=Se.buildRouteUrl(Se.normalizeDiscoveryUri(this._baseUri),[e,"stream","replay","".concat("primary",".m3u8")]);return i.searchParams.set("edgeAuthToken",t),i.searchParams.set("startTime",xr.toIsoString(n)),i.searchParams.set("endTime",xr.toIsoString(r)),i.searchParams.set("apiVersion","0"),i.searchParams.set("clientVersion",B.sdkVersion),i}},{key:"logNonManifestBody",value:function(t){var n=t.trim();if(n){var r=e.redactCredentials(n),i=r.length>512?"".concat(r.substring(0,512),"[...]"):r;this._logger.debug("Replay manifest response was not a playlist, body [%s]",i)}else this._logger.debug("Replay manifest response body was empty")}}],[{key:"mapHttpStatusToReplayStatus",value:function(e){switch(e){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 404:return"not-found";case 408:return"timeout";case 429:case 504:return"rate-limited";case 503:return"capacity";default:return"failed"}}},{key:"statusFromBody",value:function(e,t){var n,r=e.trim();if(!r)return t;try{var i=JSON.parse(r),o=null==i?void 0:i.status;if("string"==typeof(n=o)&&Tr.includes(n)&&"ok"!==o)return o}catch(e){}return t}},{key:"redactCredentials",value:function(e){return Or.reduce(function(e,t){return e.replace(new RegExp("".concat(t,"=[^&\\s\"'<]*"),"gi"),"".concat(t,"=[redacted]")).replace(new RegExp('"'.concat(t,'"\\s*:\\s*"[^"]*"'),"gi"),'"'.concat(t,'":"[redacted]"'))},e)}}]);var n}(),Fr="replay",Ir=["streaming","on-demand"],Ar=function(){function e(){throw t()(this,e),new Error("ReplayCapabilities is a static class that may not be instantiated")}return o()(e,null,[{key:"capabilityReplay",get:function(){return Fr}},{key:"capabilitiesChunkedStreaming",get:function(){return Ir}},{key:"includesReplay",value:function(e){return e.includes(Fr)}},{key:"includesChunkedStreaming",value:function(e){return Ir.some(function(t){return e.includes(t)})}},{key:"tokenHasReplay",value:function(t){return e.includesReplay(re.parseToken(t).capabilities)}},{key:"tokenIsForChunkedStreaming",value:function(t){return e.includesChunkedStreaming(re.parseToken(t).capabilities)}}])}();function Lr(){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,l=Object.create(u.prototype);return Dr(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Dr(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Dr(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Dr(d,"constructor",l),Dr(l,"constructor",u),u.displayName="GeneratorFunction",Dr(l,i,"GeneratorFunction"),Dr(d),Dr(d,i,"Generator"),Dr(d,r,function(){return this}),Dr(d,"toString",function(){return"[object Generator]"}),(Lr=function(){return{w:o,m:h}})()}function Dr(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Dr=function(e,t,n,r){function o(t,n){Dr(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))},Dr(e,t,n,r)}var jr=function(){return o()(function e(n){var r;t()(this,e),s()(this,"_logger",ee.getLogger("ReplayController")),s()(this,"_dependencies",void 0),s()(this,"_context",void 0),s()(this,"_now",void 0),s()(this,"_player",null),s()(this,"_sessionDisposables",null),s()(this,"_isDisposed",!1),s()(this,"_epoch",0),this._dependencies=n,this._context=n.context,this._now=null!==(r=n.now)&&void 0!==r?r:function(){return Date.now()}},[{key:"start",value:(r=N()(Lr().m(function e(t,n){var r,i,o,a,s,u,l,c,d,h=this;return Lr().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!this._isDisposed){e.n=1;break}throw new Error("ReplayController has been disposed");case 1:return this.refuseWhenBusy(),r=this.validate(t,n),i=++this._epoch,this._context.state.value=Xn.Loading,this._context.error.value=null,this._context.window.value=r,this._context.autoMuted.value=!1,r.wasAdjusted&&this._logger.info("Replay window end moved back to the live-edge safety margin, from [%s] to [%s]",xr.toIsoString(r.requestedEndTime),xr.toIsoString(r.endTime)),e.p=2,e.n=3,this._dependencies.getManifest(t,r.startTime,r.endTime);case 3:o=e.v,e.n=6;break;case 4:if(e.p=4,l=e.v,i===this._epoch){e.n=5;break}return e.a(2);case 5:throw this.failWith(l),l;case 6:if(i===this._epoch){e.n=7;break}return e.a(2);case 7:if("ok"===o.status){e.n=8;break}throw this._logger.warn("Replay manifest request failed with status [%s]",o.status),a=new sr("Replay failed with status ".concat(o.status),o.status),this.failWith(a),a;case 8:if(this._context.isReplaying.value=!0,s=this._dependencies.presentation.attach(),this._context.videoElement.value=s,this._dependencies.realTime.muteForReplay(),i===this._epoch){e.n=9;break}return e.a(2);case 9:return e.p=9,e.n=10,this._dependencies.createPlayer(s);case 10:u=e.v,e.n=13;break;case 11:if(e.p=11,c=e.v,i===this._epoch){e.n=12;break}return e.a(2);case 12:throw this.failWith(c),c;case 13:if(i===this._epoch){e.n=14;break}return u.dispose(),e.a(2);case 14:return this._player=u,this._sessionDisposables=new ie,this._sessionDisposables.add(u.ended.subscribe(function(e){return h.onEnded(e)})),this._sessionDisposables.add(u.fatalError.subscribe(function(e){return h.onFatalError(e)})),e.p=15,e.n=16,u.play(o.url);case 16:if(i===this._epoch){e.n=17;break}return e.a(2);case 17:e.n=20;break;case 18:if(e.p=18,d=e.v,!(i!==this._epoch||d instanceof lr)){e.n=19;break}return e.a(2);case 19:throw this.failWith(d),d;case 20:return this._context.state.value===Xn.Loading&&(this._context.state.value=Xn.Playing),e.n=21,this.startPlayback(s,i);case 21:return e.a(2)}},e,this,[[15,18],[9,11],[2,4]])})),function(e,t){return r.apply(this,arguments)})},{key:"returnToRealTime",value:(n=N()(Lr().m(function e(){var t,n;return Lr().w(function(e){for(;;)switch(e.n){case 0:if(this.hasSession()){e.n=1;break}return e.a(2);case 1:if(t=++this._epoch,this._context.state.value=Xn.ReturningToRealTime,this.teardownSession(),this._dependencies.realTime.restoreMutedState(),!this._isDisposed&&t===this._epoch){e.n=2;break}return e.a(2);case 2:n=this._dependencies.realTime.isRealTimeAvailable(),this._context.isReplaying.value=!1,this._context.window.value=null,this._context.autoMuted.value=!1,this._context.error.value=n?null:"real-time-unavailable",this._context.state.value=n?Xn.Idle:Xn.RealTimeUnavailable,n||this._logger.info("Replay ended but there is no real-time stream to return to");case 3:return e.a(2)}},e,this)})),function(){return n.apply(this,arguments)})},{key:"dispose",value:function(){this._isDisposed||(this._isDisposed=!0,this._epoch++,this.teardownSession(),this._dependencies.presentation.dispose(),this._context.isReplaying.value=!1)}},{key:"hasSession",value:function(){switch(this._context.state.value){case Xn.Loading:case Xn.Playing:case Xn.Ended:return!0;default:return!1}}},{key:"refuseWhenBusy",value:function(){switch(this._context.state.value){case Xn.Loading:case Xn.Playing:case Xn.Ended:throw new sr("A replay window is already loading or playing; call returnToRealTime() before starting another.","already-replaying");case Xn.ReturningToRealTime:throw new sr("A return to real time is still in progress; wait for it to complete before requesting replay again.","already-replaying");default:return}}},{key:"validate",value:function(e,t){var n=this.parseCapabilitiesOrRefuse(e);Ar.includesChunkedStreaming(n)&&this.refuse("Replay is not supported on a chunked channel","unsupported-feature"),Ar.includesReplay(n)||this.refuse("Replay token does not include the capability [".concat(Ar.capabilityReplay,"]"),"unauthorized"),this._dependencies.isPlayerSupported()||this.refuse("Replay requires hls.js (register one with SDK.init({hlsJsLoader})) or native HLS playback support","unsupported-feature");try{return xr.resolve(t.startTime,t.duration,{nowMs:this._now()})}catch(e){var r=e instanceof ar?e.status:"invalid-window";this.refuse(e.message,r)}}},{key:"parseCapabilitiesOrRefuse",value:function(e){var t=re.parseToken(e);return t.tenancy||this.refuse("Replay token is not valid","unauthorized"),t.capabilities}},{key:"refuse",value:function(e,t){throw this._logger.warn("Replay request refused with status [%s]",t),this._context.state.value=tr.convertReplayStatusToReplayState(t),this._context.error.value=tr.convertReplayStatusToReplayError(t),new sr(e,t)}},{key:"onEnded",value:function(e){e&&this.hasSession()&&(this._context.state.value=Xn.Ended,this.returnToRealTime())}},{key:"onFatalError",value:function(e){e&&this.hasSession()&&(this._logger.error("Replay session failed after playback had started",e),this.failWith(e))}},{key:"startPlayback",value:(e=N()(Lr().m(function e(t,n){var r,i;return Lr().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,t.play();case 1:return e.a(2);case 2:if(e.p=2,r=e.v,n===this._epoch){e.n=3;break}return e.a(2);case 3:return t.muted&&this.failPlayback(r),this._logger.debug("Replay element rejected play(); retrying muted",r),t.muted=!0,this._context.autoMuted.value=!0,e.p=4,e.n=5,t.play();case 5:e.n=8;break;case 6:if(e.p=6,i=e.v,n===this._epoch){e.n=7;break}return e.a(2);case 7:this.failPlayback(i);case 8:return e.a(2)}},e,this,[[4,6],[0,2]])})),function(t,n){return e.apply(this,arguments)})},{key:"failPlayback",value:function(e){if("NotAllowedError"!==e.name)throw this.failWith(e),e;this._logger.warn("Replay element was not allowed to play, even muted",e);var t=new ur("The browser did not allow the replay element to play","autoplay-blocked");throw this.failWith(t),t}},{key:"failWith",value:function(e){var t=e instanceof ar?e.status:"failed";this._epoch++,e instanceof ar||this._logger.error("Failed to play replay window",e),this.teardownSession(),this._dependencies.realTime.restoreMutedState(),this._context.isReplaying.value=!1,this._context.window.value=null,this._context.autoMuted.value=!1,this._context.state.value=tr.convertReplayStatusToReplayState(t),this._context.error.value=tr.convertReplayStatusToReplayError(t)}},{key:"teardownSession",value:function(){var e,t;null===(e=this._sessionDisposables)||void 0===e||e.dispose(),this._sessionDisposables=null,null===(t=this._player)||void 0===t||t.dispose(),this._player=null,this._dependencies.presentation.detach(),this._context.videoElement.value=null}}]);var e,n,r}();function Mr(){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,l=Object.create(u.prototype);return Nr(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Nr(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Nr(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Nr(d,"constructor",l),Nr(l,"constructor",u),u.displayName="GeneratorFunction",Nr(l,i,"GeneratorFunction"),Nr(d),Nr(d,i,"Generator"),Nr(d,r,function(){return this}),Nr(d,"toString",function(){return"[object Generator]"}),(Mr=function(){return{w:o,m:h}})()}function Nr(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Nr=function(e,t,n,r){function o(t,n){Nr(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))},Nr(e,t,n,r)}var Vr=function(){return o()(function e(n,r){t()(this,e),s()(this,"_logger",ee.getLogger("ChannelReplay")),s()(this,"_context",void 0),s()(this,"_dependencies",void 0),s()(this,"_readOnlyIsSupported",void 0),s()(this,"_readOnlyIsReplaying",void 0),s()(this,"_readOnlyState",void 0),s()(this,"_readOnlyWindow",void 0),s()(this,"_readOnlyError",void 0),s()(this,"_readOnlyAutoMuted",void 0),s()(this,"_controller",null),s()(this,"_controllerVideoElement",null),s()(this,"_controllerRealTime",null),s()(this,"_isDisposed",!1),this._context=n,this._dependencies=r,this._readOnlyIsSupported=new C(n.isSupported),this._readOnlyIsReplaying=new C(n.isReplaying),this._readOnlyState=new C(n.state),this._readOnlyWindow=new C(n.window),this._readOnlyError=new C(n.error),this._readOnlyAutoMuted=new C(n.autoMuted),this.refreshSupport()},[{key:"isSupported",get:function(){return this._readOnlyIsSupported}},{key:"isReplaying",get:function(){return this._readOnlyIsReplaying}},{key:"state",get:function(){return this._readOnlyState}},{key:"window",get:function(){return this._readOnlyWindow}},{key:"error",get:function(){return this._readOnlyError}},{key:"autoMuted",get:function(){return this._readOnlyAutoMuted}},{key:"start",value:(n=N()(Mr().m(function e(t){var n;return Mr().w(function(e){for(;;)if(0===e.n)return this._isDisposed&&this.refuse("The channel has been disposed","unsupported-feature"),this.onVideoElementChanged(),(n=this._dependencies.getVideoElement())||this.refuse("Replay requires a video element","unsupported-feature"),e.a(2,this.getOrCreateController(n).start(this._dependencies.getToken(),t))},e,this)})),function(e){return n.apply(this,arguments)})},{key:"returnToRealTime",value:(e=N()(Mr().m(function e(){var t;return Mr().w(function(e){for(;;)if(0===e.n)return e.a(2,null===(t=this._controller)||void 0===t?void 0:t.returnToRealTime())},e,this)})),function(){return e.apply(this,arguments)})},{key:"refreshSupport",value:function(){this._context.isSupported.value=this.computeIsSupported()}},{key:"onVideoElementChanged",value:function(){this._controllerVideoElement!==this._dependencies.getVideoElement()&&this.reset()}},{key:"reset",value:function(){this.disposeController(),this._context.resetSession(),this.refreshSupport()}},{key:"dispose",value:function(){this._isDisposed||(this._isDisposed=!0,this.disposeController(),this._context.resetSession(),this._context.isSupported.value=!1)}},{key:"computeIsSupported",value:function(){if(this._isDisposed||!this.isPlayerSupported())return!1;try{var e=this._dependencies.getToken();return Ar.tokenHasReplay(e)&&!Ar.tokenIsForChunkedStreaming(e)}catch(e){return this._logger.debug("Unable to determine replay support from the channel token",e),!1}}},{key:"isPlayerSupported",value:function(){var e;return(null!==(e=this._dependencies.isPlayerSupported)&&void 0!==e?e:wr.isSupported)()}},{key:"getOrCreateController",value:function(e){var t,n,r=this;if(this._controller)return this._controller;var i=this._dependencies.createRealTimePresentation(e);return this._controller=new jr({context:this._context,presentation:new Sr(e),realTime:i,getManifest:null!==(t=this._dependencies.getManifest)&&void 0!==t?t:function(e,t,n){return new Pr(r._dependencies.getBaseUri(e)).getReplayManifest(e,t,n)},createPlayer:null!==(n=this._dependencies.createPlayer)&&void 0!==n?n:wr.create,isPlayerSupported:function(){return r.isPlayerSupported()},now:this._dependencies.now}),this._controllerVideoElement=e,this._controllerRealTime=i,this._controller}},{key:"disposeController",value:function(){var e,t;null===(e=this._controller)||void 0===e||e.dispose(),null===(t=this._controllerRealTime)||void 0===t||t.restoreMutedState(),this._controller=null,this._controllerVideoElement=null,this._controllerRealTime=null}},{key:"refuse",value:function(e,t){throw this._logger.warn("Replay request refused with status [%s]",t),this._context.state.value=tr.convertReplayStatusToReplayState(t),this._context.error.value=tr.convertReplayStatusToReplayError(t),new sr(e,t)}}]);var e,n}(),Br=function(){function e(n,r){t()(this,e),s()(this,"_videoElement",void 0),s()(this,"_dependencies",void 0),s()(this,"_isMutedForReplay",!1),s()(this,"_mutedBeforeReplay",!1),this._videoElement=n,this._dependencies=r}return o()(e,[{key:"muteForReplay",value:function(){this._isMutedForReplay||(this._isMutedForReplay=!0,this._mutedBeforeReplay=this._videoElement.muted,this._videoElement.muted=!0)}},{key:"restoreMutedState",value:function(){this._isMutedForReplay&&(this._isMutedForReplay=!1,this._videoElement.muted=this._mutedBeforeReplay)}},{key:"isRealTimeAvailable",value:function(){return!e.isGone(this._dependencies.getMediaStream())}}],[{key:"isGone",value:function(e){if(!e)return!0;try{var t=e.getTracks();return t.length>0&&t.every(function(e){return"live"!==e.readyState})}catch(e){return!1}}}])}(),Gr=n(981).A;function Ur(){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,l=Object.create(u.prototype);return zr(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(zr(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,zr(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,zr(d,"constructor",l),zr(l,"constructor",u),u.displayName="GeneratorFunction",zr(l,i,"GeneratorFunction"),zr(d),zr(d,i,"Generator"),zr(d,r,function(){return this}),zr(d,"toString",function(){return"[object Generator]"}),(Ur=function(){return{w:o,m:h}})()}function zr(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}zr=function(e,t,n,r){function o(t,n){zr(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))},zr(e,t,n,r)}var Hr=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,"_replayContext",void 0),s()(this,"_replay",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,"_readOnlyAudioTracks",void 0),s()(this,"_readOnlySelectedAudioTrack",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),s()(this,"_mutedAfterReplay",null);var a=re.parseToken(r),u={maxAudioTracks:null==i?void 0:i.maxAudioTracks,audioLanguages:null==i?void 0:i.audioLanguages,targetLag:null==i?void 0:i.targetLag,onRealTimeSubscribeRequestCallback:null==i?void 0:i.onRealTimeSubscribeRequestCallback,onRealTimeSubscribeResponseCallback:null==i?void 0:i.onRealTimeSubscribeResponseCallback},l={forceGarbageCollectionOnRestart:Be.forceGarbageCollectionOnRestart},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 Xe(r),this._channelContext=new tt(u),this._peerConnectionContext=new at(l),this._streamTransformContext=new it(c),this._stateContext=new st,this._exponentialBackoff=new Re,this._replayContext=new er,this._channelStartTime=Date.now(),this._replay=new Vr(this._replayContext,{getVideoElement:function(){return o._channelContext.videoElement.value},getToken:function(){return o.token},getBaseUri:function(e){return o.getUri(e).toString()},createRealTimePresentation:function(e){return new Br(e,{getMediaStream:function(){return o._peerConnectionContext.mediaStream.value}})}}),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._readOnlyAudioTracks=new C(this._channelContext.audioTracks),this._readOnlySelectedAudioTrack=new C(this._channelContext.selectedAudioTrack),this._readOnlyMediaStream=new C(this._peerConnectionContext.mediaStream);var d=(a.uri||Be.discoveryUri.value).toString();Be.tenancy.value=a.tenancy||Be.tenancy.value,Te.uri.value=d,this._metricsService=Ne.getMetricsService(d),this._sessionTelemetry=new Ze(Be.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._channelContext.channelDisposables.add(this._replayContext.isReplaying.subscribe(function(e){e||o.applyMutedIntentAfterReplay()})),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=n,this._frameTimingInformationContext=new ut,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=Be.clientSessionId,o.videoElement.dataset.streamId=o.streamId),o._channelContext.videoTelemetry=new qe(o.streamId,Be.pageLoadTime,o._channelStartTime,o._metricsService),o._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(o.videoElement),o._channelContext.videoTelemetry.setupListenerForRebuffering(o.videoElement),o._channelContext.state.value===ze.Stopped)&&o.restartAfterStop()})),o._channelContext.channelDisposables.add(o._channelContext.rendererDisposables))})),this._channelContext.channelDisposables.add(this._channelContext.state.subscribe(function(e){o._channelContext.clearFailureCountTimeout&&E.value.clearTimeout(o._channelContext.clearFailureCountTimeout),o._channelContext.failureCount.value&&e===ze.Playing&&(o._channelContext.clearFailureCountTimeout=E.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,Ye.Normal).catch(function(e){o._logger.error("Error while setting limit bitrate",e)})}})),this._channelContext.channelDisposables.add(this._replayContext.isReplaying.subscribe(function(e){e||o.reevaluateRealTimeHealthAfterReplay()}));var h=function(){o._channelContext.stream.value&&o._channelContext.endPoint.value&&o._channelContext.endPoint.value.destroyStreamOnUnmount(o._channelContext.stream.value,"client:termination-on-window-unload")};E.value.addWindowEventListener("beforeunload",h),this._channelContext.channelDisposables.add(new m(function(){E.value.removeWindowEventListener("beforeunload",h)})),this.start(),Be.automaticRetryOnFailure&&this._channelContext.channelDisposables.add(Be.applicationActivityMonitor.isForeground.subscribe(function(e){if(e){var t=Be.applicationActivityMonitor.getLastBackgroundDuration(),n=O.isMobile&&null!==t&&t>5e3,r=o._channelContext.state.value===ze.Reconnecting&&null!==t&&t>3e4;if(n||r)return o._logger.info("[%s] Foregrounded after [%s] ms in background, trying restart",o._channelContext.streamId,t),void o.tryRestart("client:foregrounded:background-timeout");o.isRetryableState()?o.tryRestart("client:foregrounded:unhealthy"):o._streamSubscriber&&o.isSubscriberHealthy().then(function(e){e||o._channelContext.state.value===ze.Playing&&o.tryRestart("client:foregrounded:unhealthy-health-check")}).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!==ze.Initializing&&(this._channelContext.state.value=ze.Stopped),this._channelContext.videoElement.value=e,this._replay.onVideoElementChanged(),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||Be.discoveryUri.value).toString();Be.tenancy.value=t.tenancy||Be.tenancy.value,Te.uri.value=n,this._metricsService=Ne.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._replay.refreshSupport(),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:"audioTracks",get:function(){return this._readOnlyAudioTracks}},{key:"selectedAudioTrack",get:function(){return this._readOnlySelectedAudioTrack}},{key:"selectAudioTrack",value:function(e){var t=this._channelContext.findAudioSection(e);if(!t)throw new Error("Audio track [".concat(e,"] is not delivered"));this._channelContext.requestedAudioTrack={id:e,language:t.language},this._channelContext.setSelectedAudioSection(t),this._channelContext.rtcAudioStatistic=null,this.applyAudioTrackSelection()}},{key:"applyAudioTrackSelection",value:function(){var e=this,t=this._peerConnectionContext.peerConnection.value,n=this._channelContext.selectedAudioMid.value,r=this._peerConnectionContext.mediaStream.value;if(null!=t&&t.supportsGetTransceivers&&n&&r){var i,o=$e.applyToMediaStream(t.getTransceivers(),n,r,this._peerConnectionContext.renderedTracks),a=this._channelContext.videoElement.value;o&&a&&a.srcObject===r&&(a.srcObject=null,a.srcObject=r,null===(i=a.play())||void 0===i||i.catch(function(t){e._logger.warn("[%s] Failed to resume playback after switching audio track",e._channelContext.streamId,t)}))}}},{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:"replay",get:function(){return this._replay}},{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,Ye.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:(h=N()(Ur().m(function e(t){var n=this;return Ur().w(function(e){for(;;)if(0===e.n)return e.a(2,new Gr(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 h.apply(this,arguments)})},{key:"processStop",value:function(e){this._replay.reset(),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=ze.Stopped}},{key:"resume",value:(d=N()(Ur().m(function e(){return Ur().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 d.apply(this,arguments)})},{key:"mute",value:function(){var e=this._replayContext.videoElement.value;if(e)return e.muted=!0,void(this._mutedAfterReplay=!0);var t=this._channelContext.videoElement.value;t&&(t.muted=!0)}},{key:"unmute",value:function(){var e=this._replayContext.videoElement.value;if(e)return e.muted=!1,void(this._mutedAfterReplay=!1);var t=this._channelContext.videoElement.value;t&&(t.muted=!1,this._channelContext.autoMuted.value=!1)}},{key:"applyMutedIntentAfterReplay",value:function(){if(null!==this._mutedAfterReplay){var e=this._mutedAfterReplay,t=this._channelContext.videoElement.value;this._mutedAfterReplay=null,t&&(t.muted=e,e||(this._channelContext.autoMuted.value=!1))}}},{key:"dispose",value:(c=N()(Ur().m(function e(){var t=this;return Ur().w(function(e){for(;;)if(0===e.n)return e.a(2,this.stop("client:channel-dispose").then(function(){t._replay.dispose(),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]",Be.discoveryUri.value),new E.value.URL(Be.discoveryUri.value))}},{key:"start",value:(l=N()(Ur().m(function e(){return Ur().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 l.apply(this,arguments)})},{key:"isTerminalState",value:function(){switch(this._channelContext.state.value){case ze.Stopped:case ze.Unauthorized:case ze.GeoRestricted:case ze.GeoBlocked:case ze.UnsupportedFeature:case ze.ConfigurationError:return!0;case ze.Initializing:case ze.Offline:case ze.Starting:case ze.Paused:case ze.Playing:case ze.Recovering:case ze.Reconnecting:case ze.StandBy:case ze.TransientConfigurationError:case ze.ConnectionError:case ze.ClientStartError:case ze.Error:return!1;default:J(this._channelContext.state.value)}}},{key:"isRetryableState",value:function(){switch(this._channelContext.state.value){case ze.Error:case ze.Reconnecting:case ze.StandBy:case ze.Offline:case ze.Recovering:case ze.TransientConfigurationError:case ze.ConnectionError:case ze.ClientStartError:return!0;case ze.Unauthorized:case ze.GeoRestricted:case ze.GeoBlocked:case ze.Stopped:case ze.Paused:case ze.Initializing:case ze.Starting:case ze.Playing:case ze.UnsupportedFeature:case ze.ConfigurationError:return!1;default:J(this._channelContext.state.value)}}},{key:"isSubscriberHealthy",value:function(){return this._streamSubscriber?this._replayContext.isReplaying.value?Gr.resolve(!0):this._streamSubscriber.isStreamHealthy():Gr.resolve(!1)}},{key:"tryRestart",value:function(e){this._replayContext.isReplaying.value?this._logger.debug("[%s] Skipping failureCount reset and Channel restart while replay is active [%s]",this._channelContext.streamId,e):this._stateContext.isStarting.value?this._logger.debug("[%s] Skipping failureCount reset and Channel restart due to Channel already starting [%s]",this._channelContext.streamId,e):this.isTerminalState()?this._logger.debug("[%s] Skipping failureCount reset and Channel restart due to terminal ChannelState [%s] [%s]",this._channelContext.streamId,ze[this._channelContext.state.value],e):(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())}},{key:"reevaluateRealTimeHealthAfterReplay",value:(u=N()(Ur().m(function e(){var t;return Ur().w(function(e){for(;;)switch(e.p=e.n){case 0:if(Be.automaticRetryOnFailure&&this._streamSubscriber&&!this._stateContext.isDisposed&&this._channelContext.state.value===ze.Playing){e.n=1;break}return e.a(2);case 1:return e.p=1,e.n=2,this.isSubscriberHealthy();case 2:if(!(e.v||this._replayContext.isReplaying.value||this._stateContext.isDisposed)){e.n=3;break}return e.a(2);case 3:this._logger.info("[%s] Real-time stream is unhealthy after a replay session; restarting the channel",this._channelContext.streamId),this.tryRestart("client:replay-ended:unhealthy"),e.n=5;break;case 4:e.p=4,t=e.v,this._logger.error("[%s] Failed to re-evaluate real-time health after a replay session",this._channelContext.streamId,t);case 5:return e.a(2)}},e,this,[[1,4]])})),function(){return u.apply(this,arguments)})},{key:"processStart",value:(a=N()(Ur().m(function e(){var t,n,r,i,o,a,s,u,l,c,d,h,f,p,v,g,y,_,b,C=this;return Ur().w(function(e){for(;;)switch(e.n){case 0:if(t=this._channelContext.state.value!==ze.Initializing,this._channelContext.state.value=t?ze.Recovering:ze.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=ze.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=rt.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=ze.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=rt.validateMediaStreamTrackTransform("audio",this._streamTransformContext.audioStreamTransformCallback),u=s.valid,l=s.validationResult,u){e.n=3;break}return this._logger.error(l),this._channelContext.state.value=ze.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(c=nt.validateEncodedStreamSink("video",this._streamTransformContext.encodedVideoStreamSink),d=c.valid,h=c.validationResult,d){e.n=4;break}return this._logger.error(h),this._channelContext.state.value=ze.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=nt.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=ze.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=ze.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=ze.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=ze.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=ze.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=ze.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=ze.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=ze.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=ze.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!==ze.Error&&e!==ze.Recovering||Ft.clearCachedClosestEndpoint(_)})),b=function(){return new Gr(function(e){if(!C.isRetryableState())return C._logger.debug("[%s] Ignoring stream failure callback due to ChannelState being [%s]",C._channelContext.streamId,ze[C._channelContext.state.value]),e();if(C._stateContext.isStarting.value=!1,C._channelContext.state.value=ze.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,!Be.applicationActivityMonitor.isForeground.value){C._logger.debug("[%s] Deferring stream failure handling to foreground recovery",C._channelContext.streamId);var t=E.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(){E.value.clearTimeout(t)})),e()}return e(C.handleStreamFailure())})},this._streamSubscriber=Qn.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.disposables.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=ze.ClientStartError,C._logger.error("Failed to start channel",e)}).finally(function(){if(C._stateContext.isStarting.value=!1,C._channelContext.state.value!==ze.Playing&&C._channelContext.state.value!==ze.Paused&&C._channelContext.state.value!==ze.Stopped&&Be.automaticRetryOnFailure){var e=E.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(){E.value.clearTimeout(e)}))}}))}},e,this)})),function(){return a.apply(this,arguments)})},{key:"restartAfterStop",value:(i=N()(Ur().m(function e(){return Ur().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=N()(Ur().m(function e(){var t;return Ur().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 ze.Initializing:case ze.StandBy:case ze.Offline:return 15e3;case ze.Error:case ze.Recovering:case ze.Unauthorized:case ze.GeoRestricted:case ze.GeoBlocked:case ze.Stopped:case ze.Starting:case ze.Playing:case ze.Paused:case ze.Reconnecting:case ze.UnsupportedFeature:case ze.ConfigurationError:case ze.TransientConfigurationError:case ze.ConnectionError:case ze.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._channelContext.failureCount.value);default:J(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(n=N()(Ur().m(function e(){var t;return Ur().w(function(e){for(;;)switch(e.n){case 0:t=this._channelContext.state.value,e.n=t===ze.Error||t===ze.Reconnecting||t===ze.StandBy||t===ze.Offline||t===ze.Recovering||t===ze.TransientConfigurationError||t===ze.ConnectionError||t===ze.ClientStartError?1:t===ze.Unauthorized?2:t===ze.GeoRestricted?3:t===ze.GeoBlocked?4:t===ze.Stopped?5:t===ze.Initializing?6:t===ze.Playing?7:t===ze.Paused?8:t===ze.Starting?9:t===ze.UnsupportedFeature?10:t===ze.ConfigurationError?11:12;break;case 1:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,ze[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:J(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.setAudioSections([]),this._channelContext.setSelectedAudioSection(null),this._channelContext.disposables.dispose(),this._peerConnectionContext.disposePeerConnection(),this._peerConnectionContext.disposeMediaStream(),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=N()(Ur().m(function e(t){var n,r,i=this;return Ur().w(function(e){for(;;)switch(e.n){case 0:if(this.applyAudioTrackSelection(),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=ze.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=ze.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=ze.Playing}).catch(function(e){var r=!!t.getTracks().filter(function(e){return"audio"===e.kind}).length,o=!Be.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=ze.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=ze.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=ze.Paused}))}))}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e,n,r,i,a,u,l,c,d,h}(),Wr=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(!Be.initialized.value)throw new Error("SDK is not loaded.");var t={maxAudioTracks:e.maxAudioTracks,audioLanguages:e.audioLanguages,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 Hr(e.videoElement,e.token,t)}},{key:"isFrameTimingInformationSupported",get:function(){return O.isChannelFrameTimingInformationSupported}}])}(),qr=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}(qr||{}),Jr=qr,Kr=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(Jr.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 Jr.Starting;case"not-found":return Jr.NotFound;case"geo-restricted":return Jr.GeoRestricted;case"geo-blocked":return Jr.GeoBlocked;case"unauthorized":return Jr.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Jr.Recovering;case"missing-channel-or-room-id":case"forbidden-tag":return Jr.ConfigurationError;case"port-in-range-not-found":return Jr.TransientConfigurationError;case"failed":return Jr.Error;default:J(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)}}])}(),Zr=n(981).A;function $r(){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,l=Object.create(u.prototype);return Qr(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Qr(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Qr(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Qr(d,"constructor",l),Qr(l,"constructor",u),u.displayName="GeneratorFunction",Qr(l,i,"GeneratorFunction"),Qr(d),Qr(d,i,"Generator"),Qr(d,r,function(){return this}),Qr(d,"toString",function(){return"[object Generator]"}),($r=function(){return{w:o,m:h}})()}function Qr(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Qr=function(e,t,n,r){function o(t,n){Qr(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))},Qr(e,t,n,r)}var Yr=function(){return o()(function e(n,r,i){var o,a,u,l,c=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!==(l=u.currentRemoteDescription)&&void 0!==l&&l.sdp){var d=new an(this._peerConnection.currentLocalDescription.sdp),h=new an(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&&c._isMonitorRunning&&(c._monitorGeneration++,E.value.clearTimeout(c._updateTimeout),c._logger.debug("Restarting stats polling after foreground transition"),c.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(),E.value.clearTimeout(this._updateTimeout),this._updateTimeout=void 0}},{key:"updateStatistic",value:(e=N()($r().m(function e(){var t,n,r,i,o,a,s,u,l,c,d,h=this;return $r().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 Zr(function(e){r=E.value.setTimeout(function(){return e(void 0)},5e3)}),e.n=4,Zr.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={},l=this._estimatedRoundTripTime,s.forEach(function(e){if("candidate-pair"===e.type&&e.currentRoundTripTime&&(l=1e3*e.currentRoundTripTime,u.audio&&(u.audio.roundTripTime=l),u.video&&(u.video.roundTripTime=l)),"candidate-pair"===e.type&&e.lastPacketSentTimestamp&&(c=e.lastPacketSentTimestamp,u.audio&&(u.audio.lastPacketSentTimestamp=c),u.video&&(u.video.lastPacketSentTimestamp=c)),"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:l},(e.lastPacketSentTimestamp||c)&&(u[r].lastPacketSentTimestamp=e.lastPacketSentTimestamp||c),"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,E.value.clearTimeout(r),e.f(8);case 9:this._isMonitorRunning&&t===this._monitorGeneration&&(this._updateTimeout=E.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}(),Xr=n(981).A;function ei(){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,l=Object.create(u.prototype);return ti(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(ti(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,ti(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,ti(d,"constructor",l),ti(l,"constructor",u),u.displayName="GeneratorFunction",ti(l,i,"GeneratorFunction"),ti(d),ti(d,i,"Generator"),ti(d,r,function(){return this}),ti(d,"toString",function(){return"[object Generator]"}),(ei=function(){return{w:o,m:h}})()}function ti(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}ti=function(e,t,n,r){function o(t,n){ti(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))},ti(e,t,n,r)}function ni(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 ri(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ni(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ni(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var ii=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(!E.value.navigatorIsOnLine)return this._publisherContext.state.value=Jr.Offline,Xr.resolve();var i=this._peerConnectionContext.mediaStream.value;if(!i)return this._logger.error("Publish failed no media stream provided"),this._publisherContext.state.value=Jr.ConfigurationError,Xr.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 Xr.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=rn()(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?(r._peerConnectionContext.disposePeerConnection(),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,l=!1,c=[];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||Be.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?c.push(n.candidate):l=!0,t||(t=E.value.setTimeout(function(){var t;r._publisherContext.stream.value!==i||o||null===(t=r._publisherContext.endPoint.value)||void 0===t||t.addIceCandidates(i,c,l).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=Jr.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=Jr.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:J(e.iceConnectionState)}}},new Xr(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!==Jr.Starting)return Xr.resolve();r._publisherContext.state.value=Jr.Publishing,r._publisherContext.publishing.value=!0;var i=new Yr(e,null!==(t=r._publisherContext.endPoint.value)&&void 0!==t&&t.roundTripTime?r._publisherContext.endPoint.value.roundTripTime/4:0,Be.applicationActivityMonitor.isForeground);return r._publisherContext.disposables.add(i),i.rtcStatistic.subscribe(function(e){r._publisherContext.rtcStatistics.value=e}),Xr.resolve()})})})}},{key:"applyRtcConfiguration",value:(e=N()(ei().m(function e(t,n){var r;return ei().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return n=sn.truncateIceServers(n),e.a(2,Be.peerConnectionFactory.value.createPeerConnection(n));case 1:return r=ri(ri({},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=Jr.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Be.maximalNumberOfPeerConnectionReconnectAttempts||!Be.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=E.value.setTimeout(function(){n.reconnectPeerConnection(e,t)},1e3);return void this._publisherContext.disposables.add(new m(function(){return E.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=E.value.setTimeout(function(){n.reconnectPeerConnection(e,t)},1e3);n._publisherContext.disposables.add(new m(function(){return E.value.clearTimeout(r)}))}else n._publisherContext.state.value=Jr.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 Jr.Starting;case"unauthorized":return Jr.Unauthorized;case"not-found":return Jr.NotFound;case"capacity":case"rate-limited":case"timeout":return Jr.Recovering;case"failed":return Jr.Error;default:J(e)}}},{key:"mapAddIceCandidatesStatusToPublisherStatus",value:function(e){switch(e){case"ok":return this._publisherContext.state.value;case"unauthorized":return Jr.Unauthorized;case"not-found":return Jr.NotFound;case"capacity":case"rate-limited":case"timeout":return Jr.Recovering;case"failed":return Jr.Error;default:J(e)}}}]);var e}(),oi=n(981).A;function ai(){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,l=Object.create(u.prototype);return si(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(si(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,si(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,si(d,"constructor",l),si(l,"constructor",u),u.displayName="GeneratorFunction",si(l,i,"GeneratorFunction"),si(d),si(d,i,"Generator"),si(d,r,function(){return this}),si(d,"toString",function(){return"[object Generator]"}),(ai=function(){return{w:o,m:h}})()}function si(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}si=function(e,t,n,r){function o(t,n){si(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))},si(e,t,n,r)}var ui=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);var a={forceGarbageCollectionOnRestart:Be.forceGarbageCollectionOnRestart};this._tokenContext=new Xe(r),this._publisherContext=new Kr(i),this._peerConnectionContext=new at(a),this._stateContext=new st,this._exponentialBackoff=new Re,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 u=re.parseToken(this._tokenContext.token.value),l=(u.uri||Be.discoveryUri.value).toString();Be.tenancy.value=u.tenancy||Be.tenancy.value,Te.uri.value=l,this._metricsService=Ne.getMetricsService(l),this._sessionTelemetry=new Ze(Be.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe(function(e){o._publisherContext.clearFailureCountTimeout&&E.value.clearTimeout(o._publisherContext.clearFailureCountTimeout),o._publisherContext.failureCount.value&&e===Jr.Publishing&&(o._publisherContext.clearFailureCountTimeout=E.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")};E.value.addWindowEventListener("beforeunload",c),this._publisherContext.publisherDisposables.add(new m(function(){E.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||Be.discoveryUri.value).toString();Be.tenancy.value=t.tenancy||Be.tenancy.value,Te.uri.value=n,this._metricsService=Ne.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=N()(ai().m(function e(t){var n=this;return ai().w(function(e){for(;;)if(0===e.n)return e.a(2,new oi(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=Jr.Stopped}},{key:"dispose",value:(i=N()(ai().m(function e(){var t=this;return ai().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]",Be.discoveryUri.value),new E.value.URL(Be.discoveryUri.value))}},{key:"start",value:(r=N()(ai().m(function e(){return ai().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=N()(ai().m(function e(){var t,n,r,i,o,a=this;return ai().w(function(e){for(;;)switch(e.n){case 0:if(this._publisherContext.state.value=Jr.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=Jr.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!==Jr.Error&&e!==Jr.Recovering||Ft.clearCachedClosestEndpoint(r)})),i=function(){return new oi(function(e){return a._stateContext.isStarting.value=!1,e(a.handleStreamFailure())})},o=new ii(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=Jr.ClientStartError,a._logger.error("Failed to start publishing",e)}).finally(function(){if(a._stateContext.isStarting.value=!1,a._publisherContext.state.value!==Jr.Publishing&&Be.automaticRetryOnFailure){var e=E.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(){E.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 Jr.Offline:return 15e3;case Jr.Initializing:case Jr.NotFound:case Jr.Error:case Jr.Recovering:case Jr.Unauthorized:case Jr.GeoRestricted:case Jr.GeoBlocked:case Jr.Stopped:case Jr.Starting:case Jr.Publishing:case Jr.Reconnecting:case Jr.UnsupportedFeature:case Jr.ConfigurationError:case Jr.TransientConfigurationError:case Jr.ConnectionError:case Jr.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._publisherContext.failureCount.value);default:J(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:(e=N()(ai().m(function e(){var t;return ai().w(function(e){for(;;)switch(e.n){case 0:t=this._publisherContext.state.value,e.n=t===Jr.Error||t===Jr.Reconnecting||t===Jr.Offline||t===Jr.Recovering||t===Jr.TransientConfigurationError||t===Jr.ConnectionError||t===Jr.ClientStartError?1:t===Jr.Unauthorized?3:t===Jr.GeoRestricted?4:t===Jr.GeoBlocked?5:t===Jr.Stopped?6:t===Jr.Publishing?7:t===Jr.Initializing?8:t===Jr.Starting?9:t===Jr.UnsupportedFeature?10:t===Jr.NotFound?11:t===Jr.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,Jr[this._publisherContext.state.value]),e.a(2);case 2:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,Jr[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:J(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(),this._peerConnectionContext.disposePeerConnection(),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}(),li=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(!Be.initialized.value)throw new Error("SDK is not loaded.");return new ui(e.mediaStream,e.token,e.name)}}])}(),ci={SDK:Be,Channels:Wr,ChannelState:ze,ReplayState:Xn,Publishers:li,PublisherState:Jr}})(),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),l=n(693),c=n.n(l),d=u()(function e(t,n,r){a()(this,e),c()(this,"onFulfilled",void 0),c()(this,"onRejected",void 0),c()(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),c()(this,"_state",void 0),c()(this,"_handled",void 0),c()(this,"_value",void 0),c()(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),l=u.value}catch(e){return void n(e)}u.done?t(l):r.resolve(l).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},646:(e,t,n)=>{var r=n(550),i=n(636);e.exports=function(e,t,n){if(r())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,t);var a=new(e.bind.apply(e,o));return n&&i(a,n.prototype),a},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},691:e=>{e.exports=function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}},e.exports.__esModule=!0,e.exports.default=e.exports},550:e=>{function t(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(n){}return(e.exports=t=function(){return!!n},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=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,l=!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){l=!0,i=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)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},837:(e,t,n)=>{var r=n(72),i=n(636),o=n(691),a=n(646);function s(t){var n="function"==typeof Map?new Map:void 0;return e.exports=s=function(e){if(null===e||!o(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,t)}function t(){return a(e,arguments,r(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),i(t,e)},e.exports.__esModule=!0,e.exports.default=e.exports,s(t)}e.exports=s,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:()=>ze,Channels:()=>Kr,PublisherState:()=>$r,Publishers:()=>hi,ReplayState:()=>nr,SDK:()=>Be,default:()=>fi});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),l=n.n(u),c=n(452),d=n.n(c),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=l()(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},w=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:"AbortController",get:function(){return this._window.AbortController}},{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:"sendBeacon",get:function(){var e=this;return this._navigator.sendBeacon?function(t,n){return e._navigator.sendBeacon(t,void 0===n?null:n)}:void 0}},{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=w,s()(w,"_instance",new b(new y(k))),s()(w,"_readOnlyInstance",new C(y._instance));var S,T,x,E=w.getInstance(),R=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""}}])}();S=R,s()(R,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),s()(R,"_browserNameAndVersion",S.parseBrowserNameAndVersion()),s()(R,"_browserName",S.parseBrowserName()),s()(R,"_browserMajorVersion",S.parseBrowserMajorVersion()),s()(R,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(T=navigator)||void 0===T?void 0:T.userAgent)),s()(R,"_isAndroid",/Android/i.test(null===(x=navigator)||void 0===x?void 0:x.userAgent)),s()(R,"_isChrome69",S._browserNameAndVersion.includes("Chrome/69.")),s()(R,"_isChrome70",S._browserNameAndVersion.includes("Chrome/70.")),s()(R,"_isChrome71",S._browserNameAndVersion.includes("Chrome/71.")),s()(R,"_isChrome72",S._browserNameAndVersion.includes("Chrome/72.")),s()(R,"_isChrome74",S._browserNameAndVersion.includes("Chrome/74.")),s()(R,"_isChrome75",S._browserNameAndVersion.includes("Chrome/75.")),s()(R,"_isChrome76",S._browserNameAndVersion.includes("Chrome/76.")),s()(R,"_isChrome77",S._browserNameAndVersion.includes("Chrome/77."));var O=function(){function e(){t()(this,e)}return o()(e,null,[{key:"clientOfferDisabled",get:function(){return R.isChrome74||R.isChrome75||R.isChrome76||R.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return R.isChrome69||R.isChrome70||R.isChrome71||R.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===R.browserName&&R.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===R.browserName&&R.browserMajorVersion<=69||"Firefox"===R.browserName&&R.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===R.browserName&&R.browserMajorVersion<=63||"Firefox"===R.browserName&&R.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===R.browserName&&R.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===R.browserName&&R.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===R.browserName||"SamsungBrowser"===R.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==R.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===R.browserName&&"function"==typeof(null===(e=E.value)||void 0===e?void 0:e.documentCreateElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===R.browserName&&R.browserMajorVersion>=71||"Firefox"===R.browserName&&R.browserMajorVersion>=69||"Safari"===R.browserName}},{key:"isMobile",get:function(){return R.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:"isProtectedChannelSupported",get:function(){return"Firefox"!==R.browserName&&"Safari"!==R.browserName}},{key:"isRequestVideoFrameCallbackSupported",get:function(){var e;return void 0!==(null===(e=E.value)||void 0===e?void 0:e.HTMLVideoElement.prototype.requestVideoFrameCallback)}},{key:"isRequestAnimationFrameSupported",get:function(){var e;return"function"==typeof(null===(e=E.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"!==R.browserName&&"Safari"!==R.browserName}}])}(),P=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>P.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.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}}])}(),A=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},[])}}])}(),I=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:!0,sendLogs:"All",sendMetrics:"All",logToConsole:"All"};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()(I,"_sendLocalCandidates",void 0),s()(I,"_sendLogs",void 0),s()(I,"_sendMetrics",void 0),s()(I,"_logToConsole",void 0),I.applyFeatures();var L=function(){return o()(function e(){t()(this,e)},null,[{key:"defaultLoggingLevel",get:function(){return P[I.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return P[I.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return P.Info}}])}(),D=function(){return o()(function e(){t()(this,e),s()(this,"_threshold",L.defaultLoggingLevel)},[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}])}(),M=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(P[e],"] ").concat(t);e<P.Warn?console.log(i):console.error(i)}}}])}(),j=n(293),N=n.n(j),V=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-12-01T03:02:20.007Z (2025.2.4-beta.729)"}catch(e){return this._defaultVersion}}}])}();s()(B,"_defaultVersion",(new Date).toISOString());var G=n(981).A;function U(){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,l=Object.create(u.prototype);return z(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(z(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,z(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,z(d,"constructor",l),z(l,"constructor",u),u.displayName="GeneratorFunction",z(l,i,"GeneratorFunction"),z(d),z(d,i,"Generator"),z(d,r,function(){return this}),z(d,"toString",function(){return"[object Generator]"}),(U=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:P[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:B.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<P.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new G(function(e){var t=E.subscribe(function(n){n&&(e(n.locationHostname),n.setTimeout(function(){return t.dispose()},0))})})}},{key:"sendLogs",value:(n=N()(U().m(function e(t){var n;return U().w(function(e){for(;;)switch(e.n){case 0:return(n=new E.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.n=1,E.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=N()(U().m(function e(){var t,n,r,i,o,a=this;return U().w(function(e){for(;;)switch(e.n){case 0:if(!(this._logs.length<=0||this._isSending)&&E.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?V.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}(),W=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)}}])}(),q=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",L.defaultTelemetryLoggingLevel)},[{key:"url",get:function(){return this._url},set:function(e){var t=new E.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(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},K=function(){return o()(function e(){t()(this,e)},null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case P.Off:return"Off";case P.Trace:return"Trace";case P.Debug:return"Debug";case P.Info:return"Info";case P.Warn:return"Warn";case P.Error:return"Error";case P.Fatal:return"Fatal";case P.All:return"All";default:J(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return P.Off;case"Trace":return P.Trace;case"Debug":return P.Debug;case"Info":return P.Info;case"Warn":return P.Warn;case"Error":return P.Error;case"Fatal":return P.Fatal;case"All":return P.All;default:J(e)}}}])}(),Z=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),$=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",Q.defaultTelemetryLevel)},[{key:"url",get:function(){return this._url},set:function(e){var t=new E.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}}])}(),Q=function(){return o()(function e(){t()(this,e)},null,[{key:"defaultTelemetryLevel",get:function(){return Z[I.sendMetrics]}}])}(),Y=function(){return o()(function e(){t()(this,e)},null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case Z.Off:return"Off";case Z.Essential:return"Essential";case Z.All:return"All";default:J(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return Z.Off;case"Essential":return Z.Essential;case"All":return Z.All;default:J(e)}}}])}(),X=function(){function e(){t()(this,e)}return o()(e,null,[{key:"getStringValue",value:function(t){return e.readConfigurationParameterValue(t)||e.readConfigurationParameterURIValue("".concat(t,"-uri-parameter-name"))||e.defaultStringValue[t]}},{key:"getBooleanValue",value:function(t){var n=e.readConfigurationParameterValue(t);if(n)return"true"===n||"1"===n||"On"===n;var r=e.readConfigurationParameterURIValue("".concat(t,"-uri-parameter-name"));return r?"true"===r||"1"===r||"On"===r:!0===e.defaultBooleanValue[t]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":Y.convertTelemetryLevelToTelemetryLevelType(Q.defaultTelemetryLevel),"phenix-logging-level":K.convertLoggingLevelToLoggingLevelType(L.defaultLoggingLevel),"phenix-console-logging-level":K.convertLoggingLevelToLoggingLevelType(L.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":K.convertLoggingLevelToLoggingLevelType(L.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}}},{key:"readConfigurationParameterValue",value:function(e){var t=E.value.documentQuerySelector("meta[name='".concat(e,"']"));if(t){var n=t.getAttribute("value");if(n)return n}}},{key:"readConfigurationParameterURIValue",value:function(t){var n=e.readConfigurationParameterValue(t);if(n){var r=new E.value.URLSearchParams(E.value.locationSearch).get(n)||void 0;if(r)return r}}}])}(),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=X.getStringValue("phenix-logging-level");P[e]&&this._threshold.setThreshold(P[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=X.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(P[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new M(e||L.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||L.defaultTelemetryLoggingLevel,this._appenders.add(new W(this._telemetryConfiguration))}}])}();s()(ee,"_loggers",{}),s()(ee,"_appenders",new A),s()(ee,"_threshold",new D),s()(ee,"_telemetryConfiguration",new q),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 E.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=!E.value.documentIsHidden;n?t&&(e._lastBackgroundDuration=Date.now()-t):(t=Date.now(),e._lastBackgroundDuration=null),e._isForeground.value=n},r=!1;E.value.addDocumentEventListener(oe,n,r),this._disposables.add(new m(function(){return E.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,l=Object.create(u.prototype);return le(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(le(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,le(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,le(d,"constructor",l),le(l,"constructor",u),u.displayName="GeneratorFunction",le(l,i,"GeneratorFunction"),le(d),le(d,i,"Generator"),le(d,r,function(){return this}),le(d,"toString",function(){return"[object Generator]"}),(ue=function(){return{w:o,m:h}})()}function le(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}le=function(e,t,n,r){function o(t,n){le(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))},le(e,t,n,r)}var ce=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 E.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=N()(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=N()(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=N()(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=N()(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,l=Object.create(u.prototype);return fe(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(fe(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,fe(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,fe(d,"constructor",l),fe(l,"constructor",u),u.displayName="GeneratorFunction",fe(l,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=N()(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=E.subscribe(function(r){r&&(e(new ce(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,l=Object.create(u.prototype);return me(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(me(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,me(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,me(d,"constructor",l),me(l,"constructor",u),u.displayName="GeneratorFunction",me(l,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=N()(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=N()(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=N()(ve().m(function e(t){var i,o,a,s,u,l,c,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,l=a,c=t,e.n=1,t.createOffer(void 0);case 1:return d=e.v,e.a(2,{audioTransceivers:u,videoTransceivers:l,peerConnection:c,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 E.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 E.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 we="/pcast/endPoints",Se=function(){return o()(function e(){throw t()(this,e),new Error("PcastUri is a static class that may not be instantiated")},null,[{key:"discoveryPath",get:function(){return we}},{key:"normalizeDiscoveryUri",value:function(e){var t=new E.value.URL(e.toString());return""!==t.pathname&&"/"!==t.pathname||(t.pathname=we),t.search="",t.hash="",t}},{key:"buildRouteUrl",value:function(e,t){var n=new E.value.URL(e.toString()),r=n.pathname.split("/");return r.length=r.length-1,n.pathname=r.concat.apply(r,l()(t)).join("/"),n}}])}(),Te=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 E.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=Se.discoveryPath),t.toString()}}])}();s()(Te,"_discoveryUri",new b("https://pcast.phenixrts.com/pcast/endPoints"));var xe=n(738),Ee=n.n(xe),Re=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)}}])}(),Oe=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}(Oe||{}),Pe=Oe,Fe=function(){return o()(function e(n){t()(this,e),s()(this,"_metrics",void 0),this._metrics=n},[{key:"getName",value:function(){return Pe[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case Pe.TimeToFirstFrame:case Pe.ChannelCreationTimeToFirstFrame:return Z.Essential;case Pe.Stalled:case Pe.Buffering:case Pe.SetupCompleted:case Pe.SetupFailed:case Pe.RoundTripTime:case Pe.DownlinkThroughputCapacity:case Pe.NetworkType:case Pe.ResolutionChanged:case Pe.ApplicationForeground:case Pe.ApplicationBackground:return Z.All;default:J(this._metrics)}}}])}(),Ae=n(981).A;function Ie(){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,l=Object.create(u.prototype);return Le(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Le(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Le(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Le(d,"constructor",l),Le(l,"constructor",u),u.displayName="GeneratorFunction",Le(l,i,"GeneratorFunction"),Le(d),Le(d,i,"Generator"),Le(d,r,function(){return this}),Le(d,"toString",function(){return"[object Generator]"}),(Ie=function(){return{w:o,m:h}})()}function Le(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Le=function(e,t,n,r){function o(t,n){Le(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))},Le(e,t,n,r)}var De,Me,je=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 Re,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 Fe(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 Ae(function(e){var t=E.subscribe(function(n){n&&(e(n.locationHostname),n.setTimeout(function(){return t.dispose()},0))})})}},{key:"sendMetrics",value:(n=N()(Ie().m(function e(t){var n;return Ie().w(function(e){for(;;)switch(e.n){case 0:return(n=new E.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.n=1,E.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=N()(Ie().m(function e(){var t,n=this;return Ie().w(function(e){for(;;)switch(e.n){case 0:if(!(this._metrics.length<=0||this._isSending)&&E.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 E.value.setTimeout(function(){n._metrics=[].concat(l()(t),l()(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}(),Ne=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(Ee()(t),"]"));var n=e._metricsServices[t];if(n)return n;var r=new $;return r.sessionId=Be.clientSessionId,r.tenancy=Be.tenancy.value,r.url=be.getTelemetryUrl(t),r.environment=Ce.getEnvironmentFromUrl(t),r.threshold=Y.convertTelemetryLevelTypeToTelemetryLevel(Be.telemetryLevel),e._metricsServices[t]=new je(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach(function(e){e.metricsConfiguration.threshold=t})}}])}();s()(Ne,"_metricsServices",{});var Ve=(null===(De=w.getInstance().value)||void 0===De?void 0:De.pageLoadTime)||Date.now(),Be=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 Ve}},{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 K.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return Y.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return R}},{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 W});r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new W(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 W});r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new W(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))})}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=Ne.getMetricsService(Te.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=X.getStringValue("phenix-metrics-level");t&&Ne.setTelemetryLevel(Z[t]),e._telemetryLevel.subscribe(function(e){Ne.setTelemetryLevel(e)})}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=X.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=X.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=X.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=X.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=X.getStringValue("phenix-channel-token");if(t){var n=re.parseToken(t);return e._tenancy.value=n.tenancy,Te.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=X.getStringValue("phenix-uri");if(r)return Te.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=X.getStringValue("phenix-base-uri");if(i){var o=new(w.getInstance().value.URL)(i);return o.pathname="/pcast/endPoints",Te.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&&w.setInstance(n.globalScope),t.discoveryUri&&(Te.uri.value=t.discoveryUri),t.peerConnectionFactory&&(_e.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&Z[t.telemetryLevel]&&(e._telemetryLevel.value=Y.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&P[t.loggingLevel]&&this._logger.threshold.setThreshold(K.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&P[t.consoleLoggingLevel]){var r=this._logger.appenders.value.find(function(e){return e instanceof M});r&&this._logger.appenders.remove(r),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new M(K.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)}}])}();Me=Be,s()(Be,"_automaticallyRetryOnFailure",X.getBooleanValue("phenix-automatically-retry-on-failure")),s()(Be,"_automaticallyReconnectPeerConnection",X.getBooleanValue("phenix-automatically-reconnect-peer-connection")),s()(Be,"_automaticallyPlayMediaStream",!0),s()(Be,"_automaticallyMuteVideoOnPlayFailure",!0),s()(Be,"_forceGarbageCollectionOnRestart",X.getBooleanValue("phenix-force-garbage-collection-on-restart")),s()(Be,"_skipGarbageCollectionOnMobileDevices",X.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices")),s()(Be,"_webPlayerLoader",void 0),s()(Be,"_shakaPlayerLoader",void 0),s()(Be,"_hlsJsLoader",void 0),s()(Be,"_applicationActivityMonitor",void 0),s()(Be,"_environment",new b("")),s()(Be,"_telemetryUrl",new b("https://telemetry.phenixrts.com/telemetry")),s()(Be,"_maximalNumberOfPeerConnectionReconnectAttempts",8),s()(Be,"_telemetryLevel",new b(Q.defaultTelemetryLevel)),s()(Be,"_metricsService",void 0),s()(Be,"_metricsConfiguration",void 0),s()(Be,"_sendLocalCandidates",new b(I.sendLocalCandidates)),s()(Be,"_tenancy",new b("")),s()(Be,"_clientSessionId",te.random(32)),s()(Be,"_loadedTimestamp",new Date),s()(Be,"_logger",ee.getLogger("SDK")),s()(Be,"_initialized",new b(!1)),s()(Be,"_readOnlyInitialized",new C(Me._initialized)),s()(Be,"_readOnlyDiscoveryUri",new C(Te.uri)),s()(Be,"_readOnlyPeerConnectionFactory",new C(_e.peerConnectionFactory)),w.subscribe(Be.onLoad.bind(Be));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)}}])}(),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||{}),ze=Ue,He=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)}}])}(),We=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",We),s()(this,"_listenForStall",We),s()(this,"_listenForContinuation",We),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 He(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:Pe.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 He(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:Pe.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 He(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:Pe.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:Pe.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 He(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:Pe.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}}])}(),Je=function(){return o()(function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("StreamSetupListener")),s()(this,"metricsService",Be.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(Pe.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(Pe.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new Fe(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 He(n-this._pageLoadTime).toIsoString(),t,i,new He(r).toIsoString())}}}])}(),Ke=function(){return o()(function e(){t()(this,e),s()(this,"_disposables",new ie),s()(this,"_isSupported",void 0!==E.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=E.value.navigatorConnection)||void 0===n?void 0:n.downlink)&&void 0!==t?t:null===(r=E.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=E.value.navigatorConnection)||void 0===n?void 0:n.effectiveType)&&void 0!==t?t:null===(r=E.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=E.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=E.value.navigatorConnection)||void 0===e||e.addEventListener("change",n),this._disposables.add(new m(function(){var e;return null===(e=E.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()}}])}(),Ze=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",Be.applicationActivityMonitor),s()(this,"_networkMonitor",new Ke),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 Je(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?Pe.ApplicationForeground:Pe.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 He(r).toIsoString()))}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:Pe.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 He(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:Pe.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 He(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:Pe.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 He(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),$e=function(){return o()(function e(){t()(this,e)},null,[{key:"applyToMediaStream",value:function(e,t,n,r){var i=!1;return e.forEach(function(e){var o,a=e.receiver.track;if("audio"===a.kind){var s=e.mid===t,u=null!==(o=r.get(a))&&void 0!==o?o:a;a.enabled=s;var l=n.getAudioTracks().some(function(e){return e.id===u.id});s&&!l?(n.addTrack(u),i=!0):!s&&l&&(n.removeTrack(u),i=!0)}}),i}}])}(),Qe=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Ye=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),Xe=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)}),et=function(){function e(){t()(this,e)}return o()(e,null,[{key:"orderByRequestedLanguages",value:function(t,n){var r=l()(t).sort(function(e,t){return e.sourceIndex-t.sourceIndex}),i=[];return n.forEach(function(t){var n=e.findMatch(r,t);n&&(i.push(n),r.splice(r.indexOf(n),1))}),[].concat(l()(i),l()(r))}},{key:"findSectionToPlay",value:function(e,t){var n,r,i,o=null==t||null===(n=t.language)||void 0===n?void 0:n.toLowerCase(),a=t?e.find(function(e){var n;return String(e.sourceIndex)===t.id&&(null===(n=e.language)||void 0===n?void 0:n.toLowerCase())===o}):void 0,s=o?e.find(function(e){var t;return(null===(t=e.language)||void 0===t?void 0:t.toLowerCase())===o}):void 0;return null!==(r=null!==(i=null!=a?a:s)&&void 0!==i?i:e[0])&&void 0!==r?r:null}},{key:"findMatch",value:function(t,n){for(var r,i=function(){var e=o.toLowerCase(),n=t.find(function(t){var n;return(null===(n=t.language)||void 0===n?void 0:n.toLowerCase())===e});if(n)return{v:n}},o=n;o;o=e.truncate(o))if(r=i())return r.v;var a="".concat(n.toLowerCase(),"-");return t.find(function(e){var t;return null===(t=e.language)||void 0===t?void 0:t.toLowerCase().startsWith(a)})}},{key:"truncate",value:function(e){var t=e.lastIndexOf("-");if(t<0)return null;var n=e.slice(0,t),r=n.lastIndexOf("-");return r>=0&&r+2===n.length?n.slice(0,r):n}}])}(),tt=function(){return o()(function e(n){var r,i,o,a,u;t()(this,e),s()(this,"maxAudioTracks",void 0),s()(this,"audioLanguages",void 0),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,"audioSections",void 0),s()(this,"audioTracks",void 0),s()(this,"selectedAudioMid",void 0),s()(this,"selectedAudioTrack",void 0),s()(this,"requestedAudioTrack",void 0),s()(this,"videoTelemetry",void 0),s()(this,"rtcAudioStatistic",void 0),s()(this,"rtcVideoStatistic",void 0),s()(this,"clearFailureCountTimeout",void 0);var c=null!==(r=null==n?void 0:n.maxAudioTracks)&&void 0!==r?r:1;if(!Number.isSafeInteger(c)||c<1)throw new Error("Invalid maximum audio track count [".concat(c,"]"));var d=null!==(i=null==n?void 0:n.audioLanguages)&&void 0!==i?i:[];e.assertValidAudioLanguages(d,c),this.maxAudioTracks=c,this.audioLanguages=l()(d),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(ze.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!==(o=null==n?void 0:n.targetLag)&&void 0!==o?o: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!==(a=null==n?void 0:n.onRealTimeSubscribeRequestCallback)&&void 0!==a?a:null,this.onRealTimeSubscribeResponseCallback=null!==(u=null==n?void 0:n.onRealTimeSubscribeResponseCallback)&&void 0!==u?u:null,this.stream=new b(null),this.rtcStatistics=new b(null),this.audioSections=new b([]),this.audioTracks=new b([]),this.selectedAudioMid=new b(null),this.selectedAudioTrack=new b(null),this.requestedAudioTrack=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:"setAudioSections",value:function(e){var t=et.orderByRequestedLanguages(e,this.audioLanguages);this.audioSections.value=t,this.audioTracks.value=t.map(function(e){return{id:String(e.sourceIndex),language:e.language}})}},{key:"findAudioMidsToAccept",value:function(e,t){return e.slice(0,this.findMaxAudioTracks(t)).map(function(e){return e.mid})}},{key:"findMaxAudioTracks",value:function(e){return e===ge.Enabled?1:this.maxAudioTracks}},{key:"findAudioSection",value:function(e){return this.audioSections.value.find(function(t){return String(t.sourceIndex)===e})}},{key:"findAudioSectionToPlay",value:function(){return et.findSectionToPlay(this.audioSections.value,this.requestedAudioTrack)}},{key:"setSelectedAudioSection",value:function(e){var t,n,r,i=e?this.audioSections.value.findIndex(function(t){return t.sourceIndex===e.sourceIndex}):-1;this.selectedAudioMid.value=null!==(t=null===(n=this.audioSections.value[i])||void 0===n?void 0:n.mid)&&void 0!==t?t:null,this.selectedAudioTrack.value=null!==(r=this.audioTracks.value[i])&&void 0!==r?r:null}},{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=Be.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return ze.Starting;case"no-stream":case"not-found":return ze.StandBy;case"geo-restricted":return ze.GeoRestricted;case"geo-blocked":return ze.GeoBlocked;case"unauthorized":return ze.Unauthorized;case"capacity":case"rate-limited":case"timeout":return ze.Recovering;case"forbidden-tag":return ze.ConfigurationError;case"port-in-range-not-found":return ze.TransientConfigurationError;case"failed":return ze.Error;default:J(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:J(e)}}}],[{key:"assertValidAudioLanguages",value:function(e,t){var n=/^[A-Za-z0-9]+(-[A-Za-z0-9]+)*$/;if(e.length>t||e.some(function(e){return!n.test(e)}))throw new Error("Invalid requested audio languages [".concat(JSON.stringify(e),"]. Maximum [").concat(t,"]"))}}])}(),nt=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(Ee()(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"}}}])}(),rt=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(Ee()(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"}}}])}(),it=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:[]}}),ot=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.isMobile&&Be.skipGarbageCollectionOnMobileDevices||O.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){O.isQueueMicrotaskSupported?E.value.queueMicrotask(this.overloadMemoryToInvokeGarbageCollection.bind(this)):E.value.setTimeout(this.overloadMemoryToInvokeGarbageCollection.bind(this),0)}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=E.value.documentCreateElement("img");e.src=E.value.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){E.value.URL.revokeObjectURL(this.src),e=null}}}])}(),at=function(){return o()(function e(n){t()(this,e),s()(this,"_forceGarbageCollectionOnRestart",void 0),s()(this,"mediaStream",void 0),s()(this,"peerConnection",void 0),s()(this,"peerConnectionReconnectAttempts",void 0),s()(this,"renderedTracks",void 0),this._forceGarbageCollectionOnRestart=n.forceGarbageCollectionOnRestart,this.mediaStream=new b(null),this.peerConnection=new b(null),this.peerConnectionReconnectAttempts=0,this.renderedTracks=new Map},[{key:"disposePeerConnection",value:function(){var e=this.peerConnection.value;e&&(this.peerConnection.value=null,e.close(),e.dispose(),this._forceGarbageCollectionOnRestart&&ot.forceGarbageCollection())}},{key:"disposeMediaStream",value:function(){var e;null===(e=this.mediaStream.value)||void 0===e||e.getTracks().forEach(function(e){return e.stop()}),this.mediaStream.value=null,this.renderedTracks=new Map}}])}(),st=o()(function e(){t()(this,e),s()(this,"isStarting",void 0),s()(this,"isDisposed",void 0),this.isStarting=new b(!1),this.isDisposed=!1}),ut=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)}),lt=n(847),ct=n.n(lt),dt=n(837),ht=n.n(dt),ft=function(){return o()(function e(){t()(this,e)},null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Ye.Normal:return"Normal";case Ye.Force:return"Force";case Ye.Reset:return"Reset";default:J(e)}}}])}(),pt=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:J(e)}}}])}(),vt=n(981).A,mt=["status","streamId","sharedSecret","lag","rtcConfiguration","setRemoteDescriptionResponse","createAnswerDescriptionResponse","createOfferDescriptionResponse","streamResponseContext"];function gt(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 yt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?gt(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _t(){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,l=Object.create(u.prototype);return bt(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(bt(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,bt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,bt(d,"constructor",l),bt(l,"constructor",u),u.displayName="GeneratorFunction",bt(l,i,"GeneratorFunction"),bt(d),bt(d,i,"Generator"),bt(d,r,function(){return this}),bt(d,"toString",function(){return"[object Generator]"}),(_t=function(){return{w:o,m:h}})()}function bt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}bt=function(e,t,n,r){function o(t,n){bt(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))},bt(e,t,n,r)}function Ct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Ct=function(){return!!e})()}var kt=function(e){function n(){return t()(this,n),e=this,r=n,i=arguments,r=f()(r),d()(e,Ct()?Reflect.construct(r,i||[],f()(e).constructor):r.apply(e,i));var e,r,i}return v()(n,e),o()(n)}(ht()(Error)),wt=function(){return o()(function e(n,r){if(t()(this,e),s()(this,"_logger",ee.getLogger("EndPoint")),s()(this,"_uri",void 0),s()(this,"_timeoutDuration",void 0),s()(this,"_roundTripTime",0),this._uri=n,this._timeoutDuration=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:(g=N()(_t().m(function e(){var t,n,r,i;return _t().w(function(e){for(;;)switch(e.n){case 0:return t=this.buildPingUrl(),n=Date.now(),r={method:"GET",cache:"no-cache"},e.n=1,this.fetchWithTimeout(t,r,this._timeoutDuration).catch(function(e){if(e instanceof kt)throw new Error("Ping timed out [".concat(t,"]"));throw e});case 1:if((i=e.v).ok){e.n=2;break}throw new Error("Ping failed [".concat(t,"] [").concat(i.status,"]"));case 2:return this._roundTripTime=Date.now()-n,e.a(2,this._roundTripTime)}},e,this)})),function(){return g.apply(this,arguments)})},{key:"subscribe",value:(m=N()(_t().m(function e(t,n,r){var i,o,a,s,u,c,d,h,f,p,v,m,g,y,_,b,C,k,w,S,T,x=arguments;return _t().w(function(e){for(;;)switch(e.n){case 0:if(a=x.length>3&&void 0!==x[3]?x[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 E.value.FormData,d=B.sdkVersion,0===r&&n?h={apiVersion:7,clientVersion:d,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:7,sessionDescription:{type:n.type,sdp:n.sdp}},createAnswerDescription:{apiVersion:7}}:(p=[].concat(l()(a.maxAudioTracks?["max-audio-tracks=".concat(a.maxAudioTracks)]:[]),l()(null!==(f=a.audioLanguages)&&void 0!==f&&f.length?["audio-languages=".concat(a.audioLanguages.join(","))]:[])),h={apiVersion:7,clientVersion:d,bearerToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:7,options:p.length?p:void 0}}),e.n=2,null===(i=a.onSubscribeRequestCallback)||void 0===i?void 0:i.call(a,h);case 2:return c.append("jsonBody",JSON.stringify(h)),v=Date.now(),m={method:"POST",body:c},e.n=3,this.executeFetchRequest(u,m,"subscribe");case 3:return g=e.v,e.n=4,this.parseJsonBody(g);case 4:if(y=e.v,this.handleStreamResponseContext(null==y?void 0:y.streamResponseContext),"ok"===(_=this.mapHttpStatusToSubscribeStatus(g))){e.n=6;break}return C={status:_},e.n=5,null===(b=a.onSubscribeResponseCallback)||void 0===b?void 0:b.call(a,C);case 5:return e.a(2,C);case 6:if(y){e.n=8;break}return w={status:"failed"},e.n=7,null===(k=a.onSubscribeResponseCallback)||void 0===k?void 0:k.call(a,w);case 7:return e.a(2,w);case 8:return S=Date.now(),T=this.normalizeSubscribeResponse(s,y),this._logger.debug("Got subscribe response [%j] in [%s] ms",T,S-v),e.n=9,null===(o=a.onSubscribeResponseCallback)||void 0===o?void 0:o.call(a,T);case 9:return e.a(2,T)}},e,this)})),function(e,t,n){return m.apply(this,arguments)})},{key:"publish",value:(v=N()(_t().m(function e(t,n,r,i){var o,a,s,u,l,c,d,h,f,p,v,m,g;return _t().w(function(e){for(;;)switch(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 E.value.FormData,u=B.sdkVersion,0===i&&r?(l={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(l))):(c={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(c))),d=Date.now(),h={method:"POST",body:s},e.n=2,this.executeFetchRequest(a,h,"publish");case 2:return f=e.v,e.n=3,this.parseJsonBody(f);case 3:if(p=e.v,this.handleStreamResponseContext(null==p?void 0:p.streamResponseContext),"ok"===(v=this.mapHttpStatusToPublishStatus(f))){e.n=4;break}return e.a(2,{status:v});case 4:if(p){e.n=5;break}return e.a(2,{status:"failed"});case 5:return m=Date.now(),g=this.normalizePublishResponse(o,p),this._logger.debug("Got publish response [%j] in [%s] ms",g,m-d),e.a(2,g)}},e,this)})),function(e,t,n,r){return v.apply(this,arguments)})},{key:"setRemoteDescription",value:(p=N()(_t().m(function e(t,n){var r,i,o,a,s,u,l,c,d;return _t().w(function(e){for(;;)switch(e.n){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new E.value.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,sessionDescription:{type:n.type,sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),s={method:"POST",body:i},e.n=1,this.executeFetchRequest(r,s,"set remote description");case 1:if(u=e.v,"ok"===(l=this.mapHttpStatusToSetRemoteDescriptionStatus(u))){e.n=2;break}return e.a(2,{status:l});case 2:return c=Date.now(),e.n=3,this.convertHttpResponseToSetRemoteDescription(u);case 3:return d=e.v,this._logger.debug("Got set remote description response [%j] in [%s] ms",d,c-a),e.a(2,d)}},e,this)})),function(e,t){return p.apply(this,arguments)})},{key:"limitBitrate",value:(f=N()(_t().m(function e(t,n,r,i,o){var a,s,u,l,c,d,h,f;return _t().w(function(e){for(;;)switch(e.n){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new E.value.FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:pt.convertBitrateStateToBitrateStateType(i),bitrateMode:ft.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),l=Date.now(),c={method:"POST",body:s},e.n=1,this.executeFetchRequest(a,c,"set limit bitrate");case 1:return d=e.v,h=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(d),f=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",h,f-l),e.a(2,{status:h})}},e,this)})),function(e,t,n,r,i){return f.apply(this,arguments)})},{key:"addIceCandidates",value:(h=N()(_t().m(function e(t,n,r){var i,o,a,s,u,l,c,d,h,f,p=arguments;return _t().w(function(e){for(;;)switch(e.n){case 0:return i=p.length>3&&void 0!==p[3]?p[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),a=new E.value.FormData,s={apiVersion:7,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},a.append("jsonBody",JSON.stringify(s)),u=Date.now(),l={method:"POST",body:a},e.n=1,this.executeFetchRequest(o,l,"add ice candidates");case 1:if(c=e.v,"ok"===(d=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.n=2;break}return e.a(2,{status:d});case 2:return h=Date.now(),e.n=3,this.convertHttpResponseToAddIceCandidates(c);case 3: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)})),function(e,t,n){return h.apply(this,arguments)})},{key:"destroyStream",value:(d=N()(_t().m(function e(t,n){var r,i,o,a,s,u,l,c,d;return _t().w(function(e){for(;;)switch(e.n){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new E.value.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},a={method:"POST",body:i,cache:"no-cache"},i.append("jsonBody",JSON.stringify(o)),s=Date.now(),e.n=1,this.executeFetchRequest(r,a,"destroy stream");case 1:if(u=e.v,"ok"===(l=this.mapHttpStatusToSetDestroyStreamStatus(u))){e.n=2;break}return e.a(2,{status:l});case 2:return c=Date.now(),e.n=3,this.convertHttpResponseToDestroyStream(u);case 3:return d=e.v,this._logger.info("Got destroy stream response [%j] in [%s] ms",d,c-s),e.a(2,d)}},e,this)})),function(e,t){return d.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(c=N()(_t().m(function e(t,n){var r,i,o,a,s=this;return _t().w(function(e){for(;;)switch(e.n){case 0:if(r=E.value.sendBeacon){e.n=1;break}return this.destroyStream(t,n).catch(function(e){s._logger.error("Failed to destroy stream on unmount",e)}),e.a(2);case 1:i=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),o=new E.value.FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},o.append("jsonBody",JSON.stringify(a)),r(i,o);case 2:return e.a(2)}},e,this)})),function(e,t){return c.apply(this,arguments)})},{key:"fetchWithTimeout",value:(u=N()(_t().m(function e(t,n,r){var i,o;return _t().w(function(e){for(;;)switch(e.p=e.n){case 0:return i=new E.value.AbortController,o=null,e.p=1,e.n=2,vt.race([E.value.fetch(t,yt(yt({},n),{},{signal:i.signal})),new vt(function(e,n){o=E.value.setTimeout(function(){i.abort(),n(new kt("Timed out [".concat(t,"]")))},r)})]);case 2:return e.a(2,e.v);case 3:return e.p=3,o&&E.value.clearTimeout(o),e.f(3);case 4:return e.a(2)}},e,null,[[1,,3,4]])})),function(e,t,n){return u.apply(this,arguments)})},{key:"executeFetchRequest",value:(a=N()(_t().m(function e(t,n,r){var i;return _t().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,this.fetchWithTimeout(t,n,this._timeoutDuration);case 1:return e.a(2,e.v);case 2:return e.p=2,i=e.v,this._logger.error("Failed to ".concat(r," [").concat(n.method||"GET","] [").concat(t,"]"),i),e.a(2,{status:i instanceof kt?408:500})}},e,this,[[0,2]])})),function(e,t,n){return a.apply(this,arguments)})},{key:"buildUrl",value:function(e){return Se.buildRouteUrl(this._uri,e)}},{key:"buildPingUrl",value:function(){var e=new E.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:"parseJsonBody",value:(i=N()(_t().m(function e(t){return _t().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,t.json();case 1:return e.a(2,e.v);case 2:return e.p=2,e.v,e.a(2,void 0)}},e,null,[[0,2]])})),function(e){return i.apply(this,arguments)})},{key:"handleStreamResponseContext",value:function(e){e&&this._logger.info("stream response context [%j]",e)}},{key:"mapHttpStatusToPublishStatus",value:function(e){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){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){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){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){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){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:"normalizeSubscribeResponse",value:function(e,t){var n=t.status,r=t.streamId,i=t.sharedSecret,o=t.lag,a=t.rtcConfiguration,s=t.setRemoteDescriptionResponse,u=t.createAnswerDescriptionResponse,l=t.createOfferDescriptionResponse,c=(t.streamResponseContext,yt(yt({},ct()(t,mt)),{},{status:n,stream:{tenancy:e,streamId:r,sharedSecret:i},lag:o}));return a&&(c.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(a)),null!=s&&s.sessionDescription&&(c.setRemoteDescriptionResponse={sessionDescription:s.sessionDescription}),null!=u&&u.sessionDescription&&(c.createAnswerDescriptionResponse={sessionDescription:u.sessionDescription}),null!=l&&l.sessionDescription&&(c.createOfferDescriptionResponse={sessionDescription:l.sessionDescription}),c}},{key:"normalizePublishResponse",value:function(e,t){var n={status:t.status,stream:{tenancy:e,streamId:t.streamId,sharedSecret:t.sharedSecret}};return t.rtcConfiguration&&(n.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(t.rtcConfiguration)),t.setRemoteDescriptionResponse&&t.setRemoteDescriptionResponse.sessionDescription&&(n.setRemoteDescriptionResponse={sessionDescription:t.setRemoteDescriptionResponse.sessionDescription}),t.createAnswerDescriptionResponse&&t.createAnswerDescriptionResponse.sessionDescription&&(n.createAnswerDescriptionResponse={sessionDescription:t.createAnswerDescriptionResponse.sessionDescription}),t.createOfferDescriptionResponse&&t.createOfferDescriptionResponse.sessionDescription&&(n.createOfferDescriptionResponse={sessionDescription:t.createOfferDescriptionResponse.sessionDescription}),n}},{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:"convertHttpResponseToSetRemoteDescription",value:(r=N()(_t().m(function e(t){var n,r,i;return _t().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.parseJsonBody(t);case 1:return n=e.v,r=n?n.status:this.mapHttpStatusToSetRemoteDescriptionStatus(t),i={status:r},n&&n.sessionDescription&&(i.sessionDescription=n.sessionDescription),e.a(2,i)}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidates",value:(n=N()(_t().m(function e(t){var n,r,i;return _t().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.parseJsonBody(t);case 1:return n=e.v,r=n?n.status:this.mapHttpStatusToAddIceCandidatesStatus(t),i={status:r,options:[]},n&&n.options&&(i.options=n.options),e.a(2,i)}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStream",value:(e=N()(_t().m(function e(t){var n,r,i;return _t().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.parseJsonBody(t);case 1:return n=e.v,r=n?n.status:this.mapHttpStatusToSetDestroyStreamStatus(t),i={status:r},e.a(2,i)}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e,n,r,i,a,u,c,d,h,f,p,v,m,g}(),St=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,l=Object.create(u.prototype);return xt(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(xt(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,xt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,xt(d,"constructor",l),xt(l,"constructor",u),u.displayName="GeneratorFunction",xt(l,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 Et=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=Ne.getMetricsService(n.toString()),this._uri=n},[{key:"discoverNearbyEndPoints",value:(n=N()(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,St.race([E.value.fetch(r,{method:"GET",cache:"no-cache"}),new St(function(e,t){return E.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 wt(e,n)}))}},e)})),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=N()(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=Te.buildDiscoveryUrl(this._uri),e.n=1,this.discoverNearbyEndPoints(new E.value.URL(n),t);case 1:return r=e.v,i=0,o=function(){return new St(function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))})},e.n=2,St.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:Pe.RoundTripTime,runtime:(n-Be.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}(),Rt=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,l=Object.create(u.prototype);return Pt(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Pt(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Pt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Pt(d,"constructor",l),Pt(l,"constructor",u),u.displayName="GeneratorFunction",Pt(l,i,"GeneratorFunction"),Pt(d),Pt(d,i,"Generator"),Pt(d,r,function(){return this}),Pt(d,"toString",function(){return"[object Generator]"}),(Ot=function(){return{w:o,m:h}})()}function Pt(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Pt=function(e,t,n,r){function o(t,n){Pt(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))},Pt(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=N()(Ot().m(function t(){return Ot().w(function(t){for(;;)if(0===t.n)return t.a(2,new Rt(function(t){var n=E.subscribe(function(r){if(r){var i=new r.URL(Be.discoveryUri.value);return e.discoverClosestEndPointWithCaching(i).then(t).then(function(){return n.dispose()})}})}))},t)})),function(){return r.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(n=N()(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 Et(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then(function(){E.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 At=function(e){return e[e.NetworkEmpty=0]="NetworkEmpty",e[e.NetworkIdle=1]="NetworkIdle",e[e.NetworkLoading=2]="NetworkLoading",e[e.NetworkNoSource=3]="NetworkNoSource",e}({});function It(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 Lt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?It(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):It(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Dt=function(){return o()(function e(n,r,i,o,a,u){t()(this,e),s()(this,"_logger",ee.getLogger("WebPlayer")),s()(this,"_videoElement",void 0),s()(this,"_kind",void 0),s()(this,"_streamId",void 0),s()(this,"_manifestURI",void 0),s()(this,"_options",void 0),s()(this,"_handleStreamFailure",void 0),s()(this,"_player",void 0),s()(this,"_lastReloadTime",void 0),this._videoElement=n,this._kind=r,this._streamId=i,this._manifestURI=encodeURI(o).replace(/[#]/g,"%23"),this._options=a,this._player=null,this._lastReloadTime=0,this._handleStreamFailure=u},[{key:"start",value:function(){var e=this;if(Zt.phenixWebPlayer){var t,n,r=Lt(Lt({},this._options),{},{bandwidthToStartAt:3e6});return this._player=new Zt.phenixWebPlayer.WebPlayer(this._logger,this._videoElement,r),null===(t=this._player)||void 0===t||t.start(this._manifestURI),void(null===(n=this._player)||void 0===n||n.addEventListener("error",function(t){e.canReload()&&t&&(3===t.code||t.severity===Zt.phenixWebPlayer.errors.severity.RECOVERABLE)&&(e._logger.warn("Reloading unhealthy stream after error event [%j]",t),e.reloadIfAble()),e._logger.error("Cannot reload with error [%j]",t),e._handleStreamFailure()}))}}},{key:"isSupported",value:function(){return Zt.phenixWebPlayer&&Zt.phenixWebPlayer.isSupported}},{key:"getStats",value:function(){var e,t;if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:At.NetworkNoSource,dataBuffered:0};var n=this._player.getStats(),r=n.currentTime||this._videoElement.currentTime,i=(Date.now()-this._options.originStartTime)/1e3;return null!==(e=this._videoElement.buffered)&&void 0!==e&&e.length&&(n.dataBuffered=this._videoElement.buffered.end(0)),n.isNative&&"Hls"===n.deliveryType&&(n.currentTime=r-n.lag),n.currentTime||(n.currentTime=r),n.isNative||(n.lag=Math.max(0,i-r)),null!==(t=this._videoElement.buffered)&&void 0!==t&&t.length?n.networkState=At.NetworkLoading:n.currentTime>0?n.networkState=At.NetworkIdle:n.video?n.networkState=At.NetworkEmpty:n.networkState=At.NetworkNoSource,n}},{key:"dispose",value:function(){this._player&&this._player.dispose(),this._player=null}},{key:"canReload",value:function(){var e=!this._lastReloadTime||Date.now()-this._lastReloadTime>15e3;return!!this._videoElement&&!!this._player&&0!==this._videoElement.buffered.length&&e}},{key:"reloadIfAble",value:function(){this.canReload()&&(this._logger.warn("[%s] Reloading unhealthy stream that was active for at least [%s] seconds",this._streamId,15),this._lastReloadTime=Date.now(),this.reload())}},{key:"reload",value:function(){this._player&&this._player.dispose(),this._player=null,this.start()}}])}(),Mt=function(){return o()(function e(n){var r=n.names,i=n.carriesAudio;t()(this,e),s()(this,"names",void 0),s()(this,"carriesAudio",void 0),this.names=r.filter(function(e,t){return e&&r.indexOf(e)===t}),this.carriesAudio=i},[{key:"equals",value:function(e){var t=this;return!!e&&e.carriesAudio===this.carriesAudio&&e.names.length===this.names.length&&e.names.every(function(e,n){return e===t.names[n]})}}])}();function jt(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 Nt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jt(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Vt=function(){function e(n,r,i,o,a,u){t()(this,e),s()(this,"_logger",ee.getLogger("ShakaPlayer")),s()(this,"_videoElement",void 0),s()(this,"_kind",void 0),s()(this,"_streamId",void 0),s()(this,"_manifestURI",void 0),s()(this,"_options",void 0),s()(this,"_handleStreamFailure",void 0),s()(this,"_disposables",void 0),s()(this,"_monitoredStatistics",void 0),s()(this,"_audioRenditions",new b(null)),s()(this,"_readOnlyAudioRenditions",new C(this._audioRenditions)),s()(this,"_audioRenditionFailure",new b(null)),s()(this,"_readOnlyAudioRenditionFailure",new C(this._audioRenditionFailure)),s()(this,"_audioRenditionSelectedByViewer",new C(new b(null))),s()(this,"_player",void 0),s()(this,"_isLoaded",!1),s()(this,"_selectedAudioRenditionName",null),this._videoElement=n,this._kind=r,this._streamId=i,this._manifestURI=encodeURI(o).replace(/[#]/g,"%23"),this._options=a,this._handleStreamFailure=u,this._disposables=new ie,this._monitoredStatistics={estimatedBandwidth:0,playTime:0},this._player=null}return o()(e,[{key:"audioRenditions",get:function(){return this._readOnlyAudioRenditions}},{key:"audioRenditionFailure",get:function(){return this._readOnlyAudioRenditionFailure}},{key:"audioRenditionSelectedByViewer",get:function(){return this._audioRenditionSelectedByViewer}},{key:"start",value:function(){if(Zt.shaka)return this._player=new Zt.shaka.Player(this._videoElement),void this.loadPlayer({abr:{defaultBandwidthEstimate:2e6},manifest:{retryParameters:{timeout:1e4}},streaming:{liveSyncPanicThreshold:1,bufferingGoal:60,bufferBehind:30,retryParameters:{timeout:1e4,maxAttempts:10,backoffFactor:1.1}}})}},{key:"selectAudioRendition",value:function(e){this._selectedAudioRenditionName=e,this.applyAudioRenditionSelection()}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:At.NetworkNoSource,dataBuffered:0};var e=Nt(Nt({},this._player.getStats()),{},{currentTime:0,lag:0}),t=this._videoElement.currentTime||0,n=(Date.now()-this._options.originStartTime)/1e3,r=Math.max(0,n-t);return this._videoElement&&(e.currentTime=t,e.lag=r,this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0))),e.estimatedBandwidth&&(e.estimatedBandwidth&&e.estimatedBandwidth>0&&this._monitoredStatistics.estimatedBandwidth&&this._monitoredStatistics.estimatedBandwidth<e.estimatedBandwidth?e.networkState=At.NetworkLoading:e.playTime&&e.playTime>0&&this._monitoredStatistics.playTime&&this._monitoredStatistics.playTime<e.playTime?e.networkState=At.NetworkIdle:e.video?e.networkState=At.NetworkEmpty:e.networkState=At.NetworkNoSource),this._monitoredStatistics.estimatedBandwidth=e.estimatedBandwidth,this._monitoredStatistics.playTime=e.playTime,e}},{key:"dispose",value:function(){this._disposables.dispose(),this._player&&(this._player.unload(),this._player.destroy()),this._player=null}},{key:"loadPlayer",value:function(e){var t,n,r,i,o=this;null===(t=this._player)||void 0===t||t.configure(e);var a=function(){return o._handleStreamFailure()};null===(n=this._player)||void 0===n||n.addEventListener("error",a),this._disposables.add(new m(function(){var e;return null===(e=o._player)||void 0===e?void 0:e.removeEventListener("error",a)}));var s=function(){return o.readAudioRenditions()};null===(r=this._player)||void 0===r||r.addEventListener("trackschanged",s),this._disposables.add(new m(function(){var e;return null===(e=o._player)||void 0===e?void 0:e.removeEventListener("trackschanged",s)})),null===(i=this._player)||void 0===i||i.load(this._manifestURI).then(function(){o._logger.info("[%s] DASH live stream has been loaded",o._streamId),o._isLoaded=!0,o._videoElement.play&&o._videoElement.play(),o.readAudioRenditions(),o.applyAudioRenditionSelection()}).catch(function(e){o._logger.error("[%s] Error while loading DASH live stream [%s]",o._streamId,e.code,e)})}},{key:"readAudioRenditions",value:function(){if(this._player&&this._isLoaded){var t=this._player.getVariantTracks(),n=t.map(function(e){var t;return null!==(t=e.label)&&void 0!==t?t:""});this._audioRenditions.value=new Mt({names:n,carriesAudio:t.some(e.carriesAudio)})}}},{key:"applyAudioRenditionSelection",value:function(){var t,n=this._player,r=this._selectedAudioRenditionName;if(n&&r&&null!==(t=this._audioRenditions.value)&&void 0!==t&&t.names.includes(r))try{e.selectUnlessActive(n,r)}catch(e){this._logger.warn("[%s] Failed to select audio rendition [%s]",this._streamId,r,e)}}}],[{key:"selectUnlessActive",value:function(e,t){var n,r;if("function"!=typeof e.selectVariantsByLabel){var i,o=(null!==(n=null===(r=e.getAudioTracks)||void 0===r?void 0:r.call(e))&&void 0!==n?n:[]).filter(function(e){return e.label===t});o.length>0&&!o.some(function(e){return e.active})&&(null===(i=e.selectAudioTrack)||void 0===i||i.call(e,o[0]))}else e.getVariantTracks().some(function(e){return e.active&&e.label===t})||e.selectVariantsByLabel(t)}},{key:"carriesAudio",value:function(e){return!!e.audioCodec||!e.videoCodec||e.videoCodec.includes(",")}}])}(),Bt=["addtrack","removetrack"],Gt=function(){function e(){t()(this,e)}return o()(e,null,[{key:"listen",value:function(t,n){var r=e.getTrackList(t);return t.addEventListener("loadedmetadata",n),Bt.forEach(function(e){return null==r?void 0:r.addEventListener(e,n)}),new m(function(){t.removeEventListener("loadedmetadata",n),Bt.forEach(function(e){return null==r?void 0:r.removeEventListener(e,n)})})}},{key:"keepSelection",value:function(t,n,r){var i=e.getTrackList(t),o=function(){var o=n();if(i&&o){var a=e.toArray(i).filter(function(e){return e.enabled}).map(function(e){return e.label});a.length>1?e.select(t,o):1===a.length&&a[0]&&a[0]!==o&&r(a[0])}};return null==i||i.addEventListener("change",o),new m(function(){return null==i?void 0:i.removeEventListener("change",o)})}},{key:"readRenditions",value:function(t){var n=e.getTrackList(t);if(!n||t.readyState<1)return null;var r=e.toArray(n);return new Mt({names:r.map(function(e){return e.label}),carriesAudio:r.length>0})}},{key:"select",value:function(t,n){var r=e.getTrackList(t),i=r?e.toArray(r):[];i.some(function(e){return e.label===n})&&i.forEach(function(e){e.enabled=e.label===n})}},{key:"getTrackList",value:function(e){var t=e.audioTracks;return"function"==typeof(null==t?void 0:t.addEventListener)&&"number"==typeof t.length?t:void 0}},{key:"toArray",value:function(e){for(var t=[],n=0;n<e.length;n++)t.push(e[n]);return t}}])}(),Ut=["levelEmptyError","fragParsingError"],zt=function(){function e(n,r,i,o,a){t()(this,e),s()(this,"_videoElement",void 0),s()(this,"_kind",void 0),s()(this,"_streamId",void 0),s()(this,"_manifestURI",void 0),s()(this,"_options",void 0),s()(this,"_audioRenditions",new b(null)),s()(this,"_readOnlyAudioRenditions",new C(this._audioRenditions)),s()(this,"_audioRenditionFailure",new b(null)),s()(this,"_readOnlyAudioRenditionFailure",new C(this._audioRenditionFailure)),s()(this,"_audioRenditionSelectedByViewer",new b(null)),s()(this,"_readOnlyAudioRenditionSelectedByViewer",new C(this._audioRenditionSelectedByViewer)),s()(this,"_disposables",new ie),s()(this,"_player",void 0),s()(this,"_isNative",!1),s()(this,"_selectedAudioRenditionName",null),s()(this,"_failedAudioRenditionName",null),s()(this,"_audioRenditionFailureTimeout",null),this._videoElement=n,this._kind=r,this._streamId=i,this._manifestURI=encodeURI(o).replace(/[#]/g,"%23"),this._options=a,this._player=null}return o()(e,[{key:"audioRenditions",get:function(){return this._readOnlyAudioRenditions}},{key:"audioRenditionFailure",get:function(){return this._readOnlyAudioRenditionFailure}},{key:"audioRenditionSelectedByViewer",get:function(){return this._readOnlyAudioRenditionSelectedByViewer}},{key:"start",value:function(){var e=this;Zt.hlsPlayer&&(Zt.hlsPlayer.isSupported()?(this._player=new Zt.hlsPlayer({enableWorker:!0,maxBufferLength:1,backBufferLength:0,liveSyncDuration:7,liveDurationInfinity:!0,liveMaxLatencyDuration:1/0,highBufferWatchdogPeriod:1}),this.listenToAudioRenditions(this._player,Zt.hlsPlayer.Events),this._player.loadSource(this._manifestURI),this._player.attachMedia(this._videoElement)):this._videoElement.canPlayType("application/vnd.apple.mpegurl")&&(this._isNative=!0,this._disposables.add(Gt.listen(this._videoElement,function(){return e.readNativeAudioRenditions()})),this._disposables.add(Gt.keepSelection(this._videoElement,function(){return e._selectedAudioRenditionName},function(t){return e.followViewerSelection(t)})),this._videoElement.src=this._manifestURI))}},{key:"selectAudioRendition",value:function(e){this._selectedAudioRenditionName=e,this._isNative?Gt.select(this._videoElement,e):this.applyAudioRenditionSelection()}},{key:"isSupported",value:function(){return Zt.hlsPlayer&&Zt.hlsPlayer.isSupported()}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:At.NetworkNoSource,dataBuffered:0};var e={width:this._player.media.offsetWidth,height:this._player.media.offsetHeight,currentTime:this._player.media.currentTime,lag:0,networkState:At.NetworkIdle,dataBuffered:0};this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0)),"IDLE"===this._player.streamController.state?e.networkState=At.NetworkIdle:"ERROR"===this._player.streamController.state||"ENDED"===this._player.streamController.state?e.networkState=At.NetworkNoSource:this._player.streamController.state.includes("LOADING")||this._player.streamController.state.includes("WAITING")?e.networkState=At.NetworkLoading:e.networkState=At.NetworkEmpty;var t=this._videoElement.currentTime||0,n=(Date.now()-this._options.originStartTime)/1e3;return e.lag=Math.max(0,t+this._options.lag/1e3-n),e}},{key:"dispose",value:function(){this._disposables.dispose(),this._isNative=!1,null!==this._audioRenditionFailureTimeout&&(E.value.clearTimeout(this._audioRenditionFailureTimeout),this._audioRenditionFailureTimeout=null),this._player&&this._player.destroy&&(this._player.destroy(),this._player=null)}},{key:"listenToAudioRenditions",value:function(t,n){var r=this;t.on(n.MANIFEST_PARSED,function(e,t){var n,i,o=(null!==(n=t.audioTracks)&&void 0!==n?n:[]).map(function(e){return e.name}),a=o.length>0||(null!==(i=t.levels)&&void 0!==i?i:[]).some(function(e){return!!e.audioCodec});r._audioRenditions.value=new Mt({names:o,carriesAudio:a})}),t.on(n.AUDIO_TRACKS_UPDATED,function(){return r.applyAudioRenditionSelection()}),t.on(n.ERROR,function(n,i){var o=e.findFailedAudioRenditionName(t,i);o&&o===r._selectedAudioRenditionName&&r.reportAudioRenditionFailureAfterTheErrorEvent(o)})}},{key:"reportAudioRenditionFailureAfterTheErrorEvent",value:function(e){var t=this;this._failedAudioRenditionName=e,null===this._audioRenditionFailureTimeout&&(this._audioRenditionFailureTimeout=E.value.setTimeout(function(){var e=t._failedAudioRenditionName;t._audioRenditionFailureTimeout=null,t._failedAudioRenditionName=null,e&&e===t._selectedAudioRenditionName&&(t._audioRenditionFailure.value={name:e})},0))}},{key:"applyAudioRenditionSelection",value:function(){var e=this._player,t=this._selectedAudioRenditionName;if(e&&t){var n=e.audioTracks.findIndex(function(e){return e.name===t});n>=0&&e.audioTrack!==n&&(e.audioTrack=n)}}},{key:"readNativeAudioRenditions",value:function(){this.applyNativeAudioRenditionSelection(),this._audioRenditions.value=Gt.readRenditions(this._videoElement)}},{key:"applyNativeAudioRenditionSelection",value:function(){this._selectedAudioRenditionName&&Gt.select(this._videoElement,this._selectedAudioRenditionName)}},{key:"followViewerSelection",value:function(e){this._selectedAudioRenditionName=e,this._audioRenditionSelectedByViewer.value={name:e}}}],[{key:"findFailedAudioRenditionName",value:function(e,t){var n,r,i,o;if("string"!=typeof t.details||!Ut.includes(t.details))return null;var a="audioTrack"===(null===(n=t.context)||void 0===n?void 0:n.type)?t.context.id:void 0,s="audio"===(null===(r=t.frag)||void 0===r?void 0:r.type)?t.frag.level:void 0,u=null!=a?a:s;return"number"==typeof u&&null!==(i=null===(o=e.audioTracks[u])||void 0===o?void 0:o.name)&&void 0!==i?i:null}}])}(),Ht=n(981).A;function Wt(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 qt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wt(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Jt(){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,l=Object.create(u.prototype);return Kt(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Kt(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Kt(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Kt(d,"constructor",l),Kt(l,"constructor",u),u.displayName="GeneratorFunction",Kt(l,i,"GeneratorFunction"),Kt(d),Kt(d,i,"Generator"),Kt(d,r,function(){return this}),Kt(d,"toString",function(){return"[object Generator]"}),(Jt=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 Zt=function(){return o()(function e(){t()(this,e)},null,[{key:"hlsPlayer",get:function(){return this._hlsPlayer}},{key:"phenixWebPlayer",get:function(){return this._phenixWebPlayer}},{key:"shaka",get:function(){return this._shaka}},{key:"start",value:(n=N()(Jt().m(function e(t,n,r,i,o){var a=this;return Jt().w(function(e){for(;;)switch(e.n){case 0:if(this._options=i,!(this._hlsPlayer||this._shaka||this._phenixWebPlayer)){e.n=1;break}return e.a(2,this.loaded(t,n,r,o));case 1:if(Be.webPlayerLoader||Be.shakaPlayerLoader||Be.hlsJsLoader){e.n=2;break}throw new Error("Unsupported-feature, add stream player");case 2:return e.a(2,new Ht(function(e){Be.hlsJsLoader&&(a._pending=!0,Be.hlsJsLoader(function(i){a._hlsPlayer=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))})),Be.webPlayerLoader&&(a._pending=!0,Be.webPlayerLoader(function(i){a._phenixWebPlayer=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))})),Be.shakaPlayerLoader&&(a._pending=!0,Be.shakaPlayerLoader(function(i){a._shaka=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))}))}))}},e,this)})),function(e,t,r,i,o){return n.apply(this,arguments)})},{key:"getStats",value:function(){return this._player?this._player.getStats():null}},{key:"play",value:(e=N()(Jt().m(function e(t,n,r,i,o,a){var s,u,l,c;return Jt().w(function(e){for(;;)switch(e.n){case 0:if(s=i.match(/a=x-playlist:([^\n]*[.]mpd\??[^\s]*)/m),u=i.match(/a=x-playlist:([^\n]*[.]m3u8\??[^\s]*)/m),l=s&&s[1]?s[1]:"",!(c=u&&u[1]?u[1]:"")){e.n=1;break}if(this._phenixWebPlayer&&!O.shouldUseNativeHls){e.n=1;break}return this._player=new t(n,"hls",r,c,o,a),this._player.start(),e.a(2,this._player);case 1:if(!l){e.n=2;break}if(this._hlsPlayer||this._phenixWebPlayer&&O.shouldUseNativeHls){e.n=2;break}return this._player=new t(n,"dash",r,l,o,a),this._player.start(),e.a(2,this._player);case 2:if(!l&&!c){e.n=3;break}throw new Error("[".concat(r,"] Cannot play [").concat(c?"HLS":"DASH","] stream with included player"));case 3:throw new Error("No stream playlist found");case 4:return e.a(2)}},e,this)})),function(t,n,r,i,o,a){return e.apply(this,arguments)})},{key:"loaded",value:function(e,t,n,r){return this._hlsPlayer?this.play(zt,e,t,n,qt(qt({},this._options),{},{preferNative:O.shouldUseNativeHls}),r):this._phenixWebPlayer?this.play(Dt,e,t,n,qt(qt({},this._options),{},{preferNative:O.shouldUseNativeHls}),r):this.play(Vt,e,t,n,qt(qt({},this._options),{},{preferNative:O.shouldUseNativeHls}),r)}}]);var e,n}();s()(Zt,"_pending",!1),s()(Zt,"_hlsPlayer",void 0),s()(Zt,"_phenixWebPlayer",void 0),s()(Zt,"_shaka",void 0),s()(Zt,"_options",void 0),s()(Zt,"_player",void 0);var $t=function(e){return e[e.Live=1]="Live",e[e.OndDemand=2]="OndDemand",e}($t||{}),Qt=$t,Yt=n(981).A,Xt=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"),Yt.resolve(!0);if(!O.isRequestAnimationFrameSupported)return this._logger.debug("requestAnimationFrame not supported, assuming rendering"),Yt.resolve(!0);if(!O.isMobile)return this._logger.debug("Skipping frame detection on desktop, assuming rendering"),Yt.resolve(!0);var n=Date.now();return new Yt(function(r){var i=!1,o=E.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,E.value.clearTimeout(o),t._logger.debug("Video frame rendered within [%s] ms — stream is healthy",Date.now()-n),r(!0))}),E.value.requestAnimationFrame(function(){i||(i=!0,E.value.clearTimeout(o),t._logger.debug("No video frame rendered within [%s] ms — stream is stalled",Date.now()-n),r(!1))})})}}])}();s()(Xt,"_logger",ee.getLogger("VideoFrameDetector"));var en=/^Track ([1-9][0-9]*)(?: \(([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)\))?$/,tn=function(){return o()(function e(){t()(this,e)},null,[{key:"parse",value:function(e){var t=en.exec(e);return t?{sourceIndex:Number(t[1])-1,language:t[2]}:null}}])}(),nn=function(){return o()(function e(n,r){var i=this;t()(this,e),s()(this,"_logger",ee.getLogger("ChunkedAudioTrackSelector")),s()(this,"_channelContext",void 0),s()(this,"_player",void 0),s()(this,"_disposables",new ie),s()(this,"_renditionNameBySourceIndex",new Map),s()(this,"_playedRenditionName",null),s()(this,"_previousRenditionName",null),this._channelContext=n,this._player=r,this._disposables.add(r.audioRenditions.subscribe(function(e){return i.applyAudioRenditions(e)})),this._disposables.add(r.audioRenditionFailure.subscribe(function(e){return i.fallBackFromFailedRendition(e)})),this._disposables.add(r.audioRenditionSelectedByViewer.subscribe(function(e){return i.followViewerSelection(e)}))},[{key:"applyAudioTrackSelection",value:function(){var e=this._channelContext.selectedAudioTrack.value,t=e?this._channelContext.findAudioSection(e.id):void 0;this.playAudioSection(null!=t?t:null)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"applyAudioRenditions",value:function(e){if(e){var t=et.orderByRequestedLanguages(this.createAudioSections(e),this._channelContext.audioLanguages).slice(0,this._channelContext.maxAudioTracks);this.playAudioSection(et.findSectionToPlay(t,this._channelContext.requestedAudioTrack)),this._channelContext.setAudioSections(t);var n=this._channelContext.findAudioSectionToPlay();this.playAudioSection(n),this._channelContext.setSelectedAudioSection(n)}}},{key:"createAudioSections",value:function(e){var t=this,n=[];return this._renditionNameBySourceIndex=new Map,e.names.forEach(function(e){var r=tn.parse(e);r&&!t._renditionNameBySourceIndex.has(r.sourceIndex)&&(t._renditionNameBySourceIndex.set(r.sourceIndex,e),n.push(r))}),0===n.length&&e.carriesAudio?[{sourceIndex:0}]:n}},{key:"playAudioSection",value:function(e){var t,n=e?this._renditionNameBySourceIndex.get(e.sourceIndex):void 0;if(n&&n!==this._playedRenditionName){var r=null!==(t=this._playedRenditionName)&&void 0!==t?t:this.findDefaultRenditionName();this._previousRenditionName=r===n?null:r,this._playedRenditionName=n,this._player.selectAudioRendition(n)}}},{key:"findDefaultRenditionName",value:function(){var e,t=Array.from(this._renditionNameBySourceIndex.keys());return t.length&&null!==(e=this._renditionNameBySourceIndex.get(Math.min.apply(Math,t)))&&void 0!==e?e:null}},{key:"fallBackFromFailedRendition",value:function(e){var t=this._previousRenditionName;e&&e.name===this._playedRenditionName&&t&&(this._logger.warn("[%s] Failed to load audio rendition [%s], playing [%s] instead",this._channelContext.streamId,e.name,t),this._previousRenditionName=null,this._playedRenditionName=t,this._player.selectAudioRendition(t))}},{key:"followViewerSelection",value:function(e){var t=this;if(e&&e.name!==this._playedRenditionName){this._logger.info("[%s] Viewer selected audio rendition [%s] in the browser",this._channelContext.streamId,e.name),this._previousRenditionName=this._playedRenditionName,this._playedRenditionName=e.name;var n=this._channelContext.audioSections.value.find(function(n){return t._renditionNameBySourceIndex.get(n.sourceIndex)===e.name});n&&(this._channelContext.requestedAudioTrack={id:String(n.sourceIndex),language:n.language},this._channelContext.setSelectedAudioSection(n))}}}],[{key:"isAudioRenditionPlayer",value:function(e){return"selectAudioRendition"in e&&"audioRenditions"in e&&"audioRenditionFailure"in e&&"audioRenditionSelectedByViewer"in e}}])}(),rn=n(981).A,on=function(){return o()(function e(n,r,i){t()(this,e),s()(this,"_logger",ee.getLogger("ChunkedStreamSubscriber")),s()(this,"_channelContext",void 0),s()(this,"_chunkedStreamPlaybackMode",void 0),s()(this,"_disposables",new ie),s()(this,"_monitorDisposables",new ie),s()(this,"_handleStreamFailure",void 0),s()(this,"_streamStatistics",null),s()(this,"_monitorFailureCount",0),s()(this,"_audioTrackSelector",null),s()(this,"_isDisposed",!1),this._channelContext=n,this._chunkedStreamPlaybackMode=r,this._handleStreamFailure=i,this._channelContext.rendererDisposables.add(this)},[{key:"start",value:function(e,t){var n=this;return Ft.discoverClosestEndPointWithCaching(e).then(function(e){return n._channelContext.online.value=!0,n._channelContext.endPoint.value=e,n._logger.info("Connecting to [%s]",e.toString()),e.subscribe(t,null,n._channelContext.failureCount.value)}).then(function(e){var t,r=e.status,i=n._channelContext.endPoint.value;if(!i)return n._logger.error("Subscribe failed: end point service is missing"),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,void(n._channelContext.state.value=ze.Error);if(n._channelContext.exists.value=n._channelContext.mapSubscribeStatusToExists(r),n._channelContext.state.value=n._channelContext.mapSubscribeStatusToChannelStatus(r),n._channelContext.applyStatus(r),"ok"!==r)return n._channelContext.stream.value=null,n._channelContext.lag.value=void 0,n._channelContext.applySessionAndStreamPropertiesToVideoElement(),void n._logger.debug("[%s] Subscribe failed with status [%s]",n._channelContext.streamId,r);var o=e.stream,a=e.createOfferDescriptionResponse,s=e.lag;n._channelContext.stream.value=o,n._channelContext.lag.value=s,n._channelContext.applySessionAndStreamPropertiesToVideoElement(),n._logger.debug("[%s] Subscribe completed [%s] [%j]",n._channelContext.streamId,r,a);var u=null==a||null===(t=a.sessionDescription)||void 0===t?void 0:t.sdp,l={originStartTime:Date.now()-s+i.roundTripTime/2,lag:s};return n._channelContext.videoElement.value?u?Zt.start(n._channelContext.videoElement.value,n._channelContext.streamId,u,l,function(){return n.retryOnStreamFailure()}).then(function(e){return n.monitor(e),n._disposables.add(e),!n._isDisposed&&nn.isAudioRenditionPlayer(e)&&(n._audioTrackSelector=new nn(n._channelContext,e),n._disposables.add(n._audioTrackSelector)),e}).catch(function(e){n._logger.error("ChunkedStreaming failed",e),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,n._channelContext.state.value=ze.Stopped}):(n._logger.error("Subscribe failed: offer SDP is missing"),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,void(n._channelContext.state.value=ze.Error)):(n._logger.error("Subscribe failed: video element is missing"),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,void(n._channelContext.state.value=ze.Stopped))})}},{key:"applyAudioTrackSelection",value:function(){var e;null===(e=this._audioTrackSelector)||void 0===e||e.applyAudioTrackSelection()}},{key:"retryOnStreamFailure",value:function(){var e=this;this._monitorFailureCount=0,this._channelContext.state.value=ze.ConnectionError,this._channelContext.playing.value=!1,this._channelContext.loading.value=!0,this._disposables.dispose(),this._monitorDisposables.dispose(),this._audioTrackSelector=null,this._handleStreamFailure().catch(function(t){e._logger.error("Failed handling stream failure",t)})}},{key:"monitor",value:function(e){var t=this;this._monitorDisposables.dispose();var n=E.value.setTimeout(function(){var n,r,i,o,a,s=Zt.getStats();if(t._chunkedStreamPlaybackMode!==Qt.Live||(null==s?void 0:s.networkState)!==At.NetworkNoSource||(null===(n=t._channelContext.videoElement.value)||void 0===n?void 0:n.currentTime)!==(null===(r=t._channelContext.videoElement.value)||void 0===r?void 0:r.duration)){if(t._streamStatistics&&(null===(i=t._channelContext.videoElement.value)||void 0===i||!i.paused)&&null!=s&&s.currentTime&&t._streamStatistics.currentTime>=s.currentTime&&(null==s||!s.dataBuffered||t._streamStatistics.dataBuffered>=s.dataBuffered)){if(t._monitorFailureCount++,t._monitorFailureCount>4)return void t.retryOnStreamFailure()}else t._monitorFailureCount=0;null!==(o=t._channelContext.videoElement.value)&&void 0!==o&&o.paused&&t._channelContext.state.value===ze.Playing&&(t._channelContext.state.value=ze.Paused),null!==(a=t._channelContext.videoElement.value)&&void 0!==a&&a.paused||t._channelContext.state.value===ze.Playing||(t._channelContext.state.value=ze.Playing),t._streamStatistics=s,t.monitor(e)}else t.retryOnStreamFailure()},1e3);this._monitorDisposables.add(new m(function(){E.value.clearTimeout(n)}))}},{key:"isStreamHealthy",value:function(){var e=this._channelContext.videoElement.value;return e?e.paused?rn.resolve(!1):Xt.isRenderingFrames(e):rn.resolve(!1)}},{key:"dispose",value:function(){this._isDisposed=!0,this._disposables.dispose(),this._monitorDisposables.dispose(),this._audioTrackSelector=null}}])}(),an=n(715),sn=n.n(an);function un(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 ln=function(){return o()(function e(n){t()(this,e),s()(this,"_sdp",void 0),s()(this,"_sdpSplitByTracks",void 0),s()(this,"_audioSections",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,this._sdpSplitByTracks=this._sdp.split(/(?:^|[\r\n])m=/);var r=this._sdp.split(/(\r\n|\r|\n)/);this._audioCodec=this.applyCodec("audio",r),this._videoCodec=this.applyCodec("video",r),this._audioSections=this.parseAudioSections(),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio"),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video")},[{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:"audioSections",get:function(){return this._audioSections}},{key:"withAudioLanguages",value:function(e){for(var t=this._sdp.includes("\r\n")?"\r\n":this._sdp.includes("\n")?"\n":"\r",n=this._sdp.split(/\r\n|\r|\n/),r=-1,i=!1,o=0;o<n.length;o++)n[o].startsWith("m=")&&(i=n[o].startsWith("m=audio "))&&r++,i&&n[o].startsWith("a=lang:")?(n.splice(o,1),o--):i&&n[o].startsWith("a=mid:")&&e[r]&&(n.splice(o+1,0,"a=lang:".concat(e[r])),o++);return n.join(t)}},{key:"parseAudioSections",value:function(){var e,t=[],n=0,r=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 un(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)?un(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._sdpSplitByTracks.slice(1));try{for(r.s();!(e=r.n()).done;){var i,o,a,s=e.value.split(/\r\n|\r|\n/);if(s[0].startsWith("audio ")){var u=null===(i=s.find(function(e){return e.startsWith("a=mid:")}))||void 0===i?void 0:i.slice(6),l=n++,c=null===(o=s.find(function(e){return e.startsWith("a=x-source-index:")}))||void 0===o?void 0:o.slice(17);u&&t.push({mid:u,sourceIndex:c&&/^\d+$/.test(c)?Number(c):l,language:null===(a=s.find(function(e){return e.startsWith("a=lang:")}))||void 0===a?void 0:a.slice(7),receivesMedia:"0"!==s[0].split(" ")[1]&&!s.includes("a=inactive")&&!s.includes("a=recvonly")})}}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"isTrackByTypeEnabled",value:function(e){var t=this._sdpSplitByTracks.find(function(t){return t.startsWith(e)});return!!t&&!t.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]}}])}(),cn=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}}])}(),dn=n(981).A;function hn(){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,l=Object.create(u.prototype);return fn(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(fn(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,fn(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,fn(d,"constructor",l),fn(l,"constructor",u),u.displayName="GeneratorFunction",fn(l,i,"GeneratorFunction"),fn(d),fn(d,i,"Generator"),fn(d,r,function(){return this}),fn(d,"toString",function(){return"[object Generator]"}),(hn=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 pn(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 vn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?pn(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var mn=function(){return o()(function e(n,r,i,o){var a=this,u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:new C(new b(null));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,"_audioTrackMids",void 0),s()(this,"_selectedAudioMid",void 0),s()(this,"_peerConnection",void 0),s()(this,"_isMonitorRunning",!0),s()(this,"_updateTimeout",null),s()(this,"_tracksToMonitor",void 0),s()(this,"_monitorGeneration",0),s()(this,"_hasWarnedUnresolvedAudio",!1),this._peerConnection=n,this._audioTrackMids=u,this._selectedAudioMid=l,this._estimatedRoundTripTime=i,this._tracksToMonitor=r.getTracks().map(function(e){return e.kind})||[],this._peerConnection){var c,d;if(!O.getCurrentOfferDisabled&&null!==(c=this._peerConnection)&&void 0!==c&&null!==(d=c.currentRemoteDescription)&&void 0!==d&&d.sdp){var h=new ln(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=h.audioCodec,this._estimatedVideoCodec=h.videoCodec}var f=!0;this._disposables.add(o.subscribe(function(e){f?f=!1:e&&a._isMonitorRunning&&(a._monitorGeneration++,a._updateTimeout&&(E.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&&(E.value.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(n=N()(hn().m(function e(){var t,n,r,i,o,a,s,u,l,c,d,h,f,p=this;return hn().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 dn(function(e){r=E.value.setTimeout(function(){return e(null)},5e3)}),e.n=4,dn.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={},l=this._estimatedRoundTripTime,s.forEach(function(e){if("candidate-pair"===e.type&&e.currentRoundTripTime&&(l=1e3*e.currentRoundTripTime,Object.values(u).forEach(function(e){e.roundTripTime=l})),"candidate-pair"===e.type&&e.lastPacketReceivedTimestamp&&(c=e.lastPacketReceivedTimestamp,Object.values(u).forEach(function(e){e.lastPacketReceivedTimestamp=c})),"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&&p._tracksToMonitor.includes(n)){var i,o,a,d,h,f,v,m="audio"===n?p.getAudioSectionMid(e):void 0;if("audio"===n&&p._audioTrackMids.length&&!m)return void(p._hasWarnedUnresolvedAudio||(p._hasWarnedUnresolvedAudio=!0,p._logger.warn("Unable to match inbound audio report to one of [%s] audio tracks",p._audioTrackMids.length)));var g=m?p.getAudioStatisticKey(m):n,y=(e.bytesReceived||0)-(null!==(i=null===(o=p._rtcStatistic.value)||void 0===o||null===(a=o[g])||void 0===a?void 0:a.bytesReceived)&&void 0!==i?i:0),_=e.timestamp-((null===(d=p._rtcStatistic.value)||void 0===d||null===(h=d[g])||void 0===h?void 0:h.timestamp)||0),b=y&&_?Math.floor(8*y/_*1e3):0;if(u[g]={ssrc:e.ssrc,mediaType:n,timestamp:e.timestamp,bitrate:b,bytesReceived:e.bytesReceived,packetsLost:e.packetsLost,packetsReceived:e.packetsReceived,codec:r||p.getCodecByType(n),roundTripTime:l},(e.lastPacketReceivedTimestamp||c)&&(u[g].lastPacketReceivedTimestamp=e.lastPacketReceivedTimestamp||c),"video"===n&&null!==(f=p._rtcStatistic.value)&&void 0!==f&&null!==(v=f.video)&&void 0!==v&&v.framesDecoded){u[g].framesDecoded=e.framesDecoded;var C=(e.framesDecoded-p._rtcStatistic.value.video.framesDecoded)/(u[g].timestamp-p._rtcStatistic.value.video.timestamp)*1e3;u[g].fps=C?Math.round(100*C)/100:0}}}}),d=this._selectedAudioMid.value,(h=d?this.getAudioStatisticKey(d):null)&&u[h]&&(u.audio=vn({},u[h])),this._rtcStatistic.value=u):this._logger.debug("getStats() timed out, skipping stats processing"),e.n=8;break;case 6:if(e.p=6,f=e.v,n===this._monitorGeneration&&this._isMonitorRunning){e.n=7;break}return e.a(2);case 7:this._logger.warn("getStats() rejected",f);case 8:return e.p=8,E.value.clearTimeout(r),e.f(8);case 9:this._isMonitorRunning&&n===this._monitorGeneration&&(this._updateTimeout=E.value.setTimeout(function(){return p.updateStatistic()},1e3));case 10:return e.a(2)}},e,this,[[2,6,8,9]])})),function(){return n.apply(this,arguments)})},{key:"updateStatisticLegacy",value:(e=N()(hn().m(function e(){var t,n,r,i,o,a,s,u,l,c=this;return hn().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 dn(function(e){n=E.value.setTimeout(function(){return e(null)},5e3)}),e.n=3,dn.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()||c.getCodecByType(r),s[r].roundTripTime=u,"video"===r&&null!==(t=c._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-c._rtcStatistic.value.video.framesDecoded)/(s[r].timestamp-c._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,l=e.v,t===this._monitorGeneration&&this._isMonitorRunning){e.n=6;break}return e.a(2);case 6:this._logger.warn("getStatsLegacy() rejected",l);case 7:return e.p=7,E.value.clearTimeout(n),e.f(7);case 8:this._isMonitorRunning&&t===this._monitorGeneration&&(this._updateTimeout=E.value.setTimeout(function(){return c.updateStatistic()},1e3));case 9:return e.a(2)}},e,this,[[1,5,7,8]])})),function(){return e.apply(this,arguments)})},{key:"getAudioSectionMid",value:function(e){var t,n;if(this._audioTrackMids.length){var r=null!==(t=this._peerConnection)&&void 0!==t&&t.supportsGetTransceivers?null===(n=this._peerConnection.getTransceivers().find(function(t){var n;return(null===(n=t.receiver.track)||void 0===n?void 0:n.id)===e.trackIdentifier}))||void 0===n?void 0:n.mid:void 0;return e.mid||r||(1===this._audioTrackMids.length?this._audioTrackMids[0]:void 0)}}},{key:"getAudioStatisticKey",value:function(e){return"audio:".concat(e)}},{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}(),gn=function(e){return e[e.H264=0]="H264",e[e.VP8=1]="VP8",e[e.VP9=2]="VP9",e}({}),yn=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}({}),_n=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[e.DropVideoChunk=5]="DropVideoChunk",e[e.DropAudioChunk=6]="DropAudioChunk",e}({});function bn(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 Cn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?bn(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function kn(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 wn=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!==gn.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){this._disposables.add(i.registerRoute(_n.FrameTimingInformation,this.handleFrameTimingMessage.bind(this,gn[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=sn()(a[o],2),u=s[0],l=s[1],c=parseInt(u,10),d=l.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(c,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 kn(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)?kn(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=sn()(o.value,2),l=u[0],c=u[1];if(l>i)break;t.value=Cn(Cn({},c),{},{renderTimestamp:new Date(performance.timeOrigin+n),playbackState:"playing"}),a.push(l)}}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()(wn,"_transformName","frame-timing-information");var Sn=n(512),Tn=n.n(Sn);function xn(){return Tn()('(()=>{var e={383:e=>{e.exports=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,r,t)=>{var n=t(736);function o(e,r){for(var t=0;t<r.length;t++){var o=r[t];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,r,t){return r&&o(e.prototype,r),t&&o(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,r,t)=>{var n=t(736);e.exports=function(e,r,t){return(r=n(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,r,t)=>{var n=t(738).default;e.exports=function(e,r){if("object"!=n(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,r||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,r,t)=>{var n=t(738).default,o=t(45);e.exports=function(e){var r=o(e,"string");return"symbol"==n(r)?r:r+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function r(t){return e.exports=r="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,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports}},r={};function t(n){var o=r[n];if(void 0!==o)return o.exports;var a=r[n]={exports:{}};return e[n](a,a.exports,t),a.exports}t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{"use strict";var e=t(383),r=t.n(e),n=t(579),o=t.n(n),a=t(693),i=t.n(a),s=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}({}),u=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[e.DropVideoChunk=5]="DropVideoChunk",e[e.DropAudioChunk=6]="DropAudioChunk",e}({});function l(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function c(e,r){for(var t=e.length,n=r;n<t-3;n++)if(0===e[n]&&0===e[n+1]){if(1===e[n+2])return n;if(n+3<t&&0===e[n+2]&&1===e[n+3])return n}return-1}function f(e,r){for(var t=r,n=0;255===e[t];)n++,t++;var o=255*n+e[t++];for(n=0;255===e[t];)n++,t++;var a=255*n+e[t++];return{type:o,payload:e.subarray(t,t+a),length:t+a-r}}function d(e){if(e.getRemainingBits()<10)return null;var r={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(r.fullTimestampFlag){if(e.getRemainingBits()<17)return null;r.seconds=e.readBits(6),r.minutes=e.readBits(6),r.hours=e.readBits(5)}else if(!function(e,r){return e.getRemainingBits()<1||0===e.readBits(1)||!(e.getRemainingBits()<6)&&(r.seconds=e.readBits(6),e.getRemainingBits()<1||0===e.readBits(1)||!(e.getRemainingBits()<6)&&(r.minutes=e.readBits(6),e.getRemainingBits()<1||0===e.readBits(1)||!(e.getRemainingBits()<5)&&(r.hours=e.readBits(5),!0)))}(e,r))return null;return e.getRemainingBits()<24?null:(r.timeOffset=e.readBits(24),r)}function p(e,r){var t,n,o=(t=function(e){var r,t=[],n=0,o=function(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return l(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?l(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);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,s=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){s=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(s)throw a}}}}(e);try{for(o.s();!(r=o.n()).done;){var a=r.value;2===n&&3===a?n=0:(0===a?n++:n=0,t.push(a))}}catch(e){o.e(e)}finally{o.f()}return new Uint8Array(t)}(e),n=0,{readBits:function(e){if(n+e>8*t.length)throw new Error("Cannot read [".concat(e,"] bits - out of bounds"));for(var r=0,o=e;o>0;){var a=Math.floor(n/8),i=8-n%8,s=Math.min(o,i),u=(1<<s)-1;r=r<<s|t[a]>>i-s&u,n+=s,o-=s}return r},skipBits:function(e){if(n+e>8*t.length)throw new Error("Cannot skip [".concat(e,"] bits - out of bounds"));n+=e},getRemainingBits:function(){return 8*t.length-n}}),a={picStruct:void 0};if(r.cpbDpbDelaysPresentFlag&&void 0!==r.cpbRemovalDelayLengthMinus1&&void 0!==r.dpbOutputDelayLengthMinus1&&(o.skipBits(r.cpbRemovalDelayLengthMinus1+1),o.skipBits(r.dpbOutputDelayLengthMinus1+1)),r.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)),s=[],u=0;u<i&&!(o.getRemainingBits()<1);u++)if(1===o.readBits(1)){var c=d(o);if(!c)break;s.push({clockTimestampFlag:!0,clockTimestamp:c})}else s.push({clockTimestampFlag:!1});a.picStruct={numClockTS:i,clockTimestamps:s}}return a}var m,g=function(){return o()(function e(){r()(this,e)},null,[{key:"createFrameTimingInformationTransform",value:function(){return new TransformStream({transform:function(e,r){(function(e){for(var r=new Date,t=new Uint8Array(e.data),n=c(t,0);-1!==n;){var o=c(t,n+1),a=-1===o?t.length:o,l=n+(1===t[n+2]?3:4);if(6==(31&t[l]))for(var d=l+1,m=t.subarray(d,a),g=0;g<m.length&&!(g+2>m.length);){var h=f(m,g);if(1===h.type){var v,y=null===(v=p(h.payload,{cpbDpbDelaysPresentFlag:!1,picStructPresentFlag:!0}).picStruct)||void 0===v?void 0:v.clockTimestamps[0];if(null!=y&&y.clockTimestampFlag){var k,b,T,w,C=e.timestamp,x={timecode:y.clockTimestamp?{hours:null!==(k=y.clockTimestamp.hours)&&void 0!==k?k:null,minutes:null!==(b=y.clockTimestamp.minutes)&&void 0!==b?b:null,seconds:null!==(T=y.clockTimestamp.seconds)&&void 0!==T?T:null,frames:null!==(w=y.clockTimestamp.nFrames)&&void 0!==w?w:null,isFrameDrop:y.clockTimestamp.cntDroppedFlag}:null,receiveTimestamp:r},B={type:s.Metadata,data:{type:u.FrameTimingInformation,data:i()({},C,{decodedFrameTimingInformation:x})}};self.postMessage(B)}}if(g+=h.length,0===h.length)break}n=o}})(e),r.enqueue(e)}})}},{key:"createEncodedStreamTransform",value:function(e,r,t,n){var o=new Map,a=0,i=0,u=0,l=function(e,r){var i=r.data;if(i.type===s.Chunk&&(i.data.type===t||i.data.type===n)){var u=i.data,l=u.type,c=u.data,f=c.timestamp,d=o.get(f);if(d){if(o.delete(f),l!==n){var p=c.surrogate;d.data=p,e.enqueue(d)}}else a++%100==0&&console.warn("[WorkerTransforms] Reply chunk not found for timestamp",f)}};return new TransformStream({start:function(r){e.addEventListener("message",l.bind(null,r),{once:!1})},transform:function(t){var n=function(e){var r,t,n=null!==(r=null===(t=e.getMetadata)||void 0===t?void 0:t.call(e).rtpTimestamp)&&void 0!==r?r:e.timestamp;return"number"==typeof n?n:void 0}(t);if(void 0!==n){for(o.set(n,t);o.size>480;){var a=o.keys().next().value;o.delete(a),i++%100==0&&console.warn("[WorkerTransforms] Pending chunk map exceeded cap of [%s]; evicted oldest timestamp",480,a)}var l=t.data;e.postMessage({type:s.Chunk,data:{type:r,data:{timestamp:n,data:new Uint8Array(l),type:t.type}}},{transfer:[l]})}else u++%100==0&&console.warn("[WorkerTransforms] Unable to resolve a correlation timestamp for chunk; dropping")}})}},{key:"createPassThroughTransform",value:function(){return new TransformStream({transform:function(e,r){return r.enqueue(e)}})}}])}(),h=self,v=function(){function e(){r()(this,e)}return o()(e,null,[{key:"postError",value:function(r){h.postMessage({type:s.Error,data:{name:e._workerName,error:r}})}},{key:"handleAddTransform",value:function(r){if(e._isPipelineConfigured)throw new Error("Error: Pipeline is locked. A transform cannot be added once the pipeline has been configured");switch(r){case"frame-timing-information":e._transforms.push(g.createFrameTimingInformationTransform());break;case"protected-video":e._transforms.push(g.createEncodedStreamTransform(h,u.EncodedVideoChunk,u.SurrogateVideoChunk,u.DropVideoChunk));break;case"protected-audio":e._transforms.push(g.createEncodedStreamTransform(h,u.EncodedAudioChunk,u.SurrogateAudioChunk,u.DropAudioChunk));break;case"pass-through":e._transforms.push(g.createPassThroughTransform());break;default:throw new Error("Error: Unknown transform type [".concat(r,"]"))}}},{key:"configurePipeline",value:function(r,t){if(!r||!t)throw new Error("Error: Configuration of TransformStreamPipeline requires both a readbale source and writable sink");(function(e,r,t){return r.reduce(function(e,r){return e.pipeThrough(r)},e).pipeTo(t)})(r,e._transforms,t).catch(function(r){e.postError(r)}),e._isPipelineConfigured=!0,h.postMessage({type:s.PipelineConfigured,data:{name:e._workerName}})}},{key:"handleMessage",value:function(r){var t=r.data,n=t.type;try{switch(n){case s.AddTransform:e.handleAddTransform(t.data);break;case s.ConfigurePipeline:e._workerName=t.data.name,e.configurePipeline(t.data.source,t.data.sink);break;case s.Chunk:break;default:!function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))}(n)}}catch(r){e.postError(r)}}}])}();m=v,i()(v,"_transforms",[]),i()(v,"_isPipelineConfigured",!1),i()(v,"_workerName","unconfigured-transform-pipeline"),h.onerror=function(e){var r,t;return m.postError(null!==(r=null!==(t=e.error)&&void 0!==t?t:e.message)&&void 0!==r?r:e)},h.onmessage=m.handleMessage.bind(m),h.RTCTransformEvent&&(h.onrtctransform=function(e){var r=e.transformer;try{m._workerName=r.options.name;var t=r.readable,n=r.writable;m.configurePipeline(t,n)}catch(e){m.postError(e)}})})()})();\n',"Worker",void 0,void 0)}var En=n(981).A,Rn=["transferable"],On=function(){return o()(function e(n,r){t()(this,e),s()(this,"_logger",ee.getLogger("TransformPipelineMessageRouter")),s()(this,"_unknownRouteLogCounts",new Map),s()(this,"_worker",void 0),s()(this,"_messageRoutes",new Map),s()(this,"_replyChains",new Map),s()(this,"_onError",void 0),s()(this,"_isDisposed",!1),s()(this,"_pendingConfiguration",void 0),this._worker=n,this._onError=r,this.initialize(n)},[{key:"registerRoute",value:function(e,t,n){var r=this;return this._messageRoutes.set(e,{handler:t,onErrorReply:n}),new m(function(){return r._messageRoutes.delete(e)})}},{key:"waitForConfiguration",value:function(){var e=this;return this._isDisposed?En.reject(new Error("Transform pipeline worker has already been disposed")):new En(function(t,n){e._pendingConfiguration={resolve:t,reject:n}})}},{key:"dispose",value:function(){var e;this._isDisposed=!0,null===(e=this._pendingConfiguration)||void 0===e||e.reject(new Error("Transform pipeline worker was disposed before it finished configuring")),this._pendingConfiguration=void 0,this._messageRoutes.clear(),this._replyChains.clear(),this._unknownRouteLogCounts.clear(),this._worker.terminate()}},{key:"initialize",value:function(e){var t=this;e.addEventListener("message",function(e){var n,r,i,o=e.data;switch(o.type){case yn.Chunk:case yn.Metadata:!function(e){var n=e.type,r=e.data,i=t._messageRoutes.get(n);if(i){var o=(t._replyChains.get(n)||En.resolve()).then(function(){return i.handler(r)}).then(function(e){return t.postReply(e)}).catch(function(e){t._logger.error("Route handler rejected for message type [%s]",n,e),i.onErrorReply&&t.postReply(i.onErrorReply(r))});t._replyChains.set(n,o)}else t.logThrottledErrorForUnknownRoute(n)}(o.data);break;case yn.PipelineConfigured:null===(n=t._pendingConfiguration)||void 0===n||n.resolve(),t._pendingConfiguration=void 0;break;case yn.Error:t._logger.error("An error occurred in [%s] worker",o.data.name,o.data.error),null===(r=t._pendingConfiguration)||void 0===r||r.reject(o.data.error),t._pendingConfiguration=void 0,t.dispose(),null===(i=t._onError)||void 0===i||i.call(t,o.data.error)}},{once:!1})}},{key:"postReply",value:function(e){if(e&&!this._isDisposed){var t=e.transferable,n=ct()(e,Rn),r=t&&"surrogate"in n.data?[n.data.surrogate]:[],i={type:yn.Chunk,data:n};this._worker.postMessage(i,r)}}},{key:"logThrottledErrorForUnknownRoute",value:function(e){var t,n=(null!==(t=this._unknownRouteLogCounts.get(e))&&void 0!==t?t:0)+1;this._unknownRouteLogCounts.set(e,n),(n-1)%100==0&&this._logger.error("Dropping message: No route registered for message type [%s]",e)}}])}(),Pn=n(981).A;function Fn(){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,l=Object.create(u.prototype);return An(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(An(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,An(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,An(d,"constructor",l),An(l,"constructor",u),u.displayName="GeneratorFunction",An(l,i,"GeneratorFunction"),An(d),An(d,i,"Generator"),An(d,r,function(){return this}),An(d,"toString",function(){return"[object Generator]"}),(Fn=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)}function In(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 Ln(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)?Ln(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 Ln(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 Dn,Mn=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,t){var n=new ie,r=e.videoTrack,i=e.audioTrack,o=function(e){var r=e.transformPipelineWorker=new xn;n.add(new m(function(){return r.terminate()})),n.add(e.transformMessageRouter=new On(r,t))},a=r.receiver,s=r.mediaStreamTrack;a&&s&&o(r);var u=i.receiver,l=i.mediaStreamTrack;return u&&l&&o(i),n}},{key:"configureEncodedStreamPipeline",value:(e=N()(Fn().m(function e(t){var n,r,i,o,a;return Fn().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=In(e.transformFunctionNames);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.transformPipelineWorker.postMessage({type:yn.AddTransform,data:r})}}catch(e){n.e(e)}finally{n.f()}}else e.transformPipelineWorker.postMessage({type:yn.AddTransform,data:"pass-through"})})(n),i(r),o=function(){var e=N()(Fn().m(function e(t){var n,r,i;return Fn().w(function(e){for(;;)switch(e.n){case 0:return n=function(){var e=N()(Fn().m(function e(t){var n,r,i,o;return Fn().w(function(e){for(;;)switch(e.n){case 0:if(n=t.receiver,r=t.mediaStreamTrack,i=t.transformPipelineWorker,o=t.transformMessageRouter,!(n&&r&&i&&o)){e.n=1;break}return n.transform=new RTCRtpScriptTransform(i,{name:"".concat(r.kind,"-transform-pipeline")}),e.a(2,o.waitForConfiguration());case 1:return e.a(2,Pn.resolve())}},e)}));return function(t){return e.apply(this,arguments)}}(),r=t.videoTrack,i=t.audioTrack,e.n=1,Pn.all([n(r),n(i)]);case 1:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}(),a=function(){var e=N()(Fn().m(function e(t){var n,r,i,o;return Fn().w(function(e){for(;;)switch(e.n){case 0:return n=function(e){var t=e.receiver,n=e.mediaStreamTrack,r=e.transformPipelineWorker,i=e.transformMessageRouter;if(t&&n&&r&&i){var o=t.createEncodedStreams(),a=i.waitForConfiguration();return r.postMessage({type:yn.ConfigurePipeline,data:{name:"".concat(n.kind,"-transform-pipeline"),source:o.readable,sink:o.writable}},{transfer:[o.readable,o.writable]}),a}return Pn.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,Pn.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 Map,o=new ie;return e.getTracks().forEach(function(e){var a=e.kind;switch(a){case"video":if(t){var s=e,u=new TransformStream({transform:function(n,r){t(e,n,r)}}),l=new MediaStreamTrackProcessor({track:s}),c=new MediaStreamTrackGenerator({kind:s.kind}),d=l.readable,h=c.writable;d.pipeThrough(u).pipeTo(h),r.addTrack(c),i.set(e,c),o.add(new m(function(){r.removeTrack(c)}))}else r.addTrack(e);break;case"audio":if(n){var f=e,p=new TransformStream({transform:function(t,r){n(e,t,r)}}),v=new MediaStreamTrackProcessor({track:f}),g=new MediaStreamTrackGenerator({kind:f.kind}),y=v.readable,_=g.writable;y.pipeThrough(p).pipeTo(_),r.addTrack(g),i.set(e,g);var b=new MediaStream,C=new Audio;b.addTrack(e),C.srcObject=b,document.body.appendChild(C),o.add(new m(function(){r.removeTrack(g),document.body.removeChild(C)}))}else r.addTrack(e);break;default:J(a)}}),{transformedStream:r,renderedTracks:i,disposables:o}}}]);var e}(),jn=function(e){return e[e.OPUS=0]="OPUS",e[e.AAC=1]="AAC",e}({}),Nn=new Uint8Array([0,0,0,1]),Vn=new Uint8Array([].concat(l()(Nn),[103,66,192,42,218,4,4,232,64,0,0,3,0,64,0,0,15,35,198,12,168],l()(Nn),[104,206,60,128],l()(Nn),[6,3,167],l()(new Uint8Array(150).fill(255)),[128],l()(Nn),[101,136,132,6,191,255,255,15,69,0,1,87,159],l()(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])),Bn=new Uint8Array([].concat(l()(Nn),[6,3,255,61],l()(new Uint8Array(316).fill(255)),[128],l()(Nn),[65,154,32,26,240,18,48])),Gn=Symbol(),Un=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 jn.OPUS:return e._dummyAudioSilentPerCodec.OPUS.buffer;case jn.AAC:return;default:J(t)}}},{key:"getInvalidSurrogateAudioData",value:function(){return e._singleZeroByte.buffer}},{key:"getSurrogateVideoIFramePerCodec",value:function(t){switch(t){case gn.H264:return e._isSafari?e._surrogate28x16H264IFrame.buffer:e._dummy2x2VideoIFramePerCodec.H264.buffer;case gn.VP8:return e._dummy2x2VideoIFramePerCodec.VP8.buffer;case gn.VP9:return e._dummy2x2VideoIFramePerCodec.VP9.buffer;default:J(t)}}},{key:"getInvalidSurrogateVideoIFrame",value:function(t){return t===gn.H264&&e._isAndroidChrome?(e._surrogate28x16PFrameFrameNumber=e._surrogate28x16PFrameFrameNumberReset,Gn):e._singleZeroByte.buffer}},{key:"getSurrogateVideoPFramePerCodec",value:function(t){switch(t){case gn.H264:return e._isSafari?e._surrogate28x16H264PFrame.buffer:e._dummy2x2VideoPFramePerCodec.H264.buffer;case gn.VP8:return e._dummy2x2VideoPFramePerCodec.VP8.buffer;case gn.VP9:return e._dummy2x2VideoPFramePerCodec.VP9.buffer;default:J(t)}}},{key:"getInvalidSurrogateVideoPFrame",value:function(){return e._singleZeroByte.buffer}}])}();function zn(){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,l=Object.create(u.prototype);return Hn(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Hn(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Hn(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Hn(d,"constructor",l),Hn(l,"constructor",u),u.displayName="GeneratorFunction",Hn(l,i,"GeneratorFunction"),Hn(d),Hn(d,i,"Generator"),Hn(d,r,function(){return this}),Hn(d,"toString",function(){return"[object Generator]"}),(zn=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)}Dn=Un,s()(Un,"_isSafari","Safari"===R.browserName),s()(Un,"_isAndroidChrome","Chrome"===R.browserName&&R.isAndroid),s()(Un,"_singleZeroByte",new Uint8Array([0])),s()(Un,"_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()(Un,"_dummy2x2VideoIFramePerCodec",{H264:new Uint8Array([].concat(l()(Nn),[9,240],l()(Nn),[103,244,0,10,145,155,43,241,241,248,8,128,0,0,3,0,128,0,0,25,7,137,18,203],l()(Nn),[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()(Un,"_dummy2x2VideoPFramePerCodec",{H264:new Uint8Array([].concat(l()(Nn),[9,240],l()(Nn),[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()(Un,"_surrogate28x16H264IFrame",Vn),s()(Un,"_surrogate28x16H264PFrame",Bn),s()(Un,"_surrogate28x16PFrameFrameNumberReset",1),s()(Un,"_surrogate28x16PFrameFrameNumber",Dn._surrogate28x16PFrameFrameNumberReset);var Wn=function(){function e(n){t()(this,e),s()(this,"_disposables",new ie),this.initialize(n)}return o()(e,[{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(_n.EncodedVideoChunk,function(n){return t.encodedVideoStreamCallback(e.videoTrack,e.encodedVideoStreamSink,n)},function(e){return{type:_n.DropVideoChunk,data:{timestamp:e.timestamp}}}))),e.audioTrack.mediaStreamTrack&&(e.audioTrack.transformFunctionNames.push("protected-audio"),this._disposables.add(e.audioTrack.transformMessageRouter.registerRoute(_n.EncodedAudioChunk,function(n){return t.encodedAudioStreamCallback(e.audioTrack,e.encodedAudioStreamSink,n)},function(e){return{type:_n.DropAudioChunk,data:{timestamp:e.timestamp}}})))}},{key:"encodedAudioStreamCallback",value:(r=N()(zn().m(function t(n,r,i){var o;return zn().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,r(n.mediaStreamTrack,i);case 1:if(t.v){t.n=2;break}o=Un.getInvalidSurrogateAudioData(),t.n=3;break;case 2:o=Un.getSurrogateAudioSilentPerCodec(n.codec);case 3:if(!o){t.n=4;break}return t.a(2,{type:_n.SurrogateAudioChunk,data:{surrogate:o,timestamp:i.timestamp}});case 4:return t.a(2,{type:_n.SurrogateAudioChunk,data:{surrogate:e.toTransferableSurrogate(i.data),timestamp:i.timestamp},transferable:!0})}},t)})),function(e,t,n){return r.apply(this,arguments)})},{key:"encodedVideoStreamCallback",value:(n=N()(zn().m(function t(n,r,i){var o,a;return zn().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,r(n.mediaStreamTrack,i);case 1:if(t.v){t.n=3;break}if((o="key"===i.type?Un.getInvalidSurrogateVideoIFrame(n.codec):Un.getInvalidSurrogateVideoPFrame())!==Gn&&void 0!==o){t.n=2;break}return t.a(2,{type:_n.DropVideoChunk,data:{timestamp:i.timestamp}});case 2:return t.a(2,{type:_n.SurrogateVideoChunk,data:{surrogate:o,timestamp:i.timestamp}});case 3:if(!(a="key"===i.type?Un.getSurrogateVideoIFramePerCodec(n.codec):Un.getSurrogateVideoPFramePerCodec(n.codec))){t.n=4;break}return t.a(2,{type:_n.SurrogateVideoChunk,data:{surrogate:a,timestamp:i.timestamp}});case 4:return t.a(2,{type:_n.SurrogateVideoChunk,data:{surrogate:e.toTransferableSurrogate(i.data),timestamp:i.timestamp},transferable:!0})}},t)})),function(e,t,r){return n.apply(this,arguments)})}],[{key:"toTransferableSurrogate",value:function(e){return e.buffer}}]);var n,r}(),qn=function(){return o()(function e(){t()(this,e)},null,[{key:"convertVideoCodecToVideoCodecType",value:function(e){switch(e){case gn.H264:return"H264";case gn.VP8:return"VP8";case gn.VP9:return"VP9";default:J(e)}}},{key:"convertVideoCodecTypeToVideoCodec",value:function(e){var t=e.toUpperCase();switch(t){case"H264":return gn.H264;case"VP8":return gn.VP8;case"VP9":return gn.VP9;default:J(t)}}}])}(),Jn=function(){return o()(function e(){t()(this,e)},null,[{key:"convertAudioCodecToAudioCodecType",value:function(e){switch(e){case jn.OPUS:return"OPUS";case jn.AAC:return"AAC";default:J(e)}}},{key:"convertAudioCodecTypeToAudioCodec",value:function(e){var t=e.toUpperCase();switch(t){case"OPUS":return jn.OPUS;case"AAC":return jn.AAC;default:J(t)}}}])}(),Kn=n(981).A;function Zn(){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,l=Object.create(u.prototype);return $n(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):($n(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,$n(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,$n(d,"constructor",l),$n(l,"constructor",u),u.displayName="GeneratorFunction",$n(l,i,"GeneratorFunction"),$n(d),$n(d,i,"Generator"),$n(d,r,function(){return this}),$n(d,"toString",function(){return"[object Generator]"}),(Zn=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)}function Qn(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 Yn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qn(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Xn=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,a=this._channelContext.findMaxAudioTracks(o),s=Array.from({length:a},function(){return"audio"});return a<this._channelContext.maxAudioTracks&&this._logger.warn("Encoded insertable streams support one audio track. Requesting [%s] instead of [%s] audio tracks",a,this._channelContext.maxAudioTracks),s.push("video"),Kn.all([Ft.discoverClosestEndPointWithCaching(e),_e.createPeerConnectionOffer("recvonly",s,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=sn()(e,2),r=n[0],o=n[1],s=o.localOffer,u=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"+s.sdp);var l={};return a>1&&(l.maxAudioTracks=a),l.audioLanguages=i._channelContext.audioLanguages,i._channelContext.onRealTimeSubscribeRequestCallback&&(l.onSubscribeRequestCallback=i._channelContext.onRealTimeSubscribeRequestCallback),i._channelContext.onRealTimeSubscribeResponseCallback&&(l.onSubscribeResponseCallback=i._channelContext.onRealTimeSubscribeResponseCallback),!O.clientOfferDisabled&&u.supportsSetConfiguration&&u.supportsGetConfiguration?(s.sdp&&i._channelContext.audioLanguages.length&&(s.sdp=new ln(s.sdp).withAudioLanguages(i._channelContext.audioLanguages)),r.subscribe(t,s,i._channelContext.failureCount.value,l)):(u.close(),u.dispose(),!Be.forceGarbageCollectionOnRestart||O.isMobile&&Be.skipGarbageCollectionOnMobileDevices||ot.forceGarbageCollection(),i._peerConnectionContext.peerConnection.value=null,r.subscribe(t,null,i._channelContext.failureCount.value,l))}).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,d=e.createAnswerDescriptionResponse,h=e.lag,f=(null==d?void 0:d.sessionDescription.sdp)||(null==c?void 0:c.sessionDescription.sdp),p=f?new ln(f).audioSections:[],v=p.filter(function(e){return e.receivesMedia}).length,g=null;return i._channelContext.stream.value=a,i._channelContext.lag.value=h,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),i._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",i._channelContext.streamId,t,s,u,c,d),i.applyRtcConfiguration(i._peerConnectionContext.peerConnection.value,s).then(function(e){var t,s=!1,h=!1,f=[];i._peerConnectionContext.peerConnection.value||(i._peerConnectionContext.peerConnection.value=e),e.onicecandidate=function(n){i._channelContext.stream.value===a&&i._peerConnectionContext.peerConnection.value===e&&(s||Be.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?f.push(n.candidate):h=!0,t||(t=E.value.setTimeout(function(){var e;i._channelContext.stream.value!==a||s||null===(e=i._channelContext.endPoint.value)||void 0===e||e.addIceCandidates(a,f,h).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 E.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(E.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:J(e.iceConnectionState)}}};var y=function(){},_=new Kn(function(t,n){if(!O.onTrackDisabled){var r,o=E.value.setTimeout(function(){return n(new Error("Stream setup timed out"))},3e4),a=new Set,s=!0;return i._disposables.add(new m(function(){return E.value.clearTimeout(o)})),y=function(){var e=g&&s?l()(g).every(function(e){return a.has(e)}):a.size>=v;r&&e&&(E.value.clearTimeout(o),t(r))},void(e.ontrack=function(e){var t,n,i;r=e.streams[0]||r,"audio"===e.track.kind&&(s=s&&!(null===(t=e.transceiver)||void 0===t||!t.mid),a.add(null!==(n=null===(i=e.transceiver)||void 0===i?void 0:i.mid)&&void 0!==n?n:e.track.id)),y()})}var u=function(n){E.value.clearTimeout(c),e.removeEventListener("track",u),e.removeEventListener("addstream",u),t("streams"in n?n.streams[0]:n.stream)},c=E.value.setTimeout(function(){e.removeEventListener("track",u),e.removeEventListener("addstream",u),n(new Error("Stream setup timed out"))},3e4);e.addEventListener("track",u),e.addEventListener("addstream",u),i._disposables.add(new m(function(){return E.value.clearTimeout(c)}))});return new Kn(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(d)return i._logger.info("[%s] Set remote SDP answer [%s]",i._channelContext.streamId,d.sessionDescription.sdp),e.setRemoteDescription(d.sessionDescription).catch(function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,d.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(){var t=p.filter(function(e){return e.receivesMedia});if(g=new Set(i._channelContext.findAudioMidsToAccept(t,o)),v=g.size,e.supportsGetTransceivers)e.getTransceivers().forEach(function(e){var t,n;"audio"!==e.receiver.track.kind||null!==(t=g)&&void 0!==t&&t.has(null!==(n=e.mid)&&void 0!==n?n:"")||(e.direction="inactive")});else if(g.size!==t.length)throw new Error("Audio track selection requires transceivers");return y(),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),_}).then(function(t){var n,a;if(p.length&&e.supportsGetTransceivers){var s,u=e.getTransceivers(),l=p.filter(function(e){return e.receivesMedia&&(!g||g.has(e.mid))}).filter(function(e){return u.some(function(t){return t.mid===e.mid&&"audio"===t.receiver.track.kind})});i._channelContext.setAudioSections(l);var c=i._channelContext.findAudioSectionToPlay(),d=null!==(s=null==c?void 0:c.mid)&&void 0!==s?s:null;u.forEach(function(e){"audio"===e.receiver.track.kind&&(e.receiver.track.enabled=e.mid===d)}),i._channelContext.setSelectedAudioSection(c)}if(o&&null!=e&&null!==(n=e.currentRemoteDescription)&&void 0!==n&&n.sdp){var h,f,v,m=new ln(e.currentRemoteDescription.sdp);i._streamTransformContext.videoTrack.codec=qn.convertVideoCodecTypeToVideoCodec(m.videoCodec),i._streamTransformContext.audioTrack.codec=Jn.convertAudioCodecTypeToAudioCodec(m.audioCodec);var y=e.getReceivers(),_=i._streamTransformContext.videoTrack.mediaStreamTrack=t.getVideoTracks()[0],b=i._streamTransformContext.videoTrack.receiver=y.filter(function(e){return e.track===_})[0];i._streamTransformContext.videoTrack.mid=e.supportsGetTransceivers?null===(h=e.getTransceivers().filter(function(e){return e.receiver===b})[0])||void 0===h?void 0:h.mid:null;var k=i._channelContext.selectedAudioMid.value,w=k&&e.supportsGetTransceivers?null===(f=e.getTransceivers().find(function(e){return e.mid===k}))||void 0===f?void 0:f.receiver.track:void 0,S=i._streamTransformContext.audioTrack.mediaStreamTrack=null!=w?w:t.getAudioTracks()[0],T=i._streamTransformContext.audioTrack.receiver=y.filter(function(e){return e.track===S})[0];i._streamTransformContext.audioTrack.mid=e.supportsGetTransceivers?null===(v=e.getTransceivers().filter(function(e){return e.receiver===T})[0])||void 0===v?void 0:v.mid:null;var x=!1,R=function(e,t){i._logger.error(e,i._channelContext.streamId,t),x||(x=!0,i._handleStreamFailure().catch(function(e){i._logger.error("[%s] Failed handling stream failure after encoded stream transform pipeline error",i._channelContext.streamId,e)}))};if(i._disposables.add(Mn.createEncodedStreamPipeline(i._streamTransformContext,function(e){R("[%s] Encoded stream transform pipeline failed",e)})),i._frameTimingInformationContext.shouldExtractTimecode.value||i._frameTimingInformationContext.shouldExtractTimestamps.value){var O={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:b,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 wn(O))}if(i._streamTransformContext.hasEncodedInsertableStreams.value){var P={videoTrack:i._streamTransformContext.videoTrack,audioTrack:i._streamTransformContext.audioTrack,encodedVideoStreamSink:i._streamTransformContext.encodedVideoStreamSink,encodedAudioStreamSink:i._streamTransformContext.encodedAudioStreamSink};i._disposables.add(new Wn(P))}Mn.configureEncodedStreamPipeline(i._streamTransformContext).catch(function(e){R("[%s] Failed to configure encoded stream transform pipeline",e)})}var F=new Map;if(i._streamTransformContext.hasInsertableStreams.value){var A=Mn.configureInsertableStreamTransformation(t,i._streamTransformContext.videoStreamTransformCallback,i._streamTransformContext.audioStreamTransformCallback);i._disposables.add(A.disposables),t=A.transformedStream,F=A.renderedTracks}i._peerConnectionContext.renderedTracks=F,i._peerConnectionContext.mediaStream.value=t;var I=new mn(e,t,null!==(a=i._channelContext.endPoint.value)&&void 0!==a&&a.roundTripTime?i._channelContext.endPoint.value.roundTripTime/4:0,Be.applicationActivityMonitor.isForeground,i._channelContext.audioSections.value.map(function(e){return e.mid}).filter(function(e){return void 0!==e}),new C(i._channelContext.selectedAudioMid));i._disposables.add(I);var L=I.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(!Be.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)&&E.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 He(t.audio.timestamp-i._channelContext.rtcAudioStatistic.timestamp).toIsoString()),i._channelContext.rtcAudioStatistic=t.audio):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)&&E.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 He(t.video.timestamp-i._channelContext.rtcVideoStatistic.timestamp).toIsoString()),i._channelContext.rtcVideoStatistic=t.video),E.value.navigatorIsOnLine)if(r||n)i.reconnectPeerConnection(i._channelContext.streamId,e,function(){I.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!==ze.Reconnecting&&i._channelContext.state.value!==ze.Offline)return;i._channelContext.state.value=i._channelContext.playing.value?ze.Playing:ze.Paused,i._logger.info("Channel state restored to [%s] after reconnecting",ze[i._channelContext.state.value])}else i._channelContext.state.value=ze.Offline}});return i._disposables.add(L),Be.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=ze.Paused))})})})}},{key:"applyRtcConfiguration",value:(e=N()(Zn().m(function e(t,n){var r;return Zn().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return n=cn.truncateIceServers(n),e.a(2,Be.peerConnectionFactory.value.createPeerConnection(n));case 1:return r=Yn(Yn({},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(Be.applicationActivityMonitor.isForeground.value){if("closed"!==t.iceConnectionState){switch(this._channelContext.state.value){case ze.Paused:case ze.Stopped:case ze.Unauthorized:case ze.GeoRestricted:case ze.GeoBlocked:case ze.UnsupportedFeature:case ze.ConfigurationError:return void this._logger.debug("[%s] Skipping peerConnection reconnection in deliberately-terminal state [%s]",e,ze[this._channelContext.state.value])}if(this._channelContext.state.value=ze.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Be.maximalNumberOfPeerConnectionReconnectAttempts||!Be.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 Kn.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&&!t.muted||!r?Kn.resolve(!1):Xt.isRenderingFrames(t)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"mapSetRemoteDescriptionStatusToChannelStatus",value:function(e){switch(e){case"ok":return ze.Starting;case"unauthorized":return ze.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return ze.Recovering;case"failed":return ze.Error;default:J(e)}}}]);var e}(),er=function(){return o()(function e(){throw t()(this,e),new Error("StreamSubscriberFactory 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,s=a.includes("streaming"),u=a.includes("on-demand");return s||u?new on(t,u?Qt.OndDemand:Qt.Live,o):new Xn(t,n,r,i,o)}}])}(),tr=function(e){return e[e.Idle=0]="Idle",e[e.Loading=1]="Loading",e[e.Playing=2]="Playing",e[e.Ended=3]="Ended",e[e.ReturningToRealTime=4]="ReturningToRealTime",e[e.Unauthorized=5]="Unauthorized",e[e.GeoRestricted=6]="GeoRestricted",e[e.GeoBlocked=7]="GeoBlocked",e[e.NoCoverage=8]="NoCoverage",e[e.NotFound=9]="NotFound",e[e.InvalidWindow=10]="InvalidWindow",e[e.UnsupportedFeature=11]="UnsupportedFeature",e[e.RealTimeUnavailable=12]="RealTimeUnavailable",e[e.Error=13]="Error",e}(tr||{}),nr=tr,rr=function(){return o()(function e(){t()(this,e),s()(this,"isSupported",new b(!1)),s()(this,"isReplaying",new b(!1)),s()(this,"state",new b(nr.Idle)),s()(this,"window",new b(null)),s()(this,"error",new b(null)),s()(this,"autoMuted",new b(!1)),s()(this,"videoElement",new b(null))},[{key:"resetSession",value:function(){this.videoElement.value=null,this.autoMuted.value=!1,this.window.value=null,this.error.value=null,this.state.value=nr.Idle,this.isReplaying.value=!1}}])}(),ir=function(){return o()(function e(){throw t()(this,e),new Error("ReplayStatusMapping is a static class that may not be instantiated")},null,[{key:"convertReplayStatusToReplayError",value:function(e){switch(e){case"no-stream":case"missing-index":case"segment-not-found":return"no-coverage";case"not-found":return"manifest-not-found";case"excessive-replay-interval":return"window-too-long";case"period-end-must-be-after-start":return"invalid-window";default:return e}}},{key:"convertReplayStatusToReplayState",value:function(e){switch(e){case"unauthorized":return nr.Unauthorized;case"geo-restricted":return nr.GeoRestricted;case"geo-blocked":return nr.GeoBlocked;case"no-stream":case"missing-index":case"segment-not-found":return nr.NoCoverage;case"not-found":return nr.NotFound;case"period-end-must-be-after-start":case"excessive-replay-interval":case"invalid-window":return nr.InvalidWindow;case"unsupported-feature":return nr.UnsupportedFeature;case"real-time-unavailable":return nr.RealTimeUnavailable;default:return nr.Error}}}])}(),or=n(981).A,ar=function(){function e(){throw t()(this,e),new Error("ReplayHlsLoader is a static class that may not be instantiated")}return o()(e,null,[{key:"isAvailable",value:function(){return Boolean(e.resolveLoaded()||Be.hlsJsLoader)}},{key:"load",value:function(){var t=e.resolveLoaded();if(t)return or.resolve(t);if(e._pending)return e._pending;var n=Be.hlsJsLoader;if(!n)return or.resolve(null);var r=e._generation;return e._pending=new or(function(t){var i=0,o=!1,a=function(n){o||(o=!0,E.value.clearTimeout(i),n&&r===e._generation&&(e._cached=n),t(n))};i=E.value.setTimeout(function(){e._logger.warn("The registered hlsJsLoader did not call back within [%s] ms",1e4),a(null)},1e4);try{n(function(t){if("function"!=typeof t)return e._logger.error("The registered hlsJsLoader called back without an hls.js constructor"),void a(null);a(t)})}catch(t){e._logger.error("The registered hlsJsLoader threw while loading hls.js",t),a(null)}}).finally(function(){r===e._generation&&(e._pending=null)}),e._pending}},{key:"reset",value:function(){e._cached=null,e._pending=null,e._generation++}},{key:"resolveLoaded",value:function(){var t,n;return null!==(t=null!==(n=e._cached)&&void 0!==n?n:Zt.hlsPlayer)&&void 0!==t?t:null}}])}();function sr(e,t,n){return t=f()(t),d()(e,ur()?Reflect.construct(t,n||[],f()(e).constructor):t.apply(e,n))}function ur(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ur=function(){return!!e})()}s()(ar,"_logger",ee.getLogger("ReplayHlsLoader")),s()(ar,"_cached",null),s()(ar,"_pending",null),s()(ar,"_generation",0);var lr=function(e){function n(e,r){var i;return t()(this,n),i=sr(this,n,[e]),s()(i,"status",void 0),s()(i,"reason",void 0),i.name="ReplaySessionError",i.status=r,i.reason=ir.convertReplayStatusToReplayError(r),i}return v()(n,e),o()(n)}(ht()(Error)),cr=function(e){function n(e,r){var i;return t()(this,n),(i=sr(this,n,[e,r])).name="ReplayRefusedError",i}return v()(n,e),o()(n)}(lr),dr=function(e){function n(e,r){var i;return t()(this,n),(i=sr(this,n,[e,r])).name="ReplayPlaybackError",i}return v()(n,e),o()(n)}(lr),hr=function(e){function n(){var e;return t()(this,n),(e=sr(this,n,["Replay playback was cancelled."])).name="ReplayPlaybackCancelledError",e}return v()(n,e),o()(n)}(ht()(Error));function fr(e,t,n,r){return e.addEventListener(t,n,r),new m(function(){e.removeEventListener(t,n,r)})}function pr(){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,l=Object.create(u.prototype);return vr(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(vr(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,vr(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,vr(d,"constructor",l),vr(l,"constructor",u),u.displayName="GeneratorFunction",vr(l,i,"GeneratorFunction"),vr(d),vr(d,i,"Generator"),vr(d,r,function(){return this}),vr(d,"toString",function(){return"[object Generator]"}),(pr=function(){return{w:o,m:h}})()}function vr(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}vr=function(e,t,n,r){function o(t,n){vr(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))},vr(e,t,n,r)}var mr=function(){return o()(function e(n,r){var i=this;t()(this,e),s()(this,"_source",void 0),s()(this,"_lifetime",new ie),s()(this,"_ended",new b(!1)),s()(this,"_readOnlyEnded",new C(this._ended)),s()(this,"_fatalError",new b(null)),s()(this,"_readOnlyFatalError",new C(this._fatalError)),s()(this,"_session",null),s()(this,"_isDisposed",!1),this._source=r,this._lifetime.add(fr(n,"ended",function(){return i.markEnded()}))},[{key:"ended",get:function(){return this._readOnlyEnded}},{key:"fatalError",get:function(){return this._readOnlyFatalError}},{key:"play",value:(e=N()(pr().m(function e(t){var n;return pr().w(function(e){for(;;)switch(e.n){case 0:if(this.stop(),!this._isDisposed){e.n=1;break}throw new dr("The replay player has been disposed","failed");case 1:return this._fatalError.value=null,n=new ie,this._session=n,e.a(2,this._source.load(t,n))}},e,this)})),function(t){return e.apply(this,arguments)})},{key:"stop",value:function(){var e;null===(e=this._session)||void 0===e||e.dispose(),this._session=null,this._source.release(),this._ended.value=!1}},{key:"markEnded",value:function(){this._ended.value=!0}},{key:"reportFatalError",value:function(e){this._fatalError.value=e}},{key:"dispose",value:function(){this._isDisposed||(this._isDisposed=!0,this.stop(),this._lifetime.dispose())}}]);var e}(),gr=n(981).A;function yr(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}var _r=function(e,t,n,r){return{default:{maxTimeToFirstByteMs:e,maxLoadTimeMs:t,timeoutRetry:{maxNumRetry:n,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:r,retryDelayMs:1e3,maxRetryDelayMs:8e3}}}},br={enableWorker:!0,lowLatencyMode:!1,backBufferLength:1/0,maxBufferLength:30,maxMaxBufferLength:120,startPosition:0,testBandwidth:!0,manifestLoadPolicy:_r(1/0,2e4,2,2),playlistLoadPolicy:_r(1e4,2e4,2,2),fragLoadPolicy:_r(1e4,12e4,4,4)},Cr=function(){function e(n,r){t()(this,e),s()(this,"_logger",ee.getLogger("ReplayHlsJsPlayer")),s()(this,"_videoElement",void 0),s()(this,"_Hls",void 0),s()(this,"_lifecycle",void 0),s()(this,"_hls",null),s()(this,"_lastSegmentNumber",null),s()(this,"_isTailMissing",!1),this._videoElement=n,this._Hls=r,this._lifecycle=new mr(n,this)}return o()(e,[{key:"ended",get:function(){return this._lifecycle.ended}},{key:"fatalError",get:function(){return this._lifecycle.fatalError}},{key:"load",value:function(t,n){var r=this,i=this._Hls,o=new i(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?yr(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({},br));return this._hls=o,this._lastSegmentNumber=null,this._isTailMissing=!1,this._videoElement.srcObject=null,this._videoElement.removeAttribute("src"),new gr(function(a,s){var u=!1,l=function(e){u||(u=!0,e())},c=function(t,n){var o,a,c,d,h=e.errorDetails(n);if(n.fatal){var f,p;if(u&&r.isMissingTailSegment(n,h))return r._logger.info("Replay window is missing its final segment [%s]; the window ends when the buffered media has played out",null!==(f=null===(p=n.frag)||void 0===p?void 0:p.sn)&&void 0!==f?f:"n/a"),r._isTailMissing=!0,void r.endIfPlayedOut();var v=e.mapHlsErrorToStatus(n,i.ErrorTypes),m=new dr("Replay playback failed (".concat(null!=h?h:n.type,")"),v);r._logger.error("Fatal replay playback error [%s] [%s] on level [%s] fragment [%s], mapped to [%s]",n.type,h,null!==(o=null===(a=n.frag)||void 0===a?void 0:a.level)&&void 0!==o?o:"n/a",null!==(c=null===(d=n.frag)||void 0===d?void 0:d.sn)&&void 0!==c?c:"n/a",v),u?r._lifecycle.reportFatalError(m):l(function(){return s(m)})}else{var g,y,_,b;r._logger.warn("Recoverable replay playback error [%s] [%s] on level [%s] fragment [%s]",n.type,h,null!==(g=null===(y=n.frag)||void 0===y?void 0:y.level)&&void 0!==g?g:"n/a",null!==(_=null===(b=n.frag)||void 0===b?void 0:b.sn)&&void 0!==_?_:"n/a")}},d=function(){return l(a)},h=function(e,t){var n;r.selectStartLevel(o,null!==(n=t.levels)&&void 0!==n?n:[])},f=function(e,t){var n="object"===Ee()(t.details)?t.details.endSN:void 0;r._lastSegmentNumber="number"==typeof n?n:null},p=function(){return r._lifecycle.markEnded()};o.on(i.Events.ERROR,c),o.on(i.Events.FRAG_BUFFERED,d),o.on(i.Events.MANIFEST_PARSED,h),o.on(i.Events.LEVEL_LOADED,f),o.on(i.Events.MEDIA_ENDED,p),n.add(fr(r._videoElement,"timeupdate",function(){return r.endIfPlayedOut()})),n.add(fr(r._videoElement,"waiting",function(){return r.endIfPlayedOut()})),n.add(new m(function(){o.off(i.Events.ERROR,c),o.off(i.Events.FRAG_BUFFERED,d),o.off(i.Events.MANIFEST_PARSED,h),o.off(i.Events.LEVEL_LOADED,f),o.off(i.Events.MEDIA_ENDED,p),l(function(){return s(new hr)})})),o.attachMedia(r._videoElement),o.loadSource(t)})}},{key:"play",value:function(e){return this._lifecycle.play(e)}},{key:"release",value:function(){var e=this._hls;this._hls=null,e&&(e.stopLoad(),e.detachMedia(),e.destroy())}},{key:"stop",value:function(){this._lifecycle.stop()}},{key:"dispose",value:function(){this._lifecycle.dispose()}},{key:"selectStartLevel",value:function(t,n){var r,i,o=e.findHighestLevel(n);o<0||(this._logger.info("Starting replay on the highest level [%s] of [%s] [%sp]",o,n.length,null!==(r=null===(i=n[o])||void 0===i?void 0:i.height)&&void 0!==r?r:"unknown"),t.startLevel=o,t.nextAutoLevel=o)}},{key:"isMissingTailSegment",value:function(t,n){var r,i=null===(r=t.frag)||void 0===r?void 0:r.sn;return null!==this._lastSegmentNumber&&"number"==typeof i&&"fragLoadError"===n&&404===e.httpStatusOf(t)&&i>=this._lastSegmentNumber}},{key:"endIfPlayedOut",value:function(){if(this._isTailMissing&&!this._lifecycle.ended.value){var e=this.reachableBufferedEnd();null!==e?this._videoElement.currentTime>=e-.4&&(this._logger.info("Replay window played out the media that exists; treating the window as ended"),this._lifecycle.markEnded()):this._lifecycle.markEnded()}}},{key:"reachableBufferedEnd",value:function(){var e=this._videoElement.buffered;if(0===e.length)return null;for(var t=this._videoElement.currentTime,n=0;n<e.length;n++)if(t>=e.start(n)-.4&&t<=e.end(n)+.4)return e.end(n);return e.end(e.length-1)}}],[{key:"findHighestLevel",value:function(e){return e.length<2?-1:e.reduce(function(t,n,r){var i,o,a,s,u,l,c=null!==(i=n.height)&&void 0!==i?i:0,d=null!==(o=null===(a=e[t])||void 0===a?void 0:a.height)&&void 0!==o?o:0;return c!==d?c>d?r:t:(null!==(s=n.bitrate)&&void 0!==s?s:0)>(null!==(u=null===(l=e[t])||void 0===l?void 0:l.bitrate)&&void 0!==u?u:0)?r:t},0)}},{key:"isMediaRequest",value:function(e){return!!e&&(e.startsWith("frag")||e.startsWith("key"))}},{key:"errorDetails",value:function(e){return"string"==typeof e.details?e.details:void 0}},{key:"httpStatusOf",value:function(e){var t,n,r;return null!==(t=null===(n=e.response)||void 0===n?void 0:n.code)&&void 0!==t?t:null===(r=e.networkDetails)||void 0===r?void 0:r.status}},{key:"mapHlsErrorToStatus",value:function(t,n){switch(e.httpStatusOf(t)){case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 404:return e.isMediaRequest(e.errorDetails(t))?"segment-not-found":"not-found";case 408:return"timeout";case 429:case 504:return"rate-limited";case 503:return"capacity"}return n&&t.type===n.KEY_SYSTEM_ERROR?"unauthorized":"failed"}}])}(),kr=n(981).A,wr=function(){return o()(function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("ReplayNativeHlsPlayer")),s()(this,"_videoElement",void 0),s()(this,"_lifecycle",void 0),this._videoElement=n,this._lifecycle=new mr(n,this)},[{key:"ended",get:function(){return this._lifecycle.ended}},{key:"fatalError",get:function(){return this._lifecycle.fatalError}},{key:"play",value:function(e){return this._lifecycle.play(e)}},{key:"load",value:function(e,t){var n=this;return this._logger.info("Playing replay window with native HLS playback"),this._videoElement.srcObject=null,this._videoElement.src=e,new kr(function(e,r){var i=!1;t.add(fr(n._videoElement,"loadedmetadata",function(){i||(i=!0,e())},{once:!0})),t.add(fr(n._videoElement,"error",function(){var e=new dr("Native HLS playback failed to load the replay window.","failed");i?n._lifecycle.reportFatalError(e):(i=!0,r(e))})),t.add(new m(function(){i||(i=!0,r(new hr))}))})}},{key:"release",value:function(){this._videoElement.hasAttribute("src")&&(this._videoElement.removeAttribute("src"),this._videoElement.load())}},{key:"stop",value:function(){this._lifecycle.stop()}},{key:"dispose",value:function(){this._lifecycle.dispose()}}],[{key:"isSupportedBy",value:function(e){return""!==e.canPlayType("application/vnd.apple.mpegurl")}}])}();function Sr(){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,l=Object.create(u.prototype);return Tr(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Tr(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Tr(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Tr(d,"constructor",l),Tr(l,"constructor",u),u.displayName="GeneratorFunction",Tr(l,i,"GeneratorFunction"),Tr(d),Tr(d,i,"Generator"),Tr(d,r,function(){return this}),Tr(d,"toString",function(){return"[object Generator]"}),(Sr=function(){return{w:o,m:h}})()}function Tr(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Tr=function(e,t,n,r){function o(t,n){Tr(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))},Tr(e,t,n,r)}var xr=function(){function e(){throw t()(this,e),new Error("ReplayPlayerFactory is a static class that may not be instantiated")}return o()(e,null,[{key:"isSupported",value:function(){return ar.isAvailable()||e.playsNatively()}},{key:"playsNatively",value:function(){return wr.isSupportedBy(E.value.documentCreateElement("video"))}},{key:"create",value:(n=N()(Sr().m(function t(n){var r;return Sr().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,ar.load();case 1:if(!(r=t.v)||!r.isSupported()){t.n=2;break}return t.a(2,new Cr(n,r));case 2:if(!wr.isSupportedBy(n)){t.n=3;break}return e._logger.info("hls.js is unavailable; falling back to native HLS playback"),t.a(2,new wr(n));case 3:throw new dr("Replay requires hls.js (register one with SDK.init({hlsJsLoader})) or native HLS playback support","unsupported-feature");case 4:return t.a(2)}},t)})),function(e){return n.apply(this,arguments)})}]);var n}();s()(xr,"_logger",ee.getLogger("ReplayPlayerFactory"));var Er=function(){function e(n){t()(this,e),s()(this,"_logger",ee.getLogger("ReplayPresentation")),s()(this,"_replayVideoElement",void 0),s()(this,"_element",null),s()(this,"_geometrySubscriptions",null),this._replayVideoElement=n}return o()(e,[{key:"element",get:function(){return this._element}},{key:"attach",value:function(){var e;if(this._element)return this._element;var t=this._replayVideoElement,n=document.createElement("video");return n.dataset.rtsReplay="true",n.playsInline=!0,n.autoplay=!1,n.controls=t.controls,n.muted=t.muted,n.volume=t.volume,this.applyLayout(n),(null!==(e=t.parentElement)&&void 0!==e?e:document.body).appendChild(n),this._element=n,this._geometrySubscriptions=new ie,this.observeGeometry(),this.syncGeometry(),n}},{key:"detach",value:function(){var e;null===(e=this._geometrySubscriptions)||void 0===e||e.dispose(),this._geometrySubscriptions=null;var t=this._element;if(this._element=null,t){try{t.pause()}catch(e){this._logger.debug("Replay element rejected pause() during teardown",e)}t.removeAttribute("src"),t.srcObject=null;try{t.load()}catch(e){this._logger.debug("Replay element rejected load() during teardown",e)}t.remove()}}},{key:"dispose",value:function(){this.detach()}},{key:"applyLayout",value:function(t){var n=t.style;n.position="absolute",n.margin="0",n.padding="0",n.border="none",n.backgroundColor="#000",n.objectFit=e.readComputedStyle(this._replayVideoElement,"objectFit")||"contain",n.zIndex=e.overlayZIndex(this._replayVideoElement)}},{key:"observeGeometry",value:function(){var e=this,t=this._geometrySubscriptions;if(t){var n=function(){return e.syncGeometry()},r=window.ResizeObserver;if(r){var i=new r(n);i.observe(this._replayVideoElement),t.add(new m(function(){return i.disconnect()}))}E.value.addWindowEventListener("resize",n),E.value.addWindowEventListener("scroll",n,!0),t.add(new m(function(){E.value.removeWindowEventListener("resize",n),E.value.removeWindowEventListener("scroll",n,!0)})),t.add(fr(this._replayVideoElement,"loadedmetadata",n)),t.add(fr(this._replayVideoElement,"resize",n))}}},{key:"syncGeometry",value:function(){var e=this._element;if(e){var t=this._replayVideoElement.getBoundingClientRect(),n=e.offsetParent,r=t.left,i=t.top;if(n){var o=n.getBoundingClientRect();r=t.left-o.left-n.clientLeft+n.scrollLeft,i=t.top-o.top-n.clientTop+n.scrollTop}else r=t.left+(window.scrollX||0),i=t.top+(window.scrollY||0);e.style.left="".concat(r,"px"),e.style.top="".concat(i,"px"),e.style.width="".concat(t.width,"px"),e.style.height="".concat(t.height,"px")}}}],[{key:"readComputedStyle",value:function(e,t){var n,r;return"function"!=typeof window.getComputedStyle?"":null!==(n=null===(r=window.getComputedStyle(e))||void 0===r?void 0:r[t])&&void 0!==n?n:""}},{key:"overlayZIndex",value:function(t){var n=Number.parseInt(e.readComputedStyle(t,"zIndex"),10);return String(Number.isFinite(n)?n+1:1)}}])}(),Rr=["ok","no-stream","missing-index","period-end-must-be-after-start","excessive-replay-interval","unauthorized","geo-restricted","geo-blocked","not-found","capacity","rate-limited","timeout","failed"],Or=function(){function e(){throw t()(this,e),new Error("ReplayWindows is a static class that may not be instantiated")}return o()(e,null,[{key:"defaultEndSkewMs",get:function(){return 8e3}},{key:"toIsoString",value:function(e){return new Date(e).toISOString()}},{key:"resolve",value:function(t,n){var r,i,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=e.toEpochMs(t);if(!Number.isFinite(a)||!Number.isFinite(n))throw new cr("Replay window startTime and duration must be finite","invalid-window");if(n<=0)throw new cr("Replay window duration must be greater than zero","invalid-window");var s=a+n;if(!e.isRepresentable(a)||!e.isRepresentable(s))throw new cr("Replay window lies outside the range a date can represent","invalid-window");var u=(null!==(r=o.nowMs)&&void 0!==r?r:Date.now())-(null!==(i=o.endSkewMs)&&void 0!==i?i:8e3);if(a>=u)throw new cr("Replay window does not overlap the available range","invalid-window");var l=Math.min(s,u);return{startTime:a,endTime:l,requestedStartTime:a,requestedEndTime:s,wasAdjusted:l!==s}}},{key:"toEpochMs",value:function(e){return e instanceof Date?e.getTime():e}},{key:"isRepresentable",value:function(e){return!Number.isNaN(new Date(e).getTime())}}])}();function Pr(){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,l=Object.create(u.prototype);return Fr(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Fr(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Fr(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Fr(d,"constructor",l),Fr(l,"constructor",u),u.displayName="GeneratorFunction",Fr(l,i,"GeneratorFunction"),Fr(d),Fr(d,i,"Generator"),Fr(d,r,function(){return this}),Fr(d,"toString",function(){return"[object Generator]"}),(Pr=function(){return{w:o,m:h}})()}function Fr(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Fr=function(e,t,n,r){function o(t,n){Fr(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))},Fr(e,t,n,r)}var Ar=["edgeAuthToken"],Ir=function(){function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e4;t()(this,e),s()(this,"_logger",ee.getLogger("ReplayApi")),s()(this,"_baseUri",void 0),s()(this,"_timeoutMs",void 0),this._baseUri=n,this._timeoutMs=r}return o()(e,[{key:"buildReplayManifestUrl",value:function(e,t,n){var r=re.parseToken(e).tenancy;if(!r)throw new Error("Replay token is missing an applicationId");return this.buildManifestUrl(r,e,t,n)}},{key:"getReplayManifest",value:(n=N()(Pr().m(function t(n,r,i){var o,a,s,u,l,c,d,h;return Pr().w(function(t){for(;;)switch(t.p=t.n){case 0:if(o=re.parseToken(n).tenancy){t.n=1;break}return this._logger.error("Replay token is missing an applicationId"),t.a(2,{status:"unauthorized"});case 1:return a=this.buildManifestUrl(o,n,r,i),s=new E.value.AbortController,u=E.value.setTimeout(function(){return s.abort()},this._timeoutMs),t.p=2,t.n=3,E.value.fetch(a.toString(),{method:"GET",cache:"no-cache",signal:s.signal});case 3:if(l=t.v,c=e.mapHttpStatusToReplayStatus(l.status),this._logger.debug("Replay manifest fetch status [%s]",c),"timeout"!==c){t.n=4;break}return t.a(2,{status:c});case 4:return t.n=5,l.text();case 5:if(d=t.v,"ok"===c){t.n=6;break}return this.logNonManifestBody(d),t.a(2,{status:e.statusFromBody(d,c)});case 6:if(!d.trim().startsWith("#EXTM3U")){t.n=7;break}return t.a(2,{status:"ok",manifest:d,url:l.url||a.toString()});case 7:return this.logNonManifestBody(d),t.a(2,{status:e.statusFromBody(d,"no-stream")});case 8:if(t.p=8,"AbortError"!==(null==(h=t.v)?void 0:h.name)){t.n=9;break}return t.a(2,{status:"timeout"});case 9:return this._logger.error("Failed to fetch replay manifest [%s]",a.pathname,h),t.a(2,{status:"failed"});case 10:return t.p=10,E.value.clearTimeout(u),t.f(10);case 11:return t.a(2)}},t,this,[[2,8,10,11]])})),function(e,t,r){return n.apply(this,arguments)})},{key:"buildManifestUrl",value:function(e,t,n,r){var i=Se.buildRouteUrl(Se.normalizeDiscoveryUri(this._baseUri),[e,"stream","replay","".concat("primary",".m3u8")]);return i.searchParams.set("edgeAuthToken",t),i.searchParams.set("startTime",Or.toIsoString(n)),i.searchParams.set("endTime",Or.toIsoString(r)),i.searchParams.set("apiVersion","0"),i.searchParams.set("clientVersion",B.sdkVersion),i}},{key:"logNonManifestBody",value:function(t){var n=t.trim();if(n){var r=e.redactCredentials(n),i=r.length>512?"".concat(r.substring(0,512),"[...]"):r;this._logger.debug("Replay manifest response was not a playlist, body [%s]",i)}else this._logger.debug("Replay manifest response body was empty")}}],[{key:"mapHttpStatusToReplayStatus",value:function(e){switch(e){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 404:return"not-found";case 408:return"timeout";case 429:case 504:return"rate-limited";case 503:return"capacity";default:return"failed"}}},{key:"statusFromBody",value:function(e,t){var n,r=e.trim();if(!r)return t;try{var i=JSON.parse(r),o=null==i?void 0:i.status;if("string"==typeof(n=o)&&Rr.includes(n)&&"ok"!==o)return o}catch(e){}return t}},{key:"redactCredentials",value:function(e){return Ar.reduce(function(e,t){return e.replace(new RegExp("".concat(t,"=[^&\\s\"'<]*"),"gi"),"".concat(t,"=[redacted]")).replace(new RegExp('"'.concat(t,'"\\s*:\\s*"[^"]*"'),"gi"),'"'.concat(t,'":"[redacted]"'))},e)}}]);var n}(),Lr="replay",Dr=["streaming","on-demand"],Mr=function(){function e(){throw t()(this,e),new Error("ReplayCapabilities is a static class that may not be instantiated")}return o()(e,null,[{key:"capabilityReplay",get:function(){return Lr}},{key:"capabilitiesChunkedStreaming",get:function(){return Dr}},{key:"includesReplay",value:function(e){return e.includes(Lr)}},{key:"includesChunkedStreaming",value:function(e){return Dr.some(function(t){return e.includes(t)})}},{key:"tokenHasReplay",value:function(t){return e.includesReplay(re.parseToken(t).capabilities)}},{key:"tokenIsForChunkedStreaming",value:function(t){return e.includesChunkedStreaming(re.parseToken(t).capabilities)}}])}();function jr(){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,l=Object.create(u.prototype);return Nr(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Nr(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Nr(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Nr(d,"constructor",l),Nr(l,"constructor",u),u.displayName="GeneratorFunction",Nr(l,i,"GeneratorFunction"),Nr(d),Nr(d,i,"Generator"),Nr(d,r,function(){return this}),Nr(d,"toString",function(){return"[object Generator]"}),(jr=function(){return{w:o,m:h}})()}function Nr(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Nr=function(e,t,n,r){function o(t,n){Nr(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))},Nr(e,t,n,r)}var Vr=function(){return o()(function e(n){var r;t()(this,e),s()(this,"_logger",ee.getLogger("ReplayController")),s()(this,"_dependencies",void 0),s()(this,"_context",void 0),s()(this,"_now",void 0),s()(this,"_player",null),s()(this,"_sessionDisposables",null),s()(this,"_isDisposed",!1),s()(this,"_epoch",0),this._dependencies=n,this._context=n.context,this._now=null!==(r=n.now)&&void 0!==r?r:function(){return Date.now()}},[{key:"start",value:(r=N()(jr().m(function e(t,n){var r,i,o,a,s,u,l,c,d,h=this;return jr().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!this._isDisposed){e.n=1;break}throw new Error("ReplayController has been disposed");case 1:return this.refuseWhenBusy(),r=this.validate(t,n),i=++this._epoch,this._context.state.value=nr.Loading,this._context.error.value=null,this._context.window.value=r,this._context.autoMuted.value=!1,r.wasAdjusted&&this._logger.info("Replay window end moved back to the live-edge safety margin, from [%s] to [%s]",Or.toIsoString(r.requestedEndTime),Or.toIsoString(r.endTime)),e.p=2,e.n=3,this._dependencies.getManifest(t,r.startTime,r.endTime);case 3:o=e.v,e.n=6;break;case 4:if(e.p=4,l=e.v,i===this._epoch){e.n=5;break}return e.a(2);case 5:throw this.failWith(l),l;case 6:if(i===this._epoch){e.n=7;break}return e.a(2);case 7:if("ok"===o.status){e.n=8;break}throw this._logger.warn("Replay manifest request failed with status [%s]",o.status),a=new cr("Replay failed with status ".concat(o.status),o.status),this.failWith(a),a;case 8:if(this._context.isReplaying.value=!0,s=this._dependencies.presentation.attach(),this._context.videoElement.value=s,this._dependencies.realTime.muteForReplay(),i===this._epoch){e.n=9;break}return e.a(2);case 9:return e.p=9,e.n=10,this._dependencies.createPlayer(s);case 10:u=e.v,e.n=13;break;case 11:if(e.p=11,c=e.v,i===this._epoch){e.n=12;break}return e.a(2);case 12:throw this.failWith(c),c;case 13:if(i===this._epoch){e.n=14;break}return u.dispose(),e.a(2);case 14:return this._player=u,this._sessionDisposables=new ie,this._sessionDisposables.add(u.ended.subscribe(function(e){return h.onEnded(e)})),this._sessionDisposables.add(u.fatalError.subscribe(function(e){return h.onFatalError(e)})),e.p=15,e.n=16,u.play(o.url);case 16:if(i===this._epoch){e.n=17;break}return e.a(2);case 17:e.n=20;break;case 18:if(e.p=18,d=e.v,!(i!==this._epoch||d instanceof hr)){e.n=19;break}return e.a(2);case 19:throw this.failWith(d),d;case 20:return this._context.state.value===nr.Loading&&(this._context.state.value=nr.Playing),e.n=21,this.startPlayback(s,i);case 21:return e.a(2)}},e,this,[[15,18],[9,11],[2,4]])})),function(e,t){return r.apply(this,arguments)})},{key:"returnToRealTime",value:(n=N()(jr().m(function e(){var t,n;return jr().w(function(e){for(;;)switch(e.n){case 0:if(this.hasSession()){e.n=1;break}return e.a(2);case 1:if(t=++this._epoch,this._context.state.value=nr.ReturningToRealTime,this.teardownSession(),this._dependencies.realTime.restoreMutedState(),!this._isDisposed&&t===this._epoch){e.n=2;break}return e.a(2);case 2:n=this._dependencies.realTime.isRealTimeAvailable(),this._context.isReplaying.value=!1,this._context.window.value=null,this._context.autoMuted.value=!1,this._context.error.value=n?null:"real-time-unavailable",this._context.state.value=n?nr.Idle:nr.RealTimeUnavailable,n||this._logger.info("Replay ended but there is no real-time stream to return to");case 3:return e.a(2)}},e,this)})),function(){return n.apply(this,arguments)})},{key:"dispose",value:function(){this._isDisposed||(this._isDisposed=!0,this._epoch++,this.teardownSession(),this._dependencies.presentation.dispose(),this._context.isReplaying.value=!1)}},{key:"hasSession",value:function(){switch(this._context.state.value){case nr.Loading:case nr.Playing:case nr.Ended:return!0;default:return!1}}},{key:"refuseWhenBusy",value:function(){switch(this._context.state.value){case nr.Loading:case nr.Playing:case nr.Ended:throw new cr("A replay window is already loading or playing; call returnToRealTime() before starting another.","already-replaying");case nr.ReturningToRealTime:throw new cr("A return to real time is still in progress; wait for it to complete before requesting replay again.","already-replaying");default:return}}},{key:"validate",value:function(e,t){var n=this.parseCapabilitiesOrRefuse(e);Mr.includesChunkedStreaming(n)&&this.refuse("Replay is not supported on a chunked channel","unsupported-feature"),Mr.includesReplay(n)||this.refuse("Replay token does not include the capability [".concat(Mr.capabilityReplay,"]"),"unauthorized"),this._dependencies.isPlayerSupported()||this.refuse("Replay requires hls.js (register one with SDK.init({hlsJsLoader})) or native HLS playback support","unsupported-feature");try{return Or.resolve(t.startTime,t.duration,{nowMs:this._now()})}catch(e){var r=e instanceof lr?e.status:"invalid-window";this.refuse(e.message,r)}}},{key:"parseCapabilitiesOrRefuse",value:function(e){var t=re.parseToken(e);return t.tenancy||this.refuse("Replay token is not valid","unauthorized"),t.capabilities}},{key:"refuse",value:function(e,t){throw this._logger.warn("Replay request refused with status [%s]",t),this._context.state.value=ir.convertReplayStatusToReplayState(t),this._context.error.value=ir.convertReplayStatusToReplayError(t),new cr(e,t)}},{key:"onEnded",value:function(e){e&&this.hasSession()&&(this._context.state.value=nr.Ended,this.returnToRealTime())}},{key:"onFatalError",value:function(e){e&&this.hasSession()&&(this._logger.error("Replay session failed after playback had started",e),this.failWith(e))}},{key:"startPlayback",value:(e=N()(jr().m(function e(t,n){var r,i;return jr().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,t.play();case 1:return e.a(2);case 2:if(e.p=2,r=e.v,n===this._epoch){e.n=3;break}return e.a(2);case 3:return t.muted&&this.failPlayback(r),this._logger.debug("Replay element rejected play(); retrying muted",r),t.muted=!0,this._context.autoMuted.value=!0,e.p=4,e.n=5,t.play();case 5:e.n=8;break;case 6:if(e.p=6,i=e.v,n===this._epoch){e.n=7;break}return e.a(2);case 7:this.failPlayback(i);case 8:return e.a(2)}},e,this,[[4,6],[0,2]])})),function(t,n){return e.apply(this,arguments)})},{key:"failPlayback",value:function(e){if("NotAllowedError"!==e.name)throw this.failWith(e),e;this._logger.warn("Replay element was not allowed to play, even muted",e);var t=new dr("The browser did not allow the replay element to play","autoplay-blocked");throw this.failWith(t),t}},{key:"failWith",value:function(e){var t=e instanceof lr?e.status:"failed";this._epoch++,e instanceof lr||this._logger.error("Failed to play replay window",e),this.teardownSession(),this._dependencies.realTime.restoreMutedState(),this._context.isReplaying.value=!1,this._context.window.value=null,this._context.autoMuted.value=!1,this._context.state.value=ir.convertReplayStatusToReplayState(t),this._context.error.value=ir.convertReplayStatusToReplayError(t)}},{key:"teardownSession",value:function(){var e,t;null===(e=this._sessionDisposables)||void 0===e||e.dispose(),this._sessionDisposables=null,null===(t=this._player)||void 0===t||t.dispose(),this._player=null,this._dependencies.presentation.detach(),this._context.videoElement.value=null}}]);var e,n,r}();function Br(){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,l=Object.create(u.prototype);return Gr(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(Gr(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Gr(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,Gr(d,"constructor",l),Gr(l,"constructor",u),u.displayName="GeneratorFunction",Gr(l,i,"GeneratorFunction"),Gr(d),Gr(d,i,"Generator"),Gr(d,r,function(){return this}),Gr(d,"toString",function(){return"[object Generator]"}),(Br=function(){return{w:o,m:h}})()}function Gr(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}Gr=function(e,t,n,r){function o(t,n){Gr(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))},Gr(e,t,n,r)}var Ur=function(){return o()(function e(n,r){t()(this,e),s()(this,"_logger",ee.getLogger("ChannelReplay")),s()(this,"_context",void 0),s()(this,"_dependencies",void 0),s()(this,"_readOnlyIsSupported",void 0),s()(this,"_readOnlyIsReplaying",void 0),s()(this,"_readOnlyState",void 0),s()(this,"_readOnlyWindow",void 0),s()(this,"_readOnlyError",void 0),s()(this,"_readOnlyAutoMuted",void 0),s()(this,"_controller",null),s()(this,"_controllerVideoElement",null),s()(this,"_controllerRealTime",null),s()(this,"_isDisposed",!1),this._context=n,this._dependencies=r,this._readOnlyIsSupported=new C(n.isSupported),this._readOnlyIsReplaying=new C(n.isReplaying),this._readOnlyState=new C(n.state),this._readOnlyWindow=new C(n.window),this._readOnlyError=new C(n.error),this._readOnlyAutoMuted=new C(n.autoMuted),this.refreshSupport()},[{key:"isSupported",get:function(){return this._readOnlyIsSupported}},{key:"isReplaying",get:function(){return this._readOnlyIsReplaying}},{key:"state",get:function(){return this._readOnlyState}},{key:"window",get:function(){return this._readOnlyWindow}},{key:"error",get:function(){return this._readOnlyError}},{key:"autoMuted",get:function(){return this._readOnlyAutoMuted}},{key:"start",value:(n=N()(Br().m(function e(t){var n;return Br().w(function(e){for(;;)if(0===e.n)return this._isDisposed&&this.refuse("The channel has been disposed","unsupported-feature"),this.onVideoElementChanged(),(n=this._dependencies.getVideoElement())||this.refuse("Replay requires a video element","unsupported-feature"),e.a(2,this.getOrCreateController(n).start(this._dependencies.getToken(),t))},e,this)})),function(e){return n.apply(this,arguments)})},{key:"returnToRealTime",value:(e=N()(Br().m(function e(){var t;return Br().w(function(e){for(;;)if(0===e.n)return e.a(2,null===(t=this._controller)||void 0===t?void 0:t.returnToRealTime())},e,this)})),function(){return e.apply(this,arguments)})},{key:"refreshSupport",value:function(){this._context.isSupported.value=this.computeIsSupported()}},{key:"onVideoElementChanged",value:function(){this._controllerVideoElement!==this._dependencies.getVideoElement()&&this.reset()}},{key:"reset",value:function(){this.disposeController(),this._context.resetSession(),this.refreshSupport()}},{key:"dispose",value:function(){this._isDisposed||(this._isDisposed=!0,this.disposeController(),this._context.resetSession(),this._context.isSupported.value=!1)}},{key:"computeIsSupported",value:function(){if(this._isDisposed||!this.isPlayerSupported())return!1;try{var e=this._dependencies.getToken();return Mr.tokenHasReplay(e)&&!Mr.tokenIsForChunkedStreaming(e)}catch(e){return this._logger.debug("Unable to determine replay support from the channel token",e),!1}}},{key:"isPlayerSupported",value:function(){var e;return(null!==(e=this._dependencies.isPlayerSupported)&&void 0!==e?e:xr.isSupported)()}},{key:"getOrCreateController",value:function(e){var t,n,r=this;if(this._controller)return this._controller;var i=this._dependencies.createRealTimePresentation(e);return this._controller=new Vr({context:this._context,presentation:new Er(e),realTime:i,getManifest:null!==(t=this._dependencies.getManifest)&&void 0!==t?t:function(e,t,n){return new Ir(r._dependencies.getBaseUri(e)).getReplayManifest(e,t,n)},createPlayer:null!==(n=this._dependencies.createPlayer)&&void 0!==n?n:xr.create,isPlayerSupported:function(){return r.isPlayerSupported()},now:this._dependencies.now}),this._controllerVideoElement=e,this._controllerRealTime=i,this._controller}},{key:"disposeController",value:function(){var e,t;null===(e=this._controller)||void 0===e||e.dispose(),null===(t=this._controllerRealTime)||void 0===t||t.restoreMutedState(),this._controller=null,this._controllerVideoElement=null,this._controllerRealTime=null}},{key:"refuse",value:function(e,t){throw this._logger.warn("Replay request refused with status [%s]",t),this._context.state.value=ir.convertReplayStatusToReplayState(t),this._context.error.value=ir.convertReplayStatusToReplayError(t),new cr(e,t)}}]);var e,n}(),zr=function(){function e(n,r){t()(this,e),s()(this,"_videoElement",void 0),s()(this,"_dependencies",void 0),s()(this,"_isMutedForReplay",!1),s()(this,"_mutedBeforeReplay",!1),this._videoElement=n,this._dependencies=r}return o()(e,[{key:"muteForReplay",value:function(){this._isMutedForReplay||(this._isMutedForReplay=!0,this._mutedBeforeReplay=this._videoElement.muted,this._videoElement.muted=!0)}},{key:"restoreMutedState",value:function(){this._isMutedForReplay&&(this._isMutedForReplay=!1,this._videoElement.muted=this._mutedBeforeReplay)}},{key:"isRealTimeAvailable",value:function(){return!e.isGone(this._dependencies.getMediaStream())}}],[{key:"isGone",value:function(e){if(!e)return!0;try{var t=e.getTracks();return t.length>0&&t.every(function(e){return"live"!==e.readyState})}catch(e){return!1}}}])}(),Hr=n(981).A;function Wr(){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,l=Object.create(u.prototype);return qr(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(qr(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,qr(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,qr(d,"constructor",l),qr(l,"constructor",u),u.displayName="GeneratorFunction",qr(l,i,"GeneratorFunction"),qr(d),qr(d,i,"Generator"),qr(d,r,function(){return this}),qr(d,"toString",function(){return"[object Generator]"}),(Wr=function(){return{w:o,m:h}})()}function qr(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}qr=function(e,t,n,r){function o(t,n){qr(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))},qr(e,t,n,r)}var Jr=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,"_replayContext",void 0),s()(this,"_replay",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,"_readOnlyAudioTracks",void 0),s()(this,"_readOnlySelectedAudioTrack",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),s()(this,"_mutedAfterReplay",null);var a=re.parseToken(r),u={maxAudioTracks:null==i?void 0:i.maxAudioTracks,audioLanguages:null==i?void 0:i.audioLanguages,targetLag:null==i?void 0:i.targetLag,onRealTimeSubscribeRequestCallback:null==i?void 0:i.onRealTimeSubscribeRequestCallback,onRealTimeSubscribeResponseCallback:null==i?void 0:i.onRealTimeSubscribeResponseCallback},l={forceGarbageCollectionOnRestart:Be.forceGarbageCollectionOnRestart},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 Xe(r),this._channelContext=new tt(u),this._peerConnectionContext=new at(l),this._streamTransformContext=new it(c),this._stateContext=new st,this._exponentialBackoff=new Re,this._replayContext=new rr,this._channelStartTime=Date.now(),this._replay=new Ur(this._replayContext,{getVideoElement:function(){return o._channelContext.videoElement.value},getToken:function(){return o.token},getBaseUri:function(e){return o.getUri(e).toString()},createRealTimePresentation:function(e){return new zr(e,{getMediaStream:function(){return o._peerConnectionContext.mediaStream.value}})}}),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._readOnlyAudioTracks=new C(this._channelContext.audioTracks),this._readOnlySelectedAudioTrack=new C(this._channelContext.selectedAudioTrack),this._readOnlyMediaStream=new C(this._peerConnectionContext.mediaStream);var d=(a.uri||Be.discoveryUri.value).toString();Be.tenancy.value=a.tenancy||Be.tenancy.value,Te.uri.value=d,this._metricsService=Ne.getMetricsService(d),this._sessionTelemetry=new Ze(Be.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._channelContext.channelDisposables.add(this._replayContext.isReplaying.subscribe(function(e){e||o.applyMutedIntentAfterReplay()})),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=n,this._frameTimingInformationContext=new ut,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=Be.clientSessionId,o.videoElement.dataset.streamId=o.streamId),o._channelContext.videoTelemetry=new qe(o.streamId,Be.pageLoadTime,o._channelStartTime,o._metricsService),o._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(o.videoElement),o._channelContext.videoTelemetry.setupListenerForRebuffering(o.videoElement),o._channelContext.state.value===ze.Stopped)&&o.restartAfterStop()})),o._channelContext.channelDisposables.add(o._channelContext.rendererDisposables))})),this._channelContext.channelDisposables.add(this._channelContext.state.subscribe(function(e){o._channelContext.clearFailureCountTimeout&&E.value.clearTimeout(o._channelContext.clearFailureCountTimeout),o._channelContext.failureCount.value&&e===ze.Playing&&(o._channelContext.clearFailureCountTimeout=E.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,Ye.Normal).catch(function(e){o._logger.error("Error while setting limit bitrate",e)})}})),this._channelContext.channelDisposables.add(this._replayContext.isReplaying.subscribe(function(e){e||o.reevaluateRealTimeHealthAfterReplay()}));var h=function(){o._channelContext.stream.value&&o._channelContext.endPoint.value&&o._channelContext.endPoint.value.destroyStreamOnUnmount(o._channelContext.stream.value,"client:termination-on-window-unload")};E.value.addWindowEventListener("beforeunload",h),this._channelContext.channelDisposables.add(new m(function(){E.value.removeWindowEventListener("beforeunload",h)})),this.start(),Be.automaticRetryOnFailure&&this._channelContext.channelDisposables.add(Be.applicationActivityMonitor.isForeground.subscribe(function(e){if(e){var t=Be.applicationActivityMonitor.getLastBackgroundDuration(),n=O.isMobile&&null!==t&&t>5e3,r=o._channelContext.state.value===ze.Reconnecting&&null!==t&&t>3e4;if(n||r)return o._logger.info("[%s] Foregrounded after [%s] ms in background, trying restart",o._channelContext.streamId,t),void o.tryRestart("client:foregrounded:background-timeout");o.isRetryableState()?o.tryRestart("client:foregrounded:unhealthy"):o._streamSubscriber&&o.isSubscriberHealthy().then(function(e){e||o._channelContext.state.value===ze.Playing&&o.tryRestart("client:foregrounded:unhealthy-health-check")}).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!==ze.Initializing&&(this._channelContext.state.value=ze.Stopped),this._channelContext.videoElement.value=e,this._replay.onVideoElementChanged(),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||Be.discoveryUri.value).toString();Be.tenancy.value=t.tenancy||Be.tenancy.value,Te.uri.value=n,this._metricsService=Ne.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._replay.refreshSupport(),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:"audioTracks",get:function(){return this._readOnlyAudioTracks}},{key:"selectedAudioTrack",get:function(){return this._readOnlySelectedAudioTrack}},{key:"selectAudioTrack",value:function(e){var t,n,r=this._channelContext.findAudioSection(e);if(!r)throw new Error("Audio track [".concat(e,"] is not delivered"));this._channelContext.requestedAudioTrack={id:e,language:r.language},this._channelContext.setSelectedAudioSection(r),this._channelContext.rtcAudioStatistic=null,this.applyAudioTrackSelection(),null===(t=this._streamSubscriber)||void 0===t||null===(n=t.applyAudioTrackSelection)||void 0===n||n.call(t)}},{key:"applyAudioTrackSelection",value:function(){var e=this,t=this._peerConnectionContext.peerConnection.value,n=this._channelContext.selectedAudioMid.value,r=this._peerConnectionContext.mediaStream.value;if(null!=t&&t.supportsGetTransceivers&&n&&r){var i,o=$e.applyToMediaStream(t.getTransceivers(),n,r,this._peerConnectionContext.renderedTracks),a=this._channelContext.videoElement.value;o&&a&&a.srcObject===r&&(a.srcObject=null,a.srcObject=r,null===(i=a.play())||void 0===i||i.catch(function(t){e._logger.warn("[%s] Failed to resume playback after switching audio track",e._channelContext.streamId,t)}))}}},{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:"replay",get:function(){return this._replay}},{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,Ye.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:(h=N()(Wr().m(function e(t){var n=this;return Wr().w(function(e){for(;;)if(0===e.n)return e.a(2,new Hr(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 h.apply(this,arguments)})},{key:"processStop",value:function(e){this._replay.reset(),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=ze.Stopped}},{key:"resume",value:(d=N()(Wr().m(function e(){return Wr().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 d.apply(this,arguments)})},{key:"mute",value:function(){var e=this._replayContext.videoElement.value;if(e)return e.muted=!0,void(this._mutedAfterReplay=!0);var t=this._channelContext.videoElement.value;t&&(t.muted=!0)}},{key:"unmute",value:function(){var e=this._replayContext.videoElement.value;if(e)return e.muted=!1,void(this._mutedAfterReplay=!1);var t=this._channelContext.videoElement.value;t&&(t.muted=!1,this._channelContext.autoMuted.value=!1)}},{key:"applyMutedIntentAfterReplay",value:function(){if(null!==this._mutedAfterReplay){var e=this._mutedAfterReplay,t=this._channelContext.videoElement.value;this._mutedAfterReplay=null,t&&(t.muted=e,e||(this._channelContext.autoMuted.value=!1))}}},{key:"dispose",value:(c=N()(Wr().m(function e(){var t=this;return Wr().w(function(e){for(;;)if(0===e.n)return e.a(2,this.stop("client:channel-dispose").then(function(){t._replay.dispose(),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]",Be.discoveryUri.value),new E.value.URL(Be.discoveryUri.value))}},{key:"start",value:(l=N()(Wr().m(function e(){return Wr().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 l.apply(this,arguments)})},{key:"isTerminalState",value:function(){switch(this._channelContext.state.value){case ze.Stopped:case ze.Unauthorized:case ze.GeoRestricted:case ze.GeoBlocked:case ze.UnsupportedFeature:case ze.ConfigurationError:return!0;case ze.Initializing:case ze.Offline:case ze.Starting:case ze.Paused:case ze.Playing:case ze.Recovering:case ze.Reconnecting:case ze.StandBy:case ze.TransientConfigurationError:case ze.ConnectionError:case ze.ClientStartError:case ze.Error:return!1;default:J(this._channelContext.state.value)}}},{key:"isRetryableState",value:function(){switch(this._channelContext.state.value){case ze.Error:case ze.Reconnecting:case ze.StandBy:case ze.Offline:case ze.Recovering:case ze.TransientConfigurationError:case ze.ConnectionError:case ze.ClientStartError:return!0;case ze.Unauthorized:case ze.GeoRestricted:case ze.GeoBlocked:case ze.Stopped:case ze.Paused:case ze.Initializing:case ze.Starting:case ze.Playing:case ze.UnsupportedFeature:case ze.ConfigurationError:return!1;default:J(this._channelContext.state.value)}}},{key:"isSubscriberHealthy",value:function(){return this._streamSubscriber?this._replayContext.isReplaying.value?Hr.resolve(!0):this._streamSubscriber.isStreamHealthy():Hr.resolve(!1)}},{key:"tryRestart",value:function(e){this._replayContext.isReplaying.value?this._logger.debug("[%s] Skipping failureCount reset and Channel restart while replay is active [%s]",this._channelContext.streamId,e):this._stateContext.isStarting.value?this._logger.debug("[%s] Skipping failureCount reset and Channel restart due to Channel already starting [%s]",this._channelContext.streamId,e):this.isTerminalState()?this._logger.debug("[%s] Skipping failureCount reset and Channel restart due to terminal ChannelState [%s] [%s]",this._channelContext.streamId,ze[this._channelContext.state.value],e):(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())}},{key:"reevaluateRealTimeHealthAfterReplay",value:(u=N()(Wr().m(function e(){var t;return Wr().w(function(e){for(;;)switch(e.p=e.n){case 0:if(Be.automaticRetryOnFailure&&this._streamSubscriber&&!this._stateContext.isDisposed&&this._channelContext.state.value===ze.Playing){e.n=1;break}return e.a(2);case 1:return e.p=1,e.n=2,this.isSubscriberHealthy();case 2:if(!(e.v||this._replayContext.isReplaying.value||this._stateContext.isDisposed)){e.n=3;break}return e.a(2);case 3:this._logger.info("[%s] Real-time stream is unhealthy after a replay session; restarting the channel",this._channelContext.streamId),this.tryRestart("client:replay-ended:unhealthy"),e.n=5;break;case 4:e.p=4,t=e.v,this._logger.error("[%s] Failed to re-evaluate real-time health after a replay session",this._channelContext.streamId,t);case 5:return e.a(2)}},e,this,[[1,4]])})),function(){return u.apply(this,arguments)})},{key:"processStart",value:(a=N()(Wr().m(function e(){var t,n,r,i,o,a,s,u,l,c,d,h,f,p,v,g,y,_,b,C=this;return Wr().w(function(e){for(;;)switch(e.n){case 0:if(t=this._channelContext.state.value!==ze.Initializing,this._channelContext.state.value=t?ze.Recovering:ze.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=ze.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=rt.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=ze.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=rt.validateMediaStreamTrackTransform("audio",this._streamTransformContext.audioStreamTransformCallback),u=s.valid,l=s.validationResult,u){e.n=3;break}return this._logger.error(l),this._channelContext.state.value=ze.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(c=nt.validateEncodedStreamSink("video",this._streamTransformContext.encodedVideoStreamSink),d=c.valid,h=c.validationResult,d){e.n=4;break}return this._logger.error(h),this._channelContext.state.value=ze.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=nt.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=ze.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=ze.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=ze.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=ze.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=ze.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=ze.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=ze.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=ze.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=ze.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!==ze.Error&&e!==ze.Recovering||Ft.clearCachedClosestEndpoint(_)})),b=function(){return new Hr(function(e){if(!C.isRetryableState())return C._logger.debug("[%s] Ignoring stream failure callback due to ChannelState being [%s]",C._channelContext.streamId,ze[C._channelContext.state.value]),e();if(C._stateContext.isStarting.value=!1,C._channelContext.state.value=ze.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,!Be.applicationActivityMonitor.isForeground.value){C._logger.debug("[%s] Deferring stream failure handling to foreground recovery",C._channelContext.streamId);var t=E.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(){E.value.clearTimeout(t)})),e()}return e(C.handleStreamFailure())})},this._streamSubscriber=er.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.disposables.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=ze.ClientStartError,C._logger.error("Failed to start channel",e)}).finally(function(){if(C._stateContext.isStarting.value=!1,C._channelContext.state.value!==ze.Playing&&C._channelContext.state.value!==ze.Paused&&C._channelContext.state.value!==ze.Stopped&&Be.automaticRetryOnFailure){var e=E.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(){E.value.clearTimeout(e)}))}}))}},e,this)})),function(){return a.apply(this,arguments)})},{key:"restartAfterStop",value:(i=N()(Wr().m(function e(){return Wr().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=N()(Wr().m(function e(){var t;return Wr().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 ze.Initializing:case ze.StandBy:case ze.Offline:return 15e3;case ze.Error:case ze.Recovering:case ze.Unauthorized:case ze.GeoRestricted:case ze.GeoBlocked:case ze.Stopped:case ze.Starting:case ze.Playing:case ze.Paused:case ze.Reconnecting:case ze.UnsupportedFeature:case ze.ConfigurationError:case ze.TransientConfigurationError:case ze.ConnectionError:case ze.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._channelContext.failureCount.value);default:J(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(n=N()(Wr().m(function e(){var t;return Wr().w(function(e){for(;;)switch(e.n){case 0:t=this._channelContext.state.value,e.n=t===ze.Error||t===ze.Reconnecting||t===ze.StandBy||t===ze.Offline||t===ze.Recovering||t===ze.TransientConfigurationError||t===ze.ConnectionError||t===ze.ClientStartError?1:t===ze.Unauthorized?2:t===ze.GeoRestricted?3:t===ze.GeoBlocked?4:t===ze.Stopped?5:t===ze.Initializing?6:t===ze.Playing?7:t===ze.Paused?8:t===ze.Starting?9:t===ze.UnsupportedFeature?10:t===ze.ConfigurationError?11:12;break;case 1:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,ze[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:J(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.setAudioSections([]),this._channelContext.setSelectedAudioSection(null),this._channelContext.disposables.dispose(),this._peerConnectionContext.disposePeerConnection(),this._peerConnectionContext.disposeMediaStream(),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=N()(Wr().m(function e(t){var n,r,i=this;return Wr().w(function(e){for(;;)switch(e.n){case 0:if(this.applyAudioTrackSelection(),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=ze.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=ze.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=ze.Playing}).catch(function(e){var r=!!t.getTracks().filter(function(e){return"audio"===e.kind}).length,o=!Be.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=ze.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=ze.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=ze.Paused}))}))}},e,this)})),function(t){return e.apply(this,arguments)})}]);var e,n,r,i,a,u,l,c,d,h}(),Kr=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(!Be.initialized.value)throw new Error("SDK is not loaded.");var t={maxAudioTracks:e.maxAudioTracks,audioLanguages:e.audioLanguages,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 Jr(e.videoElement,e.token,t)}},{key:"isFrameTimingInformationSupported",get:function(){return O.isChannelFrameTimingInformationSupported}}])}(),Zr=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}(Zr||{}),$r=Zr,Qr=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($r.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 $r.Starting;case"not-found":return $r.NotFound;case"geo-restricted":return $r.GeoRestricted;case"geo-blocked":return $r.GeoBlocked;case"unauthorized":return $r.Unauthorized;case"capacity":case"rate-limited":case"timeout":return $r.Recovering;case"missing-channel-or-room-id":case"forbidden-tag":return $r.ConfigurationError;case"port-in-range-not-found":return $r.TransientConfigurationError;case"failed":return $r.Error;default:J(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)}}])}(),Yr=n(981).A;function Xr(){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,l=Object.create(u.prototype);return ei(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(ei(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,ei(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,ei(d,"constructor",l),ei(l,"constructor",u),u.displayName="GeneratorFunction",ei(l,i,"GeneratorFunction"),ei(d),ei(d,i,"Generator"),ei(d,r,function(){return this}),ei(d,"toString",function(){return"[object Generator]"}),(Xr=function(){return{w:o,m:h}})()}function ei(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}ei=function(e,t,n,r){function o(t,n){ei(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))},ei(e,t,n,r)}var ti=function(){return o()(function e(n,r,i){var o,a,u,l,c=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!==(l=u.currentRemoteDescription)&&void 0!==l&&l.sdp){var d=new ln(this._peerConnection.currentLocalDescription.sdp),h=new ln(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&&c._isMonitorRunning&&(c._monitorGeneration++,E.value.clearTimeout(c._updateTimeout),c._logger.debug("Restarting stats polling after foreground transition"),c.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(),E.value.clearTimeout(this._updateTimeout),this._updateTimeout=void 0}},{key:"updateStatistic",value:(e=N()(Xr().m(function e(){var t,n,r,i,o,a,s,u,l,c,d,h=this;return Xr().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 Yr(function(e){r=E.value.setTimeout(function(){return e(void 0)},5e3)}),e.n=4,Yr.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={},l=this._estimatedRoundTripTime,s.forEach(function(e){if("candidate-pair"===e.type&&e.currentRoundTripTime&&(l=1e3*e.currentRoundTripTime,u.audio&&(u.audio.roundTripTime=l),u.video&&(u.video.roundTripTime=l)),"candidate-pair"===e.type&&e.lastPacketSentTimestamp&&(c=e.lastPacketSentTimestamp,u.audio&&(u.audio.lastPacketSentTimestamp=c),u.video&&(u.video.lastPacketSentTimestamp=c)),"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:l},(e.lastPacketSentTimestamp||c)&&(u[r].lastPacketSentTimestamp=e.lastPacketSentTimestamp||c),"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,E.value.clearTimeout(r),e.f(8);case 9:this._isMonitorRunning&&t===this._monitorGeneration&&(this._updateTimeout=E.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}(),ni=n(981).A;function ri(){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,l=Object.create(u.prototype);return ii(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(ii(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,ii(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,ii(d,"constructor",l),ii(l,"constructor",u),u.displayName="GeneratorFunction",ii(l,i,"GeneratorFunction"),ii(d),ii(d,i,"Generator"),ii(d,r,function(){return this}),ii(d,"toString",function(){return"[object Generator]"}),(ri=function(){return{w:o,m:h}})()}function ii(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}ii=function(e,t,n,r){function o(t,n){ii(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))},ii(e,t,n,r)}function oi(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 ai(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?oi(Object(n),!0).forEach(function(t){s()(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):oi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var si=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(!E.value.navigatorIsOnLine)return this._publisherContext.state.value=$r.Offline,ni.resolve();var i=this._peerConnectionContext.mediaStream.value;if(!i)return this._logger.error("Publish failed no media stream provided"),this._publisherContext.state.value=$r.ConfigurationError,ni.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 ni.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=sn()(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?(r._peerConnectionContext.disposePeerConnection(),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,l=!1,c=[];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||Be.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?c.push(n.candidate):l=!0,t||(t=E.value.setTimeout(function(){var t;r._publisherContext.stream.value!==i||o||null===(t=r._publisherContext.endPoint.value)||void 0===t||t.addIceCandidates(i,c,l).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=$r.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=$r.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:J(e.iceConnectionState)}}},new ni(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!==$r.Starting)return ni.resolve();r._publisherContext.state.value=$r.Publishing,r._publisherContext.publishing.value=!0;var i=new ti(e,null!==(t=r._publisherContext.endPoint.value)&&void 0!==t&&t.roundTripTime?r._publisherContext.endPoint.value.roundTripTime/4:0,Be.applicationActivityMonitor.isForeground);return r._publisherContext.disposables.add(i),i.rtcStatistic.subscribe(function(e){r._publisherContext.rtcStatistics.value=e}),ni.resolve()})})})}},{key:"applyRtcConfiguration",value:(e=N()(ri().m(function e(t,n){var r;return ri().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return n=cn.truncateIceServers(n),e.a(2,Be.peerConnectionFactory.value.createPeerConnection(n));case 1:return r=ai(ai({},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=$r.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Be.maximalNumberOfPeerConnectionReconnectAttempts||!Be.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=E.value.setTimeout(function(){n.reconnectPeerConnection(e,t)},1e3);return void this._publisherContext.disposables.add(new m(function(){return E.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=E.value.setTimeout(function(){n.reconnectPeerConnection(e,t)},1e3);n._publisherContext.disposables.add(new m(function(){return E.value.clearTimeout(r)}))}else n._publisherContext.state.value=$r.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 $r.Starting;case"unauthorized":return $r.Unauthorized;case"not-found":return $r.NotFound;case"capacity":case"rate-limited":case"timeout":return $r.Recovering;case"failed":return $r.Error;default:J(e)}}},{key:"mapAddIceCandidatesStatusToPublisherStatus",value:function(e){switch(e){case"ok":return this._publisherContext.state.value;case"unauthorized":return $r.Unauthorized;case"not-found":return $r.NotFound;case"capacity":case"rate-limited":case"timeout":return $r.Recovering;case"failed":return $r.Error;default:J(e)}}}]);var e}(),ui=n(981).A;function li(){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,l=Object.create(u.prototype);return ci(l,"_invoke",function(n,r,i){var o,s,u,l=0,c=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&&l&&!i&&t<c.length;t++){var i,o=c[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,c,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&f(c,p),s=c,u=p;(t=s<2?e:u)||!d;){o||(s?(s>1&&(h.n=s<3?-1:u),f(s,u)):h.v=u);try{if(l=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{l=1}}return{value:t,done:d}}}(n,i,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][r]?t(t([][r]())):(ci(t={},r,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function h(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,ci(e,i,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,ci(d,"constructor",l),ci(l,"constructor",u),u.displayName="GeneratorFunction",ci(l,i,"GeneratorFunction"),ci(d),ci(d,i,"Generator"),ci(d,r,function(){return this}),ci(d,"toString",function(){return"[object Generator]"}),(li=function(){return{w:o,m:h}})()}function ci(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}ci=function(e,t,n,r){function o(t,n){ci(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))},ci(e,t,n,r)}var di=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);var a={forceGarbageCollectionOnRestart:Be.forceGarbageCollectionOnRestart};this._tokenContext=new Xe(r),this._publisherContext=new Qr(i),this._peerConnectionContext=new at(a),this._stateContext=new st,this._exponentialBackoff=new Re,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 u=re.parseToken(this._tokenContext.token.value),l=(u.uri||Be.discoveryUri.value).toString();Be.tenancy.value=u.tenancy||Be.tenancy.value,Te.uri.value=l,this._metricsService=Ne.getMetricsService(l),this._sessionTelemetry=new Ze(Be.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe(function(e){o._publisherContext.clearFailureCountTimeout&&E.value.clearTimeout(o._publisherContext.clearFailureCountTimeout),o._publisherContext.failureCount.value&&e===$r.Publishing&&(o._publisherContext.clearFailureCountTimeout=E.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")};E.value.addWindowEventListener("beforeunload",c),this._publisherContext.publisherDisposables.add(new m(function(){E.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||Be.discoveryUri.value).toString();Be.tenancy.value=t.tenancy||Be.tenancy.value,Te.uri.value=n,this._metricsService=Ne.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=N()(li().m(function e(t){var n=this;return li().w(function(e){for(;;)if(0===e.n)return e.a(2,new ui(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=$r.Stopped}},{key:"dispose",value:(i=N()(li().m(function e(){var t=this;return li().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]",Be.discoveryUri.value),new E.value.URL(Be.discoveryUri.value))}},{key:"start",value:(r=N()(li().m(function e(){return li().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=N()(li().m(function e(){var t,n,r,i,o,a=this;return li().w(function(e){for(;;)switch(e.n){case 0:if(this._publisherContext.state.value=$r.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=$r.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!==$r.Error&&e!==$r.Recovering||Ft.clearCachedClosestEndpoint(r)})),i=function(){return new ui(function(e){return a._stateContext.isStarting.value=!1,e(a.handleStreamFailure())})},o=new si(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=$r.ClientStartError,a._logger.error("Failed to start publishing",e)}).finally(function(){if(a._stateContext.isStarting.value=!1,a._publisherContext.state.value!==$r.Publishing&&Be.automaticRetryOnFailure){var e=E.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(){E.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 $r.Offline:return 15e3;case $r.Initializing:case $r.NotFound:case $r.Error:case $r.Recovering:case $r.Unauthorized:case $r.GeoRestricted:case $r.GeoBlocked:case $r.Stopped:case $r.Starting:case $r.Publishing:case $r.Reconnecting:case $r.UnsupportedFeature:case $r.ConfigurationError:case $r.TransientConfigurationError:case $r.ConnectionError:case $r.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._publisherContext.failureCount.value);default:J(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:(e=N()(li().m(function e(){var t;return li().w(function(e){for(;;)switch(e.n){case 0:t=this._publisherContext.state.value,e.n=t===$r.Error||t===$r.Reconnecting||t===$r.Offline||t===$r.Recovering||t===$r.TransientConfigurationError||t===$r.ConnectionError||t===$r.ClientStartError?1:t===$r.Unauthorized?3:t===$r.GeoRestricted?4:t===$r.GeoBlocked?5:t===$r.Stopped?6:t===$r.Publishing?7:t===$r.Initializing?8:t===$r.Starting?9:t===$r.UnsupportedFeature?10:t===$r.NotFound?11:t===$r.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,$r[this._publisherContext.state.value]),e.a(2);case 2:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,$r[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:J(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(),this._peerConnectionContext.disposePeerConnection(),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}(),hi=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(!Be.initialized.value)throw new Error("SDK is not loaded.");return new di(e.mediaStream,e.token,e.name)}}])}(),fi={SDK:Be,Channels:Kr,ChannelState:ze,ReplayState:nr,Publishers:hi,PublisherState:$r}})(),r})());
3
3
  //# sourceMappingURL=full.js.map