@phenixrts/sdk 2024.2.0 → 2024.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/channels/debug/channels.js +1 -1
- package/channels/debug/package.json +1 -1
- package/channels/debug.private/channels.js +1 -1
- package/channels/debug.private/package.json +1 -1
- package/channels/es5.debug.private/channels.js +1 -1
- package/channels/es5.debug.private/package.json +1 -1
- package/channels/min/channels.js +1 -1
- package/channels/min/package.json +1 -1
- package/channels/min.private/channels.js +1 -1
- package/channels/min.private/package.json +1 -1
- package/channels/package.json +1 -1
- package/full/debug/full.js +1 -1
- package/full/debug/package.json +1 -1
- package/full/debug.private/full.js +1 -1
- package/full/debug.private/package.json +1 -1
- package/full/min/full.js +1 -1
- package/full/min/package.json +1 -1
- package/full/min.private/full.js +1 -1
- package/full/min.private/package.json +1 -1
- package/full/package.json +1 -1
- package/package.json +1 -1
- package/publish/debug/package.json +1 -1
- package/publish/debug/publish.js +1 -1
- package/publish/debug.private/package.json +1 -1
- package/publish/debug.private/publish.js +1 -1
- package/publish/min/package.json +1 -1
- package/publish/min/publish.js +1 -1
- package/publish/min.private/package.json +1 -1
- package/publish/min.private/publish.js +1 -1
- package/publish/package.json +1 -1
package/channels/min/channels.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see channels.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={701:(e,t,n)=>{"use strict";n.d(t,{A:()=>p});var r=n(738),i=n.n(r),o=n(383),a=n.n(o),s=n(579),u=n.n(s),c=n(693),l=n.n(c),d=u()((function e(t,n,r){a()(this,e),l()(this,"onFulfilled",void 0),l()(this,"onRejected",void 0),l()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.promise=r})),h=function(){function e(t){if(a()(this,e),l()(this,"_state",void 0),l()(this,"_handled",void 0),l()(this,"_value",void 0),l()(this,"_deferreds",void 0),!(this instanceof e))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=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"===i()(t)||"function"==typeof t)){var r=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof r)return void n.doResolve((function(){r.apply(t,arguments)}))}n._state=1,n._value=t,n.finale()}catch(e){n.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate((function(){t._handled||e._unhandledRejection(t._value)}));for(var n=0,r=this._deferreds.length;n<r;n++)this.handle(this._deferreds[n]);this._deferreds=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 r;try{r=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(r)}else 1===n._state?t.promise.promiseResolve(n._value):t.promise.promiseReject(n._value)}))):n._deferreds.push(t)}}],[{key:"all",value:function(t){return new e((function(e,n){if(!Array.isArray(t))return n(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);for(var o=r.length,a=function(t,s){try{if(s&&("object"===i()(s)||"function"==typeof s)){var u=s.then;if("function"==typeof u)return void u.call(s,(function(e){return a(t,e)}),n)}r[t]=s,0==--o&&e(r)}catch(e){n(e)}},s=0;s<r.length;s++)a(s,r[s])}))}},{key:"resolve",value:function(t){return t&&"object"===i()(t)&&t.constructor===e?t:new e((function(e){return e(t)}))}},{key:"reject",value:function(t){return new e((function(e,n){return n(t)}))}},{key:"race",value:function(t){return new e((function(n,r){if(!Array.isArray(t))return r(new TypeError("Promise.race accepts an array"));for(var i=0,o=t.length;i<o;i++)e.resolve(t[i]).then(n,r)}))}},{key:"_immediate",value:function(e){setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}])}();h.prototype.catch=function(e){return this.then(null,e)},h.prototype.then=function(e,t){var n=new this.constructor((function(){return null}));return this.handle(new d(e,t,n)),n},h.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 p=h},79:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},987:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},901:(e,t,n)=>{var r=n(79);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},475:e=>{e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},293:(e,t,n)=>{var r=n(701).A;function i(e,t,n,i,o,a,s){try{var u=e[a](s),c=u.value}catch(e){return void n(e)}u.done?t(c):r.resolve(c).then(i,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new r((function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,u,"next",e)}function u(e){i(a,r,o,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,n)=>{var r=n(736);function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}e.exports=function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,t,n)=>{var r=n(736);e.exports=function(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},72:e=>{function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},511:(e,t,n)=>{var r=n(636);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},291:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},156:e=>{e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}},e.exports.__esModule=!0,e.exports.default=e.exports},752:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},869:e=>{e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},452:(e,t,n)=>{var r=n(738).default,i=n(475);e.exports=function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return i(e)},e.exports.__esModule=!0,e.exports.default=e.exports},633:(e,t,n)=>{var r=n(701).A,i=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,r){var i=t&&t.prototype instanceof b?t:b,o=Object.create(i.prototype),a=new I(r||[]);return u(o,"_invoke",{value:R(e,n,a)}),o}function v(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=f;var m="suspendedStart",g="suspendedYield",_="executing",y="completed",C={};function b(){}function k(){}function S(){}var w={};p(w,l,(function(){return this}));var x=Object.getPrototypeOf,T=x&&x(x(A([])));T&&T!==a&&s.call(T,l)&&(w=T);var P=S.prototype=b.prototype=Object.create(w);function L(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function n(r,o,a,u){var c=v(e[r],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==i(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 r;u(this,"_invoke",{value:function(e,i){function o(){return new t((function(t,r){n(e,i,t,r)}))}return r=r?r.then(o,o):o()}})}function R(e,n,r){var i=m;return function(o,a){if(i===_)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var u=F(s,r);if(u){if(u===C)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===m)throw i=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=_;var c=v(e,n,r);if("normal"===c.type){if(i=r.done?y:g,c.arg===C)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=y,r.method="throw",r.arg=c.arg)}}}function F(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,F(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),C;var o=v(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,C;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,C):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,C)}function O(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 D(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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 r=-1,o=function n(){for(;++r<e.length;)if(s.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(i(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}},L(E.prototype),p(E.prototype,d,(function(){return this})),n.AsyncIterator=E,n.async=function(e,t,i,o,a){void 0===a&&(a=r);var s=new E(f(e,t,i,o),a);return n.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},L(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 r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},n.values=A,I.prototype={constructor:I,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(D),!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 r(r,i){return a.type="throw",a.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("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 r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,C):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),C},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),D(n),C}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;D(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:A(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),C}},n}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},636:e=>{function t(n,r){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},715:(e,t,n)=>{var r=n(987),i=n(156),o=n(122),a=n(752);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},132:(e,t,n)=>{var r=n(901),i=n(291),o=n(122),a=n(869);e.exports=function(e){return r(e)||i(e)||o(e)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,t,n)=>{var r=n(738).default;e.exports=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,t,n)=>{var r=n(738).default,i=n(45);e.exports=function(e){var t=i(e,"string");return"symbol"==r(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},122:(e,t,n)=>{var r=n(79);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},756:(e,t,n)=>{var r=n(633)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.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 r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},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 r={};return(()=>{"use strict";n.r(r),n.d(r,{ChannelState:()=>we,Channels:()=>St,SDK:()=>Ce,default:()=>wt});var e,t,i,o=n(383),a=n.n(o),s=n(579),u=n.n(s),c=n(693),l=n.n(c),d=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=d,l()(d,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),l()(d,"_browserNameAndVersion",e.parseBrowserNameAndVersion()),l()(d,"_browserName",e.parseBrowserName()),l()(d,"_browserMajorVersion",e.parseBrowserMajorVersion()),l()(d,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(t=navigator)||void 0===t?void 0:t.userAgent)),l()(d,"_isAndroid",/Android/i.test(null===(i=navigator)||void 0===i?void 0:i.userAgent)),l()(d,"_isChrome69",e._browserNameAndVersion.includes("Chrome/69.")),l()(d,"_isChrome70",e._browserNameAndVersion.includes("Chrome/70.")),l()(d,"_isChrome71",e._browserNameAndVersion.includes("Chrome/71.")),l()(d,"_isChrome72",e._browserNameAndVersion.includes("Chrome/72.")),l()(d,"_isChrome74",e._browserNameAndVersion.includes("Chrome/74.")),l()(d,"_isChrome75",e._browserNameAndVersion.includes("Chrome/75.")),l()(d,"_isChrome76",e._browserNameAndVersion.includes("Chrome/76.")),l()(d,"_isChrome77",e._browserNameAndVersion.includes("Chrome/77."));var h=function(){return u()((function e(){a()(this,e)}),null,[{key:"clientOfferDisabled",get:function(){return d.isChrome74||d.isChrome75||d.isChrome76||d.isChrome77}},{key:"addTranceiverDisabled",get:function(){return d.isChrome69||d.isChrome70||d.isChrome71||d.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===d.browserName&&d.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===d.browserName&&d.browserMajorVersion<=69||"Firefox"===d.browserName&&d.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===d.browserName&&d.browserMajorVersion<=63||"Firefox"===d.browserName&&d.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===d.browserName&&d.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===d.browserName&&d.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===d.browserName||"SamsungBrowser"===d.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==d.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===d.browserName&&"function"==typeof(null===(e=document)||void 0===e?void 0:e.createElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===d.browserName&&d.browserMajorVersion>=71||"Firefox"===d.browserName&&d.browserMajorVersion>=69||"Safari"===d.browserName}},{key:"isMobile",get:function(){return d.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:"errorStackAlsoHasErrorMessage",get:function(){return"Firefox"!==d.browserName&&"Safari"!==d.browserName}}])}(),p=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),f=function(){return u()((function e(t,n,r){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=r}),[{key:"category",get:function(){return this._category}},{key:"appenders",get:function(){return this._appenders}},{key:"threshold",get:function(){return this._threshold}},{key:"trace",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,r=new Date,i=this.replacePlaceholders(t);this._appenders.value.forEach((function(t){t.log(e,i,n.category,r)}))}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],r=0;n.indexOf&&e.length>1&&r>=0;)if((r=n.indexOf("%",r))>0)switch(n.substring(r+1,r+2)){case"%":n=n.substring(0,r)+n.substring(r+1),r++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,r),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,r),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce((function(e,n,r,i){return r+1===i.length&&n instanceof Error?h.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}),[])}}])}(),m=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:!0,sendLogs:"All",sendMetrics:"All",logToConsole:"All"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}])}();l()(m,"_sendLocalCandidates",void 0),l()(m,"_sendLogs",void 0),l()(m,"_sendMetrics",void 0),l()(m,"_logToConsole",void 0),m.applyFeatures();var g=function(){return u()((function e(){a()(this,e)}),null,[{key:"defaultLoggingLevel",get:function(){return p[m.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return p[m.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return p.Info}}])}(),_=function(){return u()((function e(){a()(this,e),l()(this,"_threshold",g.defaultLoggingLevel)}),[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}])}(),y=function(){return u()((function e(t){a()(this,e),l()(this,"_threshold",void 0),this._threshold=t}),[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(p[e],"] ").concat(t);e<p.Warn?console.log(i):console.error(i)}}}])}(),C=n(293),b=n.n(C),k=n(756),S=n.n(k),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,r=t;return r<0&&(r*=-1,n++),e.countDigitsBeforeDecimal(r)+n+(r!==Math.floor(r)?e.countDigitsAfterDecimal(r)+1:0)}},{key:"fixRounding",value:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}},{key:"countDigitsBeforeDecimal",value:function(e){for(var t=1,n=e;n>=10;)n/=10,t++;return t}},{key:"countDigitsAfterDecimal",value:function(t){for(var n=t,r=Math.floor(t),i=0;r!==n&&i<15;)i++,r=e.fixRounding(n,i);return i}}])}(),x=function(){return u()((function e(){a()(this,e)}),null,[{key:"sdkVersion",get:function(){try{return"2024-08-14T17:46:25.349Z (2024.2.0)"}catch(e){return this._defaultVersion}}}])}();l()(x,"_defaultVersion",(new Date).toISOString());var T=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",location.hostname),this._telemetryConfiguration=t}),[{key:"push",value:function(e,t,n,r){var i=(r.valueOf()-this._telemetryConfiguration.pageLoadTime)/1e3,o={timestamp:r.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:p[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:x.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<p.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"sendLogs",value:(t=b()(S().mark((function e(t){var n;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,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=b()(S().mark((function e(){var t,n,r,i,o,a=this;return S().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,r=function(e){return"number"==typeof e?w.countNumberLength(e):e.length},i=function(e){return Object.values(e).reduce((function(e,t){return e+(t?r(t):0)}),0)};this._logs.length>t&&i(this._logs[t])+n<8192;)n+=i(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,i(this._logs[t])+(8192-i(this._logs[t]))),t=1),o=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.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}(),P=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 T(t)}),[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}])}(),L=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",g.defaultTelemetryLoggingLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new 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}}])}(),E=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),R=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",F.defaultTelemetryLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new 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}}])}(),F=function(){return u()((function e(){a()(this,e)}),null,[{key:"defaultTelemetryLevel",get:function(){return E[m.sendMetrics]}}])}(),O=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},D=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case E.Off:return"Off";case E.Essential:return"Essential";case E.All:return"All";default:O(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return E.Off;case"Essential":return E.Essential;case"All":return E.All;default:O(e)}}}])}(),I=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case p.Off:return"Off";case p.Trace:return"Trace";case p.Debug:return"Debug";case p.Info:return"Trace";case p.Warn:return"Warn";case p.Error:return"Error";case p.Fatal:return"Fatal";case p.All:return"All";default:O(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return p.Off;case"Trace":return p.Trace;case"Debug":return p.Debug;case"Info":return p.Info;case"Warn":return p.Warn;case"Error":return p.Error;case"Fatal":return p.Fatal;case"All":return p.All;default:O(e)}}}])}(),A=function(){return u()((function e(){a()(this,e)}),[{key:"getStringValue",value:function(e){return this.readConfigurationParameterValue(e)||this.readConfigurationParameterURIValue("".concat(e,"-uri-parameter-name"))||this.defaultStringValue[e]}},{key:"getBooleanValue",value:function(e){var t=this.readConfigurationParameterValue(e);if(t)return"true"===t||"1"===t||"On"===t;var n=this.readConfigurationParameterURIValue("".concat(e,"-uri-parameter-name"));return n?"true"===n||"1"===n||"On"===n:!0===this.defaultBooleanValue[e]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":D.convertTelemetryLevelToTelemetryLevelType(F.defaultTelemetryLevel),"phenix-logging-level":I.convertLoggingLevelToLoggingLevelType(g.defaultLoggingLevel),"phenix-console-logging-level":I.convertLoggingLevelToLoggingLevelType(g.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":I.convertLoggingLevelToLoggingLevelType(g.defaultTelemetryLoggingLevel),"phenix-channel-token":"","phenix-uri":"","phenix-base-uri":""}}},{key:"defaultBooleanValue",get:function(){return{"phenix-automatically-retry-on-failure":!0,"phenix-automatically-reconnect-peer-connection":!0,"phenix-force-garbage-collection-on-restart":!0,"phenix-skip-garbage-collection-on-mobile-devices":!0}}},{key:"readConfigurationParameterValue",value:function(e){var t=document.querySelector("meta[name='".concat(e,"']"));if(t){var n=t.getAttribute("value");if(n)return n}}},{key:"readConfigurationParameterURIValue",value:function(e){var t=this.readConfigurationParameterValue(e);if(t){var n=new URLSearchParams(location.search).get(t)||void 0;if(n)return n}}}])}(),M=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 f(t,this._appenders,this._threshold))}},{key:"applyLoggerConfigFromParameterConfiguration",value:function(){e.applyLoggingLevel(),e.applyAppenderLoggingLevel("console",e.applyConsoleLogger.bind(this)),e.applyAppenderLoggingLevel("telemetry",e.applyTelemetryLogger.bind(this))}},{key:"applyLoggingLevel",value:function(){var e=this._configurationParameterReader.getStringValue("phenix-logging-level");p[e]&&this._threshold.setThreshold(p[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=this._configurationParameterReader.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(p[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new y(e||g.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||g.defaultTelemetryLoggingLevel,this._appenders.add(new P(this._telemetryConfiguration))}}])}();l()(M,"_configurationParameterReader",new A),l()(M,"_loggers",{}),l()(M,"_appenders",new v),l()(M,"_threshold",new _),l()(M,"_telemetryConfiguration",new L),M.applyLoggerConfigFromParameterConfiguration();var N=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)}}])}(),V=n(452),j=n.n(V),U=n(72),B=n.n(U),G=n(511),H=n.n(G),z=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(e,t,n){return t=B()(t),j()(e,J()?Reflect.construct(t,n||[],B()(e).constructor):t.apply(e,n))}function J(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(J=function(){return!!e})()}var q=function(e){function t(e,n){return a()(this,t),W(this,t,[function(){var t=e.indexOf(n);t>=0&&e.splice(t,1)}])}return H()(t,e),u()(t)}(z),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 q(this._listeners,e)}}])}(),Z=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)}}])}(),Q=function(){return u()((function e(t){var n,r;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 URL(t.token.uri):null,capabilities:(null==t||null===(r=t.token)||void 0===r?void 0:r.capabilities)||[]}}),[{key:"uri",get:function(){return this._token.uri}},{key:"capabilities",get:function(){return this._token.capabilities}},{key:"tenancy",get:function(){return this._applicationId}}])}(),Y=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 Q(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new Q(r)}catch(t){return e._logger.error("Cannot parse token value",t),new Q(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();l()(Y,"_logger",M.getLogger("EdgeAuthParser"));var $=n(738),X=n.n($),ee=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,"]")}}])}(),te=function(){return u()((function e(){a()(this,e),l()(this,"_disposables",new ee),l()(this,"_readOnlyIsForeground",void 0),l()(this,"_isForeground",void 0),l()(this,"_timeOfLastTabFocusChange",Date.now()),l()(this,"_documentFocusInterval",void 0),this._isForeground=new K(!0),this._readOnlyIsForeground=new Z(this._isForeground),this.detectTabFocusChange()}),[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"detectTabFocusChange",value:function(){var e,t,n=this;if("object"===("undefined"==typeof document?"undefined":X()(document))){void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden?(e="webkitHidden",t="webkitvisibilitychange"):void 0!==document.hidden&&(e="hidden",t="visibilitychange");var r=function(){var t=!document[e];n.setFocusState(t)};void 0!==document.addEventListener&&void 0!==document[e]?(document.addEventListener(t,r,!1),this._disposables.add(new z((function(){document.removeEventListener(t,r,!1)})))):this.listenForDocumentFocus.call(this)}}},{key:"listenForDocumentFocus",value:function(){var e=this;this._documentFocusInterval=window.setInterval((function(){var t=document.hasFocus();e.setFocusState(t)}),3e3),this._disposables.add(new z((function(){e._documentFocusInterval&&clearInterval(e._documentFocusInterval),e._documentFocusInterval=null})))}},{key:"setFocusState",value:function(e){this._isForeground!==e&&(this._isForeground.value=e)}}])}(),ne=n(701).A,re=function(){return u()((function e(t){a()(this,e),l()(this,"_logger",M.getLogger("VanillaPeerConnection")),l()(this,"_peerConnection",void 0),h.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:"supportsAddTransceiver",get:function(){return!h.addTranceiverDisabled&&"function"==typeof this._peerConnection.addTransceiver}},{key:"createOffer",value:(r=b()(S().mark((function e(t){var n=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!h.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new ne((function(e,r){return n._peerConnection.createOffer(e,r,t)})));case 2:return e.abrupt("return",this._peerConnection.createOffer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAnswer",value:(n=b()(S().mark((function e(t){var n=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!h.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new ne((function(e,r){return n._peerConnection.createAnswer(e,r,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=b()(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._peerConnection.setLocalDescription(h.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=b()(S().mark((function e(t){var n;return S().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(h.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 ne((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:"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,r}(),ie=function(){return u()((function e(){a()(this,e)}),[{key:"createPeerConnection",value:(e=b()(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new re(t));case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e}(),oe=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(){h.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(n=b()(S().mark((function t(){return S().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=b()(S().mark((function t(){var n,r,i,o,a=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=a.length>0&&void 0!==a[0]?a[0]:"recvonly",r=a.length>1&&void 0!==a[1]&&a[1],!e._cached||e._cached.direction!==n||r){t.next=6;break}return i=e._cached.peerConnection,e._cached=null,t.abrupt("return",i);case 6:return o=h.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:r}:void 0,t.abrupt("return",e._peerConnectionFactory.value.createPeerConnection(o).then(function(){var e=b()(S().mark((function e(t){var r,i,o;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.supportsAddTransceiver){e.next=11;break}return i=t.addTransceiver("audio",{direction:n}),r=t.addTransceiver("video",{direction:n}),e.t0=i,e.t1=r,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()(oe,"_logger",M.getLogger("PeerConnectionService")),l()(oe,"_peerConnectionFactory",new K(new ie)),l()(oe,"_cached",void 0),oe.initiateInitialPrecaching();var ae=function(){return u()((function e(){a()(this,e)}),null,[{key:"getTelemetryUrl",value:function(e){try{var t=new 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}}}])}(),se=function(){return u()((function e(){a()(this,e)}),null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new URL(e).origin}catch(e){return""}}}])}(),ue=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:"distribution"}};this._discoveryParameters="discovery"in e?e.discovery:{intentions:""}}catch(e){this._discoveryParameters={intentions:""}}}}])}();l()(ue,"_discoveryParameters",void 0),ue.applyParameters();var ce=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 URL(e.toString()),n=x.sdkVersion,r=ue.discoveryParameters.intentions;return t.searchParams.set("version",n),t.searchParams.set("intentions",r),t.searchParams.set("_","".concat(Date.now())),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}])}();l()(ce,"_discoveryUri",new K("https://pcast.phenixrts.com/pcast/endPoints"));var le,de=n(132),he=n.n(de),pe=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,r=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=r}),[{key:"getExponentialBackoffIntervalByFailureCount",value:function(e){var t=this._backoffIntervalInMillisecond/1e3,n=.5+.5*Math.random(),r=Math.pow(t,e-2),i=Math.floor(r)*n,o=Math.ceil(Math.max(1e3*i,this._minBackoffIntervalInMillisecond));return Math.min(o,this._maxBackoffIntervalInMillisecond)}}])}(),fe=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}(fe||{}),ve=fe,me=function(){return u()((function e(t){a()(this,e),l()(this,"_metrics",void 0),this._metrics=t}),[{key:"getName",value:function(){return ve[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case ve.TimeToFirstFrame:case ve.ChannelCreationTimeToFirstFrame:return E.Essential;case ve.Stalled:case ve.Buffering:case ve.SetupCompleted:case ve.SetupFailed:case ve.RoundTripTime:case ve.DownlinkThroughputCapacity:case ve.NetworkType:case ve.ResolutionChanged:case ve.ApplicationForeground:case ve.ApplicationBackground:return E.All;default:O(this._metrics)}}}])}(),ge=function(){return u()((function e(t){a()(this,e),l()(this,"_logger",M.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",location.hostname),this._metricsConfiguration=t,this._exponentialBackoff=new pe}),[{key:"metricsConfiguration",get:function(){return this._metricsConfiguration}},{key:"push",value:function(e){var t=e.streamId,n=e.value,r=e.previousValue,i=e.runtime,o=e.resource,a=e.kind,s=new 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:r,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:x.sdkVersion,runtime:i,resource:o,kind:a};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:(t=b()(S().mark((function e(t){var n;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,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=b()(S().mark((function e(){var t,n=this;return S().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 setTimeout((function(){n._metrics=[].concat(he()(t),he()(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}(),_e=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 r=new R;return r.sessionId=Ce.clientSessionId,r.tenancy=Ce.tenancy.value,r.url=ae.getTelemetryUrl(t),r.environment=se.getEnvironmentFromUrl(t),r.threshold=D.convertTelemetryLevelTypeToTelemetryLevel(Ce.telemetryLevel),e._metricsServices[t]=new ge(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}])}();l()(_e,"_metricsServices",{});var ye=window.__phenixPageLoadTime||window.__pageLoadTime||Date.now(),Ce=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 ye}},{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 I.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return D.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return d}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=M.telemetryConfiguration;n.sessionId=e.clientSessionId,n.pageLoadTime=e.pageLoadTime,e._environment.subscribe((function(e){n.environment=e})),e.telemetryUrl.subscribe((function(e){var r=t._logger.appenders.value.find((function(e){return e instanceof P}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new P(n)),t._logger.info("Telemetry URL was set to [%s]",n.url))})),e._tenancy.subscribe((function(e){var r=t._logger.appenders.value.find((function(e){return e instanceof P}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new P(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=_e.getMetricsService(ce.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&&_e.setTelemetryLevel(E[t]),e._telemetryLevel.subscribe((function(e){_e.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=se.getEnvironmentFromUrl(t)}));var t=this._configurationParameterReader.getStringValue("phenix-channel-token");if(t){var n=Y.parseToken(t);return e._tenancy.value=n.tenancy,ce.uri.value=(n.uri||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var r=this._configurationParameterReader.getStringValue("phenix-uri");if(r)return ce.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=this._configurationParameterReader.getStringValue("phenix-base-uri");if(i){var o=new URL(i);return o.pathname="/pcast/endPoints",ce.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 te),t){if(t.discoveryUri&&(ce.uri.value=t.discoveryUri),t.peerConnectionFactory&&(oe.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&E[t.telemetryLevel]&&(e._telemetryLevel.value=D.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&p[t.loggingLevel]&&this._logger.threshold.setThreshold(I.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&p[t.consoleLoggingLevel]){var n=this._logger.appenders.value.find((function(e){return e instanceof y}));n&&this._logger.appenders.remove(n),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new y(I.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 ae.getTelemetryUrl(e)}}])}();le=Ce,l()(Ce,"_automaticallyRetryOnFailure",!0),l()(Ce,"_automaticallyReconnectPeerConnection",!0),l()(Ce,"_automaticallyPlayMediaStream",!0),l()(Ce,"_automaticallyMuteVideoOnPlayFailure",!0),l()(Ce,"_forceGarbageCollectionOnRestart",!0),l()(Ce,"_skipGarbageCollectionOnMobileDevices",!0),l()(Ce,"_webPlayerLoader",null),l()(Ce,"_shakaPlayerLoader",null),l()(Ce,"_hlsJsLoader",null),l()(Ce,"_configurationParameterReader",new A),l()(Ce,"_applicationActivityMonitor",void 0),l()(Ce,"_environment",new K("")),l()(Ce,"_telemetryUrl",new K("https://telemetry.phenixrts.com/telemetry")),l()(Ce,"_maximalNumberOfPeerConnectionReconnectAttempts",8),l()(Ce,"_telemetryLevel",new K(F.defaultTelemetryLevel)),l()(Ce,"_metricsService",void 0),l()(Ce,"_metricsConfiguration",void 0),l()(Ce,"_sendLocalCandidates",new K(m.sendLocalCandidates)),l()(Ce,"_tenancy",new K("")),l()(Ce,"_clientSessionId",N.random(32)),l()(Ce,"_loadedTimestamp",new Date),l()(Ce,"_logger",M.getLogger("SDK")),l()(Ce,"_initialized",new K(!1)),l()(Ce,"_readOnlyInitialized",new Z(le._initialized)),l()(Ce,"_readOnlyDiscoveryUri",new Z(ce.uri)),l()(Ce,"_readOnlyPeerConnectionFactory",new Z(oe.peerConnectionFactory)),window.addEventListener("unload",(function(){Ce.dispose()})),Ce.applyDiscoveryUriDefaultFromParameterConfiguration(),Ce.applyMetricsConfiguration(),Ce.applyTelemetryConfiguration(),Ce.applyAutomaticallyRetryOnFailureFromParameterConfiguration(),Ce.applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration(),Ce.applyForceGarbageCollectionOnRestartFromParameterConfiguration(),Ce.applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration(),Ce.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)}}])}(),ke=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(){h.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){var e=this;h.isQueueMicrotaskSupported?queueMicrotask((function(){e.overloadMemoryToInvokeGarbageCollection()})):setTimeout((function(){e.overloadMemoryToInvokeGarbageCollection()}))}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=document.createElement("img");e.src=window.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){window.URL.revokeObjectURL(this.src),e=null}}}])}(),Se=function(e){return 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}(Se||{}),we=Se,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),r=n%1e3,i=(n=Math.floor(n/1e3))%60,o=(n=Math.floor(n/60))%60,a=(n=Math.floor(n/60))%24,s=["PT"];return e&&s.unshift("-"),a&&s.push(a+"H"),o&&s.push(o+"M"),(i||r)&&(s.push(String(i)),r&&s.push("."+this.padStart(r.toString(),3,"0")),s.push("S")),s.join("")}},{key:"padStart",value:function(e,t,n){return t|=0,n=String(void 0!==n?n:" "),e.length>t?e:((t-=e.length)>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}}])}(),Te=function(){return u()((function e(t,n,r,i){a()(this,e),l()(this,"_pageLoadTime",void 0),l()(this,"_channelStartTime",void 0),l()(this,"_logger",M.getLogger("StreamTelemetry")),l()(this,"_disposables",new ee),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=r,this._metricsService=i}),[{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 z((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 z((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:ve.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:ve.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:ve.Stalled,runtime:(Date.now()-this._pageLoadTime)/1e3,streamId:this._streamId}),this._videoStalled=Date.now(),this._logger.info("[%s] [%s] [buffering] Stream has stalled",this.durationSincePageLoad,this._streamId))}},{key:"onContinuation",value:function(e,t){if(t.buffered){var n=t.buffered.length,r=!("playing"===e.type||n>0)||("progress"===e.type||"timeupdate"===e.type)&&t.buffered.end(n-1)===this._lastProgress;if(this._videoStalled&&!r){"progress"===e.type&&(this._lastProgress=t.buffered.end(n-1));var i=Date.now()-this._videoStalled;this._metricsService.push({metricType:ve.Buffering,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{uint64:i},streamId:this._streamId}),this._logger.info("[%s] [%s] [buffering] Stream has recovered from stall after [%s]",this.durationSincePageLoad,this._streamId,new xe(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:ve.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}}])}(),Pe=function(){return u()((function e(t){a()(this,e),l()(this,"_logger",M.getLogger("StreamSetupListener")),l()(this,"metricsService",Ce.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(ve.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(ve.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new me(e).getName();this.metricsService.push({metricType:e,runtime:(n-this._pageLoadTime)/1e3,value:{uint64:r},streamId:t}),this._logger.info("[%s] [%s] Stream metric [%s] in [%s]",new xe(n-this._pageLoadTime).toIsoString(),t,i,new xe(r).toIsoString())}}}])}(),Le=function(){return u()((function e(){a()(this,e),l()(this,"_disposables",new ee),l()(this,"_isSupported",navigator&&navigator.connection),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(){return this.isSupported?navigator.connection.downlink||navigator.connection.downlinkMax:-1}},{key:"getEffectiveType",value:function(){return this.isSupported?navigator.connection.effectiveType||navigator.connection.type:"Unknown"}},{key:"getRoundTripTime",value:function(){return navigator.connection.rtt}},{key:"setupNetworkChangeListeners",value:function(){var e=this,t=function(){e.updateStatistics()};navigator.connection.addEventListener("change",t),this._disposables.add(new z((function(){navigator.connection.removeEventListener("change",t)})))}},{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 r=this;a()(this,e),l()(this,"_logger",M.getLogger("SessionTelemetry")),l()(this,"_metricsService",void 0),l()(this,"_applicationActivityMonitor",Ce.applicationActivityMonitor),l()(this,"_networkMonitor",new Le),l()(this,"_pageLoadTime",void 0),l()(this,"_disposables",new ee),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){r.recordForegroundChange(e)}))),this._disposables.add(this._networkMonitor.rtt.subscribe((function(e){r.recordNetworkRTTUpdate(e)}))),this._disposables.add(this._networkMonitor.effectiveType.subscribe((function(e){r.recordNetworkTypeChangeUpdate(e)}))),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe((function(e){r.recordNetworkDownlinkThroughputCapacityUpdate(e)}))))}),[{key:"listenOnStreamSetup",value:function(){return new Pe(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?ve.ApplicationForeground:ve.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:ve.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:ve.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:ve.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)}}])}(),Re=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Fe=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),Oe=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 ee,this.channelDisposables=new ee,this.rendererDisposables=new ee,this.channelInitialization=new Date,this.videoElement=new K(null),this.state=new K(we.Starting),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=Ce.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return we.Starting;case"no-stream":case"not-found":return we.StandBy;case"geo-restricted":return we.GeoRestricted;case"geo-blocked":return we.GeoBlocked;case"unauthorized":return we.Unauthorized;case"capacity":case"rate-limited":case"timeout":return we.Recovering;case"forbidden-tag":return we.ConfigurationError;case"port-in-range-not-found":return we.TransientConfigurationError;case"failed":return we.Error;default:O(e)}}}])}(),Ie=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(X()(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"}}}])}(),Ae=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(X()(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"}}}])}(),Me=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})),Ne=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})),Ve=u()((function e(){a()(this,e),l()(this,"isStarting",void 0),l()(this,"isDisposed",void 0),this.isStarting=new K(!1),this.isDisposed=!1})),je=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Fe.Normal:return"Normal";case Fe.Force:return"Force";case Fe.Reset:return"Reset";default:O(e)}}}])}(),Ue=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Re.Keep:return"Keep";case Re.Reset:return"Reset";default:O(e)}}}])}(),Be=n(701).A,Ge=function(){return u()((function e(t,n){if(a()(this,e),l()(this,"_logger",M.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=b()(S().mark((function e(){var t,n,r,i,o=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,Be.race([fetch(t,{method:"GET",cache:"no-cache"}),new Be((function(e,n){return setTimeout((function(){return n(new Error("Ping timed out [".concat(t,"]")))}),o._timeout)}))]);case 4:if(r=e.sent,i=Date.now(),r.ok){e.next=8;break}throw new Error("Ping failed [".concat(t,"] [").concat(r.status,"]"));case 8:return this._roundTripTime=i-n,e.abrupt("return",this._roundTripTime);case 10:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"subscribe",value:(f=b()(S().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,p,f,v,m=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=Y.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([i,"stream","subscribe"]).toString(),a=new FormData,s=x.sdkVersion,0===r&&n?(u={apiVersion:7,clientVersion:s,bearerToken:t,failureCount:r,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:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:7}},a.append("jsonBody",JSON.stringify(c))),l=Date.now(),e.prev=9,h=null,e.next=13,Be.race([fetch(o,{method:"POST",body:a}),new Be((function(e){return h=window.setTimeout((function(){m._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(o,"]"))),e({status:408})}),m._timeout)}))]).finally((function(){h&&clearTimeout(h)}));case 13:d=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"===(p=this.mapHttpStatusToSubscribeStatus(d))){e.next=23;break}return e.abrupt("return",{status:p});case 23:return f=Date.now(),e.next=26,this.convertHttpResponseToSubscribeResponse(i,d);case 26:return v=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",v,f-l),e.abrupt("return",v);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n){return f.apply(this,arguments)})},{key:"publish",value:(p=b()(S().mark((function e(t,n,r,i){var o,a,s,u,c,l,d,h,p,f,v,m,g=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=Y.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 FormData,u=x.sdkVersion,0===i&&r?(c={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:7,sessionDescription:{type:r.type,sdp:r.sdp}},createAnswerDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(c))):(l={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(l))),d=Date.now(),e.prev=9,p=null,e.next=13,Be.race([fetch(a,{method:"POST",body:s}),new Be((function(e){return p=window.setTimeout((function(){g._logger.error("Failed to publish",new Error("Publish timed out [".concat(a,"]"))),e({status:408})}),g._timeout)}))]).finally((function(){p&&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 publish",e.t0),e.abrupt("return",{status:"failed"});case 20:if("ok"===(f=this.mapHttpStatusToPublishStatus(h))){e.next=23;break}return e.abrupt("return",{status:f});case 23:return v=Date.now(),e.next=26,this.convertHttpResponseToPublishResponse(o,h);case 26:return m=e.sent,this._logger.debug("Got publish response [%j] in [%s] ms",m,v-d),e.abrupt("return",m);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n,r){return p.apply(this,arguments)})},{key:"setRemoteDescription",value:(h=b()(S().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,sessionDescription:{type:n.type,sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,Be.race([fetch(r,{method:"POST",body:i}),new Be((function(e){return u=window.setTimeout((function(){h._logger.error("Failed to set remote description",new Error("Set remote description timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&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 d=e.sent,this._logger.debug("Got set remote description response [%j] in [%s] ms",d,l-a),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return h.apply(this,arguments)})},{key:"limitBitrate",value:(d=b()(S().mark((function e(t,n,r,i,o){var a,s,u,c,l,d,h,p,f=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:Ue.convertBitrateStateToBitrateStateType(i),bitrateMode:je.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,d=null,e.next=9,Be.race([fetch(a,{method:"POST",body:s}),new Be((function(e){return d=window.setTimeout((function(){f._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(a,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){d&&clearTimeout(d)}));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 h=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),p=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",h,p-c),e.abrupt("return",{status:h});case 20:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t,n,r,i){return d.apply(this,arguments)})},{key:"addIceCandidates",value:(c=b()(S().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,p,f=this,v=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=v.length>3&&void 0!==v[3]?v[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),a=new FormData,s={apiVersion:7,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},a.append("jsonBody",JSON.stringify(s)),u=Date.now(),e.prev=6,l=null,e.next=10,Be.race([fetch(o,{method:"POST",body:a}),new Be((function(e){return l=window.setTimeout((function(){f._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(o,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){l&&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"===(d=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.next=20;break}return e.abrupt("return",{status:d});case 20:return h=Date.now(),e.next=23,this.convertHttpResponseToAddIceCandidatesResponse(c);case 23:return p=e.sent,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",p,h-u),e.abrupt("return",p);case 26:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e,t,n){return c.apply(this,arguments)})},{key:"destroyStream",value:(s=b()(S().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,Be.race([fetch(r,{method:"POST",body:i,cache:"no-cache"}),new Be((function(e){return u=window.setTimeout((function(){h._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&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 d=e.sent,this._logger.info("Got destroy stream response [%j] in [%s] ms",d,l-a),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return s.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(o=b()(S().mark((function e(t,n){var r,i,o,a;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(r=navigator)&&void 0!==r&&r.sendBeacon||this.destroyStream(t,n),i=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),o=new FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},o.append("jsonBody",JSON.stringify(a)),navigator.sendBeacon(i,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 URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,he()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new URL(this._uri),t=x.sdkVersion,n=ue.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:(i=b()(S().mark((function e(t,n){var r,i;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},i.lag=r.lag,r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(r=b()(S().mark((function e(t,n){var r,i;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={iceServers:[]};if(e.bundlePolicy&&(t.bundlePolicy=e.bundlePolicy),"number"==typeof e.iceCandidatePoolSize&&(t.iceCandidatePoolSize=e.iceCandidatePoolSize),e.iceServers){for(var n=[],r=0;r<e.iceServers.length;r++)n.push({urls:e.iceServers[r].urls,username:e.iceServers[r].username,credential:e.iceServers[r].credential});t.iceServers=n}return e.iceTransportPolicy&&(t.iceTransportPolicy=e.iceTransportPolicy),e.rtcpMuxPolicy&&(t.rtcpMuxPolicy=e.rtcpMuxPolicy),t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(n=b()(S().mark((function e(t){var n,r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},n&&n.sessionDescription&&(r.sessionDescription=n.sessionDescription),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(t=b()(S().mark((function e(t){var n,r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status,options:[]},n&&n.options&&(r.options=n.options),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(e=b()(S().mark((function e(t){var n,r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,i,o,s,c,d,h,p,f,v}(),He=n(701).A,ze=function(){return u()((function e(t){if(a()(this,e),l()(this,"_logger",M.getLogger("Discovery")),l()(this,"_metricsService",void 0),l()(this,"_uri",void 0),!t)throw new Error("Discovery requires uri");this._metricsService=_e.getMetricsService(t.toString()),this._uri=t}),[{key:"discoverNearbyEndPoints",value:(t=b()(S().mark((function e(t,n){var r,i,o,a;return S().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 r=t.toString(),e.next=5,He.race([fetch(r,{method:"GET",cache:"no-cache"}),new He((function(e,t){return setTimeout((function(){return t(new Error("Discovery timed out [".concat(r,"]")))}),n)}))]);case 5:if((i=e.sent).ok){e.next=8;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 8:if(null!==i.body){e.next=10;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 10:return e.next=12,i.text();case 12:return o=e.sent,a=o.split(","),e.abrupt("return",a.map((function(e){return new Ge(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=b()(S().mark((function e(){var t,n,r,i,o,a,s=this,u=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=ce.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new URL(n),t);case 4:return r=e.sent,i=0,o=function(){return new He((function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))}))},e.next=9,He.race(r.map((function(e){return e.ping().catch((function(t){return s._logger.warn("Failed to ping end point [%s]",e,t),i++,o()})).then((function(t){var n=Date.now();return s._logger.info("Discovered end point [%s] with time [%s]",e.toString(),t),s._metricsService.push({metricType:ve.RoundTripTime,runtime:(n-Ce.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}(),We=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=b()(S().mark((function t(){var n;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new URL(Ce.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=b()(S().mark((function t(n){var r,i,o;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.toString(),!e._cache[r]){t.next=3;break}return t.abrupt("return",e._cache[r]);case 3:return i=new ze(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then((function(){setTimeout((function(){e._cache[r]===o&&delete e._cache[r]}),6e4)})).catch((function(){delete e._cache[r]})),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()(We,"_cache",{}),We.precacheClosestEndPointDiscovery();var Je=function(e){return e[e.NetworkEmpty=0]="NetworkEmpty",e[e.NetworkIdle=1]="NetworkIdle",e[e.NetworkLoading=2]="NetworkLoading",e[e.NetworkNoSource=3]="NetworkNoSource",e}({});function qe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ke(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qe(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ze=function(){return u()((function e(t,n,r,i,o){a()(this,e),l()(this,"_logger",M.getLogger("WebPlayer")),l()(this,"_videoElement",void 0),l()(this,"_kind",void 0),l()(this,"_streamId",void 0),l()(this,"_manifestURI",void 0),l()(this,"_options",void 0),l()(this,"_player",void 0),l()(this,"_lastReloadTime",void 0),this._videoElement=t,this._kind=n,this._streamId=r,this._manifestURI=encodeURI(i).replace(/[#]/g,"%23"),this._options=o}),[{key:"start",value:function(){var e=this;if(rt.phenixWebPlayer){var t=Ke(Ke({},this._options),{},{bandwidthToStartAt:3e6});return this._player=new rt.phenixWebPlayer.WebPlayer(this._logger,this._videoElement,t),this._player.start(this._manifestURI),void this._player.addEventListener("error",(function(t){e.canReload()&&t&&(3===t.code||t.severity===rt.phenixWebPlayer.errors.severity.RECOVERABLE)&&(e._logger.warn("Reloading unhealthy stream after error event [%j]",t),e.reloadIfAble()),e._logger.error("Cannot reload with error [%j]",t)}))}}},{key:"isSupported",value:function(){return rt.phenixWebPlayer&&rt.phenixWebPlayer.isSupported}},{key:"getStats",value:function(){var e,t;if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:Je.NetworkNoSource,dataBuffered:0};var n=this._player.getStats(),r=n.currentTime||this._videoElement.currentTime,i=(Date.now()-this._options.originStartTime)/1e3;return null!==(e=this._videoElement.buffered)&&void 0!==e&&e.length&&(n.dataBuffered=this._videoElement.buffered.end(0)),n.isNative&&"Hls"===n.deliveryType&&(n.currentTime=r-n.lag),n.currentTime||(n.currentTime=r),n.isNative||(n.lag=Math.max(0,i-r)),null!==(t=this._videoElement.buffered)&&void 0!==t&&t.length?n.networkState=Je.NetworkLoading:n.currentTime>0?n.networkState=Je.NetworkIdle:n.video?n.networkState=Je.NetworkEmpty:n.networkState=Je.NetworkNoSource,n}},{key:"dispose",value:function(){this._player&&this._player.dispose(),this._player=null}},{key:"canReload",value:function(){var e=!this._lastReloadTime||Date.now()-this._lastReloadTime>15e3;return this._videoElement&&this._player&&0!==this._videoElement.buffered.length&&e}},{key:"reloadIfAble",value:function(){this.canReload()&&(this._logger.warn("[%s] Reloading unhealthy stream that was active for at least [%s] seconds",this._streamId,15),this._lastReloadTime=Date.now(),this.reload())}},{key:"reload",value:function(){this._player.dispose(),this._player=null,this.start()}}])}();function Qe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ye(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qe(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var $e=function(){return u()((function e(t,n,r,i,o){a()(this,e),l()(this,"_logger",M.getLogger("ShakaPlayer")),l()(this,"_videoElement",void 0),l()(this,"_kind",void 0),l()(this,"_streamId",void 0),l()(this,"_manifestURI",void 0),l()(this,"_options",void 0),l()(this,"_monitoredStatistics",void 0),l()(this,"_player",void 0),this._videoElement=t,this._kind=n,this._streamId=r,this._manifestURI=encodeURI(i).replace(/[#]/g,"%23"),this._options=o,this._monitoredStatistics={estimatedBandwidth:0,playTime:0}}),[{key:"start",value:function(){if(rt.shaka)return this._player=new rt.shaka.Player(this._videoElement),void this.loadPlayer({abr:{defaultBandwidthEstimate:2e6},manifest:{retryParameters:{timeout:1e4}},streaming:{liveSyncPanicThreshold:1,bufferingGoal:60,bufferBehind:30,retryParameters:{timeout:1e4,maxAttempts:10,backoffFactor:1.1}}})}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:Je.NetworkNoSource};var e=Ye(Ye({},this._player.getStats()),{},{currentTime:0,lag:0}),t=this._videoElement.currentTime||0,n=(Date.now()-this._options.originStartTime)/1e3,r=Math.max(0,n-t);return this._videoElement&&(e.currentTime=t,e.lag=r,this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0))),e.estimatedBandwidth>0&&this._monitoredStatistics.estimatedBandwidth<e.estimatedBandwidth?e.networkState=Je.NetworkLoading:e.playTime>0&&this._monitoredStatistics.playTime<e.playTime?e.networkState=Je.NetworkIdle:e.video?e.networkState=Je.NetworkEmpty:e.networkState=Je.NetworkNoSource,this._monitoredStatistics.estimatedBandwidth=e.estimatedBandwidth,this._monitoredStatistics.playTime=e.playTime,e}},{key:"dispose",value:function(){this._player&&(this._player.unload(),this._player.destroy()),this._player=null}},{key:"loadPlayer",value:function(e){var t=this;this._player.configure(e),this._player.load(this._manifestURI).then((function(){t._logger.info("[%s] DASH live stream has been loaded",t._streamId),t._videoElement.play&&t._videoElement.play()})).catch((function(e){t._logger.error("[%s] Error while loading DASH live stream [%s]",t._streamId,e.code,e)}))}}])}(),Xe=function(){return u()((function e(t,n,r,i,o){a()(this,e),l()(this,"_videoElement",void 0),l()(this,"_kind",void 0),l()(this,"_streamId",void 0),l()(this,"_manifestURI",void 0),l()(this,"_options",void 0),l()(this,"_player",void 0),this._videoElement=t,this._kind=n,this._streamId=r,this._manifestURI=encodeURI(i).replace(/[#]/g,"%23"),this._options=o}),[{key:"start",value:function(){rt.hlsPlayer&&(rt.hlsPlayer.isSupported()?(this._player=new rt.hlsPlayer({enableWorker:!0,maxBufferLength:1,backBufferLength:0,liveSyncDuration:7,liveDurationInfinity:!0,liveMaxLatencyDuration:1/0,highBufferWatchdogPeriod:1}),this._player.loadSource(this._manifestURI),this._player.attachMedia(this._videoElement)):this._videoElement.canPlayType("application/vnd.apple.mpegurl")&&(this._videoElement.src=this._manifestURI))}},{key:"isSupported",value:function(){return rt.hlsPlayer&&rt.hlsPlayer.isSupported()}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:Je.NetworkNoSource};var e={width:this._player.media.offsetWidth,height:this._player.media.offsetHeight,currentTime:this._player.media.currentTime,lag:0,networkState:Je.NetworkIdle,dataBuffered:0};this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0)),"IDLE"===this._player.streamController.state?e.networkState=Je.NetworkIdle:"ERROR"===this._player.streamController.state||"ENDED"===this._player.streamController.state?e.networkState=Je.NetworkNoSource:this._player.streamController.state.includes("LOADING")||this._player.streamController.state.includes("WAITING")?e.networkState=Je.NetworkLoading:e.networkState=Je.NetworkEmpty;var t=this._videoElement.currentTime||0,n=(Date.now()-this._options.originStartTime)/1e3;return e.lag=Math.max(0,t+this._options.lag/1e3-n),e}},{key:"dispose",value:function(){this._player&&this._player.destroy&&(this._player.destroy(),this._player=null)}}])}(),et=n(701).A;function tt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function nt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?tt(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var rt=function(){return u()((function e(){a()(this,e)}),null,[{key:"hlsPlayer",get:function(){return this._hlsPlayer}},{key:"phenixWebPlayer",get:function(){return this._phenixWebPlayer}},{key:"shaka",get:function(){return this._shaka}},{key:"start",value:(t=b()(S().mark((function e(t,n,r,i){var o=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._options=i,!(this._hlsPlayer||this._shaka||this._phenixWebPlayer)){e.next=3;break}return e.abrupt("return",this.loaded(t,n,r));case 3:if(Ce.webPlayerLoader||Ce.shakaPlayerLoader||Ce.hlsJsLoader){e.next=5;break}throw new Error("Unsupported-feature, add stream player");case 5:return e.abrupt("return",new et((function(e){Ce.hlsJsLoader&&(o._pending=!0,Ce.hlsJsLoader((function(i){o._hlsPlayer=i,o._pending&&(o._pending=!1,e(o.loaded(t,n,r)))}))),Ce.webPlayerLoader&&(o._pending=!0,Ce.webPlayerLoader((function(i){o._phenixWebPlayer=i,o._pending&&(o._pending=!1,e(o.loaded(t,n,r)))}))),Ce.shakaPlayerLoader&&(o._pending=!0,Ce.shakaPlayerLoader((function(i){o._shaka=i,o._pending&&(o._pending=!1,e(o.loaded(t,n,r)))})))})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,n,r,i){return t.apply(this,arguments)})},{key:"getStats",value:function(){return this._player?this._player.getStats():null}},{key:"play",value:(e=b()(S().mark((function e(t,n,r,i,o){var a,s,u,c;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=i.match(/a=x-playlist:([^\n]*[.]mpd\??[^\s]*)/m),s=i.match(/a=x-playlist:([^\n]*[.]m3u8\??[^\s]*)/m),u=a&&a[1]?a[1]:"",!(c=s&&s[1]?s[1]:"")){e.next=9;break}if(this._phenixWebPlayer&&!h.shouldUseNativeHls){e.next=9;break}return this._player=new t(n,"hls",r,c,o),this._player.start(),e.abrupt("return",this._player);case 9:if(!u){e.next=14;break}if(this._hlsPlayer||this._phenixWebPlayer&&h.shouldUseNativeHls){e.next=14;break}return this._player=new t(n,"dash",r,u,o),this._player.start(),e.abrupt("return",this._player);case 14:if(!u&&!c){e.next=16;break}throw new Error("[".concat(r,"] Cannot play [").concat(c?"HLS":"DASH","] stream with included player"));case 16:throw new Error("No stream playlist found");case 17:case"end":return e.stop()}}),e,this)}))),function(t,n,r,i,o){return e.apply(this,arguments)})},{key:"loaded",value:function(e,t,n){if(this._shaka||this._phenixWebPlayer||this._hlsPlayer)return this._hlsPlayer?this.play(Xe,e,t,n,nt(nt({},this._options),{},{preferNative:h.shouldUseNativeHls})):this._phenixWebPlayer?this.play(Ze,e,t,n,nt(nt({},this._options),{},{preferNative:h.shouldUseNativeHls})):this._shaka?this.play($e,e,t,n,nt(nt({},this._options),{},{preferNative:h.shouldUseNativeHls})):void 0}}]);var e,t}();l()(rt,"_pending",!1),l()(rt,"_hlsPlayer",void 0),l()(rt,"_phenixWebPlayer",void 0),l()(rt,"_shaka",void 0),l()(rt,"_options",void 0),l()(rt,"_player",void 0);var it,ot=function(e){return e[e.Live=1]="Live",e[e.OndDemand=2]="OndDemand",e}(ot||{}),at=ot,st=function(){return u()((function e(t,n,r){a()(this,e),l()(this,"_logger",M.getLogger("ChunkedStream")),l()(this,"_channelContext",void 0),l()(this,"_chunkedStreamPlaybackMode",void 0),l()(this,"_monitorDisposables",new ee),l()(this,"_handleStreamFailure",void 0),l()(this,"_streamStatistics",void 0),l()(this,"_monitorFailureCount",0),this._channelContext=t,this._chunkedStreamPlaybackMode=n,this._handleStreamFailure=r,this._channelContext.disposables.add(this)}),[{key:"start",value:function(e,t){var n=this;return We.discoverClosestEndPointWithCaching(e).then((function(e){return n._channelContext.online.value=!0,n._channelContext.endPoint.value=e,n._logger.info("Connecting to [%s]",e.toString()),e.subscribe(t,null,n._channelContext.failureCount.value)})).then((function(e){var t=e.status,r=e.stream,i=e.createOfferDescriptionResponse,o=e.lag;if(n._channelContext.stream.value=r,n._channelContext.lag.value=o,n._channelContext.applySessionAndStreamPropertiesToVideoElement(),n._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",n._channelContext.streamId,t,i),n._channelContext.state.value=n._channelContext.mapSubscribeStatusToChannelStatus(t),n._channelContext.applyStatus(t),"ok"===t){var a=i.sessionDescription.sdp,s={originStartTime:Date.now()-o+n._channelContext.endPoint.value.roundTripTime/2,lag:o};return rt.start(n._channelContext.videoElement.value,n._channelContext.streamId,a,s).then((function(e){return n.monitor(e),e})).catch((function(e){n._logger.error("ChunkedStreaming failed",e),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,n._channelContext.state.value=we.Stopped}))}}))}},{key:"monitor",value:function(e){var t=this;this._monitorDisposables.dispose();var n=window.setTimeout((function(){var n=rt.getStats();if(t._chunkedStreamPlaybackMode!==at.Live||n.networkState!==Je.NetworkNoSource||t._channelContext.videoElement.value.currentTime!==t._channelContext.videoElement.value.duration){if(t._streamStatistics&&!t._channelContext.videoElement.value.paused&&t._streamStatistics.currentTime>=n.currentTime&&(t._streamStatistics.dataBuffered>=n.dataBuffered||!n.dataBuffered)){if(t._monitorFailureCount++,t._monitorFailureCount>4)return t._monitorFailureCount=0,t._channelContext.state.value=we.ConnectionError,t._channelContext.playing.value=!1,t._channelContext.loading.value=!0,e.dispose(),t._monitorDisposables.dispose(),void t._handleStreamFailure().catch((function(e){t._logger.error("Failed handling stream failure",e)}))}else t._monitorFailureCount=0;t._channelContext.videoElement.value.paused&&t._channelContext.state.value===we.Playing&&(t._channelContext.state.value=we.Paused),t._channelContext.videoElement.value.paused||t._channelContext.state.value===we.Playing||(t._channelContext.state.value=we.Playing),t._streamStatistics=n,t.monitor(e)}else t._monitorFailureCount=0,t._channelContext.state.value=we.ConnectionError,t._channelContext.playing.value=!1,t._channelContext.loading.value=!0,e.dispose(),t._monitorDisposables.dispose(),t._handleStreamFailure().catch((function(e){t._logger.error("Failed handling end of stream",e)}))}),1e3);this._monitorDisposables.add(new z((function(){clearTimeout(n)})))}},{key:"dispose",value:function(){this._monitorDisposables.dispose()}}])}(),ut=n(715),ct=n.n(ut),lt=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)/),r=this._sdp.split(/(?:^|[\r\n])m=/);this._audioCodec=this.applyCodec("audio",n),this._videoCodec=this.applyCodec("video",n),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",r),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",r)}),[{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]}}])}(),dt=function(){return u()((function e(t,n,r){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=r,this._tracksToMonitor=n.getTracks().map((function(e){return e.kind}))||[],this._peerConnection){if(!h.getCurrentOfferDisabled){var i=new lt(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=i.audioCodec,this._estimatedVideoCodec=i.videoCodec}this.updateStatistic()}}),[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(t=b()(S().mark((function e(){var t,n=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!h.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 r={};if(e){var i,o=n._estimatedRoundTripTime;e.forEach((function(a){if("candidate-pair"===a.type&&a.currentRoundTripTime&&(o=1e3*a.currentRoundTripTime,r.audio&&(r.audio.roundTripTime=o),r.video&&(r.video.roundTripTime=o)),"candidate-pair"===a.type&&a.lastPacketReceivedTimestamp&&(i=a.lastPacketReceivedTimestamp,r.audio&&(r.audio.lastPacketReceivedTimestamp=i),r.video&&(r.video.lastPacketReceivedTimestamp=i)),"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),v=a.timestamp-(null===(h=n._rtcStatistic.value)||void 0===h||null===(p=h[s])||void 0===p?void 0:p.timestamp),m=f&&v?Math.floor(8*f/v*1e3):0;if(r[s]={ssrc:a.ssrc,mediaType:s,timestamp:a.timestamp,bitrate:m,bytesReceived:a.bytesReceived,packetsLost:a.packetsLost,packetsReceived:a.packetsReceived,codec:u||n.getCodecByType(s),roundTripTime:o},(a.lastPacketReceivedTimestamp||i)&&(r[s].lastPacketReceivedTimestamp=a.lastPacketReceivedTimestamp||i),"video"===s&&n._rtcStatistic.value&&n._rtcStatistic.value.video){r[s].framesDecoded=a.framesDecoded;var g=(a.framesDecoded-n._rtcStatistic.value.video.framesDecoded)/(r[s].timestamp-n._rtcStatistic.value.video.timestamp)*1e3;r[s].fps=g?Math.round(100*g)/100:0}}}}))}n._rtcStatistic.value=r})).then((function(){n._isMonitorRunning&&(n._updateTimeout=window.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=b()(S().mark((function e(){var t=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.getStatsLegacy().then((function(e){var n={},r=t._estimatedRoundTripTime;e.result().forEach((function(e){if(e.names().forEach((function(t){"googRTT"===t&&(r=e.stat(t))})),"ssrc"===e.type){var i=e.stat("mediaType").toString();n[i]={timestamp:Date.now()},n[i].ssrc=e.stat("ssrc").toString(),n[i].mediaType=i,n[i].bytesReceived=e.stat("bytesReceived"),n[i].packetsLost=e.stat("packetsLost"),n[i].packetsReceived=e.stat("packetsReceived"),n[i].codec=e.stat("googCodecName").toString()||t.getCodecByType(i),n[i].roundTripTime=r,"video"===i&&t._rtcStatistic.value&&t._rtcStatistic.value.video&&(n[i].framesDecoded=e.stat("framesDecoded"),n[i].fps=(n[i].framesDecoded-t._rtcStatistic.value.video.framesDecoded)/(n[i].timestamp-t._rtcStatistic.value.video.timestamp)*1e3||0)}})),t._rtcStatistic.value=n})).then((function(){t._isMonitorRunning&&(t._updateTimeout=window.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}(),ht=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 r=[],i=0;i<2;i++)e.iceServers[n].urls[i]&&r.push(e.iceServers[n].urls[i]);t.push({urls:r,username:e.iceServers[n].username,credential:e.iceServers[n].credential})}return e.iceServers=t,e}}])}(),pt=Symbol(),ft=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)?pt: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,r=e.getSurrogate82x82PFrameAndUpdateFrameNumber();return n>e._surrogate82x82PFrameFrameNumberReset?e._isAndroidChrome?pt:e._singleZeroByte.buffer:(e._surrogate82x82PFrameFrameNumber++,r)}return e._singleZeroByte.buffer}},{key:"getSurrogate82x82PFrameAndUpdateFrameNumber",value:function(){var t=(14&e._surrogate82x82PFrameFrameNumber)>>1,n=(1&e._surrogate82x82PFrameFrameNumber)<<7,r=e._dummy82x82H264.PFrame.slice().buffer,i=e._dummy82x82H264PFrameFrameNumberIndex;return r[i]|=t,r[i+1]|=n,e._surrogate82x82PFrameFrameNumber++,r}}])}();it=ft,l()(ft,"_isSafari","Safari"===d.browserName),l()(ft,"_isMobileChrome","Chrome"===d.browserName&&d.isMobile()),l()(ft,"_isAndroidChrome","Chrome"===d.browserName&&d.isAndroid),l()(ft,"_singleZeroByte",new Uint8Array([0])),l()(ft,"_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()(ft,"_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()(ft,"_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()(ft,"_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(he()(new Uint8Array(40).fill(255)),[95],he()(new Uint8Array(10295).fill(255)),[128,0,0,0,1,101,136,132,5],he()(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(he()(new Uint8Array(40).fill(255)),[164],he()(new Uint8Array(10364).fill(255)),[128,0,0,0,1,65,154,32,21,240,75]))}),l()(ft,"_dummy82x82H264PFrameFrameNumberIndex",10418),l()(ft,"_surrogate82x82PFrameFrameNumberReset",1),l()(ft,"_useUpdateSurrogate82x82PFrameFrameNumber",it._isMobileChrome||it._isSafari),l()(ft,"_surrogate82x82PFrameFrameNumber",it._surrogate82x82PFrameFrameNumberReset);var vt=function(){return u()((function e(){throw a()(this,e),new Error("InsertableStreams is a static class that may not be instantiated")}),null,[{key:"applyEncodedStreamTransformation",value:function(e,t,r,i,o,a){var s=new ee;return e.getTracks().forEach((function(e){var u=t.filter((function(t){return t.track===e}))[0],c=e.kind;switch(c){case"video":if(r){if(h.isRTCRtpScriptTransformSupported){var l=new Worker(new URL(n.p+n.u(63),n.b),{type:void 0});l.onmessage=function(){var t=b()(S().mark((function t(n){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r(e,n.data.chunk);case 2:if(t.sent){t.next=4;break}l.postMessage({forceInvalidFrame:!0});case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),u.transform=new RTCRtpScriptTransform(l,{kind:e.kind,codec:o}),s.add(new z((function(){l.terminate()})));break}var d=function(){var t=b()(S().mark((function t(n,i){var a;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r(e,n);case 2:if(t.sent){t.next=9;break}if((a="key"===n.type?ft.getInvalidSurrogateVideoIFrame(o):ft.getInvalidSurrogateVideoPFrame(o))!==pt){t.next=6;break}return t.abrupt("return");case 6:n.data=a||n.data,t.next=10;break;case 9:"key"===n.type?n.data=ft.getSurrogateVideoIFramePerCodec(o)||n.data:n.data=ft.getSurrogateVideoPFramePerCodec(o)||n.data;case 10:i.enqueue(n);case 11:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),p=new TransformStream({transform:d}),f=u.createEncodedStreams(),v=f.readable,m=f.writable;v.pipeThrough(p).pipeTo(m)}break;case"audio":if(i){if(h.isRTCRtpScriptTransformSupported){var g=new Worker(new URL(n.p+n.u(444),n.b),{type:void 0});g.onmessage=function(){var t=b()(S().mark((function t(n){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i(e,n.data.chunk);case 2:if(t.sent){t.next=4;break}g.postMessage({forceInvalidFrame:!0});case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),u.transform=new RTCRtpScriptTransform(g,{kind:e.kind,codec:a});var _=new MediaStream,y=new Audio;y.srcObject=_,document.body.appendChild(y),s.add(new z((function(){g.terminate(),document.body.removeChild(y)})));break}var C=function(){var t=b()(S().mark((function t(n,r){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i(e,n);case 2:if(t.sent){t.next=6;break}n.data=ft.getInvalidSurrogateAudioData(),t.next=7;break;case 6:n.data=ft.getSurrogateAudioSilentPerCodec(a)||n.data;case 7:r.enqueue(n);case 8:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),k=new TransformStream({transform:C}),w=u.createEncodedStreams(),x=w.readable,T=w.writable;x.pipeThrough(k).pipeTo(T)}break;default:O(c)}})),{disposables:s}}},{key:"applyInsertableStreamTransformation",value:function(e,t,n){var r=new MediaStream,i=new ee;return e.getTracks().forEach((function(e){var o=e.kind;switch(o){case"video":if(t){var a=e,s=new TransformStream({transform:function(n,r){t(e,n,r)}}),u=new MediaStreamTrackProcessor({track:a}),c=new MediaStreamTrackGenerator({kind:a.kind}),l=u.readable,d=c.writable;l.pipeThrough(s).pipeTo(d),r.addTrack(c),i.add(new z((function(){r.removeTrack(c)})))}else r.addTrack(e);break;case"audio":if(n){var h=e,p=new TransformStream({transform:function(t,r){n(e,t,r)}}),f=new MediaStreamTrackProcessor({track:h}),v=new MediaStreamTrackGenerator({kind:h.kind}),m=f.readable,g=v.writable;m.pipeThrough(p).pipeTo(g),r.addTrack(v);var _=new MediaStream,y=new Audio;_.addTrack(e),y.srcObject=_,document.body.appendChild(y),i.add(new z((function(){r.removeTrack(v),document.body.removeChild(y)})))}else r.addTrack(e);break;default:O(o)}})),{transformedStream:r,disposables:i}}}])}(),mt=n(701).A;function gt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _t(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?gt(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var yt=function(){return u()((function e(t,n,r,i){a()(this,e),l()(this,"_logger",M.getLogger("RealTimeStream")),l()(this,"_channelContext",void 0),l()(this,"_peerConnectionContext",void 0),l()(this,"_streamTransformContext",void 0),l()(this,"_handleStreamFailure",void 0),l()(this,"_disposables",void 0),this._channelContext=t,this._peerConnectionContext=n,this._streamTransformContext=r,this._handleStreamFailure=i,this._disposables=new ee,this._channelContext.disposables.add(this)}),[{key:"start",value:function(e,t,n,r){var i=this,o="function"==typeof this._streamTransformContext.encodedVideoStreamSink||"function"==typeof this._streamTransformContext.encodedAudioStreamSink;return mt.all([We.discoverClosestEndPointWithCaching(e),oe.createPeerConnectionOffer("recvonly",o).then((function(e){var t=e.localOffer,n=e.peerConnection;return i._peerConnectionContext.peerConnection.value=n,{localOffer:t,peerConnection:n}}))]).then((function(e){var n=ct()(e,2),r=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;return i._channelContext.online.value=!0,i._channelContext.endPoint.value=r,i._logger.info("Connecting to [%s]",r.toString()),i._logger.info("Local offer:\n"+a.sdp),!h.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration||(s.close(),s.dispose(),!Ce.forceGarbageCollectionOnRestart||h.isMobile&&Ce.skipGarbageCollectionOnMobileDevices||ke.forceGarbageCollection(),s=null,a=null,i._peerConnectionContext.peerConnection.value=s),r.subscribe(t,a,i._channelContext.failureCount.value)})).then((function(e){var t=e.status,o=e.stream,a=e.rtcConfiguration,s=e.setRemoteDescriptionResponse,u=e.createOfferDescriptionResponse,c=e.createAnswerDescriptionResponse,l=e.lag;if(i._channelContext.stream.value=o,i._channelContext.lag.value=l,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),i._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",i._channelContext.streamId,t,a,s,u,c),i._channelContext.state.value=i._channelContext.mapSubscribeStatusToChannelStatus(t),i._channelContext.applyStatus(t),"ok"===t)return i.applyRtcConfiguration(i._peerConnectionContext.peerConnection.value,a).then((function(e){var t,a=!1,l=!1,d=[];i._peerConnectionContext.peerConnection.value||(i._peerConnectionContext.peerConnection.value=e),e.onicecandidate=function(n){i._channelContext.stream.value===o&&i._peerConnectionContext.peerConnection.value===e&&(a||Ce.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?d.push(n.candidate):l=!0,t||(t=setTimeout((function(){i._channelContext.stream.value!==o||a||i._channelContext.endPoint.value.addIceCandidates(o,d,l).then((function(e){var t=e.status,n=e.options;"ok"===t?(n.includes("cancel")&&(a=!0),i._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",i._channelContext.streamId,t,n)):i._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",i._channelContext.streamId,t)})).catch((function(e){i._logger.error("[%s] Failed to add ICE candidates",i._channelContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(i._channelContext.stream.value===o&&i._peerConnectionContext.peerConnection.value===e){var t=function(){i._channelContext.state.value=we.ConnectionError,i._channelContext.videoElement.value&&(i._channelContext.videoElement.value.pause(),i._channelContext.videoElement.value.srcObject=null),i._channelContext.playing.value=!1,i._channelContext.loading.value=!0,i._handleStreamFailure().catch((function(t){i._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)}))};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return void(navigator.onLine&&(i._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",i._channelContext.streamId,e.iceConnectionState),i.reconnectPeerConnection(e,t)));case"closed":return i._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",i._channelContext.streamId,e.iceConnectionState),void t();default:O(e.iceConnectionState)}}};var p=new mt((function(t,n){if(h.onTrackDisabled){var r=function(n){clearTimeout(i),e.removeEventListener("track",r),e.removeEventListener("addstream",r),n.streams?t(n.streams[0]):t(n.stream)},i=setTimeout((function(){e.removeEventListener("track",r),e.removeEventListener("addstream",r),n(new Error("Stream setup timed out"))}),3e4);e.addEventListener("track",r),e.addEventListener("addstream",r)}else{var o=setTimeout((function(){return n(new Error("Stream setup timed out"))}),3e4);e.ontrack=function(e){clearTimeout(o),t(e.streams[0])}}}));return new mt((function(e){e()})).then((function(){if(s)return i._logger.info("[%s] Set local SDP offer [%s]",i._channelContext.streamId,s.sessionDescription.sdp),e.setLocalDescription(s.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,s.sessionDescription,e.message),e}))})).then((function(){if(c)return i._logger.info("[%s] Set remote SDP answer [%s]",i._channelContext.streamId,c.sessionDescription.sdp),e.setRemoteDescription(c.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,c.sessionDescription,e.message),e}))})).then((function(){if(u)return i._logger.info("[%s] Set remote SDP offer [%s]",i._channelContext.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._channelContext.streamId,u.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})})).then((function(e){return i._logger.info("[%s] Set local SDP answer [%j]",i._channelContext.streamId,e),i._channelContext.endPoint.value.setRemoteDescription(o,e)})).then((function(t){var n=t.status,r=t.sessionDescription;return i._channelContext.state.value=i.mapSetRemoteDescriptionStatusToChannelStatus(n),"ok"!==n?(i._channelContext.playing.value=!1,i._channelContext.standby.value=!0,void(i._channelContext.stopped.value=!1)):e.setLocalDescription(r).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,r,e.message),e}))}))})).then((function(){return n.success(i._channelContext.streamId),p})).then((function(t){if(i._streamTransformContext.hasEncodedInsertableStreams.value){var n=new lt(e.currentRemoteDescription.sdp),o=vt.applyEncodedStreamTransformation(t,e.getReceivers(),i._streamTransformContext.encodedVideoStreamSink,i._streamTransformContext.encodedAudioStreamSink,n.videoCodec,n.audioCodec).disposables;i._disposables.add(o)}if(i._streamTransformContext.hasInsertableStreams.value){var a=vt.applyInsertableStreamTransformation(t,i._streamTransformContext.videoStreamTransformCallback,i._streamTransformContext.audioStreamTransformCallback),s=a.transformedStream,u=a.disposables;i._disposables.add(u),t=s}i._peerConnectionContext.mediaStream.value=t;var c=new dt(e,t,i._channelContext.endPoint.value.roundTripTime/4);i._disposables.add(c);var l=c.rtcStatistic.subscribe((function(t){if(i._channelContext.rtcStatistics.value=t,!i._channelContext.rtcVideoStatistic&&!i._channelContext.rtcAudioStatistic)return i._channelContext.rtcAudioStatistic=t.audio,void(i._channelContext.rtcVideoStatistic=t.video);var n=!1,r=!1;if(t.audio&&i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.timestamp!==t.audio.timestamp&&((n=i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.bytesReceived===t.audio.bytesReceived)&&navigator.onLine&&i._logger.info("[%s] Audio track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.audio.bytesReceived,i._channelContext.rtcAudioStatistic.bytesReceived,new xe(t.audio.timestamp-i._channelContext.rtcAudioStatistic.timestamp).toIsoString()),i._channelContext.rtcAudioStatistic=t.audio),t.video&&i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.timestamp!==t.video.timestamp&&((r=i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.bytesReceived===t.video.bytesReceived)&&navigator.onLine&&i._logger.info("[%s] Video track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.video.bytesReceived,i._channelContext.rtcVideoStatistic.bytesReceived,new xe(t.video.timestamp-i._channelContext.rtcVideoStatistic.timestamp).toIsoString()),i._channelContext.rtcVideoStatistic=t.video),(r||n)&&navigator.onLine)i.reconnectPeerConnection(e,(function(){i._channelContext.state.value=we.ConnectionError,i._channelContext.videoElement.value&&(i._channelContext.videoElement.value.pause(),i._channelContext.videoElement.value.srcObject=null),i._channelContext.playing.value=!1,i._channelContext.loading.value=!0,c.dispose(),i._handleStreamFailure().catch((function(t){i._logger.error("[%s] Failed handling stream failure after track stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)}))}));else{if(i._peerConnectionContext.peerConnectionReconnectAttempts=0,i._channelContext.state.value!==we.Reconnecting)return;i._channelContext.state.value=i._channelContext.playing.value?we.Playing:we.Paused,i._logger.info("Channel state restored to [%s] after reconnecting",we[i._channelContext.state.value])}}));return i._disposables.add(l),Ce.automaticallyPlayMediaStream?r(t):(i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,void(i._channelContext.state.value=we.Paused))}))}))}))}},{key:"applyRtcConfiguration",value:(e=b()(S().mark((function e(t,n){var r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=ht.truncateIceServers(n),e.abrupt("return",Ce.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=_t(_t({},t.getConfiguration()),n),t.setConfiguration(r),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=we.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Ce.maximalNumberOfPeerConnectionReconnectAttempts||!Ce.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(h.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!i)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 we.Starting;case"unauthorized":return we.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return we.Recovering;case"failed":return we.Error;default:O(e)}}}]);var e}(),Ct=function(){return u()((function e(){throw a()(this,e),new Error("StreamFactory is a static class that may not be instantiated")}),null,[{key:"create",value:function(e,t,n,r,i){var o=Y.parseToken(e).capabilities,a=o.includes("streaming"),s=o.includes("on-demand");return a||s?new st(t,s?at.OndDemand:at.Live,i):new yt(t,n,r,i)}}])}();l()(Ct,"_logger",M.getLogger("Streaming"));var bt=n(701).A,kt=function(){return u()((function e(t,n,r){var i=this;a()(this,e),l()(this,"_logger",M.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,"_exponentialBackoff",void 0),l()(this,"_channelStartTime",void 0),l()(this,"_readOnlyVideoElement",void 0),l()(this,"_readOnlyToken",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,"_metricsService",void 0),l()(this,"_sessionTelemetry",void 0),l()(this,"_videoMetaDataChangedHandler",void 0);var o=Y.parseToken(n),s={targetLag:null==r?void 0:r.targetLag},u={hasInsertableStreams:o.capabilities.includes("insertable-streams"),hasEncodedInsertableStreams:o.capabilities.includes("encoded-insertable-streams"),videoStreamTransformCallback:null==r?void 0:r.videoStreamTransformCallback,audioStreamTransformCallback:null==r?void 0:r.audioStreamTransformCallback,encodedVideoStreamSink:null==r?void 0:r.encodedVideoStreamSink,encodedAudioStreamSink:null==r?void 0:r.encodedAudioStreamSink};this._tokenContext=new Oe(n),this._channelContext=new De(s),this._peerConnectionContext=new Ne,this._streamTransformContext=new Me(u),this._stateContext=new Ve,this._exponentialBackoff=new pe,this._channelStartTime=Date.now(),this._readOnlyVideoElement=new Z(this._channelContext.videoElement),this._readOnlyToken=new Z(this._tokenContext.token),this._readOnlyPeerConnection=new Z(this._peerConnectionContext.peerConnection),this._readOnlyState=new Z(this._channelContext.state),this._readOnlyAutoMuted=new Z(this._channelContext.autoMuted),this._readOnlyAutoPaused=new Z(this._channelContext.autoPaused),this._readOnlyTokenExpiring=new Z(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new Z(this._channelContext.authorized),this._readOnlyOnline=new Z(this._channelContext.online),this._readOnlyLoading=new Z(this._channelContext.loading),this._readOnlyPlaying=new Z(this._channelContext.playing),this._readOnlyStandby=new Z(this._channelContext.standby),this._readOnlyStopped=new Z(this._channelContext.stopped),this._readOnlyTargetLag=new Z(this._channelContext.targetLag),this._readOnlyLag=new Z(this._channelContext.lag),this._readOnlyBitrateLimit=new Z(this._channelContext.bitrateLimit),this._readOnlyResolution=new Z(this._channelContext.resolution),this._readOnlyFailureCount=new Z(this._channelContext.failureCount),this._readOnlyEndPoint=new Z(this._channelContext.endPoint),this._readOnlyStream=new Z(this._channelContext.stream),this._readOnlyRtcStatistics=new Z(this._channelContext.rtcStatistics),this._readOnlyMediaStream=new Z(this._peerConnectionContext.mediaStream);var c=(o.uri||Ce.discoveryUri.value).toString();Ce.tenancy.value=o.tenancy||Ce.tenancy.value,ce.uri.value=c,this._metricsService=_e.getMetricsService(c),this._sessionTelemetry=new Ee(Ce.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=t,this._channelContext.channelDisposables.add(this._channelContext.videoElement.subscribe((function(e){i._channelContext.rendererDisposables.dispose(),e&&(i._channelContext.rendererDisposables.add(i._channelContext.stream.subscribe((function(e){i._channelContext.videoTelemetry&&i._channelContext.videoTelemetry.dispose(),e&&i.videoElement&&(i.videoElement.dataset&&(i.videoElement.dataset.sessionId=Ce.clientSessionId,i.videoElement.dataset.streamId=i.streamId),i._channelContext.videoTelemetry=new Te(i.streamId,Ce.pageLoadTime,i._channelStartTime,i._metricsService),i._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(i.videoElement),i._channelContext.videoTelemetry.setupListenerForRebuffering(i.videoElement),i._channelContext.state.value===we.Stopped)&&i.restartAfterStop()}))),i._channelContext.channelDisposables.add(i._channelContext.rendererDisposables))}))),this._channelContext.channelDisposables.add(this._channelContext.state.subscribe((function(e){i._channelContext.clearFailureCountTimeout&&clearTimeout(i._channelContext.clearFailureCountTimeout),i._channelContext.failureCount.value&&e===we.Playing&&(i._channelContext.clearFailureCountTimeout=window.setTimeout((function(){i._channelContext.failureCount.value=0}),3e3))}))),this._channelContext.channelDisposables.add(this._channelContext.resolution.subscribe((function(e){i._channelContext.videoTelemetry&&i._channelContext.videoTelemetry.onVideoResolutionChanges(e.toString())}))),this._channelContext.channelDisposables.add(this._channelContext.bitrateLimit.subscribe((function(e){if(e&&i._channelContext.endPoint.value&&i._channelContext.stream.value){var t=Date.now()-i._channelContext.channelInitialization.getTime();i._channelContext.endPoint.value.limitBitrate(i._channelContext.stream.value,t,e,Re.Keep,Fe.Normal).catch((function(e){i._logger.error("Error while setting limit bitrate",e)}))}})));var d=function(){i._channelContext.stream.value&&i._channelContext.endPoint.value&&i._channelContext.endPoint.value.destroyStreamOnUnmount(i._channelContext.stream.value,"client:termination-on-window-unload")};window.addEventListener("beforeunload",d),this._channelContext.channelDisposables.add(new z((function(){window.removeEventListener("beforeunload",d)}))),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=we.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=Y.parseToken(this._tokenContext.token.value),n=(t.uri||Ce.discoveryUri.value).toString();Ce.tenancy.value=t.tenancy||Ce.tenancy.value,ce.uri.value=n,this._metricsService=_e.getMetricsService(n),this._streamTransformContext.hasInsertableStreams.value=t.capabilities.includes("insertable-streams"),this._streamTransformContext.hasEncodedInsertableStreams.value=t.capabilities.includes("encoded-insertable-streams"),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:"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,Re.Keep,Fe.Reset).then((function(t){"ok"===t.status&&(e._channelContext.bitrateLimit.value=0)})).catch((function(t){e._logger.error("Error while setting limit bitrate",t)}))}}},{key:"updateTargetLag",value:function(e){this._channelContext.targetLag.value=e}},{key:"stop",value:(d=b()(S().mark((function e(t){var n=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new bt((function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._channelContext.rendererDisposables.add(n._stateContext.isStarting.subscribe((function(r){r||(n.processStop(t),e())})))})));case 1:case"end":return e.stop()}}),e)}))),function(e){return d.apply(this,arguments)})},{key:"processStop",value:function(e){this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.pause(),this._channelContext.videoElement.value.srcObject=null),this._channelContext.rendererDisposables.dispose(),this.cleanUpResources(e),this._channelContext.state.value=we.Stopped}},{key:"resume",value:(c=b()(S().mark((function e(){return S().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=b()(S().mark((function e(){var t=this;return S().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 Y.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",Ce.discoveryUri.value),new URL(Ce.discoveryUri.value))}},{key:"start",value:(o=b()(S().mark((function e(){return S().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:(i=b()(S().mark((function e(){var t,n,r,i,o,a,s,u,c,l,d,p,f,v,m,g,_,y,C,b=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),Y.isEncodedEdgeTokenValid(t)){e.next=8;break}return this._logger.error("Failed to parse token [%s]",t),this._channelContext.state.value=we.Unauthorized,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 8:if(!this._streamTransformContext.videoStreamTransformCallback){e.next=16;break}if(r=Ae.validateMediaStreamTrackTransform("video",this._streamTransformContext.videoStreamTransformCallback),i=r.valid,o=r.validationResult,i){e.next=16;break}return this._logger.error(o),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 16:if(!this._streamTransformContext.audioStreamTransformCallback){e.next=24;break}if(a=Ae.validateMediaStreamTrackTransform("audio",this._streamTransformContext.audioStreamTransformCallback),s=a.valid,u=a.validationResult,s){e.next=24;break}return this._logger.error(u),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 24:if(!this._streamTransformContext.encodedVideoStreamSink){e.next=32;break}if(c=Ie.validateEncodedStreamSink("video",this._streamTransformContext.encodedVideoStreamSink),l=c.valid,d=c.validationResult,l){e.next=32;break}return this._logger.error(d),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 32:if(!this._streamTransformContext.encodedAudioStreamSink){e.next=40;break}if(p=Ie.validateEncodedStreamSink("audio",this._streamTransformContext.encodedAudioStreamSink),f=p.valid,v=p.validationResult,f){e.next=40;break}return this._logger.error(v),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 40:if(!this._streamTransformContext.hasInsertableStreams.value||!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=46;break}return this._logger.error("Both insertable-streams and encoded-insertable-streams are enabled, only use one or the other"),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 46:if(m="function"==typeof this._streamTransformContext.videoStreamTransformCallback||"function"==typeof this._streamTransformContext.audioStreamTransformCallback,g="function"==typeof this._streamTransformContext.encodedVideoStreamSink||"function"==typeof this._streamTransformContext.encodedAudioStreamSink,!m||!g){e.next=54;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=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 54:if(!this._streamTransformContext.hasInsertableStreams.value){e.next=69;break}if(h.isInsertableStreamsSupported){e.next=61;break}return this._logger.error("Browser does not support Media Stream Track API"),this._channelContext.state.value=we.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 61:if(m){e.next=67;break}return this._logger.error("CreateChannelOptions transform callback function is missing; however, insertable-streams is enabled"),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 67:e.next=75;break;case 69:if(!m){e.next=75;break}return this._logger.error("CreateChannelOptions transform callback function found; however, insertable-streams is not enabled"),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 75:if(!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=90;break}if(h.isEncodedInsertableStreamsSupported||h.isRTCRtpScriptTransformSupported){e.next=82;break}return this._logger.error("Browser does not support encodedInsertableStreams API"),this._channelContext.state.value=we.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 82:if(g){e.next=88;break}return this._logger.error("CreateChannelOptions transform sink function is missing; however, encoded-insertable-streams is enabled"),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 88:e.next=96;break;case 90:if(!g){e.next=96;break}return this._logger.error("CreateChannelOptions transform sink function found; however, encoded-insertable-streams is not enabled"),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 96:if(this.cleanUpResources("client:start"),this._channelContext.state.value=we.Starting,this._channelContext.loading.value=!0,_=this.getUri(t),this._channelContext.disposables.add(this._channelContext.state.subscribe((function(e){e!==we.Error&&e!==we.Recovering||We.clearCachedClosestEndpoint(_)}))),y=function(){return new bt((function(e){return b._stateContext.isStarting.value=!1,e(b.handleStreamFailure())}))},C=Ct.create(t,this._channelContext,this._peerConnectionContext,this._streamTransformContext,y)){e.next=106;break}return this._stateContext.isStarting.value=!1,e.abrupt("return");case 106:return e.abrupt("return",C.start(_,t,n,this.playMediaStreamInVideoElement.bind(this)).then((function(){b._channelContext.loading.value=!1})).catch((function(e){n.fail(),b._channelContext.failureCount.value++,b._channelContext.online.value=!1,b.cleanUpResources("client:cleanup-after-failed-setup"),b._channelContext.state.value=we.ClientStartError,b._logger.error("Failed to start channel",e)})).finally((function(){if(b._stateContext.isStarting.value=!1,b._channelContext.state.value!==we.Playing&&Ce.automaticRetryOnFailure){var e=setTimeout((function(){b.handleStreamFailure().catch((function(e){b._logger.error("Failed handling stream failure",e)}))}),b.getRetryInterval());b._channelContext.disposables.add(new z((function(){clearTimeout(e)})))}})));case 107:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"restartAfterStop",value:(r=b()(S().mark((function e(){return S().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 r.apply(this,arguments)})},{key:"play",value:(n=b()(S().mark((function e(){var t;return S().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 we.StandBy:case we.Offline:return 15e3;case we.Error:case we.Recovering:case we.Unauthorized:case we.GeoRestricted:case we.GeoBlocked:case we.Stopped:case we.Starting:case we.Playing:case we.Paused:case we.Reconnecting:case we.UnsupportedFeature:case we.ConfigurationError:case we.TransientConfigurationError:case we.ConnectionError:case we.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._channelContext.failureCount.value);default:O(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(t=b()(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._channelContext.state.value,e.next=e.t0===we.Error||e.t0===we.Reconnecting||e.t0===we.StandBy||e.t0===we.Offline||e.t0===we.Recovering||e.t0===we.TransientConfigurationError||e.t0===we.ConnectionError||e.t0===we.ClientStartError?3:e.t0===we.Unauthorized?5:e.t0===we.GeoRestricted?7:e.t0===we.GeoBlocked?9:e.t0===we.Stopped?11:e.t0===we.Playing?13:e.t0===we.Paused?15:e.t0===we.Starting?17:e.t0===we.UnsupportedFeature?19:e.t0===we.ConfigurationError?21:23;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,we[this._channelContext.state.value]),e.abrupt("break",24);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 playing, skipping retry of start"),e.abrupt("return");case 15:return this._logger.info("Channel is paused, skipping retry of start. Please invoke play()"),e.abrupt("return");case 17:return this._logger.info("Channel is already starting, skipping retry of start"),e.abrupt("return");case 19:return this._logger.info("Channel is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 21:return this._logger.info("Channel is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 23:O(this._channelContext.state.value);case 24:return e.abrupt("return",this.start());case 25: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(),!Ce.forceGarbageCollectionOnRestart||h.isMobile&&Ce.skipGarbageCollectionOnMobileDevices||ke.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:"playMediaStreamInVideoElement",value:(e=b()(S().mark((function e(t){var n,r,i=this;return S().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=we.Stopped,e.abrupt("return");case 8:if(this._streamTransformContext.hasEncodedInsertableStreams.value||(n.srcObject=t),void 0!==(r=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=we.Playing,e.abrupt("return");case 17:return e.abrupt("return",r.then((function(){i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!1,i._channelContext.loading.value=!1,i._channelContext.playing.value=!0,i._channelContext.state.value=we.Playing})).catch((function(e){var r=!!t.getTracks().filter((function(e){return"audio"===e.kind})).length,o=!Ce.automaticallyMuteVideoOnPlayFailure;return o||n.muted||!r?(n.srcObject=null,i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=we.Paused,o?void i._logger.info("[%s] Paused video after play failed. Manual user action required.",i.streamId,e):r?void i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e):void i._logger.info("[%s] Failed to play muted video. Manual user action required.",i.streamId,e)):(n.muted=!0,n.play().then((function(){i._logger.info("[%s] Played video after auto muting. Manual user action required to unmute.",i.streamId),i._channelContext.autoMuted.value=!0,i._channelContext.autoPaused.value=!1,i._channelContext.loading.value=!1,i._channelContext.playing.value=!0,i._channelContext.state.value=we.Playing})).catch((function(e){n.muted=!1,i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e),n.srcObject=null,i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=we.Paused})))})));case 18:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,i,o,s,c,d}(),St=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(!Ce.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 kt(e.videoElement,e.token,t)}}])}(),wt={SDK:Ce,Channels:St,ChannelState:we}})(),r})()));
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.phenix=t():e.phenix=t()}(self,(()=>(()=>{var e={701:(e,t,n)=>{"use strict";n.d(t,{A:()=>p});var r=n(738),i=n.n(r),o=n(383),a=n.n(o),s=n(579),u=n.n(s),c=n(693),l=n.n(c),d=u()((function e(t,n,r){a()(this,e),l()(this,"onFulfilled",void 0),l()(this,"onRejected",void 0),l()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.promise=r})),h=function(){function e(t){if(a()(this,e),l()(this,"_state",void 0),l()(this,"_handled",void 0),l()(this,"_value",void 0),l()(this,"_deferreds",void 0),!(this instanceof e))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=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"===i()(t)||"function"==typeof t)){var r=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof r)return void n.doResolve((function(){r.apply(t,arguments)}))}n._state=1,n._value=t,n.finale()}catch(e){n.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate((function(){t._handled||e._unhandledRejection(t._value)}));for(var n=0,r=this._deferreds.length;n<r;n++)this.handle(this._deferreds[n]);this._deferreds=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 r;try{r=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(r)}else 1===n._state?t.promise.promiseResolve(n._value):t.promise.promiseReject(n._value)}))):n._deferreds.push(t)}}],[{key:"all",value:function(t){return new e((function(e,n){if(!Array.isArray(t))return n(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);for(var o=r.length,a=function(t,s){try{if(s&&("object"===i()(s)||"function"==typeof s)){var u=s.then;if("function"==typeof u)return void u.call(s,(function(e){return a(t,e)}),n)}r[t]=s,0==--o&&e(r)}catch(e){n(e)}},s=0;s<r.length;s++)a(s,r[s])}))}},{key:"resolve",value:function(t){return t&&"object"===i()(t)&&t.constructor===e?t:new e((function(e){return e(t)}))}},{key:"reject",value:function(t){return new e((function(e,n){return n(t)}))}},{key:"race",value:function(t){return new e((function(n,r){if(!Array.isArray(t))return r(new TypeError("Promise.race accepts an array"));for(var i=0,o=t.length;i<o;i++)e.resolve(t[i]).then(n,r)}))}},{key:"_immediate",value:function(e){setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}])}();h.prototype.catch=function(e){return this.then(null,e)},h.prototype.then=function(e,t){var n=new this.constructor((function(){return null}));return this.handle(new d(e,t,n)),n},h.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 p=h},79:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},987:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},901:(e,t,n)=>{var r=n(79);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},475:e=>{e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},293:(e,t,n)=>{var r=n(701).A;function i(e,t,n,i,o,a,s){try{var u=e[a](s),c=u.value}catch(e){return void n(e)}u.done?t(c):r.resolve(c).then(i,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new r((function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,u,"next",e)}function u(e){i(a,r,o,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,n)=>{var r=n(736);function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}e.exports=function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,t,n)=>{var r=n(736);e.exports=function(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},72:e=>{function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},511:(e,t,n)=>{var r=n(636);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},291:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},156:e=>{e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}},e.exports.__esModule=!0,e.exports.default=e.exports},752:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},869:e=>{e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},452:(e,t,n)=>{var r=n(738).default,i=n(475);e.exports=function(e,t){if(t&&("object"==r(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return i(e)},e.exports.__esModule=!0,e.exports.default=e.exports},633:(e,t,n)=>{var r=n(701).A,i=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,r){var i=t&&t.prototype instanceof b?t:b,o=Object.create(i.prototype),a=new I(r||[]);return u(o,"_invoke",{value:R(e,n,a)}),o}function v(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=f;var m="suspendedStart",g="suspendedYield",_="executing",y="completed",C={};function b(){}function k(){}function S(){}var w={};p(w,l,(function(){return this}));var x=Object.getPrototypeOf,T=x&&x(x(A([])));T&&T!==a&&s.call(T,l)&&(w=T);var P=S.prototype=b.prototype=Object.create(w);function L(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function n(r,o,a,u){var c=v(e[r],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==i(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 r;u(this,"_invoke",{value:function(e,i){function o(){return new t((function(t,r){n(e,i,t,r)}))}return r=r?r.then(o,o):o()}})}function R(e,n,r){var i=m;return function(o,a){if(i===_)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var u=F(s,r);if(u){if(u===C)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===m)throw i=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=_;var c=v(e,n,r);if("normal"===c.type){if(i=r.done?y:g,c.arg===C)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=y,r.method="throw",r.arg=c.arg)}}}function F(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,F(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),C;var o=v(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,C;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,C):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,C)}function O(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 D(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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 r=-1,o=function n(){for(;++r<e.length;)if(s.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(i(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}},L(E.prototype),p(E.prototype,d,(function(){return this})),n.AsyncIterator=E,n.async=function(e,t,i,o,a){void 0===a&&(a=r);var s=new E(f(e,t,i,o),a);return n.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},L(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 r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},n.values=A,I.prototype={constructor:I,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(D),!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 r(r,i){return a.type="throw",a.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("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 r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,C):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),C},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),D(n),C}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;D(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:A(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),C}},n}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},636:e=>{function t(n,r){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n,r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},715:(e,t,n)=>{var r=n(987),i=n(156),o=n(122),a=n(752);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},132:(e,t,n)=>{var r=n(901),i=n(291),o=n(122),a=n(869);e.exports=function(e){return r(e)||i(e)||o(e)||a()},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,t,n)=>{var r=n(738).default;e.exports=function(e,t){if("object"!=r(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,t,n)=>{var r=n(738).default,i=n(45);e.exports=function(e){var t=i(e,"string");return"symbol"==r(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},122:(e,t,n)=>{var r=n(79);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},756:(e,t,n)=>{var r=n(633)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.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 r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},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 r={};return(()=>{"use strict";n.r(r),n.d(r,{ChannelState:()=>we,Channels:()=>St,SDK:()=>Ce,default:()=>wt});var e,t,i,o=n(383),a=n.n(o),s=n(579),u=n.n(s),c=n(693),l=n.n(c),d=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=d,l()(d,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),l()(d,"_browserNameAndVersion",e.parseBrowserNameAndVersion()),l()(d,"_browserName",e.parseBrowserName()),l()(d,"_browserMajorVersion",e.parseBrowserMajorVersion()),l()(d,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(t=navigator)||void 0===t?void 0:t.userAgent)),l()(d,"_isAndroid",/Android/i.test(null===(i=navigator)||void 0===i?void 0:i.userAgent)),l()(d,"_isChrome69",e._browserNameAndVersion.includes("Chrome/69.")),l()(d,"_isChrome70",e._browserNameAndVersion.includes("Chrome/70.")),l()(d,"_isChrome71",e._browserNameAndVersion.includes("Chrome/71.")),l()(d,"_isChrome72",e._browserNameAndVersion.includes("Chrome/72.")),l()(d,"_isChrome74",e._browserNameAndVersion.includes("Chrome/74.")),l()(d,"_isChrome75",e._browserNameAndVersion.includes("Chrome/75.")),l()(d,"_isChrome76",e._browserNameAndVersion.includes("Chrome/76.")),l()(d,"_isChrome77",e._browserNameAndVersion.includes("Chrome/77."));var h=function(){return u()((function e(){a()(this,e)}),null,[{key:"clientOfferDisabled",get:function(){return d.isChrome74||d.isChrome75||d.isChrome76||d.isChrome77}},{key:"addTranceiverDisabled",get:function(){return d.isChrome69||d.isChrome70||d.isChrome71||d.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===d.browserName&&d.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===d.browserName&&d.browserMajorVersion<=69||"Firefox"===d.browserName&&d.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===d.browserName&&d.browserMajorVersion<=63||"Firefox"===d.browserName&&d.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===d.browserName&&d.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===d.browserName&&d.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===d.browserName||"SamsungBrowser"===d.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==d.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===d.browserName&&"function"==typeof(null===(e=document)||void 0===e?void 0:e.createElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===d.browserName&&d.browserMajorVersion>=71||"Firefox"===d.browserName&&d.browserMajorVersion>=69||"Safari"===d.browserName}},{key:"isMobile",get:function(){return d.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:"errorStackAlsoHasErrorMessage",get:function(){return"Firefox"!==d.browserName&&"Safari"!==d.browserName}}])}(),p=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),f=function(){return u()((function e(t,n,r){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=r}),[{key:"category",get:function(){return this._category}},{key:"appenders",get:function(){return this._appenders}},{key:"threshold",get:function(){return this._threshold}},{key:"trace",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>p.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(p.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,r=new Date,i=this.replacePlaceholders(t);this._appenders.value.forEach((function(t){t.log(e,i,n.category,r)}))}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],r=0;n.indexOf&&e.length>1&&r>=0;)if((r=n.indexOf("%",r))>0)switch(n.substring(r+1,r+2)){case"%":n=n.substring(0,r)+n.substring(r+1),r++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,r),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,r),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce((function(e,n,r,i){return r+1===i.length&&n instanceof Error?h.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}),[])}}])}(),m=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:!0,sendLogs:"All",sendMetrics:"All",logToConsole:"All"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}])}();l()(m,"_sendLocalCandidates",void 0),l()(m,"_sendLogs",void 0),l()(m,"_sendMetrics",void 0),l()(m,"_logToConsole",void 0),m.applyFeatures();var g=function(){return u()((function e(){a()(this,e)}),null,[{key:"defaultLoggingLevel",get:function(){return p[m.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return p[m.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return p.Info}}])}(),_=function(){return u()((function e(){a()(this,e),l()(this,"_threshold",g.defaultLoggingLevel)}),[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}])}(),y=function(){return u()((function e(t){a()(this,e),l()(this,"_threshold",void 0),this._threshold=t}),[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(p[e],"] ").concat(t);e<p.Warn?console.log(i):console.error(i)}}}])}(),C=n(293),b=n.n(C),k=n(756),S=n.n(k),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,r=t;return r<0&&(r*=-1,n++),e.countDigitsBeforeDecimal(r)+n+(r!==Math.floor(r)?e.countDigitsAfterDecimal(r)+1:0)}},{key:"fixRounding",value:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}},{key:"countDigitsBeforeDecimal",value:function(e){for(var t=1,n=e;n>=10;)n/=10,t++;return t}},{key:"countDigitsAfterDecimal",value:function(t){for(var n=t,r=Math.floor(t),i=0;r!==n&&i<15;)i++,r=e.fixRounding(n,i);return i}}])}(),x=function(){return u()((function e(){a()(this,e)}),null,[{key:"sdkVersion",get:function(){try{return"2024-08-14T22:48:47.741Z (2024.2.1)"}catch(e){return this._defaultVersion}}}])}();l()(x,"_defaultVersion",(new Date).toISOString());var T=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",location.hostname),this._telemetryConfiguration=t}),[{key:"push",value:function(e,t,n,r){var i=(r.valueOf()-this._telemetryConfiguration.pageLoadTime)/1e3,o={timestamp:r.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:p[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:x.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<p.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"sendLogs",value:(t=b()(S().mark((function e(t){var n;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,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=b()(S().mark((function e(){var t,n,r,i,o,a=this;return S().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,r=function(e){return"number"==typeof e?w.countNumberLength(e):e.length},i=function(e){return Object.values(e).reduce((function(e,t){return e+(t?r(t):0)}),0)};this._logs.length>t&&i(this._logs[t])+n<8192;)n+=i(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,i(this._logs[t])+(8192-i(this._logs[t]))),t=1),o=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.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}(),P=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 T(t)}),[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}])}(),L=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",g.defaultTelemetryLoggingLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new 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}}])}(),E=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),R=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",F.defaultTelemetryLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new 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}}])}(),F=function(){return u()((function e(){a()(this,e)}),null,[{key:"defaultTelemetryLevel",get:function(){return E[m.sendMetrics]}}])}(),O=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},D=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case E.Off:return"Off";case E.Essential:return"Essential";case E.All:return"All";default:O(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return E.Off;case"Essential":return E.Essential;case"All":return E.All;default:O(e)}}}])}(),I=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case p.Off:return"Off";case p.Trace:return"Trace";case p.Debug:return"Debug";case p.Info:return"Trace";case p.Warn:return"Warn";case p.Error:return"Error";case p.Fatal:return"Fatal";case p.All:return"All";default:O(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return p.Off;case"Trace":return p.Trace;case"Debug":return p.Debug;case"Info":return p.Info;case"Warn":return p.Warn;case"Error":return p.Error;case"Fatal":return p.Fatal;case"All":return p.All;default:O(e)}}}])}(),A=function(){return u()((function e(){a()(this,e)}),[{key:"getStringValue",value:function(e){return this.readConfigurationParameterValue(e)||this.readConfigurationParameterURIValue("".concat(e,"-uri-parameter-name"))||this.defaultStringValue[e]}},{key:"getBooleanValue",value:function(e){var t=this.readConfigurationParameterValue(e);if(t)return"true"===t||"1"===t||"On"===t;var n=this.readConfigurationParameterURIValue("".concat(e,"-uri-parameter-name"));return n?"true"===n||"1"===n||"On"===n:!0===this.defaultBooleanValue[e]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":D.convertTelemetryLevelToTelemetryLevelType(F.defaultTelemetryLevel),"phenix-logging-level":I.convertLoggingLevelToLoggingLevelType(g.defaultLoggingLevel),"phenix-console-logging-level":I.convertLoggingLevelToLoggingLevelType(g.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":I.convertLoggingLevelToLoggingLevelType(g.defaultTelemetryLoggingLevel),"phenix-channel-token":"","phenix-uri":"","phenix-base-uri":""}}},{key:"defaultBooleanValue",get:function(){return{"phenix-automatically-retry-on-failure":!0,"phenix-automatically-reconnect-peer-connection":!0,"phenix-force-garbage-collection-on-restart":!0,"phenix-skip-garbage-collection-on-mobile-devices":!0}}},{key:"readConfigurationParameterValue",value:function(e){var t=document.querySelector("meta[name='".concat(e,"']"));if(t){var n=t.getAttribute("value");if(n)return n}}},{key:"readConfigurationParameterURIValue",value:function(e){var t=this.readConfigurationParameterValue(e);if(t){var n=new URLSearchParams(location.search).get(t)||void 0;if(n)return n}}}])}(),M=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 f(t,this._appenders,this._threshold))}},{key:"applyLoggerConfigFromParameterConfiguration",value:function(){e.applyLoggingLevel(),e.applyAppenderLoggingLevel("console",e.applyConsoleLogger.bind(this)),e.applyAppenderLoggingLevel("telemetry",e.applyTelemetryLogger.bind(this))}},{key:"applyLoggingLevel",value:function(){var e=this._configurationParameterReader.getStringValue("phenix-logging-level");p[e]&&this._threshold.setThreshold(p[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=this._configurationParameterReader.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(p[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new y(e||g.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||g.defaultTelemetryLoggingLevel,this._appenders.add(new P(this._telemetryConfiguration))}}])}();l()(M,"_configurationParameterReader",new A),l()(M,"_loggers",{}),l()(M,"_appenders",new v),l()(M,"_threshold",new _),l()(M,"_telemetryConfiguration",new L),M.applyLoggerConfigFromParameterConfiguration();var N=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)}}])}(),V=n(452),j=n.n(V),U=n(72),B=n.n(U),G=n(511),H=n.n(G),z=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(e,t,n){return t=B()(t),j()(e,J()?Reflect.construct(t,n||[],B()(e).constructor):t.apply(e,n))}function J(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(J=function(){return!!e})()}var q=function(e){function t(e,n){return a()(this,t),W(this,t,[function(){var t=e.indexOf(n);t>=0&&e.splice(t,1)}])}return H()(t,e),u()(t)}(z),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 q(this._listeners,e)}}])}(),Z=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)}}])}(),Q=function(){return u()((function e(t){var n,r;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 URL(t.token.uri):null,capabilities:(null==t||null===(r=t.token)||void 0===r?void 0:r.capabilities)||[]}}),[{key:"uri",get:function(){return this._token.uri}},{key:"capabilities",get:function(){return this._token.capabilities}},{key:"tenancy",get:function(){return this._applicationId}}])}(),Y=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 Q(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new Q(r)}catch(t){return e._logger.error("Cannot parse token value",t),new Q(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();l()(Y,"_logger",M.getLogger("EdgeAuthParser"));var $=n(738),X=n.n($),ee=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,"]")}}])}(),te=function(){return u()((function e(){a()(this,e),l()(this,"_disposables",new ee),l()(this,"_readOnlyIsForeground",void 0),l()(this,"_isForeground",void 0),l()(this,"_timeOfLastTabFocusChange",Date.now()),l()(this,"_documentFocusInterval",void 0),this._isForeground=new K(!0),this._readOnlyIsForeground=new Z(this._isForeground),this.detectTabFocusChange()}),[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"detectTabFocusChange",value:function(){var e,t,n=this;if("object"===("undefined"==typeof document?"undefined":X()(document))){void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden?(e="webkitHidden",t="webkitvisibilitychange"):void 0!==document.hidden&&(e="hidden",t="visibilitychange");var r=function(){var t=!document[e];n.setFocusState(t)};void 0!==document.addEventListener&&void 0!==document[e]?(document.addEventListener(t,r,!1),this._disposables.add(new z((function(){document.removeEventListener(t,r,!1)})))):this.listenForDocumentFocus.call(this)}}},{key:"listenForDocumentFocus",value:function(){var e=this;this._documentFocusInterval=window.setInterval((function(){var t=document.hasFocus();e.setFocusState(t)}),3e3),this._disposables.add(new z((function(){e._documentFocusInterval&&clearInterval(e._documentFocusInterval),e._documentFocusInterval=null})))}},{key:"setFocusState",value:function(e){this._isForeground!==e&&(this._isForeground.value=e)}}])}(),ne=n(701).A,re=function(){return u()((function e(t){a()(this,e),l()(this,"_logger",M.getLogger("VanillaPeerConnection")),l()(this,"_peerConnection",void 0),h.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:"supportsAddTransceiver",get:function(){return!h.addTranceiverDisabled&&"function"==typeof this._peerConnection.addTransceiver}},{key:"createOffer",value:(r=b()(S().mark((function e(t){var n=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!h.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new ne((function(e,r){return n._peerConnection.createOffer(e,r,t)})));case 2:return e.abrupt("return",this._peerConnection.createOffer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAnswer",value:(n=b()(S().mark((function e(t){var n=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!h.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new ne((function(e,r){return n._peerConnection.createAnswer(e,r,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=b()(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._peerConnection.setLocalDescription(h.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=b()(S().mark((function e(t){var n;return S().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(h.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 ne((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:"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,r}(),ie=function(){return u()((function e(){a()(this,e)}),[{key:"createPeerConnection",value:(e=b()(S().mark((function e(t){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new re(t));case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e}(),oe=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(){h.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(n=b()(S().mark((function t(){return S().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=b()(S().mark((function t(){var n,r,i,o,a=arguments;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=a.length>0&&void 0!==a[0]?a[0]:"recvonly",r=a.length>1&&void 0!==a[1]&&a[1],!e._cached||e._cached.direction!==n||r){t.next=6;break}return i=e._cached.peerConnection,e._cached=null,t.abrupt("return",i);case 6:return o=h.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:r}:void 0,t.abrupt("return",e._peerConnectionFactory.value.createPeerConnection(o).then(function(){var e=b()(S().mark((function e(t){var r,i,o;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.supportsAddTransceiver){e.next=11;break}return i=t.addTransceiver("audio",{direction:n}),r=t.addTransceiver("video",{direction:n}),e.t0=i,e.t1=r,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()(oe,"_logger",M.getLogger("PeerConnectionService")),l()(oe,"_peerConnectionFactory",new K(new ie)),l()(oe,"_cached",void 0),oe.initiateInitialPrecaching();var ae=function(){return u()((function e(){a()(this,e)}),null,[{key:"getTelemetryUrl",value:function(e){try{var t=new 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}}}])}(),se=function(){return u()((function e(){a()(this,e)}),null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new URL(e).origin}catch(e){return""}}}])}(),ue=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:"distribution"}};this._discoveryParameters="discovery"in e?e.discovery:{intentions:""}}catch(e){this._discoveryParameters={intentions:""}}}}])}();l()(ue,"_discoveryParameters",void 0),ue.applyParameters();var ce=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 URL(e.toString()),n=x.sdkVersion,r=ue.discoveryParameters.intentions;return t.searchParams.set("version",n),t.searchParams.set("intentions",r),t.searchParams.set("_","".concat(Date.now())),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}])}();l()(ce,"_discoveryUri",new K("https://pcast.phenixrts.com/pcast/endPoints"));var le,de=n(132),he=n.n(de),pe=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,r=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=r}),[{key:"getExponentialBackoffIntervalByFailureCount",value:function(e){var t=this._backoffIntervalInMillisecond/1e3,n=.5+.5*Math.random(),r=Math.pow(t,e-2),i=Math.floor(r)*n,o=Math.ceil(Math.max(1e3*i,this._minBackoffIntervalInMillisecond));return Math.min(o,this._maxBackoffIntervalInMillisecond)}}])}(),fe=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}(fe||{}),ve=fe,me=function(){return u()((function e(t){a()(this,e),l()(this,"_metrics",void 0),this._metrics=t}),[{key:"getName",value:function(){return ve[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case ve.TimeToFirstFrame:case ve.ChannelCreationTimeToFirstFrame:return E.Essential;case ve.Stalled:case ve.Buffering:case ve.SetupCompleted:case ve.SetupFailed:case ve.RoundTripTime:case ve.DownlinkThroughputCapacity:case ve.NetworkType:case ve.ResolutionChanged:case ve.ApplicationForeground:case ve.ApplicationBackground:return E.All;default:O(this._metrics)}}}])}(),ge=function(){return u()((function e(t){a()(this,e),l()(this,"_logger",M.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",location.hostname),this._metricsConfiguration=t,this._exponentialBackoff=new pe}),[{key:"metricsConfiguration",get:function(){return this._metricsConfiguration}},{key:"push",value:function(e){var t=e.streamId,n=e.value,r=e.previousValue,i=e.runtime,o=e.resource,a=e.kind,s=new 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:r,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:x.sdkVersion,runtime:i,resource:o,kind:a};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:(t=b()(S().mark((function e(t){var n;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,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=b()(S().mark((function e(){var t,n=this;return S().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 setTimeout((function(){n._metrics=[].concat(he()(t),he()(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}(),_e=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 r=new R;return r.sessionId=Ce.clientSessionId,r.tenancy=Ce.tenancy.value,r.url=ae.getTelemetryUrl(t),r.environment=se.getEnvironmentFromUrl(t),r.threshold=D.convertTelemetryLevelTypeToTelemetryLevel(Ce.telemetryLevel),e._metricsServices[t]=new ge(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}])}();l()(_e,"_metricsServices",{});var ye=window.__phenixPageLoadTime||window.__pageLoadTime||Date.now(),Ce=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 ye}},{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 I.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return D.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return d}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=M.telemetryConfiguration;n.sessionId=e.clientSessionId,n.pageLoadTime=e.pageLoadTime,e._environment.subscribe((function(e){n.environment=e})),e.telemetryUrl.subscribe((function(e){var r=t._logger.appenders.value.find((function(e){return e instanceof P}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new P(n)),t._logger.info("Telemetry URL was set to [%s]",n.url))})),e._tenancy.subscribe((function(e){var r=t._logger.appenders.value.find((function(e){return e instanceof P}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new P(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=_e.getMetricsService(ce.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&&_e.setTelemetryLevel(E[t]),e._telemetryLevel.subscribe((function(e){_e.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=se.getEnvironmentFromUrl(t)}));var t=this._configurationParameterReader.getStringValue("phenix-channel-token");if(t){var n=Y.parseToken(t);return e._tenancy.value=n.tenancy,ce.uri.value=(n.uri||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var r=this._configurationParameterReader.getStringValue("phenix-uri");if(r)return ce.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=this._configurationParameterReader.getStringValue("phenix-base-uri");if(i){var o=new URL(i);return o.pathname="/pcast/endPoints",ce.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 te),t){if(t.discoveryUri&&(ce.uri.value=t.discoveryUri),t.peerConnectionFactory&&(oe.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&E[t.telemetryLevel]&&(e._telemetryLevel.value=D.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&p[t.loggingLevel]&&this._logger.threshold.setThreshold(I.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&p[t.consoleLoggingLevel]){var n=this._logger.appenders.value.find((function(e){return e instanceof y}));n&&this._logger.appenders.remove(n),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new y(I.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 ae.getTelemetryUrl(e)}}])}();le=Ce,l()(Ce,"_automaticallyRetryOnFailure",!0),l()(Ce,"_automaticallyReconnectPeerConnection",!0),l()(Ce,"_automaticallyPlayMediaStream",!0),l()(Ce,"_automaticallyMuteVideoOnPlayFailure",!0),l()(Ce,"_forceGarbageCollectionOnRestart",!0),l()(Ce,"_skipGarbageCollectionOnMobileDevices",!0),l()(Ce,"_webPlayerLoader",null),l()(Ce,"_shakaPlayerLoader",null),l()(Ce,"_hlsJsLoader",null),l()(Ce,"_configurationParameterReader",new A),l()(Ce,"_applicationActivityMonitor",void 0),l()(Ce,"_environment",new K("")),l()(Ce,"_telemetryUrl",new K("https://telemetry.phenixrts.com/telemetry")),l()(Ce,"_maximalNumberOfPeerConnectionReconnectAttempts",8),l()(Ce,"_telemetryLevel",new K(F.defaultTelemetryLevel)),l()(Ce,"_metricsService",void 0),l()(Ce,"_metricsConfiguration",void 0),l()(Ce,"_sendLocalCandidates",new K(m.sendLocalCandidates)),l()(Ce,"_tenancy",new K("")),l()(Ce,"_clientSessionId",N.random(32)),l()(Ce,"_loadedTimestamp",new Date),l()(Ce,"_logger",M.getLogger("SDK")),l()(Ce,"_initialized",new K(!1)),l()(Ce,"_readOnlyInitialized",new Z(le._initialized)),l()(Ce,"_readOnlyDiscoveryUri",new Z(ce.uri)),l()(Ce,"_readOnlyPeerConnectionFactory",new Z(oe.peerConnectionFactory)),window.addEventListener("unload",(function(){Ce.dispose()})),Ce.applyDiscoveryUriDefaultFromParameterConfiguration(),Ce.applyMetricsConfiguration(),Ce.applyTelemetryConfiguration(),Ce.applyAutomaticallyRetryOnFailureFromParameterConfiguration(),Ce.applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration(),Ce.applyForceGarbageCollectionOnRestartFromParameterConfiguration(),Ce.applySkipGarbageCollectionOnMobileDevicesFromParameterConfiguration(),Ce.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)}}])}(),ke=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(){h.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){var e=this;h.isQueueMicrotaskSupported?queueMicrotask((function(){e.overloadMemoryToInvokeGarbageCollection()})):setTimeout((function(){e.overloadMemoryToInvokeGarbageCollection()}))}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=document.createElement("img");e.src=window.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){window.URL.revokeObjectURL(this.src),e=null}}}])}(),Se=function(e){return 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}(Se||{}),we=Se,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),r=n%1e3,i=(n=Math.floor(n/1e3))%60,o=(n=Math.floor(n/60))%60,a=(n=Math.floor(n/60))%24,s=["PT"];return e&&s.unshift("-"),a&&s.push(a+"H"),o&&s.push(o+"M"),(i||r)&&(s.push(String(i)),r&&s.push("."+this.padStart(r.toString(),3,"0")),s.push("S")),s.join("")}},{key:"padStart",value:function(e,t,n){return t|=0,n=String(void 0!==n?n:" "),e.length>t?e:((t-=e.length)>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}}])}(),Te=function(){return u()((function e(t,n,r,i){a()(this,e),l()(this,"_pageLoadTime",void 0),l()(this,"_channelStartTime",void 0),l()(this,"_logger",M.getLogger("StreamTelemetry")),l()(this,"_disposables",new ee),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=r,this._metricsService=i}),[{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 z((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 z((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:ve.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:ve.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:ve.Stalled,runtime:(Date.now()-this._pageLoadTime)/1e3,streamId:this._streamId}),this._videoStalled=Date.now(),this._logger.info("[%s] [%s] [buffering] Stream has stalled",this.durationSincePageLoad,this._streamId))}},{key:"onContinuation",value:function(e,t){if(t.buffered){var n=t.buffered.length,r=!("playing"===e.type||n>0)||("progress"===e.type||"timeupdate"===e.type)&&t.buffered.end(n-1)===this._lastProgress;if(this._videoStalled&&!r){"progress"===e.type&&(this._lastProgress=t.buffered.end(n-1));var i=Date.now()-this._videoStalled;this._metricsService.push({metricType:ve.Buffering,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{uint64:i},streamId:this._streamId}),this._logger.info("[%s] [%s] [buffering] Stream has recovered from stall after [%s]",this.durationSincePageLoad,this._streamId,new xe(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:ve.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}}])}(),Pe=function(){return u()((function e(t){a()(this,e),l()(this,"_logger",M.getLogger("StreamSetupListener")),l()(this,"metricsService",Ce.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(ve.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(ve.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new me(e).getName();this.metricsService.push({metricType:e,runtime:(n-this._pageLoadTime)/1e3,value:{uint64:r},streamId:t}),this._logger.info("[%s] [%s] Stream metric [%s] in [%s]",new xe(n-this._pageLoadTime).toIsoString(),t,i,new xe(r).toIsoString())}}}])}(),Le=function(){return u()((function e(){a()(this,e),l()(this,"_disposables",new ee),l()(this,"_isSupported",navigator&&navigator.connection),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(){return this.isSupported?navigator.connection.downlink||navigator.connection.downlinkMax:-1}},{key:"getEffectiveType",value:function(){return this.isSupported?navigator.connection.effectiveType||navigator.connection.type:"Unknown"}},{key:"getRoundTripTime",value:function(){return navigator.connection.rtt}},{key:"setupNetworkChangeListeners",value:function(){var e=this,t=function(){e.updateStatistics()};navigator.connection.addEventListener("change",t),this._disposables.add(new z((function(){navigator.connection.removeEventListener("change",t)})))}},{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 r=this;a()(this,e),l()(this,"_logger",M.getLogger("SessionTelemetry")),l()(this,"_metricsService",void 0),l()(this,"_applicationActivityMonitor",Ce.applicationActivityMonitor),l()(this,"_networkMonitor",new Le),l()(this,"_pageLoadTime",void 0),l()(this,"_disposables",new ee),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){r.recordForegroundChange(e)}))),this._disposables.add(this._networkMonitor.rtt.subscribe((function(e){r.recordNetworkRTTUpdate(e)}))),this._disposables.add(this._networkMonitor.effectiveType.subscribe((function(e){r.recordNetworkTypeChangeUpdate(e)}))),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe((function(e){r.recordNetworkDownlinkThroughputCapacityUpdate(e)}))))}),[{key:"listenOnStreamSetup",value:function(){return new Pe(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?ve.ApplicationForeground:ve.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:ve.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:ve.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:ve.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)}}])}(),Re=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Fe=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),Oe=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 ee,this.channelDisposables=new ee,this.rendererDisposables=new ee,this.channelInitialization=new Date,this.videoElement=new K(null),this.state=new K(we.Starting),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=Ce.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return we.Starting;case"no-stream":case"not-found":return we.StandBy;case"geo-restricted":return we.GeoRestricted;case"geo-blocked":return we.GeoBlocked;case"unauthorized":return we.Unauthorized;case"capacity":case"rate-limited":case"timeout":return we.Recovering;case"forbidden-tag":return we.ConfigurationError;case"port-in-range-not-found":return we.TransientConfigurationError;case"failed":return we.Error;default:O(e)}}}])}(),Ie=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(X()(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"}}}])}(),Ae=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(X()(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"}}}])}(),Me=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})),Ne=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})),Ve=u()((function e(){a()(this,e),l()(this,"isStarting",void 0),l()(this,"isDisposed",void 0),this.isStarting=new K(!1),this.isDisposed=!1})),je=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Fe.Normal:return"Normal";case Fe.Force:return"Force";case Fe.Reset:return"Reset";default:O(e)}}}])}(),Ue=function(){return u()((function e(){a()(this,e)}),null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Re.Keep:return"Keep";case Re.Reset:return"Reset";default:O(e)}}}])}(),Be=n(701).A,Ge=function(){return u()((function e(t,n){if(a()(this,e),l()(this,"_logger",M.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=b()(S().mark((function e(){var t,n,r,i,o=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,Be.race([fetch(t,{method:"GET",cache:"no-cache"}),new Be((function(e,n){return setTimeout((function(){return n(new Error("Ping timed out [".concat(t,"]")))}),o._timeout)}))]);case 4:if(r=e.sent,i=Date.now(),r.ok){e.next=8;break}throw new Error("Ping failed [".concat(t,"] [").concat(r.status,"]"));case 8:return this._roundTripTime=i-n,e.abrupt("return",this._roundTripTime);case 10:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"subscribe",value:(f=b()(S().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,p,f,v,m=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=Y.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([i,"stream","subscribe"]).toString(),a=new FormData,s=x.sdkVersion,0===r&&n?(u={apiVersion:7,clientVersion:s,bearerToken:t,failureCount:r,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:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:7}},a.append("jsonBody",JSON.stringify(c))),l=Date.now(),e.prev=9,h=null,e.next=13,Be.race([fetch(o,{method:"POST",body:a}),new Be((function(e){return h=window.setTimeout((function(){m._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(o,"]"))),e({status:408})}),m._timeout)}))]).finally((function(){h&&clearTimeout(h)}));case 13:d=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"===(p=this.mapHttpStatusToSubscribeStatus(d))){e.next=23;break}return e.abrupt("return",{status:p});case 23:return f=Date.now(),e.next=26,this.convertHttpResponseToSubscribeResponse(i,d);case 26:return v=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",v,f-l),e.abrupt("return",v);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n){return f.apply(this,arguments)})},{key:"publish",value:(p=b()(S().mark((function e(t,n,r,i){var o,a,s,u,c,l,d,h,p,f,v,m,g=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=Y.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 FormData,u=x.sdkVersion,0===i&&r?(c={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:7,sessionDescription:{type:r.type,sdp:r.sdp}},createAnswerDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(c))):(l={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(l))),d=Date.now(),e.prev=9,p=null,e.next=13,Be.race([fetch(a,{method:"POST",body:s}),new Be((function(e){return p=window.setTimeout((function(){g._logger.error("Failed to publish",new Error("Publish timed out [".concat(a,"]"))),e({status:408})}),g._timeout)}))]).finally((function(){p&&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 publish",e.t0),e.abrupt("return",{status:"failed"});case 20:if("ok"===(f=this.mapHttpStatusToPublishStatus(h))){e.next=23;break}return e.abrupt("return",{status:f});case 23:return v=Date.now(),e.next=26,this.convertHttpResponseToPublishResponse(o,h);case 26:return m=e.sent,this._logger.debug("Got publish response [%j] in [%s] ms",m,v-d),e.abrupt("return",m);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n,r){return p.apply(this,arguments)})},{key:"setRemoteDescription",value:(h=b()(S().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,sessionDescription:{type:n.type,sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,Be.race([fetch(r,{method:"POST",body:i}),new Be((function(e){return u=window.setTimeout((function(){h._logger.error("Failed to set remote description",new Error("Set remote description timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&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 d=e.sent,this._logger.debug("Got set remote description response [%j] in [%s] ms",d,l-a),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return h.apply(this,arguments)})},{key:"limitBitrate",value:(d=b()(S().mark((function e(t,n,r,i,o){var a,s,u,c,l,d,h,p,f=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:Ue.convertBitrateStateToBitrateStateType(i),bitrateMode:je.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,d=null,e.next=9,Be.race([fetch(a,{method:"POST",body:s}),new Be((function(e){return d=window.setTimeout((function(){f._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(a,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){d&&clearTimeout(d)}));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 h=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),p=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",h,p-c),e.abrupt("return",{status:h});case 20:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t,n,r,i){return d.apply(this,arguments)})},{key:"addIceCandidates",value:(c=b()(S().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,p,f=this,v=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=v.length>3&&void 0!==v[3]?v[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),a=new FormData,s={apiVersion:7,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},a.append("jsonBody",JSON.stringify(s)),u=Date.now(),e.prev=6,l=null,e.next=10,Be.race([fetch(o,{method:"POST",body:a}),new Be((function(e){return l=window.setTimeout((function(){f._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(o,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){l&&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"===(d=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.next=20;break}return e.abrupt("return",{status:d});case 20:return h=Date.now(),e.next=23,this.convertHttpResponseToAddIceCandidatesResponse(c);case 23:return p=e.sent,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",p,h-u),e.abrupt("return",p);case 26:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e,t,n){return c.apply(this,arguments)})},{key:"destroyStream",value:(s=b()(S().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new FormData,o={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,Be.race([fetch(r,{method:"POST",body:i,cache:"no-cache"}),new Be((function(e){return u=window.setTimeout((function(){h._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&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 d=e.sent,this._logger.info("Got destroy stream response [%j] in [%s] ms",d,l-a),e.abrupt("return",d);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return s.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(o=b()(S().mark((function e(t,n){var r,i,o,a;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null!==(r=navigator)&&void 0!==r&&r.sendBeacon||this.destroyStream(t,n),i=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),o=new FormData,a={apiVersion:7,sharedSecret:t.sharedSecret,reason:n,options:[]},o.append("jsonBody",JSON.stringify(a)),navigator.sendBeacon(i,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 URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,he()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new URL(this._uri),t=x.sdkVersion,n=ue.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:(i=b()(S().mark((function e(t,n){var r,i;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},i.lag=r.lag,r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(r=b()(S().mark((function e(t,n){var r,i;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:r.setRemoteDescriptionResponse.sessionDescription}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:r.createAnswerDescriptionResponse.sessionDescription}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:r.createOfferDescriptionResponse.sessionDescription})),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={iceServers:[]};if(e.bundlePolicy&&(t.bundlePolicy=e.bundlePolicy),"number"==typeof e.iceCandidatePoolSize&&(t.iceCandidatePoolSize=e.iceCandidatePoolSize),e.iceServers){for(var n=[],r=0;r<e.iceServers.length;r++)n.push({urls:e.iceServers[r].urls,username:e.iceServers[r].username,credential:e.iceServers[r].credential});t.iceServers=n}return e.iceTransportPolicy&&(t.iceTransportPolicy=e.iceTransportPolicy),e.rtcpMuxPolicy&&(t.rtcpMuxPolicy=e.rtcpMuxPolicy),t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(n=b()(S().mark((function e(t){var n,r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},n&&n.sessionDescription&&(r.sessionDescription=n.sessionDescription),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(t=b()(S().mark((function e(t){var n,r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status,options:[]},n&&n.options&&(r.options=n.options),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(e=b()(S().mark((function e(t){var n,r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:return n=e.sent,r={status:n.status},e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,i,o,s,c,d,h,p,f,v}(),He=n(701).A,ze=function(){return u()((function e(t){if(a()(this,e),l()(this,"_logger",M.getLogger("Discovery")),l()(this,"_metricsService",void 0),l()(this,"_uri",void 0),!t)throw new Error("Discovery requires uri");this._metricsService=_e.getMetricsService(t.toString()),this._uri=t}),[{key:"discoverNearbyEndPoints",value:(t=b()(S().mark((function e(t,n){var r,i,o,a;return S().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 r=t.toString(),e.next=5,He.race([fetch(r,{method:"GET",cache:"no-cache"}),new He((function(e,t){return setTimeout((function(){return t(new Error("Discovery timed out [".concat(r,"]")))}),n)}))]);case 5:if((i=e.sent).ok){e.next=8;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 8:if(null!==i.body){e.next=10;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 10:return e.next=12,i.text();case 12:return o=e.sent,a=o.split(","),e.abrupt("return",a.map((function(e){return new Ge(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=b()(S().mark((function e(){var t,n,r,i,o,a,s=this,u=arguments;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=ce.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new URL(n),t);case 4:return r=e.sent,i=0,o=function(){return new He((function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))}))},e.next=9,He.race(r.map((function(e){return e.ping().catch((function(t){return s._logger.warn("Failed to ping end point [%s]",e,t),i++,o()})).then((function(t){var n=Date.now();return s._logger.info("Discovered end point [%s] with time [%s]",e.toString(),t),s._metricsService.push({metricType:ve.RoundTripTime,runtime:(n-Ce.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}(),We=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=b()(S().mark((function t(){var n;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new URL(Ce.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=b()(S().mark((function t(n){var r,i,o;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.toString(),!e._cache[r]){t.next=3;break}return t.abrupt("return",e._cache[r]);case 3:return i=new ze(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then((function(){setTimeout((function(){e._cache[r]===o&&delete e._cache[r]}),6e4)})).catch((function(){delete e._cache[r]})),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()(We,"_cache",{}),We.precacheClosestEndPointDiscovery();var Je=function(e){return e[e.NetworkEmpty=0]="NetworkEmpty",e[e.NetworkIdle=1]="NetworkIdle",e[e.NetworkLoading=2]="NetworkLoading",e[e.NetworkNoSource=3]="NetworkNoSource",e}({});function qe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ke(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qe(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Ze=function(){return u()((function e(t,n,r,i,o){a()(this,e),l()(this,"_logger",M.getLogger("WebPlayer")),l()(this,"_videoElement",void 0),l()(this,"_kind",void 0),l()(this,"_streamId",void 0),l()(this,"_manifestURI",void 0),l()(this,"_options",void 0),l()(this,"_player",void 0),l()(this,"_lastReloadTime",void 0),this._videoElement=t,this._kind=n,this._streamId=r,this._manifestURI=encodeURI(i).replace(/[#]/g,"%23"),this._options=o}),[{key:"start",value:function(){var e=this;if(rt.phenixWebPlayer){var t=Ke(Ke({},this._options),{},{bandwidthToStartAt:3e6});return this._player=new rt.phenixWebPlayer.WebPlayer(this._logger,this._videoElement,t),this._player.start(this._manifestURI),void this._player.addEventListener("error",(function(t){e.canReload()&&t&&(3===t.code||t.severity===rt.phenixWebPlayer.errors.severity.RECOVERABLE)&&(e._logger.warn("Reloading unhealthy stream after error event [%j]",t),e.reloadIfAble()),e._logger.error("Cannot reload with error [%j]",t)}))}}},{key:"isSupported",value:function(){return rt.phenixWebPlayer&&rt.phenixWebPlayer.isSupported}},{key:"getStats",value:function(){var e,t;if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:Je.NetworkNoSource,dataBuffered:0};var n=this._player.getStats(),r=n.currentTime||this._videoElement.currentTime,i=(Date.now()-this._options.originStartTime)/1e3;return null!==(e=this._videoElement.buffered)&&void 0!==e&&e.length&&(n.dataBuffered=this._videoElement.buffered.end(0)),n.isNative&&"Hls"===n.deliveryType&&(n.currentTime=r-n.lag),n.currentTime||(n.currentTime=r),n.isNative||(n.lag=Math.max(0,i-r)),null!==(t=this._videoElement.buffered)&&void 0!==t&&t.length?n.networkState=Je.NetworkLoading:n.currentTime>0?n.networkState=Je.NetworkIdle:n.video?n.networkState=Je.NetworkEmpty:n.networkState=Je.NetworkNoSource,n}},{key:"dispose",value:function(){this._player&&this._player.dispose(),this._player=null}},{key:"canReload",value:function(){var e=!this._lastReloadTime||Date.now()-this._lastReloadTime>15e3;return this._videoElement&&this._player&&0!==this._videoElement.buffered.length&&e}},{key:"reloadIfAble",value:function(){this.canReload()&&(this._logger.warn("[%s] Reloading unhealthy stream that was active for at least [%s] seconds",this._streamId,15),this._lastReloadTime=Date.now(),this.reload())}},{key:"reload",value:function(){this._player.dispose(),this._player=null,this.start()}}])}();function Qe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ye(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qe(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var $e=function(){return u()((function e(t,n,r,i,o){a()(this,e),l()(this,"_logger",M.getLogger("ShakaPlayer")),l()(this,"_videoElement",void 0),l()(this,"_kind",void 0),l()(this,"_streamId",void 0),l()(this,"_manifestURI",void 0),l()(this,"_options",void 0),l()(this,"_monitoredStatistics",void 0),l()(this,"_player",void 0),this._videoElement=t,this._kind=n,this._streamId=r,this._manifestURI=encodeURI(i).replace(/[#]/g,"%23"),this._options=o,this._monitoredStatistics={estimatedBandwidth:0,playTime:0}}),[{key:"start",value:function(){if(rt.shaka)return this._player=new rt.shaka.Player(this._videoElement),void this.loadPlayer({abr:{defaultBandwidthEstimate:2e6},manifest:{retryParameters:{timeout:1e4}},streaming:{liveSyncPanicThreshold:1,bufferingGoal:60,bufferBehind:30,retryParameters:{timeout:1e4,maxAttempts:10,backoffFactor:1.1}}})}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:Je.NetworkNoSource};var e=Ye(Ye({},this._player.getStats()),{},{currentTime:0,lag:0}),t=this._videoElement.currentTime||0,n=(Date.now()-this._options.originStartTime)/1e3,r=Math.max(0,n-t);return this._videoElement&&(e.currentTime=t,e.lag=r,this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0))),e.estimatedBandwidth>0&&this._monitoredStatistics.estimatedBandwidth<e.estimatedBandwidth?e.networkState=Je.NetworkLoading:e.playTime>0&&this._monitoredStatistics.playTime<e.playTime?e.networkState=Je.NetworkIdle:e.video?e.networkState=Je.NetworkEmpty:e.networkState=Je.NetworkNoSource,this._monitoredStatistics.estimatedBandwidth=e.estimatedBandwidth,this._monitoredStatistics.playTime=e.playTime,e}},{key:"dispose",value:function(){this._player&&(this._player.unload(),this._player.destroy()),this._player=null}},{key:"loadPlayer",value:function(e){var t=this;this._player.configure(e),this._player.load(this._manifestURI).then((function(){t._logger.info("[%s] DASH live stream has been loaded",t._streamId),t._videoElement.play&&t._videoElement.play()})).catch((function(e){t._logger.error("[%s] Error while loading DASH live stream [%s]",t._streamId,e.code,e)}))}}])}(),Xe=function(){return u()((function e(t,n,r,i,o){a()(this,e),l()(this,"_videoElement",void 0),l()(this,"_kind",void 0),l()(this,"_streamId",void 0),l()(this,"_manifestURI",void 0),l()(this,"_options",void 0),l()(this,"_player",void 0),this._videoElement=t,this._kind=n,this._streamId=r,this._manifestURI=encodeURI(i).replace(/[#]/g,"%23"),this._options=o}),[{key:"start",value:function(){rt.hlsPlayer&&(rt.hlsPlayer.isSupported()?(this._player=new rt.hlsPlayer({enableWorker:!0,maxBufferLength:1,backBufferLength:0,liveSyncDuration:7,liveDurationInfinity:!0,liveMaxLatencyDuration:1/0,highBufferWatchdogPeriod:1}),this._player.loadSource(this._manifestURI),this._player.attachMedia(this._videoElement)):this._videoElement.canPlayType("application/vnd.apple.mpegurl")&&(this._videoElement.src=this._manifestURI))}},{key:"isSupported",value:function(){return rt.hlsPlayer&&rt.hlsPlayer.isSupported()}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:Je.NetworkNoSource};var e={width:this._player.media.offsetWidth,height:this._player.media.offsetHeight,currentTime:this._player.media.currentTime,lag:0,networkState:Je.NetworkIdle,dataBuffered:0};this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0)),"IDLE"===this._player.streamController.state?e.networkState=Je.NetworkIdle:"ERROR"===this._player.streamController.state||"ENDED"===this._player.streamController.state?e.networkState=Je.NetworkNoSource:this._player.streamController.state.includes("LOADING")||this._player.streamController.state.includes("WAITING")?e.networkState=Je.NetworkLoading:e.networkState=Je.NetworkEmpty;var t=this._videoElement.currentTime||0,n=(Date.now()-this._options.originStartTime)/1e3;return e.lag=Math.max(0,t+this._options.lag/1e3-n),e}},{key:"dispose",value:function(){this._player&&this._player.destroy&&(this._player.destroy(),this._player=null)}}])}(),et=n(701).A;function tt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function nt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?tt(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var rt=function(){return u()((function e(){a()(this,e)}),null,[{key:"hlsPlayer",get:function(){return this._hlsPlayer}},{key:"phenixWebPlayer",get:function(){return this._phenixWebPlayer}},{key:"shaka",get:function(){return this._shaka}},{key:"start",value:(t=b()(S().mark((function e(t,n,r,i){var o=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._options=i,!(this._hlsPlayer||this._shaka||this._phenixWebPlayer)){e.next=3;break}return e.abrupt("return",this.loaded(t,n,r));case 3:if(Ce.webPlayerLoader||Ce.shakaPlayerLoader||Ce.hlsJsLoader){e.next=5;break}throw new Error("Unsupported-feature, add stream player");case 5:return e.abrupt("return",new et((function(e){Ce.hlsJsLoader&&(o._pending=!0,Ce.hlsJsLoader((function(i){o._hlsPlayer=i,o._pending&&(o._pending=!1,e(o.loaded(t,n,r)))}))),Ce.webPlayerLoader&&(o._pending=!0,Ce.webPlayerLoader((function(i){o._phenixWebPlayer=i,o._pending&&(o._pending=!1,e(o.loaded(t,n,r)))}))),Ce.shakaPlayerLoader&&(o._pending=!0,Ce.shakaPlayerLoader((function(i){o._shaka=i,o._pending&&(o._pending=!1,e(o.loaded(t,n,r)))})))})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,n,r,i){return t.apply(this,arguments)})},{key:"getStats",value:function(){return this._player?this._player.getStats():null}},{key:"play",value:(e=b()(S().mark((function e(t,n,r,i,o){var a,s,u,c;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=i.match(/a=x-playlist:([^\n]*[.]mpd\??[^\s]*)/m),s=i.match(/a=x-playlist:([^\n]*[.]m3u8\??[^\s]*)/m),u=a&&a[1]?a[1]:"",!(c=s&&s[1]?s[1]:"")){e.next=9;break}if(this._phenixWebPlayer&&!h.shouldUseNativeHls){e.next=9;break}return this._player=new t(n,"hls",r,c,o),this._player.start(),e.abrupt("return",this._player);case 9:if(!u){e.next=14;break}if(this._hlsPlayer||this._phenixWebPlayer&&h.shouldUseNativeHls){e.next=14;break}return this._player=new t(n,"dash",r,u,o),this._player.start(),e.abrupt("return",this._player);case 14:if(!u&&!c){e.next=16;break}throw new Error("[".concat(r,"] Cannot play [").concat(c?"HLS":"DASH","] stream with included player"));case 16:throw new Error("No stream playlist found");case 17:case"end":return e.stop()}}),e,this)}))),function(t,n,r,i,o){return e.apply(this,arguments)})},{key:"loaded",value:function(e,t,n){if(this._shaka||this._phenixWebPlayer||this._hlsPlayer)return this._hlsPlayer?this.play(Xe,e,t,n,nt(nt({},this._options),{},{preferNative:h.shouldUseNativeHls})):this._phenixWebPlayer?this.play(Ze,e,t,n,nt(nt({},this._options),{},{preferNative:h.shouldUseNativeHls})):this._shaka?this.play($e,e,t,n,nt(nt({},this._options),{},{preferNative:h.shouldUseNativeHls})):void 0}}]);var e,t}();l()(rt,"_pending",!1),l()(rt,"_hlsPlayer",void 0),l()(rt,"_phenixWebPlayer",void 0),l()(rt,"_shaka",void 0),l()(rt,"_options",void 0),l()(rt,"_player",void 0);var it,ot=function(e){return e[e.Live=1]="Live",e[e.OndDemand=2]="OndDemand",e}(ot||{}),at=ot,st=function(){return u()((function e(t,n,r){a()(this,e),l()(this,"_logger",M.getLogger("ChunkedStream")),l()(this,"_channelContext",void 0),l()(this,"_chunkedStreamPlaybackMode",void 0),l()(this,"_monitorDisposables",new ee),l()(this,"_handleStreamFailure",void 0),l()(this,"_streamStatistics",void 0),l()(this,"_monitorFailureCount",0),this._channelContext=t,this._chunkedStreamPlaybackMode=n,this._handleStreamFailure=r,this._channelContext.disposables.add(this)}),[{key:"start",value:function(e,t){var n=this;return We.discoverClosestEndPointWithCaching(e).then((function(e){return n._channelContext.online.value=!0,n._channelContext.endPoint.value=e,n._logger.info("Connecting to [%s]",e.toString()),e.subscribe(t,null,n._channelContext.failureCount.value)})).then((function(e){var t=e.status,r=e.stream,i=e.createOfferDescriptionResponse,o=e.lag;if(n._channelContext.stream.value=r,n._channelContext.lag.value=o,n._channelContext.applySessionAndStreamPropertiesToVideoElement(),n._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",n._channelContext.streamId,t,i),n._channelContext.state.value=n._channelContext.mapSubscribeStatusToChannelStatus(t),n._channelContext.applyStatus(t),"ok"===t){var a=i.sessionDescription.sdp,s={originStartTime:Date.now()-o+n._channelContext.endPoint.value.roundTripTime/2,lag:o};return rt.start(n._channelContext.videoElement.value,n._channelContext.streamId,a,s).then((function(e){return n.monitor(e),e})).catch((function(e){n._logger.error("ChunkedStreaming failed",e),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,n._channelContext.state.value=we.Stopped}))}}))}},{key:"monitor",value:function(e){var t=this;this._monitorDisposables.dispose();var n=window.setTimeout((function(){var n=rt.getStats();if(t._chunkedStreamPlaybackMode!==at.Live||n.networkState!==Je.NetworkNoSource||t._channelContext.videoElement.value.currentTime!==t._channelContext.videoElement.value.duration){if(t._streamStatistics&&!t._channelContext.videoElement.value.paused&&t._streamStatistics.currentTime>=n.currentTime&&(t._streamStatistics.dataBuffered>=n.dataBuffered||!n.dataBuffered)){if(t._monitorFailureCount++,t._monitorFailureCount>4)return t._monitorFailureCount=0,t._channelContext.state.value=we.ConnectionError,t._channelContext.playing.value=!1,t._channelContext.loading.value=!0,e.dispose(),t._monitorDisposables.dispose(),void t._handleStreamFailure().catch((function(e){t._logger.error("Failed handling stream failure",e)}))}else t._monitorFailureCount=0;t._channelContext.videoElement.value.paused&&t._channelContext.state.value===we.Playing&&(t._channelContext.state.value=we.Paused),t._channelContext.videoElement.value.paused||t._channelContext.state.value===we.Playing||(t._channelContext.state.value=we.Playing),t._streamStatistics=n,t.monitor(e)}else t._monitorFailureCount=0,t._channelContext.state.value=we.ConnectionError,t._channelContext.playing.value=!1,t._channelContext.loading.value=!0,e.dispose(),t._monitorDisposables.dispose(),t._handleStreamFailure().catch((function(e){t._logger.error("Failed handling end of stream",e)}))}),1e3);this._monitorDisposables.add(new z((function(){clearTimeout(n)})))}},{key:"dispose",value:function(){this._monitorDisposables.dispose()}}])}(),ut=n(715),ct=n.n(ut),lt=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)/),r=this._sdp.split(/(?:^|[\r\n])m=/);this._audioCodec=this.applyCodec("audio",n),this._videoCodec=this.applyCodec("video",n),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",r),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",r)}),[{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]}}])}(),dt=function(){return u()((function e(t,n,r){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=r,this._tracksToMonitor=n.getTracks().map((function(e){return e.kind}))||[],this._peerConnection){if(!h.getCurrentOfferDisabled){var i=new lt(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=i.audioCodec,this._estimatedVideoCodec=i.videoCodec}this.updateStatistic()}}),[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(t=b()(S().mark((function e(){var t,n=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!h.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 r={};if(e){var i,o=n._estimatedRoundTripTime;e.forEach((function(a){if("candidate-pair"===a.type&&a.currentRoundTripTime&&(o=1e3*a.currentRoundTripTime,r.audio&&(r.audio.roundTripTime=o),r.video&&(r.video.roundTripTime=o)),"candidate-pair"===a.type&&a.lastPacketReceivedTimestamp&&(i=a.lastPacketReceivedTimestamp,r.audio&&(r.audio.lastPacketReceivedTimestamp=i),r.video&&(r.video.lastPacketReceivedTimestamp=i)),"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),v=a.timestamp-(null===(h=n._rtcStatistic.value)||void 0===h||null===(p=h[s])||void 0===p?void 0:p.timestamp),m=f&&v?Math.floor(8*f/v*1e3):0;if(r[s]={ssrc:a.ssrc,mediaType:s,timestamp:a.timestamp,bitrate:m,bytesReceived:a.bytesReceived,packetsLost:a.packetsLost,packetsReceived:a.packetsReceived,codec:u||n.getCodecByType(s),roundTripTime:o},(a.lastPacketReceivedTimestamp||i)&&(r[s].lastPacketReceivedTimestamp=a.lastPacketReceivedTimestamp||i),"video"===s&&n._rtcStatistic.value&&n._rtcStatistic.value.video){r[s].framesDecoded=a.framesDecoded;var g=(a.framesDecoded-n._rtcStatistic.value.video.framesDecoded)/(r[s].timestamp-n._rtcStatistic.value.video.timestamp)*1e3;r[s].fps=g?Math.round(100*g)/100:0}}}}))}n._rtcStatistic.value=r})).then((function(){n._isMonitorRunning&&(n._updateTimeout=window.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=b()(S().mark((function e(){var t=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.getStatsLegacy().then((function(e){var n={},r=t._estimatedRoundTripTime;e.result().forEach((function(e){if(e.names().forEach((function(t){"googRTT"===t&&(r=e.stat(t))})),"ssrc"===e.type){var i=e.stat("mediaType").toString();n[i]={timestamp:Date.now()},n[i].ssrc=e.stat("ssrc").toString(),n[i].mediaType=i,n[i].bytesReceived=e.stat("bytesReceived"),n[i].packetsLost=e.stat("packetsLost"),n[i].packetsReceived=e.stat("packetsReceived"),n[i].codec=e.stat("googCodecName").toString()||t.getCodecByType(i),n[i].roundTripTime=r,"video"===i&&t._rtcStatistic.value&&t._rtcStatistic.value.video&&(n[i].framesDecoded=e.stat("framesDecoded"),n[i].fps=(n[i].framesDecoded-t._rtcStatistic.value.video.framesDecoded)/(n[i].timestamp-t._rtcStatistic.value.video.timestamp)*1e3||0)}})),t._rtcStatistic.value=n})).then((function(){t._isMonitorRunning&&(t._updateTimeout=window.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}(),ht=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 r=[],i=0;i<2;i++)e.iceServers[n].urls[i]&&r.push(e.iceServers[n].urls[i]);t.push({urls:r,username:e.iceServers[n].username,credential:e.iceServers[n].credential})}return e.iceServers=t,e}}])}(),pt=Symbol(),ft=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)?pt: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,r=e.getSurrogate82x82PFrameAndUpdateFrameNumber();return n>e._surrogate82x82PFrameFrameNumberReset?e._isAndroidChrome?pt:e._singleZeroByte.buffer:(e._surrogate82x82PFrameFrameNumber++,r)}return e._singleZeroByte.buffer}},{key:"getSurrogate82x82PFrameAndUpdateFrameNumber",value:function(){var t=(14&e._surrogate82x82PFrameFrameNumber)>>1,n=(1&e._surrogate82x82PFrameFrameNumber)<<7,r=e._dummy82x82H264.PFrame.slice().buffer,i=e._dummy82x82H264PFrameFrameNumberIndex;return r[i]|=t,r[i+1]|=n,e._surrogate82x82PFrameFrameNumber++,r}}])}();it=ft,l()(ft,"_isSafari","Safari"===d.browserName),l()(ft,"_isMobileChrome","Chrome"===d.browserName&&d.isMobile()),l()(ft,"_isAndroidChrome","Chrome"===d.browserName&&d.isAndroid),l()(ft,"_singleZeroByte",new Uint8Array([0])),l()(ft,"_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()(ft,"_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()(ft,"_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()(ft,"_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(he()(new Uint8Array(40).fill(255)),[95],he()(new Uint8Array(10295).fill(255)),[128,0,0,0,1,101,136,132,5],he()(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(he()(new Uint8Array(40).fill(255)),[164],he()(new Uint8Array(10364).fill(255)),[128,0,0,0,1,65,154,32,21,240,75]))}),l()(ft,"_dummy82x82H264PFrameFrameNumberIndex",10418),l()(ft,"_surrogate82x82PFrameFrameNumberReset",1),l()(ft,"_useUpdateSurrogate82x82PFrameFrameNumber",it._isMobileChrome||it._isSafari),l()(ft,"_surrogate82x82PFrameFrameNumber",it._surrogate82x82PFrameFrameNumberReset);var vt=function(){return u()((function e(){throw a()(this,e),new Error("InsertableStreams is a static class that may not be instantiated")}),null,[{key:"applyEncodedStreamTransformation",value:function(e,t,r,i,o,a){var s=new ee;return e.getTracks().forEach((function(e){var u=t.filter((function(t){return t.track===e}))[0],c=e.kind;switch(c){case"video":if(r){if(h.isRTCRtpScriptTransformSupported){var l=new Worker(new URL(n.p+n.u(63),n.b),{type:void 0});l.onmessage=function(){var t=b()(S().mark((function t(n){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r(e,n.data.chunk);case 2:if(t.sent){t.next=4;break}l.postMessage({forceInvalidFrame:!0});case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),u.transform=new RTCRtpScriptTransform(l,{kind:e.kind,codec:o}),s.add(new z((function(){l.terminate()})));break}var d=function(){var t=b()(S().mark((function t(n,i){var a;return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r(e,n);case 2:if(t.sent){t.next=9;break}if((a="key"===n.type?ft.getInvalidSurrogateVideoIFrame(o):ft.getInvalidSurrogateVideoPFrame(o))!==pt){t.next=6;break}return t.abrupt("return");case 6:n.data=a||n.data,t.next=10;break;case 9:"key"===n.type?n.data=ft.getSurrogateVideoIFramePerCodec(o)||n.data:n.data=ft.getSurrogateVideoPFramePerCodec(o)||n.data;case 10:i.enqueue(n);case 11:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),p=new TransformStream({transform:d}),f=u.createEncodedStreams(),v=f.readable,m=f.writable;v.pipeThrough(p).pipeTo(m)}break;case"audio":if(i){if(h.isRTCRtpScriptTransformSupported){var g=new Worker(new URL(n.p+n.u(444),n.b),{type:void 0});g.onmessage=function(){var t=b()(S().mark((function t(n){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i(e,n.data.chunk);case 2:if(t.sent){t.next=4;break}g.postMessage({forceInvalidFrame:!0});case 4:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),u.transform=new RTCRtpScriptTransform(g,{kind:e.kind,codec:a});var _=new MediaStream,y=new Audio;y.srcObject=_,document.body.appendChild(y),s.add(new z((function(){g.terminate(),document.body.removeChild(y)})));break}var C=function(){var t=b()(S().mark((function t(n,r){return S().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i(e,n);case 2:if(t.sent){t.next=6;break}n.data=ft.getInvalidSurrogateAudioData(),t.next=7;break;case 6:n.data=ft.getSurrogateAudioSilentPerCodec(a)||n.data;case 7:r.enqueue(n);case 8:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),k=new TransformStream({transform:C}),w=u.createEncodedStreams(),x=w.readable,T=w.writable;x.pipeThrough(k).pipeTo(T)}break;default:O(c)}})),{disposables:s}}},{key:"applyInsertableStreamTransformation",value:function(e,t,n){var r=new MediaStream,i=new ee;return e.getTracks().forEach((function(e){var o=e.kind;switch(o){case"video":if(t){var a=e,s=new TransformStream({transform:function(n,r){t(e,n,r)}}),u=new MediaStreamTrackProcessor({track:a}),c=new MediaStreamTrackGenerator({kind:a.kind}),l=u.readable,d=c.writable;l.pipeThrough(s).pipeTo(d),r.addTrack(c),i.add(new z((function(){r.removeTrack(c)})))}else r.addTrack(e);break;case"audio":if(n){var h=e,p=new TransformStream({transform:function(t,r){n(e,t,r)}}),f=new MediaStreamTrackProcessor({track:h}),v=new MediaStreamTrackGenerator({kind:h.kind}),m=f.readable,g=v.writable;m.pipeThrough(p).pipeTo(g),r.addTrack(v);var _=new MediaStream,y=new Audio;_.addTrack(e),y.srcObject=_,document.body.appendChild(y),i.add(new z((function(){r.removeTrack(v),document.body.removeChild(y)})))}else r.addTrack(e);break;default:O(o)}})),{transformedStream:r,disposables:i}}}])}(),mt=n(701).A;function gt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _t(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?gt(Object(n),!0).forEach((function(t){l()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var yt=function(){return u()((function e(t,n,r,i){a()(this,e),l()(this,"_logger",M.getLogger("RealTimeStream")),l()(this,"_channelContext",void 0),l()(this,"_peerConnectionContext",void 0),l()(this,"_streamTransformContext",void 0),l()(this,"_handleStreamFailure",void 0),l()(this,"_disposables",void 0),this._channelContext=t,this._peerConnectionContext=n,this._streamTransformContext=r,this._handleStreamFailure=i,this._disposables=new ee,this._channelContext.disposables.add(this)}),[{key:"start",value:function(e,t,n,r){var i=this,o="function"==typeof this._streamTransformContext.encodedVideoStreamSink||"function"==typeof this._streamTransformContext.encodedAudioStreamSink;return mt.all([We.discoverClosestEndPointWithCaching(e),oe.createPeerConnectionOffer("recvonly",o).then((function(e){var t=e.localOffer,n=e.peerConnection;return i._peerConnectionContext.peerConnection.value=n,{localOffer:t,peerConnection:n}}))]).then((function(e){var n=ct()(e,2),r=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;return i._channelContext.online.value=!0,i._channelContext.endPoint.value=r,i._logger.info("Connecting to [%s]",r.toString()),i._logger.info("Local offer:\n"+a.sdp),!h.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration||(s.close(),s.dispose(),!Ce.forceGarbageCollectionOnRestart||h.isMobile&&Ce.skipGarbageCollectionOnMobileDevices||ke.forceGarbageCollection(),s=null,a=null,i._peerConnectionContext.peerConnection.value=s),r.subscribe(t,a,i._channelContext.failureCount.value)})).then((function(e){var t=e.status,o=e.stream,a=e.rtcConfiguration,s=e.setRemoteDescriptionResponse,u=e.createOfferDescriptionResponse,c=e.createAnswerDescriptionResponse,l=e.lag;if(i._channelContext.stream.value=o,i._channelContext.lag.value=l,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),i._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",i._channelContext.streamId,t,a,s,u,c),i._channelContext.state.value=i._channelContext.mapSubscribeStatusToChannelStatus(t),i._channelContext.applyStatus(t),"ok"===t)return i.applyRtcConfiguration(i._peerConnectionContext.peerConnection.value,a).then((function(e){var t,a=!1,l=!1,d=[];i._peerConnectionContext.peerConnection.value||(i._peerConnectionContext.peerConnection.value=e),e.onicecandidate=function(n){i._channelContext.stream.value===o&&i._peerConnectionContext.peerConnection.value===e&&(a||Ce.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?d.push(n.candidate):l=!0,t||(t=setTimeout((function(){i._channelContext.stream.value!==o||a||i._channelContext.endPoint.value.addIceCandidates(o,d,l).then((function(e){var t=e.status,n=e.options;"ok"===t?(n.includes("cancel")&&(a=!0),i._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",i._channelContext.streamId,t,n)):i._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",i._channelContext.streamId,t)})).catch((function(e){i._logger.error("[%s] Failed to add ICE candidates",i._channelContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(i._channelContext.stream.value===o&&i._peerConnectionContext.peerConnection.value===e){var t=function(){i._channelContext.state.value=we.ConnectionError,i._channelContext.videoElement.value&&(i._channelContext.videoElement.value.pause(),i._channelContext.videoElement.value.srcObject=null),i._channelContext.playing.value=!1,i._channelContext.loading.value=!0,i._handleStreamFailure().catch((function(t){i._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)}))};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return void(navigator.onLine&&(i._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",i._channelContext.streamId,e.iceConnectionState),i.reconnectPeerConnection(e,t)));case"closed":return i._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",i._channelContext.streamId,e.iceConnectionState),void t();default:O(e.iceConnectionState)}}};var p=new mt((function(t,n){if(h.onTrackDisabled){var r=function(n){clearTimeout(i),e.removeEventListener("track",r),e.removeEventListener("addstream",r),n.streams?t(n.streams[0]):t(n.stream)},i=setTimeout((function(){e.removeEventListener("track",r),e.removeEventListener("addstream",r),n(new Error("Stream setup timed out"))}),3e4);e.addEventListener("track",r),e.addEventListener("addstream",r)}else{var o=setTimeout((function(){return n(new Error("Stream setup timed out"))}),3e4);e.ontrack=function(e){clearTimeout(o),t(e.streams[0])}}}));return new mt((function(e){e()})).then((function(){if(s)return i._logger.info("[%s] Set local SDP offer [%s]",i._channelContext.streamId,s.sessionDescription.sdp),e.setLocalDescription(s.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,s.sessionDescription,e.message),e}))})).then((function(){if(c)return i._logger.info("[%s] Set remote SDP answer [%s]",i._channelContext.streamId,c.sessionDescription.sdp),e.setRemoteDescription(c.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,c.sessionDescription,e.message),e}))})).then((function(){if(u)return i._logger.info("[%s] Set remote SDP offer [%s]",i._channelContext.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._channelContext.streamId,u.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})})).then((function(e){return i._logger.info("[%s] Set local SDP answer [%j]",i._channelContext.streamId,e),i._channelContext.endPoint.value.setRemoteDescription(o,e)})).then((function(t){var n=t.status,r=t.sessionDescription;return i._channelContext.state.value=i.mapSetRemoteDescriptionStatusToChannelStatus(n),"ok"!==n?(i._channelContext.playing.value=!1,i._channelContext.standby.value=!0,void(i._channelContext.stopped.value=!1)):e.setLocalDescription(r).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,r,e.message),e}))}))})).then((function(){return n.success(i._channelContext.streamId),p})).then((function(t){if(i._streamTransformContext.hasEncodedInsertableStreams.value){var n=new lt(e.currentRemoteDescription.sdp),o=vt.applyEncodedStreamTransformation(t,e.getReceivers(),i._streamTransformContext.encodedVideoStreamSink,i._streamTransformContext.encodedAudioStreamSink,n.videoCodec,n.audioCodec).disposables;i._disposables.add(o)}if(i._streamTransformContext.hasInsertableStreams.value){var a=vt.applyInsertableStreamTransformation(t,i._streamTransformContext.videoStreamTransformCallback,i._streamTransformContext.audioStreamTransformCallback),s=a.transformedStream,u=a.disposables;i._disposables.add(u),t=s}i._peerConnectionContext.mediaStream.value=t;var c=new dt(e,t,i._channelContext.endPoint.value.roundTripTime/4);i._disposables.add(c);var l=c.rtcStatistic.subscribe((function(t){if(i._channelContext.rtcStatistics.value=t,!i._channelContext.rtcVideoStatistic&&!i._channelContext.rtcAudioStatistic)return i._channelContext.rtcAudioStatistic=t.audio,void(i._channelContext.rtcVideoStatistic=t.video);var n=!1,r=!1;if(t.audio&&i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.timestamp!==t.audio.timestamp&&((n=i._channelContext.rtcAudioStatistic&&i._channelContext.rtcAudioStatistic.bytesReceived===t.audio.bytesReceived)&&navigator.onLine&&i._logger.info("[%s] Audio track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.audio.bytesReceived,i._channelContext.rtcAudioStatistic.bytesReceived,new xe(t.audio.timestamp-i._channelContext.rtcAudioStatistic.timestamp).toIsoString()),i._channelContext.rtcAudioStatistic=t.audio),t.video&&i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.timestamp!==t.video.timestamp&&((r=i._channelContext.rtcVideoStatistic&&i._channelContext.rtcVideoStatistic.bytesReceived===t.video.bytesReceived)&&navigator.onLine&&i._logger.info("[%s] Video track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.video.bytesReceived,i._channelContext.rtcVideoStatistic.bytesReceived,new xe(t.video.timestamp-i._channelContext.rtcVideoStatistic.timestamp).toIsoString()),i._channelContext.rtcVideoStatistic=t.video),(r||n)&&navigator.onLine)i.reconnectPeerConnection(e,(function(){i._channelContext.state.value=we.ConnectionError,i._channelContext.videoElement.value&&(i._channelContext.videoElement.value.pause(),i._channelContext.videoElement.value.srcObject=null),i._channelContext.playing.value=!1,i._channelContext.loading.value=!0,c.dispose(),i._handleStreamFailure().catch((function(t){i._logger.error("[%s] Failed handling stream failure after track stopped with state [%s]",i._channelContext.streamId,e.iceConnectionState,t)}))}));else{if(i._peerConnectionContext.peerConnectionReconnectAttempts=0,i._channelContext.state.value!==we.Reconnecting)return;i._channelContext.state.value=i._channelContext.playing.value?we.Playing:we.Paused,i._logger.info("Channel state restored to [%s] after reconnecting",we[i._channelContext.state.value])}}));return i._disposables.add(l),Ce.automaticallyPlayMediaStream?r(t):(i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,void(i._channelContext.state.value=we.Paused))}))}))}))}},{key:"applyRtcConfiguration",value:(e=b()(S().mark((function e(t,n){var r;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=ht.truncateIceServers(n),e.abrupt("return",Ce.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=_t(_t({},t.getConfiguration()),n),t.setConfiguration(r),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=we.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Ce.maximalNumberOfPeerConnectionReconnectAttempts||!Ce.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(h.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!i)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 we.Starting;case"unauthorized":return we.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return we.Recovering;case"failed":return we.Error;default:O(e)}}}]);var e}(),Ct=function(){return u()((function e(){throw a()(this,e),new Error("StreamFactory is a static class that may not be instantiated")}),null,[{key:"create",value:function(e,t,n,r,i){var o=Y.parseToken(e).capabilities,a=o.includes("streaming"),s=o.includes("on-demand");return a||s?new st(t,s?at.OndDemand:at.Live,i):new yt(t,n,r,i)}}])}();l()(Ct,"_logger",M.getLogger("Streaming"));var bt=n(701).A,kt=function(){return u()((function e(t,n,r){var i=this;a()(this,e),l()(this,"_logger",M.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,"_exponentialBackoff",void 0),l()(this,"_channelStartTime",void 0),l()(this,"_readOnlyVideoElement",void 0),l()(this,"_readOnlyToken",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,"_metricsService",void 0),l()(this,"_sessionTelemetry",void 0),l()(this,"_videoMetaDataChangedHandler",void 0);var o=Y.parseToken(n),s={targetLag:null==r?void 0:r.targetLag},u={hasInsertableStreams:o.capabilities.includes("insertable-streams"),hasEncodedInsertableStreams:o.capabilities.includes("encoded-insertable-streams"),videoStreamTransformCallback:null==r?void 0:r.videoStreamTransformCallback,audioStreamTransformCallback:null==r?void 0:r.audioStreamTransformCallback,encodedVideoStreamSink:null==r?void 0:r.encodedVideoStreamSink,encodedAudioStreamSink:null==r?void 0:r.encodedAudioStreamSink};this._tokenContext=new Oe(n),this._channelContext=new De(s),this._peerConnectionContext=new Ne,this._streamTransformContext=new Me(u),this._stateContext=new Ve,this._exponentialBackoff=new pe,this._channelStartTime=Date.now(),this._readOnlyVideoElement=new Z(this._channelContext.videoElement),this._readOnlyToken=new Z(this._tokenContext.token),this._readOnlyPeerConnection=new Z(this._peerConnectionContext.peerConnection),this._readOnlyState=new Z(this._channelContext.state),this._readOnlyAutoMuted=new Z(this._channelContext.autoMuted),this._readOnlyAutoPaused=new Z(this._channelContext.autoPaused),this._readOnlyTokenExpiring=new Z(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new Z(this._channelContext.authorized),this._readOnlyOnline=new Z(this._channelContext.online),this._readOnlyLoading=new Z(this._channelContext.loading),this._readOnlyPlaying=new Z(this._channelContext.playing),this._readOnlyStandby=new Z(this._channelContext.standby),this._readOnlyStopped=new Z(this._channelContext.stopped),this._readOnlyTargetLag=new Z(this._channelContext.targetLag),this._readOnlyLag=new Z(this._channelContext.lag),this._readOnlyBitrateLimit=new Z(this._channelContext.bitrateLimit),this._readOnlyResolution=new Z(this._channelContext.resolution),this._readOnlyFailureCount=new Z(this._channelContext.failureCount),this._readOnlyEndPoint=new Z(this._channelContext.endPoint),this._readOnlyStream=new Z(this._channelContext.stream),this._readOnlyRtcStatistics=new Z(this._channelContext.rtcStatistics),this._readOnlyMediaStream=new Z(this._peerConnectionContext.mediaStream);var c=(o.uri||Ce.discoveryUri.value).toString();Ce.tenancy.value=o.tenancy||Ce.tenancy.value,ce.uri.value=c,this._metricsService=_e.getMetricsService(c),this._sessionTelemetry=new Ee(Ce.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=t,this._channelContext.channelDisposables.add(this._channelContext.videoElement.subscribe((function(e){i._channelContext.rendererDisposables.dispose(),e&&(i._channelContext.rendererDisposables.add(i._channelContext.stream.subscribe((function(e){i._channelContext.videoTelemetry&&i._channelContext.videoTelemetry.dispose(),e&&i.videoElement&&(i.videoElement.dataset&&(i.videoElement.dataset.sessionId=Ce.clientSessionId,i.videoElement.dataset.streamId=i.streamId),i._channelContext.videoTelemetry=new Te(i.streamId,Ce.pageLoadTime,i._channelStartTime,i._metricsService),i._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(i.videoElement),i._channelContext.videoTelemetry.setupListenerForRebuffering(i.videoElement),i._channelContext.state.value===we.Stopped)&&i.restartAfterStop()}))),i._channelContext.channelDisposables.add(i._channelContext.rendererDisposables))}))),this._channelContext.channelDisposables.add(this._channelContext.state.subscribe((function(e){i._channelContext.clearFailureCountTimeout&&clearTimeout(i._channelContext.clearFailureCountTimeout),i._channelContext.failureCount.value&&e===we.Playing&&(i._channelContext.clearFailureCountTimeout=window.setTimeout((function(){i._channelContext.failureCount.value=0}),3e3))}))),this._channelContext.channelDisposables.add(this._channelContext.resolution.subscribe((function(e){i._channelContext.videoTelemetry&&i._channelContext.videoTelemetry.onVideoResolutionChanges(e.toString())}))),this._channelContext.channelDisposables.add(this._channelContext.bitrateLimit.subscribe((function(e){if(e&&i._channelContext.endPoint.value&&i._channelContext.stream.value){var t=Date.now()-i._channelContext.channelInitialization.getTime();i._channelContext.endPoint.value.limitBitrate(i._channelContext.stream.value,t,e,Re.Keep,Fe.Normal).catch((function(e){i._logger.error("Error while setting limit bitrate",e)}))}})));var d=function(){i._channelContext.stream.value&&i._channelContext.endPoint.value&&i._channelContext.endPoint.value.destroyStreamOnUnmount(i._channelContext.stream.value,"client:termination-on-window-unload")};window.addEventListener("beforeunload",d),this._channelContext.channelDisposables.add(new z((function(){window.removeEventListener("beforeunload",d)}))),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=we.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=Y.parseToken(this._tokenContext.token.value),n=(t.uri||Ce.discoveryUri.value).toString();Ce.tenancy.value=t.tenancy||Ce.tenancy.value,ce.uri.value=n,this._metricsService=_e.getMetricsService(n),this._streamTransformContext.hasInsertableStreams.value=t.capabilities.includes("insertable-streams"),this._streamTransformContext.hasEncodedInsertableStreams.value=t.capabilities.includes("encoded-insertable-streams"),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:"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,Re.Keep,Fe.Reset).then((function(t){"ok"===t.status&&(e._channelContext.bitrateLimit.value=0)})).catch((function(t){e._logger.error("Error while setting limit bitrate",t)}))}}},{key:"updateTargetLag",value:function(e){this._channelContext.targetLag.value=e}},{key:"stop",value:(d=b()(S().mark((function e(t){var n=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new bt((function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._channelContext.rendererDisposables.add(n._stateContext.isStarting.subscribe((function(r){r||(n.processStop(t),e())})))})));case 1:case"end":return e.stop()}}),e)}))),function(e){return d.apply(this,arguments)})},{key:"processStop",value:function(e){this._channelContext.videoElement.value&&(this._channelContext.videoElement.value.pause(),this._channelContext.videoElement.value.srcObject=null),this._channelContext.rendererDisposables.dispose(),this.cleanUpResources(e),this._channelContext.state.value=we.Stopped}},{key:"resume",value:(c=b()(S().mark((function e(){return S().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=b()(S().mark((function e(){var t=this;return S().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 Y.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",Ce.discoveryUri.value),new URL(Ce.discoveryUri.value))}},{key:"start",value:(o=b()(S().mark((function e(){return S().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:(i=b()(S().mark((function e(){var t,n,r,i,o,a,s,u,c,l,d,p,f,v,m,g,_,y,C,b=this;return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),Y.isEncodedEdgeTokenValid(t)){e.next=8;break}return this._logger.error("Failed to parse token [%s]",t),this._channelContext.state.value=we.Unauthorized,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 8:if(!this._streamTransformContext.videoStreamTransformCallback){e.next=16;break}if(r=Ae.validateMediaStreamTrackTransform("video",this._streamTransformContext.videoStreamTransformCallback),i=r.valid,o=r.validationResult,i){e.next=16;break}return this._logger.error(o),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 16:if(!this._streamTransformContext.audioStreamTransformCallback){e.next=24;break}if(a=Ae.validateMediaStreamTrackTransform("audio",this._streamTransformContext.audioStreamTransformCallback),s=a.valid,u=a.validationResult,s){e.next=24;break}return this._logger.error(u),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 24:if(!this._streamTransformContext.encodedVideoStreamSink){e.next=32;break}if(c=Ie.validateEncodedStreamSink("video",this._streamTransformContext.encodedVideoStreamSink),l=c.valid,d=c.validationResult,l){e.next=32;break}return this._logger.error(d),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 32:if(!this._streamTransformContext.encodedAudioStreamSink){e.next=40;break}if(p=Ie.validateEncodedStreamSink("audio",this._streamTransformContext.encodedAudioStreamSink),f=p.valid,v=p.validationResult,f){e.next=40;break}return this._logger.error(v),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 40:if(!this._streamTransformContext.hasInsertableStreams.value||!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=46;break}return this._logger.error("Both insertable-streams and encoded-insertable-streams are enabled, only use one or the other"),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 46:if(m="function"==typeof this._streamTransformContext.videoStreamTransformCallback||"function"==typeof this._streamTransformContext.audioStreamTransformCallback,g="function"==typeof this._streamTransformContext.encodedVideoStreamSink||"function"==typeof this._streamTransformContext.encodedAudioStreamSink,!m||!g){e.next=54;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=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 54:if(!this._streamTransformContext.hasInsertableStreams.value){e.next=69;break}if(h.isInsertableStreamsSupported){e.next=61;break}return this._logger.error("Browser does not support Media Stream Track API"),this._channelContext.state.value=we.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 61:if(m){e.next=67;break}return this._logger.error("CreateChannelOptions transform callback function is missing; however, insertable-streams is enabled"),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 67:e.next=75;break;case 69:if(!m){e.next=75;break}return this._logger.error("CreateChannelOptions transform callback function found; however, insertable-streams is not enabled"),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 75:if(!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=90;break}if(h.isEncodedInsertableStreamsSupported||h.isRTCRtpScriptTransformSupported){e.next=82;break}return this._logger.error("Browser does not support encodedInsertableStreams API"),this._channelContext.state.value=we.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 82:if(g){e.next=88;break}return this._logger.error("CreateChannelOptions transform sink function is missing; however, encoded-insertable-streams is enabled"),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 88:e.next=96;break;case 90:if(!g){e.next=96;break}return this._logger.error("CreateChannelOptions transform sink function found; however, encoded-insertable-streams is not enabled"),this._channelContext.state.value=we.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 96:if(this.cleanUpResources("client:start"),this._channelContext.state.value=we.Starting,this._channelContext.loading.value=!0,_=this.getUri(t),this._channelContext.disposables.add(this._channelContext.state.subscribe((function(e){e!==we.Error&&e!==we.Recovering||We.clearCachedClosestEndpoint(_)}))),y=function(){return new bt((function(e){return b._stateContext.isStarting.value=!1,e(b.handleStreamFailure())}))},C=Ct.create(t,this._channelContext,this._peerConnectionContext,this._streamTransformContext,y)){e.next=106;break}return this._stateContext.isStarting.value=!1,e.abrupt("return");case 106:return e.abrupt("return",C.start(_,t,n,this.playMediaStreamInVideoElement.bind(this)).then((function(){b._channelContext.loading.value=!1})).catch((function(e){n.fail(),b._channelContext.failureCount.value++,b._channelContext.online.value=!1,b.cleanUpResources("client:cleanup-after-failed-setup"),b._channelContext.state.value=we.ClientStartError,b._logger.error("Failed to start channel",e)})).finally((function(){if(b._stateContext.isStarting.value=!1,b._channelContext.state.value!==we.Playing&&Ce.automaticRetryOnFailure){var e=setTimeout((function(){b.handleStreamFailure().catch((function(e){b._logger.error("Failed handling stream failure",e)}))}),b.getRetryInterval());b._channelContext.disposables.add(new z((function(){clearTimeout(e)})))}})));case 107:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"restartAfterStop",value:(r=b()(S().mark((function e(){return S().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 r.apply(this,arguments)})},{key:"play",value:(n=b()(S().mark((function e(){var t;return S().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 we.StandBy:case we.Offline:return 15e3;case we.Error:case we.Recovering:case we.Unauthorized:case we.GeoRestricted:case we.GeoBlocked:case we.Stopped:case we.Starting:case we.Playing:case we.Paused:case we.Reconnecting:case we.UnsupportedFeature:case we.ConfigurationError:case we.TransientConfigurationError:case we.ConnectionError:case we.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._channelContext.failureCount.value);default:O(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(t=b()(S().mark((function e(){return S().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._channelContext.state.value,e.next=e.t0===we.Error||e.t0===we.Reconnecting||e.t0===we.StandBy||e.t0===we.Offline||e.t0===we.Recovering||e.t0===we.TransientConfigurationError||e.t0===we.ConnectionError||e.t0===we.ClientStartError?3:e.t0===we.Unauthorized?5:e.t0===we.GeoRestricted?7:e.t0===we.GeoBlocked?9:e.t0===we.Stopped?11:e.t0===we.Playing?13:e.t0===we.Paused?15:e.t0===we.Starting?17:e.t0===we.UnsupportedFeature?19:e.t0===we.ConfigurationError?21:23;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,we[this._channelContext.state.value]),e.abrupt("break",24);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 playing, skipping retry of start"),e.abrupt("return");case 15:return this._logger.info("Channel is paused, skipping retry of start. Please invoke play()"),e.abrupt("return");case 17:return this._logger.info("Channel is already starting, skipping retry of start"),e.abrupt("return");case 19:return this._logger.info("Channel is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 21:return this._logger.info("Channel is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 23:O(this._channelContext.state.value);case 24:return e.abrupt("return",this.start());case 25: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(),!Ce.forceGarbageCollectionOnRestart||h.isMobile&&Ce.skipGarbageCollectionOnMobileDevices||ke.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:"playMediaStreamInVideoElement",value:(e=b()(S().mark((function e(t){var n,r,i=this;return S().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=we.Stopped,e.abrupt("return");case 8:if(this._streamTransformContext.hasEncodedInsertableStreams.value||(n.srcObject=t),void 0!==(r=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=we.Playing,e.abrupt("return");case 17:return e.abrupt("return",r.then((function(){i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!1,i._channelContext.loading.value=!1,i._channelContext.playing.value=!0,i._channelContext.state.value=we.Playing})).catch((function(e){var r=!!t.getTracks().filter((function(e){return"audio"===e.kind})).length,o=!Ce.automaticallyMuteVideoOnPlayFailure;return o||n.muted||!r?(n.srcObject=null,i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=we.Paused,o?void i._logger.info("[%s] Paused video after play failed. Manual user action required.",i.streamId,e):r?void i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e):void i._logger.info("[%s] Failed to play muted video. Manual user action required.",i.streamId,e)):(n.muted=!0,n.play().then((function(){i._logger.info("[%s] Played video after auto muting. Manual user action required to unmute.",i.streamId),i._channelContext.autoMuted.value=!0,i._channelContext.autoPaused.value=!1,i._channelContext.loading.value=!1,i._channelContext.playing.value=!0,i._channelContext.state.value=we.Playing})).catch((function(e){n.muted=!1,i._logger.info("[%s] Failed to play video. Manual user action required.",i.streamId,e),n.srcObject=null,i._channelContext.autoMuted.value=!1,i._channelContext.autoPaused.value=!0,i._channelContext.loading.value=!1,i._channelContext.playing.value=!1,i._channelContext.state.value=we.Paused})))})));case 18:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})}]);var e,t,n,r,i,o,s,c,d}(),St=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(!Ce.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 kt(e.videoElement,e.token,t)}}])}(),wt={SDK:Ce,Channels:St,ChannelState:we}})(),r})()));
|
|
3
3
|
//# sourceMappingURL=channels.js.map
|