@phenixrts/sdk 2024.2.8-beta.366 → 2024.2.8-beta.367

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.
@@ -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={787:(e,t,n)=>{"use strict";var i,r=n(383),o=n.n(r),a=n(579),s=n.n(a),u=n(693),c=n.n(u),l=function(){function e(){o()(this,e),c()(this,"_document",void 0),c()(this,"_location",void 0),c()(this,"_navigator",void 0),c()(this,"_window",void 0),this._document=document,this._location=location,this._navigator=navigator,this._window=window}return s()(e,[{key:"FormData",get:function(){return this._window.FormData}},{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:"queueMicrotask",get:function(){return this._window.queueMicrotask.bind(this._window)}},{key:"removeDocumentEventListener",get:function(){return this._document.removeEventListener.bind(this._document)}},{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:"getInstance",value:function(){return e._instance}}])}();i=l,c()(l,"_instance",new i),t.A=l.getInstance()},701:(e,t,n)=>{"use strict";n.d(t,{A:()=>f});var i=n(738),r=n.n(i),o=n(383),a=n.n(o),s=n(579),u=n.n(s),c=n(693),l=n.n(c),d=n(787),h=u()((function e(t,n,i){a()(this,e),l()(this,"onFulfilled",void 0),l()(this,"onRejected",void 0),l()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.promise=i})),p=function(){function e(t){if(a()(this,e),l()(this,"_state",void 0),l()(this,"_handled",void 0),l()(this,"_value",void 0),l()(this,"_deferreds",void 0),!(this instanceof e))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,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"===r()(t)||"function"==typeof t)){var i=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof i)return void n.doResolve((function(){i.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,i=this._deferreds.length;n<i;n++)this.handle(this._deferreds[n]);this._deferreds=null}},{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 i;try{i=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(i)}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 i=Array.prototype.slice.call(t);if(0===i.length)return e([]);for(var o=i.length,a=function(t,s){try{if(s&&("object"===r()(s)||"function"==typeof s)){var u=s.then;if("function"==typeof u)return void u.call(s,(function(e){return a(t,e)}),n)}i[t]=s,0==--o&&e(i)}catch(e){n(e)}},s=0;s<i.length;s++)a(s,i[s])}))}},{key:"resolve",value:function(t){return t&&"object"===r()(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,i){if(!Array.isArray(t))return i(new TypeError("Promise.race accepts an array"));for(var r=0,o=t.length;r<o;r++)e.resolve(t[r]).then(n,i)}))}},{key:"_immediate",value:function(e){d.A.setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}])}();p.prototype.catch=function(e){return this.then(null,e)},p.prototype.then=function(e,t){var n=new this.constructor((function(){return null}));return this.handle(new h(e,t,n)),n},p.prototype.finally=function(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){return t.reject(n)}))}))};var f=p},79:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i},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 i=n(79);e.exports=function(e){if(Array.isArray(e))return i(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 i=n(701).A;function r(e,t,n,r,o,a,s){try{var u=e[a](s),c=u.value}catch(e){return void n(e)}u.done?t(c):i.resolve(c).then(r,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new i((function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,u,"next",e)}function u(e){r(a,i,o,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,n)=>{var i=n(736);function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,i(r.key),r)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,t,n)=>{var i=n(736);e.exports=function(e,t,n){return(t=i(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 i=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&&i(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},291:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},156:e=>{e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(i=o.call(n)).done)&&(s.push(i.value),s.length!==t);u=!0);}catch(e){c=!0,r=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw r}}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},452:(e,t,n)=>{var i=n(738).default,r=n(475);e.exports=function(e,t){if(t&&("object"==i(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},633:(e,t,n)=>{var i=n(701).A,r=n(738).default;function o(){"use strict";e.exports=o=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},a=Object.prototype,s=a.hasOwnProperty,u=Object.defineProperty||function(e,t,n){e[t]=n.value},c="function"==typeof Symbol?Symbol:{},l=c.iterator||"@@iterator",d=c.asyncIterator||"@@asyncIterator",h=c.toStringTag||"@@toStringTag";function p(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(t){p=function(e,t,n){return e[t]=n}}function f(e,t,n,i){var r=t&&t.prototype instanceof C?t:C,o=Object.create(r.prototype),a=new O(i||[]);return u(o,"_invoke",{value:R(e,n,a)}),o}function m(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=f;var v="suspendedStart",g="suspendedYield",_="executing",y="completed",b={};function C(){}function k(){}function S(){}var x={};p(x,l,(function(){return this}));var w=Object.getPrototypeOf,T=w&&w(w(A([])));T&&T!==a&&s.call(T,l)&&(x=T);var P=S.prototype=C.prototype=Object.create(x);function E(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function F(e,t){function n(i,o,a,u){var c=m(e[i],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==r(d)&&s.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,a,u)}),(function(e){n("throw",e,a,u)})):t.resolve(d).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,u)}))}u(c.arg)}var i;u(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}})}function R(e,n,i){var r=v;return function(o,a){if(r===_)throw Error("Generator is already running");if(r===y){if("throw"===o)throw a;return{value:t,done:!0}}for(i.method=o,i.arg=a;;){var s=i.delegate;if(s){var u=I(s,i);if(u){if(u===b)continue;return u}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===v)throw r=y,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=_;var c=m(e,n,i);if("normal"===c.type){if(r=i.done?y:g,c.arg===b)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(r=y,i.method="throw",i.arg=c.arg)}}}function I(e,n){var i=n.method,r=e.iterator[i];if(r===t)return n.delegate=null,"throw"===i&&e.iterator.return&&(n.method="return",n.arg=t,I(e,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),b;var o=m(r,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,b;var a=o.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function A(e){if(e||""===e){var n=e[l];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(s.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(r(e)+" is not iterable")}return k.prototype=S,u(P,"constructor",{value:S,configurable:!0}),u(S,"constructor",{value:k,configurable:!0}),k.displayName=p(S,h,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===k||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,p(e,h,"GeneratorFunction")),e.prototype=Object.create(P),e},n.awrap=function(e){return{__await:e}},E(F.prototype),p(F.prototype,d,(function(){return this})),n.AsyncIterator=F,n.async=function(e,t,r,o,a){void 0===a&&(a=i);var s=new F(f(e,t,r,o),a);return n.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},E(P),p(P,h,"Generator"),p(P,l,(function(){return this})),p(P,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),n=[];for(var i in t)n.push(i);return n.reverse(),function e(){for(;n.length;){var i=n.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},n.values=A,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var n in this)"t"===n.charAt(0)&&s.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function i(i,r){return a.type="throw",a.arg=e,n.next=i,r&&(n.method="next",n.arg=t),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var u=s.call(o,"catchLoc"),c=s.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&s.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var r=i;break}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var o=r?r.completion:{};return o.type=e,o.arg=t,r?(this.method="next",this.next=r.finallyLoc,b):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var r=i.arg;L(n)}return r}}throw Error("illegal catch attempt")},delegateYield:function(e,n,i){return this.delegate={iterator:A(e),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=t),b}},n}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},636:e=>{function t(n,i){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,i)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},715:(e,t,n)=>{var i=n(987),r=n(156),o=n(122),a=n(752);e.exports=function(e,t){return i(e)||r(e,t)||o(e,t)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},132:(e,t,n)=>{var i=n(901),r=n(291),o=n(122),a=n(869);e.exports=function(e){return i(e)||r(e)||o(e)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,t,n)=>{var i=n(738).default;e.exports=function(e,t){if("object"!=i(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=i(r))return r;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 i=n(738).default,r=n(45);e.exports=function(e){var t=r(e,"string");return"symbol"==i(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 i=n(79);e.exports=function(e,t){if(e){if("string"==typeof e)return i(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)?i(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},756:(e,t,n)=>{var i=n(633)();e.exports=i;try{regeneratorRuntime=i}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var o=t[i]={exports:{}};return e[i](o,o.exports,n),o.exports}n.m=e,n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.u=e=>e+".js",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})},n.p="",n.b=document.baseURI||self.location.href;var i={};return(()=>{"use strict";n.r(i),n.d(i,{ChannelState:()=>Se,Channels:()=>Mt,PublisherState:()=>Vt,Publishers:()=>Jt,SDK:()=>ye,default:()=>Kt});var e,t,r,o=n(383),a=n.n(o),s=n(579),u=n.n(s),c=n(693),l=n.n(c),d=n(787),h=function(){function e(){a()(this,e)}return u()(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""}}])}();e=h,l()(h,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),l()(h,"_browserNameAndVersion",e.parseBrowserNameAndVersion()),l()(h,"_browserName",e.parseBrowserName()),l()(h,"_browserMajorVersion",e.parseBrowserMajorVersion()),l()(h,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(t=navigator)||void 0===t?void 0:t.userAgent)),l()(h,"_isAndroid",/Android/i.test(null===(r=navigator)||void 0===r?void 0:r.userAgent)),l()(h,"_isChrome69",e._browserNameAndVersion.includes("Chrome/69.")),l()(h,"_isChrome70",e._browserNameAndVersion.includes("Chrome/70.")),l()(h,"_isChrome71",e._browserNameAndVersion.includes("Chrome/71.")),l()(h,"_isChrome72",e._browserNameAndVersion.includes("Chrome/72.")),l()(h,"_isChrome74",e._browserNameAndVersion.includes("Chrome/74.")),l()(h,"_isChrome75",e._browserNameAndVersion.includes("Chrome/75.")),l()(h,"_isChrome76",e._browserNameAndVersion.includes("Chrome/76.")),l()(h,"_isChrome77",e._browserNameAndVersion.includes("Chrome/77."));var p=function(){function e(){a()(this,e)}return u()(e,null,[{key:"clientOfferDisabled",get:function(){return h.isChrome74||h.isChrome75||h.isChrome76||h.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return h.isChrome69||h.isChrome70||h.isChrome71||h.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=69||"Firefox"===h.browserName&&h.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=63||"Firefox"===h.browserName&&h.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===h.browserName&&h.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===h.browserName||"SamsungBrowser"===h.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==h.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){return"Chrome"===h.browserName&&"function"==typeof d.A.documentCreateElement}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion>=71||"Firefox"===h.browserName&&h.browserMajorVersion>=69||"Safari"===h.browserName}},{key:"isMobile",get:function(){return h.isMobile()}},{key:"isInsertableStreamsSupported",get:function(){return!("undefined"==typeof MediaStreamTrackProcessor||"undefined"==typeof MediaStreamTrackGenerator)}},{key:"isEncodedInsertableStreamsSupported",get:function(){return"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams}},{key:"isRTCRtpScriptTransformSupported",get:function(){return"undefined"!=typeof RTCRtpScriptTransform}},{key:"isRequestVideoFrameCallbackSupported",get:function(){return void 0!==HTMLVideoElement.prototype.requestVideoFrameCallback}},{key:"isChannelFrameTimingInformationSupported",get:function(){return e.isRequestVideoFrameCallbackSupported&&(e.isEncodedInsertableStreamsSupported||e.isRTCRtpScriptTransformSupported)}},{key:"errorStackAlsoHasErrorMessage",get:function(){return"Firefox"!==h.browserName&&"Safari"!==h.browserName}}])}(),f=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}({}),m=function(){return u()((function e(t,n,i){a()(this,e),l()(this,"_category",void 0),l()(this,"_appenders",void 0),l()(this,"_threshold",void 0),this._category=t,this._appenders=n,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>f.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(f.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>f.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(f.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>f.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(f.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>f.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(f.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>f.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(f.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>f.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(f.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,i=new Date,r=this.replacePlaceholders(t);this._appenders.value.forEach((function(t){t.log(e,r,n.category,i)}))}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],i=0;n.indexOf&&e.length>1&&i>=0;)if((i=n.indexOf("%",i))>0)switch(n.substring(i+1,i+2)){case"%":n=n.substring(0,i)+n.substring(i+1),i++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,i),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,i),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce((function(e,n,i,r){return i+1===r.length&&n instanceof Error?p.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}}])}(),v=function(){return u()((function e(){a()(this,e),l()(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}),[])}}])}(),g=function(){return u()((function e(){a()(this,e)}),null,[{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"sendLogs",get:function(){return this._sendLogs}},{key:"sendMetrics",get:function(){return this._sendMetrics}},{key:"logToConsole",get:function(){return this._logToConsole}},{key:"applyFeatures",value:function(){try{var e={sendLocalCandidates:!1,sendLogs:"Off",sendMetrics:"Essential",logToConsole:"Off"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}])}();l()(g,"_sendLocalCandidates",void 0),l()(g,"_sendLogs",void 0),l()(g,"_sendMetrics",void 0),l()(g,"_logToConsole",void 0),g.applyFeatures();var _=function(){return u()((function e(){a()(this,e)}),null,[{key:"defaultLoggingLevel",get:function(){return f[g.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return f[g.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return f.Info}}])}(),y=function(){return u()((function e(){a()(this,e),l()(this,"_threshold",_.defaultLoggingLevel)}),[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}])}(),b=function(){return u()((function e(t){a()(this,e),l()(this,"_threshold",void 0),this._threshold=t}),[{key:"log",value:function(e,t,n,i){if(!(e<this._threshold)){var r="".concat(i.toISOString()," [").concat(n,"] [").concat(f[e],"] ").concat(t);e<f.Warn?console.log(r):console.error(r)}}}])}(),C=n(293),k=n.n(C),S=n(756),x=n.n(S),w=function(){function e(){throw a()(this,e),new Error("Numbers is a static class that may not be instantiated")}return u()(e,null,[{key:"countNumberLength",value:function(t){var n=0,i=t;return i<0&&(i*=-1,n++),e.countDigitsBeforeDecimal(i)+n+(i!==Math.floor(i)?e.countDigitsAfterDecimal(i)+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,i=Math.floor(t),r=0;i!==n&&r<15;)r++,i=e.fixRounding(n,r);return r}}])}(),T=function(){return u()((function e(){a()(this,e)}),null,[{key:"sdkVersion",get:function(){try{return"2024-12-09T18:00:58.926Z (2024.2.8-beta.366)"}catch(e){return this._defaultVersion}}}])}();l()(T,"_defaultVersion",(new Date).toISOString());var P=function(){return u()((function e(t){a()(this,e),l()(this,"_telemetryConfiguration",void 0),l()(this,"_logs",[]),l()(this,"_isSending",void 0),l()(this,"_domain",d.A.locationHostname),this._telemetryConfiguration=t}),[{key:"push",value:function(e,t,n,i){var r=(i.valueOf()-this._telemetryConfiguration.pageLoadTime)/1e3,o={timestamp:i.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:f[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:T.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:r};e<f.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"sendLogs",value:(t=k()(x().mark((function e(t){var n;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new d.A.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,d.A.fetch(this._telemetryConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"sendLogsIfAble",value:(e=k()(x().mark((function e(){var t,n,i,r,o,a=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._logs.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:for(t=0,n=0,this._isSending=!0,i=function(e){return"number"==typeof e?w.countNumberLength(e):e.length},r=function(e){return Object.values(e).reduce((function(e,t){return e+(t?i(t):0)}),0)};this._logs.length>t&&r(this._logs[t])+n<8192;)n+=r(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,r(this._logs[t])+(8192-r(this._logs[t]))),t=1),o=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.abrupt("return",this.sendLogs(o).then((function(e){return a._isSending=!1,a.sendLogsIfAble(),e})).catch((function(){a._isSending=!1,a.sendLogsIfAble()})));case 12:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]);var e,t}(),E=function(){return u()((function e(t){a()(this,e),l()(this,"_telemetryService",void 0),l()(this,"_tenancy",void 0),l()(this,"_sessionId",void 0),l()(this,"_threshold",void 0),this._tenancy=t.tenancy,this._sessionId=t.sessionId,this._threshold=t.threshold,this._telemetryService=new P(t)}),[{key:"log",value:function(e,t,n,i){e<this._threshold||this._telemetryService.push(e,t,n,i)}}])}(),F=function(){return u()((function e(){a()(this,e),l()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),l()(this,"_tenancy",void 0),l()(this,"_sessionId",void 0),l()(this,"_environment",void 0),l()(this,"_pageLoadTime",void 0),l()(this,"_threshold",_.defaultTelemetryLoggingLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new d.A.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}}])}(),R=function(){return u()((function e(){a()(this,e)}),null,[{key:"defaultTelemetryLevel",get:function(){return I[g.sendMetrics]}}])}(),I=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),D=function(){return u()((function e(){a()(this,e),l()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),l()(this,"_tenancy",void 0),l()(this,"_sessionId",void 0),l()(this,"_environment",void 0),l()(this,"_threshold",R.defaultTelemetryLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new d.A.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}}])}(),L=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},O=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case I.Off:return"Off";case I.Essential:return"Essential";case I.All:return"All";default:L(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return I.Off;case"Essential":return I.Essential;case"All":return I.All;default:L(e)}}}])}(),A=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case f.Off:return"Off";case f.Trace:return"Trace";case f.Debug:return"Debug";case f.Info:return"Trace";case f.Warn:return"Warn";case f.Error:return"Error";case f.Fatal:return"Fatal";case f.All:return"All";default:L(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return f.Off;case"Trace":return f.Trace;case"Debug":return f.Debug;case"Info":return f.Info;case"Warn":return f.Warn;case"Error":return f.Error;case"Fatal":return f.Fatal;case"All":return f.All;default:L(e)}}}])}(),M=function(){return u()((function e(){a()(this,e)}),[{key:"getStringValue",value:function(e){return this.defaultStringValue[e]}},{key:"getBooleanValue",value:function(e){return this.defaultBooleanValue[e]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":O.convertTelemetryLevelToTelemetryLevelType(R.defaultTelemetryLevel),"phenix-logging-level":A.convertLoggingLevelToLoggingLevelType(_.defaultLoggingLevel),"phenix-console-logging-level":A.convertLoggingLevelToLoggingLevelType(_.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":A.convertLoggingLevelToLoggingLevelType(_.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}}}])}(),U=function(){function e(){throw a()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return u()(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 m(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=this._configurationParameterReader.getStringValue("phenix-logging-level");f[e]&&this._threshold.setThreshold(f[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=this._configurationParameterReader.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(f[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new b(e||_.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||_.defaultTelemetryLoggingLevel,this._appenders.add(new E(this._telemetryConfiguration))}}])}();l()(U,"_configurationParameterReader",new M),l()(U,"_loggers",{}),l()(U,"_appenders",new v),l()(U,"_threshold",new y),l()(U,"_telemetryConfiguration",new F),U.applyLoggerConfigFromParameterConfiguration();var V=function(){return u()((function e(){throw a()(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)}}])}(),B=n(452),N=n.n(B),j=n(72),z=n.n(j),G=n(511),H=n.n(G),q=function(){return u()((function e(t){a()(this,e),l()(this,"_disposed",void 0),l()(this,"_disposable",void 0),this._disposed=!1,this._disposable=t}),[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}])}();function W(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(W=function(){return!!e})()}var J=function(e){function t(e,n){return a()(this,t),i=this,r=t,o=[function(){var t=e.indexOf(n);t>=0&&e.splice(t,1)}],r=z()(r),N()(i,W()?Reflect.construct(r,o||[],z()(i).constructor):r.apply(i,o));var i,r,o}return H()(t,e),u()(t)}(q),K=function(){return u()((function e(t){a()(this,e),l()(this,"_listeners",void 0),l()(this,"_value",void 0),this._listeners=[],this._value=t}),[{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))}t&&(this._value=e,this._listeners.forEach((function(t){t(e)})))}},{key:"subscribe",value:function(e){return this._listeners.push(e),e(this._value),new J(this._listeners,e)}}])}(),Q=function(){return u()((function e(t){a()(this,e),l()(this,"_subject",void 0),this._subject=t}),[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}])}(),Z=function(){return u()((function e(t){var n,i;a()(this,e),l()(this,"_applicationId",void 0),l()(this,"_token",void 0),this._applicationId=(null==t?void 0:t.applicationId)||"",this._token={uri:null!=t&&null!==(n=t.token)&&void 0!==n&&n.uri?new d.A.URL(t.token.uri):null,capabilities:(null==t||null===(i=t.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}}])}(),$=function(){function e(){a()(this,e)}return u()(e,null,[{key:"parseToken",value:function(t){if(!this.isEncodedEdgeTokenValid(t))return e._logger.error("Token is not valid [%s]",t),new Z(null);try{var n=atob(t.substr(7)),i=JSON.parse(n);return i.token=JSON.parse(i.token),new Z(i)}catch(t){return e._logger.error("Cannot parse token value",t),new Z(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();l()($,"_logger",U.getLogger("EdgeAuthParser"));var X=function(){return u()((function e(){a()(this,e),l()(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,"]")}}])}(),Y="visibilitychange",ee=function(){return u()((function e(){a()(this,e),l()(this,"_disposables",new X),l()(this,"_readOnlyIsForeground",void 0),l()(this,"_isForeground",void 0),l()(this,"_timeOfLastTabFocusChange",Date.now()),this._isForeground=new K(!0),this._readOnlyIsForeground=new Q(this._isForeground),this.initialize()}),[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"initialize",value:function(){var e=this,t=function(){return e._isForeground.value=!d.A.documentIsHidden},n=!1;d.A.addDocumentEventListener(Y,t,n),this._disposables.add(new q((function(){return d.A.removeDocumentEventListener(Y,t,n)})))}}])}(),te=n(701).A,ne=function(){return u()((function e(t){a()(this,e),l()(this,"_logger",U.getLogger("VanillaPeerConnection")),l()(this,"_peerConnection",void 0),p.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(t):this._peerConnection=new RTCPeerConnection(t)}),[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){return this._peerConnection.currentLocalDescription}},{key:"currentRemoteDescription",get:function(){return this._peerConnection.currentRemoteDescription}},{key:"connectionState",get:function(){return this._peerConnection.connectionState}},{key:"iceConnectionState",get:function(){return this._peerConnection.iceConnectionState}},{key:"supportsGetConfiguration",get:function(){return"function"==typeof this._peerConnection.getConfiguration}},{key:"supportsSetConfiguration",get:function(){return"function"==typeof this._peerConnection.setConfiguration}},{key:"supportsGetTransceivers",get:function(){return!p.getTransceiversDisabled&&"function"==typeof this._peerConnection.getTransceivers}},{key:"supportsAddTransceiver",get:function(){return!p.addTranceiverDisabled&&"function"==typeof this._peerConnection.addTransceiver}},{key:"createOffer",value:(i=k()(x().mark((function e(t){var n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!p.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new te((function(e,i){return n._peerConnection.createOffer(e,i,t)})));case 2:return e.abrupt("return",this._peerConnection.createOffer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"createAnswer",value:(n=k()(x().mark((function e(t){var n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!p.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new te((function(e,i){return n._peerConnection.createAnswer(e,i,t)})));case 2:return e.abrupt("return",this._peerConnection.createAnswer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLocalDescription",value:(t=k()(x().mark((function e(t){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._peerConnection.setLocalDescription(p.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"setRemoteDescription",value:(e=k()(x().mark((function e(t){var n;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0: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.abrupt("return",this._peerConnection.setRemoteDescription(p.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"getSenders",value:function(){return this._peerConnection.getSenders()}},{key:"getReceivers",value:function(){return this._peerConnection.getReceivers()}},{key:"getStats",value:function(e){return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;return new te((function(t){e._peerConnection.getStats(t)}))}},{key:"addEventListener",value:function(e,t,n){this._peerConnection.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){this._peerConnection.removeEventListener(e,t,n)}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"addTransceiver",value:function(e,t){return this._peerConnection.addTransceiver(e,t)}},{key:"addStream",value:function(e){var t=this;e.getTracks().forEach((function(e){t._peerConnection.addTrack(e)}))}},{key:"getConfiguration",value:function(){return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){this._peerConnection.setConfiguration(e)}},{key:"ontrack",get:function(){return this._peerConnection.ontrack},set:function(e){this._peerConnection.ontrack=e}},{key:"onicecandidate",get:function(){return this._peerConnection.onicecandidate},set:function(e){this._peerConnection.onicecandidate=e}},{key:"onconnectionstatechange",get:function(){return this._peerConnection.onconnectionstatechange},set:function(e){this._peerConnection.onconnectionstatechange=e}},{key:"oniceconnectionstatechange",get:function(){return this._peerConnection.oniceconnectionstatechange},set:function(e){this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){this._peerConnection.close()}},{key:"dispose",value:function(){this._peerConnection=null}}]);var e,t,n,i}(),ie=function(){return u()((function e(){a()(this,e)}),[{key:"createPeerConnection",value:(e=k()(x().mark((function e(t){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new ne(t));case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e}(),re=function(){function e(){throw a()(this,e),new Error("PeerConnectionService is a static class that may not be instantiated")}return u()(e,null,[{key:"peerConnectionFactory",get:function(){return e._peerConnectionFactory}},{key:"initiateInitialPrecaching",value:function(){p.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(n=k()(x().mark((function t(){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e._cached={direction:"recvonly",peerConnection:e.createPeerConnectionOffer().catch((function(t){throw e._cached=null,t}))});case 1:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(t=k()(x().mark((function t(){var n,i,r,o,a=arguments;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=a.length>0&&void 0!==a[0]?a[0]:"recvonly",i=a.length>1&&void 0!==a[1]&&a[1],!e._cached||e._cached.direction!==n||i){t.next=6;break}return r=e._cached.peerConnection,e._cached=null,t.abrupt("return",r);case 6:return o=p.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:i}:void 0,t.abrupt("return",e._peerConnectionFactory.value.createPeerConnection(o).then(function(){var e=k()(x().mark((function e(t){var i,r,o;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.supportsAddTransceiver){e.next=11;break}return r=t.addTransceiver("audio",{direction:n}),i=t.addTransceiver("video",{direction:n}),e.t0=r,e.t1=i,e.t2=t,e.next=9,t.createOffer(void 0);case 9:return e.t3=e.sent,e.abrupt("return",{audioTransceiver:e.t0,videoTransceiver:e.t1,peerConnection:e.t2,localOffer:e.t3});case 11:return o="recvonly"===n?{offerToReceiveAudio:!0,offerToReceiveVideo:!0}:{},e.t4=t,e.next=15,t.createOffer(o);case 15:return e.t5=e.sent,e.abrupt("return",{peerConnection:e.t4,localOffer:e.t5});case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 8:case"end":return t.stop()}}),t)}))),function(){return t.apply(this,arguments)})}]);var t,n}();l()(re,"_logger",U.getLogger("PeerConnectionService")),l()(re,"_peerConnectionFactory",new K(new ie)),l()(re,"_cached",void 0),re.initiateInitialPrecaching();var oe=function(){return u()((function e(){a()(this,e)}),null,[{key:"getTelemetryUrl",value:function(e){try{var t=new d.A.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}}}])}(),ae=function(){return u()((function e(){a()(this,e)}),null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new d.A.URL(e).origin}catch(e){return""}}}])}(),se=function(){return u()((function e(){a()(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:""}}}}])}();l()(se,"_discoveryParameters",void 0),se.applyParameters();var ue=function(){function e(){throw a()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return u()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new d.A.URL(e.toString()),n=T.sdkVersion,i=se.discoveryParameters.intentions;return t.searchParams.set("version",n),t.searchParams.set("intentions",i),t.searchParams.set("_","".concat(Date.now())),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}])}();l()(ue,"_discoveryUri",new K("https://pcast.phenixrts.com/pcast/endPoints"));var ce,le=n(132),de=n.n(le),he=function(){return u()((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e5;a()(this,e),l()(this,"_backoffIntervalInMillisecond",void 0),l()(this,"_minBackoffIntervalInMillisecond",void 0),l()(this,"_maxBackoffIntervalInMillisecond",void 0),this._backoffIntervalInMillisecond=t,this._minBackoffIntervalInMillisecond=n,this._maxBackoffIntervalInMillisecond=i}),[{key:"getExponentialBackoffIntervalByFailureCount",value:function(e){var t=this._backoffIntervalInMillisecond/1e3,n=.5+.5*Math.random(),i=Math.pow(t,e-2),r=Math.floor(i)*n,o=Math.ceil(Math.max(1e3*r,this._minBackoffIntervalInMillisecond));return Math.min(o,this._maxBackoffIntervalInMillisecond)}}])}(),pe=function(e){return e[e.TimeToFirstFrame=0]="TimeToFirstFrame",e[e.ChannelCreationTimeToFirstFrame=1]="ChannelCreationTimeToFirstFrame",e[e.Stalled=2]="Stalled",e[e.Buffering=3]="Buffering",e[e.SetupCompleted=4]="SetupCompleted",e[e.SetupFailed=5]="SetupFailed",e[e.RoundTripTime=6]="RoundTripTime",e[e.DownlinkThroughputCapacity=7]="DownlinkThroughputCapacity",e[e.NetworkType=8]="NetworkType",e[e.ResolutionChanged=9]="ResolutionChanged",e[e.ApplicationForeground=10]="ApplicationForeground",e[e.ApplicationBackground=11]="ApplicationBackground",e}(pe||{}),fe=pe,me=function(){return u()((function e(t){a()(this,e),l()(this,"_metrics",void 0),this._metrics=t}),[{key:"getName",value:function(){return fe[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case fe.TimeToFirstFrame:case fe.ChannelCreationTimeToFirstFrame:return I.Essential;case fe.Stalled:case fe.Buffering:case fe.SetupCompleted:case fe.SetupFailed:case fe.RoundTripTime:case fe.DownlinkThroughputCapacity:case fe.NetworkType:case fe.ResolutionChanged:case fe.ApplicationForeground:case fe.ApplicationBackground:return I.All;default:L(this._metrics)}}}])}(),ve=function(){return u()((function e(t){a()(this,e),l()(this,"_logger",U.getLogger("MetricsService")),l()(this,"_metricsConfiguration",void 0),l()(this,"_exponentialBackoff",void 0),l()(this,"_metrics",[]),l()(this,"_isSending",void 0),l()(this,"_failureCount",0),l()(this,"_domain",d.A.locationHostname),this._metricsConfiguration=t,this._exponentialBackoff=new he}),[{key:"metricsConfiguration",get:function(){return this._metricsConfiguration}},{key:"push",value:function(e){var t=e.streamId,n=e.value,i=e.previousValue,r=e.runtime,o=e.resource,a=e.kind,s=new me(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:i,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:T.sdkVersion,runtime:r,resource:o,kind:a};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:(t=k()(x().mark((function e(t){var n;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new d.A.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,d.A.fetch(this._metricsConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(e=k()(x().mark((function e(){var t,n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._metrics.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.abrupt("return",this.sendMetrics(t).then((function(e){if(n.isResponseStatusCodeRetryable(e)){if(n._metrics.length<=2048)return n._failureCount++,void d.A.setTimeout((function(){n._metrics=[].concat(de()(t),de()(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()})));case 6:case"end":return e.stop()}}),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,t}(),ge=function(){function e(){throw a()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return u()(e,null,[{key:"getMetricsService",value:function(t){if("string"!=typeof t)throw new Error("ur");var n=e._metricsServices[t];if(n)return n;var i=new D;return i.sessionId=ye.clientSessionId,i.tenancy=ye.tenancy.value,i.url=oe.getTelemetryUrl(t),i.environment=ae.getEnvironmentFromUrl(t),i.threshold=O.convertTelemetryLevelTypeToTelemetryLevel(ye.telemetryLevel),e._metricsServices[t]=new ve(i)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}])}();l()(ge,"_metricsServices",{});var _e=window.__phenixPageLoadTime||window.__pageLoadTime||Date.now(),ye=function(){function e(){throw a()(this,e),new Error("SDK is a static class that may not be instantiated")}return u()(e,null,[{key:"pageLoadTime",get:function(){return _e}},{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 A.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return O.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return h}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=U.telemetryConfiguration;n.sessionId=e.clientSessionId,n.pageLoadTime=e.pageLoadTime,e._environment.subscribe((function(e){n.environment=e})),e.telemetryUrl.subscribe((function(e){var i=t._logger.appenders.value.find((function(e){return e instanceof E}));i&&(n.url=e,t._logger.appenders.remove(i),t._logger.appenders.add(new E(n)),t._logger.info("Telemetry URL was set to [%s]",n.url))})),e._tenancy.subscribe((function(e){var i=t._logger.appenders.value.find((function(e){return e instanceof E}));i&&e&&(n.tenancy=e,t._logger.appenders.remove(i),t._logger.appenders.add(new E(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=ge.getMetricsService(ue.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=this._configurationParameterReader.getStringValue("phenix-metrics-level");t&&ge.setTelemetryLevel(I[t]),e._telemetryLevel.subscribe((function(e){ge.setTelemetryLevel(e)}))}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=this._configurationParameterReader.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=this._configurationParameterReader.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=this._configurationParameterReader.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=this._configurationParameterReader.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=ae.getEnvironmentFromUrl(t)}));var t=this._configurationParameterReader.getStringValue("phenix-channel-token");if(t){var n=$.parseToken(t);return e._tenancy.value=n.tenancy,ue.uri.value=(n.uri||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var i=this._configurationParameterReader.getStringValue("phenix-uri");if(i)return ue.uri.value=i,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var r=this._configurationParameterReader.getStringValue("phenix-base-uri");if(r){var o=new d.A.URL(r);return o.pathname="/pcast/endPoints",ue.uri.value=o.toString(),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)}}},{key:"init",value:function(t){if(this._initialized.value||(this._applicationActivityMonitor=new ee),t){if(t.discoveryUri&&(ue.uri.value=t.discoveryUri),t.peerConnectionFactory&&(re.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&I[t.telemetryLevel]&&(e._telemetryLevel.value=O.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&f[t.loggingLevel]&&this._logger.threshold.setThreshold(A.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&f[t.consoleLoggingLevel]){var n=this._logger.appenders.value.find((function(e){return e instanceof b}));n&&this._logger.appenders.remove(n),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new b(A.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)}e._initialized.value=!0}},{key:"dispose",value:function(){e._initialized.value=!1,this._applicationActivityMonitor.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return oe.getTelemetryUrl(e)}}])}();ce=ye,l()(ye,"_automaticallyRetryOnFailure",!0),l()(ye,"_automaticallyReconnectPeerConnection",!0),l()(ye,"_automaticallyPlayMediaStream",!0),l()(ye,"_automaticallyMuteVideoOnPlayFailure",!0),l()(ye,"_forceGarbageCollectionOnRestart",!0),l()(ye,"_skipGarbageCollectionOnMobileDevices",!0),l()(ye,"_webPlayerLoader",null),l()(ye,"_shakaPlayerLoader",null),l()(ye,"_hlsJsLoader",null),l()(ye,"_configurationParameterReader",new M),l()(ye,"_applicationActivityMonitor",void 0),l()(ye,"_environment",new K("")),l()(ye,"_telemetryUrl",new K("https://telemetry.phenixrts.com/telemetry")),l()(ye,"_maximalNumberOfPeerConnectionReconnectAttempts",8),l()(ye,"_telemetryLevel",new K(R.defaultTelemetryLevel)),l()(ye,"_metricsService",void 0),l()(ye,"_metricsConfiguration",void 0),l()(ye,"_sendLocalCandidates",new K(g.sendLocalCandidates)),l()(ye,"_tenancy",new K("")),l()(ye,"_clientSessionId",V.random(32)),l()(ye,"_loadedTimestamp",new Date),l()(ye,"_logger",U.getLogger("SDK")),l()(ye,"_initialized",new K(!1)),l()(ye,"_readOnlyInitialized",new Q(ce._initialized)),l()(ye,"_readOnlyDiscoveryUri",new Q(ue.uri)),l()(ye,"_readOnlyPeerConnectionFactory",new Q(re.peerConnectionFactory)),d.A.addWindowEventListener("unload",(function(){ye.dispose()})),ye.applyDiscoveryUriDefaultFromParameterConfiguration(),ye.applyMetricsConfiguration(),ye.applyTelemetryConfiguration(),ye.applyAutomaticallyRetryOnFailureFromParameterConfiguration(),ye.applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration(),ye.applyForceGarbageCollectionOnRestartFromParameterConfiguration(),ye.applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration(),ye.init();var be=function(){function e(t,n){a()(this,e),l()(this,"width",void 0),l()(this,"height",void 0),this.width=t,this.height=n}return u()(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)}}])}(),Ce=function(){return u()((function e(){throw a()(this,e),new Error("GarbageCollectorManager is a static class that may not be instantiated")}),null,[{key:"forceGarbageCollection",value:function(){p.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){p.isQueueMicrotaskSupported?d.A.queueMicrotask(this.overloadMemoryToInvokeGarbageCollection.bind(this)):d.A.setTimeout(this.overloadMemoryToInvokeGarbageCollection.bind(this),0)}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=d.A.documentCreateElement("img");e.src=d.A.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){d.A.URL.revokeObjectURL(this.src),e=null}}}])}(),ke=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}(ke||{}),Se=ke,xe=function(){return u()((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;a()(this,e),l()(this,"_duration",void 0),this._duration=t}),[{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),i=n%1e3,r=(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"),(r||i)&&(s.push(String(r)),i&&s.push("."+this.padStart(i.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(){return u()((function e(t,n,i,r){a()(this,e),l()(this,"_pageLoadTime",void 0),l()(this,"_channelStartTime",void 0),l()(this,"_logger",U.getLogger("StreamTelemetry")),l()(this,"_disposables",new X),l()(this,"_streamId",void 0),l()(this,"_metricsService",void 0),l()(this,"_listenToFirstTime",void 0),l()(this,"_listenForStall",void 0),l()(this,"_listenForContinuation",void 0),l()(this,"_timeToFirstFrame",void 0),l()(this,"_channelCreationTimeToFirstFrame",void 0),l()(this,"_startRecordingFirstFrame",void 0),l()(this,"_videoStalled",void 0),l()(this,"_lastProgress",void 0),l()(this,"_videoResolution",void 0),l()(this,"_clearTimeToFirstFrameListener",void 0),l()(this,"_clearRebufferingListener",void 0),this._streamId=t,this._pageLoadTime=n,this._channelStartTime=i,this._metricsService=r}),[{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 q((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 q((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 xe(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:fe.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 xe(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:fe.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 xe(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:fe.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,i=!("playing"===e.type||n>0)||("progress"===e.type||"timeupdate"===e.type)&&t.buffered.end(n-1)===this._lastProgress;if(this._videoStalled&&!i){"progress"===e.type&&(this._lastProgress=t.buffered.end(n-1));var r=Date.now()-this._videoStalled;this._metricsService.push({metricType:fe.Buffering,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{uint64:r},streamId:this._streamId}),this._logger.info("[%s] [%s] [buffering] Stream has recovered from stall after [%s]",this.durationSincePageLoad,this._streamId,new xe(r).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:fe.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}}])}(),Te=function(){return u()((function e(t){a()(this,e),l()(this,"_logger",U.getLogger("StreamSetupListener")),l()(this,"metricsService",ye.metricsService),l()(this,"_pageLoadTime",void 0),l()(this,"_startTime",void 0),l()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=t}),[{key:"success",value:function(e){this.recordStreamMetric(fe.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(fe.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),i=n-this._startTime,r=new me(e).getName();this.metricsService.push({metricType:e,runtime:(n-this._pageLoadTime)/1e3,value:{uint64:i},streamId:t}),this._logger.info("[%s] [%s] Stream metric [%s] in [%s]",new xe(n-this._pageLoadTime).toIsoString(),t,r,new xe(i).toIsoString())}}}])}(),Pe=function(){return u()((function e(){a()(this,e),l()(this,"_disposables",new X),l()(this,"_isSupported",void 0!==d.A.navigatorConnection),l()(this,"_rtt",new K(void 0)),l()(this,"_effectiveType",new K(void 0)),l()(this,"_downlinkThroughputCapacity",new K(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,i;return null!==(e=null!==(t=null===(n=d.A.navigatorConnection)||void 0===n?void 0:n.downlink)&&void 0!==t?t:null===(i=d.A.navigatorConnection)||void 0===i?void 0:i.downlinkMax)&&void 0!==e?e:-1}},{key:"getEffectiveType",value:function(){var e,t,n,i;return null!==(e=null!==(t=null===(n=d.A.navigatorConnection)||void 0===n?void 0:n.effectiveType)&&void 0!==t?t:null===(i=d.A.navigatorConnection)||void 0===i?void 0:i.type)&&void 0!==e?e:"Unknown"}},{key:"getRoundTripTime",value:function(){var e,t;return null!==(e=null===(t=d.A.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=d.A.navigatorConnection)||void 0===e||e.addEventListener("change",n),this._disposables.add(new q((function(){var e;return null===(e=d.A.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()}}])}(),Ee=function(){return u()((function e(t,n){var i=this;a()(this,e),l()(this,"_logger",U.getLogger("SessionTelemetry")),l()(this,"_metricsService",void 0),l()(this,"_applicationActivityMonitor",ye.applicationActivityMonitor),l()(this,"_networkMonitor",new Pe),l()(this,"_pageLoadTime",void 0),l()(this,"_disposables",new X),l()(this,"_lastNetworkStatistics",{}),this._pageLoadTime=t,this._disposables.add(this._networkMonitor),this._metricsService=n,this._networkMonitor.isSupported&&(this._disposables.add(this._applicationActivityMonitor.isForeground.subscribe((function(e){i.recordForegroundChange(e)}))),this._disposables.add(this._networkMonitor.rtt.subscribe((function(e){i.recordNetworkRTTUpdate(e)}))),this._disposables.add(this._networkMonitor.effectiveType.subscribe((function(e){i.recordNetworkTypeChangeUpdate(e)}))),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe((function(e){i.recordNetworkDownlinkThroughputCapacityUpdate(e)}))))}),[{key:"listenOnStreamSetup",value:function(){return new Te(this._pageLoadTime)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"recordForegroundChange",value:function(e){var t=Date.now(),n=this._applicationActivityMonitor.getTimeSinceLastChange();this._metricsService.push({metricType:e?fe.ApplicationForeground:fe.ApplicationBackground,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:n}}),this._logger.info("Application has gone into the [%s] after [%s] ms",e?"foreground":"background",new xe(n).toIsoString())}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:fe.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 xe(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:fe.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 xe(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:fe.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 xe(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),Fe=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Re=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),Ie=u()((function e(t){a()(this,e),l()(this,"token",void 0),l()(this,"tokenExpiring",void 0),this.token=new K(t),this.tokenExpiring=new K(!1)})),De=function(){return u()((function e(t){var n;a()(this,e),l()(this,"channelInitialization",void 0),l()(this,"disposables",void 0),l()(this,"channelDisposables",void 0),l()(this,"rendererDisposables",void 0),l()(this,"videoElement",void 0),l()(this,"state",void 0),l()(this,"autoMuted",void 0),l()(this,"autoPaused",void 0),l()(this,"authorized",void 0),l()(this,"online",void 0),l()(this,"loading",void 0),l()(this,"playing",void 0),l()(this,"standby",void 0),l()(this,"stopped",void 0),l()(this,"targetLag",void 0),l()(this,"lag",void 0),l()(this,"bitrateLimit",void 0),l()(this,"resolution",void 0),l()(this,"failureCount",void 0),l()(this,"endPoint",void 0),l()(this,"stream",void 0),l()(this,"rtcStatistics",void 0),l()(this,"videoTelemetry",void 0),l()(this,"rtcAudioStatistic",void 0),l()(this,"rtcVideoStatistic",void 0),l()(this,"clearFailureCountTimeout",void 0),this.disposables=new X,this.channelDisposables=new X,this.rendererDisposables=new X,this.channelInitialization=new Date,this.videoElement=new K(null),this.state=new K(Se.Initializing),this.autoMuted=new K(!1),this.autoPaused=new K(!1),this.authorized=new K(!0),this.online=new K(!0),this.loading=new K(!1),this.playing=new K(!1),this.standby=new K(!1),this.stopped=new K(!1),this.targetLag=new K(null!==(n=null==t?void 0:t.targetLag)&&void 0!==n?n:0),this.lag=new K(0),this.bitrateLimit=new K(0),this.resolution=new K(be.empty),this.failureCount=new K(0),this.endPoint=new K(null),this.stream=new K(null),this.rtcStatistics=new K(null)}),[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":this.authorized.value=!1;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=ye.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return Se.Starting;case"no-stream":case"not-found":return Se.StandBy;case"geo-restricted":return Se.GeoRestricted;case"geo-blocked":return Se.GeoBlocked;case"unauthorized":return Se.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Se.Recovering;case"forbidden-tag":return Se.ConfigurationError;case"port-in-range-not-found":return Se.TransientConfigurationError;case"failed":return Se.Error;default:L(e)}}}])}(),Le=n(738),Oe=n.n(Le),Ae=function(){return u()((function e(){throw a()(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(Oe()(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"}}}])}(),Me=function(){return u()((function e(){a()(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(Oe()(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"}}}])}(),Ue=u()((function e(t){a()(this,e),l()(this,"hasInsertableStreams",void 0),l()(this,"hasEncodedInsertableStreams",void 0),l()(this,"videoStreamTransformCallback",void 0),l()(this,"audioStreamTransformCallback",void 0),l()(this,"encodedVideoStreamSink",void 0),l()(this,"encodedAudioStreamSink",void 0),this.hasInsertableStreams=new K(t.hasInsertableStreams),this.hasEncodedInsertableStreams=new K(t.hasEncodedInsertableStreams),this.videoStreamTransformCallback=t.videoStreamTransformCallback,this.audioStreamTransformCallback=t.audioStreamTransformCallback,this.encodedVideoStreamSink=t.encodedVideoStreamSink,this.encodedAudioStreamSink=t.encodedAudioStreamSink})),Ve=u()((function e(){a()(this,e),l()(this,"mediaStream",void 0),l()(this,"peerConnection",void 0),l()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new K(null),this.peerConnection=new K(null),this.peerConnectionReconnectAttempts=0})),Be=u()((function e(){a()(this,e),l()(this,"isStarting",void 0),l()(this,"isDisposed",void 0),this.isStarting=new K(!1),this.isDisposed=!1})),Ne=u()((function e(){a()(this,e),l()(this,"shouldExtractTimecode",void 0),l()(this,"shouldExtractTimestamps",void 0),l()(this,"isEnabled",void 0),l()(this,"decodedFrameTimingInformation",void 0),l()(this,"renderedFrameTimingInformation",void 0),this.shouldExtractTimecode=new K(!1),this.shouldExtractTimestamps=new K(!1),this.isEnabled=new K(!1),this.decodedFrameTimingInformation=new K(null),this.renderedFrameTimingInformation=new K(null)})),je=n(715),ze=n.n(je),Ge=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Re.Normal:return"Normal";case Re.Force:return"Force";case Re.Reset:return"Reset";default:L(e)}}}])}(),He=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Fe.Keep:return"Keep";case Fe.Reset:return"Reset";default:L(e)}}}])}(),qe=n(701).A,We=function(){return u()((function e(t,n){if(a()(this,e),l()(this,"_logger",U.getLogger("EndPoint")),l()(this,"_uri",void 0),l()(this,"_timeout",void 0),l()(this,"_roundTripTime",void 0),this._uri=t,this._timeout=n,!n)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:(v=k()(x().mark((function e(){var t,n,i,r,o=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,qe.race([d.A.fetch(t,{method:"GET",cache:"no-cache"}),new qe((function(e,n){return d.A.setTimeout((function(){return n(new Error("Ping timed out [".concat(t,"]")))}),o._timeout)}))]);case 4:if(i=e.sent,r=Date.now(),i.ok){e.next=8;break}throw new Error("Ping failed [".concat(t,"] [").concat(i.status,"]"));case 8:return this._roundTripTime=r-n,e.abrupt("return",this._roundTripTime);case 10:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"subscribe",value:(m=k()(x().mark((function e(t,n,i){var r,o,a,s,u,c,l,h,p,f,m,v,g=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=$.parseToken(t).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",t),e.abrupt("return",{status:"unauthorized"});case 4:return o=this.buildUrl([r,"stream","subscribe"]).toString(),a=new d.A.FormData,s=T.sdkVersion,0===i&&n?(u={apiVersion:7,clientVersion:s,bearerToken:t,failureCount:i,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:7,sessionDescription:{type:n.type,sdp:n.sdp}},createAnswerDescription:{apiVersion:7}},a.append("jsonBody",JSON.stringify(u))):(c={apiVersion:7,clientVersion:s,bearerToken:t,failureCount:i,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:7}},a.append("jsonBody",JSON.stringify(c))),l=Date.now(),e.prev=9,p=null,e.next=13,qe.race([d.A.fetch(o,{method:"POST",body:a}),new qe((function(e){return p=d.A.setTimeout((function(){g._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(o,"]"))),e({status:408})}),g._timeout)}))]).finally((function(){p&&d.A.clearTimeout(p)}));case 13:h=e.sent,e.next=20;break;case 16:return e.prev=16,e.t0=e.catch(9),this._logger.error("Failed to subscribe",e.t0),e.abrupt("return",{status:"failed"});case 20:if("ok"===(f=this.mapHttpStatusToSubscribeStatus(h))){e.next=23;break}return e.abrupt("return",{status:f});case 23:return m=Date.now(),e.next=26,this.convertHttpResponseToSubscribeResponse(r,h);case 26:return v=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",v,m-l),e.abrupt("return",v);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n){return m.apply(this,arguments)})},{key:"publish",value:(f=k()(x().mark((function e(t,n,i,r){var o,a,s,u,c,l,h,p,f,m,v,g,_=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=$.parseToken(n).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",n),e.abrupt("return",{status:"unauthorized"});case 4:return a=this.buildUrl([o,"stream","publish"]).toString(),s=new d.A.FormData,u=T.sdkVersion,0===r&&i?(c={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:r,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:7,sessionDescription:{type:i.type,sdp:i.sdp}},createAnswerDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(c))):(l={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:r,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(l))),h=Date.now(),e.prev=9,f=null,e.next=13,qe.race([d.A.fetch(a,{method:"POST",body:s}),new qe((function(e){return f=d.A.setTimeout((function(){_._logger.error("Failed to publish",new Error("Publish timed out [".concat(a,"]"))),e({status:408})}),_._timeout)}))]).finally((function(){f&&d.A.clearTimeout(f)}));case 13:p=e.sent,e.next=20;break;case 16:return e.prev=16,e.t0=e.catch(9),this._logger.error("Failed to publish",e.t0),e.abrupt("return",{status:"failed"});case 20:if("ok"===(m=this.mapHttpStatusToPublishStatus(p))){e.next=23;break}return e.abrupt("return",{status:m});case 23:return v=Date.now(),e.next=26,this.convertHttpResponseToPublishResponse(o,p);case 26:return g=e.sent,this._logger.debug("Got publish response [%j] in [%s] ms",g,v-h),e.abrupt("return",g);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n,i){return f.apply(this,arguments)})},{key:"setRemoteDescription",value:(p=k()(x().mark((function e(t,n){var i,r,o,a,s,u,c,l,h,p=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),r=new d.A.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,sessionDescription:{type:n.type,sdp:n.sdp}},r.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,qe.race([d.A.fetch(i,{method:"POST",body:r}),new qe((function(e){return u=d.A.setTimeout((function(){p._logger.error("Failed to set remote description",new Error("Set remote description timed out [".concat(i,"]"))),e({status:408})}),p._timeout)}))]).finally((function(){u&&d.A.clearTimeout(u)}));case 9:s=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set remote description",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(c=this.mapHttpStatusToSetRemoteDescriptionStatus(s))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToSetRemoteDescriptionResponse(s);case 22:return h=e.sent,this._logger.debug("Got set remote description response [%j] in [%s] ms",h,l-a),e.abrupt("return",h);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return p.apply(this,arguments)})},{key:"limitBitrate",value:(h=k()(x().mark((function e(t,n,i,r,o){var a,s,u,c,l,h,p,f,m=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new d.A.FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:i,bitrateState:He.convertBitrateStateToBitrateStateType(r),bitrateMode:Ge.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,h=null,e.next=9,qe.race([d.A.fetch(a,{method:"POST",body:s}),new qe((function(e){return h=d.A.setTimeout((function(){m._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(a,"]"))),e({status:408})}),m._timeout)}))]).finally((function(){h&&d.A.clearTimeout(h)}));case 9:l=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set limit bitrate timed",e.t0),e.abrupt("return",{status:"failed"});case 16:return p=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),f=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",p,f-c),e.abrupt("return",{status:p});case 20:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t,n,i,r){return h.apply(this,arguments)})},{key:"addIceCandidates",value:(c=k()(x().mark((function e(t,n,i){var r,o,a,s,u,c,l,h,p,f,m=this,v=arguments;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=v.length>3&&void 0!==v[3]?v[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),a=new d.A.FormData,s={apiVersion:7,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:i,options:r},a.append("jsonBody",JSON.stringify(s)),u=Date.now(),e.prev=6,l=null,e.next=10,qe.race([d.A.fetch(o,{method:"POST",body:a}),new qe((function(e){return l=d.A.setTimeout((function(){m._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(o,"]"))),e({status:408})}),m._timeout)}))]).finally((function(){l&&d.A.clearTimeout(l)}));case 10:c=e.sent,e.next=17;break;case 13:return e.prev=13,e.t0=e.catch(6),this._logger.error("Failed to add ice candidates",e.t0),e.abrupt("return",{status:"failed"});case 17:if("ok"===(h=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.next=20;break}return e.abrupt("return",{status:h});case 20:return p=Date.now(),e.next=23,this.convertHttpResponseToAddIceCandidatesResponse(c);case 23:return f=e.sent,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",f,p-u),e.abrupt("return",f);case 26:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e,t,n){return c.apply(this,arguments)})},{key:"destroyStream",value:(s=k()(x().mark((function e(t,n){var i,r,o,a,s,u,c,l,h,p=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),r=new d.A.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},r.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,qe.race([d.A.fetch(i,{method:"POST",body:r,cache:"no-cache"}),new qe((function(e){return u=d.A.setTimeout((function(){p._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(i,"]"))),e({status:408})}),p._timeout)}))]).finally((function(){u&&d.A.clearTimeout(u)}));case 9:s=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to delete stream",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(c=this.mapHttpStatusToSetDestroyStreamStatus(s))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToDestroyStreamResponse(s);case 22:return h=e.sent,this._logger.info("Got destroy stream response [%j] in [%s] ms",h,l-a),e.abrupt("return",h);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return s.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(o=k()(x().mark((function e(t,n){var i,r,o,a;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(i=navigator)&&void 0!==i&&i.sendBeacon||this.destroyStream(t,n),r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),o=new d.A.FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},o.append("jsonBody",JSON.stringify(a)),navigator.sendBeacon(r,o);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new d.A.URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,de()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new d.A.URL(this._uri),t=T.sdkVersion,n=se.discoveryParameters.intentions;return e.searchParams.set("type","http"),e.searchParams.set("version",t),e.searchParams.set("intentions",n),e.searchParams.set("_","".concat(Date.now())),e.toString()}},{key:"mapHttpStatusToPublishStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 406:return"missing-channel-or-room-id";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSubscribeStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetRemoteDescriptionStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetTemporaryMaximalBitrateStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToAddIceCandidatesStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetDestroyStreamStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"convertHttpResponseToSubscribeResponse",value:(r=k()(x().mark((function e(t,n){var i,r;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return i=e.sent,(r={status:i.status}).stream={tenancy:t,streamId:i.streamId,sharedSecret:i.sharedSecret},r.lag=i.lag,i&&(i.rtcConfiguration&&(r.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(i.rtcConfiguration)),i.setRemoteDescriptionResponse&&i.setRemoteDescriptionResponse.sessionDescription&&(r.setRemoteDescriptionResponse={sessionDescription:i.setRemoteDescriptionResponse.sessionDescription}),i.createAnswerDescriptionResponse&&i.createAnswerDescriptionResponse.sessionDescription&&(r.createAnswerDescriptionResponse={sessionDescription:i.createAnswerDescriptionResponse.sessionDescription}),i.createOfferDescriptionResponse&&i.createOfferDescriptionResponse.sessionDescription&&(r.createOfferDescriptionResponse={sessionDescription:i.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(i=k()(x().mark((function e(t,n){var i,r;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return i=e.sent,(r={status:i.status}).stream={tenancy:t,streamId:i.streamId,sharedSecret:i.sharedSecret},i&&(i.rtcConfiguration&&(r.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(i.rtcConfiguration)),i.setRemoteDescriptionResponse&&i.setRemoteDescriptionResponse.sessionDescription&&(r.setRemoteDescriptionResponse={sessionDescription:i.setRemoteDescriptionResponse.sessionDescription}),i.createAnswerDescriptionResponse&&i.createAnswerDescriptionResponse.sessionDescription&&(r.createAnswerDescriptionResponse={sessionDescription:i.createAnswerDescriptionResponse.sessionDescription}),i.createOfferDescriptionResponse&&i.createOfferDescriptionResponse.sessionDescription&&(r.createOfferDescriptionResponse={sessionDescription:i.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={iceServers:[]};if(e.bundlePolicy&&(t.bundlePolicy=e.bundlePolicy),"number"==typeof e.iceCandidatePoolSize&&(t.iceCandidatePoolSize=e.iceCandidatePoolSize),e.iceServers){for(var n=[],i=0;i<e.iceServers.length;i++)n.push({urls:e.iceServers[i].urls,username:e.iceServers[i].username,credential:e.iceServers[i].credential});t.iceServers=n}return e.iceTransportPolicy&&(t.iceTransportPolicy=e.iceTransportPolicy),e.rtcpMuxPolicy&&(t.rtcpMuxPolicy=e.rtcpMuxPolicy),t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(n=k()(x().mark((function e(t){var n,i;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,i={status:n.status},n&&n.sessionDescription&&(i.sessionDescription=n.sessionDescription),e.abrupt("return",i);case 6:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(t=k()(x().mark((function e(t){var n,i;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,i={status:n.status,options:[]},n&&n.options&&(i.options=n.options),e.abrupt("return",i);case 6:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(e=k()(x().mark((function e(t){var n,i;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,i={status:n.status},e.abrupt("return",i);case 5:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,i,r,o,s,c,h,p,f,m,v}(),Je=n(701).A,Ke=function(){return u()((function e(t){if(a()(this,e),l()(this,"_logger",U.getLogger("Discovery")),l()(this,"_metricsService",void 0),l()(this,"_uri",void 0),!t)throw new Error("Discovery requires uri");this._metricsService=ge.getMetricsService(t.toString()),this._uri=t}),[{key:"discoverNearbyEndPoints",value:(t=k()(x().mark((function e(t,n){var i,r,o,a;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}throw new Error("Discovery requires timeout");case 2:return i=t.toString(),e.next=5,Je.race([d.A.fetch(i,{method:"GET",cache:"no-cache"}),new Je((function(e,t){return d.A.setTimeout((function(){return t(new Error("Discovery timed out [".concat(i,"]")))}),n)}))]);case 5:if((r=e.sent).ok){e.next=8;break}throw new Error("Discovery failed [".concat(i,"] [").concat(r.status,"]"));case 8:if(null!==r.body){e.next=10;break}throw new Error("Discovery failed with no data [".concat(i,"]"));case 10:return e.next=12,r.text();case 12:return o=e.sent,a=o.split(","),e.abrupt("return",a.map((function(e){return new We(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=k()(x().mark((function e(){var t,n,i,r,o,a,s=this,u=arguments;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=ue.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new d.A.URL(n),t);case 4:return i=e.sent,r=0,o=function(){return new Je((function(e,t){r>=i.length&&t("Discovery of [".concat(i.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))}))},e.next=9,Je.race(i.map((function(e){return e.ping().catch((function(t){return s._logger.warn("Failed to ping end point [%s]",e,t),r++,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:fe.RoundTripTime,runtime:(n-ye.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e}))})));case 9:return a=e.sent,e.abrupt("return",a);case 11:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]);var e,t}(),Qe=function(){function e(){throw a()(this,e),new Error("Discovery is a static class that may not be instantiated")}return u()(e,null,[{key:"precacheClosestEndPointDiscovery",value:(n=k()(x().mark((function t(){var n;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new d.A.URL(ye.discoveryUri.value),t.abrupt("return",e.discoverClosestEndPointWithCaching(n));case 2:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(t=k()(x().mark((function t(n){var i,r,o;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=n.toString(),!e._cache[i]){t.next=3;break}return t.abrupt("return",e._cache[i]);case 3:return r=new Ke(n),o=e._cache[i]=r.discoverClosestEndPoint(),e._cache[i].then((function(){d.A.setTimeout((function(){e._cache[i]===o&&delete e._cache[i]}),6e4)})).catch((function(){delete e._cache[i]})),t.abrupt("return",o);case 7:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})},{key:"clearCachedClosestEndpoint",value:function(t){var n=t.toString();e._cache[n]&&delete e._cache[n]}}]);var t,n}();l()(Qe,"_cache",{}),Qe.precacheClosestEndPointDiscovery();var Ze=function(){return u()((function e(t){a()(this,e),l()(this,"_sdp",void 0),l()(this,"_audioCodec",void 0),l()(this,"_videoCodec",void 0),l()(this,"_isAudioTrackEnabled",void 0),l()(this,"_isVideoTrackEnabled",void 0),this._sdp=t;var n=this._sdp.split(/(\r\n|\r|\n)/),i=this._sdp.split(/(?:^|[\r\n])m=/);this._audioCodec=this.applyCodec("audio",n),this._videoCodec=this.applyCodec("video",n),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",i),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",i)}),[{key:"audioCodec",get:function(){return this._audioCodec}},{key:"videoCodec",get:function(){return this._videoCodec}},{key:"isAudioTrackEnabled",get:function(){return this._isAudioTrackEnabled}},{key:"isVideoTrackEnabled",get:function(){return this._isVideoTrackEnabled}},{key:"isTrackByTypeEnabled",value:function(e,t){var n=t.find((function(t){return t.startsWith(e)}));return!!n&&!n.includes("a=inactive")}},{key:"applyCodec",value:function(e,t){return t.find((function(n){return n.includes("a=rtpmap:".concat(t.find((function(t){return t.includes("m=".concat(e))})).split(" ")[3]))})).split(" ")[1].split("/")[0]}}])}(),$e=function(){return u()((function e(t,n,i){if(a()(this,e),l()(this,"_estimatedRoundTripTime",void 0),l()(this,"_estimatedVideoCodec",void 0),l()(this,"_estimatedAudioCodec",void 0),l()(this,"_rtcStatistic",new K({})),l()(this,"_peerConnection",void 0),l()(this,"_isMonitorRunning",!0),l()(this,"_updateTimeout",void 0),l()(this,"_tracksToMonitor",void 0),this._peerConnection=t,this._estimatedRoundTripTime=i,this._tracksToMonitor=n.getTracks().map((function(e){return e.kind}))||[],this._peerConnection){if(!p.getCurrentOfferDisabled){var r=new Ze(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=r.audioCodec,this._estimatedVideoCodec=r.videoCodec}this.updateStatistic()}}),[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(d.A.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(t=k()(x().mark((function e(){var t,n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!p.getStatsPromiseBasedDisabled){e.next=5;break}return e.next=3,this.updateStatisticLegacy();case 3:return e.sent,e.abrupt("return");case 5:return t=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=8,this._peerConnection.getStats(null).then((function(e){var i={};if(e){var r,o=n._estimatedRoundTripTime;e.forEach((function(a){if("candidate-pair"===a.type&&a.currentRoundTripTime&&(o=1e3*a.currentRoundTripTime,i.audio&&(i.audio.roundTripTime=o),i.video&&(i.video.roundTripTime=o)),"candidate-pair"===a.type&&a.lastPacketReceivedTimestamp&&(r=a.lastPacketReceivedTimestamp,i.audio&&(i.audio.lastPacketReceivedTimestamp=r),i.video&&(i.video.lastPacketReceivedTimestamp=r)),"inbound-rtp"===a.type){var s=a.kind||a.mediaType||t(a),u="";if(e.forEach((function(e){e.id===a.codecId&&(u=e.mimeType)})),s&&n._tracksToMonitor.includes(s)){var c,l,d,h,p,f=(a.bytesReceived||0)-(null!==(c=null===(l=n._rtcStatistic.value)||void 0===l||null===(d=l[s])||void 0===d?void 0:d.bytesReceived)&&void 0!==c?c:0),m=a.timestamp-(null===(h=n._rtcStatistic.value)||void 0===h||null===(p=h[s])||void 0===p?void 0:p.timestamp),v=f&&m?Math.floor(8*f/m*1e3):0;if(i[s]={ssrc:a.ssrc,mediaType:s,timestamp:a.timestamp,bitrate:v,bytesReceived:a.bytesReceived,packetsLost:a.packetsLost,packetsReceived:a.packetsReceived,codec:u||n.getCodecByType(s),roundTripTime:o},(a.lastPacketReceivedTimestamp||r)&&(i[s].lastPacketReceivedTimestamp=a.lastPacketReceivedTimestamp||r),"video"===s&&n._rtcStatistic.value&&n._rtcStatistic.value.video){i[s].framesDecoded=a.framesDecoded;var g=(a.framesDecoded-n._rtcStatistic.value.video.framesDecoded)/(i[s].timestamp-n._rtcStatistic.value.video.timestamp)*1e3;i[s].fps=g?Math.round(100*g)/100:0}}}}))}n._rtcStatistic.value=i})).then((function(){n._isMonitorRunning&&(n._updateTimeout=d.A.setTimeout((function(){return n.updateStatistic()}),1e3))}));case 8:e.sent;case 9:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"updateStatisticLegacy",value:(e=k()(x().mark((function e(){var t=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.getStatsLegacy().then((function(e){var n={},i=t._estimatedRoundTripTime;e.result().forEach((function(e){if(e.names().forEach((function(t){"googRTT"===t&&(i=e.stat(t))})),"ssrc"===e.type){var r=e.stat("mediaType").toString();n[r]={timestamp:Date.now()},n[r].ssrc=e.stat("ssrc").toString(),n[r].mediaType=r,n[r].bytesReceived=e.stat("bytesReceived"),n[r].packetsLost=e.stat("packetsLost"),n[r].packetsReceived=e.stat("packetsReceived"),n[r].codec=e.stat("googCodecName").toString()||t.getCodecByType(r),n[r].roundTripTime=i,"video"===r&&t._rtcStatistic.value&&t._rtcStatistic.value.video&&(n[r].framesDecoded=e.stat("framesDecoded"),n[r].fps=(n[r].framesDecoded-t._rtcStatistic.value.video.framesDecoded)/(n[r].timestamp-t._rtcStatistic.value.video.timestamp)*1e3||0)}})),t._rtcStatistic.value=n})).then((function(){t._isMonitorRunning&&(t._updateTimeout=d.A.setTimeout((function(){return t.updateStatistic()}),1e3))}));case 2:e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec;case"video":return this._estimatedVideoCodec;default:return"unknown"}}}]);var e,t}(),Xe=function(){return u()((function e(){throw a()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")}),null,[{key:"truncateIceServers",value:function(e){for(var t=[],n=0;n<e.iceServers.length;n++){for(var i=[],r=0;r<2;r++)e.iceServers[n].urls[r]&&i.push(e.iceServers[n].urls[r]);t.push({urls:i,username:e.iceServers[n].username,credential:e.iceServers[n].credential})}return e.iceServers=t,e}}])}(),Ye=function(e){return e[e.BufferingPeriod=0]="BufferingPeriod",e[e.PictureTiming=1]="PictureTiming",e[e.PanScanRect=2]="PanScanRect",e[e.FillerPayload=3]="FillerPayload",e[e.UserDataRegistered=4]="UserDataRegistered",e[e.UserDataUnregistered=5]="UserDataUnregistered",e[e.RecoveryPoint=6]="RecoveryPoint",e[e.DecRefPicMarkingRepeition=7]="DecRefPicMarkingRepeition",e[e.SparePic=8]="SparePic",e[e.SceneInfo=9]="SceneInfo",e[e.SubSeqInfo=10]="SubSeqInfo",e[e.SubSeqLayerCharacteristics=11]="SubSeqLayerCharacteristics",e[e.SubSeqCharacteristics=12]="SubSeqCharacteristics",e[e.FullFrameFreeze=13]="FullFrameFreeze",e[e.FullFrameFreezeRelease=14]="FullFrameFreezeRelease",e[e.FullFrameSnapshot=15]="FullFrameSnapshot",e[e.ProgressiveRefinementSegmentStart=16]="ProgressiveRefinementSegmentStart",e[e.ProgressiveRefinementSegmentEnd=17]="ProgressiveRefinementSegmentEnd",e[e.MotionConstrainedSliceGroupSet=18]="MotionConstrainedSliceGroupSet",e[e.FilmGrainCharacteristic=19]="FilmGrainCharacteristic",e[e.DeblockingFilterDisplayReference=20]="DeblockingFilterDisplayReference",e[e.StereoVideoInfo=21]="StereoVideoInfo",e[e.PostFilterHint=22]="PostFilterHint",e[e.ToneMappingInfo=23]="ToneMappingInfo",e[e.ScalabilityInfo=24]="ScalabilityInfo",e[e.SubPicScalableLayer=25]="SubPicScalableLayer",e[e.NonRequiredLayerRep=26]="NonRequiredLayerRep",e[e.PariorityLayerInfo=27]="PariorityLayerInfo",e[e.LayersNotPresent=28]="LayersNotPresent",e[e.LayerDependencyChange=29]="LayerDependencyChange",e[e.ScalableNesting=30]="ScalableNesting",e[e.BaseLayerTemporalHrd=31]="BaseLayerTemporalHrd",e[e.QualityLayerIntegrityCheck=32]="QualityLayerIntegrityCheck",e[e.RedundantPicProperty=33]="RedundantPicProperty",e[e.Tl0DepRepIndex=34]="Tl0DepRepIndex",e[e.TlSwitchingPoint=35]="TlSwitchingPoint",e[e.ParallelDecodingInfo=36]="ParallelDecodingInfo",e[e.MvcScalableNesting=37]="MvcScalableNesting",e[e.ViewScalabilityInfo=38]="ViewScalabilityInfo",e[e.MultiviewSceneInfo=39]="MultiviewSceneInfo",e[e.MultiviewAcquisitionInfo=40]="MultiviewAcquisitionInfo",e[e.NonRequiredViewComponent=41]="NonRequiredViewComponent",e[e.ViewDependencyChange=42]="ViewDependencyChange",e[e.OperationPointsNotPresent=43]="OperationPointsNotPresent",e[e.BaseViewTemporalHdr=44]="BaseViewTemporalHdr",e[e.FramePackingArrangement=45]="FramePackingArrangement",e[e.MultiviewViewPosition=46]="MultiviewViewPosition",e[e.DisplayOrientation=47]="DisplayOrientation",e[e.MvcdScalableNesting=48]="MvcdScalableNesting",e[e.MvcdViewScalabilityInfo=49]="MvcdViewScalabilityInfo",e[e.DepthRepresentationInfo=50]="DepthRepresentationInfo",e[e.ThreeDimensionalReferenceDisplaysInfo=51]="ThreeDimensionalReferenceDisplaysInfo",e[e.DepthTiming=52]="DepthTiming",e[e.DepthSamplingInfo=53]="DepthSamplingInfo",e[e.ConstrainedDepthParameterSetIdentifier=54]="ConstrainedDepthParameterSetIdentifier",e[e.GreenMetadata=55]="GreenMetadata",e[e.MasteringDisplayColourVolumev=56]="MasteringDisplayColourVolumev",e[e.ColourRemappingInfo=57]="ColourRemappingInfo",e[e.ContentLightLevelInfo=58]="ContentLightLevelInfo",e[e.AlternativeTransferCharacteristics=59]="AlternativeTransferCharacteristics",e[e.AmbientViewingEnvironment=60]="AmbientViewingEnvironment",e[e.ContentColourVolume=61]="ContentColourVolume",e[e.EquirectangularProjection=62]="EquirectangularProjection",e[e.CubemapProjection=63]="CubemapProjection",e[e.SphereRotation=64]="SphereRotation",e[e.RegionwisePacking=65]="RegionwisePacking",e[e.OmniViewport=66]="OmniViewport",e[e.AlternativeDepthInfo=67]="AlternativeDepthInfo",e[e.SeiManifest=68]="SeiManifest",e[e.SeiPrefixIndication=69]="SeiPrefixIndication",e[e.AnnotatedRegions=70]="AnnotatedRegions",e[e.ShutterIntervalInfo=71]="ShutterIntervalInfo",e}(Ye||{}),et=Ye,tt=function(){return u()((function e(t){a()(this,e),l()(this,"_data",void 0),l()(this,"_bitOffset",void 0),this._data=t,this._bitOffset=0}),[{key:"readBits",value:function(e){if(this._bitOffset+e>8*this._data.length)throw new Error("Cannot read [".concat(e,"] bits - only [").concat(this.getRemainingBits(),"] bits remaining in stream"));for(var t=0,n=e;n>0;){var i=Math.floor(this._bitOffset/8),r=8-this._bitOffset%8,o=Math.min(n,r),a=(1<<o)-1;t=t<<o|this._data[i]>>r-o&a,n-=o,this._bitOffset+=o}return t}},{key:"skipBits",value:function(e){if(this._bitOffset+e>8*this._data.length)throw new Error("Cannot skip [".concat(e,"] bits - only [").concat(this.getRemainingBits(),"] bits remaining in stream"));this._bitOffset+=e}},{key:"getRemainingBits",value:function(){return 8*this._data.length-this._bitOffset}}])}(),nt=function(){return u()((function e(){throw a()(this,e),new Error("EmulationPreventionBytes is a static class that may not be instantiated")}),null,[{key:"getOffsetWithExpandedEmulationPreventionBytes",value:function(e,t,n){for(var i=0,r=0,o=n,a=t;a<e.length&&0!==o;a++,r++)2!==i||3!==e[a]?(0===e[a]?i++:i>0&&(i=0),o--):i=0;return r}},{key:"removeEmulationPreventionBytes",value:function(e){for(var t=new Uint8Array(e.byteLength),n=0,i=0,r=2;r<e.byteLength;r++)3===e[r]&&0===e[r-1]&&0===e[r-2]&&(t.set(e.subarray(i,r),n),n+=r-i,i=r+1);return i<e.byteLength&&t.set(e.subarray(i),n),t}}])}(),it=function(e){return e[e.ProgressiveFrame=0]="ProgressiveFrame",e[e.TopField=1]="TopField",e[e.BottomField=2]="BottomField",e[e.TopFieldBottomField=3]="TopFieldBottomField",e[e.BottomFieldTopField=4]="BottomFieldTopField",e[e.TopFieldBottomFieldTopFieldRepeated=5]="TopFieldBottomFieldTopFieldRepeated",e[e.BottomFieldTopFieldBottomFieldRepeated=6]="BottomFieldTopFieldBottomFieldRepeated",e[e.FrameDoubling=7]="FrameDoubling",e[e.FrameTripling=8]="FrameTripling",e}(it||{}),rt=function(){return u()((function e(){a()(this,e)}),[{key:"parse",value:function(e,t){var n=new tt(nt.removeEmulationPreventionBytes(e)),i={picStruct:void 0};if(t.cpbDpbDelaysPresentFlag&&(n.skipBits(t.cpbRemovalDelayLengthMinus1+1),n.skipBits(t.dpbOutputDelayLengthMinus1+1)),t.picStructPresentFlag){var r=this.convertPicStructToNumClockTS(n.readBits(4));i.picStruct={numClockTS:r,clockTimestamps:[]};for(var o=0;o<i.picStruct.numClockTS;o++){var a=1===n.readBits(1);if(a){var s={ctType:n.readBits(2),nuitFieldBasedFlag:1===n.readBits(1),countingType:n.readBits(5),fullTimestampFlag:1===n.readBits(1),discontinuityFlag:1===n.readBits(1),cntDroppedFlag:1===n.readBits(1),nFrames:n.readBits(8)};s.fullTimestampFlag?(s.seconds=n.readBits(6),s.minutes=n.readBits(6),s.hours=n.readBits(5)):1===n.readBits(1)&&(s.seconds=n.readBits(6),1===n.readBits(1)&&(s.minutes=n.readBits(6),1===n.readBits(1)&&(s.hours=n.readBits(5)))),s.timeOffset=n.readBits(24),i.picStruct.clockTimestamps.push({clockTimestampFlag:a,clockTimestamp:s})}else i.picStruct.clockTimestamps.push({clockTimestampFlag:!1})}}return i}},{key:"convertPicStructToNumClockTS",value:function(e){switch(e){case it.ProgressiveFrame:case it.TopField:case it.BottomField:return 1;case it.TopFieldBottomField:case it.BottomFieldTopField:case it.FrameDoubling:return 2;case it.TopFieldBottomFieldTopFieldRepeated:case it.BottomFieldTopFieldBottomFieldRepeated:case it.FrameTripling:return 3;default:return 0}}}])}();function ot(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}var at=function(){return u()((function e(){a()(this,e),l()(this,"_listeners",new Set)}),[{key:"subscribe",value:function(e){var t=this;return this._listeners.add(e),new q((function(){return t._listeners.delete(e)}))}},{key:"emit",value:function(e){var t,n=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 ot(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)?ot(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}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._listeners);try{for(n.s();!(t=n.n()).done;)(0,t.value)(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"dispose",value:function(){this.cleanUpResources()}},{key:"cleanUpResources",value:function(){this._listeners.clear()}}])}(),st=function(){return u()((function e(){a()(this,e),l()(this,"_eventEmitters",new Map),l()(this,"_onEventWithNoSubscriberHandlers",new Set),l()(this,"_disposables",new X)}),[{key:"onEventWithNoSubscriber",value:function(e){var t=this;return this._onEventWithNoSubscriberHandlers.add(e),new q((function(){return t._onEventWithNoSubscriberHandlers.delete(e)}))}},{key:"subscribe",value:function(e,t){var n=(this._eventEmitters.get(e)||this.createEmitter(e)).subscribe(t);return this._disposables.add(n),n}},{key:"publish",value:function(e,t){var n=this._eventEmitters.get(e);n?n.emit(t):this._onEventWithNoSubscriberHandlers.forEach((function(n){return n(e,t)}))}},{key:"dispose",value:function(){this._disposables.dispose(),this.cleanUpResources()}},{key:"cleanUpResources",value:function(){this._eventEmitters.clear(),this._onEventWithNoSubscriberHandlers.clear()}},{key:"createEmitter",value:function(e){var t=new at;return this._eventEmitters.set(e,t),t}}])}(),ut=function(e){return e[e.EncodedVideoStreamChunk=0]="EncodedVideoStreamChunk",e[e.NalUnit=1]="NalUnit",e[e.SeiPayload=2]="SeiPayload",e[e.Payload=3]="Payload",e[e.PayloadSubscription=4]="PayloadSubscription",e[e.EndOfChunk=5]="EndOfChunk",e}({}),ct=function(){return u()((function e(t){a()(this,e),l()(this,"_eventPublisher",void 0),l()(this,"_disposables",new X),this._eventPublisher=t}),[{key:"subscribeToNalUnit",value:function(e,t){return this._eventPublisher.subscribe(ut.NalUnit,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToSeiPayloadType",value:function(e,t){return this._eventPublisher.subscribe(ut.SeiPayload,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToPayload",value:function(e,t,n){return this._eventPublisher.publish(ut.PayloadSubscription,{context:e,data:t}),this._eventPublisher.subscribe(ut.Payload,(function(e){e.data.uuid===t&&n(e)}))}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),lt=function(){function e(){throw a()(this,e),new Error("Uint8Arrays is a static class that may not be instantiated")}return u()(e,null,[{key:"isDataAtOffsetTargetByteSequence",value:function(e,t,n){for(var i=0;i<e.length;i++)if(e[i]!==t[n+i])return!1;return!0}},{key:"findTargetByteSequenceIndexFromOffset",value:function(t,n,i){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,o=i;o<=n.byteLength;o++)if(e.isDataAtOffsetTargetByteSequence(t,n,o))return o;return r}},{key:"getUuidStringFromUint8Array",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,n=[],i=0;i<t;i++){var r=e[i].toString(16).padStart(2,"0");n.push(r),3!==i&&5!==i&&7!==i&&9!==i||n.push("-")}return n.join("")}}])}(),dt=function(e){return e[e.Unspecified=0]="Unspecified",e[e.SliceLayerNonIdrData=1]="SliceLayerNonIdrData",e[e.SliceDataPartitionALayer=2]="SliceDataPartitionALayer",e[e.SliceDataPartitionBLayer=3]="SliceDataPartitionBLayer",e[e.SliceDataPartitionCLayer=4]="SliceDataPartitionCLayer",e[e.SliceLayerIdrData=5]="SliceLayerIdrData",e[e.SupplementalEnhancementInformation=6]="SupplementalEnhancementInformation",e[e.SequenceParameterSet=7]="SequenceParameterSet",e[e.PictureParameterSet=8]="PictureParameterSet",e[e.AccessUnitDelimiter=9]="AccessUnitDelimiter",e[e.EndOfSequence=10]="EndOfSequence",e[e.EndOfStream=11]="EndOfStream",e[e.FillerData=12]="FillerData",e[e.SequenceParamterSetExtension=13]="SequenceParamterSetExtension",e[e.PrefixNalUnit=14]="PrefixNalUnit",e[e.SubsetSequenceParamterSet=15]="SubsetSequenceParamterSet",e[e.DepthParamterSet=16]="DepthParamterSet",e[e.Reserved17=17]="Reserved17",e[e.Reserved18=18]="Reserved18",e[e.SliceLayerAuxiliary=19]="SliceLayerAuxiliary",e[e.SliceExtension=20]="SliceExtension",e[e.SliceExtensionDepthViewComponent=21]="SliceExtensionDepthViewComponent",e[e.Reserved22=22]="Reserved22",e[e.Reserverd23=23]="Reserverd23",e[e.Unspecified24=24]="Unspecified24",e[e.Unspecified25=25]="Unspecified25",e[e.Unspecified26=26]="Unspecified26",e[e.Unspecified27=27]="Unspecified27",e[e.Unspecified28=28]="Unspecified28",e[e.Unspecified29=29]="Unspecified29",e[e.Unspecified30=30]="Unspecified30",e[e.Unspecified31=31]="Unspecified31",e}(dt||{}),ht=dt,pt=function(){function e(t,n){a()(this,e),l()(this,"_eventPublisher",void 0),l()(this,"_vclExtractionStrategy",void 0),l()(this,"_disposables",new X),this._eventPublisher=t,this._vclExtractionStrategy=n,this._disposables.add(this.subscribeToEncodedVideoStreamChunkEvents())}return u()(e,[{key:"dispose",value:function(){this._disposables.dispose()}},{key:"subscribeToEncodedVideoStreamChunkEvents",value:function(){return this._eventPublisher.subscribe(ut.EncodedVideoStreamChunk,this.parseEncodedVideoStreamChunk.bind(this))}},{key:"parseEncodedVideoStreamChunk",value:function(e){for(var t=e.context,n=e.data,i=0;i<n.byteLength;)i+=this.handleExtractedData(t,this.extractNalUnitAtOffset(n,i));this.notifyEndOfChunk(t)}},{key:"handleExtractedData",value:function(e,t){var n=t.annexBStartCodeLength,i=t.nalUnit,r=t.seiPayloads;return this.publishNalUnit(e,i),null==r||r.forEach(this.handleSeiPayload.bind(this,e)),i.data.byteLength+n}},{key:"handleSeiPayload",value:function(e,t){this.publishSeiPayload(e,t),t.type===et.UserDataUnregistered&&this.handleSeiPayloadUserDataUnregistered(e,t)}},{key:"handleSeiPayloadUserDataUnregistered",value:function(e,t){var n=lt.getUuidStringFromUint8Array(t.data.subarray(0,16)),i=t.data.subarray(16);this.publishPayload(e,{uuid:n,data:i})}},{key:"publishNalUnit",value:function(e,t){this._eventPublisher.publish(ut.NalUnit,{context:e,data:t})}},{key:"publishSeiPayload",value:function(e,t){this._eventPublisher.publish(ut.SeiPayload,{context:e,data:t})}},{key:"publishPayload",value:function(e,t){this._eventPublisher.publish(ut.Payload,{context:e,data:t})}},{key:"notifyEndOfChunk",value:function(e){this._eventPublisher.publish(ut.EndOfChunk,{context:e,data:null})}},{key:"extractNalUnitAtOffset",value:function(e,t){var n,i=1===e[t+2]?3:4,r=t+i,o=31&e[r];switch(o){case ht.SliceLayerNonIdrData:case ht.SliceDataPartitionALayer:case ht.SliceDataPartitionBLayer:case ht.SliceDataPartitionCLayer:case ht.SliceLayerIdrData:n=this._vclExtractionStrategy.extractVclNalUnit(e,r);break;case ht.SupplementalEnhancementInformation:n=this.extractSeiNalUnit(e,r);break;default:n=this.extractNonVclNalUnit(e,r)}return{annexBStartCodeLength:i,nalUnit:{type:o,data:n.nalUnitData},seiPayloads:n.seiPayloads}}},{key:"extractSeiNalUnit",value:function(t,n){for(var i=n+1,r=[];!lt.isDataAtOffsetTargetByteSequence(e._seiPayload4ByteEndCode,t,i)&&!lt.isDataAtOffsetTargetByteSequence(e._seiPayload3ByteEndCode,t,i)&&i<t.byteLength;){var o=this.extractSeiPayload(t,i);r.push({data:o.payload,type:o.payloadType}),i=o.endIndex}return i++,{nalUnitData:t.subarray(n,i),seiPayloads:r}}},{key:"extractNonVclNalUnit",value:function(t,n){var i=e.findAnnexBStartIndexFromOffset(t,n,t.byteLength);return{nalUnitData:t.subarray(n,i)}}},{key:"extractSeiPayload",value:function(e,t){for(var n=t,i=0;255===e[n];)n++,i++;var r=255*i+e[n];for(n++,i=0;255===e[n];)n++,i++;var o=255*i+e[n],a=++n+nt.getOffsetWithExpandedEmulationPreventionBytes(e,n,o);return{payloadType:r,payload:e.subarray(n,a),endIndex:a}}}],[{key:"findAnnexBStartIndexFromOffset",value:function(t,n,i){var r=lt.findTargetByteSequenceIndexFromOffset(e.annexB4ByteStartCode,t,n,i);return r!==i?r:lt.findTargetByteSequenceIndexFromOffset(e.annexB3ByteStartCode,t,n,i)}}])}();l()(pt,"annexB3ByteStartCode",new Uint8Array([0,0,1])),l()(pt,"annexB4ByteStartCode",new Uint8Array([0,0,0,1])),l()(pt,"_seiPayload3ByteEndCode",new Uint8Array([128,0,0,1])),l()(pt,"_seiPayload4ByteEndCode",new Uint8Array([128,0,0,0,1]));var ft=function(){return u()((function e(){a()(this,e)}),[{key:"extractVclNalUnit",value:function(e,t){var n=pt.findAnnexBStartIndexFromOffset(e,t,e.byteLength);return{nalUnitData:e.subarray(t,n)}}}])}(),mt=function(){function e(){a()(this,e)}return u()(e,[{key:"extractVclNalUnit",value:function(t,n){var i=n+pt.annexB4ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;if(lt.isDataAtOffsetTargetByteSequence(pt.annexB4ByteStartCode,t,i))return{nalUnitData:t.subarray(n+pt.annexB4ByteStartCode.byteLength,i)};var r=n+pt.annexB3ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;return lt.isDataAtOffsetTargetByteSequence(pt.annexB3ByteStartCode,t,r)?{nalUnitData:t.subarray(n+pt.annexB3ByteStartCode.byteLength,r)}:{nalUnitData:t.subarray(n)}}}])}();l()(mt,"_truncatedVclNalUnitByteLength",32);var vt=function(){},gt=function(){function e(t){a()(this,e),l()(this,"_logger",U.getLogger("PhenixEmbeddedIsoBmff2023")),l()(this,"_eventPublisher",void 0),l()(this,"_expectedPayloadUuid",new Set),l()(this,"_endOfChunkHandlersByTrackId",new Map),l()(this,"_disposables",new X),l()(this,"_enableWarningLogWhenVclEmbeddedDataNotFound",new q(this.enableWarningLogWhenVclEmbeddedDataNotFound.bind(this))),this._eventPublisher=t,this._expectedPayloadUuid.add(e._phenixVclEmbeddedDataUuid),this._expectedPayloadUuid.add(e._phenixInitializationSegmentUuid),this._disposables.add(this.subscribeToPayloadEvents()),this._disposables.add(this.subscribeToPayloadSubscriptionEvents()),this._disposables.add(this.subscribeToNalUnitEvents())}return u()(e,[{key:"subscribeToEmbeddedData",value:function(t){return this._enableWarningLogWhenVclEmbeddedDataNotFound.dispose(),this._eventPublisher.subscribe(ut.Payload,(function(n){var i=n.context,r=n.data;switch(r.uuid){case e._phenixInitializationSegmentUuid:t({context:i,data:{type:"Initialization",data:r.data}});break;case e._phenixVclEmbeddedDataUuid:t({context:i,data:{type:"Media",data:r.data}})}}))}},{key:"dispose",value:function(){this._disposables.dispose(),this._endOfChunkHandlersByTrackId.clear(),this._expectedPayloadUuid.clear()}},{key:"enableWarningLogWhenVclEmbeddedDataNotFound",value:function(){this._disposables.add(this.subscribeToEncodedVideoStreamChunkEvents()),this._disposables.add(this.subscribeToEndOfChunkEvents())}},{key:"subscribeToPayloadSubscriptionEvents",value:function(){var e=this;return this._eventPublisher.subscribe(ut.PayloadSubscription,(function(t){var n=t.data;return e._expectedPayloadUuid.add(n)}))}},{key:"subscribeToEncodedVideoStreamChunkEvents",value:function(){return this._eventPublisher.subscribe(ut.EncodedVideoStreamChunk,this.armLoggingNoVclEmbeddedDataFound.bind(this))}},{key:"subscribeToNalUnitEvents",value:function(){return this._eventPublisher.subscribe(ut.NalUnit,this.handleNalUnitEvent.bind(this))}},{key:"handleNalUnitEvent",value:function(t){var n=t.context,i=t.data;i.type>ht.SliceLayerIdrData||i.data.byteLength<e._truncatedVclNalUnitDataByteLength||(this.publishVclEmbeddedPayload(n,{uuid:e._phenixVclEmbeddedDataUuid,data:this.extractVclEmbeddedData(i)}),this.disarmLoggingNoVclEmbeddedDataFound(n.trackId))}},{key:"extractVclEmbeddedData",value:function(t){return t.data.subarray(e._truncatedVclNalUnitDataByteLength)}},{key:"publishVclEmbeddedPayload",value:function(e,t){this._eventPublisher.publish(ut.Payload,{context:e,data:t})}},{key:"armLoggingNoVclEmbeddedDataFound",value:function(e){var t=e.context;this._endOfChunkHandlersByTrackId.set(t.trackId,this.logWarningVclEmbeddedDataNotFound.bind(this,t.trackId))}},{key:"disarmLoggingNoVclEmbeddedDataFound",value:function(e){this._endOfChunkHandlersByTrackId.set(e,vt)}},{key:"logWarningVclEmbeddedDataNotFound",value:function(e){this._logger.warn("[%s] [%s] No VCL embedded data found in an encoded video stream chunk from track with id [%s]",e.streamId,e.contextId,e.trackId)}},{key:"subscribeToEndOfChunkEvents",value:function(){return this._eventPublisher.subscribe(ut.EndOfChunk,this.handleEndOfEncodedVideoStreamChunk.bind(this))}},{key:"handleEndOfEncodedVideoStreamChunk",value:function(e){var t=e.context;this._endOfChunkHandlersByTrackId.get(t.trackId)()}},{key:"subscribeToPayloadEvents",value:function(){return this._eventPublisher.subscribe(ut.Payload,this.handlePayloadEvent.bind(this))}},{key:"handlePayloadEvent",value:function(e){var t=e.context,n=e.data;this._expectedPayloadUuid.has(n.uuid)||d.A.setTimeout(this.logWarningUnexpectedPayloadUuidReceivedOnce.bind(this,t,n.uuid))}},{key:"logWarningUnexpectedPayloadUuidReceivedOnce",value:function(e,t){this._logger.warn("[%s] [%s] [%s] Received unexpected payload with uuid [%s]",e.streamId,e.contextId,e.trackId,t),this._expectedPayloadUuid.add(t)}}])}();l()(gt,"_truncatedVclNalUnitDataByteLength",32),l()(gt,"_phenixVclEmbeddedDataUuid","00000000-0000-0000-0000-000000000000"),l()(gt,"_phenixInitializationSegmentUuid","511e22bd-34c0-4cee-b6c3-3c4d407622c7");var _t=function(){return u()((function e(t,n,i){a()(this,e),l()(this,"_eventPublisher",void 0),l()(this,"_bitstream",void 0),l()(this,"_parser",void 0),l()(this,"_disposables",new X),this._eventPublisher=t,this._bitstream=n,this._parser=i,this._disposables.add(this._bitstream),this._disposables.add(this._parser)}),[{key:"bitstream",get:function(){return this._bitstream}},{key:"decode",value:function(e){this._eventPublisher.publish(ut.EncodedVideoStreamChunk,e)}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),yt=function(){return u()((function e(t,n){a()(this,e),l()(this,"_h264VideoBitstreamDecoder",void 0),l()(this,"_encoding",void 0),l()(this,"_disposables",void 0),this._h264VideoBitstreamDecoder=t,this._encoding=n,this._disposables=new X,this._disposables.add(this._h264VideoBitstreamDecoder),this._disposables.add(this._encoding)}),[{key:"bitstream",get:function(){return this._h264VideoBitstreamDecoder.bitstream}},{key:"decode",value:function(e){this._h264VideoBitstreamDecoder.decode(e)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"subscribeToEmbeddedData",value:function(e,t){return t?this._encoding.subscribeToEmbeddedData((function(n){n.trackId===t&&e(n)})):this._encoding.subscribeToEmbeddedData(e)}}])}(),bt=function(){return u()((function e(){throw a()(this,e),new Error("BitstreamDecoders is a static class that may not be instantiated")}),null,[{key:"createH264VideoBitstreamDecoder",value:function(){var e=new st,t=new ct(e),n=new pt(e,new ft);return new _t(e,t,n)}},{key:"createPhenixH264EmbeddedIsoBmff2023VideoBitstreamDecoder",value:function(){var e=new st,t=new ct(e),n=new pt(e,new mt),i=new _t(e,t,n),r=new gt(e);return new yt(i,r)}}])}();function Ct(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function kt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ct(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ct(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function St(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}var xt,wt=function(){function e(t,n){var i=this;a()(this,e),l()(this,"_channelContext",void 0),l()(this,"_frameTimingInformationContext",void 0),l()(this,"_bitstreamDecoder",bt.createH264VideoBitstreamDecoder()),l()(this,"_frameTimingsByRtpTimestamp",new Map),l()(this,"_picturingTimingParsingConfig",{cpbDpbDelaysPresentFlag:!1,picStructPresentFlag:!0}),l()(this,"_pictureTimingParser",new rt),l()(this,"_videoElementDisposables",new X),l()(this,"_currentPlaybackState","waiting"),l()(this,"_armedVideoFrameCallbackId",null),l()(this,"_disposables",new X),l()(this,"_disposed",!1),this._channelContext=t,this._frameTimingInformationContext=n,this._disposables.add(this._bitstreamDecoder),this._disposables.add(new q((function(){return i._frameTimingsByRtpTimestamp.clear()}))),this._disposables.add(this._videoElementDisposables),this._channelContext.videoElement.value&&this.setupVideoEventListeners(this._channelContext.videoElement.value),this._disposables.add(this._channelContext.videoElement.subscribe((function(e){i._videoElementDisposables.dispose(),e&&i.setupVideoEventListeners(e)}))),this._frameTimingInformationContext.shouldExtractTimecode.value&&this._disposables.add(this._bitstreamDecoder.bitstream.subscribeToSeiPayloadType(et.PictureTiming,this.onPictureTimingExtracted.bind(this)))}return u()(e,[{key:"processFrame",value:function(e,t,n,i){if(!this._disposed){var r={mid:t,trackId:n,receiveTimestamp:new Date};this.removeFrameTimingsExceedingMaxCapacity();var o=i.timestamp.toString(10);this._frameTimingsByRtpTimestamp.has(o),this._frameTimingsByRtpTimestamp.set(o,r),this._bitstreamDecoder.decode({context:{streamId:e,trackId:n,contextId:o},data:new Uint8Array(i.data)})}}},{key:"dispose",value:function(){this._disposed=!0,this._disposables.dispose()}},{key:"onPictureTimingExtracted",value:function(e){var t,n,i,r,o,a=e.context,s=a.contextId,u=a.trackId,c=e.data;if(!this._disposed){var l=null===(t=this._pictureTimingParser.parse(c.data,this._picturingTimingParsingConfig).picStruct)||void 0===t||null===(n=t.clockTimestamps.find((function(e){return!0===e.clockTimestampFlag})))||void 0===n?void 0:n.clockTimestamp;if(l){var d=this._frameTimingsByRtpTimestamp.get(s);if(d){var h={mid:d.mid,trackId:u,kind:"video",codec:"H264",timecode:{hours:null!==(i=l.hours)&&void 0!==i?i:null,minutes:null!==(r=l.minutes)&&void 0!==r?r:null,seconds:null!==(o=l.seconds)&&void 0!==o?o:null,frames:l.nFrames,isFrameDrop:l.countingType>1},sourceTimestamp:null,ingestTimestamp:null,encodeTimestamp:null,transcodeTimestamp:null,receiveTimestamp:new Date(d.receiveTimestamp),playbackState:this._currentPlaybackState};d.decodedFrameTimingInformation=h,this._frameTimingInformationContext.decodedFrameTimingInformation.value=h}}}}},{key:"videoFrameCallback",value:function(e,t){if(!this._disposed){this.armVideoFrameCallback();var n=t.rtpTimestamp;if(n){var i,r=[],o=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 St(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)?St(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}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._frameTimingsByRtpTimestamp);try{for(o.s();!(i=o.n()).done;){var a=ze()(i.value,2),s=a[0],u=a[1];if(parseInt(s,10)>n)break;"playing"===this._currentPlaybackState&&(this._frameTimingInformationContext.renderedFrameTimingInformation.value=kt(kt({},u.decodedFrameTimingInformation),{},{renderTimestamp:new Date(performance.timeOrigin+e),playbackState:"playing"})),r.push(s)}}catch(e){o.e(e)}finally{o.f()}for(var c=0,l=r;c<l.length;c++){var d=l[c];this._frameTimingsByRtpTimestamp.delete(d)}}}}},{key:"removeFrameTimingsExceedingMaxCapacity",value:function(){var t=this._frameTimingsByRtpTimestamp.size-(e.MAX_FRAME_TIMING_ENTRIES-1);if(!(t<=0))for(var n=this._frameTimingsByRtpTimestamp.keys(),i=0;i<t;i++){var r=n.next().value;this._frameTimingsByRtpTimestamp.delete(r)}}},{key:"setupVideoEventListeners",value:function(e){var t=this,n=function(){return t._currentPlaybackState="playing"};e.addEventListener("playing",n),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("playing",n)})));var i=function(){return t._currentPlaybackState="paused"};e.addEventListener("pause",i),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("pause",i)})));var r=function(){return t._currentPlaybackState="stalled"};e.addEventListener("stalled",r),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("stalled",r)})));var o=function(){return t._currentPlaybackState="waiting"};e.addEventListener("waiting",o),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("waiting",o)})));var a=function(){return t._currentPlaybackState="ended"};e.addEventListener("ended",a),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("ended",a)})));var s=function(){return t._currentPlaybackState="error"};e.addEventListener("error",s),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("error",s)}))),this.armVideoFrameCallback(),this._videoElementDisposables.add(new q((function(){var e;t._armedVideoFrameCallbackId&&(null===(e=t._channelContext.videoElement.value)||void 0===e||e.cancelVideoFrameCallback(t._armedVideoFrameCallbackId))})))}},{key:"armVideoFrameCallback",value:function(){var e;this._armedVideoFrameCallbackId=null===(e=this._channelContext.videoElement.value)||void 0===e?void 0:e.requestVideoFrameCallback(this.videoFrameCallback.bind(this))}}])}();l()(wt,"MAX_FRAME_TIMING_ENTRIES",1800);var Tt=Symbol(),Pt=function(){function e(){throw a()(this,e),new Error("SurrogateFrameDataManager is a static class that may not be instantiated")}return u()(e,null,[{key:"getSurrogateAudioSilentPerCodec",value:function(t){if("OPUS"===t.toUpperCase())return e._dummyAudioSilentPerCodec.OPUS.buffer}},{key:"getInvalidSurrogateAudioData",value:function(){return e._singleZeroByte.buffer}},{key:"getSurrogateVideoIFramePerCodec",value:function(t){switch(t.toUpperCase()){case"H264":return e._useUpdateSurrogate82x82PFrameFrameNumber?(e._surrogate82x82PFrameFrameNumber=e._surrogate82x82PFrameFrameNumberReset,e._dummy82x82H264.IFrame.buffer):e._dummy2x2VideoIFramePerCodec.H264.buffer;case"VP8":return e._dummy2x2VideoIFramePerCodec.VP8.buffer;case"VP9":return e._dummy2x2VideoIFramePerCodec.VP9.buffer;default:return}}},{key:"getInvalidSurrogateVideoIFrame",value:function(t){return"H264"===t.toUpperCase()&&e._useUpdateSurrogate82x82PFrameFrameNumber&&(e._surrogate82x82PFrameFrameNumber=e._surrogate82x82PFrameFrameNumberReset,e._isAndroidChrome)?Tt:e._singleZeroByte.buffer}},{key:"getSurrogateVideoPFramePerCodec",value:function(t){switch(t.toUpperCase()){case"H264":return e._useUpdateSurrogate82x82PFrameFrameNumber?e.getSurrogate82x82PFrameAndUpdateFrameNumber():e._dummy2x2VideoPFramePerCodec.H264.buffer;case"VP8":return e._dummy2x2VideoPFramePerCodec.VP8.buffer;case"VP9":return e._dummy2x2VideoPFramePerCodec.VP9.buffer;default:return}}},{key:"getInvalidSurrogateVideoPFrame",value:function(t){if("H264"===t.toUpperCase()&&e._useUpdateSurrogate82x82PFrameFrameNumber){var n=e._surrogate82x82PFrameFrameNumber,i=e.getSurrogate82x82PFrameAndUpdateFrameNumber();return n>e._surrogate82x82PFrameFrameNumberReset?e._isAndroidChrome?Tt:e._singleZeroByte.buffer:(e._surrogate82x82PFrameFrameNumber++,i)}return e._singleZeroByte.buffer}},{key:"getSurrogate82x82PFrameAndUpdateFrameNumber",value:function(){var t=(14&e._surrogate82x82PFrameFrameNumber)>>1,n=(1&e._surrogate82x82PFrameFrameNumber)<<7,i=e._dummy82x82H264.PFrame.slice().buffer,r=e._dummy82x82H264PFrameFrameNumberIndex;return i[r]|=t,i[r+1]|=n,e._surrogate82x82PFrameFrameNumber++,i}}])}();xt=Pt,l()(Pt,"_isSafari","Safari"===h.browserName),l()(Pt,"_isMobileChrome","Chrome"===h.browserName&&h.isMobile()),l()(Pt,"_isAndroidChrome","Chrome"===h.browserName&&h.isAndroid),l()(Pt,"_singleZeroByte",new Uint8Array([0])),l()(Pt,"_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])}),l()(Pt,"_dummy2x2VideoIFramePerCodec",{H264:new Uint8Array([0,0,0,1,9,240,0,0,0,1,103,244,0,10,145,155,43,241,241,248,8,128,0,0,3,0,128,0,0,25,7,137,18,203,0,0,0,1,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])}),l()(Pt,"_dummy2x2VideoPFramePerCodec",{H264:new Uint8Array([0,0,0,1,9,240,0,0,0,1,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])}),l()(Pt,"_dummy82x82H264",{IFrame:new Uint8Array([0,0,0,1,103,66,192,13,218,24,222,34,34,16,0,0,3,0,16,0,0,3,3,200,241,66,170,0,0,0,1,104,206,15,200,0,0,0,1,6,3].concat(de()(new Uint8Array(40).fill(255)),[95],de()(new Uint8Array(10295).fill(255)),[128,0,0,0,1,101,136,132,5],de()(new Uint8Array(3).fill(255)),[15,69,0,1,87,159,39,39,39,39,39,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,120])),PFrame:new Uint8Array([0,0,0,1,6,3].concat(de()(new Uint8Array(40).fill(255)),[164],de()(new Uint8Array(10364).fill(255)),[128,0,0,0,1,65,154,32,21,240,75]))}),l()(Pt,"_dummy82x82H264PFrameFrameNumberIndex",10418),l()(Pt,"_surrogate82x82PFrameFrameNumberReset",1),l()(Pt,"_useUpdateSurrogate82x82PFrameFrameNumber",xt._isMobileChrome||xt._isSafari),l()(Pt,"_surrogate82x82PFrameFrameNumber",xt._surrogate82x82PFrameFrameNumberReset);var Et=function(){return u()((function e(){throw a()(this,e),new Error("InsertableStreams is a static class that may not be instantiated")}),null,[{key:"configureEncodedStreamPipeline",value:function(e,t,i,r,o,a){var s=new X,u=new K(null),c=new K(null);return e.getTracks().forEach((function(e){var l=t.filter((function(t){return t.track===e}))[0],d=e.kind;switch(d){case"video":var h=!!i;if(p.isRTCRtpScriptTransformSupported){var f=new Worker(new URL(n.p+n.u(63),n.b),{type:void 0});f.onmessage=function(){var t=k()(x().mark((function t(n){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n.data.chunk},t.t0=h,!t.t0){t.next=6;break}return t.next=5,i(e,n.data.chunk);case 5:t.t0=!t.sent;case 6:if(!t.t0){t.next=8;break}f.postMessage({forceInvalidFrame:!0});case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),l.transform=new RTCRtpScriptTransform(f,{kind:e.kind,codec:o,mustSink:h}),s.add(new q((function(){f.terminate()})));break}var m=function(){var t=k()(x().mark((function t(n,r){var a;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n},!h){t.next=12;break}return t.next=4,i(e,n);case 4:if(t.sent){t.next=11;break}if((a="key"===n.type?Pt.getInvalidSurrogateVideoIFrame(o):Pt.getInvalidSurrogateVideoPFrame(o))!==Tt){t.next=8;break}return t.abrupt("return");case 8:n.data=a||n.data,t.next=12;break;case 11:"key"===n.type?n.data=Pt.getSurrogateVideoIFramePerCodec(o)||n.data:n.data=Pt.getSurrogateVideoPFramePerCodec(o)||n.data;case 12:r.enqueue(n);case 13:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),v=new TransformStream({transform:m}),g=l.createEncodedStreams(),_=g.readable,y=g.writable;_.pipeThrough(v).pipeTo(y);break;case"audio":var b=!!r;if(p.isRTCRtpScriptTransformSupported){var C=new Worker(new URL(n.p+n.u(444),n.b),{type:void 0});C.onmessage=function(){var t=k()(x().mark((function t(n){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(c.value={track:e,chunk:n.data.chunk},t.t0=b,!t.t0){t.next=6;break}return t.next=5,r(e,n.data.chunk);case 5:t.t0=!t.sent;case 6:if(!t.t0){t.next=8;break}C.postMessage({forceInvalidFrame:!0});case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),l.transform=new RTCRtpScriptTransform(C,{kind:e.kind,codec:a,mustSink:b});var S=new MediaStream,w=new Audio;w.srcObject=S,document.body.appendChild(w),s.add(new q((function(){C.terminate(),document.body.removeChild(w)})));break}var T=function(){var t=k()(x().mark((function t(n,i){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(c.value={track:e,chunk:n},!b){t.next=9;break}return t.next=4,r(e,n);case 4:if(t.sent){t.next=8;break}n.data=Pt.getInvalidSurrogateAudioData(),t.next=9;break;case 8:n.data=Pt.getSurrogateAudioSilentPerCodec(a)||n.data;case 9:i.enqueue(n);case 10:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),P=new TransformStream({transform:T}),E=l.createEncodedStreams(),F=E.readable,R=E.writable;F.pipeThrough(P).pipeTo(R);break;default:L(d)}})),{disposables:s,encodedVideoFrame:u,encodedAudioFrame:c}}},{key:"configureInsertableStreamTransformation",value:function(e,t,n){var i=new MediaStream,r=new X;return e.getTracks().forEach((function(e){var o=e.kind;switch(o){case"video":if(t){var a=e,s=new TransformStream({transform:function(n,i){t(e,n,i)}}),u=new MediaStreamTrackProcessor({track:a}),c=new MediaStreamTrackGenerator({kind:a.kind}),l=u.readable,d=c.writable;l.pipeThrough(s).pipeTo(d),i.addTrack(c),r.add(new q((function(){i.removeTrack(c)})))}else i.addTrack(e);break;case"audio":if(n){var h=e,p=new TransformStream({transform:function(t,i){n(e,t,i)}}),f=new MediaStreamTrackProcessor({track:h}),m=new MediaStreamTrackGenerator({kind:h.kind}),v=f.readable,g=m.writable;v.pipeThrough(p).pipeTo(g),i.addTrack(m);var _=new MediaStream,y=new Audio;_.addTrack(e),y.srcObject=_,document.body.appendChild(y),r.add(new q((function(){i.removeTrack(m),document.body.removeChild(y)})))}else i.addTrack(e);break;default:L(o)}})),{transformedStream:i,disposables:r}}}])}(),Ft=n(701).A;function Rt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function It(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Rt(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Rt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Dt=function(){return u()((function e(t,n,i,r,o){a()(this,e),l()(this,"_logger",U.getLogger("RealTimeStream")),l()(this,"_channelContext",void 0),l()(this,"_peerConnectionContext",void 0),l()(this,"_streamTransformContext",void 0),l()(this,"_frameTimingInformationContext",void 0),l()(this,"_handleStreamFailure",void 0),l()(this,"_disposables",void 0),this._channelContext=t,this._peerConnectionContext=n,this._streamTransformContext=i,this._frameTimingInformationContext=r,this._handleStreamFailure=o,this._disposables=new X,this._channelContext.disposables.add(this)}),[{key:"start",value:function(e,t,n,i){var r=this,o=this._streamTransformContext.hasEncodedInsertableStreams.value||this._frameTimingInformationContext.shouldExtractTimecode.value||this._frameTimingInformationContext.shouldExtractTimestamps.value;return Ft.all([Qe.discoverClosestEndPointWithCaching(e),re.createPeerConnectionOffer("recvonly",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=ze()(e,2),i=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;return r._channelContext.online.value=!0,r._channelContext.endPoint.value=i,r._logger.info("Connecting to [%s]",i.toString()),r._logger.info("Local offer:\n"+a.sdp),!p.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration||(s.close(),s.dispose(),!ye.forceGarbageCollectionOnRestart||p.isMobile&&ye.skipGarbageCollectionOnMobileDevices||Ce.forceGarbageCollection(),s=null,a=null,r._peerConnectionContext.peerConnection.value=s),i.subscribe(t,a,r._channelContext.failureCount.value)})).then((function(e){var t=e.status,a=e.stream,s=e.rtcConfiguration,u=e.setRemoteDescriptionResponse,c=e.createOfferDescriptionResponse,l=e.createAnswerDescriptionResponse,h=e.lag;if(r._channelContext.stream.value=a,r._channelContext.lag.value=h,r._channelContext.applySessionAndStreamPropertiesToVideoElement(),r._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",r._channelContext.streamId,t,s,u,c,l),r._channelContext.state.value=r._channelContext.mapSubscribeStatusToChannelStatus(t),r._channelContext.applyStatus(t),"ok"===t)return r.applyRtcConfiguration(r._peerConnectionContext.peerConnection.value,s).then((function(e){var t,s=!1,h=!1,f=[];r._peerConnectionContext.peerConnection.value||(r._peerConnectionContext.peerConnection.value=e),e.onicecandidate=function(n){r._channelContext.stream.value===a&&r._peerConnectionContext.peerConnection.value===e&&(s||ye.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?f.push(n.candidate):h=!0,t||(t=d.A.setTimeout((function(){r._channelContext.stream.value!==a||s||r._channelContext.endPoint.value.addIceCandidates(a,f,h).then((function(e){var t=e.status,n=e.options;"ok"===t?(n.includes("cancel")&&(s=!0),r._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",r._channelContext.streamId,t,n)):r._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",r._channelContext.streamId,t)})).catch((function(e){r._logger.error("[%s] Failed to add ICE candidates",r._channelContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(r._channelContext.stream.value===a&&r._peerConnectionContext.peerConnection.value===e){var t=function(){r._channelContext.state.value=Se.ConnectionError,r._channelContext.videoElement.value&&(r._channelContext.videoElement.value.pause(),r._channelContext.videoElement.value.srcObject=null),r._channelContext.playing.value=!1,r._channelContext.loading.value=!0,r._handleStreamFailure().catch((function(t){r._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",r._channelContext.streamId,e.iceConnectionState,t)}))};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return void(d.A.navigatorIsOnLine&&(r._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",r._channelContext.streamId,e.iceConnectionState),r.reconnectPeerConnection(e,t)));case"closed":return r._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",r._channelContext.streamId,e.iceConnectionState),void t();default:L(e.iceConnectionState)}}};var m=new Ft((function(t,n){if(p.onTrackDisabled){var i=function(n){d.A.clearTimeout(r),e.removeEventListener("track",i),e.removeEventListener("addstream",i),n.streams?t(n.streams[0]):t(n.stream)},r=d.A.setTimeout((function(){e.removeEventListener("track",i),e.removeEventListener("addstream",i),n(new Error("Stream setup timed out"))}),3e4);e.addEventListener("track",i),e.addEventListener("addstream",i)}else{var o=d.A.setTimeout((function(){return n(new Error("Stream setup timed out"))}),3e4);e.ontrack=function(e){d.A.clearTimeout(o),t(e.streams[0])}}}));return new Ft((function(e){e()})).then((function(){if(u)return r._logger.info("[%s] Set local SDP offer [%s]",r._channelContext.streamId,u.sessionDescription.sdp),e.setLocalDescription(u.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._channelContext.streamId,u.sessionDescription,e.message),e}))})).then((function(){if(l)return r._logger.info("[%s] Set remote SDP answer [%s]",r._channelContext.streamId,l.sessionDescription.sdp),e.setRemoteDescription(l.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._channelContext.streamId,l.sessionDescription,e.message),e}))})).then((function(){if(c)return r._logger.info("[%s] Set remote SDP offer [%s]",r._channelContext.streamId,c.sessionDescription.sdp),e.setRemoteDescription(c.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._channelContext.streamId,c.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})})).then((function(e){return r._logger.info("[%s] Set local SDP answer [%j]",r._channelContext.streamId,e),r._channelContext.endPoint.value.setRemoteDescription(a,e)})).then((function(t){var n=t.status,i=t.sessionDescription;return r._channelContext.state.value=r.mapSetRemoteDescriptionStatusToChannelStatus(n),"ok"!==n?(r._channelContext.playing.value=!1,r._channelContext.standby.value=!0,void(r._channelContext.stopped.value=!1)):e.setLocalDescription(i).catch((function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._channelContext.streamId,i,e.message),e}))}))})).then((function(){return n.success(r._channelContext.streamId),m})).then((function(t){if(o){var n=new Ze(e.currentRemoteDescription.sdp),a=e.getReceivers(),s=Et.configureEncodedStreamPipeline(t,a,r._streamTransformContext.encodedVideoStreamSink,r._streamTransformContext.encodedAudioStreamSink,n.videoCodec,n.audioCodec),u=s.disposables,c=s.encodedVideoFrame;if("H264"===n.videoCodec.toUpperCase()&&(r._frameTimingInformationContext.shouldExtractTimecode.value||r._frameTimingInformationContext.shouldExtractTimestamps.value)){var l=new wt(r._channelContext,r._frameTimingInformationContext);r._disposables.add(l),t.getVideoTracks().forEach((function(t){var n,i=a.filter((function(e){return e.track===t}))[0],o=e.supportsGetTransceivers?null===(n=e.getTransceivers().filter((function(e){return e.receiver===i}))[0])||void 0===n?void 0:n.mid:null;i?o?(r._disposables.add(c.subscribe((function(e){e&&l.processFrame(r._channelContext.streamId,o,e.track.id,e.chunk)}))),r._frameTimingInformationContext.isEnabled.value=!0):r._logger.warn("[%s] Skipping frame timing information for track [%s] because no mid was found",r._channelContext.streamId,t.id):r._logger.warn("[%s] Skipping frame timing information for track [%s] because no receiver was found",r._channelContext.streamId,t.id)}))}r._disposables.add(u)}if(r._streamTransformContext.hasInsertableStreams.value){var h=Et.configureInsertableStreamTransformation(t,r._streamTransformContext.videoStreamTransformCallback,r._streamTransformContext.audioStreamTransformCallback),p=h.transformedStream,f=h.disposables;r._disposables.add(f),t=p}r._peerConnectionContext.mediaStream.value=t;var m=new $e(e,t,r._channelContext.endPoint.value.roundTripTime/4);r._disposables.add(m);var v=m.rtcStatistic.subscribe((function(t){if(r._channelContext.rtcStatistics.value=t,!r._channelContext.rtcVideoStatistic&&!r._channelContext.rtcAudioStatistic)return r._channelContext.rtcAudioStatistic=t.audio,void(r._channelContext.rtcVideoStatistic=t.video);var n=!1,i=!1;if(t.audio&&r._channelContext.rtcAudioStatistic&&r._channelContext.rtcAudioStatistic.timestamp!==t.audio.timestamp&&((n=r._channelContext.rtcAudioStatistic&&r._channelContext.rtcAudioStatistic.bytesReceived===t.audio.bytesReceived)&&d.A.navigatorIsOnLine&&r._logger.info("[%s] Audio track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",r._channelContext.streamId,t.audio.bytesReceived,r._channelContext.rtcAudioStatistic.bytesReceived,new xe(t.audio.timestamp-r._channelContext.rtcAudioStatistic.timestamp).toIsoString()),r._channelContext.rtcAudioStatistic=t.audio),t.video&&r._channelContext.rtcVideoStatistic&&r._channelContext.rtcVideoStatistic.timestamp!==t.video.timestamp&&((i=r._channelContext.rtcVideoStatistic&&r._channelContext.rtcVideoStatistic.bytesReceived===t.video.bytesReceived)&&d.A.navigatorIsOnLine&&r._logger.info("[%s] Video track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",r._channelContext.streamId,t.video.bytesReceived,r._channelContext.rtcVideoStatistic.bytesReceived,new xe(t.video.timestamp-r._channelContext.rtcVideoStatistic.timestamp).toIsoString()),r._channelContext.rtcVideoStatistic=t.video),d.A.navigatorIsOnLine)if(i||n)r.reconnectPeerConnection(e,(function(){r._channelContext.state.value=Se.ConnectionError,r._channelContext.videoElement.value&&(r._channelContext.videoElement.value.pause(),r._channelContext.videoElement.value.srcObject=null),r._channelContext.playing.value=!1,r._channelContext.loading.value=!0,m.dispose(),r._handleStreamFailure().catch((function(t){r._logger.error("[%s] Failed handling stream failure after track stopped with state [%s]",r._channelContext.streamId,e.iceConnectionState,t)}))}));else{if(r._peerConnectionContext.peerConnectionReconnectAttempts=0,r._channelContext.state.value!==Se.Reconnecting&&r._channelContext.state.value!==Se.Offline)return;r._channelContext.state.value=r._channelContext.playing.value?Se.Playing:Se.Paused,r._logger.info("Channel state restored to [%s] after reconnecting",Se[r._channelContext.state.value])}else r._channelContext.state.value=Se.Offline}));return r._disposables.add(v),ye.automaticallyPlayMediaStream?i(t):(r._channelContext.autoMuted.value=!1,r._channelContext.autoPaused.value=!0,r._channelContext.loading.value=!1,r._channelContext.playing.value=!1,void(r._channelContext.state.value=Se.Paused))}))}))}))}},{key:"applyRtcConfiguration",value:(e=k()(x().mark((function e(t,n){var i;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=Xe.truncateIceServers(n),e.abrupt("return",ye.peerConnectionFactory.value.createPeerConnection(n));case 3:return i=It(It({},t.getConfiguration()),n),t.setConfiguration(i),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)}))),function(t,n){return e.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._channelContext.state.value=Se.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<ye.maximalNumberOfPeerConnectionReconnectAttempts||!ye.automaticallyReconnectPeerConnection){var i;this._peerConnectionContext.peerConnectionReconnectAttempts++;var r="offer"===(null===(i=e.currentLocalDescription)||void 0===i?void 0:i.type);if(p.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!r)return;this._logger.info("Reconnecting peer connection by restarting ICE");var o=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(t){return e.setLocalDescription(t).then((function(){return e.setLocalDescription(o)}))})).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:"dispose",value:function(){this._disposables.dispose()}},{key:"mapSetRemoteDescriptionStatusToChannelStatus",value:function(e){switch(e){case"ok":return Se.Starting;case"unauthorized":return Se.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return Se.Recovering;case"failed":return Se.Error;default:L(e)}}}]);var e}(),Lt=function(){return u()((function e(){throw a()(this,e),new Error("RealTimeStreamFactory is a static class that may not be instantiated")}),null,[{key:"create",value:function(e,t,n,i,r,o){var a=$.parseToken(e).capabilities;return a.includes("on-demand")?(this._logger.error("This build does not support On-Demand Stream playback."),void(t.state.value=Se.UnsupportedFeature)):a.includes("streaming")?(this._logger.error("This build does not support Live Stream playback."),void(t.state.value=Se.UnsupportedFeature)):new Dt(t,n,i,r,o)}}])}();l()(Lt,"_logger",U.getLogger("Streaming"));var Ot=n(701).A,At=function(){return u()((function e(t,n,i){var r=this;a()(this,e),l()(this,"_logger",U.getLogger("Channel")),l()(this,"_tokenContext",void 0),l()(this,"_channelContext",void 0),l()(this,"_peerConnectionContext",void 0),l()(this,"_streamTransformContext",void 0),l()(this,"_stateContext",void 0),l()(this,"_frameTimingInformationContext",void 0),l()(this,"_exponentialBackoff",void 0),l()(this,"_channelStartTime",void 0),l()(this,"_readOnlyPeerConnection",void 0),l()(this,"_readOnlyState",void 0),l()(this,"_readOnlyAutoMuted",void 0),l()(this,"_readOnlyAutoPaused",void 0),l()(this,"_readOnlyTokenExpiring",void 0),l()(this,"_readOnlyAuthorized",void 0),l()(this,"_readOnlyOnline",void 0),l()(this,"_readOnlyLoading",void 0),l()(this,"_readOnlyPlaying",void 0),l()(this,"_readOnlyStandby",void 0),l()(this,"_readOnlyStopped",void 0),l()(this,"_readOnlyTargetLag",void 0),l()(this,"_readOnlyLag",void 0),l()(this,"_readOnlyBitrateLimit",void 0),l()(this,"_readOnlyResolution",void 0),l()(this,"_readOnlyFailureCount",void 0),l()(this,"_readOnlyEndPoint",void 0),l()(this,"_readOnlyStream",void 0),l()(this,"_readOnlyRtcStatistics",void 0),l()(this,"_readOnlyMediaStream",void 0),l()(this,"_readOnlyIsFrameTimingInformationEnabled",void 0),l()(this,"_readOnlyDecodedFrameTimingInformation",void 0),l()(this,"_readOnlyRenderedFrameTimingInformation",void 0),l()(this,"_metricsService",void 0),l()(this,"_sessionTelemetry",void 0),l()(this,"_videoMetaDataChangedHandler",void 0);var o=$.parseToken(n),s={targetLag:null==i?void 0:i.targetLag},u={hasInsertableStreams:o.capabilities.includes("insertable-streams"),hasEncodedInsertableStreams:o.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 Ie(n),this._channelContext=new De(s),this._peerConnectionContext=new Ve,this._streamTransformContext=new Ue(u),this._stateContext=new Be,this._exponentialBackoff=new he,this._channelStartTime=Date.now(),this._readOnlyPeerConnection=new Q(this._peerConnectionContext.peerConnection),this._readOnlyState=new Q(this._channelContext.state),this._readOnlyAutoMuted=new Q(this._channelContext.autoMuted),this._readOnlyAutoPaused=new Q(this._channelContext.autoPaused),this._readOnlyTokenExpiring=new Q(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new Q(this._channelContext.authorized),this._readOnlyOnline=new Q(this._channelContext.online),this._readOnlyLoading=new Q(this._channelContext.loading),this._readOnlyPlaying=new Q(this._channelContext.playing),this._readOnlyStandby=new Q(this._channelContext.standby),this._readOnlyStopped=new Q(this._channelContext.stopped),this._readOnlyTargetLag=new Q(this._channelContext.targetLag),this._readOnlyLag=new Q(this._channelContext.lag),this._readOnlyBitrateLimit=new Q(this._channelContext.bitrateLimit),this._readOnlyResolution=new Q(this._channelContext.resolution),this._readOnlyFailureCount=new Q(this._channelContext.failureCount),this._readOnlyEndPoint=new Q(this._channelContext.endPoint),this._readOnlyStream=new Q(this._channelContext.stream),this._readOnlyRtcStatistics=new Q(this._channelContext.rtcStatistics),this._readOnlyMediaStream=new Q(this._peerConnectionContext.mediaStream);var c=(o.uri||ye.discoveryUri.value).toString();ye.tenancy.value=o.tenancy||ye.tenancy.value,ue.uri.value=c,this._metricsService=ge.getMetricsService(c),this._sessionTelemetry=new Ee(ye.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=t,this._frameTimingInformationContext=new Ne,this.configureFrameTimingInformation(o),this._readOnlyIsFrameTimingInformationEnabled=new Q(this._frameTimingInformationContext.isEnabled),this._readOnlyDecodedFrameTimingInformation=new Q(this._frameTimingInformationContext.decodedFrameTimingInformation),this._readOnlyRenderedFrameTimingInformation=new Q(this._frameTimingInformationContext.renderedFrameTimingInformation),this._channelContext.channelDisposables.add(this._channelContext.videoElement.subscribe((function(e){r._channelContext.rendererDisposables.dispose(),e&&(r._channelContext.rendererDisposables.add(r._channelContext.stream.subscribe((function(e){r._channelContext.videoTelemetry&&r._channelContext.videoTelemetry.dispose(),e&&r.videoElement&&(r.videoElement.dataset&&(r.videoElement.dataset.sessionId=ye.clientSessionId,r.videoElement.dataset.streamId=r.streamId),r._channelContext.videoTelemetry=new we(r.streamId,ye.pageLoadTime,r._channelStartTime,r._metricsService),r._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(r.videoElement),r._channelContext.videoTelemetry.setupListenerForRebuffering(r.videoElement),r._channelContext.state.value===Se.Stopped)&&r.restartAfterStop()}))),r._channelContext.channelDisposables.add(r._channelContext.rendererDisposables))}))),this._channelContext.channelDisposables.add(this._channelContext.state.subscribe((function(e){r._channelContext.clearFailureCountTimeout&&d.A.clearTimeout(r._channelContext.clearFailureCountTimeout),r._channelContext.failureCount.value&&e===Se.Playing&&(r._channelContext.clearFailureCountTimeout=d.A.setTimeout((function(){r._channelContext.failureCount.value=0}),3e3))}))),this._channelContext.channelDisposables.add(this._channelContext.resolution.subscribe((function(e){r._channelContext.videoTelemetry&&r._channelContext.videoTelemetry.onVideoResolutionChanges(e.toString())}))),this._channelContext.channelDisposables.add(this._channelContext.bitrateLimit.subscribe((function(e){if(e&&r._channelContext.endPoint.value&&r._channelContext.stream.value){var t=Date.now()-r._channelContext.channelInitialization.getTime();r._channelContext.endPoint.value.limitBitrate(r._channelContext.stream.value,t,e,Fe.Keep,Re.Normal).catch((function(e){r._logger.error("Error while setting limit bitrate",e)}))}})));var h=function(){r._channelContext.stream.value&&r._channelContext.endPoint.value&&r._channelContext.endPoint.value.destroyStreamOnUnmount(r._channelContext.stream.value,"client:termination-on-window-unload")};d.A.addWindowEventListener("beforeunload",h),this._channelContext.channelDisposables.add(new q((function(){d.A.removeWindowEventListener("beforeunload",h)}))),this.start()}),[{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!==Se.Initializing&&(this._channelContext.state.value=Se.Stopped),this._channelContext.videoElement.value=e,this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.addEventListener("loadeddata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.addEventListener("loadedmetadata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.addEventListener("resize",this._videoMetaDataChangedHandler))}},{key:"handleVideoMetaDataChanged",value:function(){var e=this._channelContext.videoElement.value;e?this.resolution.value.width===e.videoWidth&&this.resolution.value.height===e.videoHeight||(this._channelContext.resolution.value=new be(e.videoWidth,e.videoHeight)):this._channelContext.resolution.value=be.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=$.parseToken(this._tokenContext.token.value),n=(t.uri||ye.discoveryUri.value).toString();ye.tenancy.value=t.tenancy||ye.tenancy.value,ue.uri.value=n,this._metricsService=ge.getMetricsService(n),this._streamTransformContext.hasInsertableStreams.value=t.capabilities.includes("insertable-streams"),this._streamTransformContext.hasEncodedInsertableStreams.value=t.capabilities.includes("encoded-insertable-streams"),this.configureFrameTimingInformation(t),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"autoMuted",get:function(){return this._readOnlyAutoMuted}},{key:"autoPaused",get:function(){return this._readOnlyAutoPaused}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"playing",get:function(){return this._readOnlyPlaying}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"targetLag",get:function(){return this._readOnlyTargetLag}},{key:"lag",get:function(){return this._readOnlyLag}},{key:"bitrateLimit",get:function(){return this._readOnlyBitrateLimit.value}},{key:"resolution",get:function(){return this._readOnlyResolution}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._channelContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"isFrameTimingInformationEnabled",get:function(){return this._readOnlyIsFrameTimingInformationEnabled}},{key:"decodedFrameTimingInformation",get:function(){return this._readOnlyDecodedFrameTimingInformation}},{key:"renderedFrameTimingInformation",get:function(){return this._readOnlyRenderedFrameTimingInformation}},{key:"setBitrateLimit",value:function(e){this._channelContext.bitrateLimit.value=e}},{key:"clearBitrateLimit",value:function(){var e=this;if(this._channelContext.bitrateLimit.value&&this._channelContext.endPoint.value&&this._channelContext.stream.value){var t=Date.now()-this._channelContext.channelInitialization.getTime();this._channelContext.endPoint.value.limitBitrate(this._channelContext.stream.value,t,0,Fe.Keep,Re.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=k()(x().mark((function e(t){var n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Ot((function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._channelContext.rendererDisposables.add(n._stateContext.isStarting.subscribe((function(i){i||(n.processStop(t),e())})))})));case 1:case"end":return e.stop()}}),e)}))),function(e){return h.apply(this,arguments)})},{key:"processStop",value:function(e){this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.pause(),this._channelContext.videoElement.value.srcObject=null),this._channelContext.rendererDisposables.dispose(),this.cleanUpResources(e),this._channelContext.state.value=Se.Stopped}},{key:"resume",value:(c=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._peerConnectionContext.mediaStream.value){e.next=3;break}return this._channelContext.autoPaused.value=!1,e.abrupt("return",this.playMediaStreamInVideoElement(this._peerConnectionContext.mediaStream.value));case 3:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"mute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!0)}},{key:"unmute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!1,this._channelContext.autoMuted.value=!1)}},{key:"dispose",value:(s=k()(x().mark((function e(){var t=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stop("client:channel-dispose").then((function(){t._channelContext.channelDisposables.dispose(),t._stateContext.isDisposed=!0})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"getUri",value:function(e){return $.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",ye.discoveryUri.value),new d.A.URL(ye.discoveryUri.value))}},{key:"start",value:(o=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._stateContext.isStarting.value){e.next=5;break}return this._logger.info("Channel is already starting, skipping start"),e.abrupt("return");case 5:return this._stateContext.isStarting.value=!0,e.abrupt("return",this.processStart());case 7:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"processStart",value:(r=k()(x().mark((function e(){var t,n,i,r,o,a,s,u,c,l,h,f,m,v,g,_,y,b,C,k=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._channelContext.state.value=Se.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),$.isEncodedEdgeTokenValid(t)){e.next=10;break}return this._logger.error("Failed to parse token [%s]",t),this._channelContext.state.value=Se.Unauthorized,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 10:if(!this._streamTransformContext.videoStreamTransformCallback){e.next=18;break}if(i=Me.validateMediaStreamTrackTransform("video",this._streamTransformContext.videoStreamTransformCallback),r=i.valid,o=i.validationResult,r){e.next=18;break}return this._logger.error(o),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 18:if(!this._streamTransformContext.audioStreamTransformCallback){e.next=26;break}if(a=Me.validateMediaStreamTrackTransform("audio",this._streamTransformContext.audioStreamTransformCallback),s=a.valid,u=a.validationResult,s){e.next=26;break}return this._logger.error(u),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 26:if(!this._streamTransformContext.encodedVideoStreamSink){e.next=34;break}if(c=Ae.validateEncodedStreamSink("video",this._streamTransformContext.encodedVideoStreamSink),l=c.valid,h=c.validationResult,l){e.next=34;break}return this._logger.error(h),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 34:if(!this._streamTransformContext.encodedAudioStreamSink){e.next=42;break}if(f=Ae.validateEncodedStreamSink("audio",this._streamTransformContext.encodedAudioStreamSink),m=f.valid,v=f.validationResult,m){e.next=42;break}return this._logger.error(v),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 42:if(!this._streamTransformContext.hasInsertableStreams.value||!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=48;break}return this._logger.error("Both insertable-streams and encoded-insertable-streams are enabled, only use one or the other"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 48:if(g="function"==typeof this._streamTransformContext.videoStreamTransformCallback||"function"==typeof this._streamTransformContext.audioStreamTransformCallback,_="function"==typeof this._streamTransformContext.encodedVideoStreamSink||"function"==typeof this._streamTransformContext.encodedAudioStreamSink,!g||!_){e.next=56;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=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 56:if(!this._streamTransformContext.hasInsertableStreams.value){e.next=71;break}if(p.isInsertableStreamsSupported){e.next=63;break}return this._logger.error("Browser does not support Media Stream Track API"),this._channelContext.state.value=Se.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 63:if(g){e.next=69;break}return this._logger.error("CreateChannelOptions transform callback function is missing; however, insertable-streams is enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 69:e.next=77;break;case 71:if(!g){e.next=77;break}return this._logger.error("CreateChannelOptions transform callback function found; however, insertable-streams is not enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 77:if(!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=92;break}if(p.isEncodedInsertableStreamsSupported||p.isRTCRtpScriptTransformSupported){e.next=84;break}return this._logger.error("Browser does not support encodedInsertableStreams API"),this._channelContext.state.value=Se.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 84:if(_){e.next=90;break}return this._logger.error("CreateChannelOptions transform sink function is missing; however, encoded-insertable-streams is enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 90:e.next=98;break;case 92:if(!_){e.next=98;break}return this._logger.error("CreateChannelOptions transform sink function found; however, encoded-insertable-streams is not enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 98:if(this._channelContext.loading.value=!0,y=this.getUri(t),this._channelContext.disposables.add(this._channelContext.state.subscribe((function(e){e!==Se.Error&&e!==Se.Recovering||Qe.clearCachedClosestEndpoint(y)}))),b=function(){return new Ot((function(e){return k._stateContext.isStarting.value=!1,e(k.handleStreamFailure())}))},C=Lt.create(t,this._channelContext,this._peerConnectionContext,this._streamTransformContext,this._frameTimingInformationContext,b)){e.next=106;break}return this._stateContext.isStarting.value=!1,e.abrupt("return");case 106:return e.abrupt("return",C.start(y,t,n,this.playMediaStreamInVideoElement.bind(this)).then((function(){k._channelContext.loading.value=!1})).catch((function(e){n.fail(),k._channelContext.failureCount.value++,k._channelContext.online.value=!1,k.cleanUpResources("client:cleanup-after-failed-setup"),k._channelContext.state.value=Se.ClientStartError,k._logger.error("Failed to start channel",e)})).finally((function(){if(k._stateContext.isStarting.value=!1,k._channelContext.state.value!==Se.Playing&&ye.automaticRetryOnFailure){var e=d.A.setTimeout((function(){k.handleStreamFailure().catch((function(e){k._logger.error("Failed handling stream failure",e)}))}),k.getRetryInterval());k._channelContext.disposables.add(new q((function(){d.A.clearTimeout(e)})))}})));case 107:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"restartAfterStop",value:(i=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._peerConnectionContext.mediaStream.value){e.next=4;break}return e.abrupt("return",this.playMediaStreamInVideoElement(this._peerConnectionContext.mediaStream.value));case 4:this._tokenContext.token.value&&this.start();case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"play",value:(n=k()(x().mark((function e(){var t;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._peerConnectionContext.mediaStream.value){e.next=3;break}return e.abrupt("return",this.start());case 3:return e.abrupt("return",this.playMediaStreamInVideoElement(t));case 4:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getRetryInterval",value:function(){switch(this._channelContext.state.value){case Se.Initializing:case Se.StandBy:case Se.Offline:return 15e3;case Se.Error:case Se.Recovering:case Se.Unauthorized:case Se.GeoRestricted:case Se.GeoBlocked:case Se.Stopped:case Se.Starting:case Se.Playing:case Se.Paused:case Se.Reconnecting:case Se.UnsupportedFeature:case Se.ConfigurationError:case Se.TransientConfigurationError:case Se.ConnectionError:case Se.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._channelContext.failureCount.value);default:L(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(t=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._channelContext.state.value,e.next=e.t0===Se.Error||e.t0===Se.Reconnecting||e.t0===Se.StandBy||e.t0===Se.Offline||e.t0===Se.Recovering||e.t0===Se.TransientConfigurationError||e.t0===Se.ConnectionError||e.t0===Se.ClientStartError?3:e.t0===Se.Unauthorized?5:e.t0===Se.GeoRestricted?7:e.t0===Se.GeoBlocked?9:e.t0===Se.Stopped?11:e.t0===Se.Initializing?13:e.t0===Se.Playing?15:e.t0===Se.Paused?17:e.t0===Se.Starting?19:e.t0===Se.UnsupportedFeature?21:e.t0===Se.ConfigurationError?23:25;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,Se[this._channelContext.state.value]),e.abrupt("break",26);case 5:return this._logger.info("Channel is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 7:return this._logger.info("Channel is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 9:return this._logger.info("Channel is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 11:return this._logger.info("Channel is stopped, skipping retry of start."),e.abrupt("return");case 13:return this._logger.info("Channel is already initializing, skipping retry of start"),e.abrupt("return");case 15:return this._logger.info("Channel is playing, skipping retry of start"),e.abrupt("return");case 17:return this._logger.info("Channel is paused, skipping retry of start. Please invoke play()"),e.abrupt("return");case 19:return this._logger.info("Channel is already starting, skipping retry of start"),e.abrupt("return");case 21:return this._logger.info("Channel is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 23:return this._logger.info("Channel is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 25:L(this._channelContext.state.value);case 26:return e.abrupt("return",this.start());case 27:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._channelContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!ye.forceGarbageCollectionOnRestart||p.isMobile&&ye.skipGarbageCollectionOnMobileDevices||Ce.forceGarbageCollection()),this._peerConnectionContext.mediaStream.value&&(this._peerConnectionContext.mediaStream.value.getTracks().forEach((function(e){return e.stop()})),this._peerConnectionContext.mediaStream.value=null),this._channelContext.autoPaused.value=!1,this._channelContext.autoMuted.value=!1,this._channelContext.playing.value=!1,this._channelContext.stopped.value=!0,this._channelContext.standby.value=!1,this._channelContext.stream.value&&this._channelContext.endPoint.value&&this._channelContext.endPoint.value.destroyStream(this._channelContext.stream.value,t).then((function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)})).catch((function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)})),this.videoElement&&this.videoElement.dataset&&(this.videoElement.dataset.sessionId="",this.videoElement.dataset.streamId=""),this._channelContext.stream.value=null,this._channelContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}},{key:"configureFrameTimingInformation",value:function(e){var t=this,n=e.capabilities.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?p.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=k()(x().mark((function e(t){var n,i,r=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this._channelContext.videoElement.value){e.next=8;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=Se.Stopped,e.abrupt("return");case 8:if(this._streamTransformContext.hasEncodedInsertableStreams.value||(n.srcObject=t),void 0!==(i=n.play())){e.next=17;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=Se.Playing,e.abrupt("return");case 17:return e.abrupt("return",i.then((function(){r._channelContext.autoMuted.value=!1,r._channelContext.autoPaused.value=!1,r._channelContext.loading.value=!1,r._channelContext.playing.value=!0,r._channelContext.state.value=Se.Playing})).catch((function(e){var i=!!t.getTracks().filter((function(e){return"audio"===e.kind})).length,o=!ye.automaticallyMuteVideoOnPlayFailure;return o||n.muted||!i?(n.srcObject=null,r._channelContext.autoMuted.value=!1,r._channelContext.autoPaused.value=!0,r._channelContext.loading.value=!1,r._channelContext.playing.value=!1,r._channelContext.state.value=Se.Paused,o?void r._logger.info("[%s] Paused video after play failed. Manual user action required.",r.streamId,e):i?void r._logger.info("[%s] Failed to play video. Manual user action required.",r.streamId,e):void r._logger.info("[%s] Failed to play muted video. Manual user action required.",r.streamId,e)):(n.muted=!0,n.play().then((function(){r._logger.info("[%s] Played video after auto muting. Manual user action required to unmute.",r.streamId),r._channelContext.autoMuted.value=!0,r._channelContext.autoPaused.value=!1,r._channelContext.loading.value=!1,r._channelContext.playing.value=!0,r._channelContext.state.value=Se.Playing})).catch((function(e){n.muted=!1,r._logger.info("[%s] Failed to play video. Manual user action required.",r.streamId,e),n.srcObject=null,r._channelContext.autoMuted.value=!1,r._channelContext.autoPaused.value=!0,r._channelContext.loading.value=!1,r._channelContext.playing.value=!1,r._channelContext.state.value=Se.Paused})))})));case 18:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,i,r,o,s,c,h}(),Mt=function(){return u()((function e(){throw a()(this,e),new Error("Channels is a static class that may not be instantiated")}),null,[{key:"createChannel",value:function(e){if(!ye.initialized.value)throw new Error("SDK is not loaded.");var t={targetLag:e.targetLag,videoStreamTransformCallback:e.videoStreamTransformCallback,audioStreamTransformCallback:e.audioStreamTransformCallback,encodedVideoStreamSink:e.encodedVideoStreamSink,encodedAudioStreamSink:e.encodedAudioStreamSink};return new At(e.videoElement,e.token,t)}},{key:"isFrameTimingInformationSupported",get:function(){return p.isChannelFrameTimingInformationSupported}}])}(),Ut=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}(Ut||{}),Vt=Ut,Bt=function(){return u()((function e(t){a()(this,e),l()(this,"publisherInitialization",void 0),l()(this,"disposables",void 0),l()(this,"publisherDisposables",void 0),l()(this,"state",void 0),l()(this,"authorized",void 0),l()(this,"online",void 0),l()(this,"loading",void 0),l()(this,"publishing",void 0),l()(this,"standby",void 0),l()(this,"stopped",void 0),l()(this,"failureCount",void 0),l()(this,"endPoint",void 0),l()(this,"stream",void 0),l()(this,"rtcStatistics",void 0),l()(this,"clearFailureCountTimeout",void 0),l()(this,"startReconnectionAttemptsTimeInMilliseconds",void 0),l()(this,"name",void 0),this.disposables=new X,this.publisherDisposables=new X,this.publisherInitialization=new Date,this.state=new K(Vt.Initializing),this.authorized=new K(!0),this.online=new K(!0),this.loading=new K(!1),this.publishing=new K(!1),this.standby=new K(!1),this.stopped=new K(!1),this.failureCount=new K(0),this.endPoint=new K(null),this.stream=new K(null),this.rtcStatistics=new K(null),this.name=t&&t.length?t:this.generateScreenName(),this.startReconnectionAttemptsTimeInMilliseconds=0}),[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":this.authorized.value=!1;case"not-found":return this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null)}}},{key:"mapPublishStatusToPublisherStatus",value:function(e){switch(e){case"ok":return Vt.Starting;case"not-found":return Vt.NotFound;case"geo-restricted":return Vt.GeoRestricted;case"geo-blocked":return Vt.GeoBlocked;case"unauthorized":return Vt.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Vt.Recovering;case"missing-channel-or-room-id":case"forbidden-tag":return Vt.ConfigurationError;case"port-in-range-not-found":return Vt.TransientConfigurationError;case"failed":return Vt.Error;default:L(e)}}},{key:"generateScreenName",value:function(){return V.random(12)}}])}(),Nt=function(){return u()((function e(t,n,i){if(a()(this,e),l()(this,"_estimatedRoundTripTime",void 0),l()(this,"_estimatedVideoCodec",void 0),l()(this,"_estimatedAudioCodec",void 0),l()(this,"_rtcStatistic",new K({})),l()(this,"_peerConnection",void 0),l()(this,"_isMonitorRunning",!0),l()(this,"_updateTimeout",void 0),l()(this,"_availableTracks",void 0),this._peerConnection=t,this._estimatedRoundTripTime=i,this._peerConnection){var r=new Ze(this._peerConnection.currentLocalDescription.sdp),o=new Ze(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=o.audioCodec,this._estimatedVideoCodec=o.videoCodec,this._availableTracks={audio:r.isAudioTrackEnabled&&o.isAudioTrackEnabled,video:r.isVideoTrackEnabled&&o.isVideoTrackEnabled},this.updateStatistic()}}),[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(d.A.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(e=k()(x().mark((function e(){var t,n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!p.getStatsPromiseBasedDisabled){e.next=3;break}return e.abrupt("return");case 3:return t=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=6,this._peerConnection.getStats(null).then((function(e){var i={};if(e){var r,o=n._estimatedRoundTripTime;e.forEach((function(a){if("candidate-pair"===a.type&&a.currentRoundTripTime&&(o=1e3*a.currentRoundTripTime,i.audio&&(i.audio.roundTripTime=o),i.video&&(i.video.roundTripTime=o)),"candidate-pair"===a.type&&a.lastPacketSentTimestamp&&(r=a.lastPacketSentTimestamp,i.audio&&(i.audio.lastPacketSentTimestamp=r),i.video&&(i.video.lastPacketSentTimestamp=r)),"outbound-rtp"===a.type){var s=a.kind||a.mediaType||t(a),u="";if(e.forEach((function(e){e.id===a.codecId&&(u=e.mimeType)})),s&&n._availableTracks[s]){var c,l,d,h,p,f=(a.bytesSent||0)-(null!==(c=null===(l=n._rtcStatistic.value)||void 0===l||null===(d=l[s])||void 0===d?void 0:d.bytesSent)&&void 0!==c?c:0),m=a.timestamp-(null===(h=n._rtcStatistic.value)||void 0===h||null===(p=h[s])||void 0===p?void 0:p.timestamp),v=f&&m?Math.floor(8*f/m*1e3):0;if(i[s]={ssrc:a.ssrc,mediaType:s,timestamp:a.timestamp,bitrate:v,bytesSent:a.bytesSent,packetsSent:a.packetsSent,retransmittedBytesSent:a.retransmittedBytesSent,codec:u||n.getCodecByType(s),roundTripTime:o},(a.lastPacketSentTimestamp||r)&&(i[s].lastPacketSentTimestamp=a.lastPacketSentTimestamp||r),"video"===s&&n._rtcStatistic.value&&n._rtcStatistic.value.video){i[s].firCount=a.firCount,i[s].frameHeight=a.frameHeight,i[s].frameWidth=a.frameWidth,i[s].framesEncoded=a.framesEncoded,i[s].framesSent=a.framesSent,i[s].headerBytesSent=a.headerBytesSent,i[s].hugeFramesSent=a.hugeFramesSent,i[s].pliCount=a.pliCount,i[s].qpSum=a.qpSum,i[s].totalEncodeTime=a.totalEncodeTime,i[s].totalEncodedBytesTarget=a.totalEncodedBytesTarget;var g=(a.framesEncoded-n._rtcStatistic.value.video.framesEncoded)/(i[s].timestamp-n._rtcStatistic.value.video.timestamp)*1e3;i[s].fps=g?Math.round(100*g)/100:0}}}}))}n._rtcStatistic.value=i})).then((function(){n._isMonitorRunning&&(n._updateTimeout=d.A.setTimeout((function(){return n.updateStatistic()}),1e3))}));case 6:e.sent;case 7:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec;case"video":return this._estimatedVideoCodec;default:return"unknown"}}}]);var e}(),jt=n(701).A;function zt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Gt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?zt(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ht=function(){return u()((function e(t,n,i){a()(this,e),l()(this,"_logger",U.getLogger("RealTimePublisher")),l()(this,"_publisherContext",void 0),l()(this,"_peerConnectionContext",void 0),l()(this,"_handleStreamFailure",void 0),this._publisherContext=t,this._peerConnectionContext=n,this._handleStreamFailure=i}),[{key:"start",value:function(e,t,n){var i=this;return d.A.navigatorIsOnLine?jt.all([Qe.discoverClosestEndPointWithCaching(e),re.createPeerConnectionOffer("sendonly").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=ze()(e,2),r=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;return i._publisherContext.online.value=!0,i._publisherContext.endPoint.value=r,i._logger.info("Connecting to [%s]",r.toString()),i._logger.info("Local offer:\n"+a.sdp),(p.clientOfferDisabled||!s.supportsSetConfiguration||!s.supportsGetConfiguration||i._publisherContext.failureCount.value>0)&&(s.close(),s.dispose(),!ye.forceGarbageCollectionOnRestart||p.isMobile&&ye.skipGarbageCollectionOnMobileDevices||Ce.forceGarbageCollection(),s=null,a=null,i._peerConnectionContext.peerConnection.value=s),r.publish(i._publisherContext.name,t,a,i._publisherContext.failureCount.value)})).then((function(e){var t=e.status,r=e.stream,o=e.rtcConfiguration,a=e.setRemoteDescriptionResponse,s=e.createOfferDescriptionResponse,u=e.createAnswerDescriptionResponse;if(i._publisherContext.stream.value=r,i._logger.debug("[%s] Publish completed [%s] [%j] [%j] [%j] [%j]",i._publisherContext.streamId,t,o,a,s,u),i._publisherContext.state.value=i._publisherContext.mapPublishStatusToPublisherStatus(t),i._publisherContext.applyStatus(t),"ok"===t)return i.applyRtcConfiguration(i._peerConnectionContext.peerConnection.value,o).then((function(e){var t,o=!1,c=!1,l=[];return i._peerConnectionContext.peerConnection.value=e,e.addStream(i._peerConnectionContext.mediaStream.value),e.onicecandidate=function(n){i._publisherContext.stream.value===r&&i._peerConnectionContext.peerConnection.value===e&&(o||ye.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?l.push(n.candidate):c=!0,t||(t=d.A.setTimeout((function(){i._publisherContext.stream.value!==r||o||i._publisherContext.endPoint.value.addIceCandidates(r,l,c).then((function(e){var t=e.status,n=e.options;"ok"===t?(n.includes("cancel")&&(o=!0),i._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",i._publisherContext.streamId,t,n)):i._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",i._publisherContext.streamId,t)})).catch((function(e){i._logger.error("[%s] Failed to add ICE candidates",i._publisherContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(i._publisherContext.stream.value===r&&i._peerConnectionContext.peerConnection.value===e){var t=function(){i._publisherContext.state.value=Vt.ConnectionError,i._publisherContext.publishing.value=!1,i._publisherContext.loading.value=!0,i._handleStreamFailure().catch((function(t){i._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",i._publisherContext.streamId,e.iceConnectionState,t)}))};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return i._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",i._publisherContext.streamId,e.iceConnectionState),void i.reconnectPeerConnection(e,t);case"closed":return i._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",i._publisherContext.streamId,e.iceConnectionState),void t();default:L(e.iceConnectionState)}}},new jt((function(e){e()})).then((function(){if(a)return i._logger.info("[%s] Set local SDP offer [%s]",i._publisherContext.streamId,a.sessionDescription.sdp),e.setLocalDescription(a.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._publisherContext.streamId,a.sessionDescription,e.message),e}))})).then((function(){if(u)return i._logger.info("[%s] Set remote SDP answer [%s]",i._publisherContext.streamId,u.sessionDescription.sdp),e.setRemoteDescription(u.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._publisherContext.streamId,u.sessionDescription,e.message),e}))})).then((function(){if(s)return i._logger.info("[%s] Set remote SDP offer [%s]",i._publisherContext.streamId,s.sessionDescription.sdp),e.setRemoteDescription(s.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._publisherContext.streamId,u.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!1,offerToReceiveVideo:!1})})).then((function(e){return i._logger.info("[%s] Set local SDP answer [%s]",i._publisherContext.streamId,e.sdp),i._publisherContext.endPoint.value.setRemoteDescription(r,e)})).then((function(t){var n=t.status,r=t.sessionDescription;return i._publisherContext.state.value=i.mapSetRemoteDescriptionStatusToPublisherStatus(n),"ok"!==n?(i._publisherContext.publishing.value=!1,i._publisherContext.standby.value=!0,void(i._publisherContext.stopped.value=!1)):(i._logger.info("[%s] Set local SDP [%s]",i._publisherContext.streamId,r.sdp),e.setLocalDescription(r).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._publisherContext.streamId,r,e.message),e})))}))})).then((function(){n.success(i._publisherContext.streamId),i._publisherContext.state.value=Vt.Publishing,i._publisherContext.publishing.value=!0;var t=new Nt(e,i._peerConnectionContext.mediaStream.value,i._publisherContext.endPoint.value.roundTripTime/4);return i._publisherContext.disposables.add(t),t.rtcStatistic.subscribe((function(e){i._publisherContext.rtcStatistics.value=e})),jt.resolve()}))}))})):(this._publisherContext.state.value=Vt.Offline,jt.resolve())}},{key:"applyRtcConfiguration",value:(e=k()(x().mark((function e(t,n){var i;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=Xe.truncateIceServers(n),e.abrupt("return",ye.peerConnectionFactory.value.createPeerConnection(n));case 3:return i=Gt(Gt({},t.getConfiguration()),n),t.setConfiguration(i),e.abrupt("return",t);case 6:case"end":return e.stop()}}),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=Vt.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<ye.maximalNumberOfPeerConnectionReconnectAttempts||!ye.automaticallyReconnectPeerConnection){var i;this._peerConnectionContext.peerConnectionReconnectAttempts++;var r="offer"===(null===(i=e.currentLocalDescription)||void 0===i?void 0:i.type);if(p.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!r){var o=d.A.setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);return void this._publisherContext.disposables.add(new q((function(){return d.A.clearTimeout(o)})))}this._logger.info("Reconnecting peer connection by restarting ICE");var a=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(i){return e.setLocalDescription(i).then((function(){return e.setLocalDescription(a).then((function(){if("disconnected"===e.iceConnectionState||"failed"===e.iceConnectionState){var i=d.A.setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);n._publisherContext.disposables.add(new q((function(){return d.A.clearTimeout(i)})))}else n._publisherContext.state.value=Vt.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 Vt.Starting;case"unauthorized":return Vt.Unauthorized;case"not-found":return Vt.NotFound;case"capacity":case"rate-limited":case"timeout":return Vt.Recovering;case"failed":return Vt.Error;default:L(e)}}}]);var e}(),qt=n(701).A,Wt=function(){return u()((function e(t,n,i){var r=this;a()(this,e),l()(this,"_logger",U.getLogger("Publisher")),l()(this,"_tokenContext",void 0),l()(this,"_publisherContext",void 0),l()(this,"_peerConnectionContext",void 0),l()(this,"_stateContext",void 0),l()(this,"_exponentialBackoff",void 0),l()(this,"_publisherStartTime",void 0),l()(this,"_readOnlyToken",void 0),l()(this,"_readOnlyPeerConnection",void 0),l()(this,"_readOnlyState",void 0),l()(this,"_readOnlyTokenExpiring",void 0),l()(this,"_readOnlyAuthorized",void 0),l()(this,"_readOnlyOnline",void 0),l()(this,"_readOnlyLoading",void 0),l()(this,"_readOnlyPublishing",void 0),l()(this,"_readOnlyStandby",void 0),l()(this,"_readOnlyStopped",void 0),l()(this,"_readOnlyFailureCount",void 0),l()(this,"_readOnlyEndPoint",void 0),l()(this,"_readOnlyStream",void 0),l()(this,"_readOnlyRtcStatistics",void 0),l()(this,"_readOnlyMediaStream",void 0),l()(this,"_metricsService",void 0),l()(this,"_sessionTelemetry",void 0),this._tokenContext=new Ie(n),this._publisherContext=new Bt(i),this._peerConnectionContext=new Ve,this._stateContext=new Be,this._exponentialBackoff=new he,this._publisherStartTime=Date.now(),this._readOnlyToken=new Q(this._tokenContext.token),this._readOnlyPeerConnection=new Q(this._peerConnectionContext.peerConnection),this._readOnlyState=new Q(this._publisherContext.state),this._readOnlyTokenExpiring=new Q(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new Q(this._publisherContext.authorized),this._readOnlyOnline=new Q(this._publisherContext.online),this._readOnlyLoading=new Q(this._publisherContext.loading),this._readOnlyPublishing=new Q(this._publisherContext.publishing),this._readOnlyStandby=new Q(this._publisherContext.standby),this._readOnlyStopped=new Q(this._publisherContext.stopped),this._readOnlyFailureCount=new Q(this._publisherContext.failureCount),this._readOnlyEndPoint=new Q(this._publisherContext.endPoint),this._readOnlyStream=new Q(this._publisherContext.stream),this._readOnlyRtcStatistics=new Q(this._publisherContext.rtcStatistics),this._readOnlyMediaStream=new Q(this._peerConnectionContext.mediaStream),this._peerConnectionContext.mediaStream.value=t;var o=$.parseToken(this._tokenContext.token.value),s=(o.uri||ye.discoveryUri.value).toString();ye.tenancy.value=o.tenancy||ye.tenancy.value,ue.uri.value=s,this._metricsService=ge.getMetricsService(s),this._sessionTelemetry=new Ee(ye.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe((function(e){r._publisherContext.clearFailureCountTimeout&&d.A.clearTimeout(r._publisherContext.clearFailureCountTimeout),r._publisherContext.failureCount.value&&e===Vt.Publishing&&(r._publisherContext.clearFailureCountTimeout=d.A.setTimeout((function(){r._publisherContext.failureCount.value=0}),3e3))})));var u=function(){r._publisherContext.stream.value&&r._publisherContext.endPoint.value&&r._publisherContext.endPoint.value.destroyStreamOnUnmount(r._publisherContext.stream.value,"client:termination-on-window-unload")};d.A.addWindowEventListener("beforeunload",u),this._publisherContext.publisherDisposables.add(new q((function(){d.A.removeWindowEventListener("beforeunload",u)}))),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=$.parseToken(this._tokenContext.token.value),n=(t.uri||ye.discoveryUri.value).toString();ye.tenancy.value=t.tenancy||ye.tenancy.value,ue.uri.value=n,this._metricsService=ge.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:(r=k()(x().mark((function e(t){var n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new qt((function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._publisherContext.disposables.add(n._stateContext.isStarting.subscribe((function(i){i||(n.processStop(t),e())})))})));case 1:case"end":return e.stop()}}),e)}))),function(e){return r.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=Vt.Stopped}},{key:"dispose",value:(i=k()(x().mark((function e(){var t=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stop("client:channel-dispose").then((function(){t._publisherContext.publisherDisposables.dispose(),t._stateContext.isDisposed=!0})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getUri",value:function(e){return $.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",ye.discoveryUri.value),new d.A.URL(ye.discoveryUri.value))}},{key:"start",value:(n=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._stateContext.isStarting.value){e.next=5;break}return this._logger.info("Publisher is already starting, skipping start"),e.abrupt("return");case 5:return this._stateContext.isStarting.value=!0,e.abrupt("return",this.processStart());case 7:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"processStart",value:(t=k()(x().mark((function e(){var t,n,i,r,o,a=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publisherContext.state.value=Vt.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),$.isEncodedEdgeTokenValid(t)){e.next=10;break}return this._logger.error("Failed to parse token [%s]",t),this._publisherContext.state.value=Vt.Unauthorized,this._publisherContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 10:return this._publisherContext.loading.value=!0,i=this.getUri(t),this._publisherContext.disposables.add(this._publisherContext.state.subscribe((function(e){e!==Vt.Error&&e!==Vt.Recovering||Qe.clearCachedClosestEndpoint(i)}))),r=function(){return new qt((function(e){return a._stateContext.isStarting.value=!1,e(a.handleStreamFailure())}))},o=new Ht(this._publisherContext,this._peerConnectionContext,r),e.abrupt("return",o.start(i,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=Vt.ClientStartError,a._logger.error("Failed to start publishing",e)})).finally((function(){if(a._stateContext.isStarting.value=!1,a._publisherContext.state.value!==Vt.Publishing&&ye.automaticRetryOnFailure){var e=d.A.setTimeout((function(){a.handleStreamFailure().catch((function(e){a._logger.error("Failed handling stream failure",e)}))}),a.getRetryInterval());a._publisherContext.disposables.add(new q((function(){d.A.clearTimeout(e)})))}else a._publisherContext.startReconnectionAttemptsTimeInMilliseconds=0})));case 16:case"end":return e.stop()}}),e,this)}))),function(){return t.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){t._peerConnectionContext.peerConnection.value.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 Vt.Offline:return 15e3;case Vt.Initializing:case Vt.NotFound:case Vt.Error:case Vt.Recovering:case Vt.Unauthorized:case Vt.GeoRestricted:case Vt.GeoBlocked:case Vt.Stopped:case Vt.Starting:case Vt.Publishing:case Vt.Reconnecting:case Vt.UnsupportedFeature:case Vt.ConfigurationError:case Vt.TransientConfigurationError:case Vt.ConnectionError:case Vt.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._publisherContext.failureCount.value);default:L(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:(e=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._publisherContext.state.value,e.next=e.t0===Vt.Error||e.t0===Vt.Reconnecting||e.t0===Vt.Offline||e.t0===Vt.Recovering||e.t0===Vt.TransientConfigurationError||e.t0===Vt.ConnectionError||e.t0===Vt.ClientStartError?4:e.t0===Vt.Unauthorized?11:e.t0===Vt.GeoRestricted?13:e.t0===Vt.GeoBlocked?15:e.t0===Vt.Stopped?17:e.t0===Vt.Publishing?19:e.t0===Vt.Initializing?21:e.t0===Vt.Starting?23:e.t0===Vt.UnsupportedFeature?25:e.t0===Vt.NotFound?27:e.t0===Vt.ConfigurationError?29:31;break;case 4:if(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds||(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds=Date.now()),!(72e5<=Date.now()-this._publisherContext.startReconnectionAttemptsTimeInMilliseconds)){e.next=9;break}return this._logger.info("Publisher stopped with state [%s] [%s] after exceeding timeout",this._publisherContext.state.value,Vt[this._publisherContext.state.value]),e.abrupt("return");case 9:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,Vt[this._publisherContext.state.value]),e.abrupt("break",32);case 11:return this._logger.info("Publisher is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 13:return this._logger.info("Publisher is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 15:return this._logger.info("Publisher is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 17:return this._logger.info("Publisher is stopped, skipping retry of start."),e.abrupt("return");case 19:return this._logger.info("Publisher is publishing, skipping retry of start"),e.abrupt("return");case 21:return this._logger.info("Publisher is initializing, skipping retry of start"),e.abrupt("return");case 23:return this._logger.info("Publisher is already starting, skipping retry of start"),e.abrupt("return");case 25:return this._logger.info("Publisher is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 27:return this._logger.info("Publisher is stopped due to channel not found, skipping retry of start."),e.abrupt("return");case 29:return this._logger.info("Publisher is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 31:L(this._publisherContext.state.value);case 32:return e.abrupt("return",this.start());case 33:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._publisherContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!ye.forceGarbageCollectionOnRestart||p.isMobile&&ye.skipGarbageCollectionOnMobileDevices||Ce.forceGarbageCollection()),this._publisherContext.publishing.value=!1,this._publisherContext.stopped.value=!0,this._publisherContext.standby.value=!1,this._publisherContext.stream.value&&this._publisherContext.endPoint.value&&this._publisherContext.endPoint.value.destroyStream(this._publisherContext.stream.value,t).then((function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)})).catch((function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)})),this._publisherContext.stream.value=null,this._publisherContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}}]);var e,t,n,i,r}(),Jt=function(){return u()((function e(){throw a()(this,e),new Error("Publishers is a static class that may not be instantiated")}),null,[{key:"createPublisher",value:function(e){if(!ye.initialized.value)throw new Error("SDK is not loaded.");return new Wt(e.mediaStream,e.token,e.name)}}])}(),Kt={SDK:ye,Channels:Mt,ChannelState:Se,Publishers:Jt,PublisherState:Vt}})(),i})()));
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={787:(e,t,n)=>{"use strict";var i,r=n(383),o=n.n(r),a=n(579),s=n.n(a),u=n(693),c=n.n(u),l=function(){function e(){o()(this,e),c()(this,"_document",void 0),c()(this,"_location",void 0),c()(this,"_navigator",void 0),c()(this,"_window",void 0),this._document=document,this._location=location,this._navigator=navigator,this._window=window}return s()(e,[{key:"FormData",get:function(){return this._window.FormData}},{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:"queueMicrotask",get:function(){return this._window.queueMicrotask.bind(this._window)}},{key:"removeDocumentEventListener",get:function(){return this._document.removeEventListener.bind(this._document)}},{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:"getInstance",value:function(){return e._instance}}])}();i=l,c()(l,"_instance",new i),t.A=l.getInstance()},701:(e,t,n)=>{"use strict";n.d(t,{A:()=>f});var i=n(738),r=n.n(i),o=n(383),a=n.n(o),s=n(579),u=n.n(s),c=n(693),l=n.n(c),d=n(787),h=u()((function e(t,n,i){a()(this,e),l()(this,"onFulfilled",void 0),l()(this,"onRejected",void 0),l()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.promise=i})),p=function(){function e(t){if(a()(this,e),l()(this,"_state",void 0),l()(this,"_handled",void 0),l()(this,"_value",void 0),l()(this,"_deferreds",void 0),!(this instanceof e))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,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"===r()(t)||"function"==typeof t)){var i=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof i)return void n.doResolve((function(){i.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,i=this._deferreds.length;n<i;n++)this.handle(this._deferreds[n]);this._deferreds=null}},{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 i;try{i=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(i)}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 i=Array.prototype.slice.call(t);if(0===i.length)return e([]);for(var o=i.length,a=function(t,s){try{if(s&&("object"===r()(s)||"function"==typeof s)){var u=s.then;if("function"==typeof u)return void u.call(s,(function(e){return a(t,e)}),n)}i[t]=s,0==--o&&e(i)}catch(e){n(e)}},s=0;s<i.length;s++)a(s,i[s])}))}},{key:"resolve",value:function(t){return t&&"object"===r()(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,i){if(!Array.isArray(t))return i(new TypeError("Promise.race accepts an array"));for(var r=0,o=t.length;r<o;r++)e.resolve(t[r]).then(n,i)}))}},{key:"_immediate",value:function(e){d.A.setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}])}();p.prototype.catch=function(e){return this.then(null,e)},p.prototype.then=function(e,t){var n=new this.constructor((function(){return null}));return this.handle(new h(e,t,n)),n},p.prototype.finally=function(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){return t.reject(n)}))}))};var f=p},79:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i},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 i=n(79);e.exports=function(e){if(Array.isArray(e))return i(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 i=n(701).A;function r(e,t,n,r,o,a,s){try{var u=e[a](s),c=u.value}catch(e){return void n(e)}u.done?t(c):i.resolve(c).then(r,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new i((function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,u,"next",e)}function u(e){r(a,i,o,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,n)=>{var i=n(736);function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,i(r.key),r)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,t,n)=>{var i=n(736);e.exports=function(e,t,n){return(t=i(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 i=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&&i(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},291:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},156:e=>{e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(i=o.call(n)).done)&&(s.push(i.value),s.length!==t);u=!0);}catch(e){c=!0,r=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw r}}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},452:(e,t,n)=>{var i=n(738).default,r=n(475);e.exports=function(e,t){if(t&&("object"==i(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},633:(e,t,n)=>{var i=n(701).A,r=n(738).default;function o(){"use strict";e.exports=o=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},a=Object.prototype,s=a.hasOwnProperty,u=Object.defineProperty||function(e,t,n){e[t]=n.value},c="function"==typeof Symbol?Symbol:{},l=c.iterator||"@@iterator",d=c.asyncIterator||"@@asyncIterator",h=c.toStringTag||"@@toStringTag";function p(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(t){p=function(e,t,n){return e[t]=n}}function f(e,t,n,i){var r=t&&t.prototype instanceof C?t:C,o=Object.create(r.prototype),a=new O(i||[]);return u(o,"_invoke",{value:R(e,n,a)}),o}function m(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=f;var v="suspendedStart",g="suspendedYield",_="executing",y="completed",b={};function C(){}function k(){}function S(){}var x={};p(x,l,(function(){return this}));var w=Object.getPrototypeOf,T=w&&w(w(A([])));T&&T!==a&&s.call(T,l)&&(x=T);var P=S.prototype=C.prototype=Object.create(x);function E(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function F(e,t){function n(i,o,a,u){var c=m(e[i],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==r(d)&&s.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,a,u)}),(function(e){n("throw",e,a,u)})):t.resolve(d).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,u)}))}u(c.arg)}var i;u(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}})}function R(e,n,i){var r=v;return function(o,a){if(r===_)throw Error("Generator is already running");if(r===y){if("throw"===o)throw a;return{value:t,done:!0}}for(i.method=o,i.arg=a;;){var s=i.delegate;if(s){var u=I(s,i);if(u){if(u===b)continue;return u}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===v)throw r=y,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=_;var c=m(e,n,i);if("normal"===c.type){if(r=i.done?y:g,c.arg===b)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(r=y,i.method="throw",i.arg=c.arg)}}}function I(e,n){var i=n.method,r=e.iterator[i];if(r===t)return n.delegate=null,"throw"===i&&e.iterator.return&&(n.method="return",n.arg=t,I(e,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),b;var o=m(r,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,b;var a=o.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function A(e){if(e||""===e){var n=e[l];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(s.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(r(e)+" is not iterable")}return k.prototype=S,u(P,"constructor",{value:S,configurable:!0}),u(S,"constructor",{value:k,configurable:!0}),k.displayName=p(S,h,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===k||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,p(e,h,"GeneratorFunction")),e.prototype=Object.create(P),e},n.awrap=function(e){return{__await:e}},E(F.prototype),p(F.prototype,d,(function(){return this})),n.AsyncIterator=F,n.async=function(e,t,r,o,a){void 0===a&&(a=i);var s=new F(f(e,t,r,o),a);return n.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},E(P),p(P,h,"Generator"),p(P,l,(function(){return this})),p(P,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),n=[];for(var i in t)n.push(i);return n.reverse(),function e(){for(;n.length;){var i=n.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},n.values=A,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var n in this)"t"===n.charAt(0)&&s.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function i(i,r){return a.type="throw",a.arg=e,n.next=i,r&&(n.method="next",n.arg=t),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var u=s.call(o,"catchLoc"),c=s.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&s.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var r=i;break}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var o=r?r.completion:{};return o.type=e,o.arg=t,r?(this.method="next",this.next=r.finallyLoc,b):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var r=i.arg;L(n)}return r}}throw Error("illegal catch attempt")},delegateYield:function(e,n,i){return this.delegate={iterator:A(e),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=t),b}},n}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},636:e=>{function t(n,i){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,i)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},715:(e,t,n)=>{var i=n(987),r=n(156),o=n(122),a=n(752);e.exports=function(e,t){return i(e)||r(e,t)||o(e,t)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},132:(e,t,n)=>{var i=n(901),r=n(291),o=n(122),a=n(869);e.exports=function(e){return i(e)||r(e)||o(e)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,t,n)=>{var i=n(738).default;e.exports=function(e,t){if("object"!=i(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=i(r))return r;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 i=n(738).default,r=n(45);e.exports=function(e){var t=r(e,"string");return"symbol"==i(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 i=n(79);e.exports=function(e,t){if(e){if("string"==typeof e)return i(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)?i(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},756:(e,t,n)=>{var i=n(633)();e.exports=i;try{regeneratorRuntime=i}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var o=t[i]={exports:{}};return e[i](o,o.exports,n),o.exports}n.m=e,n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.u=e=>e+".js",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})},n.p="",n.b=document.baseURI||self.location.href;var i={};return(()=>{"use strict";n.r(i),n.d(i,{ChannelState:()=>Se,Channels:()=>Mt,PublisherState:()=>Vt,Publishers:()=>Jt,SDK:()=>ye,default:()=>Kt});var e,t,r,o=n(383),a=n.n(o),s=n(579),u=n.n(s),c=n(693),l=n.n(c),d=n(787),h=function(){function e(){a()(this,e)}return u()(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""}}])}();e=h,l()(h,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),l()(h,"_browserNameAndVersion",e.parseBrowserNameAndVersion()),l()(h,"_browserName",e.parseBrowserName()),l()(h,"_browserMajorVersion",e.parseBrowserMajorVersion()),l()(h,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(t=navigator)||void 0===t?void 0:t.userAgent)),l()(h,"_isAndroid",/Android/i.test(null===(r=navigator)||void 0===r?void 0:r.userAgent)),l()(h,"_isChrome69",e._browserNameAndVersion.includes("Chrome/69.")),l()(h,"_isChrome70",e._browserNameAndVersion.includes("Chrome/70.")),l()(h,"_isChrome71",e._browserNameAndVersion.includes("Chrome/71.")),l()(h,"_isChrome72",e._browserNameAndVersion.includes("Chrome/72.")),l()(h,"_isChrome74",e._browserNameAndVersion.includes("Chrome/74.")),l()(h,"_isChrome75",e._browserNameAndVersion.includes("Chrome/75.")),l()(h,"_isChrome76",e._browserNameAndVersion.includes("Chrome/76.")),l()(h,"_isChrome77",e._browserNameAndVersion.includes("Chrome/77."));var p=function(){function e(){a()(this,e)}return u()(e,null,[{key:"clientOfferDisabled",get:function(){return h.isChrome74||h.isChrome75||h.isChrome76||h.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return h.isChrome69||h.isChrome70||h.isChrome71||h.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=69||"Firefox"===h.browserName&&h.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=63||"Firefox"===h.browserName&&h.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===h.browserName&&h.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===h.browserName||"SamsungBrowser"===h.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==h.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){return"Chrome"===h.browserName&&"function"==typeof d.A.documentCreateElement}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===h.browserName&&h.browserMajorVersion>=71||"Firefox"===h.browserName&&h.browserMajorVersion>=69||"Safari"===h.browserName}},{key:"isMobile",get:function(){return h.isMobile()}},{key:"isInsertableStreamsSupported",get:function(){return!("undefined"==typeof MediaStreamTrackProcessor||"undefined"==typeof MediaStreamTrackGenerator)}},{key:"isEncodedInsertableStreamsSupported",get:function(){return"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams}},{key:"isRTCRtpScriptTransformSupported",get:function(){return"undefined"!=typeof RTCRtpScriptTransform}},{key:"isRequestVideoFrameCallbackSupported",get:function(){return void 0!==HTMLVideoElement.prototype.requestVideoFrameCallback}},{key:"isChannelFrameTimingInformationSupported",get:function(){return e.isRequestVideoFrameCallbackSupported&&(e.isEncodedInsertableStreamsSupported||e.isRTCRtpScriptTransformSupported)}},{key:"errorStackAlsoHasErrorMessage",get:function(){return"Firefox"!==h.browserName&&"Safari"!==h.browserName}}])}(),f=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}({}),m=function(){return u()((function e(t,n,i){a()(this,e),l()(this,"_category",void 0),l()(this,"_appenders",void 0),l()(this,"_threshold",void 0),this._category=t,this._appenders=n,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>f.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(f.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>f.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(f.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>f.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(f.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>f.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(f.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>f.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(f.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>f.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(f.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,i=new Date,r=this.replacePlaceholders(t);this._appenders.value.forEach((function(t){t.log(e,r,n.category,i)}))}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],i=0;n.indexOf&&e.length>1&&i>=0;)if((i=n.indexOf("%",i))>0)switch(n.substring(i+1,i+2)){case"%":n=n.substring(0,i)+n.substring(i+1),i++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,i),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,i),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce((function(e,n,i,r){return i+1===r.length&&n instanceof Error?p.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}}])}(),v=function(){return u()((function e(){a()(this,e),l()(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}),[])}}])}(),g=function(){return u()((function e(){a()(this,e)}),null,[{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"sendLogs",get:function(){return this._sendLogs}},{key:"sendMetrics",get:function(){return this._sendMetrics}},{key:"logToConsole",get:function(){return this._logToConsole}},{key:"applyFeatures",value:function(){try{var e={sendLocalCandidates:!1,sendLogs:"Off",sendMetrics:"Essential",logToConsole:"Off"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}])}();l()(g,"_sendLocalCandidates",void 0),l()(g,"_sendLogs",void 0),l()(g,"_sendMetrics",void 0),l()(g,"_logToConsole",void 0),g.applyFeatures();var _=function(){return u()((function e(){a()(this,e)}),null,[{key:"defaultLoggingLevel",get:function(){return f[g.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return f[g.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return f.Info}}])}(),y=function(){return u()((function e(){a()(this,e),l()(this,"_threshold",_.defaultLoggingLevel)}),[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}])}(),b=function(){return u()((function e(t){a()(this,e),l()(this,"_threshold",void 0),this._threshold=t}),[{key:"log",value:function(e,t,n,i){if(!(e<this._threshold)){var r="".concat(i.toISOString()," [").concat(n,"] [").concat(f[e],"] ").concat(t);e<f.Warn?console.log(r):console.error(r)}}}])}(),C=n(293),k=n.n(C),S=n(756),x=n.n(S),w=function(){function e(){throw a()(this,e),new Error("Numbers is a static class that may not be instantiated")}return u()(e,null,[{key:"countNumberLength",value:function(t){var n=0,i=t;return i<0&&(i*=-1,n++),e.countDigitsBeforeDecimal(i)+n+(i!==Math.floor(i)?e.countDigitsAfterDecimal(i)+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,i=Math.floor(t),r=0;i!==n&&r<15;)r++,i=e.fixRounding(n,r);return r}}])}(),T=function(){return u()((function e(){a()(this,e)}),null,[{key:"sdkVersion",get:function(){try{return"2024-12-09T18:19:35.161Z (2024.2.8-beta.367)"}catch(e){return this._defaultVersion}}}])}();l()(T,"_defaultVersion",(new Date).toISOString());var P=function(){return u()((function e(t){a()(this,e),l()(this,"_telemetryConfiguration",void 0),l()(this,"_logs",[]),l()(this,"_isSending",void 0),l()(this,"_domain",d.A.locationHostname),this._telemetryConfiguration=t}),[{key:"push",value:function(e,t,n,i){var r=(i.valueOf()-this._telemetryConfiguration.pageLoadTime)/1e3,o={timestamp:i.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:f[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:T.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:r};e<f.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"sendLogs",value:(t=k()(x().mark((function e(t){var n;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new d.A.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,d.A.fetch(this._telemetryConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"sendLogsIfAble",value:(e=k()(x().mark((function e(){var t,n,i,r,o,a=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._logs.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:for(t=0,n=0,this._isSending=!0,i=function(e){return"number"==typeof e?w.countNumberLength(e):e.length},r=function(e){return Object.values(e).reduce((function(e,t){return e+(t?i(t):0)}),0)};this._logs.length>t&&r(this._logs[t])+n<8192;)n+=r(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,r(this._logs[t])+(8192-r(this._logs[t]))),t=1),o=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.abrupt("return",this.sendLogs(o).then((function(e){return a._isSending=!1,a.sendLogsIfAble(),e})).catch((function(){a._isSending=!1,a.sendLogsIfAble()})));case 12:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]);var e,t}(),E=function(){return u()((function e(t){a()(this,e),l()(this,"_telemetryService",void 0),l()(this,"_tenancy",void 0),l()(this,"_sessionId",void 0),l()(this,"_threshold",void 0),this._tenancy=t.tenancy,this._sessionId=t.sessionId,this._threshold=t.threshold,this._telemetryService=new P(t)}),[{key:"log",value:function(e,t,n,i){e<this._threshold||this._telemetryService.push(e,t,n,i)}}])}(),F=function(){return u()((function e(){a()(this,e),l()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),l()(this,"_tenancy",void 0),l()(this,"_sessionId",void 0),l()(this,"_environment",void 0),l()(this,"_pageLoadTime",void 0),l()(this,"_threshold",_.defaultTelemetryLoggingLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new d.A.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}}])}(),R=function(){return u()((function e(){a()(this,e)}),null,[{key:"defaultTelemetryLevel",get:function(){return I[g.sendMetrics]}}])}(),I=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),D=function(){return u()((function e(){a()(this,e),l()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),l()(this,"_tenancy",void 0),l()(this,"_sessionId",void 0),l()(this,"_environment",void 0),l()(this,"_threshold",R.defaultTelemetryLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new d.A.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}}])}(),L=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},O=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case I.Off:return"Off";case I.Essential:return"Essential";case I.All:return"All";default:L(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return I.Off;case"Essential":return I.Essential;case"All":return I.All;default:L(e)}}}])}(),A=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case f.Off:return"Off";case f.Trace:return"Trace";case f.Debug:return"Debug";case f.Info:return"Trace";case f.Warn:return"Warn";case f.Error:return"Error";case f.Fatal:return"Fatal";case f.All:return"All";default:L(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return f.Off;case"Trace":return f.Trace;case"Debug":return f.Debug;case"Info":return f.Info;case"Warn":return f.Warn;case"Error":return f.Error;case"Fatal":return f.Fatal;case"All":return f.All;default:L(e)}}}])}(),M=function(){return u()((function e(){a()(this,e)}),[{key:"getStringValue",value:function(e){return this.defaultStringValue[e]}},{key:"getBooleanValue",value:function(e){return this.defaultBooleanValue[e]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":O.convertTelemetryLevelToTelemetryLevelType(R.defaultTelemetryLevel),"phenix-logging-level":A.convertLoggingLevelToLoggingLevelType(_.defaultLoggingLevel),"phenix-console-logging-level":A.convertLoggingLevelToLoggingLevelType(_.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":A.convertLoggingLevelToLoggingLevelType(_.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}}}])}(),U=function(){function e(){throw a()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return u()(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 m(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=this._configurationParameterReader.getStringValue("phenix-logging-level");f[e]&&this._threshold.setThreshold(f[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=this._configurationParameterReader.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(f[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new b(e||_.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||_.defaultTelemetryLoggingLevel,this._appenders.add(new E(this._telemetryConfiguration))}}])}();l()(U,"_configurationParameterReader",new M),l()(U,"_loggers",{}),l()(U,"_appenders",new v),l()(U,"_threshold",new y),l()(U,"_telemetryConfiguration",new F),U.applyLoggerConfigFromParameterConfiguration();var V=function(){return u()((function e(){throw a()(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)}}])}(),B=n(452),N=n.n(B),j=n(72),z=n.n(j),G=n(511),H=n.n(G),q=function(){return u()((function e(t){a()(this,e),l()(this,"_disposed",void 0),l()(this,"_disposable",void 0),this._disposed=!1,this._disposable=t}),[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}])}();function W(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(W=function(){return!!e})()}var J=function(e){function t(e,n){return a()(this,t),i=this,r=t,o=[function(){var t=e.indexOf(n);t>=0&&e.splice(t,1)}],r=z()(r),N()(i,W()?Reflect.construct(r,o||[],z()(i).constructor):r.apply(i,o));var i,r,o}return H()(t,e),u()(t)}(q),K=function(){return u()((function e(t){a()(this,e),l()(this,"_listeners",void 0),l()(this,"_value",void 0),this._listeners=[],this._value=t}),[{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))}t&&(this._value=e,this._listeners.forEach((function(t){t(e)})))}},{key:"subscribe",value:function(e){return this._listeners.push(e),e(this._value),new J(this._listeners,e)}}])}(),Q=function(){return u()((function e(t){a()(this,e),l()(this,"_subject",void 0),this._subject=t}),[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}])}(),Z=function(){return u()((function e(t){var n,i;a()(this,e),l()(this,"_applicationId",void 0),l()(this,"_token",void 0),this._applicationId=(null==t?void 0:t.applicationId)||"",this._token={uri:null!=t&&null!==(n=t.token)&&void 0!==n&&n.uri?new d.A.URL(t.token.uri):null,capabilities:(null==t||null===(i=t.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}}])}(),$=function(){function e(){a()(this,e)}return u()(e,null,[{key:"parseToken",value:function(t){if(!this.isEncodedEdgeTokenValid(t))return e._logger.error("Token is not valid [%s]",t),new Z(null);try{var n=atob(t.substr(7)),i=JSON.parse(n);return i.token=JSON.parse(i.token),new Z(i)}catch(t){return e._logger.error("Cannot parse token value",t),new Z(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();l()($,"_logger",U.getLogger("EdgeAuthParser"));var X=function(){return u()((function e(){a()(this,e),l()(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,"]")}}])}(),Y="visibilitychange",ee=function(){return u()((function e(){a()(this,e),l()(this,"_disposables",new X),l()(this,"_readOnlyIsForeground",void 0),l()(this,"_isForeground",void 0),l()(this,"_timeOfLastTabFocusChange",Date.now()),this._isForeground=new K(!0),this._readOnlyIsForeground=new Q(this._isForeground),this.initialize()}),[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"initialize",value:function(){var e=this,t=function(){return e._isForeground.value=!d.A.documentIsHidden},n=!1;d.A.addDocumentEventListener(Y,t,n),this._disposables.add(new q((function(){return d.A.removeDocumentEventListener(Y,t,n)})))}}])}(),te=n(701).A,ne=function(){return u()((function e(t){a()(this,e),l()(this,"_logger",U.getLogger("VanillaPeerConnection")),l()(this,"_peerConnection",void 0),p.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(t):this._peerConnection=new RTCPeerConnection(t)}),[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){return this._peerConnection.currentLocalDescription}},{key:"currentRemoteDescription",get:function(){return this._peerConnection.currentRemoteDescription}},{key:"connectionState",get:function(){return this._peerConnection.connectionState}},{key:"iceConnectionState",get:function(){return this._peerConnection.iceConnectionState}},{key:"supportsGetConfiguration",get:function(){return"function"==typeof this._peerConnection.getConfiguration}},{key:"supportsSetConfiguration",get:function(){return"function"==typeof this._peerConnection.setConfiguration}},{key:"supportsGetTransceivers",get:function(){return!p.getTransceiversDisabled&&"function"==typeof this._peerConnection.getTransceivers}},{key:"supportsAddTransceiver",get:function(){return!p.addTranceiverDisabled&&"function"==typeof this._peerConnection.addTransceiver}},{key:"createOffer",value:(i=k()(x().mark((function e(t){var n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!p.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new te((function(e,i){return n._peerConnection.createOffer(e,i,t)})));case 2:return e.abrupt("return",this._peerConnection.createOffer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"createAnswer",value:(n=k()(x().mark((function e(t){var n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!p.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new te((function(e,i){return n._peerConnection.createAnswer(e,i,t)})));case 2:return e.abrupt("return",this._peerConnection.createAnswer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLocalDescription",value:(t=k()(x().mark((function e(t){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._peerConnection.setLocalDescription(p.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"setRemoteDescription",value:(e=k()(x().mark((function e(t){var n;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0: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.abrupt("return",this._peerConnection.setRemoteDescription(p.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"getSenders",value:function(){return this._peerConnection.getSenders()}},{key:"getReceivers",value:function(){return this._peerConnection.getReceivers()}},{key:"getStats",value:function(e){return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;return new te((function(t){e._peerConnection.getStats(t)}))}},{key:"addEventListener",value:function(e,t,n){this._peerConnection.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){this._peerConnection.removeEventListener(e,t,n)}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"addTransceiver",value:function(e,t){return this._peerConnection.addTransceiver(e,t)}},{key:"addStream",value:function(e){var t=this;e.getTracks().forEach((function(e){t._peerConnection.addTrack(e)}))}},{key:"getConfiguration",value:function(){return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){this._peerConnection.setConfiguration(e)}},{key:"ontrack",get:function(){return this._peerConnection.ontrack},set:function(e){this._peerConnection.ontrack=e}},{key:"onicecandidate",get:function(){return this._peerConnection.onicecandidate},set:function(e){this._peerConnection.onicecandidate=e}},{key:"onconnectionstatechange",get:function(){return this._peerConnection.onconnectionstatechange},set:function(e){this._peerConnection.onconnectionstatechange=e}},{key:"oniceconnectionstatechange",get:function(){return this._peerConnection.oniceconnectionstatechange},set:function(e){this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){this._peerConnection.close()}},{key:"dispose",value:function(){this._peerConnection=null}}]);var e,t,n,i}(),ie=function(){return u()((function e(){a()(this,e)}),[{key:"createPeerConnection",value:(e=k()(x().mark((function e(t){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new ne(t));case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e}(),re=function(){function e(){throw a()(this,e),new Error("PeerConnectionService is a static class that may not be instantiated")}return u()(e,null,[{key:"peerConnectionFactory",get:function(){return e._peerConnectionFactory}},{key:"initiateInitialPrecaching",value:function(){p.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(n=k()(x().mark((function t(){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e._cached={direction:"recvonly",peerConnection:e.createPeerConnectionOffer().catch((function(t){throw e._cached=null,t}))});case 1:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(t=k()(x().mark((function t(){var n,i,r,o,a=arguments;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=a.length>0&&void 0!==a[0]?a[0]:"recvonly",i=a.length>1&&void 0!==a[1]&&a[1],!e._cached||e._cached.direction!==n||i){t.next=6;break}return r=e._cached.peerConnection,e._cached=null,t.abrupt("return",r);case 6:return o=p.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:i}:void 0,t.abrupt("return",e._peerConnectionFactory.value.createPeerConnection(o).then(function(){var e=k()(x().mark((function e(t){var i,r,o;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.supportsAddTransceiver){e.next=11;break}return r=t.addTransceiver("audio",{direction:n}),i=t.addTransceiver("video",{direction:n}),e.t0=r,e.t1=i,e.t2=t,e.next=9,t.createOffer(void 0);case 9:return e.t3=e.sent,e.abrupt("return",{audioTransceiver:e.t0,videoTransceiver:e.t1,peerConnection:e.t2,localOffer:e.t3});case 11:return o="recvonly"===n?{offerToReceiveAudio:!0,offerToReceiveVideo:!0}:{},e.t4=t,e.next=15,t.createOffer(o);case 15:return e.t5=e.sent,e.abrupt("return",{peerConnection:e.t4,localOffer:e.t5});case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 8:case"end":return t.stop()}}),t)}))),function(){return t.apply(this,arguments)})}]);var t,n}();l()(re,"_logger",U.getLogger("PeerConnectionService")),l()(re,"_peerConnectionFactory",new K(new ie)),l()(re,"_cached",void 0),re.initiateInitialPrecaching();var oe=function(){return u()((function e(){a()(this,e)}),null,[{key:"getTelemetryUrl",value:function(e){try{var t=new d.A.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}}}])}(),ae=function(){return u()((function e(){a()(this,e)}),null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new d.A.URL(e).origin}catch(e){return""}}}])}(),se=function(){return u()((function e(){a()(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:""}}}}])}();l()(se,"_discoveryParameters",void 0),se.applyParameters();var ue=function(){function e(){throw a()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return u()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new d.A.URL(e.toString()),n=T.sdkVersion,i=se.discoveryParameters.intentions;return t.searchParams.set("version",n),t.searchParams.set("intentions",i),t.searchParams.set("_","".concat(Date.now())),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}])}();l()(ue,"_discoveryUri",new K("https://pcast.phenixrts.com/pcast/endPoints"));var ce,le=n(132),de=n.n(le),he=function(){return u()((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e5;a()(this,e),l()(this,"_backoffIntervalInMillisecond",void 0),l()(this,"_minBackoffIntervalInMillisecond",void 0),l()(this,"_maxBackoffIntervalInMillisecond",void 0),this._backoffIntervalInMillisecond=t,this._minBackoffIntervalInMillisecond=n,this._maxBackoffIntervalInMillisecond=i}),[{key:"getExponentialBackoffIntervalByFailureCount",value:function(e){var t=this._backoffIntervalInMillisecond/1e3,n=.5+.5*Math.random(),i=Math.pow(t,e-2),r=Math.floor(i)*n,o=Math.ceil(Math.max(1e3*r,this._minBackoffIntervalInMillisecond));return Math.min(o,this._maxBackoffIntervalInMillisecond)}}])}(),pe=function(e){return e[e.TimeToFirstFrame=0]="TimeToFirstFrame",e[e.ChannelCreationTimeToFirstFrame=1]="ChannelCreationTimeToFirstFrame",e[e.Stalled=2]="Stalled",e[e.Buffering=3]="Buffering",e[e.SetupCompleted=4]="SetupCompleted",e[e.SetupFailed=5]="SetupFailed",e[e.RoundTripTime=6]="RoundTripTime",e[e.DownlinkThroughputCapacity=7]="DownlinkThroughputCapacity",e[e.NetworkType=8]="NetworkType",e[e.ResolutionChanged=9]="ResolutionChanged",e[e.ApplicationForeground=10]="ApplicationForeground",e[e.ApplicationBackground=11]="ApplicationBackground",e}(pe||{}),fe=pe,me=function(){return u()((function e(t){a()(this,e),l()(this,"_metrics",void 0),this._metrics=t}),[{key:"getName",value:function(){return fe[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case fe.TimeToFirstFrame:case fe.ChannelCreationTimeToFirstFrame:return I.Essential;case fe.Stalled:case fe.Buffering:case fe.SetupCompleted:case fe.SetupFailed:case fe.RoundTripTime:case fe.DownlinkThroughputCapacity:case fe.NetworkType:case fe.ResolutionChanged:case fe.ApplicationForeground:case fe.ApplicationBackground:return I.All;default:L(this._metrics)}}}])}(),ve=function(){return u()((function e(t){a()(this,e),l()(this,"_logger",U.getLogger("MetricsService")),l()(this,"_metricsConfiguration",void 0),l()(this,"_exponentialBackoff",void 0),l()(this,"_metrics",[]),l()(this,"_isSending",void 0),l()(this,"_failureCount",0),l()(this,"_domain",d.A.locationHostname),this._metricsConfiguration=t,this._exponentialBackoff=new he}),[{key:"metricsConfiguration",get:function(){return this._metricsConfiguration}},{key:"push",value:function(e){var t=e.streamId,n=e.value,i=e.previousValue,r=e.runtime,o=e.resource,a=e.kind,s=new me(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:i,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:T.sdkVersion,runtime:r,resource:o,kind:a};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:(t=k()(x().mark((function e(t){var n;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new d.A.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,d.A.fetch(this._metricsConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(e=k()(x().mark((function e(){var t,n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._metrics.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.abrupt("return",this.sendMetrics(t).then((function(e){if(n.isResponseStatusCodeRetryable(e)){if(n._metrics.length<=2048)return n._failureCount++,void d.A.setTimeout((function(){n._metrics=[].concat(de()(t),de()(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()})));case 6:case"end":return e.stop()}}),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,t}(),ge=function(){function e(){throw a()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return u()(e,null,[{key:"getMetricsService",value:function(t){if("string"!=typeof t)throw new Error("ur");var n=e._metricsServices[t];if(n)return n;var i=new D;return i.sessionId=ye.clientSessionId,i.tenancy=ye.tenancy.value,i.url=oe.getTelemetryUrl(t),i.environment=ae.getEnvironmentFromUrl(t),i.threshold=O.convertTelemetryLevelTypeToTelemetryLevel(ye.telemetryLevel),e._metricsServices[t]=new ve(i)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}])}();l()(ge,"_metricsServices",{});var _e=window.__phenixPageLoadTime||window.__pageLoadTime||Date.now(),ye=function(){function e(){throw a()(this,e),new Error("SDK is a static class that may not be instantiated")}return u()(e,null,[{key:"pageLoadTime",get:function(){return _e}},{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 A.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return O.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return h}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=U.telemetryConfiguration;n.sessionId=e.clientSessionId,n.pageLoadTime=e.pageLoadTime,e._environment.subscribe((function(e){n.environment=e})),e.telemetryUrl.subscribe((function(e){var i=t._logger.appenders.value.find((function(e){return e instanceof E}));i&&(n.url=e,t._logger.appenders.remove(i),t._logger.appenders.add(new E(n)),t._logger.info("Telemetry URL was set to [%s]",n.url))})),e._tenancy.subscribe((function(e){var i=t._logger.appenders.value.find((function(e){return e instanceof E}));i&&e&&(n.tenancy=e,t._logger.appenders.remove(i),t._logger.appenders.add(new E(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=ge.getMetricsService(ue.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=this._configurationParameterReader.getStringValue("phenix-metrics-level");t&&ge.setTelemetryLevel(I[t]),e._telemetryLevel.subscribe((function(e){ge.setTelemetryLevel(e)}))}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=this._configurationParameterReader.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=this._configurationParameterReader.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=this._configurationParameterReader.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=this._configurationParameterReader.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=ae.getEnvironmentFromUrl(t)}));var t=this._configurationParameterReader.getStringValue("phenix-channel-token");if(t){var n=$.parseToken(t);return e._tenancy.value=n.tenancy,ue.uri.value=(n.uri||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var i=this._configurationParameterReader.getStringValue("phenix-uri");if(i)return ue.uri.value=i,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var r=this._configurationParameterReader.getStringValue("phenix-base-uri");if(r){var o=new d.A.URL(r);return o.pathname="/pcast/endPoints",ue.uri.value=o.toString(),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)}}},{key:"init",value:function(t){if(this._initialized.value||(this._applicationActivityMonitor=new ee),t){if(t.discoveryUri&&(ue.uri.value=t.discoveryUri),t.peerConnectionFactory&&(re.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&I[t.telemetryLevel]&&(e._telemetryLevel.value=O.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&f[t.loggingLevel]&&this._logger.threshold.setThreshold(A.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&f[t.consoleLoggingLevel]){var n=this._logger.appenders.value.find((function(e){return e instanceof b}));n&&this._logger.appenders.remove(n),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new b(A.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)}e._initialized.value=!0}},{key:"dispose",value:function(){e._initialized.value=!1,this._applicationActivityMonitor.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return oe.getTelemetryUrl(e)}}])}();ce=ye,l()(ye,"_automaticallyRetryOnFailure",!0),l()(ye,"_automaticallyReconnectPeerConnection",!0),l()(ye,"_automaticallyPlayMediaStream",!0),l()(ye,"_automaticallyMuteVideoOnPlayFailure",!0),l()(ye,"_forceGarbageCollectionOnRestart",!0),l()(ye,"_skipGarbageCollectionOnMobileDevices",!0),l()(ye,"_webPlayerLoader",null),l()(ye,"_shakaPlayerLoader",null),l()(ye,"_hlsJsLoader",null),l()(ye,"_configurationParameterReader",new M),l()(ye,"_applicationActivityMonitor",void 0),l()(ye,"_environment",new K("")),l()(ye,"_telemetryUrl",new K("https://telemetry.phenixrts.com/telemetry")),l()(ye,"_maximalNumberOfPeerConnectionReconnectAttempts",8),l()(ye,"_telemetryLevel",new K(R.defaultTelemetryLevel)),l()(ye,"_metricsService",void 0),l()(ye,"_metricsConfiguration",void 0),l()(ye,"_sendLocalCandidates",new K(g.sendLocalCandidates)),l()(ye,"_tenancy",new K("")),l()(ye,"_clientSessionId",V.random(32)),l()(ye,"_loadedTimestamp",new Date),l()(ye,"_logger",U.getLogger("SDK")),l()(ye,"_initialized",new K(!1)),l()(ye,"_readOnlyInitialized",new Q(ce._initialized)),l()(ye,"_readOnlyDiscoveryUri",new Q(ue.uri)),l()(ye,"_readOnlyPeerConnectionFactory",new Q(re.peerConnectionFactory)),d.A.addWindowEventListener("unload",(function(){ye.dispose()})),ye.applyDiscoveryUriDefaultFromParameterConfiguration(),ye.applyMetricsConfiguration(),ye.applyTelemetryConfiguration(),ye.applyAutomaticallyRetryOnFailureFromParameterConfiguration(),ye.applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration(),ye.applyForceGarbageCollectionOnRestartFromParameterConfiguration(),ye.applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration(),ye.init();var be=function(){function e(t,n){a()(this,e),l()(this,"width",void 0),l()(this,"height",void 0),this.width=t,this.height=n}return u()(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)}}])}(),Ce=function(){return u()((function e(){throw a()(this,e),new Error("GarbageCollectorManager is a static class that may not be instantiated")}),null,[{key:"forceGarbageCollection",value:function(){p.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){p.isQueueMicrotaskSupported?d.A.queueMicrotask(this.overloadMemoryToInvokeGarbageCollection.bind(this)):d.A.setTimeout(this.overloadMemoryToInvokeGarbageCollection.bind(this),0)}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=d.A.documentCreateElement("img");e.src=d.A.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){d.A.URL.revokeObjectURL(this.src),e=null}}}])}(),ke=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}(ke||{}),Se=ke,xe=function(){return u()((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;a()(this,e),l()(this,"_duration",void 0),this._duration=t}),[{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),i=n%1e3,r=(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"),(r||i)&&(s.push(String(r)),i&&s.push("."+this.padStart(i.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(){return u()((function e(t,n,i,r){a()(this,e),l()(this,"_pageLoadTime",void 0),l()(this,"_channelStartTime",void 0),l()(this,"_logger",U.getLogger("StreamTelemetry")),l()(this,"_disposables",new X),l()(this,"_streamId",void 0),l()(this,"_metricsService",void 0),l()(this,"_listenToFirstTime",void 0),l()(this,"_listenForStall",void 0),l()(this,"_listenForContinuation",void 0),l()(this,"_timeToFirstFrame",void 0),l()(this,"_channelCreationTimeToFirstFrame",void 0),l()(this,"_startRecordingFirstFrame",void 0),l()(this,"_videoStalled",void 0),l()(this,"_lastProgress",void 0),l()(this,"_videoResolution",void 0),l()(this,"_clearTimeToFirstFrameListener",void 0),l()(this,"_clearRebufferingListener",void 0),this._streamId=t,this._pageLoadTime=n,this._channelStartTime=i,this._metricsService=r}),[{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 q((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 q((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 xe(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:fe.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 xe(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:fe.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 xe(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:fe.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,i=!("playing"===e.type||n>0)||("progress"===e.type||"timeupdate"===e.type)&&t.buffered.end(n-1)===this._lastProgress;if(this._videoStalled&&!i){"progress"===e.type&&(this._lastProgress=t.buffered.end(n-1));var r=Date.now()-this._videoStalled;this._metricsService.push({metricType:fe.Buffering,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{uint64:r},streamId:this._streamId}),this._logger.info("[%s] [%s] [buffering] Stream has recovered from stall after [%s]",this.durationSincePageLoad,this._streamId,new xe(r).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:fe.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}}])}(),Te=function(){return u()((function e(t){a()(this,e),l()(this,"_logger",U.getLogger("StreamSetupListener")),l()(this,"metricsService",ye.metricsService),l()(this,"_pageLoadTime",void 0),l()(this,"_startTime",void 0),l()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=t}),[{key:"success",value:function(e){this.recordStreamMetric(fe.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(fe.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),i=n-this._startTime,r=new me(e).getName();this.metricsService.push({metricType:e,runtime:(n-this._pageLoadTime)/1e3,value:{uint64:i},streamId:t}),this._logger.info("[%s] [%s] Stream metric [%s] in [%s]",new xe(n-this._pageLoadTime).toIsoString(),t,r,new xe(i).toIsoString())}}}])}(),Pe=function(){return u()((function e(){a()(this,e),l()(this,"_disposables",new X),l()(this,"_isSupported",void 0!==d.A.navigatorConnection),l()(this,"_rtt",new K(void 0)),l()(this,"_effectiveType",new K(void 0)),l()(this,"_downlinkThroughputCapacity",new K(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,i;return null!==(e=null!==(t=null===(n=d.A.navigatorConnection)||void 0===n?void 0:n.downlink)&&void 0!==t?t:null===(i=d.A.navigatorConnection)||void 0===i?void 0:i.downlinkMax)&&void 0!==e?e:-1}},{key:"getEffectiveType",value:function(){var e,t,n,i;return null!==(e=null!==(t=null===(n=d.A.navigatorConnection)||void 0===n?void 0:n.effectiveType)&&void 0!==t?t:null===(i=d.A.navigatorConnection)||void 0===i?void 0:i.type)&&void 0!==e?e:"Unknown"}},{key:"getRoundTripTime",value:function(){var e,t;return null!==(e=null===(t=d.A.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=d.A.navigatorConnection)||void 0===e||e.addEventListener("change",n),this._disposables.add(new q((function(){var e;return null===(e=d.A.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()}}])}(),Ee=function(){return u()((function e(t,n){var i=this;a()(this,e),l()(this,"_logger",U.getLogger("SessionTelemetry")),l()(this,"_metricsService",void 0),l()(this,"_applicationActivityMonitor",ye.applicationActivityMonitor),l()(this,"_networkMonitor",new Pe),l()(this,"_pageLoadTime",void 0),l()(this,"_disposables",new X),l()(this,"_lastNetworkStatistics",{}),this._pageLoadTime=t,this._disposables.add(this._networkMonitor),this._metricsService=n,this._networkMonitor.isSupported&&(this._disposables.add(this._applicationActivityMonitor.isForeground.subscribe((function(e){i.recordForegroundChange(e)}))),this._disposables.add(this._networkMonitor.rtt.subscribe((function(e){i.recordNetworkRTTUpdate(e)}))),this._disposables.add(this._networkMonitor.effectiveType.subscribe((function(e){i.recordNetworkTypeChangeUpdate(e)}))),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe((function(e){i.recordNetworkDownlinkThroughputCapacityUpdate(e)}))))}),[{key:"listenOnStreamSetup",value:function(){return new Te(this._pageLoadTime)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"recordForegroundChange",value:function(e){var t=Date.now(),n=this._applicationActivityMonitor.getTimeSinceLastChange();this._metricsService.push({metricType:e?fe.ApplicationForeground:fe.ApplicationBackground,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:n}}),this._logger.info("Application has gone into the [%s] after [%s] ms",e?"foreground":"background",new xe(n).toIsoString())}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:fe.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 xe(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:fe.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 xe(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:fe.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 xe(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),Fe=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Re=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),Ie=u()((function e(t){a()(this,e),l()(this,"token",void 0),l()(this,"tokenExpiring",void 0),this.token=new K(t),this.tokenExpiring=new K(!1)})),De=function(){return u()((function e(t){var n;a()(this,e),l()(this,"channelInitialization",void 0),l()(this,"disposables",void 0),l()(this,"channelDisposables",void 0),l()(this,"rendererDisposables",void 0),l()(this,"videoElement",void 0),l()(this,"state",void 0),l()(this,"autoMuted",void 0),l()(this,"autoPaused",void 0),l()(this,"authorized",void 0),l()(this,"online",void 0),l()(this,"loading",void 0),l()(this,"playing",void 0),l()(this,"standby",void 0),l()(this,"stopped",void 0),l()(this,"targetLag",void 0),l()(this,"lag",void 0),l()(this,"bitrateLimit",void 0),l()(this,"resolution",void 0),l()(this,"failureCount",void 0),l()(this,"endPoint",void 0),l()(this,"stream",void 0),l()(this,"rtcStatistics",void 0),l()(this,"videoTelemetry",void 0),l()(this,"rtcAudioStatistic",void 0),l()(this,"rtcVideoStatistic",void 0),l()(this,"clearFailureCountTimeout",void 0),this.disposables=new X,this.channelDisposables=new X,this.rendererDisposables=new X,this.channelInitialization=new Date,this.videoElement=new K(null),this.state=new K(Se.Initializing),this.autoMuted=new K(!1),this.autoPaused=new K(!1),this.authorized=new K(!0),this.online=new K(!0),this.loading=new K(!1),this.playing=new K(!1),this.standby=new K(!1),this.stopped=new K(!1),this.targetLag=new K(null!==(n=null==t?void 0:t.targetLag)&&void 0!==n?n:0),this.lag=new K(0),this.bitrateLimit=new K(0),this.resolution=new K(be.empty),this.failureCount=new K(0),this.endPoint=new K(null),this.stream=new K(null),this.rtcStatistics=new K(null)}),[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":this.authorized.value=!1;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=ye.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return Se.Starting;case"no-stream":case"not-found":return Se.StandBy;case"geo-restricted":return Se.GeoRestricted;case"geo-blocked":return Se.GeoBlocked;case"unauthorized":return Se.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Se.Recovering;case"forbidden-tag":return Se.ConfigurationError;case"port-in-range-not-found":return Se.TransientConfigurationError;case"failed":return Se.Error;default:L(e)}}}])}(),Le=n(738),Oe=n.n(Le),Ae=function(){return u()((function e(){throw a()(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(Oe()(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"}}}])}(),Me=function(){return u()((function e(){a()(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(Oe()(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"}}}])}(),Ue=u()((function e(t){a()(this,e),l()(this,"hasInsertableStreams",void 0),l()(this,"hasEncodedInsertableStreams",void 0),l()(this,"videoStreamTransformCallback",void 0),l()(this,"audioStreamTransformCallback",void 0),l()(this,"encodedVideoStreamSink",void 0),l()(this,"encodedAudioStreamSink",void 0),this.hasInsertableStreams=new K(t.hasInsertableStreams),this.hasEncodedInsertableStreams=new K(t.hasEncodedInsertableStreams),this.videoStreamTransformCallback=t.videoStreamTransformCallback,this.audioStreamTransformCallback=t.audioStreamTransformCallback,this.encodedVideoStreamSink=t.encodedVideoStreamSink,this.encodedAudioStreamSink=t.encodedAudioStreamSink})),Ve=u()((function e(){a()(this,e),l()(this,"mediaStream",void 0),l()(this,"peerConnection",void 0),l()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new K(null),this.peerConnection=new K(null),this.peerConnectionReconnectAttempts=0})),Be=u()((function e(){a()(this,e),l()(this,"isStarting",void 0),l()(this,"isDisposed",void 0),this.isStarting=new K(!1),this.isDisposed=!1})),Ne=u()((function e(){a()(this,e),l()(this,"shouldExtractTimecode",void 0),l()(this,"shouldExtractTimestamps",void 0),l()(this,"isEnabled",void 0),l()(this,"decodedFrameTimingInformation",void 0),l()(this,"renderedFrameTimingInformation",void 0),this.shouldExtractTimecode=new K(!1),this.shouldExtractTimestamps=new K(!1),this.isEnabled=new K(!1),this.decodedFrameTimingInformation=new K(null),this.renderedFrameTimingInformation=new K(null)})),je=n(715),ze=n.n(je),Ge=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Re.Normal:return"Normal";case Re.Force:return"Force";case Re.Reset:return"Reset";default:L(e)}}}])}(),He=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Fe.Keep:return"Keep";case Fe.Reset:return"Reset";default:L(e)}}}])}(),qe=n(701).A,We=function(){return u()((function e(t,n){if(a()(this,e),l()(this,"_logger",U.getLogger("EndPoint")),l()(this,"_uri",void 0),l()(this,"_timeout",void 0),l()(this,"_roundTripTime",void 0),this._uri=t,this._timeout=n,!n)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:(v=k()(x().mark((function e(){var t,n,i,r,o=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,qe.race([d.A.fetch(t,{method:"GET",cache:"no-cache"}),new qe((function(e,n){return d.A.setTimeout((function(){return n(new Error("Ping timed out [".concat(t,"]")))}),o._timeout)}))]);case 4:if(i=e.sent,r=Date.now(),i.ok){e.next=8;break}throw new Error("Ping failed [".concat(t,"] [").concat(i.status,"]"));case 8:return this._roundTripTime=r-n,e.abrupt("return",this._roundTripTime);case 10:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"subscribe",value:(m=k()(x().mark((function e(t,n,i){var r,o,a,s,u,c,l,h,p,f,m,v,g=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=$.parseToken(t).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",t),e.abrupt("return",{status:"unauthorized"});case 4:return o=this.buildUrl([r,"stream","subscribe"]).toString(),a=new d.A.FormData,s=T.sdkVersion,0===i&&n?(u={apiVersion:7,clientVersion:s,bearerToken:t,failureCount:i,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:7,sessionDescription:{type:n.type,sdp:n.sdp}},createAnswerDescription:{apiVersion:7}},a.append("jsonBody",JSON.stringify(u))):(c={apiVersion:7,clientVersion:s,bearerToken:t,failureCount:i,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:7}},a.append("jsonBody",JSON.stringify(c))),l=Date.now(),e.prev=9,p=null,e.next=13,qe.race([d.A.fetch(o,{method:"POST",body:a}),new qe((function(e){return p=d.A.setTimeout((function(){g._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(o,"]"))),e({status:408})}),g._timeout)}))]).finally((function(){p&&d.A.clearTimeout(p)}));case 13:h=e.sent,e.next=20;break;case 16:return e.prev=16,e.t0=e.catch(9),this._logger.error("Failed to subscribe",e.t0),e.abrupt("return",{status:"failed"});case 20:if("ok"===(f=this.mapHttpStatusToSubscribeStatus(h))){e.next=23;break}return e.abrupt("return",{status:f});case 23:return m=Date.now(),e.next=26,this.convertHttpResponseToSubscribeResponse(r,h);case 26:return v=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",v,m-l),e.abrupt("return",v);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n){return m.apply(this,arguments)})},{key:"publish",value:(f=k()(x().mark((function e(t,n,i,r){var o,a,s,u,c,l,h,p,f,m,v,g,_=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=$.parseToken(n).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",n),e.abrupt("return",{status:"unauthorized"});case 4:return a=this.buildUrl([o,"stream","publish"]).toString(),s=new d.A.FormData,u=T.sdkVersion,0===r&&i?(c={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:r,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:7,sessionDescription:{type:i.type,sdp:i.sdp}},createAnswerDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(c))):(l={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:r,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(l))),h=Date.now(),e.prev=9,f=null,e.next=13,qe.race([d.A.fetch(a,{method:"POST",body:s}),new qe((function(e){return f=d.A.setTimeout((function(){_._logger.error("Failed to publish",new Error("Publish timed out [".concat(a,"]"))),e({status:408})}),_._timeout)}))]).finally((function(){f&&d.A.clearTimeout(f)}));case 13:p=e.sent,e.next=20;break;case 16:return e.prev=16,e.t0=e.catch(9),this._logger.error("Failed to publish",e.t0),e.abrupt("return",{status:"failed"});case 20:if("ok"===(m=this.mapHttpStatusToPublishStatus(p))){e.next=23;break}return e.abrupt("return",{status:m});case 23:return v=Date.now(),e.next=26,this.convertHttpResponseToPublishResponse(o,p);case 26:return g=e.sent,this._logger.debug("Got publish response [%j] in [%s] ms",g,v-h),e.abrupt("return",g);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n,i){return f.apply(this,arguments)})},{key:"setRemoteDescription",value:(p=k()(x().mark((function e(t,n){var i,r,o,a,s,u,c,l,h,p=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),r=new d.A.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,sessionDescription:{type:n.type,sdp:n.sdp}},r.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,qe.race([d.A.fetch(i,{method:"POST",body:r}),new qe((function(e){return u=d.A.setTimeout((function(){p._logger.error("Failed to set remote description",new Error("Set remote description timed out [".concat(i,"]"))),e({status:408})}),p._timeout)}))]).finally((function(){u&&d.A.clearTimeout(u)}));case 9:s=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set remote description",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(c=this.mapHttpStatusToSetRemoteDescriptionStatus(s))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToSetRemoteDescriptionResponse(s);case 22:return h=e.sent,this._logger.debug("Got set remote description response [%j] in [%s] ms",h,l-a),e.abrupt("return",h);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return p.apply(this,arguments)})},{key:"limitBitrate",value:(h=k()(x().mark((function e(t,n,i,r,o){var a,s,u,c,l,h,p,f,m=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new d.A.FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:i,bitrateState:He.convertBitrateStateToBitrateStateType(r),bitrateMode:Ge.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,h=null,e.next=9,qe.race([d.A.fetch(a,{method:"POST",body:s}),new qe((function(e){return h=d.A.setTimeout((function(){m._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(a,"]"))),e({status:408})}),m._timeout)}))]).finally((function(){h&&d.A.clearTimeout(h)}));case 9:l=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set limit bitrate timed",e.t0),e.abrupt("return",{status:"failed"});case 16:return p=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),f=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",p,f-c),e.abrupt("return",{status:p});case 20:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t,n,i,r){return h.apply(this,arguments)})},{key:"addIceCandidates",value:(c=k()(x().mark((function e(t,n,i){var r,o,a,s,u,c,l,h,p,f,m=this,v=arguments;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=v.length>3&&void 0!==v[3]?v[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),a=new d.A.FormData,s={apiVersion:7,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:i,options:r},a.append("jsonBody",JSON.stringify(s)),u=Date.now(),e.prev=6,l=null,e.next=10,qe.race([d.A.fetch(o,{method:"POST",body:a}),new qe((function(e){return l=d.A.setTimeout((function(){m._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(o,"]"))),e({status:408})}),m._timeout)}))]).finally((function(){l&&d.A.clearTimeout(l)}));case 10:c=e.sent,e.next=17;break;case 13:return e.prev=13,e.t0=e.catch(6),this._logger.error("Failed to add ice candidates",e.t0),e.abrupt("return",{status:"failed"});case 17:if("ok"===(h=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.next=20;break}return e.abrupt("return",{status:h});case 20:return p=Date.now(),e.next=23,this.convertHttpResponseToAddIceCandidatesResponse(c);case 23:return f=e.sent,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",f,p-u),e.abrupt("return",f);case 26:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e,t,n){return c.apply(this,arguments)})},{key:"destroyStream",value:(s=k()(x().mark((function e(t,n){var i,r,o,a,s,u,c,l,h,p=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),r=new d.A.FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},r.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,qe.race([d.A.fetch(i,{method:"POST",body:r,cache:"no-cache"}),new qe((function(e){return u=d.A.setTimeout((function(){p._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(i,"]"))),e({status:408})}),p._timeout)}))]).finally((function(){u&&d.A.clearTimeout(u)}));case 9:s=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to delete stream",e.t0),e.abrupt("return",{status:"failed"});case 16:if("ok"===(c=this.mapHttpStatusToSetDestroyStreamStatus(s))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToDestroyStreamResponse(s);case 22:return h=e.sent,this._logger.info("Got destroy stream response [%j] in [%s] ms",h,l-a),e.abrupt("return",h);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return s.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(o=k()(x().mark((function e(t,n){var i,r,o,a;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(i=navigator)&&void 0!==i&&i.sendBeacon||this.destroyStream(t,n),r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),o=new d.A.FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},o.append("jsonBody",JSON.stringify(a)),navigator.sendBeacon(r,o);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new d.A.URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,de()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new d.A.URL(this._uri),t=T.sdkVersion,n=se.discoveryParameters.intentions;return e.searchParams.set("type","http"),e.searchParams.set("version",t),e.searchParams.set("intentions",n),e.searchParams.set("_","".concat(Date.now())),e.toString()}},{key:"mapHttpStatusToPublishStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 406:return"missing-channel-or-room-id";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSubscribeStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetRemoteDescriptionStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetTemporaryMaximalBitrateStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToAddIceCandidatesStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetDestroyStreamStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"convertHttpResponseToSubscribeResponse",value:(r=k()(x().mark((function e(t,n){var i,r;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return i=e.sent,(r={status:i.status}).stream={tenancy:t,streamId:i.streamId,sharedSecret:i.sharedSecret},r.lag=i.lag,i&&(i.rtcConfiguration&&(r.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(i.rtcConfiguration)),i.setRemoteDescriptionResponse&&i.setRemoteDescriptionResponse.sessionDescription&&(r.setRemoteDescriptionResponse={sessionDescription:i.setRemoteDescriptionResponse.sessionDescription}),i.createAnswerDescriptionResponse&&i.createAnswerDescriptionResponse.sessionDescription&&(r.createAnswerDescriptionResponse={sessionDescription:i.createAnswerDescriptionResponse.sessionDescription}),i.createOfferDescriptionResponse&&i.createOfferDescriptionResponse.sessionDescription&&(r.createOfferDescriptionResponse={sessionDescription:i.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(i=k()(x().mark((function e(t,n){var i,r;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return i=e.sent,(r={status:i.status}).stream={tenancy:t,streamId:i.streamId,sharedSecret:i.sharedSecret},i&&(i.rtcConfiguration&&(r.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(i.rtcConfiguration)),i.setRemoteDescriptionResponse&&i.setRemoteDescriptionResponse.sessionDescription&&(r.setRemoteDescriptionResponse={sessionDescription:i.setRemoteDescriptionResponse.sessionDescription}),i.createAnswerDescriptionResponse&&i.createAnswerDescriptionResponse.sessionDescription&&(r.createAnswerDescriptionResponse={sessionDescription:i.createAnswerDescriptionResponse.sessionDescription}),i.createOfferDescriptionResponse&&i.createOfferDescriptionResponse.sessionDescription&&(r.createOfferDescriptionResponse={sessionDescription:i.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={iceServers:[]};if(e.bundlePolicy&&(t.bundlePolicy=e.bundlePolicy),"number"==typeof e.iceCandidatePoolSize&&(t.iceCandidatePoolSize=e.iceCandidatePoolSize),e.iceServers){for(var n=[],i=0;i<e.iceServers.length;i++)n.push({urls:e.iceServers[i].urls,username:e.iceServers[i].username,credential:e.iceServers[i].credential});t.iceServers=n}return e.iceTransportPolicy&&(t.iceTransportPolicy=e.iceTransportPolicy),e.rtcpMuxPolicy&&(t.rtcpMuxPolicy=e.rtcpMuxPolicy),t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(n=k()(x().mark((function e(t){var n,i;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,i={status:n.status},n&&n.sessionDescription&&(i.sessionDescription=n.sessionDescription),e.abrupt("return",i);case 6:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(t=k()(x().mark((function e(t){var n,i;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,i={status:n.status,options:[]},n&&n.options&&(i.options=n.options),e.abrupt("return",i);case 6:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(e=k()(x().mark((function e(t){var n,i;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,i={status:n.status},e.abrupt("return",i);case 5:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,i,r,o,s,c,h,p,f,m,v}(),Je=n(701).A,Ke=function(){return u()((function e(t){if(a()(this,e),l()(this,"_logger",U.getLogger("Discovery")),l()(this,"_metricsService",void 0),l()(this,"_uri",void 0),!t)throw new Error("Discovery requires uri");this._metricsService=ge.getMetricsService(t.toString()),this._uri=t}),[{key:"discoverNearbyEndPoints",value:(t=k()(x().mark((function e(t,n){var i,r,o,a;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n){e.next=2;break}throw new Error("Discovery requires timeout");case 2:return i=t.toString(),e.next=5,Je.race([d.A.fetch(i,{method:"GET",cache:"no-cache"}),new Je((function(e,t){return d.A.setTimeout((function(){return t(new Error("Discovery timed out [".concat(i,"]")))}),n)}))]);case 5:if((r=e.sent).ok){e.next=8;break}throw new Error("Discovery failed [".concat(i,"] [").concat(r.status,"]"));case 8:if(null!==r.body){e.next=10;break}throw new Error("Discovery failed with no data [".concat(i,"]"));case 10:return e.next=12,r.text();case 12:return o=e.sent,a=o.split(","),e.abrupt("return",a.map((function(e){return new We(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=k()(x().mark((function e(){var t,n,i,r,o,a,s=this,u=arguments;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=ue.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new d.A.URL(n),t);case 4:return i=e.sent,r=0,o=function(){return new Je((function(e,t){r>=i.length&&t("Discovery of [".concat(i.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))}))},e.next=9,Je.race(i.map((function(e){return e.ping().catch((function(t){return s._logger.warn("Failed to ping end point [%s]",e,t),r++,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:fe.RoundTripTime,runtime:(n-ye.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e}))})));case 9:return a=e.sent,e.abrupt("return",a);case 11:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})}]);var e,t}(),Qe=function(){function e(){throw a()(this,e),new Error("Discovery is a static class that may not be instantiated")}return u()(e,null,[{key:"precacheClosestEndPointDiscovery",value:(n=k()(x().mark((function t(){var n;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new d.A.URL(ye.discoveryUri.value),t.abrupt("return",e.discoverClosestEndPointWithCaching(n));case 2:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(t=k()(x().mark((function t(n){var i,r,o;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=n.toString(),!e._cache[i]){t.next=3;break}return t.abrupt("return",e._cache[i]);case 3:return r=new Ke(n),o=e._cache[i]=r.discoverClosestEndPoint(),e._cache[i].then((function(){d.A.setTimeout((function(){e._cache[i]===o&&delete e._cache[i]}),6e4)})).catch((function(){delete e._cache[i]})),t.abrupt("return",o);case 7:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})},{key:"clearCachedClosestEndpoint",value:function(t){var n=t.toString();e._cache[n]&&delete e._cache[n]}}]);var t,n}();l()(Qe,"_cache",{}),Qe.precacheClosestEndPointDiscovery();var Ze=function(){return u()((function e(t){a()(this,e),l()(this,"_sdp",void 0),l()(this,"_audioCodec",void 0),l()(this,"_videoCodec",void 0),l()(this,"_isAudioTrackEnabled",void 0),l()(this,"_isVideoTrackEnabled",void 0),this._sdp=t;var n=this._sdp.split(/(\r\n|\r|\n)/),i=this._sdp.split(/(?:^|[\r\n])m=/);this._audioCodec=this.applyCodec("audio",n),this._videoCodec=this.applyCodec("video",n),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",i),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",i)}),[{key:"audioCodec",get:function(){return this._audioCodec}},{key:"videoCodec",get:function(){return this._videoCodec}},{key:"isAudioTrackEnabled",get:function(){return this._isAudioTrackEnabled}},{key:"isVideoTrackEnabled",get:function(){return this._isVideoTrackEnabled}},{key:"isTrackByTypeEnabled",value:function(e,t){var n=t.find((function(t){return t.startsWith(e)}));return!!n&&!n.includes("a=inactive")}},{key:"applyCodec",value:function(e,t){return t.find((function(n){return n.includes("a=rtpmap:".concat(t.find((function(t){return t.includes("m=".concat(e))})).split(" ")[3]))})).split(" ")[1].split("/")[0]}}])}(),$e=function(){return u()((function e(t,n,i){if(a()(this,e),l()(this,"_estimatedRoundTripTime",void 0),l()(this,"_estimatedVideoCodec",void 0),l()(this,"_estimatedAudioCodec",void 0),l()(this,"_rtcStatistic",new K({})),l()(this,"_peerConnection",void 0),l()(this,"_isMonitorRunning",!0),l()(this,"_updateTimeout",void 0),l()(this,"_tracksToMonitor",void 0),this._peerConnection=t,this._estimatedRoundTripTime=i,this._tracksToMonitor=n.getTracks().map((function(e){return e.kind}))||[],this._peerConnection){if(!p.getCurrentOfferDisabled){var r=new Ze(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=r.audioCodec,this._estimatedVideoCodec=r.videoCodec}this.updateStatistic()}}),[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(d.A.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(t=k()(x().mark((function e(){var t,n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!p.getStatsPromiseBasedDisabled){e.next=5;break}return e.next=3,this.updateStatisticLegacy();case 3:return e.sent,e.abrupt("return");case 5:return t=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=8,this._peerConnection.getStats(null).then((function(e){var i={};if(e){var r,o=n._estimatedRoundTripTime;e.forEach((function(a){if("candidate-pair"===a.type&&a.currentRoundTripTime&&(o=1e3*a.currentRoundTripTime,i.audio&&(i.audio.roundTripTime=o),i.video&&(i.video.roundTripTime=o)),"candidate-pair"===a.type&&a.lastPacketReceivedTimestamp&&(r=a.lastPacketReceivedTimestamp,i.audio&&(i.audio.lastPacketReceivedTimestamp=r),i.video&&(i.video.lastPacketReceivedTimestamp=r)),"inbound-rtp"===a.type){var s=a.kind||a.mediaType||t(a),u="";if(e.forEach((function(e){e.id===a.codecId&&(u=e.mimeType)})),s&&n._tracksToMonitor.includes(s)){var c,l,d,h,p,f=(a.bytesReceived||0)-(null!==(c=null===(l=n._rtcStatistic.value)||void 0===l||null===(d=l[s])||void 0===d?void 0:d.bytesReceived)&&void 0!==c?c:0),m=a.timestamp-(null===(h=n._rtcStatistic.value)||void 0===h||null===(p=h[s])||void 0===p?void 0:p.timestamp),v=f&&m?Math.floor(8*f/m*1e3):0;if(i[s]={ssrc:a.ssrc,mediaType:s,timestamp:a.timestamp,bitrate:v,bytesReceived:a.bytesReceived,packetsLost:a.packetsLost,packetsReceived:a.packetsReceived,codec:u||n.getCodecByType(s),roundTripTime:o},(a.lastPacketReceivedTimestamp||r)&&(i[s].lastPacketReceivedTimestamp=a.lastPacketReceivedTimestamp||r),"video"===s&&n._rtcStatistic.value&&n._rtcStatistic.value.video){i[s].framesDecoded=a.framesDecoded;var g=(a.framesDecoded-n._rtcStatistic.value.video.framesDecoded)/(i[s].timestamp-n._rtcStatistic.value.video.timestamp)*1e3;i[s].fps=g?Math.round(100*g)/100:0}}}}))}n._rtcStatistic.value=i})).then((function(){n._isMonitorRunning&&(n._updateTimeout=d.A.setTimeout((function(){return n.updateStatistic()}),1e3))}));case 8:e.sent;case 9:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"updateStatisticLegacy",value:(e=k()(x().mark((function e(){var t=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.getStatsLegacy().then((function(e){var n={},i=t._estimatedRoundTripTime;e.result().forEach((function(e){if(e.names().forEach((function(t){"googRTT"===t&&(i=e.stat(t))})),"ssrc"===e.type){var r=e.stat("mediaType").toString();n[r]={timestamp:Date.now()},n[r].ssrc=e.stat("ssrc").toString(),n[r].mediaType=r,n[r].bytesReceived=e.stat("bytesReceived"),n[r].packetsLost=e.stat("packetsLost"),n[r].packetsReceived=e.stat("packetsReceived"),n[r].codec=e.stat("googCodecName").toString()||t.getCodecByType(r),n[r].roundTripTime=i,"video"===r&&t._rtcStatistic.value&&t._rtcStatistic.value.video&&(n[r].framesDecoded=e.stat("framesDecoded"),n[r].fps=(n[r].framesDecoded-t._rtcStatistic.value.video.framesDecoded)/(n[r].timestamp-t._rtcStatistic.value.video.timestamp)*1e3||0)}})),t._rtcStatistic.value=n})).then((function(){t._isMonitorRunning&&(t._updateTimeout=d.A.setTimeout((function(){return t.updateStatistic()}),1e3))}));case 2:e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec;case"video":return this._estimatedVideoCodec;default:return"unknown"}}}]);var e,t}(),Xe=function(){return u()((function e(){throw a()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")}),null,[{key:"truncateIceServers",value:function(e){for(var t=[],n=0;n<e.iceServers.length;n++){for(var i=[],r=0;r<2;r++)e.iceServers[n].urls[r]&&i.push(e.iceServers[n].urls[r]);t.push({urls:i,username:e.iceServers[n].username,credential:e.iceServers[n].credential})}return e.iceServers=t,e}}])}(),Ye=function(e){return e[e.BufferingPeriod=0]="BufferingPeriod",e[e.PictureTiming=1]="PictureTiming",e[e.PanScanRect=2]="PanScanRect",e[e.FillerPayload=3]="FillerPayload",e[e.UserDataRegistered=4]="UserDataRegistered",e[e.UserDataUnregistered=5]="UserDataUnregistered",e[e.RecoveryPoint=6]="RecoveryPoint",e[e.DecRefPicMarkingRepeition=7]="DecRefPicMarkingRepeition",e[e.SparePic=8]="SparePic",e[e.SceneInfo=9]="SceneInfo",e[e.SubSeqInfo=10]="SubSeqInfo",e[e.SubSeqLayerCharacteristics=11]="SubSeqLayerCharacteristics",e[e.SubSeqCharacteristics=12]="SubSeqCharacteristics",e[e.FullFrameFreeze=13]="FullFrameFreeze",e[e.FullFrameFreezeRelease=14]="FullFrameFreezeRelease",e[e.FullFrameSnapshot=15]="FullFrameSnapshot",e[e.ProgressiveRefinementSegmentStart=16]="ProgressiveRefinementSegmentStart",e[e.ProgressiveRefinementSegmentEnd=17]="ProgressiveRefinementSegmentEnd",e[e.MotionConstrainedSliceGroupSet=18]="MotionConstrainedSliceGroupSet",e[e.FilmGrainCharacteristic=19]="FilmGrainCharacteristic",e[e.DeblockingFilterDisplayReference=20]="DeblockingFilterDisplayReference",e[e.StereoVideoInfo=21]="StereoVideoInfo",e[e.PostFilterHint=22]="PostFilterHint",e[e.ToneMappingInfo=23]="ToneMappingInfo",e[e.ScalabilityInfo=24]="ScalabilityInfo",e[e.SubPicScalableLayer=25]="SubPicScalableLayer",e[e.NonRequiredLayerRep=26]="NonRequiredLayerRep",e[e.PariorityLayerInfo=27]="PariorityLayerInfo",e[e.LayersNotPresent=28]="LayersNotPresent",e[e.LayerDependencyChange=29]="LayerDependencyChange",e[e.ScalableNesting=30]="ScalableNesting",e[e.BaseLayerTemporalHrd=31]="BaseLayerTemporalHrd",e[e.QualityLayerIntegrityCheck=32]="QualityLayerIntegrityCheck",e[e.RedundantPicProperty=33]="RedundantPicProperty",e[e.Tl0DepRepIndex=34]="Tl0DepRepIndex",e[e.TlSwitchingPoint=35]="TlSwitchingPoint",e[e.ParallelDecodingInfo=36]="ParallelDecodingInfo",e[e.MvcScalableNesting=37]="MvcScalableNesting",e[e.ViewScalabilityInfo=38]="ViewScalabilityInfo",e[e.MultiviewSceneInfo=39]="MultiviewSceneInfo",e[e.MultiviewAcquisitionInfo=40]="MultiviewAcquisitionInfo",e[e.NonRequiredViewComponent=41]="NonRequiredViewComponent",e[e.ViewDependencyChange=42]="ViewDependencyChange",e[e.OperationPointsNotPresent=43]="OperationPointsNotPresent",e[e.BaseViewTemporalHdr=44]="BaseViewTemporalHdr",e[e.FramePackingArrangement=45]="FramePackingArrangement",e[e.MultiviewViewPosition=46]="MultiviewViewPosition",e[e.DisplayOrientation=47]="DisplayOrientation",e[e.MvcdScalableNesting=48]="MvcdScalableNesting",e[e.MvcdViewScalabilityInfo=49]="MvcdViewScalabilityInfo",e[e.DepthRepresentationInfo=50]="DepthRepresentationInfo",e[e.ThreeDimensionalReferenceDisplaysInfo=51]="ThreeDimensionalReferenceDisplaysInfo",e[e.DepthTiming=52]="DepthTiming",e[e.DepthSamplingInfo=53]="DepthSamplingInfo",e[e.ConstrainedDepthParameterSetIdentifier=54]="ConstrainedDepthParameterSetIdentifier",e[e.GreenMetadata=55]="GreenMetadata",e[e.MasteringDisplayColourVolumev=56]="MasteringDisplayColourVolumev",e[e.ColourRemappingInfo=57]="ColourRemappingInfo",e[e.ContentLightLevelInfo=58]="ContentLightLevelInfo",e[e.AlternativeTransferCharacteristics=59]="AlternativeTransferCharacteristics",e[e.AmbientViewingEnvironment=60]="AmbientViewingEnvironment",e[e.ContentColourVolume=61]="ContentColourVolume",e[e.EquirectangularProjection=62]="EquirectangularProjection",e[e.CubemapProjection=63]="CubemapProjection",e[e.SphereRotation=64]="SphereRotation",e[e.RegionwisePacking=65]="RegionwisePacking",e[e.OmniViewport=66]="OmniViewport",e[e.AlternativeDepthInfo=67]="AlternativeDepthInfo",e[e.SeiManifest=68]="SeiManifest",e[e.SeiPrefixIndication=69]="SeiPrefixIndication",e[e.AnnotatedRegions=70]="AnnotatedRegions",e[e.ShutterIntervalInfo=71]="ShutterIntervalInfo",e}(Ye||{}),et=Ye,tt=function(){return u()((function e(t){a()(this,e),l()(this,"_data",void 0),l()(this,"_bitOffset",void 0),this._data=t,this._bitOffset=0}),[{key:"readBits",value:function(e){if(this._bitOffset+e>8*this._data.length)throw new Error("Cannot read [".concat(e,"] bits - only [").concat(this.getRemainingBits(),"] bits remaining in stream"));for(var t=0,n=e;n>0;){var i=Math.floor(this._bitOffset/8),r=8-this._bitOffset%8,o=Math.min(n,r),a=(1<<o)-1;t=t<<o|this._data[i]>>r-o&a,n-=o,this._bitOffset+=o}return t}},{key:"skipBits",value:function(e){if(this._bitOffset+e>8*this._data.length)throw new Error("Cannot skip [".concat(e,"] bits - only [").concat(this.getRemainingBits(),"] bits remaining in stream"));this._bitOffset+=e}},{key:"getRemainingBits",value:function(){return 8*this._data.length-this._bitOffset}}])}(),nt=function(){return u()((function e(){throw a()(this,e),new Error("EmulationPreventionBytes is a static class that may not be instantiated")}),null,[{key:"getOffsetWithExpandedEmulationPreventionBytes",value:function(e,t,n){for(var i=0,r=0,o=n,a=t;a<e.length&&0!==o;a++,r++)2!==i||3!==e[a]?(0===e[a]?i++:i>0&&(i=0),o--):i=0;return r}},{key:"removeEmulationPreventionBytes",value:function(e){for(var t=new Uint8Array(e.byteLength),n=0,i=0,r=2;r<e.byteLength;r++)3===e[r]&&0===e[r-1]&&0===e[r-2]&&(t.set(e.subarray(i,r),n),n+=r-i,i=r+1);return i<e.byteLength&&t.set(e.subarray(i),n),t}}])}(),it=function(e){return e[e.ProgressiveFrame=0]="ProgressiveFrame",e[e.TopField=1]="TopField",e[e.BottomField=2]="BottomField",e[e.TopFieldBottomField=3]="TopFieldBottomField",e[e.BottomFieldTopField=4]="BottomFieldTopField",e[e.TopFieldBottomFieldTopFieldRepeated=5]="TopFieldBottomFieldTopFieldRepeated",e[e.BottomFieldTopFieldBottomFieldRepeated=6]="BottomFieldTopFieldBottomFieldRepeated",e[e.FrameDoubling=7]="FrameDoubling",e[e.FrameTripling=8]="FrameTripling",e}(it||{}),rt=function(){return u()((function e(){a()(this,e)}),[{key:"parse",value:function(e,t){var n=new tt(nt.removeEmulationPreventionBytes(e)),i={picStruct:void 0};if(t.cpbDpbDelaysPresentFlag&&(n.skipBits(t.cpbRemovalDelayLengthMinus1+1),n.skipBits(t.dpbOutputDelayLengthMinus1+1)),t.picStructPresentFlag){var r=this.convertPicStructToNumClockTS(n.readBits(4));i.picStruct={numClockTS:r,clockTimestamps:[]};for(var o=0;o<i.picStruct.numClockTS;o++){var a=1===n.readBits(1);if(a){var s={ctType:n.readBits(2),nuitFieldBasedFlag:1===n.readBits(1),countingType:n.readBits(5),fullTimestampFlag:1===n.readBits(1),discontinuityFlag:1===n.readBits(1),cntDroppedFlag:1===n.readBits(1),nFrames:n.readBits(8)};s.fullTimestampFlag?(s.seconds=n.readBits(6),s.minutes=n.readBits(6),s.hours=n.readBits(5)):1===n.readBits(1)&&(s.seconds=n.readBits(6),1===n.readBits(1)&&(s.minutes=n.readBits(6),1===n.readBits(1)&&(s.hours=n.readBits(5)))),s.timeOffset=n.readBits(24),i.picStruct.clockTimestamps.push({clockTimestampFlag:a,clockTimestamp:s})}else i.picStruct.clockTimestamps.push({clockTimestampFlag:!1})}}return i}},{key:"convertPicStructToNumClockTS",value:function(e){switch(e){case it.ProgressiveFrame:case it.TopField:case it.BottomField:return 1;case it.TopFieldBottomField:case it.BottomFieldTopField:case it.FrameDoubling:return 2;case it.TopFieldBottomFieldTopFieldRepeated:case it.BottomFieldTopFieldBottomFieldRepeated:case it.FrameTripling:return 3;default:return 0}}}])}();function ot(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}var at=function(){return u()((function e(){a()(this,e),l()(this,"_listeners",new Set)}),[{key:"subscribe",value:function(e){var t=this;return this._listeners.add(e),new q((function(){return t._listeners.delete(e)}))}},{key:"emit",value:function(e){var t,n=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 ot(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)?ot(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}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._listeners);try{for(n.s();!(t=n.n()).done;)(0,t.value)(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"dispose",value:function(){this.cleanUpResources()}},{key:"cleanUpResources",value:function(){this._listeners.clear()}}])}(),st=function(){return u()((function e(){a()(this,e),l()(this,"_eventEmitters",new Map),l()(this,"_onEventWithNoSubscriberHandlers",new Set),l()(this,"_disposables",new X)}),[{key:"onEventWithNoSubscriber",value:function(e){var t=this;return this._onEventWithNoSubscriberHandlers.add(e),new q((function(){return t._onEventWithNoSubscriberHandlers.delete(e)}))}},{key:"subscribe",value:function(e,t){var n=(this._eventEmitters.get(e)||this.createEmitter(e)).subscribe(t);return this._disposables.add(n),n}},{key:"publish",value:function(e,t){var n=this._eventEmitters.get(e);n?n.emit(t):this._onEventWithNoSubscriberHandlers.forEach((function(n){return n(e,t)}))}},{key:"dispose",value:function(){this._disposables.dispose(),this.cleanUpResources()}},{key:"cleanUpResources",value:function(){this._eventEmitters.clear(),this._onEventWithNoSubscriberHandlers.clear()}},{key:"createEmitter",value:function(e){var t=new at;return this._eventEmitters.set(e,t),t}}])}(),ut=function(e){return e[e.EncodedVideoStreamChunk=0]="EncodedVideoStreamChunk",e[e.NalUnit=1]="NalUnit",e[e.SeiPayload=2]="SeiPayload",e[e.Payload=3]="Payload",e[e.PayloadSubscription=4]="PayloadSubscription",e[e.EndOfChunk=5]="EndOfChunk",e}({}),ct=function(){return u()((function e(t){a()(this,e),l()(this,"_eventPublisher",void 0),l()(this,"_disposables",new X),this._eventPublisher=t}),[{key:"subscribeToNalUnit",value:function(e,t){return this._eventPublisher.subscribe(ut.NalUnit,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToSeiPayloadType",value:function(e,t){return this._eventPublisher.subscribe(ut.SeiPayload,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToPayload",value:function(e,t,n){return this._eventPublisher.publish(ut.PayloadSubscription,{context:e,data:t}),this._eventPublisher.subscribe(ut.Payload,(function(e){e.data.uuid===t&&n(e)}))}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),lt=function(){function e(){throw a()(this,e),new Error("Uint8Arrays is a static class that may not be instantiated")}return u()(e,null,[{key:"isDataAtOffsetTargetByteSequence",value:function(e,t,n){for(var i=0;i<e.length;i++)if(e[i]!==t[n+i])return!1;return!0}},{key:"findTargetByteSequenceIndexFromOffset",value:function(t,n,i){for(var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,o=i;o<=n.byteLength;o++)if(e.isDataAtOffsetTargetByteSequence(t,n,o))return o;return r}},{key:"getUuidStringFromUint8Array",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,n=[],i=0;i<t;i++){var r=e[i].toString(16).padStart(2,"0");n.push(r),3!==i&&5!==i&&7!==i&&9!==i||n.push("-")}return n.join("")}}])}(),dt=function(e){return e[e.Unspecified=0]="Unspecified",e[e.SliceLayerNonIdrData=1]="SliceLayerNonIdrData",e[e.SliceDataPartitionALayer=2]="SliceDataPartitionALayer",e[e.SliceDataPartitionBLayer=3]="SliceDataPartitionBLayer",e[e.SliceDataPartitionCLayer=4]="SliceDataPartitionCLayer",e[e.SliceLayerIdrData=5]="SliceLayerIdrData",e[e.SupplementalEnhancementInformation=6]="SupplementalEnhancementInformation",e[e.SequenceParameterSet=7]="SequenceParameterSet",e[e.PictureParameterSet=8]="PictureParameterSet",e[e.AccessUnitDelimiter=9]="AccessUnitDelimiter",e[e.EndOfSequence=10]="EndOfSequence",e[e.EndOfStream=11]="EndOfStream",e[e.FillerData=12]="FillerData",e[e.SequenceParamterSetExtension=13]="SequenceParamterSetExtension",e[e.PrefixNalUnit=14]="PrefixNalUnit",e[e.SubsetSequenceParamterSet=15]="SubsetSequenceParamterSet",e[e.DepthParamterSet=16]="DepthParamterSet",e[e.Reserved17=17]="Reserved17",e[e.Reserved18=18]="Reserved18",e[e.SliceLayerAuxiliary=19]="SliceLayerAuxiliary",e[e.SliceExtension=20]="SliceExtension",e[e.SliceExtensionDepthViewComponent=21]="SliceExtensionDepthViewComponent",e[e.Reserved22=22]="Reserved22",e[e.Reserverd23=23]="Reserverd23",e[e.Unspecified24=24]="Unspecified24",e[e.Unspecified25=25]="Unspecified25",e[e.Unspecified26=26]="Unspecified26",e[e.Unspecified27=27]="Unspecified27",e[e.Unspecified28=28]="Unspecified28",e[e.Unspecified29=29]="Unspecified29",e[e.Unspecified30=30]="Unspecified30",e[e.Unspecified31=31]="Unspecified31",e}(dt||{}),ht=dt,pt=function(){function e(t,n){a()(this,e),l()(this,"_eventPublisher",void 0),l()(this,"_vclExtractionStrategy",void 0),l()(this,"_disposables",new X),this._eventPublisher=t,this._vclExtractionStrategy=n,this._disposables.add(this.subscribeToEncodedVideoStreamChunkEvents())}return u()(e,[{key:"dispose",value:function(){this._disposables.dispose()}},{key:"subscribeToEncodedVideoStreamChunkEvents",value:function(){return this._eventPublisher.subscribe(ut.EncodedVideoStreamChunk,this.parseEncodedVideoStreamChunk.bind(this))}},{key:"parseEncodedVideoStreamChunk",value:function(e){for(var t=e.context,n=e.data,i=0;i<n.byteLength;)i+=this.handleExtractedData(t,this.extractNalUnitAtOffset(n,i));this.notifyEndOfChunk(t)}},{key:"handleExtractedData",value:function(e,t){var n=t.annexBStartCodeLength,i=t.nalUnit,r=t.seiPayloads;return this.publishNalUnit(e,i),null==r||r.forEach(this.handleSeiPayload.bind(this,e)),i.data.byteLength+n}},{key:"handleSeiPayload",value:function(e,t){this.publishSeiPayload(e,t),t.type===et.UserDataUnregistered&&this.handleSeiPayloadUserDataUnregistered(e,t)}},{key:"handleSeiPayloadUserDataUnregistered",value:function(e,t){var n=lt.getUuidStringFromUint8Array(t.data.subarray(0,16)),i=t.data.subarray(16);this.publishPayload(e,{uuid:n,data:i})}},{key:"publishNalUnit",value:function(e,t){this._eventPublisher.publish(ut.NalUnit,{context:e,data:t})}},{key:"publishSeiPayload",value:function(e,t){this._eventPublisher.publish(ut.SeiPayload,{context:e,data:t})}},{key:"publishPayload",value:function(e,t){this._eventPublisher.publish(ut.Payload,{context:e,data:t})}},{key:"notifyEndOfChunk",value:function(e){this._eventPublisher.publish(ut.EndOfChunk,{context:e,data:null})}},{key:"extractNalUnitAtOffset",value:function(e,t){var n,i=1===e[t+2]?3:4,r=t+i,o=31&e[r];switch(o){case ht.SliceLayerNonIdrData:case ht.SliceDataPartitionALayer:case ht.SliceDataPartitionBLayer:case ht.SliceDataPartitionCLayer:case ht.SliceLayerIdrData:n=this._vclExtractionStrategy.extractVclNalUnit(e,r);break;case ht.SupplementalEnhancementInformation:n=this.extractSeiNalUnit(e,r);break;default:n=this.extractNonVclNalUnit(e,r)}return{annexBStartCodeLength:i,nalUnit:{type:o,data:n.nalUnitData},seiPayloads:n.seiPayloads}}},{key:"extractSeiNalUnit",value:function(t,n){for(var i=n+1,r=[];!lt.isDataAtOffsetTargetByteSequence(e._seiPayload4ByteEndCode,t,i)&&!lt.isDataAtOffsetTargetByteSequence(e._seiPayload3ByteEndCode,t,i)&&i<t.byteLength;){var o=this.extractSeiPayload(t,i);r.push({data:o.payload,type:o.payloadType}),i=o.endIndex}return i++,{nalUnitData:t.subarray(n,i),seiPayloads:r}}},{key:"extractNonVclNalUnit",value:function(t,n){var i=e.findAnnexBStartIndexFromOffset(t,n,t.byteLength);return{nalUnitData:t.subarray(n,i)}}},{key:"extractSeiPayload",value:function(e,t){for(var n=t,i=0;255===e[n];)n++,i++;var r=255*i+e[n];for(n++,i=0;255===e[n];)n++,i++;var o=255*i+e[n],a=++n+nt.getOffsetWithExpandedEmulationPreventionBytes(e,n,o);return{payloadType:r,payload:e.subarray(n,a),endIndex:a}}}],[{key:"findAnnexBStartIndexFromOffset",value:function(t,n,i){var r=lt.findTargetByteSequenceIndexFromOffset(e.annexB4ByteStartCode,t,n,i);return r!==i?r:lt.findTargetByteSequenceIndexFromOffset(e.annexB3ByteStartCode,t,n,i)}}])}();l()(pt,"annexB3ByteStartCode",new Uint8Array([0,0,1])),l()(pt,"annexB4ByteStartCode",new Uint8Array([0,0,0,1])),l()(pt,"_seiPayload3ByteEndCode",new Uint8Array([128,0,0,1])),l()(pt,"_seiPayload4ByteEndCode",new Uint8Array([128,0,0,0,1]));var ft=function(){return u()((function e(){a()(this,e)}),[{key:"extractVclNalUnit",value:function(e,t){var n=pt.findAnnexBStartIndexFromOffset(e,t,e.byteLength);return{nalUnitData:e.subarray(t,n)}}}])}(),mt=function(){function e(){a()(this,e)}return u()(e,[{key:"extractVclNalUnit",value:function(t,n){var i=n+pt.annexB4ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;if(lt.isDataAtOffsetTargetByteSequence(pt.annexB4ByteStartCode,t,i))return{nalUnitData:t.subarray(n+pt.annexB4ByteStartCode.byteLength,i)};var r=n+pt.annexB3ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;return lt.isDataAtOffsetTargetByteSequence(pt.annexB3ByteStartCode,t,r)?{nalUnitData:t.subarray(n+pt.annexB3ByteStartCode.byteLength,r)}:{nalUnitData:t.subarray(n)}}}])}();l()(mt,"_truncatedVclNalUnitByteLength",32);var vt=function(){},gt=function(){function e(t){a()(this,e),l()(this,"_logger",U.getLogger("PhenixEmbeddedIsoBmff2023")),l()(this,"_eventPublisher",void 0),l()(this,"_expectedPayloadUuid",new Set),l()(this,"_endOfChunkHandlersByTrackId",new Map),l()(this,"_disposables",new X),l()(this,"_enableWarningLogWhenVclEmbeddedDataNotFound",new q(this.enableWarningLogWhenVclEmbeddedDataNotFound.bind(this))),this._eventPublisher=t,this._expectedPayloadUuid.add(e._phenixVclEmbeddedDataUuid),this._expectedPayloadUuid.add(e._phenixInitializationSegmentUuid),this._disposables.add(this.subscribeToPayloadEvents()),this._disposables.add(this.subscribeToPayloadSubscriptionEvents()),this._disposables.add(this.subscribeToNalUnitEvents())}return u()(e,[{key:"subscribeToEmbeddedData",value:function(t){return this._enableWarningLogWhenVclEmbeddedDataNotFound.dispose(),this._eventPublisher.subscribe(ut.Payload,(function(n){var i=n.context,r=n.data;switch(r.uuid){case e._phenixInitializationSegmentUuid:t({context:i,data:{type:"Initialization",data:r.data}});break;case e._phenixVclEmbeddedDataUuid:t({context:i,data:{type:"Media",data:r.data}})}}))}},{key:"dispose",value:function(){this._disposables.dispose(),this._endOfChunkHandlersByTrackId.clear(),this._expectedPayloadUuid.clear()}},{key:"enableWarningLogWhenVclEmbeddedDataNotFound",value:function(){this._disposables.add(this.subscribeToEncodedVideoStreamChunkEvents()),this._disposables.add(this.subscribeToEndOfChunkEvents())}},{key:"subscribeToPayloadSubscriptionEvents",value:function(){var e=this;return this._eventPublisher.subscribe(ut.PayloadSubscription,(function(t){var n=t.data;return e._expectedPayloadUuid.add(n)}))}},{key:"subscribeToEncodedVideoStreamChunkEvents",value:function(){return this._eventPublisher.subscribe(ut.EncodedVideoStreamChunk,this.armLoggingNoVclEmbeddedDataFound.bind(this))}},{key:"subscribeToNalUnitEvents",value:function(){return this._eventPublisher.subscribe(ut.NalUnit,this.handleNalUnitEvent.bind(this))}},{key:"handleNalUnitEvent",value:function(t){var n=t.context,i=t.data;i.type>ht.SliceLayerIdrData||i.data.byteLength<e._truncatedVclNalUnitDataByteLength||(this.publishVclEmbeddedPayload(n,{uuid:e._phenixVclEmbeddedDataUuid,data:this.extractVclEmbeddedData(i)}),this.disarmLoggingNoVclEmbeddedDataFound(n.trackId))}},{key:"extractVclEmbeddedData",value:function(t){return t.data.subarray(e._truncatedVclNalUnitDataByteLength)}},{key:"publishVclEmbeddedPayload",value:function(e,t){this._eventPublisher.publish(ut.Payload,{context:e,data:t})}},{key:"armLoggingNoVclEmbeddedDataFound",value:function(e){var t=e.context;this._endOfChunkHandlersByTrackId.set(t.trackId,this.logWarningVclEmbeddedDataNotFound.bind(this,t.trackId))}},{key:"disarmLoggingNoVclEmbeddedDataFound",value:function(e){this._endOfChunkHandlersByTrackId.set(e,vt)}},{key:"logWarningVclEmbeddedDataNotFound",value:function(e){this._logger.warn("[%s] [%s] No VCL embedded data found in an encoded video stream chunk from track with id [%s]",e.streamId,e.contextId,e.trackId)}},{key:"subscribeToEndOfChunkEvents",value:function(){return this._eventPublisher.subscribe(ut.EndOfChunk,this.handleEndOfEncodedVideoStreamChunk.bind(this))}},{key:"handleEndOfEncodedVideoStreamChunk",value:function(e){var t=e.context;this._endOfChunkHandlersByTrackId.get(t.trackId)()}},{key:"subscribeToPayloadEvents",value:function(){return this._eventPublisher.subscribe(ut.Payload,this.handlePayloadEvent.bind(this))}},{key:"handlePayloadEvent",value:function(e){var t=e.context,n=e.data;this._expectedPayloadUuid.has(n.uuid)||d.A.setTimeout(this.logWarningUnexpectedPayloadUuidReceivedOnce.bind(this,t,n.uuid))}},{key:"logWarningUnexpectedPayloadUuidReceivedOnce",value:function(e,t){this._logger.warn("[%s] [%s] [%s] Received unexpected payload with uuid [%s]",e.streamId,e.contextId,e.trackId,t),this._expectedPayloadUuid.add(t)}}])}();l()(gt,"_truncatedVclNalUnitDataByteLength",32),l()(gt,"_phenixVclEmbeddedDataUuid","00000000-0000-0000-0000-000000000000"),l()(gt,"_phenixInitializationSegmentUuid","511e22bd-34c0-4cee-b6c3-3c4d407622c7");var _t=function(){return u()((function e(t,n,i){a()(this,e),l()(this,"_eventPublisher",void 0),l()(this,"_bitstream",void 0),l()(this,"_parser",void 0),l()(this,"_disposables",new X),this._eventPublisher=t,this._bitstream=n,this._parser=i,this._disposables.add(this._bitstream),this._disposables.add(this._parser)}),[{key:"bitstream",get:function(){return this._bitstream}},{key:"decode",value:function(e){this._eventPublisher.publish(ut.EncodedVideoStreamChunk,e)}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),yt=function(){return u()((function e(t,n){a()(this,e),l()(this,"_h264VideoBitstreamDecoder",void 0),l()(this,"_encoding",void 0),l()(this,"_disposables",void 0),this._h264VideoBitstreamDecoder=t,this._encoding=n,this._disposables=new X,this._disposables.add(this._h264VideoBitstreamDecoder),this._disposables.add(this._encoding)}),[{key:"bitstream",get:function(){return this._h264VideoBitstreamDecoder.bitstream}},{key:"decode",value:function(e){this._h264VideoBitstreamDecoder.decode(e)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"subscribeToEmbeddedData",value:function(e,t){return t?this._encoding.subscribeToEmbeddedData((function(n){n.trackId===t&&e(n)})):this._encoding.subscribeToEmbeddedData(e)}}])}(),bt=function(){return u()((function e(){throw a()(this,e),new Error("BitstreamDecoders is a static class that may not be instantiated")}),null,[{key:"createH264VideoBitstreamDecoder",value:function(){var e=new st,t=new ct(e),n=new pt(e,new ft);return new _t(e,t,n)}},{key:"createPhenixH264EmbeddedIsoBmff2023VideoBitstreamDecoder",value:function(){var e=new st,t=new ct(e),n=new pt(e,new mt),i=new _t(e,t,n),r=new gt(e);return new yt(i,r)}}])}();function Ct(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function kt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ct(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ct(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function St(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}var xt,wt=function(){function e(t,n){var i=this;a()(this,e),l()(this,"_channelContext",void 0),l()(this,"_frameTimingInformationContext",void 0),l()(this,"_bitstreamDecoder",bt.createH264VideoBitstreamDecoder()),l()(this,"_frameTimingsByRtpTimestamp",new Map),l()(this,"_picturingTimingParsingConfig",{cpbDpbDelaysPresentFlag:!1,picStructPresentFlag:!0}),l()(this,"_pictureTimingParser",new rt),l()(this,"_videoElementDisposables",new X),l()(this,"_currentPlaybackState","waiting"),l()(this,"_armedVideoFrameCallbackId",null),l()(this,"_disposables",new X),l()(this,"_disposed",!1),this._channelContext=t,this._frameTimingInformationContext=n,this._disposables.add(this._bitstreamDecoder),this._disposables.add(new q((function(){return i._frameTimingsByRtpTimestamp.clear()}))),this._disposables.add(this._videoElementDisposables),this._channelContext.videoElement.value&&this.setupVideoEventListeners(this._channelContext.videoElement.value),this._disposables.add(this._channelContext.videoElement.subscribe((function(e){i._videoElementDisposables.dispose(),e&&i.setupVideoEventListeners(e)}))),this._frameTimingInformationContext.shouldExtractTimecode.value&&this._disposables.add(this._bitstreamDecoder.bitstream.subscribeToSeiPayloadType(et.PictureTiming,this.onPictureTimingExtracted.bind(this)))}return u()(e,[{key:"processFrame",value:function(e,t,n,i){if(!this._disposed){var r={mid:t,trackId:n,receiveTimestamp:new Date};this.removeFrameTimingsExceedingMaxCapacity();var o=i.timestamp.toString(10);this._frameTimingsByRtpTimestamp.has(o),this._frameTimingsByRtpTimestamp.set(o,r),this._bitstreamDecoder.decode({context:{streamId:e,trackId:n,contextId:o},data:new Uint8Array(i.data)})}}},{key:"dispose",value:function(){this._disposed=!0,this._disposables.dispose()}},{key:"onPictureTimingExtracted",value:function(e){var t,n,i,r,o,a=e.context,s=a.contextId,u=a.trackId,c=e.data;if(!this._disposed){var l=null===(t=this._pictureTimingParser.parse(c.data,this._picturingTimingParsingConfig).picStruct)||void 0===t||null===(n=t.clockTimestamps.find((function(e){return!0===e.clockTimestampFlag})))||void 0===n?void 0:n.clockTimestamp;if(l){var d=this._frameTimingsByRtpTimestamp.get(s);if(d){var h={mid:d.mid,trackId:u,kind:"video",codec:"H264",timecode:{hours:null!==(i=l.hours)&&void 0!==i?i:null,minutes:null!==(r=l.minutes)&&void 0!==r?r:null,seconds:null!==(o=l.seconds)&&void 0!==o?o:null,frames:l.nFrames,isFrameDrop:l.countingType>1},sourceTimestamp:null,ingestTimestamp:null,encodeTimestamp:null,transcodeTimestamp:null,receiveTimestamp:new Date(d.receiveTimestamp),playbackState:this._currentPlaybackState};d.decodedFrameTimingInformation=h,this._frameTimingInformationContext.decodedFrameTimingInformation.value=h}}}}},{key:"videoFrameCallback",value:function(e,t){if(!this._disposed){this.armVideoFrameCallback();var n=t.rtpTimestamp;if(n){var i,r=[],o=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 St(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)?St(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}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._frameTimingsByRtpTimestamp);try{for(o.s();!(i=o.n()).done;){var a=ze()(i.value,2),s=a[0],u=a[1];if(parseInt(s,10)>n)break;"playing"===this._currentPlaybackState&&(this._frameTimingInformationContext.renderedFrameTimingInformation.value=kt(kt({},u.decodedFrameTimingInformation),{},{renderTimestamp:new Date(performance.timeOrigin+e),playbackState:"playing"})),r.push(s)}}catch(e){o.e(e)}finally{o.f()}for(var c=0,l=r;c<l.length;c++){var d=l[c];this._frameTimingsByRtpTimestamp.delete(d)}}}}},{key:"removeFrameTimingsExceedingMaxCapacity",value:function(){var t=this._frameTimingsByRtpTimestamp.size-(e.MAX_FRAME_TIMING_ENTRIES-1);if(!(t<=0))for(var n=this._frameTimingsByRtpTimestamp.keys(),i=0;i<t;i++){var r=n.next().value;this._frameTimingsByRtpTimestamp.delete(r)}}},{key:"setupVideoEventListeners",value:function(e){var t=this,n=function(){return t._currentPlaybackState="playing"};e.addEventListener("playing",n),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("playing",n)})));var i=function(){return t._currentPlaybackState="paused"};e.addEventListener("pause",i),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("pause",i)})));var r=function(){return t._currentPlaybackState="stalled"};e.addEventListener("stalled",r),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("stalled",r)})));var o=function(){return t._currentPlaybackState="waiting"};e.addEventListener("waiting",o),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("waiting",o)})));var a=function(){return t._currentPlaybackState="ended"};e.addEventListener("ended",a),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("ended",a)})));var s=function(){return t._currentPlaybackState="error"};e.addEventListener("error",s),this._videoElementDisposables.add(new q((function(){return e.removeEventListener("error",s)}))),this.armVideoFrameCallback(),this._videoElementDisposables.add(new q((function(){var e;t._armedVideoFrameCallbackId&&(null===(e=t._channelContext.videoElement.value)||void 0===e||e.cancelVideoFrameCallback(t._armedVideoFrameCallbackId))})))}},{key:"armVideoFrameCallback",value:function(){var e;this._armedVideoFrameCallbackId=null===(e=this._channelContext.videoElement.value)||void 0===e?void 0:e.requestVideoFrameCallback(this.videoFrameCallback.bind(this))}}])}();l()(wt,"MAX_FRAME_TIMING_ENTRIES",1800);var Tt=Symbol(),Pt=function(){function e(){throw a()(this,e),new Error("SurrogateFrameDataManager is a static class that may not be instantiated")}return u()(e,null,[{key:"getSurrogateAudioSilentPerCodec",value:function(t){if("OPUS"===t.toUpperCase())return e._dummyAudioSilentPerCodec.OPUS.buffer}},{key:"getInvalidSurrogateAudioData",value:function(){return e._singleZeroByte.buffer}},{key:"getSurrogateVideoIFramePerCodec",value:function(t){switch(t.toUpperCase()){case"H264":return e._useUpdateSurrogate82x82PFrameFrameNumber?(e._surrogate82x82PFrameFrameNumber=e._surrogate82x82PFrameFrameNumberReset,e._dummy82x82H264.IFrame.buffer):e._dummy2x2VideoIFramePerCodec.H264.buffer;case"VP8":return e._dummy2x2VideoIFramePerCodec.VP8.buffer;case"VP9":return e._dummy2x2VideoIFramePerCodec.VP9.buffer;default:return}}},{key:"getInvalidSurrogateVideoIFrame",value:function(t){return"H264"===t.toUpperCase()&&e._useUpdateSurrogate82x82PFrameFrameNumber&&(e._surrogate82x82PFrameFrameNumber=e._surrogate82x82PFrameFrameNumberReset,e._isAndroidChrome)?Tt:e._singleZeroByte.buffer}},{key:"getSurrogateVideoPFramePerCodec",value:function(t){switch(t.toUpperCase()){case"H264":return e._useUpdateSurrogate82x82PFrameFrameNumber?e.getSurrogate82x82PFrameAndUpdateFrameNumber():e._dummy2x2VideoPFramePerCodec.H264.buffer;case"VP8":return e._dummy2x2VideoPFramePerCodec.VP8.buffer;case"VP9":return e._dummy2x2VideoPFramePerCodec.VP9.buffer;default:return}}},{key:"getInvalidSurrogateVideoPFrame",value:function(t){if("H264"===t.toUpperCase()&&e._useUpdateSurrogate82x82PFrameFrameNumber){var n=e._surrogate82x82PFrameFrameNumber,i=e.getSurrogate82x82PFrameAndUpdateFrameNumber();return n>e._surrogate82x82PFrameFrameNumberReset?e._isAndroidChrome?Tt:e._singleZeroByte.buffer:(e._surrogate82x82PFrameFrameNumber++,i)}return e._singleZeroByte.buffer}},{key:"getSurrogate82x82PFrameAndUpdateFrameNumber",value:function(){var t=(14&e._surrogate82x82PFrameFrameNumber)>>1,n=(1&e._surrogate82x82PFrameFrameNumber)<<7,i=e._dummy82x82H264.PFrame.slice().buffer,r=e._dummy82x82H264PFrameFrameNumberIndex;return i[r]|=t,i[r+1]|=n,e._surrogate82x82PFrameFrameNumber++,i}}])}();xt=Pt,l()(Pt,"_isSafari","Safari"===h.browserName),l()(Pt,"_isMobileChrome","Chrome"===h.browserName&&h.isMobile()),l()(Pt,"_isAndroidChrome","Chrome"===h.browserName&&h.isAndroid),l()(Pt,"_singleZeroByte",new Uint8Array([0])),l()(Pt,"_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])}),l()(Pt,"_dummy2x2VideoIFramePerCodec",{H264:new Uint8Array([0,0,0,1,9,240,0,0,0,1,103,244,0,10,145,155,43,241,241,248,8,128,0,0,3,0,128,0,0,25,7,137,18,203,0,0,0,1,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])}),l()(Pt,"_dummy2x2VideoPFramePerCodec",{H264:new Uint8Array([0,0,0,1,9,240,0,0,0,1,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])}),l()(Pt,"_dummy82x82H264",{IFrame:new Uint8Array([0,0,0,1,103,66,192,13,218,24,222,34,34,16,0,0,3,0,16,0,0,3,3,200,241,66,170,0,0,0,1,104,206,15,200,0,0,0,1,6,3].concat(de()(new Uint8Array(40).fill(255)),[95],de()(new Uint8Array(10295).fill(255)),[128,0,0,0,1,101,136,132,5],de()(new Uint8Array(3).fill(255)),[15,69,0,1,87,159,39,39,39,39,39,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,117,215,93,120])),PFrame:new Uint8Array([0,0,0,1,6,3].concat(de()(new Uint8Array(40).fill(255)),[164],de()(new Uint8Array(10364).fill(255)),[128,0,0,0,1,65,154,32,21,240,75]))}),l()(Pt,"_dummy82x82H264PFrameFrameNumberIndex",10418),l()(Pt,"_surrogate82x82PFrameFrameNumberReset",1),l()(Pt,"_useUpdateSurrogate82x82PFrameFrameNumber",xt._isMobileChrome||xt._isSafari),l()(Pt,"_surrogate82x82PFrameFrameNumber",xt._surrogate82x82PFrameFrameNumberReset);var Et=function(){return u()((function e(){throw a()(this,e),new Error("InsertableStreams is a static class that may not be instantiated")}),null,[{key:"configureEncodedStreamPipeline",value:function(e,t,i,r,o,a){var s=new X,u=new K(null),c=new K(null);return e.getTracks().forEach((function(e){var l=t.filter((function(t){return t.track===e}))[0],d=e.kind;switch(d){case"video":var h=!!i;if(p.isRTCRtpScriptTransformSupported){var f=new Worker(new URL(n.p+n.u(63),n.b),{type:void 0});f.onmessage=function(){var t=k()(x().mark((function t(n){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n.data.chunk},t.t0=h,!t.t0){t.next=6;break}return t.next=5,i(e,n.data.chunk);case 5:t.t0=!t.sent;case 6:if(!t.t0){t.next=8;break}f.postMessage({forceInvalidFrame:!0});case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),l.transform=new RTCRtpScriptTransform(f,{kind:e.kind,codec:o,mustSink:h}),s.add(new q((function(){f.terminate()})));break}var m=function(){var t=k()(x().mark((function t(n,r){var a;return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n},!h){t.next=12;break}return t.next=4,i(e,n);case 4:if(t.sent){t.next=11;break}if((a="key"===n.type?Pt.getInvalidSurrogateVideoIFrame(o):Pt.getInvalidSurrogateVideoPFrame(o))!==Tt){t.next=8;break}return t.abrupt("return");case 8:n.data=a||n.data,t.next=12;break;case 11:"key"===n.type?n.data=Pt.getSurrogateVideoIFramePerCodec(o)||n.data:n.data=Pt.getSurrogateVideoPFramePerCodec(o)||n.data;case 12:r.enqueue(n);case 13:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),v=new TransformStream({transform:m}),g=l.createEncodedStreams(),_=g.readable,y=g.writable;_.pipeThrough(v).pipeTo(y);break;case"audio":var b=!!r;if(p.isRTCRtpScriptTransformSupported){var C=new Worker(new URL(n.p+n.u(444),n.b),{type:void 0});C.onmessage=function(){var t=k()(x().mark((function t(n){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(c.value={track:e,chunk:n.data.chunk},t.t0=b,!t.t0){t.next=6;break}return t.next=5,r(e,n.data.chunk);case 5:t.t0=!t.sent;case 6:if(!t.t0){t.next=8;break}C.postMessage({forceInvalidFrame:!0});case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),l.transform=new RTCRtpScriptTransform(C,{kind:e.kind,codec:a,mustSink:b});var S=new MediaStream,w=new Audio;w.srcObject=S,document.body.appendChild(w),s.add(new q((function(){C.terminate(),document.body.removeChild(w)})));break}var T=function(){var t=k()(x().mark((function t(n,i){return x().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(c.value={track:e,chunk:n},!b){t.next=9;break}return t.next=4,r(e,n);case 4:if(t.sent){t.next=8;break}n.data=Pt.getInvalidSurrogateAudioData(),t.next=9;break;case 8:n.data=Pt.getSurrogateAudioSilentPerCodec(a)||n.data;case 9:i.enqueue(n);case 10:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),P=new TransformStream({transform:T}),E=l.createEncodedStreams(),F=E.readable,R=E.writable;F.pipeThrough(P).pipeTo(R);break;default:L(d)}})),{disposables:s,encodedVideoFrame:u,encodedAudioFrame:c}}},{key:"configureInsertableStreamTransformation",value:function(e,t,n){var i=new MediaStream,r=new X;return e.getTracks().forEach((function(e){var o=e.kind;switch(o){case"video":if(t){var a=e,s=new TransformStream({transform:function(n,i){t(e,n,i)}}),u=new MediaStreamTrackProcessor({track:a}),c=new MediaStreamTrackGenerator({kind:a.kind}),l=u.readable,d=c.writable;l.pipeThrough(s).pipeTo(d),i.addTrack(c),r.add(new q((function(){i.removeTrack(c)})))}else i.addTrack(e);break;case"audio":if(n){var h=e,p=new TransformStream({transform:function(t,i){n(e,t,i)}}),f=new MediaStreamTrackProcessor({track:h}),m=new MediaStreamTrackGenerator({kind:h.kind}),v=f.readable,g=m.writable;v.pipeThrough(p).pipeTo(g),i.addTrack(m);var _=new MediaStream,y=new Audio;_.addTrack(e),y.srcObject=_,document.body.appendChild(y),r.add(new q((function(){i.removeTrack(m),document.body.removeChild(y)})))}else i.addTrack(e);break;default:L(o)}})),{transformedStream:i,disposables:r}}}])}(),Ft=n(701).A;function Rt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function It(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Rt(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Rt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Dt=function(){return u()((function e(t,n,i,r,o){a()(this,e),l()(this,"_logger",U.getLogger("RealTimeStream")),l()(this,"_channelContext",void 0),l()(this,"_peerConnectionContext",void 0),l()(this,"_streamTransformContext",void 0),l()(this,"_frameTimingInformationContext",void 0),l()(this,"_handleStreamFailure",void 0),l()(this,"_disposables",void 0),this._channelContext=t,this._peerConnectionContext=n,this._streamTransformContext=i,this._frameTimingInformationContext=r,this._handleStreamFailure=o,this._disposables=new X,this._channelContext.disposables.add(this)}),[{key:"start",value:function(e,t,n,i){var r=this,o=this._streamTransformContext.hasEncodedInsertableStreams.value||this._frameTimingInformationContext.shouldExtractTimecode.value||this._frameTimingInformationContext.shouldExtractTimestamps.value;return Ft.all([Qe.discoverClosestEndPointWithCaching(e),re.createPeerConnectionOffer("recvonly",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=ze()(e,2),i=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;return r._channelContext.online.value=!0,r._channelContext.endPoint.value=i,r._logger.info("Connecting to [%s]",i.toString()),r._logger.info("Local offer:\n"+a.sdp),!p.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration||(s.close(),s.dispose(),!ye.forceGarbageCollectionOnRestart||p.isMobile&&ye.skipGarbageCollectionOnMobileDevices||Ce.forceGarbageCollection(),s=null,a=null,r._peerConnectionContext.peerConnection.value=s),i.subscribe(t,a,r._channelContext.failureCount.value)})).then((function(e){var t=e.status,a=e.stream,s=e.rtcConfiguration,u=e.setRemoteDescriptionResponse,c=e.createOfferDescriptionResponse,l=e.createAnswerDescriptionResponse,h=e.lag;if(r._channelContext.stream.value=a,r._channelContext.lag.value=h,r._channelContext.applySessionAndStreamPropertiesToVideoElement(),r._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",r._channelContext.streamId,t,s,u,c,l),r._channelContext.state.value=r._channelContext.mapSubscribeStatusToChannelStatus(t),r._channelContext.applyStatus(t),"ok"===t)return r.applyRtcConfiguration(r._peerConnectionContext.peerConnection.value,s).then((function(e){var t,s=!1,h=!1,f=[];r._peerConnectionContext.peerConnection.value||(r._peerConnectionContext.peerConnection.value=e),e.onicecandidate=function(n){r._channelContext.stream.value===a&&r._peerConnectionContext.peerConnection.value===e&&(s||ye.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?f.push(n.candidate):h=!0,t||(t=d.A.setTimeout((function(){r._channelContext.stream.value!==a||s||r._channelContext.endPoint.value.addIceCandidates(a,f,h).then((function(e){var t=e.status,n=e.options;"ok"===t?(n.includes("cancel")&&(s=!0),r._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",r._channelContext.streamId,t,n)):r._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",r._channelContext.streamId,t)})).catch((function(e){r._logger.error("[%s] Failed to add ICE candidates",r._channelContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(r._channelContext.stream.value===a&&r._peerConnectionContext.peerConnection.value===e){var t=function(){r._channelContext.state.value=Se.ConnectionError,r._channelContext.videoElement.value&&(r._channelContext.videoElement.value.pause(),r._channelContext.videoElement.value.srcObject=null),r._channelContext.playing.value=!1,r._channelContext.loading.value=!0,r._handleStreamFailure().catch((function(t){r._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",r._channelContext.streamId,e.iceConnectionState,t)}))};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return void(d.A.navigatorIsOnLine&&(r._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",r._channelContext.streamId,e.iceConnectionState),r.reconnectPeerConnection(e,t)));case"closed":return r._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",r._channelContext.streamId,e.iceConnectionState),void t();default:L(e.iceConnectionState)}}};var m=new Ft((function(t,n){if(p.onTrackDisabled){var i=function(n){d.A.clearTimeout(r),e.removeEventListener("track",i),e.removeEventListener("addstream",i),n.streams?t(n.streams[0]):t(n.stream)},r=d.A.setTimeout((function(){e.removeEventListener("track",i),e.removeEventListener("addstream",i),n(new Error("Stream setup timed out"))}),3e4);e.addEventListener("track",i),e.addEventListener("addstream",i)}else{var o=d.A.setTimeout((function(){return n(new Error("Stream setup timed out"))}),3e4);e.ontrack=function(e){d.A.clearTimeout(o),t(e.streams[0])}}}));return new Ft((function(e){e()})).then((function(){if(u)return r._logger.info("[%s] Set local SDP offer [%s]",r._channelContext.streamId,u.sessionDescription.sdp),e.setLocalDescription(u.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._channelContext.streamId,u.sessionDescription,e.message),e}))})).then((function(){if(l)return r._logger.info("[%s] Set remote SDP answer [%s]",r._channelContext.streamId,l.sessionDescription.sdp),e.setRemoteDescription(l.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._channelContext.streamId,l.sessionDescription,e.message),e}))})).then((function(){if(c)return r._logger.info("[%s] Set remote SDP offer [%s]",r._channelContext.streamId,c.sessionDescription.sdp),e.setRemoteDescription(c.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._channelContext.streamId,c.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})})).then((function(e){return r._logger.info("[%s] Set local SDP answer [%j]",r._channelContext.streamId,e),r._channelContext.endPoint.value.setRemoteDescription(a,e)})).then((function(t){var n=t.status,i=t.sessionDescription;return r._channelContext.state.value=r.mapSetRemoteDescriptionStatusToChannelStatus(n),"ok"!==n?(r._channelContext.playing.value=!1,r._channelContext.standby.value=!0,void(r._channelContext.stopped.value=!1)):e.setLocalDescription(i).catch((function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._channelContext.streamId,i,e.message),e}))}))})).then((function(){return n.success(r._channelContext.streamId),m})).then((function(t){if(o){var n=new Ze(e.currentRemoteDescription.sdp),a=e.getReceivers(),s=Et.configureEncodedStreamPipeline(t,a,r._streamTransformContext.encodedVideoStreamSink,r._streamTransformContext.encodedAudioStreamSink,n.videoCodec,n.audioCodec),u=s.disposables,c=s.encodedVideoFrame;if("H264"===n.videoCodec.toUpperCase()&&(r._frameTimingInformationContext.shouldExtractTimecode.value||r._frameTimingInformationContext.shouldExtractTimestamps.value)){var l=new wt(r._channelContext,r._frameTimingInformationContext);r._disposables.add(l),t.getVideoTracks().forEach((function(t){var n,i=a.filter((function(e){return e.track===t}))[0],o=e.supportsGetTransceivers?null===(n=e.getTransceivers().filter((function(e){return e.receiver===i}))[0])||void 0===n?void 0:n.mid:null;i?o?(r._disposables.add(c.subscribe((function(e){e&&l.processFrame(r._channelContext.streamId,o,e.track.id,e.chunk)}))),r._frameTimingInformationContext.isEnabled.value=!0):r._logger.warn("[%s] Skipping frame timing information for track [%s] because no mid was found",r._channelContext.streamId,t.id):r._logger.warn("[%s] Skipping frame timing information for track [%s] because no receiver was found",r._channelContext.streamId,t.id)}))}r._disposables.add(u)}if(r._streamTransformContext.hasInsertableStreams.value){var h=Et.configureInsertableStreamTransformation(t,r._streamTransformContext.videoStreamTransformCallback,r._streamTransformContext.audioStreamTransformCallback),p=h.transformedStream,f=h.disposables;r._disposables.add(f),t=p}r._peerConnectionContext.mediaStream.value=t;var m=new $e(e,t,r._channelContext.endPoint.value.roundTripTime/4);r._disposables.add(m);var v=m.rtcStatistic.subscribe((function(t){if(r._channelContext.rtcStatistics.value=t,!r._channelContext.rtcVideoStatistic&&!r._channelContext.rtcAudioStatistic)return r._channelContext.rtcAudioStatistic=t.audio,void(r._channelContext.rtcVideoStatistic=t.video);var n=!1,i=!1;if(t.audio&&r._channelContext.rtcAudioStatistic&&r._channelContext.rtcAudioStatistic.timestamp!==t.audio.timestamp&&((n=r._channelContext.rtcAudioStatistic&&r._channelContext.rtcAudioStatistic.bytesReceived===t.audio.bytesReceived)&&d.A.navigatorIsOnLine&&r._logger.info("[%s] Audio track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",r._channelContext.streamId,t.audio.bytesReceived,r._channelContext.rtcAudioStatistic.bytesReceived,new xe(t.audio.timestamp-r._channelContext.rtcAudioStatistic.timestamp).toIsoString()),r._channelContext.rtcAudioStatistic=t.audio),t.video&&r._channelContext.rtcVideoStatistic&&r._channelContext.rtcVideoStatistic.timestamp!==t.video.timestamp&&((i=r._channelContext.rtcVideoStatistic&&r._channelContext.rtcVideoStatistic.bytesReceived===t.video.bytesReceived)&&d.A.navigatorIsOnLine&&r._logger.info("[%s] Video track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",r._channelContext.streamId,t.video.bytesReceived,r._channelContext.rtcVideoStatistic.bytesReceived,new xe(t.video.timestamp-r._channelContext.rtcVideoStatistic.timestamp).toIsoString()),r._channelContext.rtcVideoStatistic=t.video),d.A.navigatorIsOnLine)if(i||n)r.reconnectPeerConnection(e,(function(){r._channelContext.state.value=Se.ConnectionError,r._channelContext.videoElement.value&&(r._channelContext.videoElement.value.pause(),r._channelContext.videoElement.value.srcObject=null),r._channelContext.playing.value=!1,r._channelContext.loading.value=!0,m.dispose(),r._handleStreamFailure().catch((function(t){r._logger.error("[%s] Failed handling stream failure after track stopped with state [%s]",r._channelContext.streamId,e.iceConnectionState,t)}))}));else{if(r._peerConnectionContext.peerConnectionReconnectAttempts=0,r._channelContext.state.value!==Se.Reconnecting&&r._channelContext.state.value!==Se.Offline)return;r._channelContext.state.value=r._channelContext.playing.value?Se.Playing:Se.Paused,r._logger.info("Channel state restored to [%s] after reconnecting",Se[r._channelContext.state.value])}else r._channelContext.state.value=Se.Offline}));return r._disposables.add(v),ye.automaticallyPlayMediaStream?i(t):(r._channelContext.autoMuted.value=!1,r._channelContext.autoPaused.value=!0,r._channelContext.loading.value=!1,r._channelContext.playing.value=!1,void(r._channelContext.state.value=Se.Paused))}))}))}))}},{key:"applyRtcConfiguration",value:(e=k()(x().mark((function e(t,n){var i;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=Xe.truncateIceServers(n),e.abrupt("return",ye.peerConnectionFactory.value.createPeerConnection(n));case 3:return i=It(It({},t.getConfiguration()),n),t.setConfiguration(i),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)}))),function(t,n){return e.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._channelContext.state.value=Se.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<ye.maximalNumberOfPeerConnectionReconnectAttempts||!ye.automaticallyReconnectPeerConnection){var i;this._peerConnectionContext.peerConnectionReconnectAttempts++;var r="offer"===(null===(i=e.currentLocalDescription)||void 0===i?void 0:i.type);if(p.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!r)return;this._logger.info("Reconnecting peer connection by restarting ICE");var o=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(t){return e.setLocalDescription(t).then((function(){return e.setLocalDescription(o)}))})).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:"dispose",value:function(){this._disposables.dispose()}},{key:"mapSetRemoteDescriptionStatusToChannelStatus",value:function(e){switch(e){case"ok":return Se.Starting;case"unauthorized":return Se.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return Se.Recovering;case"failed":return Se.Error;default:L(e)}}}]);var e}(),Lt=function(){return u()((function e(){throw a()(this,e),new Error("RealTimeStreamFactory is a static class that may not be instantiated")}),null,[{key:"create",value:function(e,t,n,i,r,o){var a=$.parseToken(e).capabilities;return a.includes("on-demand")?(this._logger.error("This build does not support On-Demand Stream playback."),void(t.state.value=Se.UnsupportedFeature)):a.includes("streaming")?(this._logger.error("This build does not support Live Stream playback."),void(t.state.value=Se.UnsupportedFeature)):new Dt(t,n,i,r,o)}}])}();l()(Lt,"_logger",U.getLogger("Streaming"));var Ot=n(701).A,At=function(){return u()((function e(t,n,i){var r=this;a()(this,e),l()(this,"_logger",U.getLogger("Channel")),l()(this,"_tokenContext",void 0),l()(this,"_channelContext",void 0),l()(this,"_peerConnectionContext",void 0),l()(this,"_streamTransformContext",void 0),l()(this,"_stateContext",void 0),l()(this,"_frameTimingInformationContext",void 0),l()(this,"_exponentialBackoff",void 0),l()(this,"_channelStartTime",void 0),l()(this,"_readOnlyPeerConnection",void 0),l()(this,"_readOnlyState",void 0),l()(this,"_readOnlyAutoMuted",void 0),l()(this,"_readOnlyAutoPaused",void 0),l()(this,"_readOnlyTokenExpiring",void 0),l()(this,"_readOnlyAuthorized",void 0),l()(this,"_readOnlyOnline",void 0),l()(this,"_readOnlyLoading",void 0),l()(this,"_readOnlyPlaying",void 0),l()(this,"_readOnlyStandby",void 0),l()(this,"_readOnlyStopped",void 0),l()(this,"_readOnlyTargetLag",void 0),l()(this,"_readOnlyLag",void 0),l()(this,"_readOnlyBitrateLimit",void 0),l()(this,"_readOnlyResolution",void 0),l()(this,"_readOnlyFailureCount",void 0),l()(this,"_readOnlyEndPoint",void 0),l()(this,"_readOnlyStream",void 0),l()(this,"_readOnlyRtcStatistics",void 0),l()(this,"_readOnlyMediaStream",void 0),l()(this,"_readOnlyIsFrameTimingInformationEnabled",void 0),l()(this,"_readOnlyDecodedFrameTimingInformation",void 0),l()(this,"_readOnlyRenderedFrameTimingInformation",void 0),l()(this,"_metricsService",void 0),l()(this,"_sessionTelemetry",void 0),l()(this,"_videoMetaDataChangedHandler",void 0);var o=$.parseToken(n),s={targetLag:null==i?void 0:i.targetLag},u={hasInsertableStreams:o.capabilities.includes("insertable-streams"),hasEncodedInsertableStreams:o.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 Ie(n),this._channelContext=new De(s),this._peerConnectionContext=new Ve,this._streamTransformContext=new Ue(u),this._stateContext=new Be,this._exponentialBackoff=new he,this._channelStartTime=Date.now(),this._readOnlyPeerConnection=new Q(this._peerConnectionContext.peerConnection),this._readOnlyState=new Q(this._channelContext.state),this._readOnlyAutoMuted=new Q(this._channelContext.autoMuted),this._readOnlyAutoPaused=new Q(this._channelContext.autoPaused),this._readOnlyTokenExpiring=new Q(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new Q(this._channelContext.authorized),this._readOnlyOnline=new Q(this._channelContext.online),this._readOnlyLoading=new Q(this._channelContext.loading),this._readOnlyPlaying=new Q(this._channelContext.playing),this._readOnlyStandby=new Q(this._channelContext.standby),this._readOnlyStopped=new Q(this._channelContext.stopped),this._readOnlyTargetLag=new Q(this._channelContext.targetLag),this._readOnlyLag=new Q(this._channelContext.lag),this._readOnlyBitrateLimit=new Q(this._channelContext.bitrateLimit),this._readOnlyResolution=new Q(this._channelContext.resolution),this._readOnlyFailureCount=new Q(this._channelContext.failureCount),this._readOnlyEndPoint=new Q(this._channelContext.endPoint),this._readOnlyStream=new Q(this._channelContext.stream),this._readOnlyRtcStatistics=new Q(this._channelContext.rtcStatistics),this._readOnlyMediaStream=new Q(this._peerConnectionContext.mediaStream);var c=(o.uri||ye.discoveryUri.value).toString();ye.tenancy.value=o.tenancy||ye.tenancy.value,ue.uri.value=c,this._metricsService=ge.getMetricsService(c),this._sessionTelemetry=new Ee(ye.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=t,this._frameTimingInformationContext=new Ne,this.configureFrameTimingInformation(o),this._readOnlyIsFrameTimingInformationEnabled=new Q(this._frameTimingInformationContext.isEnabled),this._readOnlyDecodedFrameTimingInformation=new Q(this._frameTimingInformationContext.decodedFrameTimingInformation),this._readOnlyRenderedFrameTimingInformation=new Q(this._frameTimingInformationContext.renderedFrameTimingInformation),this._channelContext.channelDisposables.add(this._channelContext.videoElement.subscribe((function(e){r._channelContext.rendererDisposables.dispose(),e&&(r._channelContext.rendererDisposables.add(r._channelContext.stream.subscribe((function(e){r._channelContext.videoTelemetry&&r._channelContext.videoTelemetry.dispose(),e&&r.videoElement&&(r.videoElement.dataset&&(r.videoElement.dataset.sessionId=ye.clientSessionId,r.videoElement.dataset.streamId=r.streamId),r._channelContext.videoTelemetry=new we(r.streamId,ye.pageLoadTime,r._channelStartTime,r._metricsService),r._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(r.videoElement),r._channelContext.videoTelemetry.setupListenerForRebuffering(r.videoElement),r._channelContext.state.value===Se.Stopped)&&r.restartAfterStop()}))),r._channelContext.channelDisposables.add(r._channelContext.rendererDisposables))}))),this._channelContext.channelDisposables.add(this._channelContext.state.subscribe((function(e){r._channelContext.clearFailureCountTimeout&&d.A.clearTimeout(r._channelContext.clearFailureCountTimeout),r._channelContext.failureCount.value&&e===Se.Playing&&(r._channelContext.clearFailureCountTimeout=d.A.setTimeout((function(){r._channelContext.failureCount.value=0}),3e3))}))),this._channelContext.channelDisposables.add(this._channelContext.resolution.subscribe((function(e){r._channelContext.videoTelemetry&&r._channelContext.videoTelemetry.onVideoResolutionChanges(e.toString())}))),this._channelContext.channelDisposables.add(this._channelContext.bitrateLimit.subscribe((function(e){if(e&&r._channelContext.endPoint.value&&r._channelContext.stream.value){var t=Date.now()-r._channelContext.channelInitialization.getTime();r._channelContext.endPoint.value.limitBitrate(r._channelContext.stream.value,t,e,Fe.Keep,Re.Normal).catch((function(e){r._logger.error("Error while setting limit bitrate",e)}))}})));var h=function(){r._channelContext.stream.value&&r._channelContext.endPoint.value&&r._channelContext.endPoint.value.destroyStreamOnUnmount(r._channelContext.stream.value,"client:termination-on-window-unload")};d.A.addWindowEventListener("beforeunload",h),this._channelContext.channelDisposables.add(new q((function(){d.A.removeWindowEventListener("beforeunload",h)}))),this.start()}),[{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!==Se.Initializing&&(this._channelContext.state.value=Se.Stopped),this._channelContext.videoElement.value=e,this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.addEventListener("loadeddata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.addEventListener("loadedmetadata",this._videoMetaDataChangedHandler),this._channelContext.videoElement.value.addEventListener("resize",this._videoMetaDataChangedHandler))}},{key:"handleVideoMetaDataChanged",value:function(){var e=this._channelContext.videoElement.value;e?this.resolution.value.width===e.videoWidth&&this.resolution.value.height===e.videoHeight||(this._channelContext.resolution.value=new be(e.videoWidth,e.videoHeight)):this._channelContext.resolution.value=be.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=$.parseToken(this._tokenContext.token.value),n=(t.uri||ye.discoveryUri.value).toString();ye.tenancy.value=t.tenancy||ye.tenancy.value,ue.uri.value=n,this._metricsService=ge.getMetricsService(n),this._streamTransformContext.hasInsertableStreams.value=t.capabilities.includes("insertable-streams"),this._streamTransformContext.hasEncodedInsertableStreams.value=t.capabilities.includes("encoded-insertable-streams"),this.configureFrameTimingInformation(t),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"autoMuted",get:function(){return this._readOnlyAutoMuted}},{key:"autoPaused",get:function(){return this._readOnlyAutoPaused}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"playing",get:function(){return this._readOnlyPlaying}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"targetLag",get:function(){return this._readOnlyTargetLag}},{key:"lag",get:function(){return this._readOnlyLag}},{key:"bitrateLimit",get:function(){return this._readOnlyBitrateLimit.value}},{key:"resolution",get:function(){return this._readOnlyResolution}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._channelContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"isFrameTimingInformationEnabled",get:function(){return this._readOnlyIsFrameTimingInformationEnabled}},{key:"decodedFrameTimingInformation",get:function(){return this._readOnlyDecodedFrameTimingInformation}},{key:"renderedFrameTimingInformation",get:function(){return this._readOnlyRenderedFrameTimingInformation}},{key:"setBitrateLimit",value:function(e){this._channelContext.bitrateLimit.value=e}},{key:"clearBitrateLimit",value:function(){var e=this;if(this._channelContext.bitrateLimit.value&&this._channelContext.endPoint.value&&this._channelContext.stream.value){var t=Date.now()-this._channelContext.channelInitialization.getTime();this._channelContext.endPoint.value.limitBitrate(this._channelContext.stream.value,t,0,Fe.Keep,Re.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=k()(x().mark((function e(t){var n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Ot((function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._channelContext.rendererDisposables.add(n._stateContext.isStarting.subscribe((function(i){i||(n.processStop(t),e())})))})));case 1:case"end":return e.stop()}}),e)}))),function(e){return h.apply(this,arguments)})},{key:"processStop",value:function(e){this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.pause(),this._channelContext.videoElement.value.srcObject=null),this._channelContext.rendererDisposables.dispose(),this.cleanUpResources(e),this._channelContext.state.value=Se.Stopped}},{key:"resume",value:(c=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._peerConnectionContext.mediaStream.value){e.next=3;break}return this._channelContext.autoPaused.value=!1,e.abrupt("return",this.playMediaStreamInVideoElement(this._peerConnectionContext.mediaStream.value));case 3:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"mute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!0)}},{key:"unmute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!1,this._channelContext.autoMuted.value=!1)}},{key:"dispose",value:(s=k()(x().mark((function e(){var t=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stop("client:channel-dispose").then((function(){t._channelContext.channelDisposables.dispose(),t._stateContext.isDisposed=!0})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"getUri",value:function(e){return $.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",ye.discoveryUri.value),new d.A.URL(ye.discoveryUri.value))}},{key:"start",value:(o=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._stateContext.isStarting.value){e.next=5;break}return this._logger.info("Channel is already starting, skipping start"),e.abrupt("return");case 5:return this._stateContext.isStarting.value=!0,e.abrupt("return",this.processStart());case 7:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"processStart",value:(r=k()(x().mark((function e(){var t,n,i,r,o,a,s,u,c,l,h,f,m,v,g,_,y,b,C,k=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._channelContext.state.value=Se.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),$.isEncodedEdgeTokenValid(t)){e.next=10;break}return this._logger.error("Failed to parse token [%s]",t),this._channelContext.state.value=Se.Unauthorized,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 10:if(!this._streamTransformContext.videoStreamTransformCallback){e.next=18;break}if(i=Me.validateMediaStreamTrackTransform("video",this._streamTransformContext.videoStreamTransformCallback),r=i.valid,o=i.validationResult,r){e.next=18;break}return this._logger.error(o),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 18:if(!this._streamTransformContext.audioStreamTransformCallback){e.next=26;break}if(a=Me.validateMediaStreamTrackTransform("audio",this._streamTransformContext.audioStreamTransformCallback),s=a.valid,u=a.validationResult,s){e.next=26;break}return this._logger.error(u),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 26:if(!this._streamTransformContext.encodedVideoStreamSink){e.next=34;break}if(c=Ae.validateEncodedStreamSink("video",this._streamTransformContext.encodedVideoStreamSink),l=c.valid,h=c.validationResult,l){e.next=34;break}return this._logger.error(h),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 34:if(!this._streamTransformContext.encodedAudioStreamSink){e.next=42;break}if(f=Ae.validateEncodedStreamSink("audio",this._streamTransformContext.encodedAudioStreamSink),m=f.valid,v=f.validationResult,m){e.next=42;break}return this._logger.error(v),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 42:if(!this._streamTransformContext.hasInsertableStreams.value||!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=48;break}return this._logger.error("Both insertable-streams and encoded-insertable-streams are enabled, only use one or the other"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 48:if(g="function"==typeof this._streamTransformContext.videoStreamTransformCallback||"function"==typeof this._streamTransformContext.audioStreamTransformCallback,_="function"==typeof this._streamTransformContext.encodedVideoStreamSink||"function"==typeof this._streamTransformContext.encodedAudioStreamSink,!g||!_){e.next=56;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=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 56:if(!this._streamTransformContext.hasInsertableStreams.value){e.next=71;break}if(p.isInsertableStreamsSupported){e.next=63;break}return this._logger.error("Browser does not support Media Stream Track API"),this._channelContext.state.value=Se.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 63:if(g){e.next=69;break}return this._logger.error("CreateChannelOptions transform callback function is missing; however, insertable-streams is enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 69:e.next=77;break;case 71:if(!g){e.next=77;break}return this._logger.error("CreateChannelOptions transform callback function found; however, insertable-streams is not enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 77:if(!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=92;break}if(p.isEncodedInsertableStreamsSupported||p.isRTCRtpScriptTransformSupported){e.next=84;break}return this._logger.error("Browser does not support encodedInsertableStreams API"),this._channelContext.state.value=Se.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 84:if(_){e.next=90;break}return this._logger.error("CreateChannelOptions transform sink function is missing; however, encoded-insertable-streams is enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 90:e.next=98;break;case 92:if(!_){e.next=98;break}return this._logger.error("CreateChannelOptions transform sink function found; however, encoded-insertable-streams is not enabled"),this._channelContext.state.value=Se.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 98:if(this._channelContext.loading.value=!0,y=this.getUri(t),this._channelContext.disposables.add(this._channelContext.state.subscribe((function(e){e!==Se.Error&&e!==Se.Recovering||Qe.clearCachedClosestEndpoint(y)}))),b=function(){return new Ot((function(e){return k._stateContext.isStarting.value=!1,e(k.handleStreamFailure())}))},C=Lt.create(t,this._channelContext,this._peerConnectionContext,this._streamTransformContext,this._frameTimingInformationContext,b)){e.next=106;break}return this._stateContext.isStarting.value=!1,e.abrupt("return");case 106:return e.abrupt("return",C.start(y,t,n,this.playMediaStreamInVideoElement.bind(this)).then((function(){k._channelContext.loading.value=!1})).catch((function(e){n.fail(),k._channelContext.failureCount.value++,k._channelContext.online.value=!1,k.cleanUpResources("client:cleanup-after-failed-setup"),k._channelContext.state.value=Se.ClientStartError,k._logger.error("Failed to start channel",e)})).finally((function(){if(k._stateContext.isStarting.value=!1,k._channelContext.state.value!==Se.Playing&&ye.automaticRetryOnFailure){var e=d.A.setTimeout((function(){k.handleStreamFailure().catch((function(e){k._logger.error("Failed handling stream failure",e)}))}),k.getRetryInterval());k._channelContext.disposables.add(new q((function(){d.A.clearTimeout(e)})))}})));case 107:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"restartAfterStop",value:(i=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._peerConnectionContext.mediaStream.value){e.next=4;break}return e.abrupt("return",this.playMediaStreamInVideoElement(this._peerConnectionContext.mediaStream.value));case 4:this._tokenContext.token.value&&this.start();case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"play",value:(n=k()(x().mark((function e(){var t;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._peerConnectionContext.mediaStream.value){e.next=3;break}return e.abrupt("return",this.start());case 3:return e.abrupt("return",this.playMediaStreamInVideoElement(t));case 4:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getRetryInterval",value:function(){switch(this._channelContext.state.value){case Se.Initializing:case Se.StandBy:case Se.Offline:return 15e3;case Se.Error:case Se.Recovering:case Se.Unauthorized:case Se.GeoRestricted:case Se.GeoBlocked:case Se.Stopped:case Se.Starting:case Se.Playing:case Se.Paused:case Se.Reconnecting:case Se.UnsupportedFeature:case Se.ConfigurationError:case Se.TransientConfigurationError:case Se.ConnectionError:case Se.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._channelContext.failureCount.value);default:L(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(t=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._channelContext.state.value,e.next=e.t0===Se.Error||e.t0===Se.Reconnecting||e.t0===Se.StandBy||e.t0===Se.Offline||e.t0===Se.Recovering||e.t0===Se.TransientConfigurationError||e.t0===Se.ConnectionError||e.t0===Se.ClientStartError?3:e.t0===Se.Unauthorized?5:e.t0===Se.GeoRestricted?7:e.t0===Se.GeoBlocked?9:e.t0===Se.Stopped?11:e.t0===Se.Initializing?13:e.t0===Se.Playing?15:e.t0===Se.Paused?17:e.t0===Se.Starting?19:e.t0===Se.UnsupportedFeature?21:e.t0===Se.ConfigurationError?23:25;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,Se[this._channelContext.state.value]),e.abrupt("break",26);case 5:return this._logger.info("Channel is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 7:return this._logger.info("Channel is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 9:return this._logger.info("Channel is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 11:return this._logger.info("Channel is stopped, skipping retry of start."),e.abrupt("return");case 13:return this._logger.info("Channel is already initializing, skipping retry of start"),e.abrupt("return");case 15:return this._logger.info("Channel is playing, skipping retry of start"),e.abrupt("return");case 17:return this._logger.info("Channel is paused, skipping retry of start. Please invoke play()"),e.abrupt("return");case 19:return this._logger.info("Channel is already starting, skipping retry of start"),e.abrupt("return");case 21:return this._logger.info("Channel is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 23:return this._logger.info("Channel is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 25:L(this._channelContext.state.value);case 26:return e.abrupt("return",this.start());case 27:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._channelContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!ye.forceGarbageCollectionOnRestart||p.isMobile&&ye.skipGarbageCollectionOnMobileDevices||Ce.forceGarbageCollection()),this._peerConnectionContext.mediaStream.value&&(this._peerConnectionContext.mediaStream.value.getTracks().forEach((function(e){return e.stop()})),this._peerConnectionContext.mediaStream.value=null),this._channelContext.autoPaused.value=!1,this._channelContext.autoMuted.value=!1,this._channelContext.playing.value=!1,this._channelContext.stopped.value=!0,this._channelContext.standby.value=!1,this._channelContext.stream.value&&this._channelContext.endPoint.value&&this._channelContext.endPoint.value.destroyStream(this._channelContext.stream.value,t).then((function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)})).catch((function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)})),this.videoElement&&this.videoElement.dataset&&(this.videoElement.dataset.sessionId="",this.videoElement.dataset.streamId=""),this._channelContext.stream.value=null,this._channelContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}},{key:"configureFrameTimingInformation",value:function(e){var t=this,n=e.capabilities.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?p.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=k()(x().mark((function e(t){var n,i,r=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this._channelContext.videoElement.value){e.next=8;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=Se.Stopped,e.abrupt("return");case 8:if(this._streamTransformContext.hasEncodedInsertableStreams.value||(n.srcObject=t),void 0!==(i=n.play())){e.next=17;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=Se.Playing,e.abrupt("return");case 17:return e.abrupt("return",i.then((function(){r._channelContext.autoMuted.value=!1,r._channelContext.autoPaused.value=!1,r._channelContext.loading.value=!1,r._channelContext.playing.value=!0,r._channelContext.state.value=Se.Playing})).catch((function(e){var i=!!t.getTracks().filter((function(e){return"audio"===e.kind})).length,o=!ye.automaticallyMuteVideoOnPlayFailure;return o||n.muted||!i?(n.srcObject=null,r._channelContext.autoMuted.value=!1,r._channelContext.autoPaused.value=!0,r._channelContext.loading.value=!1,r._channelContext.playing.value=!1,r._channelContext.state.value=Se.Paused,o?void r._logger.info("[%s] Paused video after play failed. Manual user action required.",r.streamId,e):i?void r._logger.info("[%s] Failed to play video. Manual user action required.",r.streamId,e):void r._logger.info("[%s] Failed to play muted video. Manual user action required.",r.streamId,e)):(n.muted=!0,n.play().then((function(){r._logger.info("[%s] Played video after auto muting. Manual user action required to unmute.",r.streamId),r._channelContext.autoMuted.value=!0,r._channelContext.autoPaused.value=!1,r._channelContext.loading.value=!1,r._channelContext.playing.value=!0,r._channelContext.state.value=Se.Playing})).catch((function(e){n.muted=!1,r._logger.info("[%s] Failed to play video. Manual user action required.",r.streamId,e),n.srcObject=null,r._channelContext.autoMuted.value=!1,r._channelContext.autoPaused.value=!0,r._channelContext.loading.value=!1,r._channelContext.playing.value=!1,r._channelContext.state.value=Se.Paused})))})));case 18:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,i,r,o,s,c,h}(),Mt=function(){return u()((function e(){throw a()(this,e),new Error("Channels is a static class that may not be instantiated")}),null,[{key:"createChannel",value:function(e){if(!ye.initialized.value)throw new Error("SDK is not loaded.");var t={targetLag:e.targetLag,videoStreamTransformCallback:e.videoStreamTransformCallback,audioStreamTransformCallback:e.audioStreamTransformCallback,encodedVideoStreamSink:e.encodedVideoStreamSink,encodedAudioStreamSink:e.encodedAudioStreamSink};return new At(e.videoElement,e.token,t)}},{key:"isFrameTimingInformationSupported",get:function(){return p.isChannelFrameTimingInformationSupported}}])}(),Ut=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}(Ut||{}),Vt=Ut,Bt=function(){return u()((function e(t){a()(this,e),l()(this,"publisherInitialization",void 0),l()(this,"disposables",void 0),l()(this,"publisherDisposables",void 0),l()(this,"state",void 0),l()(this,"authorized",void 0),l()(this,"online",void 0),l()(this,"loading",void 0),l()(this,"publishing",void 0),l()(this,"standby",void 0),l()(this,"stopped",void 0),l()(this,"failureCount",void 0),l()(this,"endPoint",void 0),l()(this,"stream",void 0),l()(this,"rtcStatistics",void 0),l()(this,"clearFailureCountTimeout",void 0),l()(this,"startReconnectionAttemptsTimeInMilliseconds",void 0),l()(this,"name",void 0),this.disposables=new X,this.publisherDisposables=new X,this.publisherInitialization=new Date,this.state=new K(Vt.Initializing),this.authorized=new K(!0),this.online=new K(!0),this.loading=new K(!1),this.publishing=new K(!1),this.standby=new K(!1),this.stopped=new K(!1),this.failureCount=new K(0),this.endPoint=new K(null),this.stream=new K(null),this.rtcStatistics=new K(null),this.name=t&&t.length?t:this.generateScreenName(),this.startReconnectionAttemptsTimeInMilliseconds=0}),[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":this.authorized.value=!1;case"not-found":return this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null)}}},{key:"mapPublishStatusToPublisherStatus",value:function(e){switch(e){case"ok":return Vt.Starting;case"not-found":return Vt.NotFound;case"geo-restricted":return Vt.GeoRestricted;case"geo-blocked":return Vt.GeoBlocked;case"unauthorized":return Vt.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Vt.Recovering;case"missing-channel-or-room-id":case"forbidden-tag":return Vt.ConfigurationError;case"port-in-range-not-found":return Vt.TransientConfigurationError;case"failed":return Vt.Error;default:L(e)}}},{key:"generateScreenName",value:function(){return V.random(12)}}])}(),Nt=function(){return u()((function e(t,n,i){if(a()(this,e),l()(this,"_estimatedRoundTripTime",void 0),l()(this,"_estimatedVideoCodec",void 0),l()(this,"_estimatedAudioCodec",void 0),l()(this,"_rtcStatistic",new K({})),l()(this,"_peerConnection",void 0),l()(this,"_isMonitorRunning",!0),l()(this,"_updateTimeout",void 0),l()(this,"_availableTracks",void 0),this._peerConnection=t,this._estimatedRoundTripTime=i,this._peerConnection){var r=new Ze(this._peerConnection.currentLocalDescription.sdp),o=new Ze(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=o.audioCodec,this._estimatedVideoCodec=o.videoCodec,this._availableTracks={audio:r.isAudioTrackEnabled&&o.isAudioTrackEnabled,video:r.isVideoTrackEnabled&&o.isVideoTrackEnabled},this.updateStatistic()}}),[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(d.A.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(e=k()(x().mark((function e(){var t,n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!p.getStatsPromiseBasedDisabled){e.next=3;break}return e.abrupt("return");case 3:return t=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=6,this._peerConnection.getStats(null).then((function(e){var i={};if(e){var r,o=n._estimatedRoundTripTime;e.forEach((function(a){if("candidate-pair"===a.type&&a.currentRoundTripTime&&(o=1e3*a.currentRoundTripTime,i.audio&&(i.audio.roundTripTime=o),i.video&&(i.video.roundTripTime=o)),"candidate-pair"===a.type&&a.lastPacketSentTimestamp&&(r=a.lastPacketSentTimestamp,i.audio&&(i.audio.lastPacketSentTimestamp=r),i.video&&(i.video.lastPacketSentTimestamp=r)),"outbound-rtp"===a.type){var s=a.kind||a.mediaType||t(a),u="";if(e.forEach((function(e){e.id===a.codecId&&(u=e.mimeType)})),s&&n._availableTracks[s]){var c,l,d,h,p,f=(a.bytesSent||0)-(null!==(c=null===(l=n._rtcStatistic.value)||void 0===l||null===(d=l[s])||void 0===d?void 0:d.bytesSent)&&void 0!==c?c:0),m=a.timestamp-(null===(h=n._rtcStatistic.value)||void 0===h||null===(p=h[s])||void 0===p?void 0:p.timestamp),v=f&&m?Math.floor(8*f/m*1e3):0;if(i[s]={ssrc:a.ssrc,mediaType:s,timestamp:a.timestamp,bitrate:v,bytesSent:a.bytesSent,packetsSent:a.packetsSent,retransmittedBytesSent:a.retransmittedBytesSent,codec:u||n.getCodecByType(s),roundTripTime:o},(a.lastPacketSentTimestamp||r)&&(i[s].lastPacketSentTimestamp=a.lastPacketSentTimestamp||r),"video"===s&&n._rtcStatistic.value&&n._rtcStatistic.value.video){i[s].firCount=a.firCount,i[s].frameHeight=a.frameHeight,i[s].frameWidth=a.frameWidth,i[s].framesEncoded=a.framesEncoded,i[s].framesSent=a.framesSent,i[s].headerBytesSent=a.headerBytesSent,i[s].hugeFramesSent=a.hugeFramesSent,i[s].pliCount=a.pliCount,i[s].qpSum=a.qpSum,i[s].totalEncodeTime=a.totalEncodeTime,i[s].totalEncodedBytesTarget=a.totalEncodedBytesTarget;var g=(a.framesEncoded-n._rtcStatistic.value.video.framesEncoded)/(i[s].timestamp-n._rtcStatistic.value.video.timestamp)*1e3;i[s].fps=g?Math.round(100*g)/100:0}}}}))}n._rtcStatistic.value=i})).then((function(){n._isMonitorRunning&&(n._updateTimeout=d.A.setTimeout((function(){return n.updateStatistic()}),1e3))}));case 6:e.sent;case 7:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec;case"video":return this._estimatedVideoCodec;default:return"unknown"}}}]);var e}(),jt=n(701).A;function zt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Gt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?zt(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ht=function(){return u()((function e(t,n,i){a()(this,e),l()(this,"_logger",U.getLogger("RealTimePublisher")),l()(this,"_publisherContext",void 0),l()(this,"_peerConnectionContext",void 0),l()(this,"_handleStreamFailure",void 0),this._publisherContext=t,this._peerConnectionContext=n,this._handleStreamFailure=i}),[{key:"start",value:function(e,t,n){var i=this;return d.A.navigatorIsOnLine?jt.all([Qe.discoverClosestEndPointWithCaching(e),re.createPeerConnectionOffer("sendonly").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=ze()(e,2),r=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;return i._publisherContext.online.value=!0,i._publisherContext.endPoint.value=r,i._logger.info("Connecting to [%s]",r.toString()),i._logger.info("Local offer:\n"+a.sdp),(p.clientOfferDisabled||!s.supportsSetConfiguration||!s.supportsGetConfiguration||i._publisherContext.failureCount.value>0)&&(s.close(),s.dispose(),!ye.forceGarbageCollectionOnRestart||p.isMobile&&ye.skipGarbageCollectionOnMobileDevices||Ce.forceGarbageCollection(),s=null,a=null,i._peerConnectionContext.peerConnection.value=s),r.publish(i._publisherContext.name,t,a,i._publisherContext.failureCount.value)})).then((function(e){var t=e.status,r=e.stream,o=e.rtcConfiguration,a=e.setRemoteDescriptionResponse,s=e.createOfferDescriptionResponse,u=e.createAnswerDescriptionResponse;if(i._publisherContext.stream.value=r,i._logger.debug("[%s] Publish completed [%s] [%j] [%j] [%j] [%j]",i._publisherContext.streamId,t,o,a,s,u),i._publisherContext.state.value=i._publisherContext.mapPublishStatusToPublisherStatus(t),i._publisherContext.applyStatus(t),"ok"===t)return i.applyRtcConfiguration(i._peerConnectionContext.peerConnection.value,o).then((function(e){var t,o=!1,c=!1,l=[];return i._peerConnectionContext.peerConnection.value=e,e.addStream(i._peerConnectionContext.mediaStream.value),e.onicecandidate=function(n){i._publisherContext.stream.value===r&&i._peerConnectionContext.peerConnection.value===e&&(o||ye.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?l.push(n.candidate):c=!0,t||(t=d.A.setTimeout((function(){i._publisherContext.stream.value!==r||o||i._publisherContext.endPoint.value.addIceCandidates(r,l,c).then((function(e){var t=e.status,n=e.options;"ok"===t?(n.includes("cancel")&&(o=!0),i._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",i._publisherContext.streamId,t,n)):i._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",i._publisherContext.streamId,t)})).catch((function(e){i._logger.error("[%s] Failed to add ICE candidates",i._publisherContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(i._publisherContext.stream.value===r&&i._peerConnectionContext.peerConnection.value===e){var t=function(){i._publisherContext.state.value=Vt.ConnectionError,i._publisherContext.publishing.value=!1,i._publisherContext.loading.value=!0,i._handleStreamFailure().catch((function(t){i._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",i._publisherContext.streamId,e.iceConnectionState,t)}))};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return i._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",i._publisherContext.streamId,e.iceConnectionState),void i.reconnectPeerConnection(e,t);case"closed":return i._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",i._publisherContext.streamId,e.iceConnectionState),void t();default:L(e.iceConnectionState)}}},new jt((function(e){e()})).then((function(){if(a)return i._logger.info("[%s] Set local SDP offer [%s]",i._publisherContext.streamId,a.sessionDescription.sdp),e.setLocalDescription(a.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._publisherContext.streamId,a.sessionDescription,e.message),e}))})).then((function(){if(u)return i._logger.info("[%s] Set remote SDP answer [%s]",i._publisherContext.streamId,u.sessionDescription.sdp),e.setRemoteDescription(u.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._publisherContext.streamId,u.sessionDescription,e.message),e}))})).then((function(){if(s)return i._logger.info("[%s] Set remote SDP offer [%s]",i._publisherContext.streamId,s.sessionDescription.sdp),e.setRemoteDescription(s.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._publisherContext.streamId,u.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!1,offerToReceiveVideo:!1})})).then((function(e){return i._logger.info("[%s] Set local SDP answer [%s]",i._publisherContext.streamId,e.sdp),i._publisherContext.endPoint.value.setRemoteDescription(r,e)})).then((function(t){var n=t.status,r=t.sessionDescription;return i._publisherContext.state.value=i.mapSetRemoteDescriptionStatusToPublisherStatus(n),"ok"!==n?(i._publisherContext.publishing.value=!1,i._publisherContext.standby.value=!0,void(i._publisherContext.stopped.value=!1)):(i._logger.info("[%s] Set local SDP [%s]",i._publisherContext.streamId,r.sdp),e.setLocalDescription(r).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._publisherContext.streamId,r,e.message),e})))}))})).then((function(){n.success(i._publisherContext.streamId),i._publisherContext.state.value=Vt.Publishing,i._publisherContext.publishing.value=!0;var t=new Nt(e,i._peerConnectionContext.mediaStream.value,i._publisherContext.endPoint.value.roundTripTime/4);return i._publisherContext.disposables.add(t),t.rtcStatistic.subscribe((function(e){i._publisherContext.rtcStatistics.value=e})),jt.resolve()}))}))})):(this._publisherContext.state.value=Vt.Offline,jt.resolve())}},{key:"applyRtcConfiguration",value:(e=k()(x().mark((function e(t,n){var i;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=Xe.truncateIceServers(n),e.abrupt("return",ye.peerConnectionFactory.value.createPeerConnection(n));case 3:return i=Gt(Gt({},t.getConfiguration()),n),t.setConfiguration(i),e.abrupt("return",t);case 6:case"end":return e.stop()}}),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=Vt.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<ye.maximalNumberOfPeerConnectionReconnectAttempts||!ye.automaticallyReconnectPeerConnection){var i;this._peerConnectionContext.peerConnectionReconnectAttempts++;var r="offer"===(null===(i=e.currentLocalDescription)||void 0===i?void 0:i.type);if(p.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!r){var o=d.A.setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);return void this._publisherContext.disposables.add(new q((function(){return d.A.clearTimeout(o)})))}this._logger.info("Reconnecting peer connection by restarting ICE");var a=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(i){return e.setLocalDescription(i).then((function(){return e.setLocalDescription(a).then((function(){if("disconnected"===e.iceConnectionState||"failed"===e.iceConnectionState){var i=d.A.setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);n._publisherContext.disposables.add(new q((function(){return d.A.clearTimeout(i)})))}else n._publisherContext.state.value=Vt.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 Vt.Starting;case"unauthorized":return Vt.Unauthorized;case"not-found":return Vt.NotFound;case"capacity":case"rate-limited":case"timeout":return Vt.Recovering;case"failed":return Vt.Error;default:L(e)}}}]);var e}(),qt=n(701).A,Wt=function(){return u()((function e(t,n,i){var r=this;a()(this,e),l()(this,"_logger",U.getLogger("Publisher")),l()(this,"_tokenContext",void 0),l()(this,"_publisherContext",void 0),l()(this,"_peerConnectionContext",void 0),l()(this,"_stateContext",void 0),l()(this,"_exponentialBackoff",void 0),l()(this,"_publisherStartTime",void 0),l()(this,"_readOnlyToken",void 0),l()(this,"_readOnlyPeerConnection",void 0),l()(this,"_readOnlyState",void 0),l()(this,"_readOnlyTokenExpiring",void 0),l()(this,"_readOnlyAuthorized",void 0),l()(this,"_readOnlyOnline",void 0),l()(this,"_readOnlyLoading",void 0),l()(this,"_readOnlyPublishing",void 0),l()(this,"_readOnlyStandby",void 0),l()(this,"_readOnlyStopped",void 0),l()(this,"_readOnlyFailureCount",void 0),l()(this,"_readOnlyEndPoint",void 0),l()(this,"_readOnlyStream",void 0),l()(this,"_readOnlyRtcStatistics",void 0),l()(this,"_readOnlyMediaStream",void 0),l()(this,"_metricsService",void 0),l()(this,"_sessionTelemetry",void 0),this._tokenContext=new Ie(n),this._publisherContext=new Bt(i),this._peerConnectionContext=new Ve,this._stateContext=new Be,this._exponentialBackoff=new he,this._publisherStartTime=Date.now(),this._readOnlyToken=new Q(this._tokenContext.token),this._readOnlyPeerConnection=new Q(this._peerConnectionContext.peerConnection),this._readOnlyState=new Q(this._publisherContext.state),this._readOnlyTokenExpiring=new Q(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new Q(this._publisherContext.authorized),this._readOnlyOnline=new Q(this._publisherContext.online),this._readOnlyLoading=new Q(this._publisherContext.loading),this._readOnlyPublishing=new Q(this._publisherContext.publishing),this._readOnlyStandby=new Q(this._publisherContext.standby),this._readOnlyStopped=new Q(this._publisherContext.stopped),this._readOnlyFailureCount=new Q(this._publisherContext.failureCount),this._readOnlyEndPoint=new Q(this._publisherContext.endPoint),this._readOnlyStream=new Q(this._publisherContext.stream),this._readOnlyRtcStatistics=new Q(this._publisherContext.rtcStatistics),this._readOnlyMediaStream=new Q(this._peerConnectionContext.mediaStream),this._peerConnectionContext.mediaStream.value=t;var o=$.parseToken(this._tokenContext.token.value),s=(o.uri||ye.discoveryUri.value).toString();ye.tenancy.value=o.tenancy||ye.tenancy.value,ue.uri.value=s,this._metricsService=ge.getMetricsService(s),this._sessionTelemetry=new Ee(ye.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe((function(e){r._publisherContext.clearFailureCountTimeout&&d.A.clearTimeout(r._publisherContext.clearFailureCountTimeout),r._publisherContext.failureCount.value&&e===Vt.Publishing&&(r._publisherContext.clearFailureCountTimeout=d.A.setTimeout((function(){r._publisherContext.failureCount.value=0}),3e3))})));var u=function(){r._publisherContext.stream.value&&r._publisherContext.endPoint.value&&r._publisherContext.endPoint.value.destroyStreamOnUnmount(r._publisherContext.stream.value,"client:termination-on-window-unload")};d.A.addWindowEventListener("beforeunload",u),this._publisherContext.publisherDisposables.add(new q((function(){d.A.removeWindowEventListener("beforeunload",u)}))),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=$.parseToken(this._tokenContext.token.value),n=(t.uri||ye.discoveryUri.value).toString();ye.tenancy.value=t.tenancy||ye.tenancy.value,ue.uri.value=n,this._metricsService=ge.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:(r=k()(x().mark((function e(t){var n=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new qt((function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._publisherContext.disposables.add(n._stateContext.isStarting.subscribe((function(i){i||(n.processStop(t),e())})))})));case 1:case"end":return e.stop()}}),e)}))),function(e){return r.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=Vt.Stopped}},{key:"dispose",value:(i=k()(x().mark((function e(){var t=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stop("client:channel-dispose").then((function(){t._publisherContext.publisherDisposables.dispose(),t._stateContext.isDisposed=!0})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getUri",value:function(e){return $.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",ye.discoveryUri.value),new d.A.URL(ye.discoveryUri.value))}},{key:"start",value:(n=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._stateContext.isStarting.value){e.next=5;break}return this._logger.info("Publisher is already starting, skipping start"),e.abrupt("return");case 5:return this._stateContext.isStarting.value=!0,e.abrupt("return",this.processStart());case 7:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"processStart",value:(t=k()(x().mark((function e(){var t,n,i,r,o,a=this;return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publisherContext.state.value=Vt.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),$.isEncodedEdgeTokenValid(t)){e.next=10;break}return this._logger.error("Failed to parse token [%s]",t),this._publisherContext.state.value=Vt.Unauthorized,this._publisherContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 10:return this._publisherContext.loading.value=!0,i=this.getUri(t),this._publisherContext.disposables.add(this._publisherContext.state.subscribe((function(e){e!==Vt.Error&&e!==Vt.Recovering||Qe.clearCachedClosestEndpoint(i)}))),r=function(){return new qt((function(e){return a._stateContext.isStarting.value=!1,e(a.handleStreamFailure())}))},o=new Ht(this._publisherContext,this._peerConnectionContext,r),e.abrupt("return",o.start(i,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=Vt.ClientStartError,a._logger.error("Failed to start publishing",e)})).finally((function(){if(a._stateContext.isStarting.value=!1,a._publisherContext.state.value!==Vt.Publishing&&ye.automaticRetryOnFailure){var e=d.A.setTimeout((function(){a.handleStreamFailure().catch((function(e){a._logger.error("Failed handling stream failure",e)}))}),a.getRetryInterval());a._publisherContext.disposables.add(new q((function(){d.A.clearTimeout(e)})))}else a._publisherContext.startReconnectionAttemptsTimeInMilliseconds=0})));case 16:case"end":return e.stop()}}),e,this)}))),function(){return t.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){t._peerConnectionContext.peerConnection.value.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 Vt.Offline:return 15e3;case Vt.Initializing:case Vt.NotFound:case Vt.Error:case Vt.Recovering:case Vt.Unauthorized:case Vt.GeoRestricted:case Vt.GeoBlocked:case Vt.Stopped:case Vt.Starting:case Vt.Publishing:case Vt.Reconnecting:case Vt.UnsupportedFeature:case Vt.ConfigurationError:case Vt.TransientConfigurationError:case Vt.ConnectionError:case Vt.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._publisherContext.failureCount.value);default:L(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:(e=k()(x().mark((function e(){return x().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._publisherContext.state.value,e.next=e.t0===Vt.Error||e.t0===Vt.Reconnecting||e.t0===Vt.Offline||e.t0===Vt.Recovering||e.t0===Vt.TransientConfigurationError||e.t0===Vt.ConnectionError||e.t0===Vt.ClientStartError?4:e.t0===Vt.Unauthorized?11:e.t0===Vt.GeoRestricted?13:e.t0===Vt.GeoBlocked?15:e.t0===Vt.Stopped?17:e.t0===Vt.Publishing?19:e.t0===Vt.Initializing?21:e.t0===Vt.Starting?23:e.t0===Vt.UnsupportedFeature?25:e.t0===Vt.NotFound?27:e.t0===Vt.ConfigurationError?29:31;break;case 4:if(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds||(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds=Date.now()),!(72e5<=Date.now()-this._publisherContext.startReconnectionAttemptsTimeInMilliseconds)){e.next=9;break}return this._logger.info("Publisher stopped with state [%s] [%s] after exceeding timeout",this._publisherContext.state.value,Vt[this._publisherContext.state.value]),e.abrupt("return");case 9:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,Vt[this._publisherContext.state.value]),e.abrupt("break",32);case 11:return this._logger.info("Publisher is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 13:return this._logger.info("Publisher is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 15:return this._logger.info("Publisher is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 17:return this._logger.info("Publisher is stopped, skipping retry of start."),e.abrupt("return");case 19:return this._logger.info("Publisher is publishing, skipping retry of start"),e.abrupt("return");case 21:return this._logger.info("Publisher is initializing, skipping retry of start"),e.abrupt("return");case 23:return this._logger.info("Publisher is already starting, skipping retry of start"),e.abrupt("return");case 25:return this._logger.info("Publisher is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 27:return this._logger.info("Publisher is stopped due to channel not found, skipping retry of start."),e.abrupt("return");case 29:return this._logger.info("Publisher is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 31:L(this._publisherContext.state.value);case 32:return e.abrupt("return",this.start());case 33:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._publisherContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!ye.forceGarbageCollectionOnRestart||p.isMobile&&ye.skipGarbageCollectionOnMobileDevices||Ce.forceGarbageCollection()),this._publisherContext.publishing.value=!1,this._publisherContext.stopped.value=!0,this._publisherContext.standby.value=!1,this._publisherContext.stream.value&&this._publisherContext.endPoint.value&&this._publisherContext.endPoint.value.destroyStream(this._publisherContext.stream.value,t).then((function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)})).catch((function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)})),this._publisherContext.stream.value=null,this._publisherContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}}]);var e,t,n,i,r}(),Jt=function(){return u()((function e(){throw a()(this,e),new Error("Publishers is a static class that may not be instantiated")}),null,[{key:"createPublisher",value:function(e){if(!ye.initialized.value)throw new Error("SDK is not loaded.");return new Wt(e.mediaStream,e.token,e.name)}}])}(),Kt={SDK:ye,Channels:Mt,ChannelState:Se,Publishers:Jt,PublisherState:Vt}})(),i})()));
3
3
  //# sourceMappingURL=full.js.map