@phenixrts/sdk 2025.0.2-beta.405 → 2025.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/channels/debug/channels.js +1282 -1250
  2. package/channels/debug/package.json +1 -1
  3. package/channels/debug.private/channels.js +1195 -1163
  4. package/channels/debug.private/package.json +1 -1
  5. package/channels/debug.provideGlobalScope/channels.js +1252 -1222
  6. package/channels/debug.provideGlobalScope/package.json +1 -1
  7. package/channels/es5.debug.private/channels.js +55 -25
  8. package/channels/es5.debug.private/package.json +1 -1
  9. package/channels/min/channels.js +1 -1
  10. package/channels/min/channels.js.map +1 -1
  11. package/channels/min/package.json +1 -1
  12. package/channels/min.private/channels.js +1 -1
  13. package/channels/min.private/channels.js.map +1 -1
  14. package/channels/min.private/package.json +1 -1
  15. package/channels/min.provideGlobalScope/channels.js +1 -1
  16. package/channels/min.provideGlobalScope/channels.js.map +1 -1
  17. package/channels/min.provideGlobalScope/package.json +1 -1
  18. package/channels/package.json +1 -1
  19. package/full/debug/full.js +1403 -1371
  20. package/full/debug/package.json +1 -1
  21. package/full/debug.private/full.js +1316 -1284
  22. package/full/debug.private/package.json +1 -1
  23. package/full/min/full.js +1 -1
  24. package/full/min/full.js.map +1 -1
  25. package/full/min/package.json +1 -1
  26. package/full/min.private/full.js +1 -1
  27. package/full/min.private/full.js.map +1 -1
  28. package/full/min.private/package.json +1 -1
  29. package/full/package.json +1 -1
  30. package/package.json +1 -1
  31. package/publish/debug/package.json +1 -1
  32. package/publish/debug/publish.js +871 -839
  33. package/publish/debug.private/package.json +1 -1
  34. package/publish/debug.private/publish.js +871 -839
  35. package/publish/min/package.json +1 -1
  36. package/publish/min/publish.js +1 -1
  37. package/publish/min/publish.js.map +1 -1
  38. package/publish/min.private/package.json +1 -1
  39. package/publish/min.private/publish.js +1 -1
  40. package/publish/min.private/publish.js.map +1 -1
  41. package/publish/package.json +1 -1
  42. package/types/metrics/MetricsService.d.ts +1 -0
  43. package/types/telemetry/TelemetryService.d.ts +1 -0
package/full/min/full.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see full.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.phenix=t():e.phenix=t()}(self,(()=>(()=>{var e={981:(e,t,n)=>{"use strict";n.d(t,{A:()=>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=null,this._deferreds=[],this.doResolve(t)}return u()(e,[{key:"doResolve",value:function(e){var t=this,n=!1;try{e((function(e){n||(n=!0,t.promiseResolve(e))}),(function(e){n||(n=!0,t.promiseReject(e))}))}catch(e){if(n)return;n=!0,this.promiseReject(e)}}},{key:"promiseResolve",value:function(t){var n=this;try{if(t===n)throw new TypeError("A Promise cannot be resolved with it self.");if(t&&("object"===i()(t)||"function"==typeof t)){var r=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof r)return void n.doResolve((function(){r.apply(t,arguments)}))}n._state=1,n._value=t,n.finale()}catch(e){n.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate((function(){t._handled||e._unhandledRejection(t._value)}));for(var n=0,r=this._deferreds.length;n<r;n++)this.handle(this._deferreds[n]);this._deferreds=[]}},{key:"handle",value:function(t){for(var n=this;3===n._state;)n=n._value;0!==n._state?(n._handled=!0,e._immediate((function(){var e=1===n._state?t.onFulfilled:t.onRejected;if(null!==e){var r;try{r=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(r)}else 1===n._state?t.promise.promiseResolve(n._value):t.promise.promiseReject(n._value)}))):n._deferreds.push(t)}}],[{key:"all",value:function(t){return new e((function(e,n){if(!Array.isArray(t))return n(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);for(var o=r.length,a=function(t,s){try{if(s&&("object"===i()(s)||"function"==typeof s)){var u=s.then;if("function"==typeof u)return void u.call(s,(function(e){return a(t,e)}),n)}r[t]=s,0==--o&&e(r)}catch(e){n(e)}},s=0;s<r.length;s++)a(s,r[s])}))}},{key:"resolve",value:function(t){return t&&"object"===i()(t)&&t.constructor===e?t:new e((function(e){return e(t)}))}},{key:"reject",value:function(t){return new e((function(e,n){return n(t)}))}},{key:"race",value:function(t){return new e((function(n,r){if(!Array.isArray(t))return r(new TypeError("Promise.race accepts an array"));for(var i=0,o=t.length;i<o;i++)e.resolve(t[i]).then(n,r)}))}},{key:"_immediate",value:function(e){window.setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}])}();h.prototype.catch=function(e){return this.then(null,e)},h.prototype.then=function(e,t){var n=new h((function(){return null}));return this.handle(new d(e,t,n)),n},h.prototype.finally=function(e){return this.then((function(t){return h.resolve(e()).then((function(){return t}),(function(){return null}))}),(function(t){return h.resolve(e()).then((function(){return h.reject(t)}),(function(){return null}))}))};var p=h},512:e=>{"use strict";e.exports=function(e,t,n,r){var i=self||window;try{try{var o;try{o=new i.Blob([e])}catch(t){(o=new(i.BlobBuilder||i.WebKitBlobBuilder||i.MozBlobBuilder||i.MSBlobBuilder)).append(e),o=o.getBlob()}var a=i.URL||i.webkitURL,s=a.createObjectURL(o),u=new i[t](s,n);return a.revokeObjectURL(s),u}catch(r){return new i[t]("data:application/javascript,".concat(encodeURIComponent(e)),n)}}catch(e){if(!r)throw Error("Inline worker is not supported");return new i[t](r,n)}}},79:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},987:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},901:(e,t,n)=>{var r=n(79);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},475:e=>{e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},293:(e,t,n)=>{var r=n(981).A;function i(e,t,n,i,o,a,s){try{var u=e[a](s),c=u.value}catch(e){return void n(e)}u.done?t(c):r.resolve(c).then(i,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new r((function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,u,"next",e)}function u(e){i(a,r,o,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,n)=>{var r=n(736);function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}e.exports=function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,t,n)=>{var r=n(736);e.exports=function(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},72:e=>{function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},511:(e,t,n)=>{var r=n(636);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},291:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},156:e=>{e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}},e.exports.__esModule=!0,e.exports.default=e.exports},752:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},869:e=>{e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},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(981).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 C?t:C,o=Object.create(i.prototype),a=new L(r||[]);return u(o,"_invoke",{value:I(e,n,a)}),o}function m(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=f;var v="suspendedStart",g="suspendedYield",_="executing",y="completed",b={};function C(){}function k(){}function S(){}var x={};p(x,l,(function(){return this}));var w=Object.getPrototypeOf,T=w&&w(w(A([])));T&&T!==a&&s.call(T,l)&&(x=T);var P=S.prototype=C.prototype=Object.create(x);function E(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function F(e,t){function n(r,o,a,u){var c=m(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 I(e,n,r){var i=v;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=R(s,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===v)throw i=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=_;var c=m(e,n,r);if("normal"===c.type){if(i=r.done?y:g,c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=y,r.method="throw",r.arg=c.arg)}}}function R(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,R(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var o=m(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,b;var a=o.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function A(e){if(e||""===e){var n=e[l];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var 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}},E(F.prototype),p(F.prototype,d,(function(){return this})),n.AsyncIterator=F,n.async=function(e,t,i,o,a){void 0===a&&(a=r);var s=new F(f(e,t,i,o),a);return n.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},E(P),p(P,h,"Generator"),p(P,l,(function(){return this})),p(P,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),n=[];for(var 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,L.prototype={constructor:L,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(O),!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,b):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),O(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;O(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),b}},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.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{ChannelState:()=>Ie,Channels:()=>un,PublisherState:()=>ln,Publishers:()=>yn,SDK:()=>Te,default:()=>bn});var e=n(383),t=n.n(e),i=n(579),o=n.n(i),a=n(693),s=n.n(a),u=n(452),c=n.n(u),l=n(72),d=n.n(l),h=n(511),p=n.n(h),f=function(){return o()((function e(n){t()(this,e),s()(this,"_disposed",void 0),s()(this,"_disposable",void 0),this._disposed=!1,this._disposable=n}),[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}])}();function m(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(m=function(){return!!e})()}var v,g=function(e){function n(e,r){return t()(this,n),i=this,o=n,a=[function(){var t=e.indexOf(r);t>=0&&e.splice(t,1)}],o=d()(o),c()(i,m()?Reflect.construct(o,a||[],d()(i).constructor):o.apply(i,a));var i,o,a}return p()(n,e),o()(n)}(f),_=function(){return o()((function e(n){t()(this,e),s()(this,"_listeners",void 0),s()(this,"_value",void 0),this._listeners=[],this._value=n}),[{key:"value",get:function(){return this._value},set:function(e){var t=this._value!==e;if(t&&e){var n=e;"function"==typeof n.equals&&(t=!n.equals(this._value))}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 g(this._listeners,e)}}])}(),y=function(){return o()((function e(n){t()(this,e),s()(this,"_subject",void 0),this._subject=n}),[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}])}(),b={document,location,navigator,window},C=function(){function e(n){t()(this,e),s()(this,"_document",void 0),s()(this,"_location",void 0),s()(this,"_navigator",void 0),s()(this,"_window",void 0),this._document=n.document,this._location=n.location,this._navigator=n.navigator,this._window=n.window}return o()(e,[{key:"FormData",get:function(){return this._window.FormData}},{key:"MediaStream",get:function(){return this._window.MediaStream}},{key:"MediaStreamTrack",get:function(){return this._window.MediaStreamTrack}},{key:"RTCPeerConnection",get:function(){return this._window.RTCPeerConnection}},{key:"RTCSessionDescription",get:function(){return this._window.RTCSessionDescription}},{key:"RTCIceCandidate",get:function(){return this._window.RTCIceCandidate}},{key:"URL",get:function(){return this._window.URL}},{key:"URLSearchParams",get:function(){return this._window.URLSearchParams}},{key:"addDocumentEventListener",get:function(){return this._document.addEventListener.bind(this._document)}},{key:"addWindowEventListener",get:function(){return this._window.addEventListener.bind(this._window)}},{key:"clearInterval",get:function(){return this._window.clearInterval.bind(this._window)}},{key:"clearTimeout",get:function(){return this._window.clearTimeout.bind(this._window)}},{key:"documentCreateElement",get:function(){return this._document.createElement.bind(this._document)}},{key:"documentHasFocus",get:function(){return this._document.hasFocus.bind(this._document)}},{key:"documentIsHidden",get:function(){return!!this._document.hidden}},{key:"documentQuerySelector",get:function(){return this._document.querySelector.bind(this._document)}},{key:"fetch",get:function(){return this._window.fetch.bind(this._window)}},{key:"locationHostname",get:function(){return this._location.hostname}},{key:"locationSearch",get:function(){return this._location.search}},{key:"navigatorConnection",get:function(){return this._navigator.connection}},{key:"navigatorIsOnLine",get:function(){return this._navigator.onLine}},{key:"pageLoadTime",get:function(){return this._window.__phenixPageLoadTime||this._window.__pageLoadTime}},{key:"queueMicrotask",get:function(){return this._window.queueMicrotask.bind(this._window)}},{key:"removeDocumentEventListener",get:function(){return this._document.removeEventListener.bind(this._document)}},{key:"removeWindowEventListener",get:function(){return this._window.removeEventListener.bind(this._window)}},{key:"setInterval",get:function(){return this._window.setInterval.bind(this._window)}},{key:"setTimeout",get:function(){return this._window.setTimeout.bind(this._window)}}],[{key:"setInstance",value:function(e){throw new Error("This build does not support setting the GlobalScope")}},{key:"getInstance",value:function(){return e._readOnlyInstance}},{key:"subscribe",value:function(t){return e._readOnlyInstance.subscribe(t)}}])}();v=C,s()(C,"_instance",new _(new v(b))),s()(C,"_readOnlyInstance",new y(v._instance));var k,S,x,w=C.getInstance(),T=function(){function e(){t()(this,e)}return o()(e,null,[{key:"browserNameAndVersion",get:function(){return e._browserNameAndVersion}},{key:"browserName",get:function(){return this._browserName}},{key:"browserMajorVersion",get:function(){return this._browserMajorVersion}},{key:"isAndroid",get:function(){return e._isAndroid}},{key:"isChrome69",get:function(){return e._isChrome69}},{key:"isChrome70",get:function(){return e._isChrome70}},{key:"isChrome71",get:function(){return e._isChrome71}},{key:"isChrome72",get:function(){return e._isChrome72}},{key:"isChrome74",get:function(){return e._isChrome74}},{key:"isChrome75",get:function(){return e._isChrome75}},{key:"isChrome76",get:function(){return e._isChrome76}},{key:"isChrome77",get:function(){return e._isChrome77}},{key:"isMobile",value:function(){return e._isMobile}},{key:"parseBrowserNameAndVersion",value:function(){if(!navigator||!navigator.userAgent)return"";var t=navigator.userAgent.match(e._browserNameAndVersionRegex);return t&&t[0]?t[0]:e.parseBrowserNameAndVersionForIE()}},{key:"parseBrowserName",value:function(){if(!e._browserNameAndVersion)return"";var t=e._browserNameAndVersion.split("/");return t&&t[0]?t[0]:""}},{key:"parseBrowserMajorVersion",value:function(){if(!e._browserNameAndVersion)return 0;var t=e._browserNameAndVersion.split("/");if(!t||!t[1])return 0;var n=t[1];return n&&Number(n.split(".")[0])||0}},{key:"parseBrowserNameAndVersionForIE",value:function(){if(!navigator||!navigator.userAgent)return"";var e=navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return"IE/".concat(parseInt(e.substring(t+5,e.indexOf(".",t)),10));if(e.indexOf("Trident/")>0){var n=e.indexOf("rv:");return"IE/".concat(parseInt(e.substring(n+3,e.indexOf(".",n)),10))}return""}}])}();k=T,s()(T,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),s()(T,"_browserNameAndVersion",k.parseBrowserNameAndVersion()),s()(T,"_browserName",k.parseBrowserName()),s()(T,"_browserMajorVersion",k.parseBrowserMajorVersion()),s()(T,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(S=navigator)||void 0===S?void 0:S.userAgent)),s()(T,"_isAndroid",/Android/i.test(null===(x=navigator)||void 0===x?void 0:x.userAgent)),s()(T,"_isChrome69",k._browserNameAndVersion.includes("Chrome/69.")),s()(T,"_isChrome70",k._browserNameAndVersion.includes("Chrome/70.")),s()(T,"_isChrome71",k._browserNameAndVersion.includes("Chrome/71.")),s()(T,"_isChrome72",k._browserNameAndVersion.includes("Chrome/72.")),s()(T,"_isChrome74",k._browserNameAndVersion.includes("Chrome/74.")),s()(T,"_isChrome75",k._browserNameAndVersion.includes("Chrome/75.")),s()(T,"_isChrome76",k._browserNameAndVersion.includes("Chrome/76.")),s()(T,"_isChrome77",k._browserNameAndVersion.includes("Chrome/77."));var P=function(){function e(){t()(this,e)}return o()(e,null,[{key:"clientOfferDisabled",get:function(){return T.isChrome74||T.isChrome75||T.isChrome76||T.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return T.isChrome69||T.isChrome70||T.isChrome71||T.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=69||"Firefox"===T.browserName&&T.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=63||"Firefox"===T.browserName&&T.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===T.browserName&&T.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===T.browserName||"SamsungBrowser"===T.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==T.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===T.browserName&&"function"==typeof(null===(e=w.value)||void 0===e?void 0:e.documentCreateElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion>=71||"Firefox"===T.browserName&&T.browserMajorVersion>=69||"Safari"===T.browserName}},{key:"isMobile",get:function(){return T.isMobile()}},{key:"isInsertableStreamsSupported",get:function(){return!("undefined"==typeof MediaStreamTrackProcessor||"undefined"==typeof MediaStreamTrackGenerator)}},{key:"isEncodedInsertableStreamsSupported",get:function(){return"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams}},{key:"isRTCRtpScriptTransformSupported",get:function(){return"undefined"!=typeof RTCRtpScriptTransform}},{key:"isRequestVideoFrameCallbackSupported",get:function(){return void 0!==HTMLVideoElement.prototype.requestVideoFrameCallback}},{key:"isChannelFrameTimingInformationSupported",get:function(){return e.isRequestVideoFrameCallbackSupported&&(e.isEncodedInsertableStreamsSupported||e.isRTCRtpScriptTransformSupported)}},{key:"errorStackAlsoHasErrorMessage",get:function(){return"Firefox"!==T.browserName&&"Safari"!==T.browserName}}])}(),E=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),F=function(){return o()((function e(n,r,i){t()(this,e),s()(this,"_category",void 0),s()(this,"_appenders",void 0),s()(this,"_threshold",void 0),this._category=n,this._appenders=r,this._threshold=i}),[{key:"category",get:function(){return this._category}},{key:"appenders",get:function(){return this._appenders}},{key:"threshold",get:function(){return this._threshold}},{key:"trace",value:function(){if(this._threshold.value&&!(this._threshold.value>E.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(E.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>E.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(E.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>E.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(E.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>E.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(E.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>E.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(E.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>E.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(E.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?P.errorStackAlsoHasErrorMessage?e+"\n"+t.toString(n.stack):e+"\n"+t.toString(n.message)+"\n"+t.toString(n.stack):e+"[".concat(t.toString(n),"]")}))),e.toString()}},{key:"stringify",value:function(e){var t=[];try{return JSON.stringify(e instanceof Error?this.toString(e):e,(function(e,n){if(n&&n instanceof Object){if(t.includes(n))return"<recursive>";t.push(n)}return n}),2)}catch(e){return"[object invalid JSON.stringify]"}}},{key:"replaceArgument",value:function(e,t,n){return t.substring(0,n)+this.toString(e)+t.substring(n+2)}},{key:"toString",value:function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return e.toString();var t="";if(e)if("function"==typeof e)t=e.toString();else if(e instanceof Object)try{t=e.toString()}catch(e){t="[object invalid toString()]"}return t}}])}(),I=function(){return o()((function e(){t()(this,e),s()(this,"_appenders",[])}),[{key:"value",get:function(){return this._appenders}},{key:"add",value:function(e){this._appenders.push(e)}},{key:"remove",value:function(e){this._appenders=this._appenders.reduce((function(t,n){return n!==e&&t.push(n),t}),[])}}])}(),R=function(){return o()((function e(){t()(this,e)}),null,[{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"sendLogs",get:function(){return this._sendLogs}},{key:"sendMetrics",get:function(){return this._sendMetrics}},{key:"logToConsole",get:function(){return this._logToConsole}},{key:"applyFeatures",value:function(){try{var e={sendLocalCandidates:!0,sendLogs:"All",sendMetrics:"All",logToConsole:"All"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}])}();s()(R,"_sendLocalCandidates",void 0),s()(R,"_sendLogs",void 0),s()(R,"_sendMetrics",void 0),s()(R,"_logToConsole",void 0),R.applyFeatures();var D=function(){return o()((function e(){t()(this,e)}),null,[{key:"defaultLoggingLevel",get:function(){return E[R.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return E[R.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return E.Info}}])}(),O=function(){return o()((function e(){t()(this,e),s()(this,"_threshold",D.defaultLoggingLevel)}),[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}])}(),L=function(){return o()((function e(n){t()(this,e),s()(this,"_threshold",void 0),this._threshold=n}),[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(E[e],"] ").concat(t);e<E.Warn?console.log(i):console.error(i)}}}])}(),A=n(293),M=n.n(A),N=n(756),V=n.n(N),U=function(){function e(){throw t()(this,e),new Error("Numbers is a static class that may not be instantiated")}return o()(e,null,[{key:"countNumberLength",value:function(t){var n=0,r=t;return r<0&&(r*=-1,n++),e.countDigitsBeforeDecimal(r)+n+(r!==Math.floor(r)?e.countDigitsAfterDecimal(r)+1:0)}},{key:"fixRounding",value:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}},{key:"countDigitsBeforeDecimal",value:function(e){for(var t=1,n=e;n>=10;)n/=10,t++;return t}},{key:"countDigitsAfterDecimal",value:function(t){for(var n=t,r=Math.floor(t),i=0;r!==n&&i<15;)i++,r=e.fixRounding(n,i);return i}}])}(),B=function(){return o()((function e(){t()(this,e)}),null,[{key:"sdkVersion",get:function(){try{return"2025-01-29T08:29:50.515Z (2025.0.2-beta.405)"}catch(e){return this._defaultVersion}}}])}();s()(B,"_defaultVersion",(new Date).toISOString());var j=function(){return o()((function e(n){var r;t()(this,e),s()(this,"_telemetryConfiguration",void 0),s()(this,"_logs",[]),s()(this,"_isSending",!1),s()(this,"_domain",(null===(r=w.value)||void 0===r?void 0:r.locationHostname)||""),this._telemetryConfiguration=n}),[{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:E[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:B.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<E.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"sendLogs",value:(n=M()(V().mark((function e(t){var n;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new w.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,w.value.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 n.apply(this,arguments)})},{key:"sendLogsIfAble",value:(e=M()(V().mark((function e(){var t,n,r,i,o,a=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._logs.length<=0||this._isSending)&&w.value){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?U.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,n}(),z=function(){return o()((function e(n){t()(this,e),s()(this,"_telemetryService",void 0),s()(this,"_tenancy",void 0),s()(this,"_sessionId",void 0),s()(this,"_threshold",void 0),this._tenancy=n.tenancy,this._sessionId=n.sessionId,this._threshold=n.threshold,this._telemetryService=new j(n)}),[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}])}(),H=function(){return o()((function e(){t()(this,e),s()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),s()(this,"_tenancy","-"),s()(this,"_sessionId","-"),s()(this,"_environment","-"),s()(this,"_pageLoadTime",0),s()(this,"_threshold",D.defaultTelemetryLoggingLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new w.value.URL(e);t.pathname=t.pathname+"/logs",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"pageLoadTime",get:function(){return this._pageLoadTime},set:function(e){this._pageLoadTime=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}])}(),G=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},W=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case E.Off:return"Off";case E.Trace:return"Trace";case E.Debug:return"Debug";case E.Info:return"Trace";case E.Warn:return"Warn";case E.Error:return"Error";case E.Fatal:return"Fatal";case E.All:return"All";default:G(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return E.Off;case"Trace":return E.Trace;case"Debug":return E.Debug;case"Info":return E.Info;case"Warn":return E.Warn;case"Error":return E.Error;case"Fatal":return E.Fatal;case"All":return E.All;default:G(e)}}}])}(),q=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),J=function(){return o()((function e(){t()(this,e),s()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),s()(this,"_tenancy","-"),s()(this,"_sessionId","-"),s()(this,"_environment","-"),s()(this,"_threshold",K.defaultTelemetryLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new w.value.URL(e);t.pathname=t.pathname+"/metrics",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}])}(),K=function(){return o()((function e(){t()(this,e)}),null,[{key:"defaultTelemetryLevel",get:function(){return q[R.sendMetrics]}}])}(),Z=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case q.Off:return"Off";case q.Essential:return"Essential";case q.All:return"All";default:G(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return q.Off;case"Essential":return q.Essential;case"All":return q.All;default:G(e)}}}])}(),Q=function(){function e(){t()(this,e)}return o()(e,null,[{key:"getStringValue",value:function(t){return e.readConfigurationParameterValue(t)||e.readConfigurationParameterURIValue("".concat(t,"-uri-parameter-name"))||e.defaultStringValue[t]}},{key:"getBooleanValue",value:function(t){var n=e.readConfigurationParameterValue(t);if(n)return"true"===n||"1"===n||"On"===n;var r=e.readConfigurationParameterURIValue("".concat(t,"-uri-parameter-name"));return r?"true"===r||"1"===r||"On"===r:!0===e.defaultBooleanValue[t]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":Z.convertTelemetryLevelToTelemetryLevelType(K.defaultTelemetryLevel),"phenix-logging-level":W.convertLoggingLevelToLoggingLevelType(D.defaultLoggingLevel),"phenix-console-logging-level":W.convertLoggingLevelToLoggingLevelType(D.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":W.convertLoggingLevelToLoggingLevelType(D.defaultTelemetryLoggingLevel),"phenix-channel-token":"","phenix-uri":"","phenix-base-uri":""}}},{key:"defaultBooleanValue",get:function(){return{"phenix-automatically-retry-on-failure":!0,"phenix-automatically-reconnect-peer-connection":!0,"phenix-force-garbage-collection-on-restart":!0,"phenix-skip-garbage-collection-on-mobile-devices":!0}}},{key:"readConfigurationParameterValue",value:function(e){var t=w.value.documentQuerySelector("meta[name='".concat(e,"']"));if(t){var n=t.getAttribute("value");if(n)return n}}},{key:"readConfigurationParameterURIValue",value:function(t){var n=e.readConfigurationParameterValue(t);if(n){var r=new w.value.URLSearchParams(w.value.locationSearch).get(n)||void 0;if(r)return r}}}])}(),$=function(){function e(){throw t()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return o()(e,null,[{key:"telemetryConfiguration",get:function(){return e._telemetryConfiguration}},{key:"getLogger",value:function(t){return"string"!=typeof t&&(t="SDK"),e._loggers[t]||(e._loggers[t]=new F(t,this._appenders,this._threshold))}},{key:"applyLoggerConfigFromParameterConfiguration",value:function(){e.applyLoggingLevel(),e.applyAppenderLoggingLevel("console",e.applyConsoleLogger.bind(this)),e.applyAppenderLoggingLevel("telemetry",e.applyTelemetryLogger.bind(this))}},{key:"applyLoggingLevel",value:function(){var e=Q.getStringValue("phenix-logging-level");E[e]&&this._threshold.setThreshold(E[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=Q.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(E[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new L(e||D.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||D.defaultTelemetryLoggingLevel,this._appenders.add(new z(this._telemetryConfiguration))}}])}();s()($,"_loggers",{}),s()($,"_appenders",new I),s()($,"_threshold",new O),s()($,"_telemetryConfiguration",new H),$.applyLoggerConfigFromParameterConfiguration();var X=function(){return o()((function e(){throw t()(this,e),new Error("Strings is a static class that may not be instantiated")}),null,[{key:"random",value:function(e){var t=Math.ceil(e/13);return new Array(t).fill((function(){return Math.random().toString(16).substring(2,15)})).reduce((function(e,t){return e+t()}),"").substring(0,e)}}])}(),Y=function(){return o()((function e(n){var r,i;t()(this,e),s()(this,"_applicationId",void 0),s()(this,"_token",void 0),this._applicationId=(null==n?void 0:n.applicationId)||"",this._token={uri:null!=n&&null!==(r=n.token)&&void 0!==r&&r.uri?new w.value.URL(n.token.uri):null,capabilities:(null==n||null===(i=n.token)||void 0===i?void 0:i.capabilities)||[]}}),[{key:"uri",get:function(){return this._token.uri}},{key:"capabilities",get:function(){return this._token.capabilities}},{key:"tenancy",get:function(){return this._applicationId}}])}(),ee=function(){function e(){t()(this,e)}return o()(e,null,[{key:"parseToken",value:function(t){if(!this.isEncodedEdgeTokenValid(t))return e._logger.error("Token is not valid [%s]",t),new Y(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new Y(r)}catch(t){return e._logger.error("Cannot parse token value",t),new Y(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();s()(ee,"_logger",$.getLogger("EdgeAuthParser"));var te=function(){return o()((function e(){t()(this,e),s()(this,"_list",[])}),[{key:"add",value:function(e){this._list.push(e)}},{key:"dispose",value:function(){this._list.forEach((function(e){return e.dispose()})),this._list.length=0}},{key:"toString",value:function(){return"DisposableList[disposables=".concat(this._list.length,"]")}}])}(),ne="visibilitychange",re=function(){return o()((function e(){t()(this,e),s()(this,"_disposables",new te),s()(this,"_readOnlyIsForeground",void 0),s()(this,"_isForeground",void 0),s()(this,"_timeOfLastTabFocusChange",Date.now()),this._isForeground=new _(!0),this._readOnlyIsForeground=new y(this._isForeground),this.initialize()}),[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"initialize",value:function(){var e=this,t=function(){return e._isForeground.value=!w.value.documentIsHidden},n=!1;w.value.addDocumentEventListener(ne,t,n),this._disposables.add(new f((function(){return w.value.removeDocumentEventListener(ne,t,n)})))}}])}(),ie=n(981).A,oe=function(){return o()((function e(n){t()(this,e),s()(this,"_logger",$.getLogger("VanillaPeerConnection")),s()(this,"_peerConnection",void 0),P.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(n):this._peerConnection=new w.value.RTCPeerConnection(n)}),[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.currentLocalDescription)||null}},{key:"currentRemoteDescription",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.currentRemoteDescription)||null}},{key:"connectionState",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.connectionState)||null}},{key:"iceConnectionState",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.iceConnectionState)||null}},{key:"supportsGetConfiguration",get:function(){var e;return"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getConfiguration)}},{key:"supportsSetConfiguration",get:function(){var e;return"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.setConfiguration)}},{key:"supportsGetTransceivers",get:function(){var e;return!P.getTransceiversDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getTransceivers)}},{key:"supportsAddTransceiver",get:function(){var e;return!P.addTranceiverDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.addTransceiver)}},{key:"createOffer",value:(i=M()(V().mark((function e(t){var n=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:if(!P.promiseBasedPCMethodsDisabled){e.next=4;break}return e.abrupt("return",new ie((function(e,r){return n._peerConnection.createOffer(e,r,t)})));case 4:return e.abrupt("return",this._peerConnection.createOffer(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"createAnswer",value:(r=M()(V().mark((function e(t){var n=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:if(!P.promiseBasedPCMethodsDisabled){e.next=4;break}return e.abrupt("return",new ie((function(e,r){return n._peerConnection.createAnswer(e,r,t)})));case 4:return e.abrupt("return",this._peerConnection.createAnswer(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setLocalDescription",value:(n=M()(V().mark((function e(t){return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:return e.abrupt("return",this._peerConnection.setLocalDescription(P.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(e=M()(V().mark((function e(t){var n;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:return(null===(n=t.sdp)||void 0===n?void 0:n.match(/a=crypto:/i))&&this._logger.warn("SDP a=crypto is not supported"),e.abrupt("return",this._peerConnection.setRemoteDescription(P.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 5:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"getSenders",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getSenders()}},{key:"getReceivers",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getReceivers()}},{key:"getStats",value:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;if(!this._peerConnection)throw new Error("No PeerConnection initialized");return new ie((function(t){e._peerConnection.getStats(t)}))}},{key:"addEventListener",value:function(e,t,n){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.removeEventListener(e,t,n)}},{key:"getTransceivers",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getTransceivers()}},{key:"addTransceiver",value:function(e,t){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.addTransceiver(e,t)}},{key:"addStream",value:function(e){var t=this;e.getTracks().forEach((function(e){if(!t._peerConnection)throw new Error("No PeerConnection initialized");t._peerConnection.addTrack(e)}))}},{key:"getConfiguration",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.setConfiguration(e)}},{key:"ontrack",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.ontrack},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.ontrack=e}},{key:"onicecandidate",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.onicecandidate},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.onicecandidate=e}},{key:"onconnectionstatechange",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.onconnectionstatechange},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.onconnectionstatechange=e}},{key:"oniceconnectionstatechange",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.oniceconnectionstatechange},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){var e;null===(e=this._peerConnection)||void 0===e||e.close()}},{key:"dispose",value:function(){this._peerConnection=null}}]);var e,n,r,i}(),ae=n(981).A,se=function(){return o()((function e(){t()(this,e)}),[{key:"createPeerConnection",value:(e=M()(V().mark((function e(t){return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new ae((function(e){w.subscribe((function(n){n&&e(new oe(t))}))})));case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e}(),ue=function(){function e(){throw t()(this,e),new Error("PeerConnectionService is a static class that may not be instantiated")}return o()(e,null,[{key:"peerConnectionFactory",get:function(){return e._peerConnectionFactory}},{key:"initiateInitialPrecaching",value:function(){P.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(r=M()(V().mark((function t(){return V().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 r.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(n=M()(V().mark((function t(){var n,r,i,o,a=arguments;return V().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=P.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:r}:void 0,t.abrupt("return",e._peerConnectionFactory.value.createPeerConnection(o).then(function(){var e=M()(V().mark((function e(t){var r,i,o;return V().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 n.apply(this,arguments)})}]);var n,r}();s()(ue,"_logger",$.getLogger("PeerConnectionService")),s()(ue,"_peerConnectionFactory",new _(new se)),s()(ue,"_cached",void 0),ue.initiateInitialPrecaching();var ce=function(){return o()((function e(){t()(this,e)}),null,[{key:"getTelemetryUrl",value:function(e){try{var t=new w.value.URL(e),n=t.hostname.split(".");switch(t.protocol){case"ws:":t.protocol="http:";break;case"wss:":t.protocol="https:"}return 2===n.length||3===n.length&&n[n.length-2].length<=2&&n[n.length-1].length<=3?n.unshift("telemetry"):n[0].startsWith("stg-")||n[0].endsWith("-stg")||n[0].includes("-stg-")||"stg"===n[0]?n[0]="telemetry-stg":n[0].startsWith("local")||n[0].endsWith("-local")||(n[0]="telemetry"),t.hostname=n.join("."),"".concat(t.origin,"/telemetry")}catch(t){return e}}}])}(),le=function(){return o()((function e(){t()(this,e)}),null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new w.value.URL(e).origin}catch(e){return""}}}])}(),de=function(){return o()((function e(){t()(this,e)}),null,[{key:"discoveryParameters",get:function(){return this._discoveryParameters}},{key:"applyParameters",value:function(){try{var e={discovery:{intentions:"contribution,distribution"}};this._discoveryParameters="discovery"in e?e.discovery:{intentions:""}}catch(e){this._discoveryParameters={intentions:""}}}}])}();s()(de,"_discoveryParameters",void 0),de.applyParameters();var he=function(){function e(){throw t()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return o()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new w.value.URL(e.toString()),n=B.sdkVersion,r=de.discoveryParameters.intentions;return t.searchParams.set("version",n),t.searchParams.set("intentions",r),t.searchParams.set("_","".concat(Date.now())),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}])}();s()(he,"_discoveryUri",new _("https://pcast.phenixrts.com/pcast/endPoints"));var pe,fe,me=n(738),ve=n.n(me),ge=n(132),_e=n.n(ge),ye=function(){return o()((function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e5;t()(this,e),s()(this,"_backoffIntervalInMillisecond",void 0),s()(this,"_minBackoffIntervalInMillisecond",void 0),s()(this,"_maxBackoffIntervalInMillisecond",void 0),this._backoffIntervalInMillisecond=n,this._minBackoffIntervalInMillisecond=r,this._maxBackoffIntervalInMillisecond=i}),[{key:"getExponentialBackoffIntervalByFailureCount",value:function(e){var t=this._backoffIntervalInMillisecond/1e3,n=.5+.5*Math.random(),r=Math.pow(t,e-2),i=Math.floor(r)*n,o=Math.ceil(Math.max(1e3*i,this._minBackoffIntervalInMillisecond));return Math.min(o,this._maxBackoffIntervalInMillisecond)}}])}(),be=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}(be||{}),Ce=be,ke=function(){return o()((function e(n){t()(this,e),s()(this,"_metrics",void 0),this._metrics=n}),[{key:"getName",value:function(){return Ce[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case Ce.TimeToFirstFrame:case Ce.ChannelCreationTimeToFirstFrame:return q.Essential;case Ce.Stalled:case Ce.Buffering:case Ce.SetupCompleted:case Ce.SetupFailed:case Ce.RoundTripTime:case Ce.DownlinkThroughputCapacity:case Ce.NetworkType:case Ce.ResolutionChanged:case Ce.ApplicationForeground:case Ce.ApplicationBackground:return q.All;default:G(this._metrics)}}}])}(),Se=function(){return o()((function e(n){var r;t()(this,e),s()(this,"_logger",$.getLogger("MetricsService")),s()(this,"_metricsConfiguration",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_metrics",[]),s()(this,"_isSending",!1),s()(this,"_failureCount",0),s()(this,"_domain",(null===(r=w.value)||void 0===r?void 0:r.locationHostname)||""),this._metricsConfiguration=n,this._exponentialBackoff=new ye}),[{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 ke(e.metricType);if(!(this._metricsConfiguration.threshold>s.getTelemetryLevel())){var u={timestamp:(new Date).toISOString(),tenancy:this._metricsConfiguration.tenancy,sessionId:this._metricsConfiguration.sessionId,streamId:t,metric:s.getName(),value:n,previousValue:r,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:B.sdkVersion,runtime:i,resource:o,kind:a};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:(n=M()(V().mark((function e(t){var n;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new w.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,w.value.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 n.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(e=M()(V().mark((function e(){var t,n=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._metrics.length<=0||this._isSending)&&w.value){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 w.value.setTimeout((function(){n._metrics=[].concat(_e()(t),_e()(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,n}(),xe=function(){function e(){throw t()(this,e),new Error("MetricsFactory is a static class that may not be instantiated")}return o()(e,null,[{key:"getMetricsService",value:function(t){if("string"!=typeof t)throw new Error("url must be a string instead received [".concat(ve()(t),"]"));var n=e._metricsServices[t];if(n)return n;var r=new J;return r.sessionId=Te.clientSessionId,r.tenancy=Te.tenancy.value,r.url=ce.getTelemetryUrl(t),r.environment=le.getEnvironmentFromUrl(t),r.threshold=Z.convertTelemetryLevelTypeToTelemetryLevel(Te.telemetryLevel),e._metricsServices[t]=new Se(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}])}();s()(xe,"_metricsServices",{});var we=(null===(pe=C.getInstance().value)||void 0===pe?void 0:pe.pageLoadTime)||Date.now(),Te=function(){function e(){throw t()(this,e),new Error("SDK is a static class that may not be instantiated")}return o()(e,null,[{key:"pageLoadTime",get:function(){return we}},{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 W.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return Z.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return T}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=$.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 z}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new z(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 z}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new z(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=xe.getMetricsService(he.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=Q.getStringValue("phenix-metrics-level");t&&xe.setTelemetryLevel(q[t]),e._telemetryLevel.subscribe((function(e){xe.setTelemetryLevel(e)}))}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=Q.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=Q.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=Q.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=Q.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=le.getEnvironmentFromUrl(t)}));var t=Q.getStringValue("phenix-channel-token");if(t){var n=ee.parseToken(t);return e._tenancy.value=n.tenancy,he.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=Q.getStringValue("phenix-uri");if(r)return he.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=Q.getStringValue("phenix-base-uri");if(i){var o=new(C.getInstance().value.URL)(i);return o.pathname="/pcast/endPoints",he.uri.value=o.toString(),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)}}},{key:"onLoad",value:function(t){t&&(this._initialized.value?this._logger.warn("SDK has already been loaded"):(t.addWindowEventListener("unload",(function(){e.dispose()})),e.applyDiscoveryUriDefaultFromParameterConfiguration(),e.applyMetricsConfiguration(),e.applyTelemetryConfiguration(),this._applicationActivityMonitor=new re,this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection),this._logger.info("Force garbage collection on restart is set to: [%s]",this._forceGarbageCollectionOnRestart),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices),this._initialized.value=!0))}},{key:"init",value:function(t){if(t){var n=t;if(n.globalScope&&C.setInstance(n.globalScope),t.discoveryUri&&(he.uri.value=t.discoveryUri),t.peerConnectionFactory&&(ue.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&q[t.telemetryLevel]&&(e._telemetryLevel.value=Z.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&E[t.loggingLevel]&&this._logger.threshold.setThreshold(W.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&E[t.consoleLoggingLevel]){var r=this._logger.appenders.value.find((function(e){return e instanceof L}));r&&this._logger.appenders.remove(r),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new L(W.convertLoggingLevelTypeToLoggingLevel(t.consoleLoggingLevel)))}"boolean"==typeof t.automaticallyPlayMediaStream&&(this._automaticallyPlayMediaStream=t.automaticallyPlayMediaStream),"boolean"==typeof t.automaticallyMuteVideoOnPlayFailure&&(this._automaticallyMuteVideoOnPlayFailure=t.automaticallyMuteVideoOnPlayFailure),t.webPlayerLoader&&(this._webPlayerLoader=t.webPlayerLoader),t.shakaPlayerLoader&&(this._shakaPlayerLoader=t.shakaPlayerLoader),t.hlsJsLoader&&(this._hlsJsLoader=t.hlsJsLoader)}}},{key:"dispose",value:function(){var t;e._initialized.value=!1,null===(t=this._applicationActivityMonitor)||void 0===t||t.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return ce.getTelemetryUrl(e)}}])}();fe=Te,s()(Te,"_automaticallyRetryOnFailure",Q.getBooleanValue("phenix-automatically-retry-on-failure")),s()(Te,"_automaticallyReconnectPeerConnection",Q.getBooleanValue("phenix-automatically-reconnect-peer-connection")),s()(Te,"_automaticallyPlayMediaStream",!0),s()(Te,"_automaticallyMuteVideoOnPlayFailure",!0),s()(Te,"_forceGarbageCollectionOnRestart",Q.getBooleanValue("phenix-force-garbage-collection-on-restart")),s()(Te,"_skipGarbageCollectionOnMobileDevices",Q.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices")),s()(Te,"_webPlayerLoader",void 0),s()(Te,"_shakaPlayerLoader",void 0),s()(Te,"_hlsJsLoader",void 0),s()(Te,"_applicationActivityMonitor",void 0),s()(Te,"_environment",new _("")),s()(Te,"_telemetryUrl",new _("https://telemetry.phenixrts.com/telemetry")),s()(Te,"_maximalNumberOfPeerConnectionReconnectAttempts",8),s()(Te,"_telemetryLevel",new _(K.defaultTelemetryLevel)),s()(Te,"_metricsService",void 0),s()(Te,"_metricsConfiguration",void 0),s()(Te,"_sendLocalCandidates",new _(R.sendLocalCandidates)),s()(Te,"_tenancy",new _("")),s()(Te,"_clientSessionId",X.random(32)),s()(Te,"_loadedTimestamp",new Date),s()(Te,"_logger",$.getLogger("SDK")),s()(Te,"_initialized",new _(!1)),s()(Te,"_readOnlyInitialized",new y(fe._initialized)),s()(Te,"_readOnlyDiscoveryUri",new y(he.uri)),s()(Te,"_readOnlyPeerConnectionFactory",new y(ue.peerConnectionFactory)),C.subscribe(Te.onLoad.bind(Te));var Pe=function(){function e(n,r){t()(this,e),s()(this,"width",void 0),s()(this,"height",void 0),this.width=n,this.height=r}return o()(e,[{key:"equals",value:function(e){return e&&this.width===e.width&&this.height===e.height}},{key:"toString",value:function(){return"".concat(this.width,"x").concat(this.height)}}],[{key:"empty",get:function(){return new e(0,0)}}])}(),Ee=function(){return o()((function e(){throw t()(this,e),new Error("GarbageCollectorManager is a static class that may not be instantiated")}),null,[{key:"forceGarbageCollection",value:function(){P.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){P.isQueueMicrotaskSupported?w.value.queueMicrotask(this.overloadMemoryToInvokeGarbageCollection.bind(this)):w.value.setTimeout(this.overloadMemoryToInvokeGarbageCollection.bind(this),0)}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=w.value.documentCreateElement("img");e.src=w.value.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){w.value.URL.revokeObjectURL(this.src),e=null}}}])}(),Fe=function(e){return e[e.Initializing=0]="Initializing",e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Paused=3]="Paused",e[e.Playing=4]="Playing",e[e.Recovering=5]="Recovering",e[e.Reconnecting=6]="Reconnecting",e[e.StandBy=7]="StandBy",e[e.Stopped=8]="Stopped",e[e.Unauthorized=9]="Unauthorized",e[e.GeoRestricted=10]="GeoRestricted",e[e.GeoBlocked=11]="GeoBlocked",e[e.UnsupportedFeature=12]="UnsupportedFeature",e[e.ConfigurationError=13]="ConfigurationError",e[e.TransientConfigurationError=14]="TransientConfigurationError",e[e.ConnectionError=15]="ConnectionError",e[e.ClientStartError=16]="ClientStartError",e[e.Error=17]="Error",e}(Fe||{}),Ie=Fe,Re=function(){return o()((function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t()(this,e),s()(this,"_duration",void 0),this._duration=n}),[{key:"toIsoString",value:function(){if(0===this._duration)return"P0S";var e=this._duration<0,t=e?Math.abs(this._duration):this._duration,n=Math.floor(t),r=n%1e3,i=(n=Math.floor(n/1e3))%60,o=(n=Math.floor(n/60))%60,a=(n=Math.floor(n/60))%24,s=["PT"];return e&&s.unshift("-"),a&&s.push(a+"H"),o&&s.push(o+"M"),(i||r)&&(s.push(String(i)),r&&s.push("."+this.padStart(r.toString(),3,"0")),s.push("S")),s.join("")}},{key:"padStart",value:function(e,t,n){return t|=0,n=String(void 0!==n?n:" "),e.length>t?e:((t-=e.length)>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}}])}(),De=function(){},Oe=function(){return o()((function e(n,r,i,o){t()(this,e),s()(this,"_pageLoadTime",void 0),s()(this,"_channelStartTime",void 0),s()(this,"_logger",$.getLogger("StreamTelemetry")),s()(this,"_disposables",new te),s()(this,"_streamId",void 0),s()(this,"_metricsService",void 0),s()(this,"_listenToFirstTime",De),s()(this,"_listenForStall",De),s()(this,"_listenForContinuation",De),s()(this,"_timeToFirstFrame",0),s()(this,"_channelCreationTimeToFirstFrame",0),s()(this,"_startRecordingFirstFrame",0),s()(this,"_videoStalled",null),s()(this,"_lastProgress",0),s()(this,"_videoResolution",""),s()(this,"_clearTimeToFirstFrameListener",new f((function(){return null}))),s()(this,"_clearRebufferingListener",new f((function(){return null}))),this._streamId=n,this._pageLoadTime=r,this._channelStartTime=i,this._metricsService=o}),[{key:"setupListenerForTimeToFirstTime",value:function(e){var t=this;this._startRecordingFirstFrame=Date.now(),this._listenToFirstTime=function(){return t.callTimeToFirstFrame()},e.addEventListener("loadeddata",this._listenToFirstTime),e.addEventListener("loadedmetadata",this._listenToFirstTime),this._clearTimeToFirstFrameListener=new f((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 f((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 Re(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:Ce.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 Re(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:Ce.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 Re(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:Ce.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:Ce.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 Re(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:Ce.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}}])}(),Le=function(){return o()((function e(n){t()(this,e),s()(this,"_logger",$.getLogger("StreamSetupListener")),s()(this,"metricsService",Te.metricsService),s()(this,"_pageLoadTime",void 0),s()(this,"_startTime",void 0),s()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=n}),[{key:"success",value:function(e){this.recordStreamMetric(Ce.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(Ce.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new ke(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 Re(n-this._pageLoadTime).toIsoString(),t,i,new Re(r).toIsoString())}}}])}(),Ae=function(){return o()((function e(){t()(this,e),s()(this,"_disposables",new te),s()(this,"_isSupported",void 0!==w.value.navigatorConnection),s()(this,"_rtt",new _(void 0)),s()(this,"_effectiveType",new _(void 0)),s()(this,"_downlinkThroughputCapacity",new _(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())}),[{key:"isSupported",get:function(){return this._isSupported}},{key:"rtt",get:function(){return this._rtt}},{key:"effectiveType",get:function(){return this._effectiveType}},{key:"downlinkThroughputCapacity",get:function(){return this._downlinkThroughputCapacity}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"getDownlinkThroughputCapacity",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=w.value.navigatorConnection)||void 0===n?void 0:n.downlink)&&void 0!==t?t:null===(r=w.value.navigatorConnection)||void 0===r?void 0:r.downlinkMax)&&void 0!==e?e:-1}},{key:"getEffectiveType",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=w.value.navigatorConnection)||void 0===n?void 0:n.effectiveType)&&void 0!==t?t:null===(r=w.value.navigatorConnection)||void 0===r?void 0:r.type)&&void 0!==e?e:"Unknown"}},{key:"getRoundTripTime",value:function(){var e,t;return null!==(e=null===(t=w.value.navigatorConnection)||void 0===t?void 0:t.rtt)&&void 0!==e?e:-1}},{key:"setupNetworkChangeListeners",value:function(){var e,t=this,n=function(){return t.updateStatistics()};null===(e=w.value.navigatorConnection)||void 0===e||e.addEventListener("change",n),this._disposables.add(new f((function(){var e;return null===(e=w.value.navigatorConnection)||void 0===e?void 0:e.removeEventListener("change",n)})))}},{key:"updateStatistics",value:function(){this._rtt.value=this.getRoundTripTime(),this._effectiveType.value=this.getEffectiveType(),this._downlinkThroughputCapacity.value=this.getDownlinkThroughputCapacity()}}])}(),Me=function(){return o()((function e(n,r){var i=this;if(t()(this,e),s()(this,"_logger",$.getLogger("SessionTelemetry")),s()(this,"_metricsService",void 0),s()(this,"_applicationActivityMonitor",Te.applicationActivityMonitor),s()(this,"_networkMonitor",new Ae),s()(this,"_pageLoadTime",void 0),s()(this,"_disposables",new te),s()(this,"_lastNetworkStatistics",{}),this._pageLoadTime=n,this._disposables.add(this._networkMonitor),this._metricsService=r,!this._applicationActivityMonitor)throw new Error("SessionTelemetry Failed: No application monitor initialized.");this._networkMonitor.isSupported&&(this._disposables.add(this._applicationActivityMonitor.isForeground.subscribe((function(e){i.recordForegroundChange(e)}))),this._disposables.add(this._networkMonitor.rtt.subscribe((function(e){e&&i.recordNetworkRTTUpdate(e)}))),this._disposables.add(this._networkMonitor.effectiveType.subscribe((function(e){e&&i.recordNetworkTypeChangeUpdate(e)}))),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe((function(e){e&&i.recordNetworkDownlinkThroughputCapacityUpdate(e)}))))}),[{key:"listenOnStreamSetup",value:function(){return new Le(this._pageLoadTime)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"recordForegroundChange",value:function(e){var t,n=Date.now(),r=null===(t=this._applicationActivityMonitor)||void 0===t?void 0:t.getTimeSinceLastChange();r&&(this._metricsService.push({metricType:e?Ce.ApplicationForeground:Ce.ApplicationBackground,runtime:(n-this._pageLoadTime)/1e3,value:{uint64:r}}),this._logger.info("Application has gone into the [%s] after [%s] ms",e?"foreground":"background",new Re(r).toIsoString()))}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:Ce.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 Re(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:Ce.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 Re(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:Ce.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 Re(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),Ne=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Ve=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),Ue=o()((function e(n){t()(this,e),s()(this,"token",void 0),s()(this,"tokenExpiring",void 0),this.token=new _(n),this.tokenExpiring=new _(!1)})),Be=function(){return o()((function e(n){var r;t()(this,e),s()(this,"channelInitialization",void 0),s()(this,"disposables",void 0),s()(this,"channelDisposables",void 0),s()(this,"rendererDisposables",void 0),s()(this,"videoElement",void 0),s()(this,"state",void 0),s()(this,"autoMuted",void 0),s()(this,"autoPaused",void 0),s()(this,"authorized",void 0),s()(this,"online",void 0),s()(this,"loading",void 0),s()(this,"playing",void 0),s()(this,"standby",void 0),s()(this,"stopped",void 0),s()(this,"targetLag",void 0),s()(this,"lag",void 0),s()(this,"bitrateLimit",void 0),s()(this,"resolution",void 0),s()(this,"failureCount",void 0),s()(this,"endPoint",void 0),s()(this,"stream",void 0),s()(this,"rtcStatistics",void 0),s()(this,"videoTelemetry",void 0),s()(this,"rtcAudioStatistic",void 0),s()(this,"rtcVideoStatistic",void 0),s()(this,"clearFailureCountTimeout",void 0),this.disposables=new te,this.channelDisposables=new te,this.rendererDisposables=new te,this.channelInitialization=new Date,this.videoElement=new _(null),this.state=new _(Ie.Initializing),this.autoMuted=new _(!1),this.autoPaused=new _(!1),this.authorized=new _(!0),this.online=new _(!0),this.loading=new _(!1),this.playing=new _(!1),this.standby=new _(!1),this.stopped=new _(!1),this.targetLag=new _(null!==(r=null==n?void 0:n.targetLag)&&void 0!==r?r:0),this.lag=new _(void 0),this.bitrateLimit=new _(0),this.resolution=new _(Pe.empty),this.failureCount=new _(0),this.endPoint=new _(null),this.stream=new _(null),this.rtcStatistics=new _(null),this.videoTelemetry=null,this.rtcAudioStatistic=null,this.rtcVideoStatistic=null,this.clearFailureCountTimeout=0}),[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":return this.authorized.value=!1,this.failureCount.value=0,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);case"no-stream":case"not-found":return this.failureCount.value=0,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null)}}},{key:"applySessionAndStreamPropertiesToVideoElement",value:function(){this.videoElement.value&&this.videoElement.value.dataset&&(this.videoElement.value.dataset.sessionId=Te.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return Ie.Starting;case"no-stream":case"not-found":return Ie.StandBy;case"geo-restricted":return Ie.GeoRestricted;case"geo-blocked":return Ie.GeoBlocked;case"unauthorized":return Ie.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Ie.Recovering;case"forbidden-tag":return Ie.ConfigurationError;case"port-in-range-not-found":return Ie.TransientConfigurationError;case"failed":return Ie.Error;default:G(e)}}}])}(),je=function(){return o()((function e(){throw t()(this,e),new Error("EncodedStreamSink is a static class that may not be instantiated")}),null,[{key:"validateEncodedStreamSink",value:function(e,t){return"function"!=typeof t?{valid:!1,validationResult:"Unexpected ".concat(e," Encoded Stream Sink function type. Found [").concat(ve()(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"}}}])}(),ze=function(){return o()((function e(){t()(this,e)}),null,[{key:"validateMediaStreamTrackTransform",value:function(e,t){return"function"!=typeof t?{valid:!1,validationResult:"Unexpected ".concat(e," Media Stream Track transform function type. Found [").concat(ve()(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"}}}])}(),He=o()((function e(n){t()(this,e),s()(this,"hasInsertableStreams",void 0),s()(this,"hasEncodedInsertableStreams",void 0),s()(this,"videoStreamTransformCallback",void 0),s()(this,"audioStreamTransformCallback",void 0),s()(this,"encodedVideoStreamSink",void 0),s()(this,"encodedAudioStreamSink",void 0),this.hasInsertableStreams=new _(n.hasInsertableStreams),this.hasEncodedInsertableStreams=new _(n.hasEncodedInsertableStreams),this.videoStreamTransformCallback=n.videoStreamTransformCallback,this.audioStreamTransformCallback=n.audioStreamTransformCallback,this.encodedVideoStreamSink=n.encodedVideoStreamSink,this.encodedAudioStreamSink=n.encodedAudioStreamSink})),Ge=o()((function e(){t()(this,e),s()(this,"mediaStream",void 0),s()(this,"peerConnection",void 0),s()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new _(null),this.peerConnection=new _(null),this.peerConnectionReconnectAttempts=0})),We=o()((function e(){t()(this,e),s()(this,"isStarting",void 0),s()(this,"isDisposed",void 0),this.isStarting=new _(!1),this.isDisposed=!1})),qe=o()((function e(){t()(this,e),s()(this,"shouldExtractTimecode",void 0),s()(this,"shouldExtractTimestamps",void 0),s()(this,"isEnabled",void 0),s()(this,"decodedFrameTimingInformation",void 0),s()(this,"renderedFrameTimingInformation",void 0),this.shouldExtractTimecode=new _(!1),this.shouldExtractTimestamps=new _(!1),this.isEnabled=new _(!1),this.decodedFrameTimingInformation=new _(null),this.renderedFrameTimingInformation=new _(null)})),Je=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Ve.Normal:return"Normal";case Ve.Force:return"Force";case Ve.Reset:return"Reset";default:G(e)}}}])}(),Ke=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Ne.Keep:return"Keep";case Ne.Reset:return"Reset";default:G(e)}}}])}(),Ze=n(981).A,Qe=function(){return o()((function e(n,r){if(t()(this,e),s()(this,"_logger",$.getLogger("EndPoint")),s()(this,"_uri",void 0),s()(this,"_timeout",void 0),s()(this,"_roundTripTime",0),this._uri=n,this._timeout=r,!r)throw new Error("End point requires a timeout")}),[{key:"roundTripTime",get:function(){return this._roundTripTime}},{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:(m=M()(V().mark((function e(){var t,n,r,i,o=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,Ze.race([w.value.fetch(t,{method:"GET",cache:"no-cache"}),new Ze((function(e,n){return w.value.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 m.apply(this,arguments)})},{key:"subscribe",value:(f=M()(V().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,p,f,m,v=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=ee.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 w.value.FormData,s=B.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,Ze.race([w.value.fetch(o,{method:"POST",body:a}),new Ze((function(e){return h=w.value.setTimeout((function(){v._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(o,"]"))),e({status:408})}),v._timeout)}))]).finally((function(){h&&w.value.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 m=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",m,f-l),e.abrupt("return",m);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n){return f.apply(this,arguments)})},{key:"publish",value:(p=M()(V().mark((function e(t,n,r,i){var o,a,s,u,c,l,d,h,p,f,m,v,g=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=ee.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 w.value.FormData,u=B.sdkVersion,0===i&&r?(c={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:7,sessionDescription:{type:r.type,sdp:r.sdp}},createAnswerDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(c))):(l={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(l))),d=Date.now(),e.prev=9,p=null,e.next=13,Ze.race([w.value.fetch(a,{method:"POST",body:s}),new Ze((function(e){return p=w.value.setTimeout((function(){g._logger.error("Failed to publish",new Error("Publish timed out [".concat(a,"]"))),e({status:408})}),g._timeout)}))]).finally((function(){p&&w.value.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 m=Date.now(),e.next=26,this.convertHttpResponseToPublishResponse(o,h);case 26:return v=e.sent,this._logger.debug("Got publish response [%j] in [%s] ms",v,m-d),e.abrupt("return",v);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=M()(V().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return V().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 w.value.FormData,o={apiVersion:7,sharedSecret:null==t?void 0:t.sharedSecret,sessionDescription:{type:n.type,sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,Ze.race([w.value.fetch(r,{method:"POST",body:i}),new Ze((function(e){return u=w.value.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&&w.value.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=M()(V().mark((function e(t,n,r,i,o){var a,s,u,c,l,d,h,p,f=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new w.value.FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:Ke.convertBitrateStateToBitrateStateType(i),bitrateMode:Je.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,d=null,e.next=9,Ze.race([w.value.fetch(a,{method:"POST",body:s}),new Ze((function(e){return d=w.value.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&&w.value.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:(l=M()(V().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,p,f=this,m=arguments;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=m.length>3&&void 0!==m[3]?m[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),a=new w.value.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,Ze.race([w.value.fetch(o,{method:"POST",body:a}),new Ze((function(e){return l=w.value.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&&w.value.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 l.apply(this,arguments)})},{key:"destroyStream",value:(c=M()(V().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new w.value.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,Ze.race([w.value.fetch(r,{method:"POST",body:i,cache:"no-cache"}),new Ze((function(e){return u=w.value.setTimeout((function(){h._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&w.value.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 c.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(u=M()(V().mark((function e(t,n){var r,i,o,a;return V().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 w.value.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 u.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new w.value.URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,_e()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new w.value.URL(this._uri),t=B.sdkVersion,n=de.discoveryParameters.intentions;return e.searchParams.set("type","http"),e.searchParams.set("version",t),e.searchParams.set("intentions",n),e.searchParams.set("_","".concat(Date.now())),e.toString()}},{key:"mapHttpStatusToPublishStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 406:return"missing-channel-or-room-id";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSubscribeStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetRemoteDescriptionStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetTemporaryMaximalBitrateStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToAddIceCandidatesStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetDestroyStreamStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"convertHttpResponseToSubscribeResponse",value:(a=M()(V().mark((function e(t,n){var r,i;return V().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},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 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(i=M()(V().mark((function e(t,n){var r,i;return V().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 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={iceServers:[]};if(e.bundlePolicy&&(t.bundlePolicy=e.bundlePolicy),"number"==typeof e.iceCandidatePoolSize&&(t.iceCandidatePoolSize=e.iceCandidatePoolSize),e.iceServers){for(var n=[],r=0;r<e.iceServers.length;r++)n.push({urls:e.iceServers[r].urls,username:e.iceServers[r].username,credential:e.iceServers[r].credential});t.iceServers=n}return e.iceTransportPolicy&&(t.iceTransportPolicy=e.iceTransportPolicy),e.rtcpMuxPolicy&&(t.rtcpMuxPolicy=e.rtcpMuxPolicy),t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(r=M()(V().mark((function e(t){var n,r;return V().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 r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(n=M()(V().mark((function e(t){var n,r;return V().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 n.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(e=M()(V().mark((function e(t){var n,r;return V().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,n,r,i,a,u,c,l,d,h,p,f,m}(),$e=n(981).A,Xe=function(){return o()((function e(n){if(t()(this,e),s()(this,"_logger",$.getLogger("Discovery")),s()(this,"_metricsService",void 0),s()(this,"_uri",void 0),!n)throw new Error("Discovery requires uri");this._metricsService=xe.getMetricsService(n.toString()),this._uri=n}),[{key:"discoverNearbyEndPoints",value:(n=M()(V().mark((function e(t,n){var r,i,o,a;return V().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,$e.race([w.value.fetch(r,{method:"GET",cache:"no-cache"}),new $e((function(e,t){return w.value.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 Qe(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=M()(V().mark((function e(){var t,n,r,i,o,a,s=this,u=arguments;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=he.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new w.value.URL(n),t);case 4:return r=e.sent,i=0,o=function(){return new $e((function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))}))},e.next=9,$e.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:Ce.RoundTripTime,runtime:(n-Te.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,n}(),Ye=n(981).A,et=function(){function e(){throw t()(this,e),new Error("Discovery is a static class that may not be instantiated")}return o()(e,null,[{key:"precacheClosestEndPointDiscovery",value:(r=M()(V().mark((function t(){return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Ye((function(t){w.subscribe((function(n){if(n){var r=new n.URL(Te.discoveryUri.value);return e.discoverClosestEndPointWithCaching(r).then(t)}}))})));case 1:case"end":return t.stop()}}),t)}))),function(){return r.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(n=M()(V().mark((function t(n){var r,i,o;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((r=n.toString())in e._cache)){t.next=3;break}return t.abrupt("return",e._cache[r]);case 3:return i=new Xe(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then((function(){w.value.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 n.apply(this,arguments)})},{key:"clearCachedClosestEndpoint",value:function(t){var n=t.toString();n in e._cache&&delete e._cache[n]}}]);var n,r}();s()(et,"_cache",{}),et.precacheClosestEndPointDiscovery();var tt=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 nt(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 rt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?nt(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var it=function(){return o()((function e(n,r,i,o,a,u){t()(this,e),s()(this,"_logger",$.getLogger("WebPlayer")),s()(this,"_videoElement",void 0),s()(this,"_kind",void 0),s()(this,"_streamId",void 0),s()(this,"_manifestURI",void 0),s()(this,"_options",void 0),s()(this,"_handleStreamFailure",void 0),s()(this,"_player",void 0),s()(this,"_lastReloadTime",void 0),this._videoElement=n,this._kind=r,this._streamId=i,this._manifestURI=encodeURI(o).replace(/[#]/g,"%23"),this._options=a,this._player=null,this._lastReloadTime=0,this._handleStreamFailure=u}),[{key:"start",value:function(){var e=this;if(ht.phenixWebPlayer){var t,n,r=rt(rt({},this._options),{},{bandwidthToStartAt:3e6});return this._player=new ht.phenixWebPlayer.WebPlayer(this._logger,this._videoElement,r),null===(t=this._player)||void 0===t||t.start(this._manifestURI),void(null===(n=this._player)||void 0===n||n.addEventListener("error",(function(t){e.canReload()&&t&&(3===t.code||t.severity===ht.phenixWebPlayer.errors.severity.RECOVERABLE)&&(e._logger.warn("Reloading unhealthy stream after error event [%j]",t),e.reloadIfAble()),e._logger.error("Cannot reload with error [%j]",t),e._handleStreamFailure()})))}}},{key:"isSupported",value:function(){return ht.phenixWebPlayer&&ht.phenixWebPlayer.isSupported}},{key:"getStats",value:function(){var e,t;if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:tt.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=tt.NetworkLoading:n.currentTime>0?n.networkState=tt.NetworkIdle:n.video?n.networkState=tt.NetworkEmpty:n.networkState=tt.NetworkNoSource,n}},{key:"dispose",value:function(){this._player&&this._player.dispose(),this._player=null}},{key:"canReload",value:function(){var e=!this._lastReloadTime||Date.now()-this._lastReloadTime>15e3;return!!this._videoElement&&!!this._player&&0!==this._videoElement.buffered.length&&e}},{key:"reloadIfAble",value:function(){this.canReload()&&(this._logger.warn("[%s] Reloading unhealthy stream that was active for at least [%s] seconds",this._streamId,15),this._lastReloadTime=Date.now(),this.reload())}},{key:"reload",value:function(){this._player&&this._player.dispose(),this._player=null,this.start()}}])}();function ot(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 at(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ot(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ot(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var st=function(){return o()((function e(n,r,i,o,a,u){t()(this,e),s()(this,"_logger",$.getLogger("ShakaPlayer")),s()(this,"_videoElement",void 0),s()(this,"_kind",void 0),s()(this,"_streamId",void 0),s()(this,"_manifestURI",void 0),s()(this,"_options",void 0),s()(this,"_handleStreamFailure",void 0),s()(this,"_disposables",void 0),s()(this,"_monitoredStatistics",void 0),s()(this,"_player",void 0),this._videoElement=n,this._kind=r,this._streamId=i,this._manifestURI=encodeURI(o).replace(/[#]/g,"%23"),this._options=a,this._handleStreamFailure=u,this._disposables=new te,this._monitoredStatistics={estimatedBandwidth:0,playTime:0},this._player=null}),[{key:"start",value:function(){if(ht.shaka)return this._player=new ht.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:tt.NetworkNoSource,dataBuffered:0};var e=at(at({},this._player.getStats()),{},{currentTime:0,lag:0}),t=this._videoElement.currentTime||0,n=(Date.now()-this._options.originStartTime)/1e3,r=Math.max(0,n-t);return this._videoElement&&(e.currentTime=t,e.lag=r,this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0))),e.estimatedBandwidth&&(e.estimatedBandwidth&&e.estimatedBandwidth>0&&this._monitoredStatistics.estimatedBandwidth&&this._monitoredStatistics.estimatedBandwidth<e.estimatedBandwidth?e.networkState=tt.NetworkLoading:e.playTime&&e.playTime>0&&this._monitoredStatistics.playTime&&this._monitoredStatistics.playTime<e.playTime?e.networkState=tt.NetworkIdle:e.video?e.networkState=tt.NetworkEmpty:e.networkState=tt.NetworkNoSource),this._monitoredStatistics.estimatedBandwidth=e.estimatedBandwidth,this._monitoredStatistics.playTime=e.playTime,e}},{key:"dispose",value:function(){this._disposables.dispose(),this._player&&(this._player.unload(),this._player.destroy()),this._player=null}},{key:"loadPlayer",value:function(e){var t,n,r,i=this;null===(t=this._player)||void 0===t||t.configure(e);var o=function(){return i._handleStreamFailure()};null===(n=this._player)||void 0===n||n.addEventListener("error",o),this._disposables.add(new f((function(){var e;return null===(e=i._player)||void 0===e?void 0:e.removeEventListener("error",o)}))),null===(r=this._player)||void 0===r||r.load(this._manifestURI).then((function(){i._logger.info("[%s] DASH live stream has been loaded",i._streamId),i._videoElement.play&&i._videoElement.play()})).catch((function(e){i._logger.error("[%s] Error while loading DASH live stream [%s]",i._streamId,e.code,e)}))}}])}(),ut=function(){return o()((function e(n,r,i,o,a){t()(this,e),s()(this,"_videoElement",void 0),s()(this,"_kind",void 0),s()(this,"_streamId",void 0),s()(this,"_manifestURI",void 0),s()(this,"_options",void 0),s()(this,"_player",void 0),this._videoElement=n,this._kind=r,this._streamId=i,this._manifestURI=encodeURI(o).replace(/[#]/g,"%23"),this._options=a,this._player=null}),[{key:"start",value:function(){ht.hlsPlayer&&(ht.hlsPlayer.isSupported()?(this._player=new ht.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 ht.hlsPlayer&&ht.hlsPlayer.isSupported()}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:tt.NetworkNoSource,dataBuffered:0};var e={width:this._player.media.offsetWidth,height:this._player.media.offsetHeight,currentTime:this._player.media.currentTime,lag:0,networkState:tt.NetworkIdle,dataBuffered:0};this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0)),"IDLE"===this._player.streamController.state?e.networkState=tt.NetworkIdle:"ERROR"===this._player.streamController.state||"ENDED"===this._player.streamController.state?e.networkState=tt.NetworkNoSource:this._player.streamController.state.includes("LOADING")||this._player.streamController.state.includes("WAITING")?e.networkState=tt.NetworkLoading:e.networkState=tt.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)}}])}(),ct=n(981).A;function lt(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 dt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?lt(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ht=function(){return o()((function e(){t()(this,e)}),null,[{key:"hlsPlayer",get:function(){return this._hlsPlayer}},{key:"phenixWebPlayer",get:function(){return this._phenixWebPlayer}},{key:"shaka",get:function(){return this._shaka}},{key:"start",value:(n=M()(V().mark((function e(t,n,r,i,o){var a=this;return V().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,o));case 3:if(Te.webPlayerLoader||Te.shakaPlayerLoader||Te.hlsJsLoader){e.next=5;break}throw new Error("Unsupported-feature, add stream player");case 5:return e.abrupt("return",new ct((function(e){Te.hlsJsLoader&&(a._pending=!0,Te.hlsJsLoader((function(i){a._hlsPlayer=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))}))),Te.webPlayerLoader&&(a._pending=!0,Te.webPlayerLoader((function(i){a._phenixWebPlayer=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))}))),Te.shakaPlayerLoader&&(a._pending=!0,Te.shakaPlayerLoader((function(i){a._shaka=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))})))})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i,o){return n.apply(this,arguments)})},{key:"getStats",value:function(){return this._player?this._player.getStats():null}},{key:"play",value:(e=M()(V().mark((function e(t,n,r,i,o,a){var s,u,c,l;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=i.match(/a=x-playlist:([^\n]*[.]mpd\??[^\s]*)/m),u=i.match(/a=x-playlist:([^\n]*[.]m3u8\??[^\s]*)/m),c=s&&s[1]?s[1]:"",!(l=u&&u[1]?u[1]:"")){e.next=9;break}if(this._phenixWebPlayer&&!P.shouldUseNativeHls){e.next=9;break}return this._player=new t(n,"hls",r,l,o,a),this._player.start(),e.abrupt("return",this._player);case 9:if(!c){e.next=14;break}if(this._hlsPlayer||this._phenixWebPlayer&&P.shouldUseNativeHls){e.next=14;break}return this._player=new t(n,"dash",r,c,o,a),this._player.start(),e.abrupt("return",this._player);case 14:if(!c&&!l){e.next=16;break}throw new Error("[".concat(r,"] Cannot play [").concat(l?"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,a){return e.apply(this,arguments)})},{key:"loaded",value:function(e,t,n,r){return this._hlsPlayer?this.play(ut,e,t,n,dt(dt({},this._options),{},{preferNative:P.shouldUseNativeHls}),r):this._phenixWebPlayer?this.play(it,e,t,n,dt(dt({},this._options),{},{preferNative:P.shouldUseNativeHls}),r):this.play(st,e,t,n,dt(dt({},this._options),{},{preferNative:P.shouldUseNativeHls}),r)}}]);var e,n}();s()(ht,"_pending",!1),s()(ht,"_hlsPlayer",void 0),s()(ht,"_phenixWebPlayer",void 0),s()(ht,"_shaka",void 0),s()(ht,"_options",void 0),s()(ht,"_player",void 0);var pt=function(e){return e[e.Live=1]="Live",e[e.OndDemand=2]="OndDemand",e}(pt||{}),ft=pt,mt=function(){return o()((function e(n,r,i){t()(this,e),s()(this,"_logger",$.getLogger("ChunkedStream")),s()(this,"_channelContext",void 0),s()(this,"_chunkedStreamPlaybackMode",void 0),s()(this,"_disposables",new te),s()(this,"_monitorDisposables",new te),s()(this,"_handleStreamFailure",void 0),s()(this,"_streamStatistics",null),s()(this,"_monitorFailureCount",0),this._channelContext=n,this._chunkedStreamPlaybackMode=r,this._handleStreamFailure=i,this._channelContext.disposables.add(this)}),[{key:"start",value:function(e,t){var n=this;return et.discoverClosestEndPointWithCaching(e).then((function(e){return n._channelContext.online.value=!0,n._channelContext.endPoint.value=e,n._logger.info("Connecting to [%s]",e.toString()),e.subscribe(t,null,n._channelContext.failureCount.value)})).then((function(e){var t,r=e.status,i=n._channelContext.endPoint.value;if(!i)return n._logger.error("Subscribe failed: end point service is missing"),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,void(n._channelContext.state.value=Ie.Error);if(n._channelContext.state.value=n._channelContext.mapSubscribeStatusToChannelStatus(r),n._channelContext.applyStatus(r),"ok"!==r)return n._channelContext.stream.value=null,n._channelContext.lag.value=void 0,n._channelContext.applySessionAndStreamPropertiesToVideoElement(),void n._logger.debug("[%s] Subscribe failed with status [%s]",n._channelContext.streamId,r);var o=e.stream,a=e.createOfferDescriptionResponse,s=e.lag;n._channelContext.stream.value=o,n._channelContext.lag.value=s,n._channelContext.applySessionAndStreamPropertiesToVideoElement(),n._logger.debug("[%s] Subscribe completed [%s] [%j]",n._channelContext.streamId,r,a);var u=null==a||null===(t=a.sessionDescription)||void 0===t?void 0:t.sdp,c={originStartTime:Date.now()-s+i.roundTripTime/2,lag:s};return n._channelContext.videoElement.value?u?ht.start(n._channelContext.videoElement.value,n._channelContext.streamId,u,c,(function(){return n.retryOnStreamFailure()})).then((function(e){return n.monitor(e),n._disposables.add(e),e})).catch((function(e){n._logger.error("ChunkedStreaming failed",e),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,n._channelContext.state.value=Ie.Stopped})):(n._logger.error("Subscribe failed: offer SDP is missing"),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,void(n._channelContext.state.value=Ie.Error)):(n._logger.error("Subscribe failed: video element is missing"),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,void(n._channelContext.state.value=Ie.Stopped))}))}},{key:"retryOnStreamFailure",value:function(){var e=this;this._monitorFailureCount=0,this._channelContext.state.value=Ie.ConnectionError,this._channelContext.playing.value=!1,this._channelContext.loading.value=!0,this._disposables.dispose(),this._monitorDisposables.dispose(),this._handleStreamFailure().catch((function(t){e._logger.error("Failed handling stream failure",t)}))}},{key:"monitor",value:function(e){var t=this;this._monitorDisposables.dispose();var n=w.value.setTimeout((function(){var n,r,i,o,a,s=ht.getStats();if(t._chunkedStreamPlaybackMode!==ft.Live||(null==s?void 0:s.networkState)!==tt.NetworkNoSource||(null===(n=t._channelContext.videoElement.value)||void 0===n?void 0:n.currentTime)!==(null===(r=t._channelContext.videoElement.value)||void 0===r?void 0:r.duration)){if(t._streamStatistics&&(null===(i=t._channelContext.videoElement.value)||void 0===i||!i.paused)&&null!=s&&s.currentTime&&t._streamStatistics.currentTime>=s.currentTime&&(null==s||!s.dataBuffered||t._streamStatistics.dataBuffered>=s.dataBuffered)){if(t._monitorFailureCount++,t._monitorFailureCount>4)return void t.retryOnStreamFailure()}else t._monitorFailureCount=0;null!==(o=t._channelContext.videoElement.value)&&void 0!==o&&o.paused&&t._channelContext.state.value===Ie.Playing&&(t._channelContext.state.value=Ie.Paused),null!==(a=t._channelContext.videoElement.value)&&void 0!==a&&a.paused||t._channelContext.state.value===Ie.Playing||(t._channelContext.state.value=Ie.Playing),t._streamStatistics=s,t.monitor(e)}else t.retryOnStreamFailure()}),1e3);this._monitorDisposables.add(new f((function(){w.value.clearTimeout(n)})))}},{key:"dispose",value:function(){this._disposables.dispose(),this._monitorDisposables.dispose()}}])}(),vt=n(715),gt=n.n(vt),_t=function(){return o()((function e(n){t()(this,e),s()(this,"_sdp",void 0),s()(this,"_audioCodec",void 0),s()(this,"_videoCodec",void 0),s()(this,"_isAudioTrackEnabled",void 0),s()(this,"_isVideoTrackEnabled",void 0),this._sdp=n;var r=this._sdp.split(/(\r\n|\r|\n)/),i=this._sdp.split(/(?:^|[\r\n])m=/);this._audioCodec=this.applyCodec("audio",r),this._videoCodec=this.applyCodec("video",r),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",i),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",i)}),[{key:"audioCodec",get:function(){return this._audioCodec}},{key:"videoCodec",get:function(){return this._videoCodec}},{key:"isAudioTrackEnabled",get:function(){return this._isAudioTrackEnabled}},{key:"isVideoTrackEnabled",get:function(){return this._isVideoTrackEnabled}},{key:"isTrackByTypeEnabled",value:function(e,t){var n=t.find((function(t){return t.startsWith(e)}));return!!n&&!n.includes("a=inactive")}},{key:"applyCodec",value:function(e,t){var n,r=(null===(n=t.find((function(t){return t.includes("m=".concat(e))})))||void 0===n?void 0:n.split(" ")[3])||"",i=t.find((function(e){return e.includes("a=rtpmap:".concat(r))}));return((null==i?void 0:i.split(" ")[1])||"").split("/")[0]}}])}(),yt=function(){return o()((function e(){throw t()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")}),null,[{key:"truncateIceServers",value:function(e){var t=[];if(!e.iceServers)return e;for(var n=0;n<e.iceServers.length;n++){for(var r=[],i=0;i<2;i++)e.iceServers[n].urls[i]&&r.push(e.iceServers[n].urls[i]);t.push({urls:r,username:e.iceServers[n].username,credential:e.iceServers[n].credential})}return e.iceServers=t,e}}])}(),bt=function(){return o()((function e(n,r,i){if(t()(this,e),s()(this,"_estimatedRoundTripTime",void 0),s()(this,"_estimatedVideoCodec","unknown"),s()(this,"_estimatedAudioCodec","unknown"),s()(this,"_rtcStatistic",new _({})),s()(this,"_peerConnection",void 0),s()(this,"_isMonitorRunning",!0),s()(this,"_updateTimeout",null),s()(this,"_tracksToMonitor",void 0),this._peerConnection=n,this._estimatedRoundTripTime=i,this._tracksToMonitor=r.getTracks().map((function(e){return e.kind}))||[],this._peerConnection){var o,a;if(!P.getCurrentOfferDisabled&&null!==(o=this._peerConnection)&&void 0!==o&&null!==(a=o.currentRemoteDescription)&&void 0!==a&&a.sdp){var u=new _t(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=u.audioCodec,this._estimatedVideoCodec=u.videoCodec}this.updateStatistic()}}),[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(w.value.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(n=M()(V().mark((function e(){var t,n,r=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!P.getStatsPromiseBasedDisabled){e.next=5;break}return e.next=3,this.updateStatisticLegacy();case 3:return e.sent,e.abrupt("return");case 5:return n=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=8,null===(t=this._peerConnection)||void 0===t?void 0:t.getStats(null).then((function(e){var t={};if(e){var i,o=r._estimatedRoundTripTime;e.forEach((function(a){if("candidate-pair"===a.type&&a.currentRoundTripTime&&(o=1e3*a.currentRoundTripTime,t.audio&&(t.audio.roundTripTime=o),t.video&&(t.video.roundTripTime=o)),"candidate-pair"===a.type&&a.lastPacketReceivedTimestamp&&(i=a.lastPacketReceivedTimestamp,t.audio&&(t.audio.lastPacketReceivedTimestamp=i),t.video&&(t.video.lastPacketReceivedTimestamp=i)),"inbound-rtp"===a.type){var s=a.kind||a.mediaType||n(a),u="";if(e.forEach((function(e){e.id===a.codecId&&(u=e.mimeType)})),s&&r._tracksToMonitor.includes(s)){var c,l,d,h,p,f,m,v=(a.bytesReceived||0)-(null!==(c=null===(l=r._rtcStatistic.value)||void 0===l||null===(d=l[s])||void 0===d?void 0:d.bytesReceived)&&void 0!==c?c:0),g=a.timestamp-((null===(h=r._rtcStatistic.value)||void 0===h||null===(p=h[s])||void 0===p?void 0:p.timestamp)||0),_=v&&g?Math.floor(8*v/g*1e3):0;if(t[s]={ssrc:a.ssrc,mediaType:s,timestamp:a.timestamp,bitrate:_,bytesReceived:a.bytesReceived,packetsLost:a.packetsLost,packetsReceived:a.packetsReceived,codec:u||r.getCodecByType(s),roundTripTime:o},(a.lastPacketReceivedTimestamp||i)&&(t[s].lastPacketReceivedTimestamp=a.lastPacketReceivedTimestamp||i),"video"===s&&null!==(f=r._rtcStatistic.value)&&void 0!==f&&null!==(m=f.video)&&void 0!==m&&m.framesDecoded){t[s].framesDecoded=a.framesDecoded;var y=(a.framesDecoded-r._rtcStatistic.value.video.framesDecoded)/(t[s].timestamp-r._rtcStatistic.value.video.timestamp)*1e3;t[s].fps=y?Math.round(100*y)/100:0}}}}))}r._rtcStatistic.value=t})).then((function(){r._isMonitorRunning&&(r._updateTimeout=w.value.setTimeout((function(){return r.updateStatistic()}),1e3))}));case 8:e.sent;case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"updateStatisticLegacy",value:(e=M()(V().mark((function e(){var t,n=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this._peerConnection)||void 0===t?void 0:t.getStatsLegacy().then((function(e){var t={},r=n._estimatedRoundTripTime;e.result().forEach((function(e){if(e.names().forEach((function(t){"googRTT"===t&&(r=e.stat(t))})),"ssrc"===e.type){var i,o,a=e.stat("mediaType").toString();t[a]={timestamp:Date.now()},t[a].ssrc=e.stat("ssrc").toString(),t[a].mediaType=a,t[a].bytesReceived=e.stat("bytesReceived"),t[a].packetsLost=e.stat("packetsLost"),t[a].packetsReceived=e.stat("packetsReceived"),t[a].codec=e.stat("googCodecName").toString()||n.getCodecByType(a),t[a].roundTripTime=r,"video"===a&&null!==(i=n._rtcStatistic.value)&&void 0!==i&&null!==(o=i.video)&&void 0!==o&&o.framesDecoded&&(t[a].framesDecoded=e.stat("framesDecoded"),t[a].fps=(t[a].framesDecoded-n._rtcStatistic.value.video.framesDecoded)/(t[a].timestamp-n._rtcStatistic.value.video.timestamp)*1e3||0)}})),n._rtcStatistic.value=t})).then((function(){n._isMonitorRunning&&(n._updateTimeout=w.value.setTimeout((function(){return n.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||"unknown";case"video":return this._estimatedVideoCodec||"unknown";default:return"unknown"}}}]);var e,n}(),Ct=function(e){return e[e.BufferingPeriod=0]="BufferingPeriod",e[e.PictureTiming=1]="PictureTiming",e[e.PanScanRect=2]="PanScanRect",e[e.FillerPayload=3]="FillerPayload",e[e.UserDataRegistered=4]="UserDataRegistered",e[e.UserDataUnregistered=5]="UserDataUnregistered",e[e.RecoveryPoint=6]="RecoveryPoint",e[e.DecRefPicMarkingRepeition=7]="DecRefPicMarkingRepeition",e[e.SparePic=8]="SparePic",e[e.SceneInfo=9]="SceneInfo",e[e.SubSeqInfo=10]="SubSeqInfo",e[e.SubSeqLayerCharacteristics=11]="SubSeqLayerCharacteristics",e[e.SubSeqCharacteristics=12]="SubSeqCharacteristics",e[e.FullFrameFreeze=13]="FullFrameFreeze",e[e.FullFrameFreezeRelease=14]="FullFrameFreezeRelease",e[e.FullFrameSnapshot=15]="FullFrameSnapshot",e[e.ProgressiveRefinementSegmentStart=16]="ProgressiveRefinementSegmentStart",e[e.ProgressiveRefinementSegmentEnd=17]="ProgressiveRefinementSegmentEnd",e[e.MotionConstrainedSliceGroupSet=18]="MotionConstrainedSliceGroupSet",e[e.FilmGrainCharacteristic=19]="FilmGrainCharacteristic",e[e.DeblockingFilterDisplayReference=20]="DeblockingFilterDisplayReference",e[e.StereoVideoInfo=21]="StereoVideoInfo",e[e.PostFilterHint=22]="PostFilterHint",e[e.ToneMappingInfo=23]="ToneMappingInfo",e[e.ScalabilityInfo=24]="ScalabilityInfo",e[e.SubPicScalableLayer=25]="SubPicScalableLayer",e[e.NonRequiredLayerRep=26]="NonRequiredLayerRep",e[e.PariorityLayerInfo=27]="PariorityLayerInfo",e[e.LayersNotPresent=28]="LayersNotPresent",e[e.LayerDependencyChange=29]="LayerDependencyChange",e[e.ScalableNesting=30]="ScalableNesting",e[e.BaseLayerTemporalHrd=31]="BaseLayerTemporalHrd",e[e.QualityLayerIntegrityCheck=32]="QualityLayerIntegrityCheck",e[e.RedundantPicProperty=33]="RedundantPicProperty",e[e.Tl0DepRepIndex=34]="Tl0DepRepIndex",e[e.TlSwitchingPoint=35]="TlSwitchingPoint",e[e.ParallelDecodingInfo=36]="ParallelDecodingInfo",e[e.MvcScalableNesting=37]="MvcScalableNesting",e[e.ViewScalabilityInfo=38]="ViewScalabilityInfo",e[e.MultiviewSceneInfo=39]="MultiviewSceneInfo",e[e.MultiviewAcquisitionInfo=40]="MultiviewAcquisitionInfo",e[e.NonRequiredViewComponent=41]="NonRequiredViewComponent",e[e.ViewDependencyChange=42]="ViewDependencyChange",e[e.OperationPointsNotPresent=43]="OperationPointsNotPresent",e[e.BaseViewTemporalHdr=44]="BaseViewTemporalHdr",e[e.FramePackingArrangement=45]="FramePackingArrangement",e[e.MultiviewViewPosition=46]="MultiviewViewPosition",e[e.DisplayOrientation=47]="DisplayOrientation",e[e.MvcdScalableNesting=48]="MvcdScalableNesting",e[e.MvcdViewScalabilityInfo=49]="MvcdViewScalabilityInfo",e[e.DepthRepresentationInfo=50]="DepthRepresentationInfo",e[e.ThreeDimensionalReferenceDisplaysInfo=51]="ThreeDimensionalReferenceDisplaysInfo",e[e.DepthTiming=52]="DepthTiming",e[e.DepthSamplingInfo=53]="DepthSamplingInfo",e[e.ConstrainedDepthParameterSetIdentifier=54]="ConstrainedDepthParameterSetIdentifier",e[e.GreenMetadata=55]="GreenMetadata",e[e.MasteringDisplayColourVolumev=56]="MasteringDisplayColourVolumev",e[e.ColourRemappingInfo=57]="ColourRemappingInfo",e[e.ContentLightLevelInfo=58]="ContentLightLevelInfo",e[e.AlternativeTransferCharacteristics=59]="AlternativeTransferCharacteristics",e[e.AmbientViewingEnvironment=60]="AmbientViewingEnvironment",e[e.ContentColourVolume=61]="ContentColourVolume",e[e.EquirectangularProjection=62]="EquirectangularProjection",e[e.CubemapProjection=63]="CubemapProjection",e[e.SphereRotation=64]="SphereRotation",e[e.RegionwisePacking=65]="RegionwisePacking",e[e.OmniViewport=66]="OmniViewport",e[e.AlternativeDepthInfo=67]="AlternativeDepthInfo",e[e.SeiManifest=68]="SeiManifest",e[e.SeiPrefixIndication=69]="SeiPrefixIndication",e[e.AnnotatedRegions=70]="AnnotatedRegions",e[e.ShutterIntervalInfo=71]="ShutterIntervalInfo",e}(Ct||{}),kt=Ct,St=function(){return o()((function e(n){t()(this,e),s()(this,"_data",void 0),s()(this,"_bitOffset",void 0),this._data=n,this._bitOffset=0}),[{key:"readBits",value:function(e){if(this._bitOffset+e>8*this._data.length)throw new Error("Cannot read [".concat(e,"] bits - only [").concat(this.getRemainingBits(),"] bits remaining in stream"));for(var t=0,n=e;n>0;){var r=Math.floor(this._bitOffset/8),i=8-this._bitOffset%8,o=Math.min(n,i),a=(1<<o)-1;t=t<<o|this._data[r]>>i-o&a,n-=o,this._bitOffset+=o}return t}},{key:"skipBits",value:function(e){if(this._bitOffset+e>8*this._data.length)throw new Error("Cannot skip [".concat(e,"] bits - only [").concat(this.getRemainingBits(),"] bits remaining in stream"));this._bitOffset+=e}},{key:"getRemainingBits",value:function(){return 8*this._data.length-this._bitOffset}}])}(),xt=function(){return o()((function e(){throw t()(this,e),new Error("EmulationPreventionBytes is a static class that may not be instantiated")}),null,[{key:"getOffsetWithExpandedEmulationPreventionBytes",value:function(e,t,n){for(var r=0,i=0,o=n,a=t;a<e.length&&0!==o;a++,i++)2!==r||3!==e[a]?(0===e[a]?r++:r>0&&(r=0),o--):r=0;return i}},{key:"removeEmulationPreventionBytes",value:function(e){for(var t=new Uint8Array(e.byteLength),n=0,r=0,i=2;i<e.byteLength;i++)3===e[i]&&0===e[i-1]&&0===e[i-2]&&(t.set(e.subarray(r,i),n),n+=i-r,r=i+1);return r<e.byteLength&&t.set(e.subarray(r),n),t}}])}(),wt=function(e){return e[e.ProgressiveFrame=0]="ProgressiveFrame",e[e.TopField=1]="TopField",e[e.BottomField=2]="BottomField",e[e.TopFieldBottomField=3]="TopFieldBottomField",e[e.BottomFieldTopField=4]="BottomFieldTopField",e[e.TopFieldBottomFieldTopFieldRepeated=5]="TopFieldBottomFieldTopFieldRepeated",e[e.BottomFieldTopFieldBottomFieldRepeated=6]="BottomFieldTopFieldBottomFieldRepeated",e[e.FrameDoubling=7]="FrameDoubling",e[e.FrameTripling=8]="FrameTripling",e}(wt||{}),Tt=function(){return o()((function e(){t()(this,e)}),[{key:"parse",value:function(e,t){var n=new St(xt.removeEmulationPreventionBytes(e)),r={picStruct:void 0};if(t.cpbDpbDelaysPresentFlag&&(n.skipBits(t.cpbRemovalDelayLengthMinus1+1),n.skipBits(t.dpbOutputDelayLengthMinus1+1)),t.picStructPresentFlag){var i=this.convertPicStructToNumClockTS(n.readBits(4));r.picStruct={numClockTS:i,clockTimestamps:[]};for(var o=0;o<r.picStruct.numClockTS;o++){var a=1===n.readBits(1);if(a){var s={ctType:n.readBits(2),nuitFieldBasedFlag:1===n.readBits(1),countingType:n.readBits(5),fullTimestampFlag:1===n.readBits(1),discontinuityFlag:1===n.readBits(1),cntDroppedFlag:1===n.readBits(1),nFrames:n.readBits(8)};s.fullTimestampFlag?(s.seconds=n.readBits(6),s.minutes=n.readBits(6),s.hours=n.readBits(5)):1===n.readBits(1)&&(s.seconds=n.readBits(6),1===n.readBits(1)&&(s.minutes=n.readBits(6),1===n.readBits(1)&&(s.hours=n.readBits(5)))),s.timeOffset=n.readBits(24),r.picStruct.clockTimestamps.push({clockTimestampFlag:a,clockTimestamp:s})}else r.picStruct.clockTimestamps.push({clockTimestampFlag:!1})}}return r}},{key:"convertPicStructToNumClockTS",value:function(e){switch(e){case wt.ProgressiveFrame:case wt.TopField:case wt.BottomField:return 1;case wt.TopFieldBottomField:case wt.BottomFieldTopField:case wt.FrameDoubling:return 2;case wt.TopFieldBottomFieldTopFieldRepeated:case wt.BottomFieldTopFieldBottomFieldRepeated:case wt.FrameTripling:return 3;default:return 0}}}])}();function Pt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var Et=function(){return o()((function e(){t()(this,e),s()(this,"_listeners",new Set)}),[{key:"subscribe",value:function(e){var t=this;return this._listeners.add(e),new f((function(){return t._listeners.delete(e)}))}},{key:"emit",value:function(e){var t,n=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Pt(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)?Pt(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(this._listeners);try{for(n.s();!(t=n.n()).done;)(0,t.value)(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"dispose",value:function(){this.cleanUpResources()}},{key:"cleanUpResources",value:function(){this._listeners.clear()}}])}(),Ft=function(){return o()((function e(){t()(this,e),s()(this,"_eventEmitters",new Map),s()(this,"_onEventWithNoSubscriberHandlers",new Set),s()(this,"_disposables",new te)}),[{key:"onEventWithNoSubscriber",value:function(e){var t=this;return this._onEventWithNoSubscriberHandlers.add(e),new f((function(){return t._onEventWithNoSubscriberHandlers.delete(e)}))}},{key:"subscribe",value:function(e,t){var n=(this._eventEmitters.get(e)||this.createEmitter(e)).subscribe(t);return this._disposables.add(n),n}},{key:"publish",value:function(e,t){var n=this._eventEmitters.get(e);n?n.emit(t):this._onEventWithNoSubscriberHandlers.forEach((function(n){return n(e,t)}))}},{key:"dispose",value:function(){this._disposables.dispose(),this.cleanUpResources()}},{key:"cleanUpResources",value:function(){this._eventEmitters.clear(),this._onEventWithNoSubscriberHandlers.clear()}},{key:"createEmitter",value:function(e){var t=new Et;return this._eventEmitters.set(e,t),t}}])}(),It=function(e){return e[e.EncodedVideoStreamChunk=0]="EncodedVideoStreamChunk",e[e.NalUnit=1]="NalUnit",e[e.SeiPayload=2]="SeiPayload",e[e.Payload=3]="Payload",e[e.PayloadSubscription=4]="PayloadSubscription",e[e.EndOfChunk=5]="EndOfChunk",e}({}),Rt=function(){return o()((function e(n){t()(this,e),s()(this,"_eventPublisher",void 0),s()(this,"_disposables",new te),this._eventPublisher=n}),[{key:"subscribeToNalUnit",value:function(e,t){return this._eventPublisher.subscribe(It.NalUnit,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToSeiPayloadType",value:function(e,t){return this._eventPublisher.subscribe(It.SeiPayload,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToPayload",value:function(e,t,n){return this._eventPublisher.publish(It.PayloadSubscription,{context:e,data:t}),this._eventPublisher.subscribe(It.Payload,(function(e){e.data.uuid===t&&n(e)}))}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),Dt=function(){function e(){throw t()(this,e),new Error("Uint8Arrays is a static class that may not be instantiated")}return o()(e,null,[{key:"isDataAtOffsetTargetByteSequence",value:function(e,t,n){for(var r=0;r<e.length;r++)if(e[r]!==t[n+r])return!1;return!0}},{key:"findTargetByteSequenceIndexFromOffset",value:function(t,n,r){for(var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,o=r;o<=n.byteLength;o++)if(e.isDataAtOffsetTargetByteSequence(t,n,o))return o;return i}},{key:"getUuidStringFromUint8Array",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,n=[],r=0;r<t;r++){var i=e[r].toString(16).padStart(2,"0");n.push(i),3!==r&&5!==r&&7!==r&&9!==r||n.push("-")}return n.join("")}}])}(),Ot=function(e){return e[e.Unspecified=0]="Unspecified",e[e.SliceLayerNonIdrData=1]="SliceLayerNonIdrData",e[e.SliceDataPartitionALayer=2]="SliceDataPartitionALayer",e[e.SliceDataPartitionBLayer=3]="SliceDataPartitionBLayer",e[e.SliceDataPartitionCLayer=4]="SliceDataPartitionCLayer",e[e.SliceLayerIdrData=5]="SliceLayerIdrData",e[e.SupplementalEnhancementInformation=6]="SupplementalEnhancementInformation",e[e.SequenceParameterSet=7]="SequenceParameterSet",e[e.PictureParameterSet=8]="PictureParameterSet",e[e.AccessUnitDelimiter=9]="AccessUnitDelimiter",e[e.EndOfSequence=10]="EndOfSequence",e[e.EndOfStream=11]="EndOfStream",e[e.FillerData=12]="FillerData",e[e.SequenceParamterSetExtension=13]="SequenceParamterSetExtension",e[e.PrefixNalUnit=14]="PrefixNalUnit",e[e.SubsetSequenceParamterSet=15]="SubsetSequenceParamterSet",e[e.DepthParamterSet=16]="DepthParamterSet",e[e.Reserved17=17]="Reserved17",e[e.Reserved18=18]="Reserved18",e[e.SliceLayerAuxiliary=19]="SliceLayerAuxiliary",e[e.SliceExtension=20]="SliceExtension",e[e.SliceExtensionDepthViewComponent=21]="SliceExtensionDepthViewComponent",e[e.Reserved22=22]="Reserved22",e[e.Reserverd23=23]="Reserverd23",e[e.Unspecified24=24]="Unspecified24",e[e.Unspecified25=25]="Unspecified25",e[e.Unspecified26=26]="Unspecified26",e[e.Unspecified27=27]="Unspecified27",e[e.Unspecified28=28]="Unspecified28",e[e.Unspecified29=29]="Unspecified29",e[e.Unspecified30=30]="Unspecified30",e[e.Unspecified31=31]="Unspecified31",e}(Ot||{}),Lt=Ot,At=function(){function e(n,r){t()(this,e),s()(this,"_eventPublisher",void 0),s()(this,"_vclExtractionStrategy",void 0),s()(this,"_disposables",new te),this._eventPublisher=n,this._vclExtractionStrategy=r,this._disposables.add(this.subscribeToEncodedVideoStreamChunkEvents())}return o()(e,[{key:"dispose",value:function(){this._disposables.dispose()}},{key:"subscribeToEncodedVideoStreamChunkEvents",value:function(){return this._eventPublisher.subscribe(It.EncodedVideoStreamChunk,this.parseEncodedVideoStreamChunk.bind(this))}},{key:"parseEncodedVideoStreamChunk",value:function(e){for(var t=e.context,n=e.data,r=0;r<n.byteLength;)r+=this.handleExtractedData(t,this.extractNalUnitAtOffset(n,r));this.notifyEndOfChunk(t)}},{key:"handleExtractedData",value:function(e,t){var n=this,r=t.annexBStartCodeLength,i=t.nalUnit,o=t.seiPayloads;return this.publishNalUnit(e,i),null==o||o.forEach((function(t){return n.handleSeiPayload(e,t)})),i.data.byteLength+r}},{key:"handleSeiPayload",value:function(e,t){this.publishSeiPayload(e,t),t.type===kt.UserDataUnregistered&&this.handleSeiPayloadUserDataUnregistered(e,t)}},{key:"handleSeiPayloadUserDataUnregistered",value:function(e,t){var n=Dt.getUuidStringFromUint8Array(t.data.subarray(0,16)),r=t.data.subarray(16);this.publishPayload(e,{uuid:n,data:r})}},{key:"publishNalUnit",value:function(e,t){this._eventPublisher.publish(It.NalUnit,{context:e,data:t})}},{key:"publishSeiPayload",value:function(e,t){this._eventPublisher.publish(It.SeiPayload,{context:e,data:t})}},{key:"publishPayload",value:function(e,t){this._eventPublisher.publish(It.Payload,{context:e,data:t})}},{key:"notifyEndOfChunk",value:function(e){this._eventPublisher.publish(It.EndOfChunk,{context:e,data:null})}},{key:"extractNalUnitAtOffset",value:function(e,t){var n,r=1===e[t+2]?3:4,i=t+r,o=31&e[i];switch(o){case Lt.SliceLayerNonIdrData:case Lt.SliceDataPartitionALayer:case Lt.SliceDataPartitionBLayer:case Lt.SliceDataPartitionCLayer:case Lt.SliceLayerIdrData:n=this._vclExtractionStrategy.extractVclNalUnit(e,i);break;case Lt.SupplementalEnhancementInformation:n=this.extractSeiNalUnit(e,i);break;default:n=this.extractNonVclNalUnit(e,i)}return{annexBStartCodeLength:r,nalUnit:{type:o,data:n.nalUnitData},seiPayloads:n.seiPayloads}}},{key:"extractSeiNalUnit",value:function(t,n){for(var r=n+1,i=[];!Dt.isDataAtOffsetTargetByteSequence(e._seiPayload4ByteEndCode,t,r)&&!Dt.isDataAtOffsetTargetByteSequence(e._seiPayload3ByteEndCode,t,r)&&r<t.byteLength;){var o=this.extractSeiPayload(t,r);i.push({data:o.payload,type:o.payloadType}),r=o.endIndex}return r++,{nalUnitData:t.subarray(n,r),seiPayloads:i}}},{key:"extractNonVclNalUnit",value:function(t,n){var r=e.findAnnexBStartIndexFromOffset(t,n,t.byteLength);return{nalUnitData:t.subarray(n,r)}}},{key:"extractSeiPayload",value:function(e,t){for(var n=t,r=0;255===e[n];)n++,r++;var i=255*r+e[n];for(n++,r=0;255===e[n];)n++,r++;var o=255*r+e[n],a=++n+xt.getOffsetWithExpandedEmulationPreventionBytes(e,n,o);return{payloadType:i,payload:e.subarray(n,a),endIndex:a}}}],[{key:"findAnnexBStartIndexFromOffset",value:function(t,n,r){var i=Dt.findTargetByteSequenceIndexFromOffset(e.annexB4ByteStartCode,t,n,r);return i!==r?i:Dt.findTargetByteSequenceIndexFromOffset(e.annexB3ByteStartCode,t,n,r)}}])}();s()(At,"annexB3ByteStartCode",new Uint8Array([0,0,1])),s()(At,"annexB4ByteStartCode",new Uint8Array([0,0,0,1])),s()(At,"_seiPayload3ByteEndCode",new Uint8Array([128,0,0,1])),s()(At,"_seiPayload4ByteEndCode",new Uint8Array([128,0,0,0,1]));var Mt=function(){return o()((function e(){t()(this,e)}),[{key:"extractVclNalUnit",value:function(e,t){var n=At.findAnnexBStartIndexFromOffset(e,t,e.byteLength);return{nalUnitData:e.subarray(t,n)}}}])}(),Nt=function(){function e(){t()(this,e)}return o()(e,[{key:"extractVclNalUnit",value:function(t,n){var r=n+At.annexB4ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;if(Dt.isDataAtOffsetTargetByteSequence(At.annexB4ByteStartCode,t,r))return{nalUnitData:t.subarray(n+At.annexB4ByteStartCode.byteLength,r)};var i=n+At.annexB3ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;return Dt.isDataAtOffsetTargetByteSequence(At.annexB3ByteStartCode,t,i)?{nalUnitData:t.subarray(n+At.annexB3ByteStartCode.byteLength,i)}:{nalUnitData:t.subarray(n)}}}])}();s()(Nt,"_truncatedVclNalUnitByteLength",32);var Vt=function(){},Ut=function(){function e(n){t()(this,e),s()(this,"_logger",$.getLogger("PhenixEmbeddedIsoBmff2023")),s()(this,"_eventPublisher",void 0),s()(this,"_expectedPayloadUuid",new Set),s()(this,"_endOfChunkHandlersByTrackId",new Map),s()(this,"_disposables",new te),s()(this,"_enableWarningLogWhenVclEmbeddedDataNotFound",new f(this.enableWarningLogWhenVclEmbeddedDataNotFound.bind(this))),this._eventPublisher=n,this._expectedPayloadUuid.add(e._phenixVclEmbeddedDataUuid),this._expectedPayloadUuid.add(e._phenixInitializationSegmentUuid),this._disposables.add(this.subscribeToPayloadEvents()),this._disposables.add(this.subscribeToPayloadSubscriptionEvents()),this._disposables.add(this.subscribeToNalUnitEvents())}return o()(e,[{key:"subscribeToEmbeddedData",value:function(t){return this._enableWarningLogWhenVclEmbeddedDataNotFound.dispose(),this._eventPublisher.subscribe(It.Payload,(function(n){var r=n.context,i=n.data;switch(i.uuid){case e._phenixInitializationSegmentUuid:t({context:r,data:{type:"Initialization",data:i.data}});break;case e._phenixVclEmbeddedDataUuid:t({context:r,data:{type:"Media",data:i.data}})}}))}},{key:"dispose",value:function(){this._disposables.dispose(),this._endOfChunkHandlersByTrackId.clear(),this._expectedPayloadUuid.clear()}},{key:"enableWarningLogWhenVclEmbeddedDataNotFound",value:function(){this._disposables.add(this.subscribeToEncodedVideoStreamChunkEvents()),this._disposables.add(this.subscribeToEndOfChunkEvents())}},{key:"subscribeToPayloadSubscriptionEvents",value:function(){var e=this;return this._eventPublisher.subscribe(It.PayloadSubscription,(function(t){var n=t.data;return e._expectedPayloadUuid.add(n)}))}},{key:"subscribeToEncodedVideoStreamChunkEvents",value:function(){return this._eventPublisher.subscribe(It.EncodedVideoStreamChunk,this.armLoggingNoVclEmbeddedDataFound.bind(this))}},{key:"subscribeToNalUnitEvents",value:function(){return this._eventPublisher.subscribe(It.NalUnit,this.handleNalUnitEvent.bind(this))}},{key:"handleNalUnitEvent",value:function(t){var n=t.context,r=t.data;r.type>Lt.SliceLayerIdrData||r.data.byteLength<e._truncatedVclNalUnitDataByteLength||(this.publishVclEmbeddedPayload(n,{uuid:e._phenixVclEmbeddedDataUuid,data:this.extractVclEmbeddedData(r)}),this.disarmLoggingNoVclEmbeddedDataFound(n.trackId))}},{key:"extractVclEmbeddedData",value:function(t){return t.data.subarray(e._truncatedVclNalUnitDataByteLength)}},{key:"publishVclEmbeddedPayload",value:function(e,t){this._eventPublisher.publish(It.Payload,{context:e,data:t})}},{key:"armLoggingNoVclEmbeddedDataFound",value:function(e){var t=e.context;this._endOfChunkHandlersByTrackId.set(t.trackId,this.logWarningVclEmbeddedDataNotFound.bind(this,t))}},{key:"disarmLoggingNoVclEmbeddedDataFound",value:function(e){this._endOfChunkHandlersByTrackId.set(e,Vt)}},{key:"logWarningVclEmbeddedDataNotFound",value:function(e){this._logger.warn("[%s] [%s] No VCL embedded data found in an encoded video stream chunk from track with id [%s]",e.streamId,e.contextId,e.trackId)}},{key:"subscribeToEndOfChunkEvents",value:function(){return this._eventPublisher.subscribe(It.EndOfChunk,this.handleEndOfEncodedVideoStreamChunk.bind(this))}},{key:"handleEndOfEncodedVideoStreamChunk",value:function(e){var t=e.context;this._endOfChunkHandlersByTrackId.get(t.trackId)()}},{key:"subscribeToPayloadEvents",value:function(){return this._eventPublisher.subscribe(It.Payload,this.handlePayloadEvent.bind(this))}},{key:"handlePayloadEvent",value:function(e){var t=e.context,n=e.data;this._expectedPayloadUuid.has(n.uuid)||w.value.setTimeout(this.logWarningUnexpectedPayloadUuidReceivedOnce.bind(this,t,n.uuid))}},{key:"logWarningUnexpectedPayloadUuidReceivedOnce",value:function(e,t){this._logger.warn("[%s] [%s] [%s] Received unexpected payload with uuid [%s]",e.streamId,e.contextId,e.trackId,t),this._expectedPayloadUuid.add(t)}}])}();s()(Ut,"_truncatedVclNalUnitDataByteLength",32),s()(Ut,"_phenixVclEmbeddedDataUuid","00000000-0000-0000-0000-000000000000"),s()(Ut,"_phenixInitializationSegmentUuid","511e22bd-34c0-4cee-b6c3-3c4d407622c7");var Bt=function(){return o()((function e(n,r,i){t()(this,e),s()(this,"_eventPublisher",void 0),s()(this,"_bitstream",void 0),s()(this,"_parser",void 0),s()(this,"_disposables",new te),this._eventPublisher=n,this._bitstream=r,this._parser=i,this._disposables.add(this._bitstream),this._disposables.add(this._parser)}),[{key:"bitstream",get:function(){return this._bitstream}},{key:"decode",value:function(e){this._eventPublisher.publish(It.EncodedVideoStreamChunk,e)}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),jt=function(){return o()((function e(n,r){t()(this,e),s()(this,"_h264VideoBitstreamDecoder",void 0),s()(this,"_encoding",void 0),s()(this,"_disposables",void 0),this._h264VideoBitstreamDecoder=n,this._encoding=r,this._disposables=new te,this._disposables.add(this._h264VideoBitstreamDecoder),this._disposables.add(this._encoding)}),[{key:"bitstream",get:function(){return this._h264VideoBitstreamDecoder.bitstream}},{key:"decode",value:function(e){this._h264VideoBitstreamDecoder.decode(e)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"subscribeToEmbeddedData",value:function(e,t){return t?this._encoding.subscribeToEmbeddedData((function(n){n.trackId===t&&e(n)})):this._encoding.subscribeToEmbeddedData(e)}}])}(),zt=function(){return o()((function e(){throw t()(this,e),new Error("BitstreamDecoders is a static class that may not be instantiated")}),null,[{key:"createH264VideoBitstreamDecoder",value:function(){var e=new Ft,t=new Rt(e),n=new At(e,new Mt);return new Bt(e,t,n)}},{key:"createPhenixH264EmbeddedIsoBmff2023VideoBitstreamDecoder",value:function(){var e=new Ft,t=new Rt(e),n=new At(e,new Nt),r=new Bt(e,t,n),i=new Ut(e);return new jt(r,i)}}])}();function Ht(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 Gt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ht(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ht(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Wt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var qt,Jt=function(){function e(n,r){var i=this;t()(this,e),s()(this,"_channelContext",void 0),s()(this,"_frameTimingInformationContext",void 0),s()(this,"_bitstreamDecoder",zt.createH264VideoBitstreamDecoder()),s()(this,"_frameTimingsByRtpTimestamp",new Map),s()(this,"_picturingTimingParsingConfig",{cpbDpbDelaysPresentFlag:!1,picStructPresentFlag:!0}),s()(this,"_pictureTimingParser",new Tt),s()(this,"_videoElementDisposables",new te),s()(this,"_currentPlaybackState","waiting"),s()(this,"_armedVideoFrameCallbackId",null),s()(this,"_disposables",new te),s()(this,"_disposed",!1),this._channelContext=n,this._frameTimingInformationContext=r,this._disposables.add(this._bitstreamDecoder),this._disposables.add(new f((function(){return i._frameTimingsByRtpTimestamp.clear()}))),this._disposables.add(this._videoElementDisposables),this._channelContext.videoElement.value&&this.setupVideoEventListeners(this._channelContext.videoElement.value),this._disposables.add(this._channelContext.videoElement.subscribe((function(e){i._videoElementDisposables.dispose(),e&&i.setupVideoEventListeners(e)}))),this._frameTimingInformationContext.shouldExtractTimecode.value&&this._disposables.add(this._bitstreamDecoder.bitstream.subscribeToSeiPayloadType(kt.PictureTiming,this.onPictureTimingExtracted.bind(this)))}return o()(e,[{key:"processFrame",value:function(e,t,n,r){if(!this._disposed){var i={mid:t,trackId:n,receiveTimestamp:new Date};this.removeFrameTimingsExceedingMaxCapacity();var o=r.timestamp.toString(10);this._frameTimingsByRtpTimestamp.has(o),this._frameTimingsByRtpTimestamp.set(o,i),this._bitstreamDecoder.decode({context:{streamId:e,trackId:n,contextId:o},data:new Uint8Array(r.data)})}}},{key:"dispose",value:function(){this._disposed=!0,this._disposables.dispose()}},{key:"onPictureTimingExtracted",value:function(e){var t,n,r,i,o,a=e.context,s=a.contextId,u=a.trackId,c=e.data;if(!this._disposed){var l=null===(t=this._pictureTimingParser.parse(c.data,this._picturingTimingParsingConfig).picStruct)||void 0===t||null===(n=t.clockTimestamps.find((function(e){return!0===e.clockTimestampFlag})))||void 0===n?void 0:n.clockTimestamp;if(l){var d=this._frameTimingsByRtpTimestamp.get(s);if(d){var h={mid:d.mid,trackId:u,kind:"video",codec:"H264",timecode:{hours:null!==(r=l.hours)&&void 0!==r?r:null,minutes:null!==(i=l.minutes)&&void 0!==i?i:null,seconds:null!==(o=l.seconds)&&void 0!==o?o:null,frames:l.nFrames,isFrameDrop:l.countingType>1},sourceTimestamp:null,ingestTimestamp:null,encodeTimestamp:null,transcodeTimestamp:null,receiveTimestamp:new Date(d.receiveTimestamp),playbackState:this._currentPlaybackState};d.decodedFrameTimingInformation=h,this._frameTimingInformationContext.decodedFrameTimingInformation.value=h}}}}},{key:"videoFrameCallback",value:function(e,t){if(!this._disposed){this.armVideoFrameCallback();var n=t.rtpTimestamp;if(n){var r,i=[],o=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Wt(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)?Wt(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(this._frameTimingsByRtpTimestamp);try{for(o.s();!(r=o.n()).done;){var a=gt()(r.value,2),s=a[0],u=a[1];if(parseInt(s,10)>n)break;"playing"===this._currentPlaybackState&&(this._frameTimingInformationContext.renderedFrameTimingInformation.value=Gt(Gt({},u.decodedFrameTimingInformation),{},{renderTimestamp:new Date(performance.timeOrigin+e),playbackState:"playing"})),i.push(s)}}catch(e){o.e(e)}finally{o.f()}for(var c=0,l=i;c<l.length;c++){var d=l[c];this._frameTimingsByRtpTimestamp.delete(d)}}}}},{key:"removeFrameTimingsExceedingMaxCapacity",value:function(){var t=this._frameTimingsByRtpTimestamp.size-(e.MAX_FRAME_TIMING_ENTRIES-1);if(!(t<=0))for(var n=this._frameTimingsByRtpTimestamp.keys(),r=0;r<t;r++){var i=n.next().value;this._frameTimingsByRtpTimestamp.delete(i)}}},{key:"setupVideoEventListeners",value:function(e){var t=this,n=function(){return t._currentPlaybackState="playing"};e.addEventListener("playing",n),this._videoElementDisposables.add(new f((function(){return e.removeEventListener("playing",n)})));var r=function(){return t._currentPlaybackState="paused"};e.addEventListener("pause",r),this._videoElementDisposables.add(new f((function(){return e.removeEventListener("pause",r)})));var i=function(){return t._currentPlaybackState="stalled"};e.addEventListener("stalled",i),this._videoElementDisposables.add(new f((function(){return e.removeEventListener("stalled",i)})));var o=function(){return t._currentPlaybackState="waiting"};e.addEventListener("waiting",o),this._videoElementDisposables.add(new f((function(){return e.removeEventListener("waiting",o)})));var a=function(){return t._currentPlaybackState="ended"};e.addEventListener("ended",a),this._videoElementDisposables.add(new f((function(){return e.removeEventListener("ended",a)})));var s=function(){return t._currentPlaybackState="error"};e.addEventListener("error",s),this._videoElementDisposables.add(new f((function(){return e.removeEventListener("error",s)}))),this.armVideoFrameCallback(),this._videoElementDisposables.add(new f((function(){var e;t._armedVideoFrameCallbackId&&(null===(e=t._channelContext.videoElement.value)||void 0===e||e.cancelVideoFrameCallback(t._armedVideoFrameCallbackId))})))}},{key:"armVideoFrameCallback",value:function(){var e;null!==(e=this._channelContext.videoElement.value)&&void 0!==e&&e.requestVideoFrameCallback&&(this._armedVideoFrameCallbackId=this._channelContext.videoElement.value.requestVideoFrameCallback(this.videoFrameCallback.bind(this)))}}])}();s()(Jt,"MAX_FRAME_TIMING_ENTRIES",1800);var Kt=Symbol(),Zt=function(){function e(){throw t()(this,e),new Error("SurrogateFrameDataManager is a static class that may not be instantiated")}return o()(e,null,[{key:"getSurrogateAudioSilentPerCodec",value:function(t){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)?Kt: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?Kt: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(),i=e._dummy82x82H264PFrameFrameNumberIndex;return r[i]|=t,r[i+1]|=n,e._surrogate82x82PFrameFrameNumber++,r.buffer}}])}();qt=Zt,s()(Zt,"_isSafari","Safari"===T.browserName),s()(Zt,"_isMobileChrome","Chrome"===T.browserName&&T.isMobile()),s()(Zt,"_isAndroidChrome","Chrome"===T.browserName&&T.isAndroid),s()(Zt,"_singleZeroByte",new Uint8Array([0])),s()(Zt,"_dummyAudioSilentPerCodec",{OPUS:new Uint8Array([104,7,217,171,188,121,135,171,142,74,20,243,167,28,242,154,122,69,167,45,68,37,116,76,173,22,179,14,81,87,234,231,173,42,56,206,51])}),s()(Zt,"_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])}),s()(Zt,"_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])}),s()(Zt,"_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(_e()(new Uint8Array(40).fill(255)),[95],_e()(new Uint8Array(10295).fill(255)),[128,0,0,0,1,101,136,132,5],_e()(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(_e()(new Uint8Array(40).fill(255)),[164],_e()(new Uint8Array(10364).fill(255)),[128,0,0,0,1,65,154,32,21,240,75]))}),s()(Zt,"_dummy82x82H264PFrameFrameNumberIndex",10418),s()(Zt,"_surrogate82x82PFrameFrameNumberReset",1),s()(Zt,"_useUpdateSurrogate82x82PFrameFrameNumber",qt._isMobileChrome||qt._isSafari),s()(Zt,"_surrogate82x82PFrameFrameNumber",qt._surrogate82x82PFrameFrameNumberReset);var Qt=n(512),$t=n.n(Qt);function Xt(){return $t()('(()=>{var e={79:e=>{e.exports=function(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=Array(r);t<r;t++)o[t]=e[t];return o},e.exports.__esModule=!0,e.exports.default=e.exports},901:(e,r,t)=>{var o=t(79);e.exports=function(e){if(Array.isArray(e))return o(e)},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,r,t)=>{var o=t(736);function n(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}e.exports=function(e,r,t){return r&&n(e.prototype,r),t&&n(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,r,t)=>{var o=t(736);e.exports=function(e,r,t){return(r=o(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e},e.exports.__esModule=!0,e.exports.default=e.exports},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},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},132:(e,r,t)=>{var o=t(901),n=t(291),a=t(122),i=t(869);e.exports=function(e){return o(e)||n(e)||a(e)||i()},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,r,t)=>{var o=t(738).default;e.exports=function(e,r){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,r,t)=>{var o=t(738).default,n=t(45);e.exports=function(e){var r=n(e,"string");return"symbol"==o(r)?r:r+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function r(t){return e.exports=r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},122:(e,r,t)=>{var o=t(79);e.exports=function(e,r){if(e){if("string"==typeof e)return o(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(e,r):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}},r={};function t(o){var n=r[o];if(void 0!==n)return n.exports;var a=r[o]={exports:{}};return e[o](a,a.exports,t),a.exports}t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{"use strict";var e,r,o,n,a=t(383),i=t.n(a),s=t(579),u=t.n(s),m=t(693),d=t.n(m),f=t(132),l=t.n(f),c=function(){function e(){i()(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 r=navigator.userAgent.match(e._browserNameAndVersionRegex);return r&&r[0]?r[0]:e.parseBrowserNameAndVersionForIE()}},{key:"parseBrowserName",value:function(){if(!e._browserNameAndVersion)return"";var r=e._browserNameAndVersion.split("/");return r&&r[0]?r[0]:""}},{key:"parseBrowserMajorVersion",value:function(){if(!e._browserNameAndVersion)return 0;var r=e._browserNameAndVersion.split("/");if(!r||!r[1])return 0;var t=r[1];return t&&Number(t.split(".")[0])||0}},{key:"parseBrowserNameAndVersionForIE",value:function(){if(!navigator||!navigator.userAgent)return"";var e=navigator.userAgent,r=e.indexOf("MSIE ");if(r>0)return"IE/".concat(parseInt(e.substring(r+5,e.indexOf(".",r)),10));if(e.indexOf("Trident/")>0){var t=e.indexOf("rv:");return"IE/".concat(parseInt(e.substring(t+3,e.indexOf(".",t)),10))}return""}}])}();e=c,d()(c,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\\/)([\\d.apre]+)/g),d()(c,"_browserNameAndVersion",e.parseBrowserNameAndVersion()),d()(c,"_browserName",e.parseBrowserName()),d()(c,"_browserMajorVersion",e.parseBrowserMajorVersion()),d()(c,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(r=navigator)||void 0===r?void 0:r.userAgent)),d()(c,"_isAndroid",/Android/i.test(null===(o=navigator)||void 0===o?void 0:o.userAgent)),d()(c,"_isChrome69",e._browserNameAndVersion.includes("Chrome/69.")),d()(c,"_isChrome70",e._browserNameAndVersion.includes("Chrome/70.")),d()(c,"_isChrome71",e._browserNameAndVersion.includes("Chrome/71.")),d()(c,"_isChrome72",e._browserNameAndVersion.includes("Chrome/72.")),d()(c,"_isChrome74",e._browserNameAndVersion.includes("Chrome/74.")),d()(c,"_isChrome75",e._browserNameAndVersion.includes("Chrome/75.")),d()(c,"_isChrome76",e._browserNameAndVersion.includes("Chrome/76.")),d()(c,"_isChrome77",e._browserNameAndVersion.includes("Chrome/77."));var p=Symbol(),b=function(){function e(){throw i()(this,e),new Error("SurrogateFrameDataManager is a static class that may not be instantiated")}return u()(e,null,[{key:"getSurrogateAudioSilentPerCodec",value:function(r){if("OPUS"===r.toUpperCase())return e._dummyAudioSilentPerCodec.OPUS.buffer}},{key:"getInvalidSurrogateAudioData",value:function(){return e._singleZeroByte.buffer}},{key:"getSurrogateVideoIFramePerCodec",value:function(r){switch(r.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(r){return"H264"===r.toUpperCase()&&e._useUpdateSurrogate82x82PFrameFrameNumber&&(e._surrogate82x82PFrameFrameNumber=e._surrogate82x82PFrameFrameNumberReset,e._isAndroidChrome)?p:e._singleZeroByte.buffer}},{key:"getSurrogateVideoPFramePerCodec",value:function(r){switch(r.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(r){if("H264"===r.toUpperCase()&&e._useUpdateSurrogate82x82PFrameFrameNumber){var t=e._surrogate82x82PFrameFrameNumber,o=e.getSurrogate82x82PFrameAndUpdateFrameNumber();return t>e._surrogate82x82PFrameFrameNumberReset?e._isAndroidChrome?p:e._singleZeroByte.buffer:(e._surrogate82x82PFrameFrameNumber++,o)}return e._singleZeroByte.buffer}},{key:"getSurrogate82x82PFrameAndUpdateFrameNumber",value:function(){var r=(14&e._surrogate82x82PFrameFrameNumber)>>1,t=(1&e._surrogate82x82PFrameFrameNumber)<<7,o=e._dummy82x82H264.PFrame.slice(),n=e._dummy82x82H264PFrameFrameNumberIndex;return o[n]|=r,o[n+1]|=t,e._surrogate82x82PFrameFrameNumber++,o.buffer}}])}();n=b,d()(b,"_isSafari","Safari"===c.browserName),d()(b,"_isMobileChrome","Chrome"===c.browserName&&c.isMobile()),d()(b,"_isAndroidChrome","Chrome"===c.browserName&&c.isAndroid),d()(b,"_singleZeroByte",new Uint8Array([0])),d()(b,"_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])}),d()(b,"_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])}),d()(b,"_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])}),d()(b,"_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(l()(new Uint8Array(40).fill(255)),[95],l()(new Uint8Array(10295).fill(255)),[128,0,0,0,1,101,136,132,5],l()(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(l()(new Uint8Array(40).fill(255)),[164],l()(new Uint8Array(10364).fill(255)),[128,0,0,0,1,65,154,32,21,240,75]))}),d()(b,"_dummy82x82H264PFrameFrameNumberIndex",10418),d()(b,"_surrogate82x82PFrameFrameNumberReset",1),d()(b,"_useUpdateSurrogate82x82PFrameFrameNumber",n._isMobileChrome||n._isSafari),d()(b,"_surrogate82x82PFrameFrameNumber",n._surrogate82x82PFrameFrameNumberReset),self.onmessage=function(e){_.forceInvalidFrame=e.data.forceInvalidFrame},self.RTCTransformEvent&&(self.onrtctransform=function(e){var r=e.transformer;_.codec=r.options.codec,_.transformFunction="video"===r.options.kind?_.videoTransformFunction:_.audioTransformFunction,_.mustSink=r.options.mustSink,_.forceInvalidFrame=!1;var t=new TransformStream({transform:_.transformFunction}),o=r.readable,n=r.writable;o.pipeThrough(t).pipeTo(n)});var _=function(){function e(){throw i()(this,e),new Error("WorkerTransformStream is a static class that may not be instantiated")}return u()(e,null,[{key:"videoTransformFunction",value:function(r,t){if(postMessage({chunk:{type:r.type,timestamp:r.timestamp,data:r.data}}),e.mustSink)if(e.forceInvalidFrame){var o;if(e.forceInvalidFrame=!1,(o="key"===r.type?b.getInvalidSurrogateVideoIFrame(e.codec):b.getInvalidSurrogateVideoPFrame(e.codec))===p)return;r.data=o||r.data}else"key"===r.type?r.data=b.getSurrogateVideoIFramePerCodec(e.codec)||r.data:r.data=b.getSurrogateVideoPFramePerCodec(e.codec)||r.data;t.enqueue(r)}},{key:"audioTransformFunction",value:function(r,t){postMessage({chunk:{timestamp:r.timestamp,data:r.data}}),e.mustSink&&(e.forceInvalidFrame?(e.forceInvalidFrame=!1,r.data=b.getInvalidSurrogateAudioData()):r.data=b.getSurrogateAudioSilentPerCodec(e.codec)||r.data),t.enqueue(r)}}])}();d()(_,"codec",void 0),d()(_,"transformFunction",void 0),d()(_,"mustSink",void 0),d()(_,"forceInvalidFrame",void 0)})()})();\n',"Worker",void 0,void 0)}var Yt=function(){return o()((function e(){throw t()(this,e),new Error("InsertableStreams is a static class that may not be instantiated")}),null,[{key:"configureEncodedStreamPipeline",value:function(e,t,n,r,i,o){var a=new te,s=new _(null),u=new _(null);return e.getTracks().forEach((function(e){var c=t.filter((function(t){return t.track===e}))[0],l=e.kind;switch(l){case"video":var d=!!n;if(P.isRTCRtpScriptTransformSupported){var h=Xt();h.onmessage=function(){var t=M()(V().mark((function t(r){return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s.value={track:e,chunk:r.data.chunk},t.t0=d,!t.t0){t.next=6;break}return t.next=5,n(e,r.data.chunk);case 5:t.t0=!t.sent;case 6:if(!t.t0){t.next=8;break}h.postMessage({forceInvalidFrame:!0});case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),c.transform=new RTCRtpScriptTransform(h,{kind:e.kind,codec:i,mustSink:d}),a.add(new f((function(){h.terminate()})));break}var p=function(){var t=M()(V().mark((function t(r,o){var a;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s.value={track:e,chunk:r},!d){t.next=12;break}return t.next=4,n(e,r);case 4:if(t.sent){t.next=11;break}if((a="key"===r.type?Zt.getInvalidSurrogateVideoIFrame(i):Zt.getInvalidSurrogateVideoPFrame(i))!==Kt){t.next=8;break}return t.abrupt("return");case 8:r.data=a||r.data,t.next=12;break;case 11:"key"===r.type?r.data=Zt.getSurrogateVideoIFramePerCodec(i)||r.data:r.data=Zt.getSurrogateVideoPFramePerCodec(i)||r.data;case 12:o.enqueue(r);case 13:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),m=new TransformStream({transform:p}),v=c.createEncodedStreams(),g=v.readable,_=v.writable;g.pipeThrough(m).pipeTo(_);break;case"audio":var y=!!r;if(P.isRTCRtpScriptTransformSupported){var b=Xt();b.onmessage=function(){var t=M()(V().mark((function t(n){return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n.data.chunk},t.t0=y,!t.t0){t.next=6;break}return t.next=5,r(e,n.data.chunk);case 5:t.t0=!t.sent;case 6:if(!t.t0){t.next=8;break}b.postMessage({forceInvalidFrame:!0});case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),c.transform=new RTCRtpScriptTransform(b,{kind:e.kind,codec:o,mustSink:y});var C=new MediaStream,k=new Audio;k.srcObject=C,document.body.appendChild(k),a.add(new f((function(){b.terminate(),document.body.removeChild(k)})));break}var S=function(){var t=M()(V().mark((function t(n,i){return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n},!y){t.next=9;break}return t.next=4,r(e,n);case 4:if(t.sent){t.next=8;break}n.data=Zt.getInvalidSurrogateAudioData(),t.next=9;break;case 8:n.data=Zt.getSurrogateAudioSilentPerCodec(o)||n.data;case 9:i.enqueue(n);case 10:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),x=new TransformStream({transform:S}),w=c.createEncodedStreams(),T=w.readable,E=w.writable;T.pipeThrough(x).pipeTo(E);break;default:G(l)}})),{disposables:a,encodedVideoFrame:s,encodedAudioFrame:u}}},{key:"configureInsertableStreamTransformation",value:function(e,t,n){var r=new MediaStream,i=new te;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 f((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)}}),m=new MediaStreamTrackProcessor({track:h}),v=new MediaStreamTrackGenerator({kind:h.kind}),g=m.readable,_=v.writable;g.pipeThrough(p).pipeTo(_),r.addTrack(v);var y=new MediaStream,b=new Audio;y.addTrack(e),b.srcObject=y,document.body.appendChild(b),i.add(new f((function(){r.removeTrack(v),document.body.removeChild(b)})))}else r.addTrack(e);break;default:G(o)}})),{transformedStream:r,disposables:i}}}])}(),en=n(981).A;function tn(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 nn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?tn(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var rn=function(){return o()((function e(n,r,i,o,a){t()(this,e),s()(this,"_logger",$.getLogger("RealTimeStream")),s()(this,"_channelContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_streamTransformContext",void 0),s()(this,"_frameTimingInformationContext",void 0),s()(this,"_handleStreamFailure",void 0),s()(this,"_disposables",void 0),this._channelContext=n,this._peerConnectionContext=r,this._streamTransformContext=i,this._frameTimingInformationContext=o,this._handleStreamFailure=a,this._disposables=new te,this._channelContext.disposables.add(this)}),[{key:"start",value:function(e,t,n,r){var i=this,o=this._streamTransformContext.hasEncodedInsertableStreams.value||this._frameTimingInformationContext.shouldExtractTimecode.value||this._frameTimingInformationContext.shouldExtractTimestamps.value;return en.all([et.discoverClosestEndPointWithCaching(e),ue.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=gt()(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),!P.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration?r.subscribe(t,a,i._channelContext.failureCount.value):(s.close(),s.dispose(),!Te.forceGarbageCollectionOnRestart||P.isMobile&&Te.skipGarbageCollectionOnMobileDevices||Ee.forceGarbageCollection(),i._peerConnectionContext.peerConnection.value=null,r.subscribe(t,null,i._channelContext.failureCount.value))})).then((function(e){var t=e.status;if(i._channelContext.state.value=i._channelContext.mapSubscribeStatusToChannelStatus(t),i._channelContext.applyStatus(t),"ok"!==t)return i._channelContext.stream.value=null,i._channelContext.lag.value=void 0,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),void i._logger.info("[%s] Subscribe failed with status [%s]",i._channelContext.streamId,t);var a=e.stream,s=e.rtcConfiguration,u=e.setRemoteDescriptionResponse,c=e.createOfferDescriptionResponse,l=e.createAnswerDescriptionResponse,d=e.lag;return i._channelContext.stream.value=a,i._channelContext.lag.value=d,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),i._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",i._channelContext.streamId,t,s,u,c,l),i.applyRtcConfiguration(i._peerConnectionContext.peerConnection.value,s).then((function(e){var t,s=!1,d=!1,h=[];i._peerConnectionContext.peerConnection.value||(i._peerConnectionContext.peerConnection.value=e),e.onicecandidate=function(n){i._channelContext.stream.value===a&&i._peerConnectionContext.peerConnection.value===e&&(s||Te.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?h.push(n.candidate):d=!0,t||(t=w.value.setTimeout((function(){var e;i._channelContext.stream.value!==a||s||null===(e=i._channelContext.endPoint.value)||void 0===e||e.addIceCandidates(a,h,d).then((function(e){var t=e.status,n=e.options;"ok"===t?(null!=n&&n.includes("cancel")&&(s=!0),i._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",i._channelContext.streamId,t,n)):i._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",i._channelContext.streamId,t)})).catch((function(e){i._logger.error("[%s] Failed to add ICE candidates",i._channelContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(i._channelContext.stream.value===a&&i._peerConnectionContext.peerConnection.value===e){var t=function(){i._channelContext.state.value=Ie.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(w.value.navigatorIsOnLine&&(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:G(e.iceConnectionState)}}};var p=new en((function(t,n){if(!P.onTrackDisabled){var r=w.value.setTimeout((function(){return n(new Error("Stream setup timed out"))}),3e4);return i._disposables.add(new f((function(){return w.value.clearTimeout(r)}))),void(e.ontrack=function(e){w.value.clearTimeout(r),t(e.streams[0])})}var o=function(n){w.value.clearTimeout(a),e.removeEventListener("track",o),e.removeEventListener("addstream",o),t("streams"in n?n.streams[0]:n.stream)},a=w.value.setTimeout((function(){e.removeEventListener("track",o),e.removeEventListener("addstream",o),n(new Error("Stream setup timed out"))}),3e4);e.addEventListener("track",o),e.addEventListener("addstream",o),i._disposables.add(new f((function(){return w.value.clearTimeout(a)})))}));return new en((function(e){e()})).then((function(){if(u)return i._logger.info("[%s] Set local SDP offer [%s]",i._channelContext.streamId,u.sessionDescription.sdp),e.setLocalDescription(u.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,u.sessionDescription,e.message),e}))})).then((function(){if(l)return i._logger.info("[%s] Set remote SDP answer [%s]",i._channelContext.streamId,l.sessionDescription.sdp),e.setRemoteDescription(l.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,l.sessionDescription,e.message),e}))})).then((function(){if(c)return i._logger.info("[%s] Set remote SDP offer [%s]",i._channelContext.streamId,c.sessionDescription.sdp),e.setRemoteDescription(c.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,c.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})})).then((function(e){return i._logger.info("[%s] Set local SDP answer [%j]",i._channelContext.streamId,e),i._channelContext.endPoint.value.setRemoteDescription(a,e)})).then((function(t){var n=t.status,r=t.sessionDescription;return i._channelContext.state.value=i.mapSetRemoteDescriptionStatusToChannelStatus(n),"ok"!==n?(i._channelContext.playing.value=!1,i._channelContext.standby.value=!0,void(i._channelContext.stopped.value=!1)):e.setLocalDescription(r).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,r,e.message),e}))}))})).then((function(){return n.success(i._channelContext.streamId),p})).then((function(t){var n,a;if(o&&null!=e&&null!==(n=e.currentRemoteDescription)&&void 0!==n&&n.sdp){var s=new _t(e.currentRemoteDescription.sdp),u=e.getReceivers(),c=Yt.configureEncodedStreamPipeline(t,u,i._streamTransformContext.encodedVideoStreamSink,i._streamTransformContext.encodedAudioStreamSink,s.videoCodec,s.audioCodec),l=c.disposables,d=c.encodedVideoFrame;if("H264"===s.videoCodec.toUpperCase()&&(i._frameTimingInformationContext.shouldExtractTimecode.value||i._frameTimingInformationContext.shouldExtractTimestamps.value)){var h=new Jt(i._channelContext,i._frameTimingInformationContext);i._disposables.add(h),t.getVideoTracks().forEach((function(t){var n,r=u.filter((function(e){return e.track===t}))[0],o=e.supportsGetTransceivers?null===(n=e.getTransceivers().filter((function(e){return e.receiver===r}))[0])||void 0===n?void 0:n.mid:null;r?o?(i._disposables.add(d.subscribe((function(e){e&&h.processFrame(i._channelContext.streamId,o,e.track.id,e.chunk)}))),i._frameTimingInformationContext.isEnabled.value=!0):i._logger.warn("[%s] Skipping frame timing information for track [%s] because no mid was found",i._channelContext.streamId,t.id):i._logger.warn("[%s] Skipping frame timing information for track [%s] because no receiver was found",i._channelContext.streamId,t.id)}))}i._disposables.add(l)}if(i._streamTransformContext.hasInsertableStreams.value){var p=Yt.configureInsertableStreamTransformation(t,i._streamTransformContext.videoStreamTransformCallback,i._streamTransformContext.audioStreamTransformCallback),f=p.transformedStream,m=p.disposables;i._disposables.add(m),t=f}i._peerConnectionContext.mediaStream.value=t;var v=new bt(e,t,null!==(a=i._channelContext.endPoint.value)&&void 0!==a&&a.roundTripTime?i._channelContext.endPoint.value.roundTripTime/4:0);i._disposables.add(v);var g=v.rtcStatistic.subscribe((function(t){if(i._channelContext.rtcStatistics.value=t,t){if(!i._channelContext.rtcVideoStatistic&&!i._channelContext.rtcAudioStatistic)return i._channelContext.rtcAudioStatistic=t.audio,void(i._channelContext.rtcVideoStatistic=t.video);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)&&w.value.navigatorIsOnLine&&i._logger.info("[%s] Audio track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.audio.bytesReceived,i._channelContext.rtcAudioStatistic.bytesReceived,new Re(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)&&w.value.navigatorIsOnLine&&i._logger.info("[%s] Video track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.video.bytesReceived,i._channelContext.rtcVideoStatistic.bytesReceived,new Re(t.video.timestamp-i._channelContext.rtcVideoStatistic.timestamp).toIsoString()),i._channelContext.rtcVideoStatistic=t.video),w.value.navigatorIsOnLine)if(r||n)i.reconnectPeerConnection(e,(function(){i._channelContext.state.value=Ie.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,v.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!==Ie.Reconnecting&&i._channelContext.state.value!==Ie.Offline)return;i._channelContext.state.value=i._channelContext.playing.value?Ie.Playing:Ie.Paused,i._logger.info("Channel state restored to [%s] after reconnecting",Ie[i._channelContext.state.value])}else i._channelContext.state.value=Ie.Offline}}));return i._disposables.add(g),Te.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=Ie.Paused))}))}))}))}},{key:"applyRtcConfiguration",value:(e=M()(V().mark((function e(t,n){var r;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=yt.truncateIceServers(n),e.abrupt("return",Te.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=nn(nn({},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=Ie.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Te.maximalNumberOfPeerConnectionReconnectAttempts||!Te.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(P.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 Ie.Starting;case"unauthorized":return Ie.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return Ie.Recovering;case"failed":return Ie.Error;default:G(e)}}}]);var e}(),on=function(){return o()((function e(){throw t()(this,e),new Error("StreamFactory is a static class that may not be instantiated")}),null,[{key:"create",value:function(e,t,n,r,i,o){var a=ee.parseToken(e).capabilities,s=a.includes("streaming"),u=a.includes("on-demand");return s||u?new mt(t,u?ft.OndDemand:ft.Live,o):new rn(t,n,r,i,o)}}])}(),an=n(981).A,sn=function(){return o()((function e(n,r,i){var o=this;t()(this,e),s()(this,"_logger",$.getLogger("Channel")),s()(this,"_tokenContext",void 0),s()(this,"_channelContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_streamTransformContext",void 0),s()(this,"_stateContext",void 0),s()(this,"_frameTimingInformationContext",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_channelStartTime",void 0),s()(this,"_readOnlyPeerConnection",void 0),s()(this,"_readOnlyState",void 0),s()(this,"_readOnlyAutoMuted",void 0),s()(this,"_readOnlyAutoPaused",void 0),s()(this,"_readOnlyTokenExpiring",void 0),s()(this,"_readOnlyAuthorized",void 0),s()(this,"_readOnlyOnline",void 0),s()(this,"_readOnlyLoading",void 0),s()(this,"_readOnlyPlaying",void 0),s()(this,"_readOnlyStandby",void 0),s()(this,"_readOnlyStopped",void 0),s()(this,"_readOnlyTargetLag",void 0),s()(this,"_readOnlyLag",void 0),s()(this,"_readOnlyBitrateLimit",void 0),s()(this,"_readOnlyResolution",void 0),s()(this,"_readOnlyFailureCount",void 0),s()(this,"_readOnlyEndPoint",void 0),s()(this,"_readOnlyStream",void 0),s()(this,"_readOnlyRtcStatistics",void 0),s()(this,"_readOnlyMediaStream",void 0),s()(this,"_readOnlyIsFrameTimingInformationEnabled",void 0),s()(this,"_readOnlyDecodedFrameTimingInformation",void 0),s()(this,"_readOnlyRenderedFrameTimingInformation",void 0),s()(this,"_metricsService",void 0),s()(this,"_sessionTelemetry",void 0),s()(this,"_videoMetaDataChangedHandler",void 0);var a=ee.parseToken(r),u={targetLag:null==i?void 0:i.targetLag},c={hasInsertableStreams:a.capabilities.includes("insertable-streams"),hasEncodedInsertableStreams:a.capabilities.includes("encoded-insertable-streams"),videoStreamTransformCallback:null==i?void 0:i.videoStreamTransformCallback,audioStreamTransformCallback:null==i?void 0:i.audioStreamTransformCallback,encodedVideoStreamSink:null==i?void 0:i.encodedVideoStreamSink,encodedAudioStreamSink:null==i?void 0:i.encodedAudioStreamSink};this._tokenContext=new Ue(r),this._channelContext=new Be(u),this._peerConnectionContext=new Ge,this._streamTransformContext=new He(c),this._stateContext=new We,this._exponentialBackoff=new ye,this._channelStartTime=Date.now(),this._readOnlyPeerConnection=new y(this._peerConnectionContext.peerConnection),this._readOnlyState=new y(this._channelContext.state),this._readOnlyAutoMuted=new y(this._channelContext.autoMuted),this._readOnlyAutoPaused=new y(this._channelContext.autoPaused),this._readOnlyTokenExpiring=new y(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new y(this._channelContext.authorized),this._readOnlyOnline=new y(this._channelContext.online),this._readOnlyLoading=new y(this._channelContext.loading),this._readOnlyPlaying=new y(this._channelContext.playing),this._readOnlyStandby=new y(this._channelContext.standby),this._readOnlyStopped=new y(this._channelContext.stopped),this._readOnlyTargetLag=new y(this._channelContext.targetLag),this._readOnlyLag=new y(this._channelContext.lag),this._readOnlyBitrateLimit=new y(this._channelContext.bitrateLimit),this._readOnlyResolution=new y(this._channelContext.resolution),this._readOnlyFailureCount=new y(this._channelContext.failureCount),this._readOnlyEndPoint=new y(this._channelContext.endPoint),this._readOnlyStream=new y(this._channelContext.stream),this._readOnlyRtcStatistics=new y(this._channelContext.rtcStatistics),this._readOnlyMediaStream=new y(this._peerConnectionContext.mediaStream);var l=(a.uri||Te.discoveryUri.value).toString();Te.tenancy.value=a.tenancy||Te.tenancy.value,he.uri.value=l,this._metricsService=xe.getMetricsService(l),this._sessionTelemetry=new Me(Te.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=n,this._frameTimingInformationContext=new qe,this.configureFrameTimingInformation(a),this._readOnlyIsFrameTimingInformationEnabled=new y(this._frameTimingInformationContext.isEnabled),this._readOnlyDecodedFrameTimingInformation=new y(this._frameTimingInformationContext.decodedFrameTimingInformation),this._readOnlyRenderedFrameTimingInformation=new y(this._frameTimingInformationContext.renderedFrameTimingInformation),this._channelContext.channelDisposables.add(this._channelContext.videoElement.subscribe((function(e){o._channelContext.rendererDisposables.dispose(),e&&(o._channelContext.rendererDisposables.add(o._channelContext.stream.subscribe((function(e){o._channelContext.videoTelemetry&&o._channelContext.videoTelemetry.dispose(),e&&o.videoElement&&(o.videoElement.dataset&&(o.videoElement.dataset.sessionId=Te.clientSessionId,o.videoElement.dataset.streamId=o.streamId),o._channelContext.videoTelemetry=new Oe(o.streamId,Te.pageLoadTime,o._channelStartTime,o._metricsService),o._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(o.videoElement),o._channelContext.videoTelemetry.setupListenerForRebuffering(o.videoElement),o._channelContext.state.value===Ie.Stopped)&&o.restartAfterStop()}))),o._channelContext.channelDisposables.add(o._channelContext.rendererDisposables))}))),this._channelContext.channelDisposables.add(this._channelContext.state.subscribe((function(e){o._channelContext.clearFailureCountTimeout&&w.value.clearTimeout(o._channelContext.clearFailureCountTimeout),o._channelContext.failureCount.value&&e===Ie.Playing&&(o._channelContext.clearFailureCountTimeout=w.value.setTimeout((function(){o._channelContext.failureCount.value=0}),3e3))}))),this._channelContext.channelDisposables.add(this._channelContext.resolution.subscribe((function(e){o._channelContext.videoTelemetry&&o._channelContext.videoTelemetry.onVideoResolutionChanges(e.toString())}))),this._channelContext.channelDisposables.add(this._channelContext.bitrateLimit.subscribe((function(e){if(e&&o._channelContext.endPoint.value&&o._channelContext.stream.value){var t=Date.now()-o._channelContext.channelInitialization.getTime();o._channelContext.endPoint.value.limitBitrate(o._channelContext.stream.value,t,e,Ne.Keep,Ve.Normal).catch((function(e){o._logger.error("Error while setting limit bitrate",e)}))}})));var d=function(){o._channelContext.stream.value&&o._channelContext.endPoint.value&&o._channelContext.endPoint.value.destroyStreamOnUnmount(o._channelContext.stream.value,"client:termination-on-window-unload")};w.value.addWindowEventListener("beforeunload",d),this._channelContext.channelDisposables.add(new f((function(){w.value.removeWindowEventListener("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!==Ie.Initializing&&(this._channelContext.state.value=Ie.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 Pe(e.videoWidth,e.videoHeight)):this._channelContext.resolution.value=Pe.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=ee.parseToken(this._tokenContext.token.value),n=(t.uri||Te.discoveryUri.value).toString();Te.tenancy.value=t.tenancy||Te.tenancy.value,he.uri.value=n,this._metricsService=xe.getMetricsService(n),this._streamTransformContext.hasInsertableStreams.value=t.capabilities.includes("insertable-streams"),this._streamTransformContext.hasEncodedInsertableStreams.value=t.capabilities.includes("encoded-insertable-streams"),this.configureFrameTimingInformation(t),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"autoMuted",get:function(){return this._readOnlyAutoMuted}},{key:"autoPaused",get:function(){return this._readOnlyAutoPaused}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"playing",get:function(){return this._readOnlyPlaying}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"targetLag",get:function(){return this._readOnlyTargetLag}},{key:"lag",get:function(){return this._readOnlyLag}},{key:"bitrateLimit",get:function(){return this._readOnlyBitrateLimit.value}},{key:"resolution",get:function(){return this._readOnlyResolution}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._channelContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"isFrameTimingInformationEnabled",get:function(){return this._readOnlyIsFrameTimingInformationEnabled}},{key:"decodedFrameTimingInformation",get:function(){return this._readOnlyDecodedFrameTimingInformation}},{key:"renderedFrameTimingInformation",get:function(){return this._readOnlyRenderedFrameTimingInformation}},{key:"setBitrateLimit",value:function(e){this._channelContext.bitrateLimit.value=e}},{key:"clearBitrateLimit",value:function(){var e=this;if(this._channelContext.bitrateLimit.value&&this._channelContext.endPoint.value&&this._channelContext.stream.value){var t=Date.now()-this._channelContext.channelInitialization.getTime();this._channelContext.endPoint.value.limitBitrate(this._channelContext.stream.value,t,0,Ne.Keep,Ve.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=M()(V().mark((function e(t){var n=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new an((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=Ie.Stopped}},{key:"resume",value:(l=M()(V().mark((function e(){return V().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 l.apply(this,arguments)})},{key:"mute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!0)}},{key:"unmute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!1,this._channelContext.autoMuted.value=!1)}},{key:"dispose",value:(c=M()(V().mark((function e(){var t=this;return V().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 c.apply(this,arguments)})},{key:"getUri",value:function(e){return ee.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",Te.discoveryUri.value),new w.value.URL(Te.discoveryUri.value))}},{key:"start",value:(u=M()(V().mark((function e(){return V().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 u.apply(this,arguments)})},{key:"processStart",value:(a=M()(V().mark((function e(){var t,n,r,i,o,a,s,u,c,l,d,h,p,m,v,g,_,y,b,C=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._channelContext.state.value=Ie.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),ee.isEncodedEdgeTokenValid(t)){e.next=10;break}return this._logger.error("Failed to parse token [%s]",t),this._channelContext.state.value=Ie.Unauthorized,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 10:if(!this._streamTransformContext.videoStreamTransformCallback){e.next=18;break}if(r=ze.validateMediaStreamTrackTransform("video",this._streamTransformContext.videoStreamTransformCallback),i=r.valid,o=r.validationResult,i){e.next=18;break}return this._logger.error(o),this._channelContext.state.value=Ie.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 18:if(!this._streamTransformContext.audioStreamTransformCallback){e.next=26;break}if(a=ze.validateMediaStreamTrackTransform("audio",this._streamTransformContext.audioStreamTransformCallback),s=a.valid,u=a.validationResult,s){e.next=26;break}return this._logger.error(u),this._channelContext.state.value=Ie.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 26:if(!this._streamTransformContext.encodedVideoStreamSink){e.next=34;break}if(c=je.validateEncodedStreamSink("video",this._streamTransformContext.encodedVideoStreamSink),l=c.valid,d=c.validationResult,l){e.next=34;break}return this._logger.error(d),this._channelContext.state.value=Ie.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 34:if(!this._streamTransformContext.encodedAudioStreamSink){e.next=42;break}if(h=je.validateEncodedStreamSink("audio",this._streamTransformContext.encodedAudioStreamSink),p=h.valid,m=h.validationResult,p){e.next=42;break}return this._logger.error(m),this._channelContext.state.value=Ie.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 42:if(!this._streamTransformContext.hasInsertableStreams.value||!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=48;break}return this._logger.error("Both insertable-streams and encoded-insertable-streams are enabled, only use one or the other"),this._channelContext.state.value=Ie.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 48:if(v="function"==typeof this._streamTransformContext.videoStreamTransformCallback||"function"==typeof this._streamTransformContext.audioStreamTransformCallback,g="function"==typeof this._streamTransformContext.encodedVideoStreamSink||"function"==typeof this._streamTransformContext.encodedAudioStreamSink,!v||!g){e.next=56;break}return this._logger.error("Both Media Stream Track transform callback and encodedInsertableStreams sink function found, only use one type or the other"),this._channelContext.state.value=Ie.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 56:if(!this._streamTransformContext.hasInsertableStreams.value){e.next=71;break}if(P.isInsertableStreamsSupported){e.next=63;break}return this._logger.error("Browser does not support Media Stream Track API"),this._channelContext.state.value=Ie.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 63:if(v){e.next=69;break}return this._logger.error("CreateChannelOptions transform callback function is missing; however, insertable-streams is enabled"),this._channelContext.state.value=Ie.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 69:e.next=77;break;case 71:if(!v){e.next=77;break}return this._logger.error("CreateChannelOptions transform callback function found; however, insertable-streams is not enabled"),this._channelContext.state.value=Ie.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 77:if(!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=92;break}if(P.isEncodedInsertableStreamsSupported||P.isRTCRtpScriptTransformSupported){e.next=84;break}return this._logger.error("Browser does not support encodedInsertableStreams API"),this._channelContext.state.value=Ie.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 84:if(g){e.next=90;break}return this._logger.error("CreateChannelOptions transform sink function is missing; however, encoded-insertable-streams is enabled"),this._channelContext.state.value=Ie.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 90:e.next=98;break;case 92:if(!g){e.next=98;break}return this._logger.error("CreateChannelOptions transform sink function found; however, encoded-insertable-streams is not enabled"),this._channelContext.state.value=Ie.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 98:if(this._channelContext.loading.value=!0,_=this.getUri(t),this._channelContext.disposables.add(this._channelContext.state.subscribe((function(e){e!==Ie.Error&&e!==Ie.Recovering||et.clearCachedClosestEndpoint(_)}))),y=function(){return new an((function(e){return C._stateContext.isStarting.value=!1,e(C.handleStreamFailure())}))},b=on.create(t,this._channelContext,this._peerConnectionContext,this._streamTransformContext,this._frameTimingInformationContext,y)){e.next=106;break}return this._stateContext.isStarting.value=!1,e.abrupt("return");case 106:return e.abrupt("return",b.start(_,t,n,this.playMediaStreamInVideoElement.bind(this)).then((function(){C._channelContext.loading.value=!1})).catch((function(e){n.fail(),C._channelContext.failureCount.value++,C._channelContext.online.value=!1,C.cleanUpResources("client:cleanup-after-failed-setup"),C._channelContext.state.value=Ie.ClientStartError,C._logger.error("Failed to start channel",e)})).finally((function(){if(C._stateContext.isStarting.value=!1,C._channelContext.state.value!==Ie.Playing&&Te.automaticRetryOnFailure){var e=w.value.setTimeout((function(){C.handleStreamFailure().catch((function(e){C._logger.error("Failed handling stream failure",e)}))}),C.getRetryInterval());C._channelContext.disposables.add(new f((function(){w.value.clearTimeout(e)})))}})));case 107:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"restartAfterStop",value:(i=M()(V().mark((function e(){return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._peerConnectionContext.mediaStream.value){e.next=4;break}return e.abrupt("return",this.playMediaStreamInVideoElement(this._peerConnectionContext.mediaStream.value));case 4:this._tokenContext.token.value&&this.start();case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"play",value:(r=M()(V().mark((function e(){var t;return V().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 r.apply(this,arguments)})},{key:"getRetryInterval",value:function(){switch(this._channelContext.state.value){case Ie.Initializing:case Ie.StandBy:case Ie.Offline:return 15e3;case Ie.Error:case Ie.Recovering:case Ie.Unauthorized:case Ie.GeoRestricted:case Ie.GeoBlocked:case Ie.Stopped:case Ie.Starting:case Ie.Playing:case Ie.Paused:case Ie.Reconnecting:case Ie.UnsupportedFeature:case Ie.ConfigurationError:case Ie.TransientConfigurationError:case Ie.ConnectionError:case Ie.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._channelContext.failureCount.value);default:G(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(n=M()(V().mark((function e(){return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._channelContext.state.value,e.next=e.t0===Ie.Error||e.t0===Ie.Reconnecting||e.t0===Ie.StandBy||e.t0===Ie.Offline||e.t0===Ie.Recovering||e.t0===Ie.TransientConfigurationError||e.t0===Ie.ConnectionError||e.t0===Ie.ClientStartError?3:e.t0===Ie.Unauthorized?5:e.t0===Ie.GeoRestricted?7:e.t0===Ie.GeoBlocked?9:e.t0===Ie.Stopped?11:e.t0===Ie.Initializing?13:e.t0===Ie.Playing?15:e.t0===Ie.Paused?17:e.t0===Ie.Starting?19:e.t0===Ie.UnsupportedFeature?21:e.t0===Ie.ConfigurationError?23:25;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,Ie[this._channelContext.state.value]),e.abrupt("break",26);case 5:return this._logger.info("Channel is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 7:return this._logger.info("Channel is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 9:return this._logger.info("Channel is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 11:return this._logger.info("Channel is stopped, skipping retry of start."),e.abrupt("return");case 13:return this._logger.info("Channel is already initializing, skipping retry of start"),e.abrupt("return");case 15:return this._logger.info("Channel is playing, skipping retry of start"),e.abrupt("return");case 17:return this._logger.info("Channel is paused, skipping retry of start. Please invoke play()"),e.abrupt("return");case 19:return this._logger.info("Channel is already starting, skipping retry of start"),e.abrupt("return");case 21:return this._logger.info("Channel is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 23:return this._logger.info("Channel is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 25:G(this._channelContext.state.value);case 26:return e.abrupt("return",this.start());case 27:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._channelContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!Te.forceGarbageCollectionOnRestart||P.isMobile&&Te.skipGarbageCollectionOnMobileDevices||Ee.forceGarbageCollection()),this._peerConnectionContext.mediaStream.value&&(this._peerConnectionContext.mediaStream.value.getTracks().forEach((function(e){return e.stop()})),this._peerConnectionContext.mediaStream.value=null),this._channelContext.autoPaused.value=!1,this._channelContext.autoMuted.value=!1,this._channelContext.playing.value=!1,this._channelContext.stopped.value=!0,this._channelContext.standby.value=!1,this._channelContext.stream.value&&this._channelContext.endPoint.value&&this._channelContext.endPoint.value.destroyStream(this._channelContext.stream.value,t).then((function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)})).catch((function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)})),this.videoElement&&this.videoElement.dataset&&(this.videoElement.dataset.sessionId="",this.videoElement.dataset.streamId=""),this._channelContext.stream.value=null,this._channelContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}},{key:"configureFrameTimingInformation",value:function(e){var t=this,n=e.capabilities.find((function(e){return e.startsWith("frame-timing-information=")}));this._frameTimingInformationContext.shouldExtractTimecode.value=!1,this._frameTimingInformationContext.shouldExtractTimestamps.value=!1,this._frameTimingInformationContext.isEnabled.value=!1,n?P.isChannelFrameTimingInformationSupported?(n.split("=")[1].split(",").map((function(e){return e.trim()})).forEach((function(e){switch(e){case"timecode":t._frameTimingInformationContext.shouldExtractTimecode.value=!0;break;case"timestamps":t._frameTimingInformationContext.shouldExtractTimestamps.value=!0;break;default:t._logger.info("Ignoring unknown frame timing information option [%s]",e)}})),this._logger.info("Frame timing information configuration [(timecode [%s], timestamps [%s])]",this._frameTimingInformationContext.shouldExtractTimecode.value,this._frameTimingInformationContext.shouldExtractTimestamps.value)):this._logger.info("Disabling frame timing information as the environment does not support it [%s]",n):this._logger.info("Disabling frame timing information as no capability was found")}},{key:"playMediaStreamInVideoElement",value:(e=M()(V().mark((function e(t){var n,r,i=this;return V().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=Ie.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=Ie.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=Ie.Playing})).catch((function(e){var r=!!t.getTracks().filter((function(e){return"audio"===e.kind})).length,o=!Te.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=Ie.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=Ie.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=Ie.Paused})))})));case 18:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})}]);var e,n,r,i,a,u,c,l,d}(),un=function(){return o()((function e(){throw t()(this,e),new Error("Channels is a static class that may not be instantiated")}),null,[{key:"createChannel",value:function(e){if(!Te.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 sn(e.videoElement,e.token,t)}},{key:"isFrameTimingInformationSupported",get:function(){return P.isChannelFrameTimingInformationSupported}}])}(),cn=function(e){return e[e.Initializing=0]="Initializing",e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Publishing=3]="Publishing",e[e.Recovering=4]="Recovering",e[e.Reconnecting=5]="Reconnecting",e[e.Stopped=6]="Stopped",e[e.Unauthorized=7]="Unauthorized",e[e.GeoRestricted=8]="GeoRestricted",e[e.GeoBlocked=9]="GeoBlocked",e[e.UnsupportedFeature=10]="UnsupportedFeature",e[e.NotFound=11]="NotFound",e[e.ConfigurationError=12]="ConfigurationError",e[e.TransientConfigurationError=13]="TransientConfigurationError",e[e.ConnectionError=14]="ConnectionError",e[e.ClientStartError=15]="ClientStartError",e[e.Error=16]="Error",e}(cn||{}),ln=cn,dn=function(){return o()((function e(n){t()(this,e),s()(this,"publisherInitialization",void 0),s()(this,"disposables",void 0),s()(this,"publisherDisposables",void 0),s()(this,"state",void 0),s()(this,"authorized",void 0),s()(this,"online",void 0),s()(this,"loading",void 0),s()(this,"publishing",void 0),s()(this,"standby",void 0),s()(this,"stopped",void 0),s()(this,"failureCount",void 0),s()(this,"endPoint",void 0),s()(this,"stream",void 0),s()(this,"rtcStatistics",void 0),s()(this,"clearFailureCountTimeout",void 0),s()(this,"startReconnectionAttemptsTimeInMilliseconds",void 0),s()(this,"name",void 0),this.disposables=new te,this.publisherDisposables=new te,this.publisherInitialization=new Date,this.state=new _(ln.Initializing),this.authorized=new _(!0),this.online=new _(!0),this.loading=new _(!1),this.publishing=new _(!1),this.standby=new _(!1),this.stopped=new _(!1),this.failureCount=new _(0),this.endPoint=new _(null),this.stream=new _(null),this.rtcStatistics=new _(null),this.clearFailureCountTimeout=0,this.name=n&&n.length?n:this.generateScreenName(),this.startReconnectionAttemptsTimeInMilliseconds=0}),[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":return this.authorized.value=!1,this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);case"not-found":return this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null)}}},{key:"mapPublishStatusToPublisherStatus",value:function(e){switch(e){case"ok":return ln.Starting;case"not-found":return ln.NotFound;case"geo-restricted":return ln.GeoRestricted;case"geo-blocked":return ln.GeoBlocked;case"unauthorized":return ln.Unauthorized;case"capacity":case"rate-limited":case"timeout":return ln.Recovering;case"missing-channel-or-room-id":case"forbidden-tag":return ln.ConfigurationError;case"port-in-range-not-found":return ln.TransientConfigurationError;case"failed":return ln.Error;default:G(e)}}},{key:"generateScreenName",value:function(){return X.random(12)}}])}(),hn=function(){return o()((function e(n,r){var i,o,a,u;if(t()(this,e),s()(this,"_estimatedRoundTripTime",void 0),s()(this,"_estimatedVideoCodec","unknown"),s()(this,"_estimatedAudioCodec","unknown"),s()(this,"_rtcStatistic",new _({})),s()(this,"_peerConnection",void 0),s()(this,"_isMonitorRunning",!0),s()(this,"_updateTimeout",null),s()(this,"_availableTracks",null),this._peerConnection=n,this._estimatedRoundTripTime=r,this._peerConnection&&null!==(i=this._peerConnection)&&void 0!==i&&null!==(o=i.currentLocalDescription)&&void 0!==o&&o.sdp&&null!==(a=this._peerConnection)&&void 0!==a&&null!==(u=a.currentRemoteDescription)&&void 0!==u&&u.sdp){var c=new _t(this._peerConnection.currentLocalDescription.sdp),l=new _t(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=l.audioCodec,this._estimatedVideoCodec=l.videoCodec,this._availableTracks={audio:c.isAudioTrackEnabled&&l.isAudioTrackEnabled,video:c.isVideoTrackEnabled&&l.isVideoTrackEnabled},this.updateStatistic()}}),[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(w.value.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(e=M()(V().mark((function e(){var t,n,r=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!P.getStatsPromiseBasedDisabled){e.next=3;break}return e.abrupt("return");case 3:return n=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=6,null===(t=this._peerConnection)||void 0===t?void 0:t.getStats(null).then((function(e){var t={};if(e){var i,o=r._estimatedRoundTripTime;e.forEach((function(a){if("candidate-pair"===a.type&&a.currentRoundTripTime&&(o=1e3*a.currentRoundTripTime,t.audio&&(t.audio.roundTripTime=o),t.video&&(t.video.roundTripTime=o)),"candidate-pair"===a.type&&a.lastPacketSentTimestamp&&(i=a.lastPacketSentTimestamp,t.audio&&(t.audio.lastPacketSentTimestamp=i),t.video&&(t.video.lastPacketSentTimestamp=i)),"outbound-rtp"===a.type){var s,u=a.kind||a.mediaType||n(a),c="";if(e.forEach((function(e){e.id===a.codecId&&(c=e.mimeType)})),u&&null!==(s=r._availableTracks)&&void 0!==s&&s[u]){var l,d,h,p,f,m,v,g=(a.bytesSent||0)-(null!==(l=null===(d=r._rtcStatistic.value)||void 0===d||null===(h=d[u])||void 0===h?void 0:h.bytesSent)&&void 0!==l?l:0),_=a.timestamp-(null===(p=r._rtcStatistic.value)||void 0===p||null===(f=p[u])||void 0===f?void 0:f.timestamp),y=g&&_?Math.floor(8*g/_*1e3):0;if(t[u]={ssrc:a.ssrc,mediaType:u,timestamp:a.timestamp,bitrate:y,bytesSent:a.bytesSent,packetsSent:a.packetsSent,retransmittedBytesSent:a.retransmittedBytesSent,codec:c||r.getCodecByType(u),roundTripTime:o},(a.lastPacketSentTimestamp||i)&&(t[u].lastPacketSentTimestamp=a.lastPacketSentTimestamp||i),"video"===u&&(t[u].firCount=a.firCount,t[u].frameHeight=a.frameHeight,t[u].frameWidth=a.frameWidth,t[u].framesEncoded=a.framesEncoded,t[u].framesSent=a.framesSent,t[u].headerBytesSent=a.headerBytesSent,t[u].hugeFramesSent=a.hugeFramesSent,t[u].pliCount=a.pliCount,t[u].qpSum=a.qpSum,t[u].totalEncodeTime=a.totalEncodeTime,t[u].totalEncodedBytesTarget=a.totalEncodedBytesTarget,null!==(m=r._rtcStatistic.value)&&void 0!==m&&null!==(v=m.video)&&void 0!==v&&v.framesEncoded)){var b=(a.framesEncoded-r._rtcStatistic.value.video.framesEncoded)/(t[u].timestamp-r._rtcStatistic.value.video.timestamp)*1e3;t[u].fps=b?Math.round(100*b)/100:0}}}}))}r._rtcStatistic.value=t})).then((function(){r._isMonitorRunning&&(r._updateTimeout=w.value.setTimeout((function(){return r.updateStatistic()}),1e3))}));case 6:e.sent;case 7:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec||"unknown";case"video":return this._estimatedVideoCodec||"unknown";default:return"unknown"}}}]);var e}(),pn=n(981).A;function fn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function mn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?fn(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var vn=function(){return o()((function e(n,r,i){t()(this,e),s()(this,"_logger",$.getLogger("RealTimePublisher")),s()(this,"_publisherContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_handleStreamFailure",void 0),this._publisherContext=n,this._peerConnectionContext=r,this._handleStreamFailure=i}),[{key:"start",value:function(e,t,n){var r=this;return w.value.navigatorIsOnLine?pn.all([et.discoverClosestEndPointWithCaching(e),ue.createPeerConnectionOffer("sendonly").then((function(e){var t=e.localOffer,n=e.peerConnection;return r._peerConnectionContext.peerConnection.value=n,{localOffer:t,peerConnection:n}}))]).then((function(e){var n=gt()(e,2),i=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;return r._publisherContext.online.value=!0,r._publisherContext.endPoint.value=i,r._logger.info("Connecting to [%s]",i.toString()),r._logger.info("Local offer:\n"+a.sdp),P.clientOfferDisabled||!s.supportsSetConfiguration||!s.supportsGetConfiguration||r._publisherContext.failureCount.value>0?(s.close(),s.dispose(),!Te.forceGarbageCollectionOnRestart||P.isMobile&&Te.skipGarbageCollectionOnMobileDevices||Ee.forceGarbageCollection(),r._peerConnectionContext.peerConnection.value=null,i.publish(r._publisherContext.name,t,null,r._publisherContext.failureCount.value)):i.publish(r._publisherContext.name,t,a,r._publisherContext.failureCount.value)})).then((function(e){var t=e.status;if(r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyStatus(t),"ok"!==t)return r._publisherContext.stream.value=null,void r._logger.info("[%s] Publish failed with status [%s]",r._publisherContext.streamId,t);var i=e.stream,o=e.rtcConfiguration,a=e.setRemoteDescriptionResponse,s=e.createOfferDescriptionResponse,u=e.createAnswerDescriptionResponse;return r._publisherContext.stream.value=i,r._logger.debug("[%s] Publish completed [%s] [%j] [%j] [%j] [%j]",r._publisherContext.streamId,t,o,a,s,u),r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyStatus(t),r.applyRtcConfiguration(r._peerConnectionContext.peerConnection.value,o).then((function(e){var t,o=!1,c=!1,l=[];return r._peerConnectionContext.peerConnection.value=e,e.addStream(r._peerConnectionContext.mediaStream.value),e.onicecandidate=function(n){r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e&&(o||Te.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?l.push(n.candidate):c=!0,t||(t=w.value.setTimeout((function(){var e;r._publisherContext.stream.value!==i||o||null===(e=r._publisherContext.endPoint.value)||void 0===e||e.addIceCandidates(i,l,c).then((function(e){var t=e.status,n=e.options;"ok"===t?(null!=n&&n.includes("cancel")&&(o=!0),r._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",r._publisherContext.streamId,t,n)):r._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",r._publisherContext.streamId,t)})).catch((function(e){r._logger.error("[%s] Failed to add ICE candidates",r._publisherContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e){var t=function(){r._publisherContext.state.value=ln.ConnectionError,r._publisherContext.publishing.value=!1,r._publisherContext.loading.value=!0,r._handleStreamFailure().catch((function(t){r._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",r._publisherContext.streamId,e.iceConnectionState,t)}))};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return r._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",r._publisherContext.streamId,e.iceConnectionState),void r.reconnectPeerConnection(e,t);case"closed":return r._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",r._publisherContext.streamId,e.iceConnectionState),void t();default:G(e.iceConnectionState)}}},new pn((function(e){e()})).then((function(){if(a)return r._logger.info("[%s] Set local SDP offer [%s]",r._publisherContext.streamId,a.sessionDescription.sdp),e.setLocalDescription(a.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,a.sessionDescription,e.message),e}))})).then((function(){var t;if(u)return r._logger.info("[%s] Set remote SDP answer [%s]",r._publisherContext.streamId,null==u||null===(t=u.sessionDescription)||void 0===t?void 0:t.sdp),e.setRemoteDescription(u.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,null==u?void 0:u.sessionDescription,e.message),e}))})).then((function(){if(s)return r._logger.info("[%s] Set remote SDP offer [%s]",r._publisherContext.streamId,s.sessionDescription.sdp),e.setRemoteDescription(s.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,null==u?void 0:u.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!1,offerToReceiveVideo:!1})})).then((function(e){r._logger.info("[%s] Set local SDP answer [%s]",r._publisherContext.streamId,e.sdp);var t=r._publisherContext.endPoint.value;if(!t)throw new Error("Failed to set remote description, EndPoint is not set");return t.setRemoteDescription(i,e)})).then((function(t){var n=t.status,i=t.sessionDescription;return r._publisherContext.state.value=r.mapSetRemoteDescriptionStatusToPublisherStatus(n),"ok"!==n?(r._publisherContext.publishing.value=!1,r._publisherContext.standby.value=!0,void(r._publisherContext.stopped.value=!1)):(r._logger.info("[%s] Set local SDP [%s]",r._publisherContext.streamId,null==i?void 0:i.sdp),e.setLocalDescription(i).catch((function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,i,e.message),e})))}))})).then((function(){var t;n.success(r._publisherContext.streamId),r._publisherContext.state.value=ln.Publishing,r._publisherContext.publishing.value=!0;var i=new hn(e,null!==(t=r._publisherContext.endPoint.value)&&void 0!==t&&t.roundTripTime?r._publisherContext.endPoint.value.roundTripTime/4:0);return r._publisherContext.disposables.add(i),i.rtcStatistic.subscribe((function(e){r._publisherContext.rtcStatistics.value=e})),pn.resolve()}))}))})):(this._publisherContext.state.value=ln.Offline,pn.resolve())}},{key:"applyRtcConfiguration",value:(e=M()(V().mark((function e(t,n){var r;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=yt.truncateIceServers(n),e.abrupt("return",Te.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=mn(mn({},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._publisherContext.state.value=ln.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Te.maximalNumberOfPeerConnectionReconnectAttempts||!Te.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(P.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!i){var o=w.value.setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);return void this._publisherContext.disposables.add(new f((function(){return w.value.clearTimeout(o)})))}this._logger.info("Reconnecting peer connection by restarting ICE");var a=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(r){return e.setLocalDescription(r).then((function(){return e.setLocalDescription(a).then((function(){if("disconnected"===e.iceConnectionState||"failed"===e.iceConnectionState){var r=w.value.setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);n._publisherContext.disposables.add(new f((function(){return w.value.clearTimeout(r)})))}else n._publisherContext.state.value=ln.Publishing}))}))})).catch((function(e){n._logger.error("Failed to reconnect peer connection",e),n._peerConnectionContext.peerConnectionReconnectAttempts=0,t()}))}else this._logger.info("Failed to reconnect peer connection after [%s] attempts, performing full recovery",this._peerConnectionContext.peerConnectionReconnectAttempts),this._peerConnectionContext.peerConnectionReconnectAttempts=0,t()}},{key:"mapSetRemoteDescriptionStatusToPublisherStatus",value:function(e){switch(e){case"ok":return ln.Starting;case"unauthorized":return ln.Unauthorized;case"not-found":return ln.NotFound;case"capacity":case"rate-limited":case"timeout":return ln.Recovering;case"failed":return ln.Error;default:G(e)}}}]);var e}(),gn=n(981).A,_n=function(){return o()((function e(n,r,i){var o=this;t()(this,e),s()(this,"_logger",$.getLogger("Publisher")),s()(this,"_tokenContext",void 0),s()(this,"_publisherContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_stateContext",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_publisherStartTime",void 0),s()(this,"_readOnlyToken",void 0),s()(this,"_readOnlyPeerConnection",void 0),s()(this,"_readOnlyState",void 0),s()(this,"_readOnlyTokenExpiring",void 0),s()(this,"_readOnlyAuthorized",void 0),s()(this,"_readOnlyOnline",void 0),s()(this,"_readOnlyLoading",void 0),s()(this,"_readOnlyPublishing",void 0),s()(this,"_readOnlyStandby",void 0),s()(this,"_readOnlyStopped",void 0),s()(this,"_readOnlyFailureCount",void 0),s()(this,"_readOnlyEndPoint",void 0),s()(this,"_readOnlyStream",void 0),s()(this,"_readOnlyRtcStatistics",void 0),s()(this,"_readOnlyMediaStream",void 0),s()(this,"_metricsService",void 0),s()(this,"_sessionTelemetry",void 0),this._tokenContext=new Ue(r),this._publisherContext=new dn(i),this._peerConnectionContext=new Ge,this._stateContext=new We,this._exponentialBackoff=new ye,this._publisherStartTime=Date.now(),this._readOnlyToken=new y(this._tokenContext.token),this._readOnlyPeerConnection=new y(this._peerConnectionContext.peerConnection),this._readOnlyState=new y(this._publisherContext.state),this._readOnlyTokenExpiring=new y(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new y(this._publisherContext.authorized),this._readOnlyOnline=new y(this._publisherContext.online),this._readOnlyLoading=new y(this._publisherContext.loading),this._readOnlyPublishing=new y(this._publisherContext.publishing),this._readOnlyStandby=new y(this._publisherContext.standby),this._readOnlyStopped=new y(this._publisherContext.stopped),this._readOnlyFailureCount=new y(this._publisherContext.failureCount),this._readOnlyEndPoint=new y(this._publisherContext.endPoint),this._readOnlyStream=new y(this._publisherContext.stream),this._readOnlyRtcStatistics=new y(this._publisherContext.rtcStatistics),this._readOnlyMediaStream=new y(this._peerConnectionContext.mediaStream),this._peerConnectionContext.mediaStream.value=n;var a=ee.parseToken(this._tokenContext.token.value),u=(a.uri||Te.discoveryUri.value).toString();Te.tenancy.value=a.tenancy||Te.tenancy.value,he.uri.value=u,this._metricsService=xe.getMetricsService(u),this._sessionTelemetry=new Me(Te.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe((function(e){o._publisherContext.clearFailureCountTimeout&&w.value.clearTimeout(o._publisherContext.clearFailureCountTimeout),o._publisherContext.failureCount.value&&e===ln.Publishing&&(o._publisherContext.clearFailureCountTimeout=w.value.setTimeout((function(){o._publisherContext.failureCount.value=0}),3e3))})));var c=function(){o._publisherContext.stream.value&&o._publisherContext.endPoint.value&&o._publisherContext.endPoint.value.destroyStreamOnUnmount(o._publisherContext.stream.value,"client:termination-on-window-unload")};w.value.addWindowEventListener("beforeunload",c),this._publisherContext.publisherDisposables.add(new f((function(){w.value.removeWindowEventListener("beforeunload",c)}))),this.start()}),[{key:"token",get:function(){return this._tokenContext.token.value},set:function(e){this._publisherContext.disposables.dispose(),this._tokenContext.token.value=e,this._tokenContext.tokenExpiring.value=!1;var t=ee.parseToken(this._tokenContext.token.value),n=(t.uri||Te.discoveryUri.value).toString();Te.tenancy.value=t.tenancy||Te.tenancy.value,he.uri.value=n,this._metricsService=xe.getMetricsService(n),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"publishing",get:function(){return this._readOnlyPublishing}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._publisherContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"stop",value:(a=M()(V().mark((function e(t){var n=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new gn((function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._publisherContext.disposables.add(n._stateContext.isStarting.subscribe((function(r){r||(n.processStop(t),e())})))})));case 1:case"end":return e.stop()}}),e)}))),function(e){return a.apply(this,arguments)})},{key:"processStop",value:function(e){this.cleanUpResources(e),this._peerConnectionContext.peerConnection.value&&(this._peerConnectionContext.peerConnection.value.close(),this._peerConnectionContext.peerConnection.value=null),this._publisherContext.state.value=ln.Stopped}},{key:"dispose",value:(i=M()(V().mark((function e(){var t=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stop("client:channel-dispose").then((function(){t._publisherContext.publisherDisposables.dispose(),t._stateContext.isDisposed=!0})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getUri",value:function(e){return ee.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",Te.discoveryUri.value),new w.value.URL(Te.discoveryUri.value))}},{key:"start",value:(r=M()(V().mark((function e(){return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._stateContext.isStarting.value){e.next=5;break}return this._logger.info("Publisher is already starting, skipping start"),e.abrupt("return");case 5:return this._stateContext.isStarting.value=!0,e.abrupt("return",this.processStart());case 7:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"processStart",value:(n=M()(V().mark((function e(){var t,n,r,i,o,a=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publisherContext.state.value=ln.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),ee.isEncodedEdgeTokenValid(t)){e.next=10;break}return this._logger.error("Failed to parse token [%s]",t),this._publisherContext.state.value=ln.Unauthorized,this._publisherContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 10:return this._publisherContext.loading.value=!0,r=this.getUri(t),this._publisherContext.disposables.add(this._publisherContext.state.subscribe((function(e){e!==ln.Error&&e!==ln.Recovering||et.clearCachedClosestEndpoint(r)}))),i=function(){return new gn((function(e){return a._stateContext.isStarting.value=!1,e(a.handleStreamFailure())}))},o=new vn(this._publisherContext,this._peerConnectionContext,i),e.abrupt("return",o.start(r,t,n).then((function(){a._publisherContext.loading.value=!1})).catch((function(e){n.fail(),a._publisherContext.failureCount.value++,a._publisherContext.online.value=!1,a.cleanUpResources("client:cleanup-after-failed-setup"),a._publisherContext.state.value=ln.ClientStartError,a._logger.error("Failed to start publishing",e)})).finally((function(){if(a._stateContext.isStarting.value=!1,a._publisherContext.state.value!==ln.Publishing&&Te.automaticRetryOnFailure){var e=w.value.setTimeout((function(){a.handleStreamFailure().catch((function(e){a._logger.error("Failed handling stream failure",e)}))}),a.getRetryInterval());a._publisherContext.disposables.add(new f((function(){w.value.clearTimeout(e)})))}else a._publisherContext.startReconnectionAttemptsTimeInMilliseconds=0})));case 16:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"setMediaStream",value:function(e){var t=this;this._peerConnectionContext.mediaStream.value=e,this._peerConnectionContext.peerConnection.value&&e.getTracks().forEach((function(e){var n;null===(n=t._peerConnectionContext.peerConnection.value)||void 0===n||n.getSenders().forEach((function(t){var n;e.kind===(null==t||null===(n=t.track)||void 0===n?void 0:n.kind)&&e.id!==t.track.id&&t.replaceTrack(e)}))}))}},{key:"getRetryInterval",value:function(){switch(this._publisherContext.state.value){case ln.Offline:return 15e3;case ln.Initializing:case ln.NotFound:case ln.Error:case ln.Recovering:case ln.Unauthorized:case ln.GeoRestricted:case ln.GeoBlocked:case ln.Stopped:case ln.Starting:case ln.Publishing:case ln.Reconnecting:case ln.UnsupportedFeature:case ln.ConfigurationError:case ln.TransientConfigurationError:case ln.ConnectionError:case ln.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._publisherContext.failureCount.value);default:G(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:(e=M()(V().mark((function e(){return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._publisherContext.state.value,e.next=e.t0===ln.Error||e.t0===ln.Reconnecting||e.t0===ln.Offline||e.t0===ln.Recovering||e.t0===ln.TransientConfigurationError||e.t0===ln.ConnectionError||e.t0===ln.ClientStartError?4:e.t0===ln.Unauthorized?11:e.t0===ln.GeoRestricted?13:e.t0===ln.GeoBlocked?15:e.t0===ln.Stopped?17:e.t0===ln.Publishing?19:e.t0===ln.Initializing?21:e.t0===ln.Starting?23:e.t0===ln.UnsupportedFeature?25:e.t0===ln.NotFound?27:e.t0===ln.ConfigurationError?29:31;break;case 4:if(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds||(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds=Date.now()),!(72e5<=Date.now()-this._publisherContext.startReconnectionAttemptsTimeInMilliseconds)){e.next=9;break}return this._logger.info("Publisher stopped with state [%s] [%s] after exceeding timeout",this._publisherContext.state.value,ln[this._publisherContext.state.value]),e.abrupt("return");case 9:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,ln[this._publisherContext.state.value]),e.abrupt("break",32);case 11:return this._logger.info("Publisher is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 13:return this._logger.info("Publisher is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 15:return this._logger.info("Publisher is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 17:return this._logger.info("Publisher is stopped, skipping retry of start."),e.abrupt("return");case 19:return this._logger.info("Publisher is publishing, skipping retry of start"),e.abrupt("return");case 21:return this._logger.info("Publisher is initializing, skipping retry of start"),e.abrupt("return");case 23:return this._logger.info("Publisher is already starting, skipping retry of start"),e.abrupt("return");case 25:return this._logger.info("Publisher is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 27:return this._logger.info("Publisher is stopped due to channel not found, skipping retry of start."),e.abrupt("return");case 29:return this._logger.info("Publisher is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 31:G(this._publisherContext.state.value);case 32:return e.abrupt("return",this.start());case 33:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._publisherContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!Te.forceGarbageCollectionOnRestart||P.isMobile&&Te.skipGarbageCollectionOnMobileDevices||Ee.forceGarbageCollection()),this._publisherContext.publishing.value=!1,this._publisherContext.stopped.value=!0,this._publisherContext.standby.value=!1,this._publisherContext.stream.value&&this._publisherContext.endPoint.value&&this._publisherContext.endPoint.value.destroyStream(this._publisherContext.stream.value,t).then((function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)})).catch((function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)})),this._publisherContext.stream.value=null,this._publisherContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}}]);var e,n,r,i,a}(),yn=function(){return o()((function e(){throw t()(this,e),new Error("Publishers is a static class that may not be instantiated")}),null,[{key:"createPublisher",value:function(e){if(!Te.initialized.value)throw new Error("SDK is not loaded.");return new _n(e.mediaStream,e.token,e.name)}}])}(),bn={SDK:Te,Channels:un,ChannelState:Ie,Publishers:yn,PublisherState:ln}})(),r})()));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.phenix=t():e.phenix=t()}(self,(()=>(()=>{var e={981:(e,t,n)=>{"use strict";n.d(t,{A:()=>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=null,this._deferreds=[],this.doResolve(t)}return u()(e,[{key:"doResolve",value:function(e){var t=this,n=!1;try{e((function(e){n||(n=!0,t.promiseResolve(e))}),(function(e){n||(n=!0,t.promiseReject(e))}))}catch(e){if(n)return;n=!0,this.promiseReject(e)}}},{key:"promiseResolve",value:function(t){var n=this;try{if(t===n)throw new TypeError("A Promise cannot be resolved with it self.");if(t&&("object"===i()(t)||"function"==typeof t)){var r=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof r)return void n.doResolve((function(){r.apply(t,arguments)}))}n._state=1,n._value=t,n.finale()}catch(e){n.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate((function(){t._handled||e._unhandledRejection(t._value)}));for(var n=0,r=this._deferreds.length;n<r;n++)this.handle(this._deferreds[n]);this._deferreds=[]}},{key:"handle",value:function(t){for(var n=this;3===n._state;)n=n._value;0!==n._state?(n._handled=!0,e._immediate((function(){var e=1===n._state?t.onFulfilled:t.onRejected;if(null!==e){var r;try{r=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(r)}else 1===n._state?t.promise.promiseResolve(n._value):t.promise.promiseReject(n._value)}))):n._deferreds.push(t)}}],[{key:"all",value:function(t){return new e((function(e,n){if(!Array.isArray(t))return n(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);for(var o=r.length,a=function(t,s){try{if(s&&("object"===i()(s)||"function"==typeof s)){var u=s.then;if("function"==typeof u)return void u.call(s,(function(e){return a(t,e)}),n)}r[t]=s,0==--o&&e(r)}catch(e){n(e)}},s=0;s<r.length;s++)a(s,r[s])}))}},{key:"resolve",value:function(t){return t&&"object"===i()(t)&&t.constructor===e?t:new e((function(e){return e(t)}))}},{key:"reject",value:function(t){return new e((function(e,n){return n(t)}))}},{key:"race",value:function(t){return new e((function(n,r){if(!Array.isArray(t))return r(new TypeError("Promise.race accepts an array"));for(var i=0,o=t.length;i<o;i++)e.resolve(t[i]).then(n,r)}))}},{key:"_immediate",value:function(e){window.setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}])}();h.prototype.catch=function(e){return this.then(null,e)},h.prototype.then=function(e,t){var n=new h((function(){return null}));return this.handle(new d(e,t,n)),n},h.prototype.finally=function(e){return this.then((function(t){return h.resolve(e()).then((function(){return t}),(function(){return null}))}),(function(t){return h.resolve(e()).then((function(){return h.reject(t)}),(function(){return null}))}))};var p=h},512:e=>{"use strict";e.exports=function(e,t,n,r){var i=self||window;try{try{var o;try{o=new i.Blob([e])}catch(t){(o=new(i.BlobBuilder||i.WebKitBlobBuilder||i.MozBlobBuilder||i.MSBlobBuilder)).append(e),o=o.getBlob()}var a=i.URL||i.webkitURL,s=a.createObjectURL(o),u=new i[t](s,n);return a.revokeObjectURL(s),u}catch(r){return new i[t]("data:application/javascript,".concat(encodeURIComponent(e)),n)}}catch(e){if(!r)throw Error("Inline worker is not supported");return new i[t](r,n)}}},79:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},987:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},901:(e,t,n)=>{var r=n(79);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},475:e=>{e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},293:(e,t,n)=>{var r=n(981).A;function i(e,t,n,i,o,a,s){try{var u=e[a](s),c=u.value}catch(e){return void n(e)}u.done?t(c):r.resolve(c).then(i,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new r((function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,u,"next",e)}function u(e){i(a,r,o,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,n)=>{var r=n(736);function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}e.exports=function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,t,n)=>{var r=n(736);e.exports=function(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},e.exports.__esModule=!0,e.exports.default=e.exports},72:e=>{function t(n){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},511:(e,t,n)=>{var r=n(636);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},291:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},156:e=>{e.exports=function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}},e.exports.__esModule=!0,e.exports.default=e.exports},752:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},869:e=>{e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},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(981).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 C?t:C,o=Object.create(i.prototype),a=new L(r||[]);return u(o,"_invoke",{value:I(e,n,a)}),o}function m(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=f;var v="suspendedStart",g="suspendedYield",_="executing",y="completed",b={};function C(){}function k(){}function S(){}var x={};p(x,l,(function(){return this}));var w=Object.getPrototypeOf,T=w&&w(w(A([])));T&&T!==a&&s.call(T,l)&&(x=T);var P=S.prototype=C.prototype=Object.create(x);function E(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function F(e,t){function n(r,o,a,u){var c=m(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 I(e,n,r){var i=v;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=R(s,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===v)throw i=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=_;var c=m(e,n,r);if("normal"===c.type){if(i=r.done?y:g,c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=y,r.method="throw",r.arg=c.arg)}}}function R(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,R(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var o=m(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,b;var a=o.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function A(e){if(e||""===e){var n=e[l];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var 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}},E(F.prototype),p(F.prototype,d,(function(){return this})),n.AsyncIterator=F,n.async=function(e,t,i,o,a){void 0===a&&(a=r);var s=new F(f(e,t,i,o),a);return n.isGeneratorFunction(t)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},E(P),p(P,h,"Generator"),p(P,l,(function(){return this})),p(P,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),n=[];for(var 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,L.prototype={constructor:L,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(O),!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,b):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),O(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;O(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),b}},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.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{ChannelState:()=>De,Channels:()=>ln,PublisherState:()=>hn,Publishers:()=>Cn,SDK:()=>Ee,default:()=>kn});var e=n(383),t=n.n(e),i=n(579),o=n.n(i),a=n(693),s=n.n(a),u=n(452),c=n.n(u),l=n(72),d=n.n(l),h=n(511),p=n.n(h),f=function(){return o()((function e(n){t()(this,e),s()(this,"_disposed",void 0),s()(this,"_disposable",void 0),this._disposed=!1,this._disposable=n}),[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}])}();function m(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(m=function(){return!!e})()}var v,g=function(e){function n(e,r){return t()(this,n),i=this,o=n,a=[function(){var t=e.indexOf(r);t>=0&&e.splice(t,1)}],o=d()(o),c()(i,m()?Reflect.construct(o,a||[],d()(i).constructor):o.apply(i,a));var i,o,a}return p()(n,e),o()(n)}(f),_=function(){return o()((function e(n){t()(this,e),s()(this,"_listeners",void 0),s()(this,"_value",void 0),this._listeners=[],this._value=n}),[{key:"value",get:function(){return this._value},set:function(e){var t=this._value!==e;if(t&&e){var n=e;"function"==typeof n.equals&&(t=!n.equals(this._value))}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 g(this._listeners,e)}}])}(),y=function(){return o()((function e(n){t()(this,e),s()(this,"_subject",void 0),this._subject=n}),[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}])}(),b={document,location,navigator,window},C=function(){function e(n){t()(this,e),s()(this,"_document",void 0),s()(this,"_location",void 0),s()(this,"_navigator",void 0),s()(this,"_window",void 0),this._document=n.document,this._location=n.location,this._navigator=n.navigator,this._window=n.window}return o()(e,[{key:"FormData",get:function(){return this._window.FormData}},{key:"MediaStream",get:function(){return this._window.MediaStream}},{key:"MediaStreamTrack",get:function(){return this._window.MediaStreamTrack}},{key:"RTCPeerConnection",get:function(){return this._window.RTCPeerConnection}},{key:"RTCSessionDescription",get:function(){return this._window.RTCSessionDescription}},{key:"RTCIceCandidate",get:function(){return this._window.RTCIceCandidate}},{key:"URL",get:function(){return this._window.URL}},{key:"URLSearchParams",get:function(){return this._window.URLSearchParams}},{key:"addDocumentEventListener",get:function(){return this._document.addEventListener.bind(this._document)}},{key:"addWindowEventListener",get:function(){return this._window.addEventListener.bind(this._window)}},{key:"clearInterval",get:function(){return this._window.clearInterval.bind(this._window)}},{key:"clearTimeout",get:function(){return this._window.clearTimeout.bind(this._window)}},{key:"documentCreateElement",get:function(){return this._document.createElement.bind(this._document)}},{key:"documentHasFocus",get:function(){return this._document.hasFocus.bind(this._document)}},{key:"documentIsHidden",get:function(){return!!this._document.hidden}},{key:"documentQuerySelector",get:function(){return this._document.querySelector.bind(this._document)}},{key:"fetch",get:function(){return this._window.fetch.bind(this._window)}},{key:"locationHostname",get:function(){return this._location.hostname}},{key:"locationSearch",get:function(){return this._location.search}},{key:"navigatorConnection",get:function(){return this._navigator.connection}},{key:"navigatorIsOnLine",get:function(){return this._navigator.onLine}},{key:"pageLoadTime",get:function(){return this._window.__phenixPageLoadTime||this._window.__pageLoadTime}},{key:"queueMicrotask",get:function(){return this._window.queueMicrotask.bind(this._window)}},{key:"removeDocumentEventListener",get:function(){return this._document.removeEventListener.bind(this._document)}},{key:"removeWindowEventListener",get:function(){return this._window.removeEventListener.bind(this._window)}},{key:"setInterval",get:function(){return this._window.setInterval.bind(this._window)}},{key:"setTimeout",get:function(){return this._window.setTimeout.bind(this._window)}}],[{key:"setInstance",value:function(e){throw new Error("This build does not support setting the GlobalScope")}},{key:"getInstance",value:function(){return e._readOnlyInstance}},{key:"subscribe",value:function(t){return e._readOnlyInstance.subscribe(t)}}])}();v=C,s()(C,"_instance",new _(new v(b))),s()(C,"_readOnlyInstance",new y(v._instance));var k,S,x,w=C.getInstance(),T=function(){function e(){t()(this,e)}return o()(e,null,[{key:"browserNameAndVersion",get:function(){return e._browserNameAndVersion}},{key:"browserName",get:function(){return this._browserName}},{key:"browserMajorVersion",get:function(){return this._browserMajorVersion}},{key:"isAndroid",get:function(){return e._isAndroid}},{key:"isChrome69",get:function(){return e._isChrome69}},{key:"isChrome70",get:function(){return e._isChrome70}},{key:"isChrome71",get:function(){return e._isChrome71}},{key:"isChrome72",get:function(){return e._isChrome72}},{key:"isChrome74",get:function(){return e._isChrome74}},{key:"isChrome75",get:function(){return e._isChrome75}},{key:"isChrome76",get:function(){return e._isChrome76}},{key:"isChrome77",get:function(){return e._isChrome77}},{key:"isMobile",value:function(){return e._isMobile}},{key:"parseBrowserNameAndVersion",value:function(){if(!navigator||!navigator.userAgent)return"";var t=navigator.userAgent.match(e._browserNameAndVersionRegex);return t&&t[0]?t[0]:e.parseBrowserNameAndVersionForIE()}},{key:"parseBrowserName",value:function(){if(!e._browserNameAndVersion)return"";var t=e._browserNameAndVersion.split("/");return t&&t[0]?t[0]:""}},{key:"parseBrowserMajorVersion",value:function(){if(!e._browserNameAndVersion)return 0;var t=e._browserNameAndVersion.split("/");if(!t||!t[1])return 0;var n=t[1];return n&&Number(n.split(".")[0])||0}},{key:"parseBrowserNameAndVersionForIE",value:function(){if(!navigator||!navigator.userAgent)return"";var e=navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return"IE/".concat(parseInt(e.substring(t+5,e.indexOf(".",t)),10));if(e.indexOf("Trident/")>0){var n=e.indexOf("rv:");return"IE/".concat(parseInt(e.substring(n+3,e.indexOf(".",n)),10))}return""}}])}();k=T,s()(T,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),s()(T,"_browserNameAndVersion",k.parseBrowserNameAndVersion()),s()(T,"_browserName",k.parseBrowserName()),s()(T,"_browserMajorVersion",k.parseBrowserMajorVersion()),s()(T,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(S=navigator)||void 0===S?void 0:S.userAgent)),s()(T,"_isAndroid",/Android/i.test(null===(x=navigator)||void 0===x?void 0:x.userAgent)),s()(T,"_isChrome69",k._browserNameAndVersion.includes("Chrome/69.")),s()(T,"_isChrome70",k._browserNameAndVersion.includes("Chrome/70.")),s()(T,"_isChrome71",k._browserNameAndVersion.includes("Chrome/71.")),s()(T,"_isChrome72",k._browserNameAndVersion.includes("Chrome/72.")),s()(T,"_isChrome74",k._browserNameAndVersion.includes("Chrome/74.")),s()(T,"_isChrome75",k._browserNameAndVersion.includes("Chrome/75.")),s()(T,"_isChrome76",k._browserNameAndVersion.includes("Chrome/76.")),s()(T,"_isChrome77",k._browserNameAndVersion.includes("Chrome/77."));var P=function(){function e(){t()(this,e)}return o()(e,null,[{key:"clientOfferDisabled",get:function(){return T.isChrome74||T.isChrome75||T.isChrome76||T.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return T.isChrome69||T.isChrome70||T.isChrome71||T.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=69||"Firefox"===T.browserName&&T.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=63||"Firefox"===T.browserName&&T.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===T.browserName&&T.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===T.browserName||"SamsungBrowser"===T.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==T.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===T.browserName&&"function"==typeof(null===(e=w.value)||void 0===e?void 0:e.documentCreateElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===T.browserName&&T.browserMajorVersion>=71||"Firefox"===T.browserName&&T.browserMajorVersion>=69||"Safari"===T.browserName}},{key:"isMobile",get:function(){return T.isMobile()}},{key:"isInsertableStreamsSupported",get:function(){return!("undefined"==typeof MediaStreamTrackProcessor||"undefined"==typeof MediaStreamTrackGenerator)}},{key:"isEncodedInsertableStreamsSupported",get:function(){return"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams}},{key:"isRTCRtpScriptTransformSupported",get:function(){return"undefined"!=typeof RTCRtpScriptTransform}},{key:"isRequestVideoFrameCallbackSupported",get:function(){return void 0!==HTMLVideoElement.prototype.requestVideoFrameCallback}},{key:"isChannelFrameTimingInformationSupported",get:function(){return e.isRequestVideoFrameCallbackSupported&&(e.isEncodedInsertableStreamsSupported||e.isRTCRtpScriptTransformSupported)}},{key:"errorStackAlsoHasErrorMessage",get:function(){return"Firefox"!==T.browserName&&"Safari"!==T.browserName}}])}(),E=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),F=function(){return o()((function e(n,r,i){t()(this,e),s()(this,"_category",void 0),s()(this,"_appenders",void 0),s()(this,"_threshold",void 0),this._category=n,this._appenders=r,this._threshold=i}),[{key:"category",get:function(){return this._category}},{key:"appenders",get:function(){return this._appenders}},{key:"threshold",get:function(){return this._threshold}},{key:"trace",value:function(){if(this._threshold.value&&!(this._threshold.value>E.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(E.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>E.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(E.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>E.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(E.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>E.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(E.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>E.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(E.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>E.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(E.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?P.errorStackAlsoHasErrorMessage?e+"\n"+t.toString(n.stack):e+"\n"+t.toString(n.message)+"\n"+t.toString(n.stack):e+"[".concat(t.toString(n),"]")}))),e.toString()}},{key:"stringify",value:function(e){var t=[];try{return JSON.stringify(e instanceof Error?this.toString(e):e,(function(e,n){if(n&&n instanceof Object){if(t.includes(n))return"<recursive>";t.push(n)}return n}),2)}catch(e){return"[object invalid JSON.stringify]"}}},{key:"replaceArgument",value:function(e,t,n){return t.substring(0,n)+this.toString(e)+t.substring(n+2)}},{key:"toString",value:function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e)return e.toString();var t="";if(e)if("function"==typeof e)t=e.toString();else if(e instanceof Object)try{t=e.toString()}catch(e){t="[object invalid toString()]"}return t}}])}(),I=function(){return o()((function e(){t()(this,e),s()(this,"_appenders",[])}),[{key:"value",get:function(){return this._appenders}},{key:"add",value:function(e){this._appenders.push(e)}},{key:"remove",value:function(e){this._appenders=this._appenders.reduce((function(t,n){return n!==e&&t.push(n),t}),[])}}])}(),R=function(){return o()((function e(){t()(this,e)}),null,[{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"sendLogs",get:function(){return this._sendLogs}},{key:"sendMetrics",get:function(){return this._sendMetrics}},{key:"logToConsole",get:function(){return this._logToConsole}},{key:"applyFeatures",value:function(){try{var e={sendLocalCandidates:!0,sendLogs:"All",sendMetrics:"All",logToConsole:"All"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}])}();s()(R,"_sendLocalCandidates",void 0),s()(R,"_sendLogs",void 0),s()(R,"_sendMetrics",void 0),s()(R,"_logToConsole",void 0),R.applyFeatures();var D=function(){return o()((function e(){t()(this,e)}),null,[{key:"defaultLoggingLevel",get:function(){return E[R.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return E[R.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return E.Info}}])}(),O=function(){return o()((function e(){t()(this,e),s()(this,"_threshold",D.defaultLoggingLevel)}),[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}])}(),L=function(){return o()((function e(n){t()(this,e),s()(this,"_threshold",void 0),this._threshold=n}),[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(E[e],"] ").concat(t);e<E.Warn?console.log(i):console.error(i)}}}])}(),A=n(293),M=n.n(A),N=n(756),V=n.n(N),U=function(){function e(){throw t()(this,e),new Error("Numbers is a static class that may not be instantiated")}return o()(e,null,[{key:"countNumberLength",value:function(t){var n=0,r=t;return r<0&&(r*=-1,n++),e.countDigitsBeforeDecimal(r)+n+(r!==Math.floor(r)?e.countDigitsAfterDecimal(r)+1:0)}},{key:"fixRounding",value:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}},{key:"countDigitsBeforeDecimal",value:function(e){for(var t=1,n=e;n>=10;)n/=10,t++;return t}},{key:"countDigitsAfterDecimal",value:function(t){for(var n=t,r=Math.floor(t),i=0;r!==n&&i<15;)i++,r=e.fixRounding(n,i);return i}}])}(),B=function(){return o()((function e(){t()(this,e)}),null,[{key:"sdkVersion",get:function(){try{return"2025-02-05T23:09:47.932Z (2025.0.2)"}catch(e){return this._defaultVersion}}}])}();s()(B,"_defaultVersion",(new Date).toISOString());var j=n(981).A,z=function(){return o()((function e(n){var r=this;t()(this,e),s()(this,"_telemetryConfiguration",void 0),s()(this,"_logs",[]),s()(this,"_isSending",!1),s()(this,"_domain",""),this._telemetryConfiguration=n,this.getLocationHostnameFromGlobalScope().then((function(e){r._domain=e}))}),[{key:"push",value:function(e,t,n,r){var i=(r.valueOf()-this._telemetryConfiguration.pageLoadTime)/1e3,o={timestamp:r.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:E[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:B.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<E.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new j((function(e){var t=w.subscribe((function(n){n&&(e(n.locationHostname),t.dispose())}))}))}},{key:"sendLogs",value:(n=M()(V().mark((function e(t){var n;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new w.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,w.value.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 n.apply(this,arguments)})},{key:"sendLogsIfAble",value:(e=M()(V().mark((function e(){var t,n,r,i,o,a=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._logs.length<=0||this._isSending)&&w.value){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?U.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,n}(),H=function(){return o()((function e(n){t()(this,e),s()(this,"_telemetryService",void 0),s()(this,"_tenancy",void 0),s()(this,"_sessionId",void 0),s()(this,"_threshold",void 0),this._tenancy=n.tenancy,this._sessionId=n.sessionId,this._threshold=n.threshold,this._telemetryService=new z(n)}),[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}])}(),G=function(){return o()((function e(){t()(this,e),s()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),s()(this,"_tenancy","-"),s()(this,"_sessionId","-"),s()(this,"_environment","-"),s()(this,"_pageLoadTime",0),s()(this,"_threshold",D.defaultTelemetryLoggingLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new w.value.URL(e);t.pathname=t.pathname+"/logs",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"pageLoadTime",get:function(){return this._pageLoadTime},set:function(e){this._pageLoadTime=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}])}(),W=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},q=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case E.Off:return"Off";case E.Trace:return"Trace";case E.Debug:return"Debug";case E.Info:return"Trace";case E.Warn:return"Warn";case E.Error:return"Error";case E.Fatal:return"Fatal";case E.All:return"All";default:W(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return E.Off;case"Trace":return E.Trace;case"Debug":return E.Debug;case"Info":return E.Info;case"Warn":return E.Warn;case"Error":return E.Error;case"Fatal":return E.Fatal;case"All":return E.All;default:W(e)}}}])}(),J=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),K=function(){return o()((function e(){t()(this,e),s()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),s()(this,"_tenancy","-"),s()(this,"_sessionId","-"),s()(this,"_environment","-"),s()(this,"_threshold",Z.defaultTelemetryLevel)}),[{key:"url",get:function(){return this._url},set:function(e){var t=new w.value.URL(e);t.pathname=t.pathname+"/metrics",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}])}(),Z=function(){return o()((function e(){t()(this,e)}),null,[{key:"defaultTelemetryLevel",get:function(){return J[R.sendMetrics]}}])}(),Q=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case J.Off:return"Off";case J.Essential:return"Essential";case J.All:return"All";default:W(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return J.Off;case"Essential":return J.Essential;case"All":return J.All;default:W(e)}}}])}(),$=function(){function e(){t()(this,e)}return o()(e,null,[{key:"getStringValue",value:function(t){return e.readConfigurationParameterValue(t)||e.readConfigurationParameterURIValue("".concat(t,"-uri-parameter-name"))||e.defaultStringValue[t]}},{key:"getBooleanValue",value:function(t){var n=e.readConfigurationParameterValue(t);if(n)return"true"===n||"1"===n||"On"===n;var r=e.readConfigurationParameterURIValue("".concat(t,"-uri-parameter-name"));return r?"true"===r||"1"===r||"On"===r:!0===e.defaultBooleanValue[t]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":Q.convertTelemetryLevelToTelemetryLevelType(Z.defaultTelemetryLevel),"phenix-logging-level":q.convertLoggingLevelToLoggingLevelType(D.defaultLoggingLevel),"phenix-console-logging-level":q.convertLoggingLevelToLoggingLevelType(D.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":q.convertLoggingLevelToLoggingLevelType(D.defaultTelemetryLoggingLevel),"phenix-channel-token":"","phenix-uri":"","phenix-base-uri":""}}},{key:"defaultBooleanValue",get:function(){return{"phenix-automatically-retry-on-failure":!0,"phenix-automatically-reconnect-peer-connection":!0,"phenix-force-garbage-collection-on-restart":!0,"phenix-skip-garbage-collection-on-mobile-devices":!0}}},{key:"readConfigurationParameterValue",value:function(e){var t=w.value.documentQuerySelector("meta[name='".concat(e,"']"));if(t){var n=t.getAttribute("value");if(n)return n}}},{key:"readConfigurationParameterURIValue",value:function(t){var n=e.readConfigurationParameterValue(t);if(n){var r=new w.value.URLSearchParams(w.value.locationSearch).get(n)||void 0;if(r)return r}}}])}(),X=function(){function e(){throw t()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return o()(e,null,[{key:"telemetryConfiguration",get:function(){return e._telemetryConfiguration}},{key:"getLogger",value:function(t){return"string"!=typeof t&&(t="SDK"),e._loggers[t]||(e._loggers[t]=new F(t,this._appenders,this._threshold))}},{key:"applyLoggerConfigFromParameterConfiguration",value:function(){e.applyLoggingLevel(),e.applyAppenderLoggingLevel("console",e.applyConsoleLogger.bind(this)),e.applyAppenderLoggingLevel("telemetry",e.applyTelemetryLogger.bind(this))}},{key:"applyLoggingLevel",value:function(){var e=$.getStringValue("phenix-logging-level");E[e]&&this._threshold.setThreshold(E[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=$.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(E[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new L(e||D.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||D.defaultTelemetryLoggingLevel,this._appenders.add(new H(this._telemetryConfiguration))}}])}();s()(X,"_loggers",{}),s()(X,"_appenders",new I),s()(X,"_threshold",new O),s()(X,"_telemetryConfiguration",new G),X.applyLoggerConfigFromParameterConfiguration();var Y=function(){return o()((function e(){throw t()(this,e),new Error("Strings is a static class that may not be instantiated")}),null,[{key:"random",value:function(e){var t=Math.ceil(e/13);return new Array(t).fill((function(){return Math.random().toString(16).substring(2,15)})).reduce((function(e,t){return e+t()}),"").substring(0,e)}}])}(),ee=function(){return o()((function e(n){var r,i;t()(this,e),s()(this,"_applicationId",void 0),s()(this,"_token",void 0),this._applicationId=(null==n?void 0:n.applicationId)||"",this._token={uri:null!=n&&null!==(r=n.token)&&void 0!==r&&r.uri?new w.value.URL(n.token.uri):null,capabilities:(null==n||null===(i=n.token)||void 0===i?void 0:i.capabilities)||[]}}),[{key:"uri",get:function(){return this._token.uri}},{key:"capabilities",get:function(){return this._token.capabilities}},{key:"tenancy",get:function(){return this._applicationId}}])}(),te=function(){function e(){t()(this,e)}return o()(e,null,[{key:"parseToken",value:function(t){if(!this.isEncodedEdgeTokenValid(t))return e._logger.error("Token is not valid [%s]",t),new ee(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new ee(r)}catch(t){return e._logger.error("Cannot parse token value",t),new ee(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();s()(te,"_logger",X.getLogger("EdgeAuthParser"));var ne=function(){return o()((function e(){t()(this,e),s()(this,"_list",[])}),[{key:"add",value:function(e){this._list.push(e)}},{key:"dispose",value:function(){this._list.forEach((function(e){return e.dispose()})),this._list.length=0}},{key:"toString",value:function(){return"DisposableList[disposables=".concat(this._list.length,"]")}}])}(),re="visibilitychange",ie=function(){return o()((function e(){t()(this,e),s()(this,"_disposables",new ne),s()(this,"_readOnlyIsForeground",void 0),s()(this,"_isForeground",void 0),s()(this,"_timeOfLastTabFocusChange",Date.now()),this._isForeground=new _(!0),this._readOnlyIsForeground=new y(this._isForeground),this.initialize()}),[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"initialize",value:function(){var e=this,t=function(){return e._isForeground.value=!w.value.documentIsHidden},n=!1;w.value.addDocumentEventListener(re,t,n),this._disposables.add(new f((function(){return w.value.removeDocumentEventListener(re,t,n)})))}}])}(),oe=n(981).A,ae=function(){return o()((function e(n){t()(this,e),s()(this,"_logger",X.getLogger("VanillaPeerConnection")),s()(this,"_peerConnection",void 0),P.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(n):this._peerConnection=new w.value.RTCPeerConnection(n)}),[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.currentLocalDescription)||null}},{key:"currentRemoteDescription",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.currentRemoteDescription)||null}},{key:"connectionState",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.connectionState)||null}},{key:"iceConnectionState",get:function(){var e;return(null===(e=this._peerConnection)||void 0===e?void 0:e.iceConnectionState)||null}},{key:"supportsGetConfiguration",get:function(){var e;return"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getConfiguration)}},{key:"supportsSetConfiguration",get:function(){var e;return"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.setConfiguration)}},{key:"supportsGetTransceivers",get:function(){var e;return!P.getTransceiversDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getTransceivers)}},{key:"supportsAddTransceiver",get:function(){var e;return!P.addTranceiverDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.addTransceiver)}},{key:"createOffer",value:(i=M()(V().mark((function e(t){var n=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:if(!P.promiseBasedPCMethodsDisabled){e.next=4;break}return e.abrupt("return",new oe((function(e,r){return n._peerConnection.createOffer(e,r,t)})));case 4:return e.abrupt("return",this._peerConnection.createOffer(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"createAnswer",value:(r=M()(V().mark((function e(t){var n=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:if(!P.promiseBasedPCMethodsDisabled){e.next=4;break}return e.abrupt("return",new oe((function(e,r){return n._peerConnection.createAnswer(e,r,t)})));case 4:return e.abrupt("return",this._peerConnection.createAnswer(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setLocalDescription",value:(n=M()(V().mark((function e(t){return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:return e.abrupt("return",this._peerConnection.setLocalDescription(P.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(e=M()(V().mark((function e(t){var n;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}throw new Error("No PeerConnection initialized");case 2:return(null===(n=t.sdp)||void 0===n?void 0:n.match(/a=crypto:/i))&&this._logger.warn("SDP a=crypto is not supported"),e.abrupt("return",this._peerConnection.setRemoteDescription(P.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 5:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"getSenders",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getSenders()}},{key:"getReceivers",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getReceivers()}},{key:"getStats",value:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;if(!this._peerConnection)throw new Error("No PeerConnection initialized");return new oe((function(t){e._peerConnection.getStats(t)}))}},{key:"addEventListener",value:function(e,t,n){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.removeEventListener(e,t,n)}},{key:"getTransceivers",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getTransceivers()}},{key:"addTransceiver",value:function(e,t){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.addTransceiver(e,t)}},{key:"addStream",value:function(e){var t=this;e.getTracks().forEach((function(e){if(!t._peerConnection)throw new Error("No PeerConnection initialized");t._peerConnection.addTrack(e)}))}},{key:"getConfiguration",value:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.setConfiguration(e)}},{key:"ontrack",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.ontrack},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.ontrack=e}},{key:"onicecandidate",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.onicecandidate},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.onicecandidate=e}},{key:"onconnectionstatechange",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.onconnectionstatechange},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.onconnectionstatechange=e}},{key:"oniceconnectionstatechange",get:function(){if(!this._peerConnection)throw new Error("No PeerConnection initialized");return this._peerConnection.oniceconnectionstatechange},set:function(e){if(!this._peerConnection)throw new Error("No PeerConnection initialized");this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){var e;null===(e=this._peerConnection)||void 0===e||e.close()}},{key:"dispose",value:function(){this._peerConnection=null}}]);var e,n,r,i}(),se=n(981).A,ue=function(){return o()((function e(){t()(this,e)}),[{key:"createPeerConnection",value:(e=M()(V().mark((function e(t){return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new se((function(e){w.subscribe((function(n){n&&e(new ae(t))}))})));case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e}(),ce=function(){function e(){throw t()(this,e),new Error("PeerConnectionService is a static class that may not be instantiated")}return o()(e,null,[{key:"peerConnectionFactory",get:function(){return e._peerConnectionFactory}},{key:"initiateInitialPrecaching",value:function(){P.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(r=M()(V().mark((function t(){return V().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 r.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(n=M()(V().mark((function t(){var n,r,i,o,a=arguments;return V().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=P.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:r}:void 0,t.abrupt("return",e._peerConnectionFactory.value.createPeerConnection(o).then(function(){var e=M()(V().mark((function e(t){var r,i,o;return V().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 n.apply(this,arguments)})}]);var n,r}();s()(ce,"_logger",X.getLogger("PeerConnectionService")),s()(ce,"_peerConnectionFactory",new _(new ue)),s()(ce,"_cached",void 0),ce.initiateInitialPrecaching();var le=function(){return o()((function e(){t()(this,e)}),null,[{key:"getTelemetryUrl",value:function(e){try{var t=new w.value.URL(e),n=t.hostname.split(".");switch(t.protocol){case"ws:":t.protocol="http:";break;case"wss:":t.protocol="https:"}return 2===n.length||3===n.length&&n[n.length-2].length<=2&&n[n.length-1].length<=3?n.unshift("telemetry"):n[0].startsWith("stg-")||n[0].endsWith("-stg")||n[0].includes("-stg-")||"stg"===n[0]?n[0]="telemetry-stg":n[0].startsWith("local")||n[0].endsWith("-local")||(n[0]="telemetry"),t.hostname=n.join("."),"".concat(t.origin,"/telemetry")}catch(t){return e}}}])}(),de=function(){return o()((function e(){t()(this,e)}),null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new w.value.URL(e).origin}catch(e){return""}}}])}(),he=function(){return o()((function e(){t()(this,e)}),null,[{key:"discoveryParameters",get:function(){return this._discoveryParameters}},{key:"applyParameters",value:function(){try{var e={discovery:{intentions:"contribution,distribution"}};this._discoveryParameters="discovery"in e?e.discovery:{intentions:""}}catch(e){this._discoveryParameters={intentions:""}}}}])}();s()(he,"_discoveryParameters",void 0),he.applyParameters();var pe=function(){function e(){throw t()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return o()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new w.value.URL(e.toString()),n=B.sdkVersion,r=he.discoveryParameters.intentions;return t.searchParams.set("version",n),t.searchParams.set("intentions",r),t.searchParams.set("_","".concat(Date.now())),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}])}();s()(pe,"_discoveryUri",new _("https://pcast.phenixrts.com/pcast/endPoints"));var fe,me,ve=n(738),ge=n.n(ve),_e=n(132),ye=n.n(_e),be=function(){return o()((function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e5;t()(this,e),s()(this,"_backoffIntervalInMillisecond",void 0),s()(this,"_minBackoffIntervalInMillisecond",void 0),s()(this,"_maxBackoffIntervalInMillisecond",void 0),this._backoffIntervalInMillisecond=n,this._minBackoffIntervalInMillisecond=r,this._maxBackoffIntervalInMillisecond=i}),[{key:"getExponentialBackoffIntervalByFailureCount",value:function(e){var t=this._backoffIntervalInMillisecond/1e3,n=.5+.5*Math.random(),r=Math.pow(t,e-2),i=Math.floor(r)*n,o=Math.ceil(Math.max(1e3*i,this._minBackoffIntervalInMillisecond));return Math.min(o,this._maxBackoffIntervalInMillisecond)}}])}(),Ce=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}(Ce||{}),ke=Ce,Se=function(){return o()((function e(n){t()(this,e),s()(this,"_metrics",void 0),this._metrics=n}),[{key:"getName",value:function(){return ke[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case ke.TimeToFirstFrame:case ke.ChannelCreationTimeToFirstFrame:return J.Essential;case ke.Stalled:case ke.Buffering:case ke.SetupCompleted:case ke.SetupFailed:case ke.RoundTripTime:case ke.DownlinkThroughputCapacity:case ke.NetworkType:case ke.ResolutionChanged:case ke.ApplicationForeground:case ke.ApplicationBackground:return J.All;default:W(this._metrics)}}}])}(),xe=n(981).A,we=function(){return o()((function e(n){var r=this;t()(this,e),s()(this,"_logger",X.getLogger("MetricsService")),s()(this,"_metricsConfiguration",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_metrics",[]),s()(this,"_isSending",!1),s()(this,"_failureCount",0),s()(this,"_domain",""),this._metricsConfiguration=n,this._exponentialBackoff=new be,this.getLocationHostnameFromGlobalScope().then((function(e){r._domain=null!=e?e:""}))}),[{key:"metricsConfiguration",get:function(){return this._metricsConfiguration}},{key:"push",value:function(e){var t=e.streamId,n=e.value,r=e.previousValue,i=e.runtime,o=e.resource,a=e.kind,s=new Se(e.metricType);if(!(this._metricsConfiguration.threshold>s.getTelemetryLevel())){var u={timestamp:(new Date).toISOString(),tenancy:this._metricsConfiguration.tenancy,sessionId:this._metricsConfiguration.sessionId,streamId:t,metric:s.getName(),value:n,previousValue:r,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:B.sdkVersion,runtime:i,resource:o,kind:a};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new xe((function(e){var t=w.subscribe((function(n){n&&(e(n.locationHostname),t.dispose())}))}))}},{key:"sendMetrics",value:(n=M()(V().mark((function e(t){var n;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new w.value.FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,w.value.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 n.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(e=M()(V().mark((function e(){var t,n=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._metrics.length<=0||this._isSending)&&w.value){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 w.value.setTimeout((function(){n._metrics=[].concat(ye()(t),ye()(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,n}(),Te=function(){function e(){throw t()(this,e),new Error("MetricsFactory is a static class that may not be instantiated")}return o()(e,null,[{key:"getMetricsService",value:function(t){if("string"!=typeof t)throw new Error("url must be a string instead received [".concat(ge()(t),"]"));var n=e._metricsServices[t];if(n)return n;var r=new K;return r.sessionId=Ee.clientSessionId,r.tenancy=Ee.tenancy.value,r.url=le.getTelemetryUrl(t),r.environment=de.getEnvironmentFromUrl(t),r.threshold=Q.convertTelemetryLevelTypeToTelemetryLevel(Ee.telemetryLevel),e._metricsServices[t]=new we(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}])}();s()(Te,"_metricsServices",{});var Pe=(null===(fe=C.getInstance().value)||void 0===fe?void 0:fe.pageLoadTime)||Date.now(),Ee=function(){function e(){throw t()(this,e),new Error("SDK is a static class that may not be instantiated")}return o()(e,null,[{key:"pageLoadTime",get:function(){return Pe}},{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 q.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return Q.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return T}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=X.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 H}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new H(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 H}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new H(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=Te.getMetricsService(pe.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=$.getStringValue("phenix-metrics-level");t&&Te.setTelemetryLevel(J[t]),e._telemetryLevel.subscribe((function(e){Te.setTelemetryLevel(e)}))}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=$.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=$.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=$.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=$.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=de.getEnvironmentFromUrl(t)}));var t=$.getStringValue("phenix-channel-token");if(t){var n=te.parseToken(t);return e._tenancy.value=n.tenancy,pe.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=$.getStringValue("phenix-uri");if(r)return pe.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=$.getStringValue("phenix-base-uri");if(i){var o=new(C.getInstance().value.URL)(i);return o.pathname="/pcast/endPoints",pe.uri.value=o.toString(),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)}}},{key:"onLoad",value:function(t){t&&(this._initialized.value?this._logger.warn("SDK has already been loaded"):(t.addWindowEventListener("unload",(function(){e.dispose()})),e.applyDiscoveryUriDefaultFromParameterConfiguration(),e.applyMetricsConfiguration(),e.applyTelemetryConfiguration(),this._applicationActivityMonitor=new ie,this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection),this._logger.info("Force garbage collection on restart is set to: [%s]",this._forceGarbageCollectionOnRestart),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices),this._initialized.value=!0))}},{key:"init",value:function(t){if(t){var n=t;if(n.globalScope&&C.setInstance(n.globalScope),t.discoveryUri&&(pe.uri.value=t.discoveryUri),t.peerConnectionFactory&&(ce.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&J[t.telemetryLevel]&&(e._telemetryLevel.value=Q.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&E[t.loggingLevel]&&this._logger.threshold.setThreshold(q.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&E[t.consoleLoggingLevel]){var r=this._logger.appenders.value.find((function(e){return e instanceof L}));r&&this._logger.appenders.remove(r),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new L(q.convertLoggingLevelTypeToLoggingLevel(t.consoleLoggingLevel)))}"boolean"==typeof t.automaticallyPlayMediaStream&&(this._automaticallyPlayMediaStream=t.automaticallyPlayMediaStream),"boolean"==typeof t.automaticallyMuteVideoOnPlayFailure&&(this._automaticallyMuteVideoOnPlayFailure=t.automaticallyMuteVideoOnPlayFailure),t.webPlayerLoader&&(this._webPlayerLoader=t.webPlayerLoader),t.shakaPlayerLoader&&(this._shakaPlayerLoader=t.shakaPlayerLoader),t.hlsJsLoader&&(this._hlsJsLoader=t.hlsJsLoader)}}},{key:"dispose",value:function(){var t;e._initialized.value=!1,null===(t=this._applicationActivityMonitor)||void 0===t||t.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return le.getTelemetryUrl(e)}}])}();me=Ee,s()(Ee,"_automaticallyRetryOnFailure",$.getBooleanValue("phenix-automatically-retry-on-failure")),s()(Ee,"_automaticallyReconnectPeerConnection",$.getBooleanValue("phenix-automatically-reconnect-peer-connection")),s()(Ee,"_automaticallyPlayMediaStream",!0),s()(Ee,"_automaticallyMuteVideoOnPlayFailure",!0),s()(Ee,"_forceGarbageCollectionOnRestart",$.getBooleanValue("phenix-force-garbage-collection-on-restart")),s()(Ee,"_skipGarbageCollectionOnMobileDevices",$.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices")),s()(Ee,"_webPlayerLoader",void 0),s()(Ee,"_shakaPlayerLoader",void 0),s()(Ee,"_hlsJsLoader",void 0),s()(Ee,"_applicationActivityMonitor",void 0),s()(Ee,"_environment",new _("")),s()(Ee,"_telemetryUrl",new _("https://telemetry.phenixrts.com/telemetry")),s()(Ee,"_maximalNumberOfPeerConnectionReconnectAttempts",8),s()(Ee,"_telemetryLevel",new _(Z.defaultTelemetryLevel)),s()(Ee,"_metricsService",void 0),s()(Ee,"_metricsConfiguration",void 0),s()(Ee,"_sendLocalCandidates",new _(R.sendLocalCandidates)),s()(Ee,"_tenancy",new _("")),s()(Ee,"_clientSessionId",Y.random(32)),s()(Ee,"_loadedTimestamp",new Date),s()(Ee,"_logger",X.getLogger("SDK")),s()(Ee,"_initialized",new _(!1)),s()(Ee,"_readOnlyInitialized",new y(me._initialized)),s()(Ee,"_readOnlyDiscoveryUri",new y(pe.uri)),s()(Ee,"_readOnlyPeerConnectionFactory",new y(ce.peerConnectionFactory)),C.subscribe(Ee.onLoad.bind(Ee));var Fe=function(){function e(n,r){t()(this,e),s()(this,"width",void 0),s()(this,"height",void 0),this.width=n,this.height=r}return o()(e,[{key:"equals",value:function(e){return e&&this.width===e.width&&this.height===e.height}},{key:"toString",value:function(){return"".concat(this.width,"x").concat(this.height)}}],[{key:"empty",get:function(){return new e(0,0)}}])}(),Ie=function(){return o()((function e(){throw t()(this,e),new Error("GarbageCollectorManager is a static class that may not be instantiated")}),null,[{key:"forceGarbageCollection",value:function(){P.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){P.isQueueMicrotaskSupported?w.value.queueMicrotask(this.overloadMemoryToInvokeGarbageCollection.bind(this)):w.value.setTimeout(this.overloadMemoryToInvokeGarbageCollection.bind(this),0)}},{key:"overloadMemoryToInvokeGarbageCollection",value:function(){var e=w.value.documentCreateElement("img");e.src=w.value.URL.createObjectURL(new Blob([new ArrayBuffer(1e8)])),e.onerror=function(){w.value.URL.revokeObjectURL(this.src),e=null}}}])}(),Re=function(e){return e[e.Initializing=0]="Initializing",e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Paused=3]="Paused",e[e.Playing=4]="Playing",e[e.Recovering=5]="Recovering",e[e.Reconnecting=6]="Reconnecting",e[e.StandBy=7]="StandBy",e[e.Stopped=8]="Stopped",e[e.Unauthorized=9]="Unauthorized",e[e.GeoRestricted=10]="GeoRestricted",e[e.GeoBlocked=11]="GeoBlocked",e[e.UnsupportedFeature=12]="UnsupportedFeature",e[e.ConfigurationError=13]="ConfigurationError",e[e.TransientConfigurationError=14]="TransientConfigurationError",e[e.ConnectionError=15]="ConnectionError",e[e.ClientStartError=16]="ClientStartError",e[e.Error=17]="Error",e}(Re||{}),De=Re,Oe=function(){return o()((function e(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t()(this,e),s()(this,"_duration",void 0),this._duration=n}),[{key:"toIsoString",value:function(){if(0===this._duration)return"P0S";var e=this._duration<0,t=e?Math.abs(this._duration):this._duration,n=Math.floor(t),r=n%1e3,i=(n=Math.floor(n/1e3))%60,o=(n=Math.floor(n/60))%60,a=(n=Math.floor(n/60))%24,s=["PT"];return e&&s.unshift("-"),a&&s.push(a+"H"),o&&s.push(o+"M"),(i||r)&&(s.push(String(i)),r&&s.push("."+this.padStart(r.toString(),3,"0")),s.push("S")),s.join("")}},{key:"padStart",value:function(e,t,n){return t|=0,n=String(void 0!==n?n:" "),e.length>t?e:((t-=e.length)>n.length&&(n+=n.repeat(t/n.length)),n.slice(0,t)+e)}}])}(),Le=function(){},Ae=function(){return o()((function e(n,r,i,o){t()(this,e),s()(this,"_pageLoadTime",void 0),s()(this,"_channelStartTime",void 0),s()(this,"_logger",X.getLogger("StreamTelemetry")),s()(this,"_disposables",new ne),s()(this,"_streamId",void 0),s()(this,"_metricsService",void 0),s()(this,"_listenToFirstTime",Le),s()(this,"_listenForStall",Le),s()(this,"_listenForContinuation",Le),s()(this,"_timeToFirstFrame",0),s()(this,"_channelCreationTimeToFirstFrame",0),s()(this,"_startRecordingFirstFrame",0),s()(this,"_videoStalled",null),s()(this,"_lastProgress",0),s()(this,"_videoResolution",""),s()(this,"_clearTimeToFirstFrameListener",new f((function(){return null}))),s()(this,"_clearRebufferingListener",new f((function(){return null}))),this._streamId=n,this._pageLoadTime=r,this._channelStartTime=i,this._metricsService=o}),[{key:"setupListenerForTimeToFirstTime",value:function(e){var t=this;this._startRecordingFirstFrame=Date.now(),this._listenToFirstTime=function(){return t.callTimeToFirstFrame()},e.addEventListener("loadeddata",this._listenToFirstTime),e.addEventListener("loadedmetadata",this._listenToFirstTime),this._clearTimeToFirstFrameListener=new f((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 f((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 Oe(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:ke.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 Oe(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:ke.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 Oe(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:ke.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:ke.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 Oe(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:ke.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}}])}(),Me=function(){return o()((function e(n){t()(this,e),s()(this,"_logger",X.getLogger("StreamSetupListener")),s()(this,"metricsService",Ee.metricsService),s()(this,"_pageLoadTime",void 0),s()(this,"_startTime",void 0),s()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=n}),[{key:"success",value:function(e){this.recordStreamMetric(ke.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(ke.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new Se(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 Oe(n-this._pageLoadTime).toIsoString(),t,i,new Oe(r).toIsoString())}}}])}(),Ne=function(){return o()((function e(){t()(this,e),s()(this,"_disposables",new ne),s()(this,"_isSupported",void 0!==w.value.navigatorConnection),s()(this,"_rtt",new _(void 0)),s()(this,"_effectiveType",new _(void 0)),s()(this,"_downlinkThroughputCapacity",new _(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())}),[{key:"isSupported",get:function(){return this._isSupported}},{key:"rtt",get:function(){return this._rtt}},{key:"effectiveType",get:function(){return this._effectiveType}},{key:"downlinkThroughputCapacity",get:function(){return this._downlinkThroughputCapacity}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"getDownlinkThroughputCapacity",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=w.value.navigatorConnection)||void 0===n?void 0:n.downlink)&&void 0!==t?t:null===(r=w.value.navigatorConnection)||void 0===r?void 0:r.downlinkMax)&&void 0!==e?e:-1}},{key:"getEffectiveType",value:function(){var e,t,n,r;return null!==(e=null!==(t=null===(n=w.value.navigatorConnection)||void 0===n?void 0:n.effectiveType)&&void 0!==t?t:null===(r=w.value.navigatorConnection)||void 0===r?void 0:r.type)&&void 0!==e?e:"Unknown"}},{key:"getRoundTripTime",value:function(){var e,t;return null!==(e=null===(t=w.value.navigatorConnection)||void 0===t?void 0:t.rtt)&&void 0!==e?e:-1}},{key:"setupNetworkChangeListeners",value:function(){var e,t=this,n=function(){return t.updateStatistics()};null===(e=w.value.navigatorConnection)||void 0===e||e.addEventListener("change",n),this._disposables.add(new f((function(){var e;return null===(e=w.value.navigatorConnection)||void 0===e?void 0:e.removeEventListener("change",n)})))}},{key:"updateStatistics",value:function(){this._rtt.value=this.getRoundTripTime(),this._effectiveType.value=this.getEffectiveType(),this._downlinkThroughputCapacity.value=this.getDownlinkThroughputCapacity()}}])}(),Ve=function(){return o()((function e(n,r){var i=this;if(t()(this,e),s()(this,"_logger",X.getLogger("SessionTelemetry")),s()(this,"_metricsService",void 0),s()(this,"_applicationActivityMonitor",Ee.applicationActivityMonitor),s()(this,"_networkMonitor",new Ne),s()(this,"_pageLoadTime",void 0),s()(this,"_disposables",new ne),s()(this,"_lastNetworkStatistics",{}),this._pageLoadTime=n,this._disposables.add(this._networkMonitor),this._metricsService=r,!this._applicationActivityMonitor)throw new Error("SessionTelemetry Failed: No application monitor initialized.");this._networkMonitor.isSupported&&(this._disposables.add(this._applicationActivityMonitor.isForeground.subscribe((function(e){i.recordForegroundChange(e)}))),this._disposables.add(this._networkMonitor.rtt.subscribe((function(e){e&&i.recordNetworkRTTUpdate(e)}))),this._disposables.add(this._networkMonitor.effectiveType.subscribe((function(e){e&&i.recordNetworkTypeChangeUpdate(e)}))),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe((function(e){e&&i.recordNetworkDownlinkThroughputCapacityUpdate(e)}))))}),[{key:"listenOnStreamSetup",value:function(){return new Me(this._pageLoadTime)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"recordForegroundChange",value:function(e){var t,n=Date.now(),r=null===(t=this._applicationActivityMonitor)||void 0===t?void 0:t.getTimeSinceLastChange();r&&(this._metricsService.push({metricType:e?ke.ApplicationForeground:ke.ApplicationBackground,runtime:(n-this._pageLoadTime)/1e3,value:{uint64:r}}),this._logger.info("Application has gone into the [%s] after [%s] ms",e?"foreground":"background",new Oe(r).toIsoString()))}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:ke.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 Oe(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:ke.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 Oe(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:ke.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 Oe(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),Ue=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Be=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),je=o()((function e(n){t()(this,e),s()(this,"token",void 0),s()(this,"tokenExpiring",void 0),this.token=new _(n),this.tokenExpiring=new _(!1)})),ze=function(){return o()((function e(n){var r;t()(this,e),s()(this,"channelInitialization",void 0),s()(this,"disposables",void 0),s()(this,"channelDisposables",void 0),s()(this,"rendererDisposables",void 0),s()(this,"videoElement",void 0),s()(this,"state",void 0),s()(this,"autoMuted",void 0),s()(this,"autoPaused",void 0),s()(this,"authorized",void 0),s()(this,"online",void 0),s()(this,"loading",void 0),s()(this,"playing",void 0),s()(this,"standby",void 0),s()(this,"stopped",void 0),s()(this,"targetLag",void 0),s()(this,"lag",void 0),s()(this,"bitrateLimit",void 0),s()(this,"resolution",void 0),s()(this,"failureCount",void 0),s()(this,"endPoint",void 0),s()(this,"stream",void 0),s()(this,"rtcStatistics",void 0),s()(this,"videoTelemetry",void 0),s()(this,"rtcAudioStatistic",void 0),s()(this,"rtcVideoStatistic",void 0),s()(this,"clearFailureCountTimeout",void 0),this.disposables=new ne,this.channelDisposables=new ne,this.rendererDisposables=new ne,this.channelInitialization=new Date,this.videoElement=new _(null),this.state=new _(De.Initializing),this.autoMuted=new _(!1),this.autoPaused=new _(!1),this.authorized=new _(!0),this.online=new _(!0),this.loading=new _(!1),this.playing=new _(!1),this.standby=new _(!1),this.stopped=new _(!1),this.targetLag=new _(null!==(r=null==n?void 0:n.targetLag)&&void 0!==r?r:0),this.lag=new _(void 0),this.bitrateLimit=new _(0),this.resolution=new _(Fe.empty),this.failureCount=new _(0),this.endPoint=new _(null),this.stream=new _(null),this.rtcStatistics=new _(null),this.videoTelemetry=null,this.rtcAudioStatistic=null,this.rtcVideoStatistic=null,this.clearFailureCountTimeout=0}),[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":return this.authorized.value=!1,this.failureCount.value=0,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);case"no-stream":case"not-found":return this.failureCount.value=0,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.playing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null)}}},{key:"applySessionAndStreamPropertiesToVideoElement",value:function(){this.videoElement.value&&this.videoElement.value.dataset&&(this.videoElement.value.dataset.sessionId=Ee.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return De.Starting;case"no-stream":case"not-found":return De.StandBy;case"geo-restricted":return De.GeoRestricted;case"geo-blocked":return De.GeoBlocked;case"unauthorized":return De.Unauthorized;case"capacity":case"rate-limited":case"timeout":return De.Recovering;case"forbidden-tag":return De.ConfigurationError;case"port-in-range-not-found":return De.TransientConfigurationError;case"failed":return De.Error;default:W(e)}}}])}(),He=function(){return o()((function e(){throw t()(this,e),new Error("EncodedStreamSink is a static class that may not be instantiated")}),null,[{key:"validateEncodedStreamSink",value:function(e,t){return"function"!=typeof t?{valid:!1,validationResult:"Unexpected ".concat(e," Encoded Stream Sink function type. Found [").concat(ge()(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"}}}])}(),Ge=function(){return o()((function e(){t()(this,e)}),null,[{key:"validateMediaStreamTrackTransform",value:function(e,t){return"function"!=typeof t?{valid:!1,validationResult:"Unexpected ".concat(e," Media Stream Track transform function type. Found [").concat(ge()(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"}}}])}(),We=o()((function e(n){t()(this,e),s()(this,"hasInsertableStreams",void 0),s()(this,"hasEncodedInsertableStreams",void 0),s()(this,"videoStreamTransformCallback",void 0),s()(this,"audioStreamTransformCallback",void 0),s()(this,"encodedVideoStreamSink",void 0),s()(this,"encodedAudioStreamSink",void 0),this.hasInsertableStreams=new _(n.hasInsertableStreams),this.hasEncodedInsertableStreams=new _(n.hasEncodedInsertableStreams),this.videoStreamTransformCallback=n.videoStreamTransformCallback,this.audioStreamTransformCallback=n.audioStreamTransformCallback,this.encodedVideoStreamSink=n.encodedVideoStreamSink,this.encodedAudioStreamSink=n.encodedAudioStreamSink})),qe=o()((function e(){t()(this,e),s()(this,"mediaStream",void 0),s()(this,"peerConnection",void 0),s()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new _(null),this.peerConnection=new _(null),this.peerConnectionReconnectAttempts=0})),Je=o()((function e(){t()(this,e),s()(this,"isStarting",void 0),s()(this,"isDisposed",void 0),this.isStarting=new _(!1),this.isDisposed=!1})),Ke=o()((function e(){t()(this,e),s()(this,"shouldExtractTimecode",void 0),s()(this,"shouldExtractTimestamps",void 0),s()(this,"isEnabled",void 0),s()(this,"decodedFrameTimingInformation",void 0),s()(this,"renderedFrameTimingInformation",void 0),this.shouldExtractTimecode=new _(!1),this.shouldExtractTimestamps=new _(!1),this.isEnabled=new _(!1),this.decodedFrameTimingInformation=new _(null),this.renderedFrameTimingInformation=new _(null)})),Ze=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Be.Normal:return"Normal";case Be.Force:return"Force";case Be.Reset:return"Reset";default:W(e)}}}])}(),Qe=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Ue.Keep:return"Keep";case Ue.Reset:return"Reset";default:W(e)}}}])}(),$e=n(981).A,Xe=function(){return o()((function e(n,r){if(t()(this,e),s()(this,"_logger",X.getLogger("EndPoint")),s()(this,"_uri",void 0),s()(this,"_timeout",void 0),s()(this,"_roundTripTime",0),this._uri=n,this._timeout=r,!r)throw new Error("End point requires a timeout")}),[{key:"roundTripTime",get:function(){return this._roundTripTime}},{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:(m=M()(V().mark((function e(){var t,n,r,i,o=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,$e.race([w.value.fetch(t,{method:"GET",cache:"no-cache"}),new $e((function(e,n){return w.value.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 m.apply(this,arguments)})},{key:"subscribe",value:(f=M()(V().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,p,f,m,v=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=te.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 w.value.FormData,s=B.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,$e.race([w.value.fetch(o,{method:"POST",body:a}),new $e((function(e){return h=w.value.setTimeout((function(){v._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(o,"]"))),e({status:408})}),v._timeout)}))]).finally((function(){h&&w.value.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 m=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",m,f-l),e.abrupt("return",m);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n){return f.apply(this,arguments)})},{key:"publish",value:(p=M()(V().mark((function e(t,n,r,i){var o,a,s,u,c,l,d,h,p,f,m,v,g=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=te.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 w.value.FormData,u=B.sdkVersion,0===i&&r?(c={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:7,sessionDescription:{type:r.type,sdp:r.sdp}},createAnswerDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(c))):(l={apiVersion:7,clientVersion:u,bearerToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",apiVersion:7}},s.append("jsonBody",JSON.stringify(l))),d=Date.now(),e.prev=9,p=null,e.next=13,$e.race([w.value.fetch(a,{method:"POST",body:s}),new $e((function(e){return p=w.value.setTimeout((function(){g._logger.error("Failed to publish",new Error("Publish timed out [".concat(a,"]"))),e({status:408})}),g._timeout)}))]).finally((function(){p&&w.value.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 m=Date.now(),e.next=26,this.convertHttpResponseToPublishResponse(o,h);case 26:return v=e.sent,this._logger.debug("Got publish response [%j] in [%s] ms",v,m-d),e.abrupt("return",v);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=M()(V().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return V().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 w.value.FormData,o={apiVersion:7,sharedSecret:null==t?void 0:t.sharedSecret,sessionDescription:{type:n.type,sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),a=Date.now(),e.prev=5,u=null,e.next=9,$e.race([w.value.fetch(r,{method:"POST",body:i}),new $e((function(e){return u=w.value.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&&w.value.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=M()(V().mark((function e(t,n,r,i,o){var a,s,u,c,l,d,h,p,f=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),s=new w.value.FormData,u={apiVersion:7,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:Qe.convertBitrateStateToBitrateStateType(i),bitrateMode:Ze.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,d=null,e.next=9,$e.race([w.value.fetch(a,{method:"POST",body:s}),new $e((function(e){return d=w.value.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&&w.value.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:(l=M()(V().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,p,f=this,m=arguments;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=m.length>3&&void 0!==m[3]?m[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),a=new w.value.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,$e.race([w.value.fetch(o,{method:"POST",body:a}),new $e((function(e){return l=w.value.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&&w.value.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 l.apply(this,arguments)})},{key:"destroyStream",value:(c=M()(V().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new w.value.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,$e.race([w.value.fetch(r,{method:"POST",body:i,cache:"no-cache"}),new $e((function(e){return u=w.value.setTimeout((function(){h._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})}),h._timeout)}))]).finally((function(){u&&w.value.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 c.apply(this,arguments)})},{key:"destroyStreamOnUnmount",value:(u=M()(V().mark((function e(t,n){var r,i,o,a;return V().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 w.value.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 u.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new w.value.URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,ye()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new w.value.URL(this._uri),t=B.sdkVersion,n=he.discoveryParameters.intentions;return e.searchParams.set("type","http"),e.searchParams.set("version",t),e.searchParams.set("intentions",n),e.searchParams.set("_","".concat(Date.now())),e.toString()}},{key:"mapHttpStatusToPublishStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 406:return"missing-channel-or-room-id";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSubscribeStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetRemoteDescriptionStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetTemporaryMaximalBitrateStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToAddIceCandidatesStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetDestroyStreamStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"convertHttpResponseToSubscribeResponse",value:(a=M()(V().mark((function e(t,n){var r,i;return V().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},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 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(i=M()(V().mark((function e(t,n){var r,i;return V().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 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={iceServers:[]};if(e.bundlePolicy&&(t.bundlePolicy=e.bundlePolicy),"number"==typeof e.iceCandidatePoolSize&&(t.iceCandidatePoolSize=e.iceCandidatePoolSize),e.iceServers){for(var n=[],r=0;r<e.iceServers.length;r++)n.push({urls:e.iceServers[r].urls,username:e.iceServers[r].username,credential:e.iceServers[r].credential});t.iceServers=n}return e.iceTransportPolicy&&(t.iceTransportPolicy=e.iceTransportPolicy),e.rtcpMuxPolicy&&(t.rtcpMuxPolicy=e.rtcpMuxPolicy),t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(r=M()(V().mark((function e(t){var n,r;return V().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 r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(n=M()(V().mark((function e(t){var n,r;return V().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 n.apply(this,arguments)})},{key:"convertHttpResponseToDestroyStreamResponse",value:(e=M()(V().mark((function e(t){var n,r;return V().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,n,r,i,a,u,c,l,d,h,p,f,m}(),Ye=n(981).A,et=function(){return o()((function e(n){if(t()(this,e),s()(this,"_logger",X.getLogger("Discovery")),s()(this,"_metricsService",void 0),s()(this,"_uri",void 0),!n)throw new Error("Discovery requires uri");this._metricsService=Te.getMetricsService(n.toString()),this._uri=n}),[{key:"discoverNearbyEndPoints",value:(n=M()(V().mark((function e(t,n){var r,i,o,a;return V().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,Ye.race([w.value.fetch(r,{method:"GET",cache:"no-cache"}),new Ye((function(e,t){return w.value.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 Xe(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=M()(V().mark((function e(){var t,n,r,i,o,a,s=this,u=arguments;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=pe.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new w.value.URL(n),t);case 4:return r=e.sent,i=0,o=function(){return new Ye((function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))}))},e.next=9,Ye.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:ke.RoundTripTime,runtime:(n-Ee.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,n}(),tt=n(981).A,nt=function(){function e(){throw t()(this,e),new Error("Discovery is a static class that may not be instantiated")}return o()(e,null,[{key:"precacheClosestEndPointDiscovery",value:(r=M()(V().mark((function t(){return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new tt((function(t){w.subscribe((function(n){if(n){var r=new n.URL(Ee.discoveryUri.value);return e.discoverClosestEndPointWithCaching(r).then(t)}}))})));case 1:case"end":return t.stop()}}),t)}))),function(){return r.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(n=M()(V().mark((function t(n){var r,i,o;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!((r=n.toString())in e._cache)){t.next=3;break}return t.abrupt("return",e._cache[r]);case 3:return i=new et(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then((function(){w.value.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 n.apply(this,arguments)})},{key:"clearCachedClosestEndpoint",value:function(t){var n=t.toString();n in e._cache&&delete e._cache[n]}}]);var n,r}();s()(nt,"_cache",{}),nt.precacheClosestEndPointDiscovery();var rt=function(e){return e[e.NetworkEmpty=0]="NetworkEmpty",e[e.NetworkIdle=1]="NetworkIdle",e[e.NetworkLoading=2]="NetworkLoading",e[e.NetworkNoSource=3]="NetworkNoSource",e}({});function it(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ot(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?it(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):it(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var at=function(){return o()((function e(n,r,i,o,a,u){t()(this,e),s()(this,"_logger",X.getLogger("WebPlayer")),s()(this,"_videoElement",void 0),s()(this,"_kind",void 0),s()(this,"_streamId",void 0),s()(this,"_manifestURI",void 0),s()(this,"_options",void 0),s()(this,"_handleStreamFailure",void 0),s()(this,"_player",void 0),s()(this,"_lastReloadTime",void 0),this._videoElement=n,this._kind=r,this._streamId=i,this._manifestURI=encodeURI(o).replace(/[#]/g,"%23"),this._options=a,this._player=null,this._lastReloadTime=0,this._handleStreamFailure=u}),[{key:"start",value:function(){var e=this;if(ft.phenixWebPlayer){var t,n,r=ot(ot({},this._options),{},{bandwidthToStartAt:3e6});return this._player=new ft.phenixWebPlayer.WebPlayer(this._logger,this._videoElement,r),null===(t=this._player)||void 0===t||t.start(this._manifestURI),void(null===(n=this._player)||void 0===n||n.addEventListener("error",(function(t){e.canReload()&&t&&(3===t.code||t.severity===ft.phenixWebPlayer.errors.severity.RECOVERABLE)&&(e._logger.warn("Reloading unhealthy stream after error event [%j]",t),e.reloadIfAble()),e._logger.error("Cannot reload with error [%j]",t),e._handleStreamFailure()})))}}},{key:"isSupported",value:function(){return ft.phenixWebPlayer&&ft.phenixWebPlayer.isSupported}},{key:"getStats",value:function(){var e,t;if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:rt.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=rt.NetworkLoading:n.currentTime>0?n.networkState=rt.NetworkIdle:n.video?n.networkState=rt.NetworkEmpty:n.networkState=rt.NetworkNoSource,n}},{key:"dispose",value:function(){this._player&&this._player.dispose(),this._player=null}},{key:"canReload",value:function(){var e=!this._lastReloadTime||Date.now()-this._lastReloadTime>15e3;return!!this._videoElement&&!!this._player&&0!==this._videoElement.buffered.length&&e}},{key:"reloadIfAble",value:function(){this.canReload()&&(this._logger.warn("[%s] Reloading unhealthy stream that was active for at least [%s] seconds",this._streamId,15),this._lastReloadTime=Date.now(),this.reload())}},{key:"reload",value:function(){this._player&&this._player.dispose(),this._player=null,this.start()}}])}();function st(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 ut(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?st(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):st(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ct=function(){return o()((function e(n,r,i,o,a,u){t()(this,e),s()(this,"_logger",X.getLogger("ShakaPlayer")),s()(this,"_videoElement",void 0),s()(this,"_kind",void 0),s()(this,"_streamId",void 0),s()(this,"_manifestURI",void 0),s()(this,"_options",void 0),s()(this,"_handleStreamFailure",void 0),s()(this,"_disposables",void 0),s()(this,"_monitoredStatistics",void 0),s()(this,"_player",void 0),this._videoElement=n,this._kind=r,this._streamId=i,this._manifestURI=encodeURI(o).replace(/[#]/g,"%23"),this._options=a,this._handleStreamFailure=u,this._disposables=new ne,this._monitoredStatistics={estimatedBandwidth:0,playTime:0},this._player=null}),[{key:"start",value:function(){if(ft.shaka)return this._player=new ft.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:rt.NetworkNoSource,dataBuffered:0};var e=ut(ut({},this._player.getStats()),{},{currentTime:0,lag:0}),t=this._videoElement.currentTime||0,n=(Date.now()-this._options.originStartTime)/1e3,r=Math.max(0,n-t);return this._videoElement&&(e.currentTime=t,e.lag=r,this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0))),e.estimatedBandwidth&&(e.estimatedBandwidth&&e.estimatedBandwidth>0&&this._monitoredStatistics.estimatedBandwidth&&this._monitoredStatistics.estimatedBandwidth<e.estimatedBandwidth?e.networkState=rt.NetworkLoading:e.playTime&&e.playTime>0&&this._monitoredStatistics.playTime&&this._monitoredStatistics.playTime<e.playTime?e.networkState=rt.NetworkIdle:e.video?e.networkState=rt.NetworkEmpty:e.networkState=rt.NetworkNoSource),this._monitoredStatistics.estimatedBandwidth=e.estimatedBandwidth,this._monitoredStatistics.playTime=e.playTime,e}},{key:"dispose",value:function(){this._disposables.dispose(),this._player&&(this._player.unload(),this._player.destroy()),this._player=null}},{key:"loadPlayer",value:function(e){var t,n,r,i=this;null===(t=this._player)||void 0===t||t.configure(e);var o=function(){return i._handleStreamFailure()};null===(n=this._player)||void 0===n||n.addEventListener("error",o),this._disposables.add(new f((function(){var e;return null===(e=i._player)||void 0===e?void 0:e.removeEventListener("error",o)}))),null===(r=this._player)||void 0===r||r.load(this._manifestURI).then((function(){i._logger.info("[%s] DASH live stream has been loaded",i._streamId),i._videoElement.play&&i._videoElement.play()})).catch((function(e){i._logger.error("[%s] Error while loading DASH live stream [%s]",i._streamId,e.code,e)}))}}])}(),lt=function(){return o()((function e(n,r,i,o,a){t()(this,e),s()(this,"_videoElement",void 0),s()(this,"_kind",void 0),s()(this,"_streamId",void 0),s()(this,"_manifestURI",void 0),s()(this,"_options",void 0),s()(this,"_player",void 0),this._videoElement=n,this._kind=r,this._streamId=i,this._manifestURI=encodeURI(o).replace(/[#]/g,"%23"),this._options=a,this._player=null}),[{key:"start",value:function(){ft.hlsPlayer&&(ft.hlsPlayer.isSupported()?(this._player=new ft.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 ft.hlsPlayer&&ft.hlsPlayer.isSupported()}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:rt.NetworkNoSource,dataBuffered:0};var e={width:this._player.media.offsetWidth,height:this._player.media.offsetHeight,currentTime:this._player.media.currentTime,lag:0,networkState:rt.NetworkIdle,dataBuffered:0};this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0)),"IDLE"===this._player.streamController.state?e.networkState=rt.NetworkIdle:"ERROR"===this._player.streamController.state||"ENDED"===this._player.streamController.state?e.networkState=rt.NetworkNoSource:this._player.streamController.state.includes("LOADING")||this._player.streamController.state.includes("WAITING")?e.networkState=rt.NetworkLoading:e.networkState=rt.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)}}])}(),dt=n(981).A;function ht(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 pt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ht(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ht(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ft=function(){return o()((function e(){t()(this,e)}),null,[{key:"hlsPlayer",get:function(){return this._hlsPlayer}},{key:"phenixWebPlayer",get:function(){return this._phenixWebPlayer}},{key:"shaka",get:function(){return this._shaka}},{key:"start",value:(n=M()(V().mark((function e(t,n,r,i,o){var a=this;return V().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,o));case 3:if(Ee.webPlayerLoader||Ee.shakaPlayerLoader||Ee.hlsJsLoader){e.next=5;break}throw new Error("Unsupported-feature, add stream player");case 5:return e.abrupt("return",new dt((function(e){Ee.hlsJsLoader&&(a._pending=!0,Ee.hlsJsLoader((function(i){a._hlsPlayer=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))}))),Ee.webPlayerLoader&&(a._pending=!0,Ee.webPlayerLoader((function(i){a._phenixWebPlayer=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))}))),Ee.shakaPlayerLoader&&(a._pending=!0,Ee.shakaPlayerLoader((function(i){a._shaka=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))})))})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i,o){return n.apply(this,arguments)})},{key:"getStats",value:function(){return this._player?this._player.getStats():null}},{key:"play",value:(e=M()(V().mark((function e(t,n,r,i,o,a){var s,u,c,l;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=i.match(/a=x-playlist:([^\n]*[.]mpd\??[^\s]*)/m),u=i.match(/a=x-playlist:([^\n]*[.]m3u8\??[^\s]*)/m),c=s&&s[1]?s[1]:"",!(l=u&&u[1]?u[1]:"")){e.next=9;break}if(this._phenixWebPlayer&&!P.shouldUseNativeHls){e.next=9;break}return this._player=new t(n,"hls",r,l,o,a),this._player.start(),e.abrupt("return",this._player);case 9:if(!c){e.next=14;break}if(this._hlsPlayer||this._phenixWebPlayer&&P.shouldUseNativeHls){e.next=14;break}return this._player=new t(n,"dash",r,c,o,a),this._player.start(),e.abrupt("return",this._player);case 14:if(!c&&!l){e.next=16;break}throw new Error("[".concat(r,"] Cannot play [").concat(l?"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,a){return e.apply(this,arguments)})},{key:"loaded",value:function(e,t,n,r){return this._hlsPlayer?this.play(lt,e,t,n,pt(pt({},this._options),{},{preferNative:P.shouldUseNativeHls}),r):this._phenixWebPlayer?this.play(at,e,t,n,pt(pt({},this._options),{},{preferNative:P.shouldUseNativeHls}),r):this.play(ct,e,t,n,pt(pt({},this._options),{},{preferNative:P.shouldUseNativeHls}),r)}}]);var e,n}();s()(ft,"_pending",!1),s()(ft,"_hlsPlayer",void 0),s()(ft,"_phenixWebPlayer",void 0),s()(ft,"_shaka",void 0),s()(ft,"_options",void 0),s()(ft,"_player",void 0);var mt=function(e){return e[e.Live=1]="Live",e[e.OndDemand=2]="OndDemand",e}(mt||{}),vt=mt,gt=function(){return o()((function e(n,r,i){t()(this,e),s()(this,"_logger",X.getLogger("ChunkedStream")),s()(this,"_channelContext",void 0),s()(this,"_chunkedStreamPlaybackMode",void 0),s()(this,"_disposables",new ne),s()(this,"_monitorDisposables",new ne),s()(this,"_handleStreamFailure",void 0),s()(this,"_streamStatistics",null),s()(this,"_monitorFailureCount",0),this._channelContext=n,this._chunkedStreamPlaybackMode=r,this._handleStreamFailure=i,this._channelContext.disposables.add(this)}),[{key:"start",value:function(e,t){var n=this;return nt.discoverClosestEndPointWithCaching(e).then((function(e){return n._channelContext.online.value=!0,n._channelContext.endPoint.value=e,n._logger.info("Connecting to [%s]",e.toString()),e.subscribe(t,null,n._channelContext.failureCount.value)})).then((function(e){var t,r=e.status,i=n._channelContext.endPoint.value;if(!i)return n._logger.error("Subscribe failed: end point service is missing"),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,void(n._channelContext.state.value=De.Error);if(n._channelContext.state.value=n._channelContext.mapSubscribeStatusToChannelStatus(r),n._channelContext.applyStatus(r),"ok"!==r)return n._channelContext.stream.value=null,n._channelContext.lag.value=void 0,n._channelContext.applySessionAndStreamPropertiesToVideoElement(),void n._logger.debug("[%s] Subscribe failed with status [%s]",n._channelContext.streamId,r);var o=e.stream,a=e.createOfferDescriptionResponse,s=e.lag;n._channelContext.stream.value=o,n._channelContext.lag.value=s,n._channelContext.applySessionAndStreamPropertiesToVideoElement(),n._logger.debug("[%s] Subscribe completed [%s] [%j]",n._channelContext.streamId,r,a);var u=null==a||null===(t=a.sessionDescription)||void 0===t?void 0:t.sdp,c={originStartTime:Date.now()-s+i.roundTripTime/2,lag:s};return n._channelContext.videoElement.value?u?ft.start(n._channelContext.videoElement.value,n._channelContext.streamId,u,c,(function(){return n.retryOnStreamFailure()})).then((function(e){return n.monitor(e),n._disposables.add(e),e})).catch((function(e){n._logger.error("ChunkedStreaming failed",e),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,n._channelContext.state.value=De.Stopped})):(n._logger.error("Subscribe failed: offer SDP is missing"),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,void(n._channelContext.state.value=De.Error)):(n._logger.error("Subscribe failed: video element is missing"),n._channelContext.loading.value=!1,n._channelContext.playing.value=!1,void(n._channelContext.state.value=De.Stopped))}))}},{key:"retryOnStreamFailure",value:function(){var e=this;this._monitorFailureCount=0,this._channelContext.state.value=De.ConnectionError,this._channelContext.playing.value=!1,this._channelContext.loading.value=!0,this._disposables.dispose(),this._monitorDisposables.dispose(),this._handleStreamFailure().catch((function(t){e._logger.error("Failed handling stream failure",t)}))}},{key:"monitor",value:function(e){var t=this;this._monitorDisposables.dispose();var n=w.value.setTimeout((function(){var n,r,i,o,a,s=ft.getStats();if(t._chunkedStreamPlaybackMode!==vt.Live||(null==s?void 0:s.networkState)!==rt.NetworkNoSource||(null===(n=t._channelContext.videoElement.value)||void 0===n?void 0:n.currentTime)!==(null===(r=t._channelContext.videoElement.value)||void 0===r?void 0:r.duration)){if(t._streamStatistics&&(null===(i=t._channelContext.videoElement.value)||void 0===i||!i.paused)&&null!=s&&s.currentTime&&t._streamStatistics.currentTime>=s.currentTime&&(null==s||!s.dataBuffered||t._streamStatistics.dataBuffered>=s.dataBuffered)){if(t._monitorFailureCount++,t._monitorFailureCount>4)return void t.retryOnStreamFailure()}else t._monitorFailureCount=0;null!==(o=t._channelContext.videoElement.value)&&void 0!==o&&o.paused&&t._channelContext.state.value===De.Playing&&(t._channelContext.state.value=De.Paused),null!==(a=t._channelContext.videoElement.value)&&void 0!==a&&a.paused||t._channelContext.state.value===De.Playing||(t._channelContext.state.value=De.Playing),t._streamStatistics=s,t.monitor(e)}else t.retryOnStreamFailure()}),1e3);this._monitorDisposables.add(new f((function(){w.value.clearTimeout(n)})))}},{key:"dispose",value:function(){this._disposables.dispose(),this._monitorDisposables.dispose()}}])}(),_t=n(715),yt=n.n(_t),bt=function(){return o()((function e(n){t()(this,e),s()(this,"_sdp",void 0),s()(this,"_audioCodec",void 0),s()(this,"_videoCodec",void 0),s()(this,"_isAudioTrackEnabled",void 0),s()(this,"_isVideoTrackEnabled",void 0),this._sdp=n;var r=this._sdp.split(/(\r\n|\r|\n)/),i=this._sdp.split(/(?:^|[\r\n])m=/);this._audioCodec=this.applyCodec("audio",r),this._videoCodec=this.applyCodec("video",r),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",i),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",i)}),[{key:"audioCodec",get:function(){return this._audioCodec}},{key:"videoCodec",get:function(){return this._videoCodec}},{key:"isAudioTrackEnabled",get:function(){return this._isAudioTrackEnabled}},{key:"isVideoTrackEnabled",get:function(){return this._isVideoTrackEnabled}},{key:"isTrackByTypeEnabled",value:function(e,t){var n=t.find((function(t){return t.startsWith(e)}));return!!n&&!n.includes("a=inactive")}},{key:"applyCodec",value:function(e,t){var n,r=(null===(n=t.find((function(t){return t.includes("m=".concat(e))})))||void 0===n?void 0:n.split(" ")[3])||"",i=t.find((function(e){return e.includes("a=rtpmap:".concat(r))}));return((null==i?void 0:i.split(" ")[1])||"").split("/")[0]}}])}(),Ct=function(){return o()((function e(){throw t()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")}),null,[{key:"truncateIceServers",value:function(e){var t=[];if(!e.iceServers)return e;for(var n=0;n<e.iceServers.length;n++){for(var r=[],i=0;i<2;i++)e.iceServers[n].urls[i]&&r.push(e.iceServers[n].urls[i]);t.push({urls:r,username:e.iceServers[n].username,credential:e.iceServers[n].credential})}return e.iceServers=t,e}}])}(),kt=function(){return o()((function e(n,r,i){if(t()(this,e),s()(this,"_estimatedRoundTripTime",void 0),s()(this,"_estimatedVideoCodec","unknown"),s()(this,"_estimatedAudioCodec","unknown"),s()(this,"_rtcStatistic",new _({})),s()(this,"_peerConnection",void 0),s()(this,"_isMonitorRunning",!0),s()(this,"_updateTimeout",null),s()(this,"_tracksToMonitor",void 0),this._peerConnection=n,this._estimatedRoundTripTime=i,this._tracksToMonitor=r.getTracks().map((function(e){return e.kind}))||[],this._peerConnection){var o,a;if(!P.getCurrentOfferDisabled&&null!==(o=this._peerConnection)&&void 0!==o&&null!==(a=o.currentRemoteDescription)&&void 0!==a&&a.sdp){var u=new bt(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=u.audioCodec,this._estimatedVideoCodec=u.videoCodec}this.updateStatistic()}}),[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(w.value.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(n=M()(V().mark((function e(){var t,n,r=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!P.getStatsPromiseBasedDisabled){e.next=5;break}return e.next=3,this.updateStatisticLegacy();case 3:return e.sent,e.abrupt("return");case 5:return n=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=8,null===(t=this._peerConnection)||void 0===t?void 0:t.getStats(null).then((function(e){var t={};if(e){var i,o=r._estimatedRoundTripTime;e.forEach((function(a){if("candidate-pair"===a.type&&a.currentRoundTripTime&&(o=1e3*a.currentRoundTripTime,t.audio&&(t.audio.roundTripTime=o),t.video&&(t.video.roundTripTime=o)),"candidate-pair"===a.type&&a.lastPacketReceivedTimestamp&&(i=a.lastPacketReceivedTimestamp,t.audio&&(t.audio.lastPacketReceivedTimestamp=i),t.video&&(t.video.lastPacketReceivedTimestamp=i)),"inbound-rtp"===a.type){var s=a.kind||a.mediaType||n(a),u="";if(e.forEach((function(e){e.id===a.codecId&&(u=e.mimeType)})),s&&r._tracksToMonitor.includes(s)){var c,l,d,h,p,f,m,v=(a.bytesReceived||0)-(null!==(c=null===(l=r._rtcStatistic.value)||void 0===l||null===(d=l[s])||void 0===d?void 0:d.bytesReceived)&&void 0!==c?c:0),g=a.timestamp-((null===(h=r._rtcStatistic.value)||void 0===h||null===(p=h[s])||void 0===p?void 0:p.timestamp)||0),_=v&&g?Math.floor(8*v/g*1e3):0;if(t[s]={ssrc:a.ssrc,mediaType:s,timestamp:a.timestamp,bitrate:_,bytesReceived:a.bytesReceived,packetsLost:a.packetsLost,packetsReceived:a.packetsReceived,codec:u||r.getCodecByType(s),roundTripTime:o},(a.lastPacketReceivedTimestamp||i)&&(t[s].lastPacketReceivedTimestamp=a.lastPacketReceivedTimestamp||i),"video"===s&&null!==(f=r._rtcStatistic.value)&&void 0!==f&&null!==(m=f.video)&&void 0!==m&&m.framesDecoded){t[s].framesDecoded=a.framesDecoded;var y=(a.framesDecoded-r._rtcStatistic.value.video.framesDecoded)/(t[s].timestamp-r._rtcStatistic.value.video.timestamp)*1e3;t[s].fps=y?Math.round(100*y)/100:0}}}}))}r._rtcStatistic.value=t})).then((function(){r._isMonitorRunning&&(r._updateTimeout=w.value.setTimeout((function(){return r.updateStatistic()}),1e3))}));case 8:e.sent;case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"updateStatisticLegacy",value:(e=M()(V().mark((function e(){var t,n=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this._peerConnection)||void 0===t?void 0:t.getStatsLegacy().then((function(e){var t={},r=n._estimatedRoundTripTime;e.result().forEach((function(e){if(e.names().forEach((function(t){"googRTT"===t&&(r=e.stat(t))})),"ssrc"===e.type){var i,o,a=e.stat("mediaType").toString();t[a]={timestamp:Date.now()},t[a].ssrc=e.stat("ssrc").toString(),t[a].mediaType=a,t[a].bytesReceived=e.stat("bytesReceived"),t[a].packetsLost=e.stat("packetsLost"),t[a].packetsReceived=e.stat("packetsReceived"),t[a].codec=e.stat("googCodecName").toString()||n.getCodecByType(a),t[a].roundTripTime=r,"video"===a&&null!==(i=n._rtcStatistic.value)&&void 0!==i&&null!==(o=i.video)&&void 0!==o&&o.framesDecoded&&(t[a].framesDecoded=e.stat("framesDecoded"),t[a].fps=(t[a].framesDecoded-n._rtcStatistic.value.video.framesDecoded)/(t[a].timestamp-n._rtcStatistic.value.video.timestamp)*1e3||0)}})),n._rtcStatistic.value=t})).then((function(){n._isMonitorRunning&&(n._updateTimeout=w.value.setTimeout((function(){return n.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||"unknown";case"video":return this._estimatedVideoCodec||"unknown";default:return"unknown"}}}]);var e,n}(),St=function(e){return e[e.BufferingPeriod=0]="BufferingPeriod",e[e.PictureTiming=1]="PictureTiming",e[e.PanScanRect=2]="PanScanRect",e[e.FillerPayload=3]="FillerPayload",e[e.UserDataRegistered=4]="UserDataRegistered",e[e.UserDataUnregistered=5]="UserDataUnregistered",e[e.RecoveryPoint=6]="RecoveryPoint",e[e.DecRefPicMarkingRepeition=7]="DecRefPicMarkingRepeition",e[e.SparePic=8]="SparePic",e[e.SceneInfo=9]="SceneInfo",e[e.SubSeqInfo=10]="SubSeqInfo",e[e.SubSeqLayerCharacteristics=11]="SubSeqLayerCharacteristics",e[e.SubSeqCharacteristics=12]="SubSeqCharacteristics",e[e.FullFrameFreeze=13]="FullFrameFreeze",e[e.FullFrameFreezeRelease=14]="FullFrameFreezeRelease",e[e.FullFrameSnapshot=15]="FullFrameSnapshot",e[e.ProgressiveRefinementSegmentStart=16]="ProgressiveRefinementSegmentStart",e[e.ProgressiveRefinementSegmentEnd=17]="ProgressiveRefinementSegmentEnd",e[e.MotionConstrainedSliceGroupSet=18]="MotionConstrainedSliceGroupSet",e[e.FilmGrainCharacteristic=19]="FilmGrainCharacteristic",e[e.DeblockingFilterDisplayReference=20]="DeblockingFilterDisplayReference",e[e.StereoVideoInfo=21]="StereoVideoInfo",e[e.PostFilterHint=22]="PostFilterHint",e[e.ToneMappingInfo=23]="ToneMappingInfo",e[e.ScalabilityInfo=24]="ScalabilityInfo",e[e.SubPicScalableLayer=25]="SubPicScalableLayer",e[e.NonRequiredLayerRep=26]="NonRequiredLayerRep",e[e.PariorityLayerInfo=27]="PariorityLayerInfo",e[e.LayersNotPresent=28]="LayersNotPresent",e[e.LayerDependencyChange=29]="LayerDependencyChange",e[e.ScalableNesting=30]="ScalableNesting",e[e.BaseLayerTemporalHrd=31]="BaseLayerTemporalHrd",e[e.QualityLayerIntegrityCheck=32]="QualityLayerIntegrityCheck",e[e.RedundantPicProperty=33]="RedundantPicProperty",e[e.Tl0DepRepIndex=34]="Tl0DepRepIndex",e[e.TlSwitchingPoint=35]="TlSwitchingPoint",e[e.ParallelDecodingInfo=36]="ParallelDecodingInfo",e[e.MvcScalableNesting=37]="MvcScalableNesting",e[e.ViewScalabilityInfo=38]="ViewScalabilityInfo",e[e.MultiviewSceneInfo=39]="MultiviewSceneInfo",e[e.MultiviewAcquisitionInfo=40]="MultiviewAcquisitionInfo",e[e.NonRequiredViewComponent=41]="NonRequiredViewComponent",e[e.ViewDependencyChange=42]="ViewDependencyChange",e[e.OperationPointsNotPresent=43]="OperationPointsNotPresent",e[e.BaseViewTemporalHdr=44]="BaseViewTemporalHdr",e[e.FramePackingArrangement=45]="FramePackingArrangement",e[e.MultiviewViewPosition=46]="MultiviewViewPosition",e[e.DisplayOrientation=47]="DisplayOrientation",e[e.MvcdScalableNesting=48]="MvcdScalableNesting",e[e.MvcdViewScalabilityInfo=49]="MvcdViewScalabilityInfo",e[e.DepthRepresentationInfo=50]="DepthRepresentationInfo",e[e.ThreeDimensionalReferenceDisplaysInfo=51]="ThreeDimensionalReferenceDisplaysInfo",e[e.DepthTiming=52]="DepthTiming",e[e.DepthSamplingInfo=53]="DepthSamplingInfo",e[e.ConstrainedDepthParameterSetIdentifier=54]="ConstrainedDepthParameterSetIdentifier",e[e.GreenMetadata=55]="GreenMetadata",e[e.MasteringDisplayColourVolumev=56]="MasteringDisplayColourVolumev",e[e.ColourRemappingInfo=57]="ColourRemappingInfo",e[e.ContentLightLevelInfo=58]="ContentLightLevelInfo",e[e.AlternativeTransferCharacteristics=59]="AlternativeTransferCharacteristics",e[e.AmbientViewingEnvironment=60]="AmbientViewingEnvironment",e[e.ContentColourVolume=61]="ContentColourVolume",e[e.EquirectangularProjection=62]="EquirectangularProjection",e[e.CubemapProjection=63]="CubemapProjection",e[e.SphereRotation=64]="SphereRotation",e[e.RegionwisePacking=65]="RegionwisePacking",e[e.OmniViewport=66]="OmniViewport",e[e.AlternativeDepthInfo=67]="AlternativeDepthInfo",e[e.SeiManifest=68]="SeiManifest",e[e.SeiPrefixIndication=69]="SeiPrefixIndication",e[e.AnnotatedRegions=70]="AnnotatedRegions",e[e.ShutterIntervalInfo=71]="ShutterIntervalInfo",e}(St||{}),xt=St,wt=function(){return o()((function e(n){t()(this,e),s()(this,"_data",void 0),s()(this,"_bitOffset",void 0),this._data=n,this._bitOffset=0}),[{key:"readBits",value:function(e){if(this._bitOffset+e>8*this._data.length)throw new Error("Cannot read [".concat(e,"] bits - only [").concat(this.getRemainingBits(),"] bits remaining in stream"));for(var t=0,n=e;n>0;){var r=Math.floor(this._bitOffset/8),i=8-this._bitOffset%8,o=Math.min(n,i),a=(1<<o)-1;t=t<<o|this._data[r]>>i-o&a,n-=o,this._bitOffset+=o}return t}},{key:"skipBits",value:function(e){if(this._bitOffset+e>8*this._data.length)throw new Error("Cannot skip [".concat(e,"] bits - only [").concat(this.getRemainingBits(),"] bits remaining in stream"));this._bitOffset+=e}},{key:"getRemainingBits",value:function(){return 8*this._data.length-this._bitOffset}}])}(),Tt=function(){return o()((function e(){throw t()(this,e),new Error("EmulationPreventionBytes is a static class that may not be instantiated")}),null,[{key:"getOffsetWithExpandedEmulationPreventionBytes",value:function(e,t,n){for(var r=0,i=0,o=n,a=t;a<e.length&&0!==o;a++,i++)2!==r||3!==e[a]?(0===e[a]?r++:r>0&&(r=0),o--):r=0;return i}},{key:"removeEmulationPreventionBytes",value:function(e){for(var t=new Uint8Array(e.byteLength),n=0,r=0,i=2;i<e.byteLength;i++)3===e[i]&&0===e[i-1]&&0===e[i-2]&&(t.set(e.subarray(r,i),n),n+=i-r,r=i+1);return r<e.byteLength&&t.set(e.subarray(r),n),t}}])}(),Pt=function(e){return e[e.ProgressiveFrame=0]="ProgressiveFrame",e[e.TopField=1]="TopField",e[e.BottomField=2]="BottomField",e[e.TopFieldBottomField=3]="TopFieldBottomField",e[e.BottomFieldTopField=4]="BottomFieldTopField",e[e.TopFieldBottomFieldTopFieldRepeated=5]="TopFieldBottomFieldTopFieldRepeated",e[e.BottomFieldTopFieldBottomFieldRepeated=6]="BottomFieldTopFieldBottomFieldRepeated",e[e.FrameDoubling=7]="FrameDoubling",e[e.FrameTripling=8]="FrameTripling",e}(Pt||{}),Et=function(){return o()((function e(){t()(this,e)}),[{key:"parse",value:function(e,t){var n=new wt(Tt.removeEmulationPreventionBytes(e)),r={picStruct:void 0};if(t.cpbDpbDelaysPresentFlag&&(n.skipBits(t.cpbRemovalDelayLengthMinus1+1),n.skipBits(t.dpbOutputDelayLengthMinus1+1)),t.picStructPresentFlag){var i=this.convertPicStructToNumClockTS(n.readBits(4));r.picStruct={numClockTS:i,clockTimestamps:[]};for(var o=0;o<r.picStruct.numClockTS;o++){var a=1===n.readBits(1);if(a){var s={ctType:n.readBits(2),nuitFieldBasedFlag:1===n.readBits(1),countingType:n.readBits(5),fullTimestampFlag:1===n.readBits(1),discontinuityFlag:1===n.readBits(1),cntDroppedFlag:1===n.readBits(1),nFrames:n.readBits(8)};s.fullTimestampFlag?(s.seconds=n.readBits(6),s.minutes=n.readBits(6),s.hours=n.readBits(5)):1===n.readBits(1)&&(s.seconds=n.readBits(6),1===n.readBits(1)&&(s.minutes=n.readBits(6),1===n.readBits(1)&&(s.hours=n.readBits(5)))),s.timeOffset=n.readBits(24),r.picStruct.clockTimestamps.push({clockTimestampFlag:a,clockTimestamp:s})}else r.picStruct.clockTimestamps.push({clockTimestampFlag:!1})}}return r}},{key:"convertPicStructToNumClockTS",value:function(e){switch(e){case Pt.ProgressiveFrame:case Pt.TopField:case Pt.BottomField:return 1;case Pt.TopFieldBottomField:case Pt.BottomFieldTopField:case Pt.FrameDoubling:return 2;case Pt.TopFieldBottomFieldTopFieldRepeated:case Pt.BottomFieldTopFieldBottomFieldRepeated:case Pt.FrameTripling:return 3;default:return 0}}}])}();function Ft(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var It=function(){return o()((function e(){t()(this,e),s()(this,"_listeners",new Set)}),[{key:"subscribe",value:function(e){var t=this;return this._listeners.add(e),new f((function(){return t._listeners.delete(e)}))}},{key:"emit",value:function(e){var t,n=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Ft(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)?Ft(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(this._listeners);try{for(n.s();!(t=n.n()).done;)(0,t.value)(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"dispose",value:function(){this.cleanUpResources()}},{key:"cleanUpResources",value:function(){this._listeners.clear()}}])}(),Rt=function(){return o()((function e(){t()(this,e),s()(this,"_eventEmitters",new Map),s()(this,"_onEventWithNoSubscriberHandlers",new Set),s()(this,"_disposables",new ne)}),[{key:"onEventWithNoSubscriber",value:function(e){var t=this;return this._onEventWithNoSubscriberHandlers.add(e),new f((function(){return t._onEventWithNoSubscriberHandlers.delete(e)}))}},{key:"subscribe",value:function(e,t){var n=(this._eventEmitters.get(e)||this.createEmitter(e)).subscribe(t);return this._disposables.add(n),n}},{key:"publish",value:function(e,t){var n=this._eventEmitters.get(e);n?n.emit(t):this._onEventWithNoSubscriberHandlers.forEach((function(n){return n(e,t)}))}},{key:"dispose",value:function(){this._disposables.dispose(),this.cleanUpResources()}},{key:"cleanUpResources",value:function(){this._eventEmitters.clear(),this._onEventWithNoSubscriberHandlers.clear()}},{key:"createEmitter",value:function(e){var t=new It;return this._eventEmitters.set(e,t),t}}])}(),Dt=function(e){return e[e.EncodedVideoStreamChunk=0]="EncodedVideoStreamChunk",e[e.NalUnit=1]="NalUnit",e[e.SeiPayload=2]="SeiPayload",e[e.Payload=3]="Payload",e[e.PayloadSubscription=4]="PayloadSubscription",e[e.EndOfChunk=5]="EndOfChunk",e}({}),Ot=function(){return o()((function e(n){t()(this,e),s()(this,"_eventPublisher",void 0),s()(this,"_disposables",new ne),this._eventPublisher=n}),[{key:"subscribeToNalUnit",value:function(e,t){return this._eventPublisher.subscribe(Dt.NalUnit,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToSeiPayloadType",value:function(e,t){return this._eventPublisher.subscribe(Dt.SeiPayload,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToPayload",value:function(e,t,n){return this._eventPublisher.publish(Dt.PayloadSubscription,{context:e,data:t}),this._eventPublisher.subscribe(Dt.Payload,(function(e){e.data.uuid===t&&n(e)}))}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),Lt=function(){function e(){throw t()(this,e),new Error("Uint8Arrays is a static class that may not be instantiated")}return o()(e,null,[{key:"isDataAtOffsetTargetByteSequence",value:function(e,t,n){for(var r=0;r<e.length;r++)if(e[r]!==t[n+r])return!1;return!0}},{key:"findTargetByteSequenceIndexFromOffset",value:function(t,n,r){for(var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,o=r;o<=n.byteLength;o++)if(e.isDataAtOffsetTargetByteSequence(t,n,o))return o;return i}},{key:"getUuidStringFromUint8Array",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,n=[],r=0;r<t;r++){var i=e[r].toString(16).padStart(2,"0");n.push(i),3!==r&&5!==r&&7!==r&&9!==r||n.push("-")}return n.join("")}}])}(),At=function(e){return e[e.Unspecified=0]="Unspecified",e[e.SliceLayerNonIdrData=1]="SliceLayerNonIdrData",e[e.SliceDataPartitionALayer=2]="SliceDataPartitionALayer",e[e.SliceDataPartitionBLayer=3]="SliceDataPartitionBLayer",e[e.SliceDataPartitionCLayer=4]="SliceDataPartitionCLayer",e[e.SliceLayerIdrData=5]="SliceLayerIdrData",e[e.SupplementalEnhancementInformation=6]="SupplementalEnhancementInformation",e[e.SequenceParameterSet=7]="SequenceParameterSet",e[e.PictureParameterSet=8]="PictureParameterSet",e[e.AccessUnitDelimiter=9]="AccessUnitDelimiter",e[e.EndOfSequence=10]="EndOfSequence",e[e.EndOfStream=11]="EndOfStream",e[e.FillerData=12]="FillerData",e[e.SequenceParamterSetExtension=13]="SequenceParamterSetExtension",e[e.PrefixNalUnit=14]="PrefixNalUnit",e[e.SubsetSequenceParamterSet=15]="SubsetSequenceParamterSet",e[e.DepthParamterSet=16]="DepthParamterSet",e[e.Reserved17=17]="Reserved17",e[e.Reserved18=18]="Reserved18",e[e.SliceLayerAuxiliary=19]="SliceLayerAuxiliary",e[e.SliceExtension=20]="SliceExtension",e[e.SliceExtensionDepthViewComponent=21]="SliceExtensionDepthViewComponent",e[e.Reserved22=22]="Reserved22",e[e.Reserverd23=23]="Reserverd23",e[e.Unspecified24=24]="Unspecified24",e[e.Unspecified25=25]="Unspecified25",e[e.Unspecified26=26]="Unspecified26",e[e.Unspecified27=27]="Unspecified27",e[e.Unspecified28=28]="Unspecified28",e[e.Unspecified29=29]="Unspecified29",e[e.Unspecified30=30]="Unspecified30",e[e.Unspecified31=31]="Unspecified31",e}(At||{}),Mt=At,Nt=function(){function e(n,r){t()(this,e),s()(this,"_eventPublisher",void 0),s()(this,"_vclExtractionStrategy",void 0),s()(this,"_disposables",new ne),this._eventPublisher=n,this._vclExtractionStrategy=r,this._disposables.add(this.subscribeToEncodedVideoStreamChunkEvents())}return o()(e,[{key:"dispose",value:function(){this._disposables.dispose()}},{key:"subscribeToEncodedVideoStreamChunkEvents",value:function(){return this._eventPublisher.subscribe(Dt.EncodedVideoStreamChunk,this.parseEncodedVideoStreamChunk.bind(this))}},{key:"parseEncodedVideoStreamChunk",value:function(e){for(var t=e.context,n=e.data,r=0;r<n.byteLength;)r+=this.handleExtractedData(t,this.extractNalUnitAtOffset(n,r));this.notifyEndOfChunk(t)}},{key:"handleExtractedData",value:function(e,t){var n=this,r=t.annexBStartCodeLength,i=t.nalUnit,o=t.seiPayloads;return this.publishNalUnit(e,i),null==o||o.forEach((function(t){return n.handleSeiPayload(e,t)})),i.data.byteLength+r}},{key:"handleSeiPayload",value:function(e,t){this.publishSeiPayload(e,t),t.type===xt.UserDataUnregistered&&this.handleSeiPayloadUserDataUnregistered(e,t)}},{key:"handleSeiPayloadUserDataUnregistered",value:function(e,t){var n=Lt.getUuidStringFromUint8Array(t.data.subarray(0,16)),r=t.data.subarray(16);this.publishPayload(e,{uuid:n,data:r})}},{key:"publishNalUnit",value:function(e,t){this._eventPublisher.publish(Dt.NalUnit,{context:e,data:t})}},{key:"publishSeiPayload",value:function(e,t){this._eventPublisher.publish(Dt.SeiPayload,{context:e,data:t})}},{key:"publishPayload",value:function(e,t){this._eventPublisher.publish(Dt.Payload,{context:e,data:t})}},{key:"notifyEndOfChunk",value:function(e){this._eventPublisher.publish(Dt.EndOfChunk,{context:e,data:null})}},{key:"extractNalUnitAtOffset",value:function(e,t){var n,r=1===e[t+2]?3:4,i=t+r,o=31&e[i];switch(o){case Mt.SliceLayerNonIdrData:case Mt.SliceDataPartitionALayer:case Mt.SliceDataPartitionBLayer:case Mt.SliceDataPartitionCLayer:case Mt.SliceLayerIdrData:n=this._vclExtractionStrategy.extractVclNalUnit(e,i);break;case Mt.SupplementalEnhancementInformation:n=this.extractSeiNalUnit(e,i);break;default:n=this.extractNonVclNalUnit(e,i)}return{annexBStartCodeLength:r,nalUnit:{type:o,data:n.nalUnitData},seiPayloads:n.seiPayloads}}},{key:"extractSeiNalUnit",value:function(t,n){for(var r=n+1,i=[];!Lt.isDataAtOffsetTargetByteSequence(e._seiPayload4ByteEndCode,t,r)&&!Lt.isDataAtOffsetTargetByteSequence(e._seiPayload3ByteEndCode,t,r)&&r<t.byteLength;){var o=this.extractSeiPayload(t,r);i.push({data:o.payload,type:o.payloadType}),r=o.endIndex}return r++,{nalUnitData:t.subarray(n,r),seiPayloads:i}}},{key:"extractNonVclNalUnit",value:function(t,n){var r=e.findAnnexBStartIndexFromOffset(t,n,t.byteLength);return{nalUnitData:t.subarray(n,r)}}},{key:"extractSeiPayload",value:function(e,t){for(var n=t,r=0;255===e[n];)n++,r++;var i=255*r+e[n];for(n++,r=0;255===e[n];)n++,r++;var o=255*r+e[n],a=++n+Tt.getOffsetWithExpandedEmulationPreventionBytes(e,n,o);return{payloadType:i,payload:e.subarray(n,a),endIndex:a}}}],[{key:"findAnnexBStartIndexFromOffset",value:function(t,n,r){var i=Lt.findTargetByteSequenceIndexFromOffset(e.annexB4ByteStartCode,t,n,r);return i!==r?i:Lt.findTargetByteSequenceIndexFromOffset(e.annexB3ByteStartCode,t,n,r)}}])}();s()(Nt,"annexB3ByteStartCode",new Uint8Array([0,0,1])),s()(Nt,"annexB4ByteStartCode",new Uint8Array([0,0,0,1])),s()(Nt,"_seiPayload3ByteEndCode",new Uint8Array([128,0,0,1])),s()(Nt,"_seiPayload4ByteEndCode",new Uint8Array([128,0,0,0,1]));var Vt=function(){return o()((function e(){t()(this,e)}),[{key:"extractVclNalUnit",value:function(e,t){var n=Nt.findAnnexBStartIndexFromOffset(e,t,e.byteLength);return{nalUnitData:e.subarray(t,n)}}}])}(),Ut=function(){function e(){t()(this,e)}return o()(e,[{key:"extractVclNalUnit",value:function(t,n){var r=n+Nt.annexB4ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;if(Lt.isDataAtOffsetTargetByteSequence(Nt.annexB4ByteStartCode,t,r))return{nalUnitData:t.subarray(n+Nt.annexB4ByteStartCode.byteLength,r)};var i=n+Nt.annexB3ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;return Lt.isDataAtOffsetTargetByteSequence(Nt.annexB3ByteStartCode,t,i)?{nalUnitData:t.subarray(n+Nt.annexB3ByteStartCode.byteLength,i)}:{nalUnitData:t.subarray(n)}}}])}();s()(Ut,"_truncatedVclNalUnitByteLength",32);var Bt=function(){},jt=function(){function e(n){t()(this,e),s()(this,"_logger",X.getLogger("PhenixEmbeddedIsoBmff2023")),s()(this,"_eventPublisher",void 0),s()(this,"_expectedPayloadUuid",new Set),s()(this,"_endOfChunkHandlersByTrackId",new Map),s()(this,"_disposables",new ne),s()(this,"_enableWarningLogWhenVclEmbeddedDataNotFound",new f(this.enableWarningLogWhenVclEmbeddedDataNotFound.bind(this))),this._eventPublisher=n,this._expectedPayloadUuid.add(e._phenixVclEmbeddedDataUuid),this._expectedPayloadUuid.add(e._phenixInitializationSegmentUuid),this._disposables.add(this.subscribeToPayloadEvents()),this._disposables.add(this.subscribeToPayloadSubscriptionEvents()),this._disposables.add(this.subscribeToNalUnitEvents())}return o()(e,[{key:"subscribeToEmbeddedData",value:function(t){return this._enableWarningLogWhenVclEmbeddedDataNotFound.dispose(),this._eventPublisher.subscribe(Dt.Payload,(function(n){var r=n.context,i=n.data;switch(i.uuid){case e._phenixInitializationSegmentUuid:t({context:r,data:{type:"Initialization",data:i.data}});break;case e._phenixVclEmbeddedDataUuid:t({context:r,data:{type:"Media",data:i.data}})}}))}},{key:"dispose",value:function(){this._disposables.dispose(),this._endOfChunkHandlersByTrackId.clear(),this._expectedPayloadUuid.clear()}},{key:"enableWarningLogWhenVclEmbeddedDataNotFound",value:function(){this._disposables.add(this.subscribeToEncodedVideoStreamChunkEvents()),this._disposables.add(this.subscribeToEndOfChunkEvents())}},{key:"subscribeToPayloadSubscriptionEvents",value:function(){var e=this;return this._eventPublisher.subscribe(Dt.PayloadSubscription,(function(t){var n=t.data;return e._expectedPayloadUuid.add(n)}))}},{key:"subscribeToEncodedVideoStreamChunkEvents",value:function(){return this._eventPublisher.subscribe(Dt.EncodedVideoStreamChunk,this.armLoggingNoVclEmbeddedDataFound.bind(this))}},{key:"subscribeToNalUnitEvents",value:function(){return this._eventPublisher.subscribe(Dt.NalUnit,this.handleNalUnitEvent.bind(this))}},{key:"handleNalUnitEvent",value:function(t){var n=t.context,r=t.data;r.type>Mt.SliceLayerIdrData||r.data.byteLength<e._truncatedVclNalUnitDataByteLength||(this.publishVclEmbeddedPayload(n,{uuid:e._phenixVclEmbeddedDataUuid,data:this.extractVclEmbeddedData(r)}),this.disarmLoggingNoVclEmbeddedDataFound(n.trackId))}},{key:"extractVclEmbeddedData",value:function(t){return t.data.subarray(e._truncatedVclNalUnitDataByteLength)}},{key:"publishVclEmbeddedPayload",value:function(e,t){this._eventPublisher.publish(Dt.Payload,{context:e,data:t})}},{key:"armLoggingNoVclEmbeddedDataFound",value:function(e){var t=e.context;this._endOfChunkHandlersByTrackId.set(t.trackId,this.logWarningVclEmbeddedDataNotFound.bind(this,t))}},{key:"disarmLoggingNoVclEmbeddedDataFound",value:function(e){this._endOfChunkHandlersByTrackId.set(e,Bt)}},{key:"logWarningVclEmbeddedDataNotFound",value:function(e){this._logger.warn("[%s] [%s] No VCL embedded data found in an encoded video stream chunk from track with id [%s]",e.streamId,e.contextId,e.trackId)}},{key:"subscribeToEndOfChunkEvents",value:function(){return this._eventPublisher.subscribe(Dt.EndOfChunk,this.handleEndOfEncodedVideoStreamChunk.bind(this))}},{key:"handleEndOfEncodedVideoStreamChunk",value:function(e){var t=e.context;this._endOfChunkHandlersByTrackId.get(t.trackId)()}},{key:"subscribeToPayloadEvents",value:function(){return this._eventPublisher.subscribe(Dt.Payload,this.handlePayloadEvent.bind(this))}},{key:"handlePayloadEvent",value:function(e){var t=e.context,n=e.data;this._expectedPayloadUuid.has(n.uuid)||w.value.setTimeout(this.logWarningUnexpectedPayloadUuidReceivedOnce.bind(this,t,n.uuid))}},{key:"logWarningUnexpectedPayloadUuidReceivedOnce",value:function(e,t){this._logger.warn("[%s] [%s] [%s] Received unexpected payload with uuid [%s]",e.streamId,e.contextId,e.trackId,t),this._expectedPayloadUuid.add(t)}}])}();s()(jt,"_truncatedVclNalUnitDataByteLength",32),s()(jt,"_phenixVclEmbeddedDataUuid","00000000-0000-0000-0000-000000000000"),s()(jt,"_phenixInitializationSegmentUuid","511e22bd-34c0-4cee-b6c3-3c4d407622c7");var zt=function(){return o()((function e(n,r,i){t()(this,e),s()(this,"_eventPublisher",void 0),s()(this,"_bitstream",void 0),s()(this,"_parser",void 0),s()(this,"_disposables",new ne),this._eventPublisher=n,this._bitstream=r,this._parser=i,this._disposables.add(this._bitstream),this._disposables.add(this._parser)}),[{key:"bitstream",get:function(){return this._bitstream}},{key:"decode",value:function(e){this._eventPublisher.publish(Dt.EncodedVideoStreamChunk,e)}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),Ht=function(){return o()((function e(n,r){t()(this,e),s()(this,"_h264VideoBitstreamDecoder",void 0),s()(this,"_encoding",void 0),s()(this,"_disposables",void 0),this._h264VideoBitstreamDecoder=n,this._encoding=r,this._disposables=new ne,this._disposables.add(this._h264VideoBitstreamDecoder),this._disposables.add(this._encoding)}),[{key:"bitstream",get:function(){return this._h264VideoBitstreamDecoder.bitstream}},{key:"decode",value:function(e){this._h264VideoBitstreamDecoder.decode(e)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"subscribeToEmbeddedData",value:function(e,t){return t?this._encoding.subscribeToEmbeddedData((function(n){n.trackId===t&&e(n)})):this._encoding.subscribeToEmbeddedData(e)}}])}(),Gt=function(){return o()((function e(){throw t()(this,e),new Error("BitstreamDecoders is a static class that may not be instantiated")}),null,[{key:"createH264VideoBitstreamDecoder",value:function(){var e=new Rt,t=new Ot(e),n=new Nt(e,new Vt);return new zt(e,t,n)}},{key:"createPhenixH264EmbeddedIsoBmff2023VideoBitstreamDecoder",value:function(){var e=new Rt,t=new Ot(e),n=new Nt(e,new Ut),r=new zt(e,t,n),i=new jt(e);return new Ht(r,i)}}])}();function Wt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function qt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wt(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Jt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var Kt,Zt=function(){function e(n,r){var i=this;t()(this,e),s()(this,"_channelContext",void 0),s()(this,"_frameTimingInformationContext",void 0),s()(this,"_bitstreamDecoder",Gt.createH264VideoBitstreamDecoder()),s()(this,"_frameTimingsByRtpTimestamp",new Map),s()(this,"_picturingTimingParsingConfig",{cpbDpbDelaysPresentFlag:!1,picStructPresentFlag:!0}),s()(this,"_pictureTimingParser",new Et),s()(this,"_videoElementDisposables",new ne),s()(this,"_currentPlaybackState","waiting"),s()(this,"_armedVideoFrameCallbackId",null),s()(this,"_disposables",new ne),s()(this,"_disposed",!1),this._channelContext=n,this._frameTimingInformationContext=r,this._disposables.add(this._bitstreamDecoder),this._disposables.add(new f((function(){return i._frameTimingsByRtpTimestamp.clear()}))),this._disposables.add(this._videoElementDisposables),this._channelContext.videoElement.value&&this.setupVideoEventListeners(this._channelContext.videoElement.value),this._disposables.add(this._channelContext.videoElement.subscribe((function(e){i._videoElementDisposables.dispose(),e&&i.setupVideoEventListeners(e)}))),this._frameTimingInformationContext.shouldExtractTimecode.value&&this._disposables.add(this._bitstreamDecoder.bitstream.subscribeToSeiPayloadType(xt.PictureTiming,this.onPictureTimingExtracted.bind(this)))}return o()(e,[{key:"processFrame",value:function(e,t,n,r){if(!this._disposed){var i={mid:t,trackId:n,receiveTimestamp:new Date};this.removeFrameTimingsExceedingMaxCapacity();var o=r.timestamp.toString(10);this._frameTimingsByRtpTimestamp.has(o),this._frameTimingsByRtpTimestamp.set(o,i),this._bitstreamDecoder.decode({context:{streamId:e,trackId:n,contextId:o},data:new Uint8Array(r.data)})}}},{key:"dispose",value:function(){this._disposed=!0,this._disposables.dispose()}},{key:"onPictureTimingExtracted",value:function(e){var t,n,r,i,o,a=e.context,s=a.contextId,u=a.trackId,c=e.data;if(!this._disposed){var l=null===(t=this._pictureTimingParser.parse(c.data,this._picturingTimingParsingConfig).picStruct)||void 0===t||null===(n=t.clockTimestamps.find((function(e){return!0===e.clockTimestampFlag})))||void 0===n?void 0:n.clockTimestamp;if(l){var d=this._frameTimingsByRtpTimestamp.get(s);if(d){var h={mid:d.mid,trackId:u,kind:"video",codec:"H264",timecode:{hours:null!==(r=l.hours)&&void 0!==r?r:null,minutes:null!==(i=l.minutes)&&void 0!==i?i:null,seconds:null!==(o=l.seconds)&&void 0!==o?o:null,frames:l.nFrames,isFrameDrop:l.countingType>1},sourceTimestamp:null,ingestTimestamp:null,encodeTimestamp:null,transcodeTimestamp:null,receiveTimestamp:new Date(d.receiveTimestamp),playbackState:this._currentPlaybackState};d.decodedFrameTimingInformation=h,this._frameTimingInformationContext.decodedFrameTimingInformation.value=h}}}}},{key:"videoFrameCallback",value:function(e,t){if(!this._disposed){this.armVideoFrameCallback();var n=t.rtpTimestamp;if(n){var r,i=[],o=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Jt(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Jt(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(this._frameTimingsByRtpTimestamp);try{for(o.s();!(r=o.n()).done;){var a=yt()(r.value,2),s=a[0],u=a[1];if(parseInt(s,10)>n)break;"playing"===this._currentPlaybackState&&(this._frameTimingInformationContext.renderedFrameTimingInformation.value=qt(qt({},u.decodedFrameTimingInformation),{},{renderTimestamp:new Date(performance.timeOrigin+e),playbackState:"playing"})),i.push(s)}}catch(e){o.e(e)}finally{o.f()}for(var c=0,l=i;c<l.length;c++){var d=l[c];this._frameTimingsByRtpTimestamp.delete(d)}}}}},{key:"removeFrameTimingsExceedingMaxCapacity",value:function(){var t=this._frameTimingsByRtpTimestamp.size-(e.MAX_FRAME_TIMING_ENTRIES-1);if(!(t<=0))for(var n=this._frameTimingsByRtpTimestamp.keys(),r=0;r<t;r++){var i=n.next().value;this._frameTimingsByRtpTimestamp.delete(i)}}},{key:"setupVideoEventListeners",value:function(e){var t=this,n=function(){return t._currentPlaybackState="playing"};e.addEventListener("playing",n),this._videoElementDisposables.add(new f((function(){return e.removeEventListener("playing",n)})));var r=function(){return t._currentPlaybackState="paused"};e.addEventListener("pause",r),this._videoElementDisposables.add(new f((function(){return e.removeEventListener("pause",r)})));var i=function(){return t._currentPlaybackState="stalled"};e.addEventListener("stalled",i),this._videoElementDisposables.add(new f((function(){return e.removeEventListener("stalled",i)})));var o=function(){return t._currentPlaybackState="waiting"};e.addEventListener("waiting",o),this._videoElementDisposables.add(new f((function(){return e.removeEventListener("waiting",o)})));var a=function(){return t._currentPlaybackState="ended"};e.addEventListener("ended",a),this._videoElementDisposables.add(new f((function(){return e.removeEventListener("ended",a)})));var s=function(){return t._currentPlaybackState="error"};e.addEventListener("error",s),this._videoElementDisposables.add(new f((function(){return e.removeEventListener("error",s)}))),this.armVideoFrameCallback(),this._videoElementDisposables.add(new f((function(){var e;t._armedVideoFrameCallbackId&&(null===(e=t._channelContext.videoElement.value)||void 0===e||e.cancelVideoFrameCallback(t._armedVideoFrameCallbackId))})))}},{key:"armVideoFrameCallback",value:function(){var e;null!==(e=this._channelContext.videoElement.value)&&void 0!==e&&e.requestVideoFrameCallback&&(this._armedVideoFrameCallbackId=this._channelContext.videoElement.value.requestVideoFrameCallback(this.videoFrameCallback.bind(this)))}}])}();s()(Zt,"MAX_FRAME_TIMING_ENTRIES",1800);var Qt=Symbol(),$t=function(){function e(){throw t()(this,e),new Error("SurrogateFrameDataManager is a static class that may not be instantiated")}return o()(e,null,[{key:"getSurrogateAudioSilentPerCodec",value:function(t){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)?Qt: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?Qt: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(),i=e._dummy82x82H264PFrameFrameNumberIndex;return r[i]|=t,r[i+1]|=n,e._surrogate82x82PFrameFrameNumber++,r.buffer}}])}();Kt=$t,s()($t,"_isSafari","Safari"===T.browserName),s()($t,"_isMobileChrome","Chrome"===T.browserName&&T.isMobile()),s()($t,"_isAndroidChrome","Chrome"===T.browserName&&T.isAndroid),s()($t,"_singleZeroByte",new Uint8Array([0])),s()($t,"_dummyAudioSilentPerCodec",{OPUS:new Uint8Array([104,7,217,171,188,121,135,171,142,74,20,243,167,28,242,154,122,69,167,45,68,37,116,76,173,22,179,14,81,87,234,231,173,42,56,206,51])}),s()($t,"_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])}),s()($t,"_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])}),s()($t,"_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(ye()(new Uint8Array(40).fill(255)),[95],ye()(new Uint8Array(10295).fill(255)),[128,0,0,0,1,101,136,132,5],ye()(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(ye()(new Uint8Array(40).fill(255)),[164],ye()(new Uint8Array(10364).fill(255)),[128,0,0,0,1,65,154,32,21,240,75]))}),s()($t,"_dummy82x82H264PFrameFrameNumberIndex",10418),s()($t,"_surrogate82x82PFrameFrameNumberReset",1),s()($t,"_useUpdateSurrogate82x82PFrameFrameNumber",Kt._isMobileChrome||Kt._isSafari),s()($t,"_surrogate82x82PFrameFrameNumber",Kt._surrogate82x82PFrameFrameNumberReset);var Xt=n(512),Yt=n.n(Xt);function en(){return Yt()('(()=>{var e={79:e=>{e.exports=function(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=Array(r);t<r;t++)o[t]=e[t];return o},e.exports.__esModule=!0,e.exports.default=e.exports},901:(e,r,t)=>{var o=t(79);e.exports=function(e){if(Array.isArray(e))return o(e)},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,r,t)=>{var o=t(736);function n(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}e.exports=function(e,r,t){return r&&n(e.prototype,r),t&&n(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},693:(e,r,t)=>{var o=t(736);e.exports=function(e,r,t){return(r=o(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e},e.exports.__esModule=!0,e.exports.default=e.exports},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},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},132:(e,r,t)=>{var o=t(901),n=t(291),a=t(122),i=t(869);e.exports=function(e){return o(e)||n(e)||a(e)||i()},e.exports.__esModule=!0,e.exports.default=e.exports},45:(e,r,t)=>{var o=t(738).default;e.exports=function(e,r){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},736:(e,r,t)=>{var o=t(738).default,n=t(45);e.exports=function(e){var r=n(e,"string");return"symbol"==o(r)?r:r+""},e.exports.__esModule=!0,e.exports.default=e.exports},738:e=>{function r(t){return e.exports=r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},122:(e,r,t)=>{var o=t(79);e.exports=function(e,r){if(e){if("string"==typeof e)return o(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(e,r):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports}},r={};function t(o){var n=r[o];if(void 0!==n)return n.exports;var a=r[o]={exports:{}};return e[o](a,a.exports,t),a.exports}t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{"use strict";var e,r,o,n,a=t(383),i=t.n(a),s=t(579),u=t.n(s),m=t(693),d=t.n(m),f=t(132),l=t.n(f),c=function(){function e(){i()(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 r=navigator.userAgent.match(e._browserNameAndVersionRegex);return r&&r[0]?r[0]:e.parseBrowserNameAndVersionForIE()}},{key:"parseBrowserName",value:function(){if(!e._browserNameAndVersion)return"";var r=e._browserNameAndVersion.split("/");return r&&r[0]?r[0]:""}},{key:"parseBrowserMajorVersion",value:function(){if(!e._browserNameAndVersion)return 0;var r=e._browserNameAndVersion.split("/");if(!r||!r[1])return 0;var t=r[1];return t&&Number(t.split(".")[0])||0}},{key:"parseBrowserNameAndVersionForIE",value:function(){if(!navigator||!navigator.userAgent)return"";var e=navigator.userAgent,r=e.indexOf("MSIE ");if(r>0)return"IE/".concat(parseInt(e.substring(r+5,e.indexOf(".",r)),10));if(e.indexOf("Trident/")>0){var t=e.indexOf("rv:");return"IE/".concat(parseInt(e.substring(t+3,e.indexOf(".",t)),10))}return""}}])}();e=c,d()(c,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\\/)([\\d.apre]+)/g),d()(c,"_browserNameAndVersion",e.parseBrowserNameAndVersion()),d()(c,"_browserName",e.parseBrowserName()),d()(c,"_browserMajorVersion",e.parseBrowserMajorVersion()),d()(c,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(r=navigator)||void 0===r?void 0:r.userAgent)),d()(c,"_isAndroid",/Android/i.test(null===(o=navigator)||void 0===o?void 0:o.userAgent)),d()(c,"_isChrome69",e._browserNameAndVersion.includes("Chrome/69.")),d()(c,"_isChrome70",e._browserNameAndVersion.includes("Chrome/70.")),d()(c,"_isChrome71",e._browserNameAndVersion.includes("Chrome/71.")),d()(c,"_isChrome72",e._browserNameAndVersion.includes("Chrome/72.")),d()(c,"_isChrome74",e._browserNameAndVersion.includes("Chrome/74.")),d()(c,"_isChrome75",e._browserNameAndVersion.includes("Chrome/75.")),d()(c,"_isChrome76",e._browserNameAndVersion.includes("Chrome/76.")),d()(c,"_isChrome77",e._browserNameAndVersion.includes("Chrome/77."));var p=Symbol(),b=function(){function e(){throw i()(this,e),new Error("SurrogateFrameDataManager is a static class that may not be instantiated")}return u()(e,null,[{key:"getSurrogateAudioSilentPerCodec",value:function(r){if("OPUS"===r.toUpperCase())return e._dummyAudioSilentPerCodec.OPUS.buffer}},{key:"getInvalidSurrogateAudioData",value:function(){return e._singleZeroByte.buffer}},{key:"getSurrogateVideoIFramePerCodec",value:function(r){switch(r.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(r){return"H264"===r.toUpperCase()&&e._useUpdateSurrogate82x82PFrameFrameNumber&&(e._surrogate82x82PFrameFrameNumber=e._surrogate82x82PFrameFrameNumberReset,e._isAndroidChrome)?p:e._singleZeroByte.buffer}},{key:"getSurrogateVideoPFramePerCodec",value:function(r){switch(r.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(r){if("H264"===r.toUpperCase()&&e._useUpdateSurrogate82x82PFrameFrameNumber){var t=e._surrogate82x82PFrameFrameNumber,o=e.getSurrogate82x82PFrameAndUpdateFrameNumber();return t>e._surrogate82x82PFrameFrameNumberReset?e._isAndroidChrome?p:e._singleZeroByte.buffer:(e._surrogate82x82PFrameFrameNumber++,o)}return e._singleZeroByte.buffer}},{key:"getSurrogate82x82PFrameAndUpdateFrameNumber",value:function(){var r=(14&e._surrogate82x82PFrameFrameNumber)>>1,t=(1&e._surrogate82x82PFrameFrameNumber)<<7,o=e._dummy82x82H264.PFrame.slice(),n=e._dummy82x82H264PFrameFrameNumberIndex;return o[n]|=r,o[n+1]|=t,e._surrogate82x82PFrameFrameNumber++,o.buffer}}])}();n=b,d()(b,"_isSafari","Safari"===c.browserName),d()(b,"_isMobileChrome","Chrome"===c.browserName&&c.isMobile()),d()(b,"_isAndroidChrome","Chrome"===c.browserName&&c.isAndroid),d()(b,"_singleZeroByte",new Uint8Array([0])),d()(b,"_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])}),d()(b,"_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])}),d()(b,"_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])}),d()(b,"_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(l()(new Uint8Array(40).fill(255)),[95],l()(new Uint8Array(10295).fill(255)),[128,0,0,0,1,101,136,132,5],l()(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(l()(new Uint8Array(40).fill(255)),[164],l()(new Uint8Array(10364).fill(255)),[128,0,0,0,1,65,154,32,21,240,75]))}),d()(b,"_dummy82x82H264PFrameFrameNumberIndex",10418),d()(b,"_surrogate82x82PFrameFrameNumberReset",1),d()(b,"_useUpdateSurrogate82x82PFrameFrameNumber",n._isMobileChrome||n._isSafari),d()(b,"_surrogate82x82PFrameFrameNumber",n._surrogate82x82PFrameFrameNumberReset),self.onmessage=function(e){_.forceInvalidFrame=e.data.forceInvalidFrame},self.RTCTransformEvent&&(self.onrtctransform=function(e){var r=e.transformer;_.codec=r.options.codec,_.transformFunction="video"===r.options.kind?_.videoTransformFunction:_.audioTransformFunction,_.mustSink=r.options.mustSink,_.forceInvalidFrame=!1;var t=new TransformStream({transform:_.transformFunction}),o=r.readable,n=r.writable;o.pipeThrough(t).pipeTo(n)});var _=function(){function e(){throw i()(this,e),new Error("WorkerTransformStream is a static class that may not be instantiated")}return u()(e,null,[{key:"videoTransformFunction",value:function(r,t){if(postMessage({chunk:{type:r.type,timestamp:r.timestamp,data:r.data}}),e.mustSink)if(e.forceInvalidFrame){var o;if(e.forceInvalidFrame=!1,(o="key"===r.type?b.getInvalidSurrogateVideoIFrame(e.codec):b.getInvalidSurrogateVideoPFrame(e.codec))===p)return;r.data=o||r.data}else"key"===r.type?r.data=b.getSurrogateVideoIFramePerCodec(e.codec)||r.data:r.data=b.getSurrogateVideoPFramePerCodec(e.codec)||r.data;t.enqueue(r)}},{key:"audioTransformFunction",value:function(r,t){postMessage({chunk:{timestamp:r.timestamp,data:r.data}}),e.mustSink&&(e.forceInvalidFrame?(e.forceInvalidFrame=!1,r.data=b.getInvalidSurrogateAudioData()):r.data=b.getSurrogateAudioSilentPerCodec(e.codec)||r.data),t.enqueue(r)}}])}();d()(_,"codec",void 0),d()(_,"transformFunction",void 0),d()(_,"mustSink",void 0),d()(_,"forceInvalidFrame",void 0)})()})();\n',"Worker",void 0,void 0)}var tn=function(){return o()((function e(){throw t()(this,e),new Error("InsertableStreams is a static class that may not be instantiated")}),null,[{key:"configureEncodedStreamPipeline",value:function(e,t,n,r,i,o){var a=new ne,s=new _(null),u=new _(null);return e.getTracks().forEach((function(e){var c=t.filter((function(t){return t.track===e}))[0],l=e.kind;switch(l){case"video":var d=!!n;if(P.isRTCRtpScriptTransformSupported){var h=en();h.onmessage=function(){var t=M()(V().mark((function t(r){return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s.value={track:e,chunk:r.data.chunk},t.t0=d,!t.t0){t.next=6;break}return t.next=5,n(e,r.data.chunk);case 5:t.t0=!t.sent;case 6:if(!t.t0){t.next=8;break}h.postMessage({forceInvalidFrame:!0});case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),c.transform=new RTCRtpScriptTransform(h,{kind:e.kind,codec:i,mustSink:d}),a.add(new f((function(){h.terminate()})));break}var p=function(){var t=M()(V().mark((function t(r,o){var a;return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s.value={track:e,chunk:r},!d){t.next=12;break}return t.next=4,n(e,r);case 4:if(t.sent){t.next=11;break}if((a="key"===r.type?$t.getInvalidSurrogateVideoIFrame(i):$t.getInvalidSurrogateVideoPFrame(i))!==Qt){t.next=8;break}return t.abrupt("return");case 8:r.data=a||r.data,t.next=12;break;case 11:"key"===r.type?r.data=$t.getSurrogateVideoIFramePerCodec(i)||r.data:r.data=$t.getSurrogateVideoPFramePerCodec(i)||r.data;case 12:o.enqueue(r);case 13:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),m=new TransformStream({transform:p}),v=c.createEncodedStreams(),g=v.readable,_=v.writable;g.pipeThrough(m).pipeTo(_);break;case"audio":var y=!!r;if(P.isRTCRtpScriptTransformSupported){var b=en();b.onmessage=function(){var t=M()(V().mark((function t(n){return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n.data.chunk},t.t0=y,!t.t0){t.next=6;break}return t.next=5,r(e,n.data.chunk);case 5:t.t0=!t.sent;case 6:if(!t.t0){t.next=8;break}b.postMessage({forceInvalidFrame:!0});case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),c.transform=new RTCRtpScriptTransform(b,{kind:e.kind,codec:o,mustSink:y});var C=new MediaStream,k=new Audio;k.srcObject=C,document.body.appendChild(k),a.add(new f((function(){b.terminate(),document.body.removeChild(k)})));break}var S=function(){var t=M()(V().mark((function t(n,i){return V().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n},!y){t.next=9;break}return t.next=4,r(e,n);case 4:if(t.sent){t.next=8;break}n.data=$t.getInvalidSurrogateAudioData(),t.next=9;break;case 8:n.data=$t.getSurrogateAudioSilentPerCodec(o)||n.data;case 9:i.enqueue(n);case 10:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}(),x=new TransformStream({transform:S}),w=c.createEncodedStreams(),T=w.readable,E=w.writable;T.pipeThrough(x).pipeTo(E);break;default:W(l)}})),{disposables:a,encodedVideoFrame:s,encodedAudioFrame:u}}},{key:"configureInsertableStreamTransformation",value:function(e,t,n){var r=new MediaStream,i=new ne;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 f((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)}}),m=new MediaStreamTrackProcessor({track:h}),v=new MediaStreamTrackGenerator({kind:h.kind}),g=m.readable,_=v.writable;g.pipeThrough(p).pipeTo(_),r.addTrack(v);var y=new MediaStream,b=new Audio;y.addTrack(e),b.srcObject=y,document.body.appendChild(b),i.add(new f((function(){r.removeTrack(v),document.body.removeChild(b)})))}else r.addTrack(e);break;default:W(o)}})),{transformedStream:r,disposables:i}}}])}(),nn=n(981).A;function rn(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 on(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rn(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var an=function(){return o()((function e(n,r,i,o,a){t()(this,e),s()(this,"_logger",X.getLogger("RealTimeStream")),s()(this,"_channelContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_streamTransformContext",void 0),s()(this,"_frameTimingInformationContext",void 0),s()(this,"_handleStreamFailure",void 0),s()(this,"_disposables",void 0),this._channelContext=n,this._peerConnectionContext=r,this._streamTransformContext=i,this._frameTimingInformationContext=o,this._handleStreamFailure=a,this._disposables=new ne,this._channelContext.disposables.add(this)}),[{key:"start",value:function(e,t,n,r){var i=this,o=this._streamTransformContext.hasEncodedInsertableStreams.value||this._frameTimingInformationContext.shouldExtractTimecode.value||this._frameTimingInformationContext.shouldExtractTimestamps.value;return nn.all([nt.discoverClosestEndPointWithCaching(e),ce.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=yt()(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),!P.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration?r.subscribe(t,a,i._channelContext.failureCount.value):(s.close(),s.dispose(),!Ee.forceGarbageCollectionOnRestart||P.isMobile&&Ee.skipGarbageCollectionOnMobileDevices||Ie.forceGarbageCollection(),i._peerConnectionContext.peerConnection.value=null,r.subscribe(t,null,i._channelContext.failureCount.value))})).then((function(e){var t=e.status;if(i._channelContext.state.value=i._channelContext.mapSubscribeStatusToChannelStatus(t),i._channelContext.applyStatus(t),"ok"!==t)return i._channelContext.stream.value=null,i._channelContext.lag.value=void 0,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),void i._logger.info("[%s] Subscribe failed with status [%s]",i._channelContext.streamId,t);var a=e.stream,s=e.rtcConfiguration,u=e.setRemoteDescriptionResponse,c=e.createOfferDescriptionResponse,l=e.createAnswerDescriptionResponse,d=e.lag;return i._channelContext.stream.value=a,i._channelContext.lag.value=d,i._channelContext.applySessionAndStreamPropertiesToVideoElement(),i._logger.debug("[%s] Subscribe completed [%s] [%j] [%j] [%j] [%j]",i._channelContext.streamId,t,s,u,c,l),i.applyRtcConfiguration(i._peerConnectionContext.peerConnection.value,s).then((function(e){var t,s=!1,d=!1,h=[];i._peerConnectionContext.peerConnection.value||(i._peerConnectionContext.peerConnection.value=e),e.onicecandidate=function(n){i._channelContext.stream.value===a&&i._peerConnectionContext.peerConnection.value===e&&(s||Ee.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?h.push(n.candidate):d=!0,t||(t=w.value.setTimeout((function(){var e;i._channelContext.stream.value!==a||s||null===(e=i._channelContext.endPoint.value)||void 0===e||e.addIceCandidates(a,h,d).then((function(e){var t=e.status,n=e.options;"ok"===t?(null!=n&&n.includes("cancel")&&(s=!0),i._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",i._channelContext.streamId,t,n)):i._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",i._channelContext.streamId,t)})).catch((function(e){i._logger.error("[%s] Failed to add ICE candidates",i._channelContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(i._channelContext.stream.value===a&&i._peerConnectionContext.peerConnection.value===e){var t=function(){i._channelContext.state.value=De.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(w.value.navigatorIsOnLine&&(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:W(e.iceConnectionState)}}};var p=new nn((function(t,n){if(!P.onTrackDisabled){var r=w.value.setTimeout((function(){return n(new Error("Stream setup timed out"))}),3e4);return i._disposables.add(new f((function(){return w.value.clearTimeout(r)}))),void(e.ontrack=function(e){w.value.clearTimeout(r),t(e.streams[0])})}var o=function(n){w.value.clearTimeout(a),e.removeEventListener("track",o),e.removeEventListener("addstream",o),t("streams"in n?n.streams[0]:n.stream)},a=w.value.setTimeout((function(){e.removeEventListener("track",o),e.removeEventListener("addstream",o),n(new Error("Stream setup timed out"))}),3e4);e.addEventListener("track",o),e.addEventListener("addstream",o),i._disposables.add(new f((function(){return w.value.clearTimeout(a)})))}));return new nn((function(e){e()})).then((function(){if(u)return i._logger.info("[%s] Set local SDP offer [%s]",i._channelContext.streamId,u.sessionDescription.sdp),e.setLocalDescription(u.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,u.sessionDescription,e.message),e}))})).then((function(){if(l)return i._logger.info("[%s] Set remote SDP answer [%s]",i._channelContext.streamId,l.sessionDescription.sdp),e.setRemoteDescription(l.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,l.sessionDescription,e.message),e}))})).then((function(){if(c)return i._logger.info("[%s] Set remote SDP offer [%s]",i._channelContext.streamId,c.sessionDescription.sdp),e.setRemoteDescription(c.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,c.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})})).then((function(e){return i._logger.info("[%s] Set local SDP answer [%j]",i._channelContext.streamId,e),i._channelContext.endPoint.value.setRemoteDescription(a,e)})).then((function(t){var n=t.status,r=t.sessionDescription;return i._channelContext.state.value=i.mapSetRemoteDescriptionStatusToChannelStatus(n),"ok"!==n?(i._channelContext.playing.value=!1,i._channelContext.standby.value=!0,void(i._channelContext.stopped.value=!1)):e.setLocalDescription(r).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,r,e.message),e}))}))})).then((function(){return n.success(i._channelContext.streamId),p})).then((function(t){var n,a;if(o&&null!=e&&null!==(n=e.currentRemoteDescription)&&void 0!==n&&n.sdp){var s=new bt(e.currentRemoteDescription.sdp),u=e.getReceivers(),c=tn.configureEncodedStreamPipeline(t,u,i._streamTransformContext.encodedVideoStreamSink,i._streamTransformContext.encodedAudioStreamSink,s.videoCodec,s.audioCodec),l=c.disposables,d=c.encodedVideoFrame;if("H264"===s.videoCodec.toUpperCase()&&(i._frameTimingInformationContext.shouldExtractTimecode.value||i._frameTimingInformationContext.shouldExtractTimestamps.value)){var h=new Zt(i._channelContext,i._frameTimingInformationContext);i._disposables.add(h),t.getVideoTracks().forEach((function(t){var n,r=u.filter((function(e){return e.track===t}))[0],o=e.supportsGetTransceivers?null===(n=e.getTransceivers().filter((function(e){return e.receiver===r}))[0])||void 0===n?void 0:n.mid:null;r?o?(i._disposables.add(d.subscribe((function(e){e&&h.processFrame(i._channelContext.streamId,o,e.track.id,e.chunk)}))),i._frameTimingInformationContext.isEnabled.value=!0):i._logger.warn("[%s] Skipping frame timing information for track [%s] because no mid was found",i._channelContext.streamId,t.id):i._logger.warn("[%s] Skipping frame timing information for track [%s] because no receiver was found",i._channelContext.streamId,t.id)}))}i._disposables.add(l)}if(i._streamTransformContext.hasInsertableStreams.value){var p=tn.configureInsertableStreamTransformation(t,i._streamTransformContext.videoStreamTransformCallback,i._streamTransformContext.audioStreamTransformCallback),f=p.transformedStream,m=p.disposables;i._disposables.add(m),t=f}i._peerConnectionContext.mediaStream.value=t;var v=new kt(e,t,null!==(a=i._channelContext.endPoint.value)&&void 0!==a&&a.roundTripTime?i._channelContext.endPoint.value.roundTripTime/4:0);i._disposables.add(v);var g=v.rtcStatistic.subscribe((function(t){if(i._channelContext.rtcStatistics.value=t,t){if(!i._channelContext.rtcVideoStatistic&&!i._channelContext.rtcAudioStatistic)return i._channelContext.rtcAudioStatistic=t.audio,void(i._channelContext.rtcVideoStatistic=t.video);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)&&w.value.navigatorIsOnLine&&i._logger.info("[%s] Audio track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.audio.bytesReceived,i._channelContext.rtcAudioStatistic.bytesReceived,new Oe(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)&&w.value.navigatorIsOnLine&&i._logger.info("[%s] Video track failed with last bytesReceived [%s] is equal to previous bytesReceived [%s] within [%s]",i._channelContext.streamId,t.video.bytesReceived,i._channelContext.rtcVideoStatistic.bytesReceived,new Oe(t.video.timestamp-i._channelContext.rtcVideoStatistic.timestamp).toIsoString()),i._channelContext.rtcVideoStatistic=t.video),w.value.navigatorIsOnLine)if(r||n)i.reconnectPeerConnection(e,(function(){i._channelContext.state.value=De.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,v.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!==De.Reconnecting&&i._channelContext.state.value!==De.Offline)return;i._channelContext.state.value=i._channelContext.playing.value?De.Playing:De.Paused,i._logger.info("Channel state restored to [%s] after reconnecting",De[i._channelContext.state.value])}else i._channelContext.state.value=De.Offline}}));return i._disposables.add(g),Ee.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=De.Paused))}))}))}))}},{key:"applyRtcConfiguration",value:(e=M()(V().mark((function e(t,n){var r;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=Ct.truncateIceServers(n),e.abrupt("return",Ee.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=on(on({},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=De.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Ee.maximalNumberOfPeerConnectionReconnectAttempts||!Ee.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(P.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 De.Starting;case"unauthorized":return De.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return De.Recovering;case"failed":return De.Error;default:W(e)}}}]);var e}(),sn=function(){return o()((function e(){throw t()(this,e),new Error("StreamFactory is a static class that may not be instantiated")}),null,[{key:"create",value:function(e,t,n,r,i,o){var a=te.parseToken(e).capabilities,s=a.includes("streaming"),u=a.includes("on-demand");return s||u?new gt(t,u?vt.OndDemand:vt.Live,o):new an(t,n,r,i,o)}}])}(),un=n(981).A,cn=function(){return o()((function e(n,r,i){var o=this;t()(this,e),s()(this,"_logger",X.getLogger("Channel")),s()(this,"_tokenContext",void 0),s()(this,"_channelContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_streamTransformContext",void 0),s()(this,"_stateContext",void 0),s()(this,"_frameTimingInformationContext",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_channelStartTime",void 0),s()(this,"_readOnlyPeerConnection",void 0),s()(this,"_readOnlyState",void 0),s()(this,"_readOnlyAutoMuted",void 0),s()(this,"_readOnlyAutoPaused",void 0),s()(this,"_readOnlyTokenExpiring",void 0),s()(this,"_readOnlyAuthorized",void 0),s()(this,"_readOnlyOnline",void 0),s()(this,"_readOnlyLoading",void 0),s()(this,"_readOnlyPlaying",void 0),s()(this,"_readOnlyStandby",void 0),s()(this,"_readOnlyStopped",void 0),s()(this,"_readOnlyTargetLag",void 0),s()(this,"_readOnlyLag",void 0),s()(this,"_readOnlyBitrateLimit",void 0),s()(this,"_readOnlyResolution",void 0),s()(this,"_readOnlyFailureCount",void 0),s()(this,"_readOnlyEndPoint",void 0),s()(this,"_readOnlyStream",void 0),s()(this,"_readOnlyRtcStatistics",void 0),s()(this,"_readOnlyMediaStream",void 0),s()(this,"_readOnlyIsFrameTimingInformationEnabled",void 0),s()(this,"_readOnlyDecodedFrameTimingInformation",void 0),s()(this,"_readOnlyRenderedFrameTimingInformation",void 0),s()(this,"_metricsService",void 0),s()(this,"_sessionTelemetry",void 0),s()(this,"_videoMetaDataChangedHandler",void 0);var a=te.parseToken(r),u={targetLag:null==i?void 0:i.targetLag},c={hasInsertableStreams:a.capabilities.includes("insertable-streams"),hasEncodedInsertableStreams:a.capabilities.includes("encoded-insertable-streams"),videoStreamTransformCallback:null==i?void 0:i.videoStreamTransformCallback,audioStreamTransformCallback:null==i?void 0:i.audioStreamTransformCallback,encodedVideoStreamSink:null==i?void 0:i.encodedVideoStreamSink,encodedAudioStreamSink:null==i?void 0:i.encodedAudioStreamSink};this._tokenContext=new je(r),this._channelContext=new ze(u),this._peerConnectionContext=new qe,this._streamTransformContext=new We(c),this._stateContext=new Je,this._exponentialBackoff=new be,this._channelStartTime=Date.now(),this._readOnlyPeerConnection=new y(this._peerConnectionContext.peerConnection),this._readOnlyState=new y(this._channelContext.state),this._readOnlyAutoMuted=new y(this._channelContext.autoMuted),this._readOnlyAutoPaused=new y(this._channelContext.autoPaused),this._readOnlyTokenExpiring=new y(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new y(this._channelContext.authorized),this._readOnlyOnline=new y(this._channelContext.online),this._readOnlyLoading=new y(this._channelContext.loading),this._readOnlyPlaying=new y(this._channelContext.playing),this._readOnlyStandby=new y(this._channelContext.standby),this._readOnlyStopped=new y(this._channelContext.stopped),this._readOnlyTargetLag=new y(this._channelContext.targetLag),this._readOnlyLag=new y(this._channelContext.lag),this._readOnlyBitrateLimit=new y(this._channelContext.bitrateLimit),this._readOnlyResolution=new y(this._channelContext.resolution),this._readOnlyFailureCount=new y(this._channelContext.failureCount),this._readOnlyEndPoint=new y(this._channelContext.endPoint),this._readOnlyStream=new y(this._channelContext.stream),this._readOnlyRtcStatistics=new y(this._channelContext.rtcStatistics),this._readOnlyMediaStream=new y(this._peerConnectionContext.mediaStream);var l=(a.uri||Ee.discoveryUri.value).toString();Ee.tenancy.value=a.tenancy||Ee.tenancy.value,pe.uri.value=l,this._metricsService=Te.getMetricsService(l),this._sessionTelemetry=new Ve(Ee.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=n,this._frameTimingInformationContext=new Ke,this.configureFrameTimingInformation(a),this._readOnlyIsFrameTimingInformationEnabled=new y(this._frameTimingInformationContext.isEnabled),this._readOnlyDecodedFrameTimingInformation=new y(this._frameTimingInformationContext.decodedFrameTimingInformation),this._readOnlyRenderedFrameTimingInformation=new y(this._frameTimingInformationContext.renderedFrameTimingInformation),this._channelContext.channelDisposables.add(this._channelContext.videoElement.subscribe((function(e){o._channelContext.rendererDisposables.dispose(),e&&(o._channelContext.rendererDisposables.add(o._channelContext.stream.subscribe((function(e){o._channelContext.videoTelemetry&&o._channelContext.videoTelemetry.dispose(),e&&o.videoElement&&(o.videoElement.dataset&&(o.videoElement.dataset.sessionId=Ee.clientSessionId,o.videoElement.dataset.streamId=o.streamId),o._channelContext.videoTelemetry=new Ae(o.streamId,Ee.pageLoadTime,o._channelStartTime,o._metricsService),o._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(o.videoElement),o._channelContext.videoTelemetry.setupListenerForRebuffering(o.videoElement),o._channelContext.state.value===De.Stopped)&&o.restartAfterStop()}))),o._channelContext.channelDisposables.add(o._channelContext.rendererDisposables))}))),this._channelContext.channelDisposables.add(this._channelContext.state.subscribe((function(e){o._channelContext.clearFailureCountTimeout&&w.value.clearTimeout(o._channelContext.clearFailureCountTimeout),o._channelContext.failureCount.value&&e===De.Playing&&(o._channelContext.clearFailureCountTimeout=w.value.setTimeout((function(){o._channelContext.failureCount.value=0}),3e3))}))),this._channelContext.channelDisposables.add(this._channelContext.resolution.subscribe((function(e){o._channelContext.videoTelemetry&&o._channelContext.videoTelemetry.onVideoResolutionChanges(e.toString())}))),this._channelContext.channelDisposables.add(this._channelContext.bitrateLimit.subscribe((function(e){if(e&&o._channelContext.endPoint.value&&o._channelContext.stream.value){var t=Date.now()-o._channelContext.channelInitialization.getTime();o._channelContext.endPoint.value.limitBitrate(o._channelContext.stream.value,t,e,Ue.Keep,Be.Normal).catch((function(e){o._logger.error("Error while setting limit bitrate",e)}))}})));var d=function(){o._channelContext.stream.value&&o._channelContext.endPoint.value&&o._channelContext.endPoint.value.destroyStreamOnUnmount(o._channelContext.stream.value,"client:termination-on-window-unload")};w.value.addWindowEventListener("beforeunload",d),this._channelContext.channelDisposables.add(new f((function(){w.value.removeWindowEventListener("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!==De.Initializing&&(this._channelContext.state.value=De.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 Fe(e.videoWidth,e.videoHeight)):this._channelContext.resolution.value=Fe.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=te.parseToken(this._tokenContext.token.value),n=(t.uri||Ee.discoveryUri.value).toString();Ee.tenancy.value=t.tenancy||Ee.tenancy.value,pe.uri.value=n,this._metricsService=Te.getMetricsService(n),this._streamTransformContext.hasInsertableStreams.value=t.capabilities.includes("insertable-streams"),this._streamTransformContext.hasEncodedInsertableStreams.value=t.capabilities.includes("encoded-insertable-streams"),this.configureFrameTimingInformation(t),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"autoMuted",get:function(){return this._readOnlyAutoMuted}},{key:"autoPaused",get:function(){return this._readOnlyAutoPaused}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"playing",get:function(){return this._readOnlyPlaying}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"targetLag",get:function(){return this._readOnlyTargetLag}},{key:"lag",get:function(){return this._readOnlyLag}},{key:"bitrateLimit",get:function(){return this._readOnlyBitrateLimit.value}},{key:"resolution",get:function(){return this._readOnlyResolution}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._channelContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"isFrameTimingInformationEnabled",get:function(){return this._readOnlyIsFrameTimingInformationEnabled}},{key:"decodedFrameTimingInformation",get:function(){return this._readOnlyDecodedFrameTimingInformation}},{key:"renderedFrameTimingInformation",get:function(){return this._readOnlyRenderedFrameTimingInformation}},{key:"setBitrateLimit",value:function(e){this._channelContext.bitrateLimit.value=e}},{key:"clearBitrateLimit",value:function(){var e=this;if(this._channelContext.bitrateLimit.value&&this._channelContext.endPoint.value&&this._channelContext.stream.value){var t=Date.now()-this._channelContext.channelInitialization.getTime();this._channelContext.endPoint.value.limitBitrate(this._channelContext.stream.value,t,0,Ue.Keep,Be.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=M()(V().mark((function e(t){var n=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new un((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=De.Stopped}},{key:"resume",value:(l=M()(V().mark((function e(){return V().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 l.apply(this,arguments)})},{key:"mute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!0)}},{key:"unmute",value:function(){var e=this._channelContext.videoElement.value;e&&(e.muted=!1,this._channelContext.autoMuted.value=!1)}},{key:"dispose",value:(c=M()(V().mark((function e(){var t=this;return V().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 c.apply(this,arguments)})},{key:"getUri",value:function(e){return te.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",Ee.discoveryUri.value),new w.value.URL(Ee.discoveryUri.value))}},{key:"start",value:(u=M()(V().mark((function e(){return V().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 u.apply(this,arguments)})},{key:"processStart",value:(a=M()(V().mark((function e(){var t,n,r,i,o,a,s,u,c,l,d,h,p,m,v,g,_,y,b,C=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._channelContext.state.value=De.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),te.isEncodedEdgeTokenValid(t)){e.next=10;break}return this._logger.error("Failed to parse token [%s]",t),this._channelContext.state.value=De.Unauthorized,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 10:if(!this._streamTransformContext.videoStreamTransformCallback){e.next=18;break}if(r=Ge.validateMediaStreamTrackTransform("video",this._streamTransformContext.videoStreamTransformCallback),i=r.valid,o=r.validationResult,i){e.next=18;break}return this._logger.error(o),this._channelContext.state.value=De.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 18:if(!this._streamTransformContext.audioStreamTransformCallback){e.next=26;break}if(a=Ge.validateMediaStreamTrackTransform("audio",this._streamTransformContext.audioStreamTransformCallback),s=a.valid,u=a.validationResult,s){e.next=26;break}return this._logger.error(u),this._channelContext.state.value=De.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 26:if(!this._streamTransformContext.encodedVideoStreamSink){e.next=34;break}if(c=He.validateEncodedStreamSink("video",this._streamTransformContext.encodedVideoStreamSink),l=c.valid,d=c.validationResult,l){e.next=34;break}return this._logger.error(d),this._channelContext.state.value=De.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 34:if(!this._streamTransformContext.encodedAudioStreamSink){e.next=42;break}if(h=He.validateEncodedStreamSink("audio",this._streamTransformContext.encodedAudioStreamSink),p=h.valid,m=h.validationResult,p){e.next=42;break}return this._logger.error(m),this._channelContext.state.value=De.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 42:if(!this._streamTransformContext.hasInsertableStreams.value||!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=48;break}return this._logger.error("Both insertable-streams and encoded-insertable-streams are enabled, only use one or the other"),this._channelContext.state.value=De.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 48:if(v="function"==typeof this._streamTransformContext.videoStreamTransformCallback||"function"==typeof this._streamTransformContext.audioStreamTransformCallback,g="function"==typeof this._streamTransformContext.encodedVideoStreamSink||"function"==typeof this._streamTransformContext.encodedAudioStreamSink,!v||!g){e.next=56;break}return this._logger.error("Both Media Stream Track transform callback and encodedInsertableStreams sink function found, only use one type or the other"),this._channelContext.state.value=De.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 56:if(!this._streamTransformContext.hasInsertableStreams.value){e.next=71;break}if(P.isInsertableStreamsSupported){e.next=63;break}return this._logger.error("Browser does not support Media Stream Track API"),this._channelContext.state.value=De.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 63:if(v){e.next=69;break}return this._logger.error("CreateChannelOptions transform callback function is missing; however, insertable-streams is enabled"),this._channelContext.state.value=De.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 69:e.next=77;break;case 71:if(!v){e.next=77;break}return this._logger.error("CreateChannelOptions transform callback function found; however, insertable-streams is not enabled"),this._channelContext.state.value=De.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 77:if(!this._streamTransformContext.hasEncodedInsertableStreams.value){e.next=92;break}if(P.isEncodedInsertableStreamsSupported||P.isRTCRtpScriptTransformSupported){e.next=84;break}return this._logger.error("Browser does not support encodedInsertableStreams API"),this._channelContext.state.value=De.UnsupportedFeature,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 84:if(g){e.next=90;break}return this._logger.error("CreateChannelOptions transform sink function is missing; however, encoded-insertable-streams is enabled"),this._channelContext.state.value=De.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 90:e.next=98;break;case 92:if(!g){e.next=98;break}return this._logger.error("CreateChannelOptions transform sink function found; however, encoded-insertable-streams is not enabled"),this._channelContext.state.value=De.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 98:if(this._channelContext.loading.value=!0,_=this.getUri(t),this._channelContext.disposables.add(this._channelContext.state.subscribe((function(e){e!==De.Error&&e!==De.Recovering||nt.clearCachedClosestEndpoint(_)}))),y=function(){return new un((function(e){return C._stateContext.isStarting.value=!1,e(C.handleStreamFailure())}))},b=sn.create(t,this._channelContext,this._peerConnectionContext,this._streamTransformContext,this._frameTimingInformationContext,y)){e.next=106;break}return this._stateContext.isStarting.value=!1,e.abrupt("return");case 106:return e.abrupt("return",b.start(_,t,n,this.playMediaStreamInVideoElement.bind(this)).then((function(){C._channelContext.loading.value=!1})).catch((function(e){n.fail(),C._channelContext.failureCount.value++,C._channelContext.online.value=!1,C.cleanUpResources("client:cleanup-after-failed-setup"),C._channelContext.state.value=De.ClientStartError,C._logger.error("Failed to start channel",e)})).finally((function(){if(C._stateContext.isStarting.value=!1,C._channelContext.state.value!==De.Playing&&Ee.automaticRetryOnFailure){var e=w.value.setTimeout((function(){C.handleStreamFailure().catch((function(e){C._logger.error("Failed handling stream failure",e)}))}),C.getRetryInterval());C._channelContext.disposables.add(new f((function(){w.value.clearTimeout(e)})))}})));case 107:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"restartAfterStop",value:(i=M()(V().mark((function e(){return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._peerConnectionContext.mediaStream.value){e.next=4;break}return e.abrupt("return",this.playMediaStreamInVideoElement(this._peerConnectionContext.mediaStream.value));case 4:this._tokenContext.token.value&&this.start();case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"play",value:(r=M()(V().mark((function e(){var t;return V().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 r.apply(this,arguments)})},{key:"getRetryInterval",value:function(){switch(this._channelContext.state.value){case De.Initializing:case De.StandBy:case De.Offline:return 15e3;case De.Error:case De.Recovering:case De.Unauthorized:case De.GeoRestricted:case De.GeoBlocked:case De.Stopped:case De.Starting:case De.Playing:case De.Paused:case De.Reconnecting:case De.UnsupportedFeature:case De.ConfigurationError:case De.TransientConfigurationError:case De.ConnectionError:case De.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._channelContext.failureCount.value);default:W(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(n=M()(V().mark((function e(){return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._channelContext.state.value,e.next=e.t0===De.Error||e.t0===De.Reconnecting||e.t0===De.StandBy||e.t0===De.Offline||e.t0===De.Recovering||e.t0===De.TransientConfigurationError||e.t0===De.ConnectionError||e.t0===De.ClientStartError?3:e.t0===De.Unauthorized?5:e.t0===De.GeoRestricted?7:e.t0===De.GeoBlocked?9:e.t0===De.Stopped?11:e.t0===De.Initializing?13:e.t0===De.Playing?15:e.t0===De.Paused?17:e.t0===De.Starting?19:e.t0===De.UnsupportedFeature?21:e.t0===De.ConfigurationError?23:25;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,De[this._channelContext.state.value]),e.abrupt("break",26);case 5:return this._logger.info("Channel is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 7:return this._logger.info("Channel is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 9:return this._logger.info("Channel is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 11:return this._logger.info("Channel is stopped, skipping retry of start."),e.abrupt("return");case 13:return this._logger.info("Channel is already initializing, skipping retry of start"),e.abrupt("return");case 15:return this._logger.info("Channel is playing, skipping retry of start"),e.abrupt("return");case 17:return this._logger.info("Channel is paused, skipping retry of start. Please invoke play()"),e.abrupt("return");case 19:return this._logger.info("Channel is already starting, skipping retry of start"),e.abrupt("return");case 21:return this._logger.info("Channel is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 23:return this._logger.info("Channel is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 25:W(this._channelContext.state.value);case 26:return e.abrupt("return",this.start());case 27:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._channelContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!Ee.forceGarbageCollectionOnRestart||P.isMobile&&Ee.skipGarbageCollectionOnMobileDevices||Ie.forceGarbageCollection()),this._peerConnectionContext.mediaStream.value&&(this._peerConnectionContext.mediaStream.value.getTracks().forEach((function(e){return e.stop()})),this._peerConnectionContext.mediaStream.value=null),this._channelContext.autoPaused.value=!1,this._channelContext.autoMuted.value=!1,this._channelContext.playing.value=!1,this._channelContext.stopped.value=!0,this._channelContext.standby.value=!1,this._channelContext.stream.value&&this._channelContext.endPoint.value&&this._channelContext.endPoint.value.destroyStream(this._channelContext.stream.value,t).then((function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)})).catch((function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)})),this.videoElement&&this.videoElement.dataset&&(this.videoElement.dataset.sessionId="",this.videoElement.dataset.streamId=""),this._channelContext.stream.value=null,this._channelContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}},{key:"configureFrameTimingInformation",value:function(e){var t=this,n=e.capabilities.find((function(e){return e.startsWith("frame-timing-information=")}));this._frameTimingInformationContext.shouldExtractTimecode.value=!1,this._frameTimingInformationContext.shouldExtractTimestamps.value=!1,this._frameTimingInformationContext.isEnabled.value=!1,n?P.isChannelFrameTimingInformationSupported?(n.split("=")[1].split(",").map((function(e){return e.trim()})).forEach((function(e){switch(e){case"timecode":t._frameTimingInformationContext.shouldExtractTimecode.value=!0;break;case"timestamps":t._frameTimingInformationContext.shouldExtractTimestamps.value=!0;break;default:t._logger.info("Ignoring unknown frame timing information option [%s]",e)}})),this._logger.info("Frame timing information configuration [(timecode [%s], timestamps [%s])]",this._frameTimingInformationContext.shouldExtractTimecode.value,this._frameTimingInformationContext.shouldExtractTimestamps.value)):this._logger.info("Disabling frame timing information as the environment does not support it [%s]",n):this._logger.info("Disabling frame timing information as no capability was found")}},{key:"playMediaStreamInVideoElement",value:(e=M()(V().mark((function e(t){var n,r,i=this;return V().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=De.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=De.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=De.Playing})).catch((function(e){var r=!!t.getTracks().filter((function(e){return"audio"===e.kind})).length,o=!Ee.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=De.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=De.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=De.Paused})))})));case 18:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})}]);var e,n,r,i,a,u,c,l,d}(),ln=function(){return o()((function e(){throw t()(this,e),new Error("Channels is a static class that may not be instantiated")}),null,[{key:"createChannel",value:function(e){if(!Ee.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 cn(e.videoElement,e.token,t)}},{key:"isFrameTimingInformationSupported",get:function(){return P.isChannelFrameTimingInformationSupported}}])}(),dn=function(e){return e[e.Initializing=0]="Initializing",e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Publishing=3]="Publishing",e[e.Recovering=4]="Recovering",e[e.Reconnecting=5]="Reconnecting",e[e.Stopped=6]="Stopped",e[e.Unauthorized=7]="Unauthorized",e[e.GeoRestricted=8]="GeoRestricted",e[e.GeoBlocked=9]="GeoBlocked",e[e.UnsupportedFeature=10]="UnsupportedFeature",e[e.NotFound=11]="NotFound",e[e.ConfigurationError=12]="ConfigurationError",e[e.TransientConfigurationError=13]="TransientConfigurationError",e[e.ConnectionError=14]="ConnectionError",e[e.ClientStartError=15]="ClientStartError",e[e.Error=16]="Error",e}(dn||{}),hn=dn,pn=function(){return o()((function e(n){t()(this,e),s()(this,"publisherInitialization",void 0),s()(this,"disposables",void 0),s()(this,"publisherDisposables",void 0),s()(this,"state",void 0),s()(this,"authorized",void 0),s()(this,"online",void 0),s()(this,"loading",void 0),s()(this,"publishing",void 0),s()(this,"standby",void 0),s()(this,"stopped",void 0),s()(this,"failureCount",void 0),s()(this,"endPoint",void 0),s()(this,"stream",void 0),s()(this,"rtcStatistics",void 0),s()(this,"clearFailureCountTimeout",void 0),s()(this,"startReconnectionAttemptsTimeInMilliseconds",void 0),s()(this,"name",void 0),this.disposables=new ne,this.publisherDisposables=new ne,this.publisherInitialization=new Date,this.state=new _(hn.Initializing),this.authorized=new _(!0),this.online=new _(!0),this.loading=new _(!1),this.publishing=new _(!1),this.standby=new _(!1),this.stopped=new _(!1),this.failureCount=new _(0),this.endPoint=new _(null),this.stream=new _(null),this.rtcStatistics=new _(null),this.clearFailureCountTimeout=0,this.name=n&&n.length?n:this.generateScreenName(),this.startReconnectionAttemptsTimeInMilliseconds=0}),[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":return this.authorized.value=!1,this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);case"not-found":return this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null)}}},{key:"mapPublishStatusToPublisherStatus",value:function(e){switch(e){case"ok":return hn.Starting;case"not-found":return hn.NotFound;case"geo-restricted":return hn.GeoRestricted;case"geo-blocked":return hn.GeoBlocked;case"unauthorized":return hn.Unauthorized;case"capacity":case"rate-limited":case"timeout":return hn.Recovering;case"missing-channel-or-room-id":case"forbidden-tag":return hn.ConfigurationError;case"port-in-range-not-found":return hn.TransientConfigurationError;case"failed":return hn.Error;default:W(e)}}},{key:"generateScreenName",value:function(){return Y.random(12)}}])}(),fn=function(){return o()((function e(n,r){var i,o,a,u;if(t()(this,e),s()(this,"_estimatedRoundTripTime",void 0),s()(this,"_estimatedVideoCodec","unknown"),s()(this,"_estimatedAudioCodec","unknown"),s()(this,"_rtcStatistic",new _({})),s()(this,"_peerConnection",void 0),s()(this,"_isMonitorRunning",!0),s()(this,"_updateTimeout",null),s()(this,"_availableTracks",null),this._peerConnection=n,this._estimatedRoundTripTime=r,this._peerConnection&&null!==(i=this._peerConnection)&&void 0!==i&&null!==(o=i.currentLocalDescription)&&void 0!==o&&o.sdp&&null!==(a=this._peerConnection)&&void 0!==a&&null!==(u=a.currentRemoteDescription)&&void 0!==u&&u.sdp){var c=new bt(this._peerConnection.currentLocalDescription.sdp),l=new bt(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=l.audioCodec,this._estimatedVideoCodec=l.videoCodec,this._availableTracks={audio:c.isAudioTrackEnabled&&l.isAudioTrackEnabled,video:c.isVideoTrackEnabled&&l.isVideoTrackEnabled},this.updateStatistic()}}),[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeout&&(w.value.clearTimeout(this._updateTimeout),this._updateTimeout=null)}},{key:"updateStatistic",value:(e=M()(V().mark((function e(){var t,n,r=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!P.getStatsPromiseBasedDisabled){e.next=3;break}return e.abrupt("return");case 3:return n=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=6,null===(t=this._peerConnection)||void 0===t?void 0:t.getStats(null).then((function(e){var t={};if(e){var i,o=r._estimatedRoundTripTime;e.forEach((function(a){if("candidate-pair"===a.type&&a.currentRoundTripTime&&(o=1e3*a.currentRoundTripTime,t.audio&&(t.audio.roundTripTime=o),t.video&&(t.video.roundTripTime=o)),"candidate-pair"===a.type&&a.lastPacketSentTimestamp&&(i=a.lastPacketSentTimestamp,t.audio&&(t.audio.lastPacketSentTimestamp=i),t.video&&(t.video.lastPacketSentTimestamp=i)),"outbound-rtp"===a.type){var s,u=a.kind||a.mediaType||n(a),c="";if(e.forEach((function(e){e.id===a.codecId&&(c=e.mimeType)})),u&&null!==(s=r._availableTracks)&&void 0!==s&&s[u]){var l,d,h,p,f,m,v,g=(a.bytesSent||0)-(null!==(l=null===(d=r._rtcStatistic.value)||void 0===d||null===(h=d[u])||void 0===h?void 0:h.bytesSent)&&void 0!==l?l:0),_=a.timestamp-(null===(p=r._rtcStatistic.value)||void 0===p||null===(f=p[u])||void 0===f?void 0:f.timestamp),y=g&&_?Math.floor(8*g/_*1e3):0;if(t[u]={ssrc:a.ssrc,mediaType:u,timestamp:a.timestamp,bitrate:y,bytesSent:a.bytesSent,packetsSent:a.packetsSent,retransmittedBytesSent:a.retransmittedBytesSent,codec:c||r.getCodecByType(u),roundTripTime:o},(a.lastPacketSentTimestamp||i)&&(t[u].lastPacketSentTimestamp=a.lastPacketSentTimestamp||i),"video"===u&&(t[u].firCount=a.firCount,t[u].frameHeight=a.frameHeight,t[u].frameWidth=a.frameWidth,t[u].framesEncoded=a.framesEncoded,t[u].framesSent=a.framesSent,t[u].headerBytesSent=a.headerBytesSent,t[u].hugeFramesSent=a.hugeFramesSent,t[u].pliCount=a.pliCount,t[u].qpSum=a.qpSum,t[u].totalEncodeTime=a.totalEncodeTime,t[u].totalEncodedBytesTarget=a.totalEncodedBytesTarget,null!==(m=r._rtcStatistic.value)&&void 0!==m&&null!==(v=m.video)&&void 0!==v&&v.framesEncoded)){var b=(a.framesEncoded-r._rtcStatistic.value.video.framesEncoded)/(t[u].timestamp-r._rtcStatistic.value.video.timestamp)*1e3;t[u].fps=b?Math.round(100*b)/100:0}}}}))}r._rtcStatistic.value=t})).then((function(){r._isMonitorRunning&&(r._updateTimeout=w.value.setTimeout((function(){return r.updateStatistic()}),1e3))}));case 6:e.sent;case 7:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec||"unknown";case"video":return this._estimatedVideoCodec||"unknown";default:return"unknown"}}}]);var e}(),mn=n(981).A;function vn(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 gn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vn(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var _n=function(){return o()((function e(n,r,i){t()(this,e),s()(this,"_logger",X.getLogger("RealTimePublisher")),s()(this,"_publisherContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_handleStreamFailure",void 0),this._publisherContext=n,this._peerConnectionContext=r,this._handleStreamFailure=i}),[{key:"start",value:function(e,t,n){var r=this;return w.value.navigatorIsOnLine?mn.all([nt.discoverClosestEndPointWithCaching(e),ce.createPeerConnectionOffer("sendonly").then((function(e){var t=e.localOffer,n=e.peerConnection;return r._peerConnectionContext.peerConnection.value=n,{localOffer:t,peerConnection:n}}))]).then((function(e){var n=yt()(e,2),i=n[0],o=n[1],a=o.localOffer,s=o.peerConnection;return r._publisherContext.online.value=!0,r._publisherContext.endPoint.value=i,r._logger.info("Connecting to [%s]",i.toString()),r._logger.info("Local offer:\n"+a.sdp),P.clientOfferDisabled||!s.supportsSetConfiguration||!s.supportsGetConfiguration||r._publisherContext.failureCount.value>0?(s.close(),s.dispose(),!Ee.forceGarbageCollectionOnRestart||P.isMobile&&Ee.skipGarbageCollectionOnMobileDevices||Ie.forceGarbageCollection(),r._peerConnectionContext.peerConnection.value=null,i.publish(r._publisherContext.name,t,null,r._publisherContext.failureCount.value)):i.publish(r._publisherContext.name,t,a,r._publisherContext.failureCount.value)})).then((function(e){var t=e.status;if(r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyStatus(t),"ok"!==t)return r._publisherContext.stream.value=null,void r._logger.info("[%s] Publish failed with status [%s]",r._publisherContext.streamId,t);var i=e.stream,o=e.rtcConfiguration,a=e.setRemoteDescriptionResponse,s=e.createOfferDescriptionResponse,u=e.createAnswerDescriptionResponse;return r._publisherContext.stream.value=i,r._logger.debug("[%s] Publish completed [%s] [%j] [%j] [%j] [%j]",r._publisherContext.streamId,t,o,a,s,u),r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyStatus(t),r.applyRtcConfiguration(r._peerConnectionContext.peerConnection.value,o).then((function(e){var t,o=!1,c=!1,l=[];return r._peerConnectionContext.peerConnection.value=e,e.addStream(r._peerConnectionContext.mediaStream.value),e.onicecandidate=function(n){r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e&&(o||Ee.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?l.push(n.candidate):c=!0,t||(t=w.value.setTimeout((function(){var e;r._publisherContext.stream.value!==i||o||null===(e=r._publisherContext.endPoint.value)||void 0===e||e.addIceCandidates(i,l,c).then((function(e){var t=e.status,n=e.options;"ok"===t?(null!=n&&n.includes("cancel")&&(o=!0),r._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",r._publisherContext.streamId,t,n)):r._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",r._publisherContext.streamId,t)})).catch((function(e){r._logger.error("[%s] Failed to add ICE candidates",r._publisherContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e){var t=function(){r._publisherContext.state.value=hn.ConnectionError,r._publisherContext.publishing.value=!1,r._publisherContext.loading.value=!0,r._handleStreamFailure().catch((function(t){r._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",r._publisherContext.streamId,e.iceConnectionState,t)}))};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return r._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",r._publisherContext.streamId,e.iceConnectionState),void r.reconnectPeerConnection(e,t);case"closed":return r._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",r._publisherContext.streamId,e.iceConnectionState),void t();default:W(e.iceConnectionState)}}},new mn((function(e){e()})).then((function(){if(a)return r._logger.info("[%s] Set local SDP offer [%s]",r._publisherContext.streamId,a.sessionDescription.sdp),e.setLocalDescription(a.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,a.sessionDescription,e.message),e}))})).then((function(){var t;if(u)return r._logger.info("[%s] Set remote SDP answer [%s]",r._publisherContext.streamId,null==u||null===(t=u.sessionDescription)||void 0===t?void 0:t.sdp),e.setRemoteDescription(u.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,null==u?void 0:u.sessionDescription,e.message),e}))})).then((function(){if(s)return r._logger.info("[%s] Set remote SDP offer [%s]",r._publisherContext.streamId,s.sessionDescription.sdp),e.setRemoteDescription(s.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,null==u?void 0:u.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!1,offerToReceiveVideo:!1})})).then((function(e){r._logger.info("[%s] Set local SDP answer [%s]",r._publisherContext.streamId,e.sdp);var t=r._publisherContext.endPoint.value;if(!t)throw new Error("Failed to set remote description, EndPoint is not set");return t.setRemoteDescription(i,e)})).then((function(t){var n=t.status,i=t.sessionDescription;return r._publisherContext.state.value=r.mapSetRemoteDescriptionStatusToPublisherStatus(n),"ok"!==n?(r._publisherContext.publishing.value=!1,r._publisherContext.standby.value=!0,void(r._publisherContext.stopped.value=!1)):(r._logger.info("[%s] Set local SDP [%s]",r._publisherContext.streamId,null==i?void 0:i.sdp),e.setLocalDescription(i).catch((function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,i,e.message),e})))}))})).then((function(){var t;n.success(r._publisherContext.streamId),r._publisherContext.state.value=hn.Publishing,r._publisherContext.publishing.value=!0;var i=new fn(e,null!==(t=r._publisherContext.endPoint.value)&&void 0!==t&&t.roundTripTime?r._publisherContext.endPoint.value.roundTripTime/4:0);return r._publisherContext.disposables.add(i),i.rtcStatistic.subscribe((function(e){r._publisherContext.rtcStatistics.value=e})),mn.resolve()}))}))})):(this._publisherContext.state.value=hn.Offline,mn.resolve())}},{key:"applyRtcConfiguration",value:(e=M()(V().mark((function e(t,n){var r;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=Ct.truncateIceServers(n),e.abrupt("return",Ee.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=gn(gn({},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._publisherContext.state.value=hn.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Ee.maximalNumberOfPeerConnectionReconnectAttempts||!Ee.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(P.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||!i){var o=w.value.setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);return void this._publisherContext.disposables.add(new f((function(){return w.value.clearTimeout(o)})))}this._logger.info("Reconnecting peer connection by restarting ICE");var a=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(r){return e.setLocalDescription(r).then((function(){return e.setLocalDescription(a).then((function(){if("disconnected"===e.iceConnectionState||"failed"===e.iceConnectionState){var r=w.value.setTimeout((function(){n.reconnectPeerConnection(e,t)}),1e3);n._publisherContext.disposables.add(new f((function(){return w.value.clearTimeout(r)})))}else n._publisherContext.state.value=hn.Publishing}))}))})).catch((function(e){n._logger.error("Failed to reconnect peer connection",e),n._peerConnectionContext.peerConnectionReconnectAttempts=0,t()}))}else this._logger.info("Failed to reconnect peer connection after [%s] attempts, performing full recovery",this._peerConnectionContext.peerConnectionReconnectAttempts),this._peerConnectionContext.peerConnectionReconnectAttempts=0,t()}},{key:"mapSetRemoteDescriptionStatusToPublisherStatus",value:function(e){switch(e){case"ok":return hn.Starting;case"unauthorized":return hn.Unauthorized;case"not-found":return hn.NotFound;case"capacity":case"rate-limited":case"timeout":return hn.Recovering;case"failed":return hn.Error;default:W(e)}}}]);var e}(),yn=n(981).A,bn=function(){return o()((function e(n,r,i){var o=this;t()(this,e),s()(this,"_logger",X.getLogger("Publisher")),s()(this,"_tokenContext",void 0),s()(this,"_publisherContext",void 0),s()(this,"_peerConnectionContext",void 0),s()(this,"_stateContext",void 0),s()(this,"_exponentialBackoff",void 0),s()(this,"_publisherStartTime",void 0),s()(this,"_readOnlyToken",void 0),s()(this,"_readOnlyPeerConnection",void 0),s()(this,"_readOnlyState",void 0),s()(this,"_readOnlyTokenExpiring",void 0),s()(this,"_readOnlyAuthorized",void 0),s()(this,"_readOnlyOnline",void 0),s()(this,"_readOnlyLoading",void 0),s()(this,"_readOnlyPublishing",void 0),s()(this,"_readOnlyStandby",void 0),s()(this,"_readOnlyStopped",void 0),s()(this,"_readOnlyFailureCount",void 0),s()(this,"_readOnlyEndPoint",void 0),s()(this,"_readOnlyStream",void 0),s()(this,"_readOnlyRtcStatistics",void 0),s()(this,"_readOnlyMediaStream",void 0),s()(this,"_metricsService",void 0),s()(this,"_sessionTelemetry",void 0),this._tokenContext=new je(r),this._publisherContext=new pn(i),this._peerConnectionContext=new qe,this._stateContext=new Je,this._exponentialBackoff=new be,this._publisherStartTime=Date.now(),this._readOnlyToken=new y(this._tokenContext.token),this._readOnlyPeerConnection=new y(this._peerConnectionContext.peerConnection),this._readOnlyState=new y(this._publisherContext.state),this._readOnlyTokenExpiring=new y(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new y(this._publisherContext.authorized),this._readOnlyOnline=new y(this._publisherContext.online),this._readOnlyLoading=new y(this._publisherContext.loading),this._readOnlyPublishing=new y(this._publisherContext.publishing),this._readOnlyStandby=new y(this._publisherContext.standby),this._readOnlyStopped=new y(this._publisherContext.stopped),this._readOnlyFailureCount=new y(this._publisherContext.failureCount),this._readOnlyEndPoint=new y(this._publisherContext.endPoint),this._readOnlyStream=new y(this._publisherContext.stream),this._readOnlyRtcStatistics=new y(this._publisherContext.rtcStatistics),this._readOnlyMediaStream=new y(this._peerConnectionContext.mediaStream),this._peerConnectionContext.mediaStream.value=n;var a=te.parseToken(this._tokenContext.token.value),u=(a.uri||Ee.discoveryUri.value).toString();Ee.tenancy.value=a.tenancy||Ee.tenancy.value,pe.uri.value=u,this._metricsService=Te.getMetricsService(u),this._sessionTelemetry=new Ve(Ee.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe((function(e){o._publisherContext.clearFailureCountTimeout&&w.value.clearTimeout(o._publisherContext.clearFailureCountTimeout),o._publisherContext.failureCount.value&&e===hn.Publishing&&(o._publisherContext.clearFailureCountTimeout=w.value.setTimeout((function(){o._publisherContext.failureCount.value=0}),3e3))})));var c=function(){o._publisherContext.stream.value&&o._publisherContext.endPoint.value&&o._publisherContext.endPoint.value.destroyStreamOnUnmount(o._publisherContext.stream.value,"client:termination-on-window-unload")};w.value.addWindowEventListener("beforeunload",c),this._publisherContext.publisherDisposables.add(new f((function(){w.value.removeWindowEventListener("beforeunload",c)}))),this.start()}),[{key:"token",get:function(){return this._tokenContext.token.value},set:function(e){this._publisherContext.disposables.dispose(),this._tokenContext.token.value=e,this._tokenContext.tokenExpiring.value=!1;var t=te.parseToken(this._tokenContext.token.value),n=(t.uri||Ee.discoveryUri.value).toString();Ee.tenancy.value=t.tenancy||Ee.tenancy.value,pe.uri.value=n,this._metricsService=Te.getMetricsService(n),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"publishing",get:function(){return this._readOnlyPublishing}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._publisherContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"stop",value:(a=M()(V().mark((function e(t){var n=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new yn((function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._publisherContext.disposables.add(n._stateContext.isStarting.subscribe((function(r){r||(n.processStop(t),e())})))})));case 1:case"end":return e.stop()}}),e)}))),function(e){return a.apply(this,arguments)})},{key:"processStop",value:function(e){this.cleanUpResources(e),this._peerConnectionContext.peerConnection.value&&(this._peerConnectionContext.peerConnection.value.close(),this._peerConnectionContext.peerConnection.value=null),this._publisherContext.state.value=hn.Stopped}},{key:"dispose",value:(i=M()(V().mark((function e(){var t=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stop("client:channel-dispose").then((function(){t._publisherContext.publisherDisposables.dispose(),t._stateContext.isDisposed=!0})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getUri",value:function(e){return te.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",Ee.discoveryUri.value),new w.value.URL(Ee.discoveryUri.value))}},{key:"start",value:(r=M()(V().mark((function e(){return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._stateContext.isStarting.value){e.next=5;break}return this._logger.info("Publisher is already starting, skipping start"),e.abrupt("return");case 5:return this._stateContext.isStarting.value=!0,e.abrupt("return",this.processStart());case 7:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"processStart",value:(n=M()(V().mark((function e(){var t,n,r,i,o,a=this;return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publisherContext.state.value=hn.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),te.isEncodedEdgeTokenValid(t)){e.next=10;break}return this._logger.error("Failed to parse token [%s]",t),this._publisherContext.state.value=hn.Unauthorized,this._publisherContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 10:return this._publisherContext.loading.value=!0,r=this.getUri(t),this._publisherContext.disposables.add(this._publisherContext.state.subscribe((function(e){e!==hn.Error&&e!==hn.Recovering||nt.clearCachedClosestEndpoint(r)}))),i=function(){return new yn((function(e){return a._stateContext.isStarting.value=!1,e(a.handleStreamFailure())}))},o=new _n(this._publisherContext,this._peerConnectionContext,i),e.abrupt("return",o.start(r,t,n).then((function(){a._publisherContext.loading.value=!1})).catch((function(e){n.fail(),a._publisherContext.failureCount.value++,a._publisherContext.online.value=!1,a.cleanUpResources("client:cleanup-after-failed-setup"),a._publisherContext.state.value=hn.ClientStartError,a._logger.error("Failed to start publishing",e)})).finally((function(){if(a._stateContext.isStarting.value=!1,a._publisherContext.state.value!==hn.Publishing&&Ee.automaticRetryOnFailure){var e=w.value.setTimeout((function(){a.handleStreamFailure().catch((function(e){a._logger.error("Failed handling stream failure",e)}))}),a.getRetryInterval());a._publisherContext.disposables.add(new f((function(){w.value.clearTimeout(e)})))}else a._publisherContext.startReconnectionAttemptsTimeInMilliseconds=0})));case 16:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"setMediaStream",value:function(e){var t=this;this._peerConnectionContext.mediaStream.value=e,this._peerConnectionContext.peerConnection.value&&e.getTracks().forEach((function(e){var n;null===(n=t._peerConnectionContext.peerConnection.value)||void 0===n||n.getSenders().forEach((function(t){var n;e.kind===(null==t||null===(n=t.track)||void 0===n?void 0:n.kind)&&e.id!==t.track.id&&t.replaceTrack(e)}))}))}},{key:"getRetryInterval",value:function(){switch(this._publisherContext.state.value){case hn.Offline:return 15e3;case hn.Initializing:case hn.NotFound:case hn.Error:case hn.Recovering:case hn.Unauthorized:case hn.GeoRestricted:case hn.GeoBlocked:case hn.Stopped:case hn.Starting:case hn.Publishing:case hn.Reconnecting:case hn.UnsupportedFeature:case hn.ConfigurationError:case hn.TransientConfigurationError:case hn.ConnectionError:case hn.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._publisherContext.failureCount.value);default:W(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:(e=M()(V().mark((function e(){return V().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._publisherContext.state.value,e.next=e.t0===hn.Error||e.t0===hn.Reconnecting||e.t0===hn.Offline||e.t0===hn.Recovering||e.t0===hn.TransientConfigurationError||e.t0===hn.ConnectionError||e.t0===hn.ClientStartError?4:e.t0===hn.Unauthorized?11:e.t0===hn.GeoRestricted?13:e.t0===hn.GeoBlocked?15:e.t0===hn.Stopped?17:e.t0===hn.Publishing?19:e.t0===hn.Initializing?21:e.t0===hn.Starting?23:e.t0===hn.UnsupportedFeature?25:e.t0===hn.NotFound?27:e.t0===hn.ConfigurationError?29:31;break;case 4:if(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds||(this._publisherContext.startReconnectionAttemptsTimeInMilliseconds=Date.now()),!(72e5<=Date.now()-this._publisherContext.startReconnectionAttemptsTimeInMilliseconds)){e.next=9;break}return this._logger.info("Publisher stopped with state [%s] [%s] after exceeding timeout",this._publisherContext.state.value,hn[this._publisherContext.state.value]),e.abrupt("return");case 9:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,hn[this._publisherContext.state.value]),e.abrupt("break",32);case 11:return this._logger.info("Publisher is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 13:return this._logger.info("Publisher is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 15:return this._logger.info("Publisher is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 17:return this._logger.info("Publisher is stopped, skipping retry of start."),e.abrupt("return");case 19:return this._logger.info("Publisher is publishing, skipping retry of start"),e.abrupt("return");case 21:return this._logger.info("Publisher is initializing, skipping retry of start"),e.abrupt("return");case 23:return this._logger.info("Publisher is already starting, skipping retry of start"),e.abrupt("return");case 25:return this._logger.info("Publisher is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 27:return this._logger.info("Publisher is stopped due to channel not found, skipping retry of start."),e.abrupt("return");case 29:return this._logger.info("Publisher is stopped due to configuration error, skipping retry of start."),e.abrupt("return");case 31:W(this._publisherContext.state.value);case 32:return e.abrupt("return",this.start());case 33:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"client:termination";this._publisherContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close(),n.dispose(),!Ee.forceGarbageCollectionOnRestart||P.isMobile&&Ee.skipGarbageCollectionOnMobileDevices||Ie.forceGarbageCollection()),this._publisherContext.publishing.value=!1,this._publisherContext.stopped.value=!0,this._publisherContext.standby.value=!1,this._publisherContext.stream.value&&this._publisherContext.endPoint.value&&this._publisherContext.endPoint.value.destroyStream(this._publisherContext.stream.value,t).then((function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)})).catch((function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)})),this._publisherContext.stream.value=null,this._publisherContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}}]);var e,n,r,i,a}(),Cn=function(){return o()((function e(){throw t()(this,e),new Error("Publishers is a static class that may not be instantiated")}),null,[{key:"createPublisher",value:function(e){if(!Ee.initialized.value)throw new Error("SDK is not loaded.");return new bn(e.mediaStream,e.token,e.name)}}])}(),kn={SDK:Ee,Channels:ln,ChannelState:De,Publishers:Cn,PublisherState:hn}})(),r})()));
3
3
  //# sourceMappingURL=full.js.map