@phenixrts/sdk 2025.0.2 → 2025.0.4-beta.409
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/channels/debug/channels.js +1303 -1258
- package/channels/debug/package.json +1 -1
- package/channels/debug.private/channels.js +1216 -1171
- package/channels/debug.private/package.json +1 -1
- package/channels/debug.provideGlobalScope/channels.js +1275 -1230
- package/channels/debug.provideGlobalScope/package.json +1 -1
- package/channels/es5.debug.private/channels.js +75 -30
- package/channels/es5.debug.private/package.json +1 -1
- package/channels/min/channels.js +1 -1
- package/channels/min/channels.js.map +1 -1
- package/channels/min/package.json +1 -1
- package/channels/min.private/channels.js +1 -1
- package/channels/min.private/channels.js.map +1 -1
- package/channels/min.private/package.json +1 -1
- package/channels/min.provideGlobalScope/channels.js +1 -1
- package/channels/min.provideGlobalScope/channels.js.map +1 -1
- package/channels/min.provideGlobalScope/package.json +1 -1
- package/channels/package.json +1 -1
- package/full/debug/full.js +1556 -1404
- package/full/debug/package.json +1 -1
- package/full/debug.private/full.js +1469 -1317
- package/full/debug.private/package.json +1 -1
- package/full/min/full.js +1 -1
- package/full/min/full.js.map +1 -1
- package/full/min/package.json +1 -1
- package/full/min.private/full.js +1 -1
- package/full/min.private/full.js.map +1 -1
- package/full/min.private/package.json +1 -1
- package/full/package.json +1 -1
- package/package.json +1 -1
- package/publish/debug/package.json +1 -1
- package/publish/debug/publish.js +1020 -869
- package/publish/debug.private/package.json +1 -1
- package/publish/debug.private/publish.js +1020 -869
- package/publish/min/package.json +1 -1
- package/publish/min/publish.js +1 -1
- package/publish/min/publish.js.map +1 -1
- package/publish/min.private/package.json +1 -1
- package/publish/min.private/publish.js +1 -1
- package/publish/min.private/publish.js.map +1 -1
- package/publish/package.json +1 -1
- package/types/globalScope/GlobalScope.d.ts +1 -0
- package/types/globalScope/IGlobalScope.d.ts +1 -0
- package/types/globalScope/IWindow.d.ts +1 -0
- package/types/globalScope/ProvidedGlobalScope.d.ts +1 -0
- package/types/rtc/PeerConnectionService.d.ts +9 -3
- package/types/sdk/publish/PublisherContext.d.ts +7 -2
- package/types/sdk/publish/RealTimePublisher.d.ts +1 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see channels.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.phenix=t():e.phenix=t()}(self,(()=>(()=>{var e={131: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=>{function t(e,t,n,r,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}e.exports=function(e){return function(){var n=this,r=arguments;return new Promise((function(i,o){var a=e.apply(n,r);function s(e){t(a,i,o,s,u,"next",e)}function u(e){t(a,i,o,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,n)=>{var 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(738).default;function i(){"use strict";e.exports=i=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},o=Object.prototype,a=o.hasOwnProperty,s=Object.defineProperty||function(e,t,n){e[t]=n.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",d=u.toStringTag||"@@toStringTag";function h(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(t){h=function(e,t,n){return e[t]=n}}function f(e,t,n,r){var i=t&&t.prototype instanceof b?t:b,o=Object.create(i.prototype),a=new R(r||[]);return s(o,"_invoke",{value:F(e,n,a)}),o}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=f;var m="suspendedStart",v="suspendedYield",g="executing",y="completed",_={};function b(){}function C(){}function k(){}var S={};h(S,c,(function(){return this}));var w=Object.getPrototypeOf,x=w&&w(w(O([])));x&&x!==o&&a.call(x,c)&&(S=x);var T=k.prototype=b.prototype=Object.create(S);function P(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function n(i,o,s,u){var c=p(e[i],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==r(d)&&a.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):t.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,u)}))}u(c.arg)}var i;s(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}})}function F(e,n,r){var i=m;return function(o,a){if(i===g)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=I(s,r);if(u){if(u===_)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===m)throw i=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=g;var c=p(e,n,r);if("normal"===c.type){if(i=r.done?y:v,c.arg===_)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=y,r.method="throw",r.arg=c.arg)}}}function I(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,I(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),_;var o=p(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,_;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,_):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,_)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function D(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function O(e){if(e||""===e){var n=e[c];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(a.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(r(e)+" is not iterable")}return C.prototype=k,s(T,"constructor",{value:k,configurable:!0}),s(k,"constructor",{value:C,configurable:!0}),C.displayName=h(k,d,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===C||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,k):(e.__proto__=k,h(e,d,"GeneratorFunction")),e.prototype=Object.create(T),e},n.awrap=function(e){return{__await:e}},P(E.prototype),h(E.prototype,l,(function(){return this})),n.AsyncIterator=E,n.async=function(e,t,r,i,o){void 0===o&&(o=Promise);var a=new E(f(e,t,r,i),o);return n.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},P(T),h(T,d,"Generator"),h(T,c,(function(){return this})),h(T,"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=O,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(D),!e)for(var n in this)"t"===n.charAt(0)&&a.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 s.type="throw",s.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],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=a.call(o,"catchLoc"),c=a.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&&a.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,_):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),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),D(n),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;D(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:O(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),_}},n}e.exports=i,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:()=>Pe,Channels:()=>Xt,SDK:()=>Se,default:()=>Yt});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),f=n.n(h),p=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 f()(n,e),o()(n)}(p),y=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)}}])}(),_=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=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(t){if(this._instance.value)throw new Error("GlobalScope can only be set one time");this._instance.value=new e(t)}},{key:"getInstance",value:function(){return e._readOnlyInstance}},{key:"subscribe",value:function(t){return e._readOnlyInstance.subscribe(t)}}])}();v=b,s()(b,"_instance",new y(null)),s()(b,"_readOnlyInstance",new _(v._instance));var C,k,S,w=b.getInstance(),x=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""}}])}();C=x,s()(x,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),s()(x,"_browserNameAndVersion",C.parseBrowserNameAndVersion()),s()(x,"_browserName",C.parseBrowserName()),s()(x,"_browserMajorVersion",C.parseBrowserMajorVersion()),s()(x,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(k=navigator)||void 0===k?void 0:k.userAgent)),s()(x,"_isAndroid",/Android/i.test(null===(S=navigator)||void 0===S?void 0:S.userAgent)),s()(x,"_isChrome69",C._browserNameAndVersion.includes("Chrome/69.")),s()(x,"_isChrome70",C._browserNameAndVersion.includes("Chrome/70.")),s()(x,"_isChrome71",C._browserNameAndVersion.includes("Chrome/71.")),s()(x,"_isChrome72",C._browserNameAndVersion.includes("Chrome/72.")),s()(x,"_isChrome74",C._browserNameAndVersion.includes("Chrome/74.")),s()(x,"_isChrome75",C._browserNameAndVersion.includes("Chrome/75.")),s()(x,"_isChrome76",C._browserNameAndVersion.includes("Chrome/76.")),s()(x,"_isChrome77",C._browserNameAndVersion.includes("Chrome/77."));var T=function(){function e(){t()(this,e)}return o()(e,null,[{key:"clientOfferDisabled",get:function(){return x.isChrome74||x.isChrome75||x.isChrome76||x.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return x.isChrome69||x.isChrome70||x.isChrome71||x.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===x.browserName&&x.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===x.browserName&&x.browserMajorVersion<=69||"Firefox"===x.browserName&&x.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===x.browserName&&x.browserMajorVersion<=63||"Firefox"===x.browserName&&x.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===x.browserName&&x.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===x.browserName&&x.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===x.browserName||"SamsungBrowser"===x.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==x.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===x.browserName&&"function"==typeof(null===(e=w.value)||void 0===e?void 0:e.documentCreateElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===x.browserName&&x.browserMajorVersion>=71||"Firefox"===x.browserName&&x.browserMajorVersion>=69||"Safari"===x.browserName}},{key:"isMobile",get:function(){return x.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"!==x.browserName&&"Safari"!==x.browserName}}])}(),P=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),E=function(){return o()((function e(n,r,i){t()(this,e),s()(this,"_category",void 0),s()(this,"_appenders",void 0),s()(this,"_threshold",void 0),this._category=n,this._appenders=r,this._threshold=i}),[{key:"category",get:function(){return this._category}},{key:"appenders",get:function(){return this._appenders}},{key:"threshold",get:function(){return this._threshold}},{key:"trace",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,r=new Date,i=this.replacePlaceholders(t);this._appenders.value.forEach((function(t){t.log(e,i,n.category,r)}))}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],r=0;n.indexOf&&e.length>1&&r>=0;)if((r=n.indexOf("%",r))>0)switch(n.substring(r+1,r+2)){case"%":n=n.substring(0,r)+n.substring(r+1),r++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,r),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,r),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce((function(e,n,r,i){return r+1===i.length&&n instanceof Error?T.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}}])}(),F=function(){return o()((function e(){t()(this,e),s()(this,"_appenders",[])}),[{key:"value",get:function(){return this._appenders}},{key:"add",value:function(e){this._appenders.push(e)}},{key:"remove",value:function(e){this._appenders=this._appenders.reduce((function(t,n){return n!==e&&t.push(n),t}),[])}}])}(),I=function(){return o()((function e(){t()(this,e)}),null,[{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"sendLogs",get:function(){return this._sendLogs}},{key:"sendMetrics",get:function(){return this._sendMetrics}},{key:"logToConsole",get:function(){return this._logToConsole}},{key:"applyFeatures",value:function(){try{var e={sendLocalCandidates:!0,sendLogs:"All",sendMetrics:"All",logToConsole:"All"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}])}();s()(I,"_sendLocalCandidates",void 0),s()(I,"_sendLogs",void 0),s()(I,"_sendMetrics",void 0),s()(I,"_logToConsole",void 0),I.applyFeatures();var L=function(){return o()((function e(){t()(this,e)}),null,[{key:"defaultLoggingLevel",get:function(){return P[I.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return P[I.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return P.Info}}])}(),D=function(){return o()((function e(){t()(this,e),s()(this,"_threshold",L.defaultLoggingLevel)}),[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}])}(),R=function(){return o()((function e(n){t()(this,e),s()(this,"_threshold",void 0),this._threshold=n}),[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(P[e],"] ").concat(t);e<P.Warn?console.log(i):console.error(i)}}}])}(),O=n(293),A=n.n(O),M=n(756),N=n.n(M),V=function(){function e(){throw t()(this,e),new Error("Numbers is a static class that may not be instantiated")}return o()(e,null,[{key:"countNumberLength",value:function(t){var n=0,r=t;return r<0&&(r*=-1,n++),e.countDigitsBeforeDecimal(r)+n+(r!==Math.floor(r)?e.countDigitsAfterDecimal(r)+1:0)}},{key:"fixRounding",value:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}},{key:"countDigitsBeforeDecimal",value:function(e){for(var t=1,n=e;n>=10;)n/=10,t++;return t}},{key:"countDigitsAfterDecimal",value:function(t){for(var n=t,r=Math.floor(t),i=0;r!==n&&i<15;)i++,r=e.fixRounding(n,i);return i}}])}(),U=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()(U,"_defaultVersion",(new Date).toISOString());var B=function(){return o()((function e(n){var r=this;t()(this,e),s()(this,"_telemetryConfiguration",void 0),s()(this,"_logs",[]),s()(this,"_isSending",!1),s()(this,"_domain",""),this._telemetryConfiguration=n,this.getLocationHostnameFromGlobalScope().then((function(e){r._domain=e}))}),[{key:"push",value:function(e,t,n,r){var i=(r.valueOf()-this._telemetryConfiguration.pageLoadTime)/1e3,o={timestamp:r.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:P[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:U.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<P.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new Promise((function(e){var t=w.subscribe((function(n){n&&(e(n.locationHostname),t.dispose())}))}))}},{key:"sendLogs",value:(n=A()(N().mark((function e(t){var n;return N().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=A()(N().mark((function e(){var t,n,r,i,o,a=this;return N().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?V.countNumberLength(e):e.length},i=function(e){return Object.values(e).reduce((function(e,t){return e+(t?r(t):0)}),0)};this._logs.length>t&&i(this._logs[t])+n<8192;)n+=i(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,i(this._logs[t])+(8192-i(this._logs[t]))),t=1),o=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.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}(),j=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 B(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",L.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}}])}(),z=function(){return o()((function e(){t()(this,e)}),null,[{key:"defaultTelemetryLevel",get:function(){return G[I.sendMetrics]}}])}(),G=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),W=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}}])}(),q=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},J=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case G.Off:return"Off";case G.Essential:return"Essential";case G.All:return"All";default:q(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return G.Off;case"Essential":return G.Essential;case"All":return G.All;default:q(e)}}}])}(),K=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case P.Off:return"Off";case P.Trace:return"Trace";case P.Debug:return"Debug";case P.Info:return"Trace";case P.Warn:return"Warn";case P.Error:return"Error";case P.Fatal:return"Fatal";case P.All:return"All";default:q(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return P.Off;case"Trace":return P.Trace;case"Debug":return P.Debug;case"Info":return P.Info;case"Warn":return P.Warn;case"Error":return P.Error;case"Fatal":return P.Fatal;case"All":return P.All;default:q(e)}}}])}(),Z=function(){function e(){t()(this,e)}return o()(e,null,[{key:"getStringValue",value:function(t){return e.defaultStringValue[t]}},{key:"getBooleanValue",value:function(t){return e.defaultBooleanValue[t]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":J.convertTelemetryLevelToTelemetryLevelType(z.defaultTelemetryLevel),"phenix-logging-level":K.convertLoggingLevelToLoggingLevelType(L.defaultLoggingLevel),"phenix-console-logging-level":K.convertLoggingLevelToLoggingLevelType(L.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":K.convertLoggingLevelToLoggingLevelType(L.defaultTelemetryLoggingLevel),"phenix-channel-token":"","phenix-uri":"","phenix-base-uri":""}}},{key:"defaultBooleanValue",get:function(){return{"phenix-automatically-retry-on-failure":!0,"phenix-automatically-reconnect-peer-connection":!0,"phenix-force-garbage-collection-on-restart":!0,"phenix-skip-garbage-collection-on-mobile-devices":!0}}}])}(),Q=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 E(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=Z.getStringValue("phenix-logging-level");P[e]&&this._threshold.setThreshold(P[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=Z.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(P[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new R(e||L.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||L.defaultTelemetryLoggingLevel,this._appenders.add(new j(this._telemetryConfiguration))}}])}();s()(Q,"_loggers",{}),s()(Q,"_appenders",new F),s()(Q,"_threshold",new D),s()(Q,"_telemetryConfiguration",new H),Q.applyLoggerConfigFromParameterConfiguration();var $=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)}}])}(),X=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}}])}(),Y=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 X(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new X(r)}catch(t){return e._logger.error("Cannot parse token value",t),new X(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();s()(Y,"_logger",Q.getLogger("EdgeAuthParser"));var ee=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,"]")}}])}(),te="visibilitychange",ne=function(){return o()((function e(){t()(this,e),s()(this,"_disposables",new ee),s()(this,"_readOnlyIsForeground",void 0),s()(this,"_isForeground",void 0),s()(this,"_timeOfLastTabFocusChange",Date.now()),this._isForeground=new y(!0),this._readOnlyIsForeground=new _(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(te,t,n),this._disposables.add(new p((function(){return w.value.removeDocumentEventListener(te,t,n)})))}}])}(),re=function(){return o()((function e(n){t()(this,e),s()(this,"_logger",Q.getLogger("VanillaPeerConnection")),s()(this,"_peerConnection",void 0),T.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!T.getTransceiversDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getTransceivers)}},{key:"supportsAddTransceiver",get:function(){var e;return!T.addTranceiverDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.addTransceiver)}},{key:"createOffer",value:(i=A()(N().mark((function e(t){var n=this;return N().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(!T.promiseBasedPCMethodsDisabled){e.next=4;break}return e.abrupt("return",new Promise((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=A()(N().mark((function e(t){var n=this;return N().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(!T.promiseBasedPCMethodsDisabled){e.next=4;break}return e.abrupt("return",new Promise((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=A()(N().mark((function e(t){return N().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(T.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=A()(N().mark((function e(t){var n;return N().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(T.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 Promise((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}(),ie=function(){return o()((function e(){t()(this,e)}),[{key:"createPeerConnection",value:(e=A()(N().mark((function e(t){return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){w.subscribe((function(n){n&&e(new re(t))}))})));case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e}(),oe=function(){function e(){throw 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(){T.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(r=A()(N().mark((function t(){return N().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=A()(N().mark((function t(){var n,r,i,o,a=arguments;return N().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=T.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:r}:void 0,t.abrupt("return",e._peerConnectionFactory.value.createPeerConnection(o).then(function(){var e=A()(N().mark((function e(t){var r,i,o;return N().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()(oe,"_logger",Q.getLogger("PeerConnectionService")),s()(oe,"_peerConnectionFactory",new y(new ie)),s()(oe,"_cached",void 0),oe.initiateInitialPrecaching();var ae=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}}}])}(),se=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""}}}])}(),ue=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:"distribution"}};this._discoveryParameters="discovery"in e?e.discovery:{intentions:""}}catch(e){this._discoveryParameters={intentions:""}}}}])}();s()(ue,"_discoveryParameters",void 0),ue.applyParameters();var ce=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=U.sdkVersion,r=ue.discoveryParameters.intentions;return t.searchParams.set("version",n),t.searchParams.set("intentions",r),t.searchParams.set("_","".concat(Date.now())),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}])}();s()(ce,"_discoveryUri",new y("https://pcast.phenixrts.com/pcast/endPoints"));var le,de,he=n(738),fe=n.n(he),pe=n(132),me=n.n(pe),ve=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)}}])}(),ge=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}(ge||{}),ye=ge,_e=function(){return o()((function e(n){t()(this,e),s()(this,"_metrics",void 0),this._metrics=n}),[{key:"getName",value:function(){return ye[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case ye.TimeToFirstFrame:case ye.ChannelCreationTimeToFirstFrame:return G.Essential;case ye.Stalled:case ye.Buffering:case ye.SetupCompleted:case ye.SetupFailed:case ye.RoundTripTime:case ye.DownlinkThroughputCapacity:case ye.NetworkType:case ye.ResolutionChanged:case ye.ApplicationForeground:case ye.ApplicationBackground:return G.All;default:q(this._metrics)}}}])}(),be=function(){return o()((function e(n){var r=this;t()(this,e),s()(this,"_logger",Q.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 ve,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 _e(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:U.sdkVersion,runtime:i,resource:o,kind:a};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new Promise((function(e){var t=w.subscribe((function(n){n&&(e(n.locationHostname),t.dispose())}))}))}},{key:"sendMetrics",value:(n=A()(N().mark((function e(t){var n;return N().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=A()(N().mark((function e(){var t,n=this;return N().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(me()(t),me()(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}(),Ce=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(fe()(t),"]"));var n=e._metricsServices[t];if(n)return n;var r=new W;return r.sessionId=Se.clientSessionId,r.tenancy=Se.tenancy.value,r.url=ae.getTelemetryUrl(t),r.environment=se.getEnvironmentFromUrl(t),r.threshold=J.convertTelemetryLevelTypeToTelemetryLevel(Se.telemetryLevel),e._metricsServices[t]=new be(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}])}();s()(Ce,"_metricsServices",{});var ke=(null===(le=b.getInstance().value)||void 0===le?void 0:le.pageLoadTime)||Date.now(),Se=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 ke}},{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"tenancy",get:function(){return this._tenancy}},{key:"clientSessionId",get:function(){return e._clientSessionId}},{key:"loadedTimestamp",get:function(){return e._loadedTimestamp}},{key:"initialized",get:function(){return e._readOnlyInitialized}},{key:"discoveryUri",get:function(){return e._readOnlyDiscoveryUri}},{key:"peerConnectionFactory",get:function(){return e._readOnlyPeerConnectionFactory}},{key:"automaticRetryOnFailure",get:function(){return e._automaticallyRetryOnFailure}},{key:"automaticallyReconnectPeerConnection",get:function(){return e._automaticallyReconnectPeerConnection}},{key:"automaticallyPlayMediaStream",get:function(){return e._automaticallyPlayMediaStream}},{key:"automaticallyMuteVideoOnPlayFailure",get:function(){return e._automaticallyMuteVideoOnPlayFailure}},{key:"forceGarbageCollectionOnRestart",get:function(){return this._forceGarbageCollectionOnRestart}},{key:"skipGarbageCollectionOnMobileDevices",get:function(){return this._skipGarbageCollectionOnMobileDevices}},{key:"webPlayerLoader",get:function(){return this._webPlayerLoader}},{key:"shakaPlayerLoader",get:function(){return this._shakaPlayerLoader}},{key:"hlsJsLoader",get:function(){return this._hlsJsLoader}},{key:"metricsService",get:function(){return e._metricsService}},{key:"applicationActivityMonitor",get:function(){return this._applicationActivityMonitor}},{key:"telemetryUrl",get:function(){return this._telemetryUrl}},{key:"maximalNumberOfPeerConnectionReconnectAttempts",get:function(){return this._maximalNumberOfPeerConnectionReconnectAttempts},set:function(e){this._maximalNumberOfPeerConnectionReconnectAttempts=e}},{key:"loggingLevel",get:function(){return K.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return J.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return x}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=Q.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 j}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new j(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 j}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new j(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=Ce.getMetricsService(ce.uri.value),e._metricsConfiguration=e._metricsService.metricsConfiguration,e._metricsConfiguration.sessionId=e.clientSessionId,e._environment.subscribe((function(t){e._metricsConfiguration.environment=t})),e.telemetryUrl.subscribe((function(t){e._metricsConfiguration.url=t})),e._tenancy.subscribe((function(t){e._metricsConfiguration.tenancy=t}));var t=Z.getStringValue("phenix-metrics-level");t&&Ce.setTelemetryLevel(G[t]),e._telemetryLevel.subscribe((function(e){Ce.setTelemetryLevel(e)}))}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=Z.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=Z.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=Z.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=Z.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices"),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices)}},{key:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe((function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=se.getEnvironmentFromUrl(t)}));var t=Z.getStringValue("phenix-channel-token");if(t){var n=Y.parseToken(t);return e._tenancy.value=n.tenancy,ce.uri.value=(n.uri||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var r=Z.getStringValue("phenix-uri");if(r)return ce.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=Z.getStringValue("phenix-base-uri");if(i){var o=new(b.getInstance().value.URL)(i);return o.pathname="/pcast/endPoints",ce.uri.value=o.toString(),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)}}},{key:"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 ne,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&&b.setInstance(n.globalScope),t.discoveryUri&&(ce.uri.value=t.discoveryUri),t.peerConnectionFactory&&(oe.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&G[t.telemetryLevel]&&(e._telemetryLevel.value=J.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&P[t.loggingLevel]&&this._logger.threshold.setThreshold(K.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&P[t.consoleLoggingLevel]){var r=this._logger.appenders.value.find((function(e){return e instanceof R}));r&&this._logger.appenders.remove(r),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new R(K.convertLoggingLevelTypeToLoggingLevel(t.consoleLoggingLevel)))}"boolean"==typeof t.automaticallyPlayMediaStream&&(this._automaticallyPlayMediaStream=t.automaticallyPlayMediaStream),"boolean"==typeof t.automaticallyMuteVideoOnPlayFailure&&(this._automaticallyMuteVideoOnPlayFailure=t.automaticallyMuteVideoOnPlayFailure),t.webPlayerLoader&&(this._webPlayerLoader=t.webPlayerLoader),t.shakaPlayerLoader&&(this._shakaPlayerLoader=t.shakaPlayerLoader),t.hlsJsLoader&&(this._hlsJsLoader=t.hlsJsLoader)}}},{key:"dispose",value:function(){var t;e._initialized.value=!1,null===(t=this._applicationActivityMonitor)||void 0===t||t.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return ae.getTelemetryUrl(e)}}])}();de=Se,s()(Se,"_automaticallyRetryOnFailure",Z.getBooleanValue("phenix-automatically-retry-on-failure")),s()(Se,"_automaticallyReconnectPeerConnection",Z.getBooleanValue("phenix-automatically-reconnect-peer-connection")),s()(Se,"_automaticallyPlayMediaStream",!0),s()(Se,"_automaticallyMuteVideoOnPlayFailure",!0),s()(Se,"_forceGarbageCollectionOnRestart",Z.getBooleanValue("phenix-force-garbage-collection-on-restart")),s()(Se,"_skipGarbageCollectionOnMobileDevices",Z.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices")),s()(Se,"_webPlayerLoader",void 0),s()(Se,"_shakaPlayerLoader",void 0),s()(Se,"_hlsJsLoader",void 0),s()(Se,"_applicationActivityMonitor",void 0),s()(Se,"_environment",new y("")),s()(Se,"_telemetryUrl",new y("https://telemetry.phenixrts.com/telemetry")),s()(Se,"_maximalNumberOfPeerConnectionReconnectAttempts",8),s()(Se,"_telemetryLevel",new y(z.defaultTelemetryLevel)),s()(Se,"_metricsService",void 0),s()(Se,"_metricsConfiguration",void 0),s()(Se,"_sendLocalCandidates",new y(I.sendLocalCandidates)),s()(Se,"_tenancy",new y("")),s()(Se,"_clientSessionId",$.random(32)),s()(Se,"_loadedTimestamp",new Date),s()(Se,"_logger",Q.getLogger("SDK")),s()(Se,"_initialized",new y(!1)),s()(Se,"_readOnlyInitialized",new _(de._initialized)),s()(Se,"_readOnlyDiscoveryUri",new _(ce.uri)),s()(Se,"_readOnlyPeerConnectionFactory",new _(oe.peerConnectionFactory)),b.subscribe(Se.onLoad.bind(Se));var we=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)}}])}(),xe=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(){T.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){T.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}}}])}(),Te=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}(Te||{}),Pe=Te,Ee=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)}}])}(),Fe=function(){},Ie=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",Q.getLogger("StreamTelemetry")),s()(this,"_disposables",new ee),s()(this,"_streamId",void 0),s()(this,"_metricsService",void 0),s()(this,"_listenToFirstTime",Fe),s()(this,"_listenForStall",Fe),s()(this,"_listenForContinuation",Fe),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 p((function(){return null}))),s()(this,"_clearRebufferingListener",new p((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 p((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 p((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 Ee(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:ye.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 Ee(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:ye.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 Ee(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:ye.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:ye.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 Ee(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:ye.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",Q.getLogger("StreamSetupListener")),s()(this,"metricsService",Se.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(ye.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(ye.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new _e(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 Ee(n-this._pageLoadTime).toIsoString(),t,i,new Ee(r).toIsoString())}}}])}(),De=function(){return o()((function e(){t()(this,e),s()(this,"_disposables",new ee),s()(this,"_isSupported",void 0!==w.value.navigatorConnection),s()(this,"_rtt",new y(void 0)),s()(this,"_effectiveType",new y(void 0)),s()(this,"_downlinkThroughputCapacity",new y(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 p((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()}}])}(),Re=function(){return o()((function e(n,r){var i=this;if(t()(this,e),s()(this,"_logger",Q.getLogger("SessionTelemetry")),s()(this,"_metricsService",void 0),s()(this,"_applicationActivityMonitor",Se.applicationActivityMonitor),s()(this,"_networkMonitor",new De),s()(this,"_pageLoadTime",void 0),s()(this,"_disposables",new ee),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?ye.ApplicationForeground:ye.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 Ee(r).toIsoString()))}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:ye.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 Ee(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:ye.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 Ee(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:ye.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 Ee(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),Oe=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Ae=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),Me=o()((function e(n){t()(this,e),s()(this,"token",void 0),s()(this,"tokenExpiring",void 0),this.token=new y(n),this.tokenExpiring=new y(!1)})),Ne=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 ee,this.channelDisposables=new ee,this.rendererDisposables=new ee,this.channelInitialization=new Date,this.videoElement=new y(null),this.state=new y(Pe.Initializing),this.autoMuted=new y(!1),this.autoPaused=new y(!1),this.authorized=new y(!0),this.online=new y(!0),this.loading=new y(!1),this.playing=new y(!1),this.standby=new y(!1),this.stopped=new y(!1),this.targetLag=new y(null!==(r=null==n?void 0:n.targetLag)&&void 0!==r?r:0),this.lag=new y(void 0),this.bitrateLimit=new y(0),this.resolution=new y(we.empty),this.failureCount=new y(0),this.endPoint=new y(null),this.stream=new y(null),this.rtcStatistics=new y(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=Se.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return Pe.Starting;case"no-stream":case"not-found":return Pe.StandBy;case"geo-restricted":return Pe.GeoRestricted;case"geo-blocked":return Pe.GeoBlocked;case"unauthorized":return Pe.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Pe.Recovering;case"forbidden-tag":return Pe.ConfigurationError;case"port-in-range-not-found":return Pe.TransientConfigurationError;case"failed":return Pe.Error;default:q(e)}}}])}(),Ve=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(fe()(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"}}}])}(),Ue=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(fe()(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"}}}])}(),Be=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 y(n.hasInsertableStreams),this.hasEncodedInsertableStreams=new y(n.hasEncodedInsertableStreams),this.videoStreamTransformCallback=n.videoStreamTransformCallback,this.audioStreamTransformCallback=n.audioStreamTransformCallback,this.encodedVideoStreamSink=n.encodedVideoStreamSink,this.encodedAudioStreamSink=n.encodedAudioStreamSink})),je=o()((function e(){t()(this,e),s()(this,"mediaStream",void 0),s()(this,"peerConnection",void 0),s()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new y(null),this.peerConnection=new y(null),this.peerConnectionReconnectAttempts=0})),He=o()((function e(){t()(this,e),s()(this,"isStarting",void 0),s()(this,"isDisposed",void 0),this.isStarting=new y(!1),this.isDisposed=!1})),ze=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 y(!1),this.shouldExtractTimestamps=new y(!1),this.isEnabled=new y(!1),this.decodedFrameTimingInformation=new y(null),this.renderedFrameTimingInformation=new y(null)})),Ge=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Ae.Normal:return"Normal";case Ae.Force:return"Force";case Ae.Reset:return"Reset";default:q(e)}}}])}(),We=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Oe.Keep:return"Keep";case Oe.Reset:return"Reset";default:q(e)}}}])}(),qe=function(){return o()((function e(n,r){if(t()(this,e),s()(this,"_logger",Q.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=A()(N().mark((function e(){var t,n,r,i,o=this;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,Promise.race([w.value.fetch(t,{method:"GET",cache:"no-cache"}),new Promise((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:(p=A()(N().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,f,p,m,v=this;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=Y.parseToken(t).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",t),e.abrupt("return",{status:"unauthorized"});case 4:return o=this.buildUrl([i,"stream","subscribe"]).toString(),a=new w.value.FormData,s=U.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,Promise.race([w.value.fetch(o,{method:"POST",body:a}),new Promise((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"===(f=this.mapHttpStatusToSubscribeStatus(d))){e.next=23;break}return e.abrupt("return",{status:f});case 23:return p=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,p-l),e.abrupt("return",m);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n){return p.apply(this,arguments)})},{key:"publish",value:(f=A()(N().mark((function e(t,n,r,i){var o,a,s,u,c,l,d,h,f,p,m,v,g=this;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=Y.parseToken(n).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",n),e.abrupt("return",{status:"unauthorized"});case 4:return a=this.buildUrl([o,"stream","publish"]).toString(),s=new w.value.FormData,u=U.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,f=null,e.next=13,Promise.race([w.value.fetch(a,{method:"POST",body:s}),new Promise((function(e){return f=w.value.setTimeout((function(){g._logger.error("Failed to publish",new Error("Publish timed out [".concat(a,"]"))),e({status:408})}),g._timeout)}))]).finally((function(){f&&w.value.clearTimeout(f)}));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"===(p=this.mapHttpStatusToPublishStatus(h))){e.next=23;break}return e.abrupt("return",{status:p});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 f.apply(this,arguments)})},{key:"setRemoteDescription",value:(h=A()(N().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return N().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,Promise.race([w.value.fetch(r,{method:"POST",body:i}),new Promise((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=A()(N().mark((function e(t,n,r,i,o){var a,s,u,c,l,d,h,f,p=this;return N().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:We.convertBitrateStateToBitrateStateType(i),bitrateMode:Ge.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,d=null,e.next=9,Promise.race([w.value.fetch(a,{method:"POST",body:s}),new Promise((function(e){return d=w.value.setTimeout((function(){p._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(a,"]"))),e({status:408})}),p._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),f=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",h,f-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=A()(N().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,f,p=this,m=arguments;return N().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,Promise.race([w.value.fetch(o,{method:"POST",body:a}),new Promise((function(e){return l=w.value.setTimeout((function(){p._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(o,"]"))),e({status:408})}),p._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 f=e.sent,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",f,h-u),e.abrupt("return",f);case 26:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e,t,n){return l.apply(this,arguments)})},{key:"destroyStream",value:(c=A()(N().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return N().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,Promise.race([w.value.fetch(r,{method:"POST",body:i,cache:"no-cache"}),new Promise((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=A()(N().mark((function e(t,n){var r,i,o,a;return N().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,me()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new w.value.URL(this._uri),t=U.sdkVersion,n=ue.discoveryParameters.intentions;return e.searchParams.set("type","http"),e.searchParams.set("version",t),e.searchParams.set("intentions",n),e.searchParams.set("_","".concat(Date.now())),e.toString()}},{key:"mapHttpStatusToPublishStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 406:return"missing-channel-or-room-id";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSubscribeStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 402:return"geo-restricted";case 403:return"geo-blocked";case 408:return"timeout";case 409:return"port-in-range-not-found";case 415:return"forbidden-tag";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetRemoteDescriptionStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetTemporaryMaximalBitrateStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToAddIceCandidatesStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"mapHttpStatusToSetDestroyStreamStatus",value:function(e){if(!e)return"failed";switch(e.status){case 200:return"ok";case 401:return"unauthorized";case 408:return"timeout";case 503:return"capacity";case 504:return"rate-limited";default:return"failed"}}},{key:"convertHttpResponseToSubscribeResponse",value:(a=A()(N().mark((function e(t,n){var r,i;return N().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=A()(N().mark((function e(t,n){var r,i;return N().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=A()(N().mark((function e(t){var n,r;return N().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=A()(N().mark((function e(t){var n,r;return N().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=A()(N().mark((function e(t){var n,r;return N().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,f,p,m}(),Je=function(){return o()((function e(n){if(t()(this,e),s()(this,"_logger",Q.getLogger("Discovery")),s()(this,"_metricsService",void 0),s()(this,"_uri",void 0),!n)throw new Error("Discovery requires uri");this._metricsService=Ce.getMetricsService(n.toString()),this._uri=n}),[{key:"discoverNearbyEndPoints",value:(n=A()(N().mark((function e(t,n){var r,i,o,a;return N().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,Promise.race([w.value.fetch(r,{method:"GET",cache:"no-cache"}),new Promise((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=A()(N().mark((function e(){var t,n,r,i,o,a,s=this,u=arguments;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=ce.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new w.value.URL(n),t);case 4:return r=e.sent,i=0,o=function(){return new Promise((function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))}))},e.next=9,Promise.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:ye.RoundTripTime,runtime:(n-Se.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}(),Ke=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=A()(N().mark((function t(){return N().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){w.subscribe((function(n){if(n){var r=new n.URL(Se.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=A()(N().mark((function t(n){var r,i,o;return N().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 Je(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()(Ke,"_cache",{}),Ke.precacheClosestEndPointDiscovery();var Ze=function(e){return e[e.NetworkEmpty=0]="NetworkEmpty",e[e.NetworkIdle=1]="NetworkIdle",e[e.NetworkLoading=2]="NetworkLoading",e[e.NetworkNoSource=3]="NetworkNoSource",e}({});function Qe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function $e(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qe(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Xe=function(){return o()((function e(n,r,i,o,a,u){t()(this,e),s()(this,"_logger",Q.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(ot.phenixWebPlayer){var t,n,r=$e($e({},this._options),{},{bandwidthToStartAt:3e6});return this._player=new ot.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===ot.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 ot.phenixWebPlayer&&ot.phenixWebPlayer.isSupported}},{key:"getStats",value:function(){var e,t;if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:Ze.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=Ze.NetworkLoading:n.currentTime>0?n.networkState=Ze.NetworkIdle:n.video?n.networkState=Ze.NetworkEmpty:n.networkState=Ze.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 Ye(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 et(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ye(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ye(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var tt=function(){return o()((function e(n,r,i,o,a,u){t()(this,e),s()(this,"_logger",Q.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 ee,this._monitoredStatistics={estimatedBandwidth:0,playTime:0},this._player=null}),[{key:"start",value:function(){if(ot.shaka)return this._player=new ot.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:Ze.NetworkNoSource,dataBuffered:0};var e=et(et({},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=Ze.NetworkLoading:e.playTime&&e.playTime>0&&this._monitoredStatistics.playTime&&this._monitoredStatistics.playTime<e.playTime?e.networkState=Ze.NetworkIdle:e.video?e.networkState=Ze.NetworkEmpty:e.networkState=Ze.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 p((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)}))}}])}(),nt=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(){ot.hlsPlayer&&(ot.hlsPlayer.isSupported()?(this._player=new ot.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 ot.hlsPlayer&&ot.hlsPlayer.isSupported()}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:Ze.NetworkNoSource,dataBuffered:0};var e={width:this._player.media.offsetWidth,height:this._player.media.offsetHeight,currentTime:this._player.media.currentTime,lag:0,networkState:Ze.NetworkIdle,dataBuffered:0};this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0)),"IDLE"===this._player.streamController.state?e.networkState=Ze.NetworkIdle:"ERROR"===this._player.streamController.state||"ENDED"===this._player.streamController.state?e.networkState=Ze.NetworkNoSource:this._player.streamController.state.includes("LOADING")||this._player.streamController.state.includes("WAITING")?e.networkState=Ze.NetworkLoading:e.networkState=Ze.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)}}])}();function rt(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 it(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rt(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ot=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=A()(N().mark((function e(t,n,r,i,o){var a=this;return N().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(Se.webPlayerLoader||Se.shakaPlayerLoader||Se.hlsJsLoader){e.next=5;break}throw new Error("Unsupported-feature, add stream player");case 5:return e.abrupt("return",new Promise((function(e){Se.hlsJsLoader&&(a._pending=!0,Se.hlsJsLoader((function(i){a._hlsPlayer=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))}))),Se.webPlayerLoader&&(a._pending=!0,Se.webPlayerLoader((function(i){a._phenixWebPlayer=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))}))),Se.shakaPlayerLoader&&(a._pending=!0,Se.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=A()(N().mark((function e(t,n,r,i,o,a){var s,u,c,l;return N().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&&!T.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&&T.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(nt,e,t,n,it(it({},this._options),{},{preferNative:T.shouldUseNativeHls}),r):this._phenixWebPlayer?this.play(Xe,e,t,n,it(it({},this._options),{},{preferNative:T.shouldUseNativeHls}),r):this.play(tt,e,t,n,it(it({},this._options),{},{preferNative:T.shouldUseNativeHls}),r)}}]);var e,n}();s()(ot,"_pending",!1),s()(ot,"_hlsPlayer",void 0),s()(ot,"_phenixWebPlayer",void 0),s()(ot,"_shaka",void 0),s()(ot,"_options",void 0),s()(ot,"_player",void 0);var at=function(e){return e[e.Live=1]="Live",e[e.OndDemand=2]="OndDemand",e}(at||{}),st=at,ut=function(){return o()((function e(n,r,i){t()(this,e),s()(this,"_logger",Q.getLogger("ChunkedStream")),s()(this,"_channelContext",void 0),s()(this,"_chunkedStreamPlaybackMode",void 0),s()(this,"_disposables",new ee),s()(this,"_monitorDisposables",new ee),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 Ke.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=Pe.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?ot.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=Pe.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=Pe.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=Pe.Stopped))}))}},{key:"retryOnStreamFailure",value:function(){var e=this;this._monitorFailureCount=0,this._channelContext.state.value=Pe.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=ot.getStats();if(t._chunkedStreamPlaybackMode!==st.Live||(null==s?void 0:s.networkState)!==Ze.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===Pe.Playing&&(t._channelContext.state.value=Pe.Paused),null!==(a=t._channelContext.videoElement.value)&&void 0!==a&&a.paused||t._channelContext.state.value===Pe.Playing||(t._channelContext.state.value=Pe.Playing),t._streamStatistics=s,t.monitor(e)}else t.retryOnStreamFailure()}),1e3);this._monitorDisposables.add(new p((function(){w.value.clearTimeout(n)})))}},{key:"dispose",value:function(){this._disposables.dispose(),this._monitorDisposables.dispose()}}])}(),ct=n(715),lt=n.n(ct),dt=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]}}])}(),ht=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}}])}(),ft=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 y({})),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(!T.getCurrentOfferDisabled&&null!==(o=this._peerConnection)&&void 0!==o&&null!==(a=o.currentRemoteDescription)&&void 0!==a&&a.sdp){var u=new dt(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=A()(N().mark((function e(){var t,n,r=this;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!T.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,f,p,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===(f=h[s])||void 0===f?void 0:f.timestamp)||0),y=v&&g?Math.floor(8*v/g*1e3):0;if(t[s]={ssrc:a.ssrc,mediaType:s,timestamp:a.timestamp,bitrate:y,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!==(p=r._rtcStatistic.value)&&void 0!==p&&null!==(m=p.video)&&void 0!==m&&m.framesDecoded){t[s].framesDecoded=a.framesDecoded;var _=(a.framesDecoded-r._rtcStatistic.value.video.framesDecoded)/(t[s].timestamp-r._rtcStatistic.value.video.timestamp)*1e3;t[s].fps=_?Math.round(100*_)/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=A()(N().mark((function e(){var t,n=this;return N().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}(),pt=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}(pt||{}),mt=pt,vt=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}}])}(),gt=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}}])}(),yt=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}(yt||{}),_t=function(){return o()((function e(){t()(this,e)}),[{key:"parse",value:function(e,t){var n=new vt(gt.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 yt.ProgressiveFrame:case yt.TopField:case yt.BottomField:return 1;case yt.TopFieldBottomField:case yt.BottomFieldTopField:case yt.FrameDoubling:return 2;case yt.TopFieldBottomFieldTopFieldRepeated:case yt.BottomFieldTopFieldBottomFieldRepeated:case yt.FrameTripling:return 3;default:return 0}}}])}();function bt(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 Ct=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 p((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 bt(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)?bt(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()}}])}(),kt=function(){return o()((function e(){t()(this,e),s()(this,"_eventEmitters",new Map),s()(this,"_onEventWithNoSubscriberHandlers",new Set),s()(this,"_disposables",new ee)}),[{key:"onEventWithNoSubscriber",value:function(e){var t=this;return this._onEventWithNoSubscriberHandlers.add(e),new p((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 Ct;return this._eventEmitters.set(e,t),t}}])}(),St=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}({}),wt=function(){return o()((function e(n){t()(this,e),s()(this,"_eventPublisher",void 0),s()(this,"_disposables",new ee),this._eventPublisher=n}),[{key:"subscribeToNalUnit",value:function(e,t){return this._eventPublisher.subscribe(St.NalUnit,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToSeiPayloadType",value:function(e,t){return this._eventPublisher.subscribe(St.SeiPayload,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToPayload",value:function(e,t,n){return this._eventPublisher.publish(St.PayloadSubscription,{context:e,data:t}),this._eventPublisher.subscribe(St.Payload,(function(e){e.data.uuid===t&&n(e)}))}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),xt=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("")}}])}(),Tt=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}(Tt||{}),Pt=Tt,Et=function(){function e(n,r){t()(this,e),s()(this,"_eventPublisher",void 0),s()(this,"_vclExtractionStrategy",void 0),s()(this,"_disposables",new ee),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(St.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===mt.UserDataUnregistered&&this.handleSeiPayloadUserDataUnregistered(e,t)}},{key:"handleSeiPayloadUserDataUnregistered",value:function(e,t){var n=xt.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(St.NalUnit,{context:e,data:t})}},{key:"publishSeiPayload",value:function(e,t){this._eventPublisher.publish(St.SeiPayload,{context:e,data:t})}},{key:"publishPayload",value:function(e,t){this._eventPublisher.publish(St.Payload,{context:e,data:t})}},{key:"notifyEndOfChunk",value:function(e){this._eventPublisher.publish(St.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 Pt.SliceLayerNonIdrData:case Pt.SliceDataPartitionALayer:case Pt.SliceDataPartitionBLayer:case Pt.SliceDataPartitionCLayer:case Pt.SliceLayerIdrData:n=this._vclExtractionStrategy.extractVclNalUnit(e,i);break;case Pt.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=[];!xt.isDataAtOffsetTargetByteSequence(e._seiPayload4ByteEndCode,t,r)&&!xt.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+gt.getOffsetWithExpandedEmulationPreventionBytes(e,n,o);return{payloadType:i,payload:e.subarray(n,a),endIndex:a}}}],[{key:"findAnnexBStartIndexFromOffset",value:function(t,n,r){var i=xt.findTargetByteSequenceIndexFromOffset(e.annexB4ByteStartCode,t,n,r);return i!==r?i:xt.findTargetByteSequenceIndexFromOffset(e.annexB3ByteStartCode,t,n,r)}}])}();s()(Et,"annexB3ByteStartCode",new Uint8Array([0,0,1])),s()(Et,"annexB4ByteStartCode",new Uint8Array([0,0,0,1])),s()(Et,"_seiPayload3ByteEndCode",new Uint8Array([128,0,0,1])),s()(Et,"_seiPayload4ByteEndCode",new Uint8Array([128,0,0,0,1]));var Ft=function(){return o()((function e(){t()(this,e)}),[{key:"extractVclNalUnit",value:function(e,t){var n=Et.findAnnexBStartIndexFromOffset(e,t,e.byteLength);return{nalUnitData:e.subarray(t,n)}}}])}(),It=function(){function e(){t()(this,e)}return o()(e,[{key:"extractVclNalUnit",value:function(t,n){var r=n+Et.annexB4ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;if(xt.isDataAtOffsetTargetByteSequence(Et.annexB4ByteStartCode,t,r))return{nalUnitData:t.subarray(n+Et.annexB4ByteStartCode.byteLength,r)};var i=n+Et.annexB3ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;return xt.isDataAtOffsetTargetByteSequence(Et.annexB3ByteStartCode,t,i)?{nalUnitData:t.subarray(n+Et.annexB3ByteStartCode.byteLength,i)}:{nalUnitData:t.subarray(n)}}}])}();s()(It,"_truncatedVclNalUnitByteLength",32);var Lt=function(){},Dt=function(){function e(n){t()(this,e),s()(this,"_logger",Q.getLogger("PhenixEmbeddedIsoBmff2023")),s()(this,"_eventPublisher",void 0),s()(this,"_expectedPayloadUuid",new Set),s()(this,"_endOfChunkHandlersByTrackId",new Map),s()(this,"_disposables",new ee),s()(this,"_enableWarningLogWhenVclEmbeddedDataNotFound",new p(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(St.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(St.PayloadSubscription,(function(t){var n=t.data;return e._expectedPayloadUuid.add(n)}))}},{key:"subscribeToEncodedVideoStreamChunkEvents",value:function(){return this._eventPublisher.subscribe(St.EncodedVideoStreamChunk,this.armLoggingNoVclEmbeddedDataFound.bind(this))}},{key:"subscribeToNalUnitEvents",value:function(){return this._eventPublisher.subscribe(St.NalUnit,this.handleNalUnitEvent.bind(this))}},{key:"handleNalUnitEvent",value:function(t){var n=t.context,r=t.data;r.type>Pt.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(St.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,Lt)}},{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(St.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(St.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()(Dt,"_truncatedVclNalUnitDataByteLength",32),s()(Dt,"_phenixVclEmbeddedDataUuid","00000000-0000-0000-0000-000000000000"),s()(Dt,"_phenixInitializationSegmentUuid","511e22bd-34c0-4cee-b6c3-3c4d407622c7");var Rt=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 ee),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(St.EncodedVideoStreamChunk,e)}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),Ot=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 ee,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)}}])}(),At=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 kt,t=new wt(e),n=new Et(e,new Ft);return new Rt(e,t,n)}},{key:"createPhenixH264EmbeddedIsoBmff2023VideoBitstreamDecoder",value:function(){var e=new kt,t=new wt(e),n=new Et(e,new It),r=new Rt(e,t,n),i=new Dt(e);return new Ot(r,i)}}])}();function Mt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Nt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Mt(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Mt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Vt(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 Ut,Bt=function(){function e(n,r){var i=this;t()(this,e),s()(this,"_channelContext",void 0),s()(this,"_frameTimingInformationContext",void 0),s()(this,"_bitstreamDecoder",At.createH264VideoBitstreamDecoder()),s()(this,"_frameTimingsByRtpTimestamp",new Map),s()(this,"_picturingTimingParsingConfig",{cpbDpbDelaysPresentFlag:!1,picStructPresentFlag:!0}),s()(this,"_pictureTimingParser",new _t),s()(this,"_videoElementDisposables",new ee),s()(this,"_currentPlaybackState","waiting"),s()(this,"_armedVideoFrameCallbackId",null),s()(this,"_disposables",new ee),s()(this,"_disposed",!1),this._channelContext=n,this._frameTimingInformationContext=r,this._disposables.add(this._bitstreamDecoder),this._disposables.add(new p((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(mt.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 Vt(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)?Vt(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=lt()(r.value,2),s=a[0],u=a[1];if(parseInt(s,10)>n)break;"playing"===this._currentPlaybackState&&(this._frameTimingInformationContext.renderedFrameTimingInformation.value=Nt(Nt({},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 p((function(){return e.removeEventListener("playing",n)})));var r=function(){return t._currentPlaybackState="paused"};e.addEventListener("pause",r),this._videoElementDisposables.add(new p((function(){return e.removeEventListener("pause",r)})));var i=function(){return t._currentPlaybackState="stalled"};e.addEventListener("stalled",i),this._videoElementDisposables.add(new p((function(){return e.removeEventListener("stalled",i)})));var o=function(){return t._currentPlaybackState="waiting"};e.addEventListener("waiting",o),this._videoElementDisposables.add(new p((function(){return e.removeEventListener("waiting",o)})));var a=function(){return t._currentPlaybackState="ended"};e.addEventListener("ended",a),this._videoElementDisposables.add(new p((function(){return e.removeEventListener("ended",a)})));var s=function(){return t._currentPlaybackState="error"};e.addEventListener("error",s),this._videoElementDisposables.add(new p((function(){return e.removeEventListener("error",s)}))),this.armVideoFrameCallback(),this._videoElementDisposables.add(new p((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()(Bt,"MAX_FRAME_TIMING_ENTRIES",1800);var jt=Symbol(),Ht=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)?jt: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?jt: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}}])}();Ut=Ht,s()(Ht,"_isSafari","Safari"===x.browserName),s()(Ht,"_isMobileChrome","Chrome"===x.browserName&&x.isMobile()),s()(Ht,"_isAndroidChrome","Chrome"===x.browserName&&x.isAndroid),s()(Ht,"_singleZeroByte",new Uint8Array([0])),s()(Ht,"_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()(Ht,"_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()(Ht,"_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()(Ht,"_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(me()(new Uint8Array(40).fill(255)),[95],me()(new Uint8Array(10295).fill(255)),[128,0,0,0,1,101,136,132,5],me()(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(me()(new Uint8Array(40).fill(255)),[164],me()(new Uint8Array(10364).fill(255)),[128,0,0,0,1,65,154,32,21,240,75]))}),s()(Ht,"_dummy82x82H264PFrameFrameNumberIndex",10418),s()(Ht,"_surrogate82x82PFrameFrameNumberReset",1),s()(Ht,"_useUpdateSurrogate82x82PFrameFrameNumber",Ut._isMobileChrome||Ut._isSafari),s()(Ht,"_surrogate82x82PFrameFrameNumber",Ut._surrogate82x82PFrameFrameNumberReset);var zt=n(131),Gt=n.n(zt);function Wt(){return Gt()('(()=>{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 qt=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 ee,s=new y(null),u=new y(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(T.isRTCRtpScriptTransformSupported){var h=Wt();h.onmessage=function(){var t=A()(N().mark((function t(r){return N().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 p((function(){h.terminate()})));break}var f=function(){var t=A()(N().mark((function t(r,o){var a;return N().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?Ht.getInvalidSurrogateVideoIFrame(i):Ht.getInvalidSurrogateVideoPFrame(i))!==jt){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=Ht.getSurrogateVideoIFramePerCodec(i)||r.data:r.data=Ht.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:f}),v=c.createEncodedStreams(),g=v.readable,y=v.writable;g.pipeThrough(m).pipeTo(y);break;case"audio":var _=!!r;if(T.isRTCRtpScriptTransformSupported){var b=Wt();b.onmessage=function(){var t=A()(N().mark((function t(n){return N().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n.data.chunk},t.t0=_,!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:_});var C=new MediaStream,k=new Audio;k.srcObject=C,document.body.appendChild(k),a.add(new p((function(){b.terminate(),document.body.removeChild(k)})));break}var S=function(){var t=A()(N().mark((function t(n,i){return N().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n},!_){t.next=9;break}return t.next=4,r(e,n);case 4:if(t.sent){t.next=8;break}n.data=Ht.getInvalidSurrogateAudioData(),t.next=9;break;case 8:n.data=Ht.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)}}(),w=new TransformStream({transform:S}),x=c.createEncodedStreams(),P=x.readable,E=x.writable;P.pipeThrough(w).pipeTo(E);break;default:q(l)}})),{disposables:a,encodedVideoFrame:s,encodedAudioFrame:u}}},{key:"configureInsertableStreamTransformation",value:function(e,t,n){var r=new MediaStream,i=new ee;return e.getTracks().forEach((function(e){var o=e.kind;switch(o){case"video":if(t){var a=e,s=new TransformStream({transform:function(n,r){t(e,n,r)}}),u=new MediaStreamTrackProcessor({track:a}),c=new MediaStreamTrackGenerator({kind:a.kind}),l=u.readable,d=c.writable;l.pipeThrough(s).pipeTo(d),r.addTrack(c),i.add(new p((function(){r.removeTrack(c)})))}else r.addTrack(e);break;case"audio":if(n){var h=e,f=new TransformStream({transform:function(t,r){n(e,t,r)}}),m=new MediaStreamTrackProcessor({track:h}),v=new MediaStreamTrackGenerator({kind:h.kind}),g=m.readable,y=v.writable;g.pipeThrough(f).pipeTo(y),r.addTrack(v);var _=new MediaStream,b=new Audio;_.addTrack(e),b.srcObject=_,document.body.appendChild(b),i.add(new p((function(){r.removeTrack(v),document.body.removeChild(b)})))}else r.addTrack(e);break;default:q(o)}})),{transformedStream:r,disposables:i}}}])}();function Jt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Kt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Jt(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Zt=function(){return o()((function e(n,r,i,o,a){t()(this,e),s()(this,"_logger",Q.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 ee,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 Promise.all([Ke.discoverClosestEndPointWithCaching(e),oe.createPeerConnectionOffer("recvonly",o).then((function(e){var t=e.localOffer,n=e.peerConnection;return i._peerConnectionContext.peerConnection.value=n,{localOffer:t,peerConnection:n}}))]).then((function(e){var n=lt()(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),!T.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration?r.subscribe(t,a,i._channelContext.failureCount.value):(s.close(),s.dispose(),!Se.forceGarbageCollectionOnRestart||T.isMobile&&Se.skipGarbageCollectionOnMobileDevices||xe.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||Se.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=Pe.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:q(e.iceConnectionState)}}};var f=new Promise((function(t,n){if(!T.onTrackDisabled){var r=w.value.setTimeout((function(){return n(new Error("Stream setup timed out"))}),3e4);return i._disposables.add(new p((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 p((function(){return w.value.clearTimeout(a)})))}));return new Promise((function(e){e()})).then((function(){if(u)return i._logger.info("[%s] Set local SDP offer [%s]",i._channelContext.streamId,u.sessionDescription.sdp),e.setLocalDescription(u.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,u.sessionDescription,e.message),e}))})).then((function(){if(l)return i._logger.info("[%s] Set remote SDP answer [%s]",i._channelContext.streamId,l.sessionDescription.sdp),e.setRemoteDescription(l.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,l.sessionDescription,e.message),e}))})).then((function(){if(c)return i._logger.info("[%s] Set remote SDP offer [%s]",i._channelContext.streamId,c.sessionDescription.sdp),e.setRemoteDescription(c.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,c.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})})).then((function(e){return i._logger.info("[%s] Set local SDP answer [%j]",i._channelContext.streamId,e),i._channelContext.endPoint.value.setRemoteDescription(a,e)})).then((function(t){var n=t.status,r=t.sessionDescription;return i._channelContext.state.value=i.mapSetRemoteDescriptionStatusToChannelStatus(n),"ok"!==n?(i._channelContext.playing.value=!1,i._channelContext.standby.value=!0,void(i._channelContext.stopped.value=!1)):e.setLocalDescription(r).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,r,e.message),e}))}))})).then((function(){return n.success(i._channelContext.streamId),f})).then((function(t){var n,a;if(o&&null!=e&&null!==(n=e.currentRemoteDescription)&&void 0!==n&&n.sdp){var s=new dt(e.currentRemoteDescription.sdp),u=e.getReceivers(),c=qt.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 Bt(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 f=qt.configureInsertableStreamTransformation(t,i._streamTransformContext.videoStreamTransformCallback,i._streamTransformContext.audioStreamTransformCallback),p=f.transformedStream,m=f.disposables;i._disposables.add(m),t=p}i._peerConnectionContext.mediaStream.value=t;var v=new ft(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 Ee(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 Ee(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=Pe.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!==Pe.Reconnecting&&i._channelContext.state.value!==Pe.Offline)return;i._channelContext.state.value=i._channelContext.playing.value?Pe.Playing:Pe.Paused,i._logger.info("Channel state restored to [%s] after reconnecting",Pe[i._channelContext.state.value])}else i._channelContext.state.value=Pe.Offline}}));return i._disposables.add(g),Se.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=Pe.Paused))}))}))}))}},{key:"applyRtcConfiguration",value:(e=A()(N().mark((function e(t,n){var r;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=ht.truncateIceServers(n),e.abrupt("return",Se.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=Kt(Kt({},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=Pe.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<Se.maximalNumberOfPeerConnectionReconnectAttempts||!Se.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(T.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 Pe.Starting;case"unauthorized":return Pe.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return Pe.Recovering;case"failed":return Pe.Error;default:q(e)}}}]);var e}(),Qt=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=Y.parseToken(e).capabilities,s=a.includes("streaming"),u=a.includes("on-demand");return s||u?new ut(t,u?st.OndDemand:st.Live,o):new Zt(t,n,r,i,o)}}])}(),$t=function(){return o()((function e(n,r,i){var o=this;t()(this,e),s()(this,"_logger",Q.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=Y.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 Me(r),this._channelContext=new Ne(u),this._peerConnectionContext=new je,this._streamTransformContext=new Be(c),this._stateContext=new He,this._exponentialBackoff=new ve,this._channelStartTime=Date.now(),this._readOnlyPeerConnection=new _(this._peerConnectionContext.peerConnection),this._readOnlyState=new _(this._channelContext.state),this._readOnlyAutoMuted=new _(this._channelContext.autoMuted),this._readOnlyAutoPaused=new _(this._channelContext.autoPaused),this._readOnlyTokenExpiring=new _(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new _(this._channelContext.authorized),this._readOnlyOnline=new _(this._channelContext.online),this._readOnlyLoading=new _(this._channelContext.loading),this._readOnlyPlaying=new _(this._channelContext.playing),this._readOnlyStandby=new _(this._channelContext.standby),this._readOnlyStopped=new _(this._channelContext.stopped),this._readOnlyTargetLag=new _(this._channelContext.targetLag),this._readOnlyLag=new _(this._channelContext.lag),this._readOnlyBitrateLimit=new _(this._channelContext.bitrateLimit),this._readOnlyResolution=new _(this._channelContext.resolution),this._readOnlyFailureCount=new _(this._channelContext.failureCount),this._readOnlyEndPoint=new _(this._channelContext.endPoint),this._readOnlyStream=new _(this._channelContext.stream),this._readOnlyRtcStatistics=new _(this._channelContext.rtcStatistics),this._readOnlyMediaStream=new _(this._peerConnectionContext.mediaStream);var l=(a.uri||Se.discoveryUri.value).toString();Se.tenancy.value=a.tenancy||Se.tenancy.value,ce.uri.value=l,this._metricsService=Ce.getMetricsService(l),this._sessionTelemetry=new Re(Se.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=n,this._frameTimingInformationContext=new ze,this.configureFrameTimingInformation(a),this._readOnlyIsFrameTimingInformationEnabled=new _(this._frameTimingInformationContext.isEnabled),this._readOnlyDecodedFrameTimingInformation=new _(this._frameTimingInformationContext.decodedFrameTimingInformation),this._readOnlyRenderedFrameTimingInformation=new _(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=Se.clientSessionId,o.videoElement.dataset.streamId=o.streamId),o._channelContext.videoTelemetry=new Ie(o.streamId,Se.pageLoadTime,o._channelStartTime,o._metricsService),o._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(o.videoElement),o._channelContext.videoTelemetry.setupListenerForRebuffering(o.videoElement),o._channelContext.state.value===Pe.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===Pe.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,Oe.Keep,Ae.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 p((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!==Pe.Initializing&&(this._channelContext.state.value=Pe.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 we(e.videoWidth,e.videoHeight)):this._channelContext.resolution.value=we.empty}},{key:"token",get:function(){return this._tokenContext.token.value},set:function(e){this._channelContext.disposables.dispose(),this._tokenContext.token.value=e,this._tokenContext.tokenExpiring.value=!1;var t=Y.parseToken(this._tokenContext.token.value),n=(t.uri||Se.discoveryUri.value).toString();Se.tenancy.value=t.tenancy||Se.tenancy.value,ce.uri.value=n,this._metricsService=Ce.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,Oe.Keep,Ae.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=A()(N().mark((function e(t){var n=this;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((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=Pe.Stopped}},{key:"resume",value:(l=A()(N().mark((function e(){return N().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=A()(N().mark((function e(){var t=this;return N().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 Y.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",Se.discoveryUri.value),new w.value.URL(Se.discoveryUri.value))}},{key:"start",value:(u=A()(N().mark((function e(){return N().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=A()(N().mark((function e(){var t,n,r,i,o,a,s,u,c,l,d,h,f,m,v,g,y,_,b,C=this;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._channelContext.state.value=Pe.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),Y.isEncodedEdgeTokenValid(t)){e.next=10;break}return this._logger.error("Failed to parse token [%s]",t),this._channelContext.state.value=Pe.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=Ue.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=Pe.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=Ue.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=Pe.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=Ve.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=Pe.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=Ve.validateEncodedStreamSink("audio",this._streamTransformContext.encodedAudioStreamSink),f=h.valid,m=h.validationResult,f){e.next=42;break}return this._logger.error(m),this._channelContext.state.value=Pe.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=Pe.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=Pe.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(T.isInsertableStreamsSupported){e.next=63;break}return this._logger.error("Browser does not support Media Stream Track API"),this._channelContext.state.value=Pe.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=Pe.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=Pe.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(T.isEncodedInsertableStreamsSupported||T.isRTCRtpScriptTransformSupported){e.next=84;break}return this._logger.error("Browser does not support encodedInsertableStreams API"),this._channelContext.state.value=Pe.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=Pe.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=Pe.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 98:if(this._channelContext.loading.value=!0,y=this.getUri(t),this._channelContext.disposables.add(this._channelContext.state.subscribe((function(e){e!==Pe.Error&&e!==Pe.Recovering||Ke.clearCachedClosestEndpoint(y)}))),_=function(){return new Promise((function(e){return C._stateContext.isStarting.value=!1,e(C.handleStreamFailure())}))},b=Qt.create(t,this._channelContext,this._peerConnectionContext,this._streamTransformContext,this._frameTimingInformationContext,_)){e.next=106;break}return this._stateContext.isStarting.value=!1,e.abrupt("return");case 106:return e.abrupt("return",b.start(y,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=Pe.ClientStartError,C._logger.error("Failed to start channel",e)})).finally((function(){if(C._stateContext.isStarting.value=!1,C._channelContext.state.value!==Pe.Playing&&Se.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 p((function(){w.value.clearTimeout(e)})))}})));case 107:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"restartAfterStop",value:(i=A()(N().mark((function e(){return N().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=A()(N().mark((function e(){var t;return N().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 Pe.Initializing:case Pe.StandBy:case Pe.Offline:return 15e3;case Pe.Error:case Pe.Recovering:case Pe.Unauthorized:case Pe.GeoRestricted:case Pe.GeoBlocked:case Pe.Stopped:case Pe.Starting:case Pe.Playing:case Pe.Paused:case Pe.Reconnecting:case Pe.UnsupportedFeature:case Pe.ConfigurationError:case Pe.TransientConfigurationError:case Pe.ConnectionError:case Pe.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._channelContext.failureCount.value);default:q(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(n=A()(N().mark((function e(){return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._channelContext.state.value,e.next=e.t0===Pe.Error||e.t0===Pe.Reconnecting||e.t0===Pe.StandBy||e.t0===Pe.Offline||e.t0===Pe.Recovering||e.t0===Pe.TransientConfigurationError||e.t0===Pe.ConnectionError||e.t0===Pe.ClientStartError?3:e.t0===Pe.Unauthorized?5:e.t0===Pe.GeoRestricted?7:e.t0===Pe.GeoBlocked?9:e.t0===Pe.Stopped?11:e.t0===Pe.Initializing?13:e.t0===Pe.Playing?15:e.t0===Pe.Paused?17:e.t0===Pe.Starting?19:e.t0===Pe.UnsupportedFeature?21:e.t0===Pe.ConfigurationError?23:25;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,Pe[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:q(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(),!Se.forceGarbageCollectionOnRestart||T.isMobile&&Se.skipGarbageCollectionOnMobileDevices||xe.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?T.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=A()(N().mark((function e(t){var n,r,i=this;return N().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=Pe.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=Pe.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=Pe.Playing})).catch((function(e){var r=!!t.getTracks().filter((function(e){return"audio"===e.kind})).length,o=!Se.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=Pe.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=Pe.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=Pe.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}(),Xt=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(!Se.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 $t(e.videoElement,e.token,t)}},{key:"isFrameTimingInformationSupported",get:function(){return T.isChannelFrameTimingInformationSupported}}])}(),Yt={SDK:Se,Channels:Xt,ChannelState:Pe}})(),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={131: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=>{function t(e,t,n,r,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}e.exports=function(e){return function(){var n=this,r=arguments;return new Promise((function(i,o){var a=e.apply(n,r);function s(e){t(a,i,o,s,u,"next",e)}function u(e){t(a,i,o,s,u,"throw",e)}s(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},383:e=>{e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},579:(e,t,n)=>{var 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(738).default;function i(){"use strict";e.exports=i=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},o=Object.prototype,a=o.hasOwnProperty,s=Object.defineProperty||function(e,t,n){e[t]=n.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",d=u.toStringTag||"@@toStringTag";function h(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(t){h=function(e,t,n){return e[t]=n}}function f(e,t,n,r){var i=t&&t.prototype instanceof b?t:b,o=Object.create(i.prototype),a=new R(r||[]);return s(o,"_invoke",{value:F(e,n,a)}),o}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=f;var m="suspendedStart",v="suspendedYield",g="executing",y="completed",_={};function b(){}function C(){}function k(){}var S={};h(S,c,(function(){return this}));var w=Object.getPrototypeOf,x=w&&w(w(O([])));x&&x!==o&&a.call(x,c)&&(S=x);var T=k.prototype=b.prototype=Object.create(S);function P(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function n(i,o,s,u){var c=p(e[i],e,o);if("throw"!==c.type){var l=c.arg,d=l.value;return d&&"object"==r(d)&&a.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):t.resolve(d).then((function(e){l.value=e,s(l)}),(function(e){return n("throw",e,s,u)}))}u(c.arg)}var i;s(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}})}function F(e,n,r){var i=m;return function(o,a){if(i===g)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=I(s,r);if(u){if(u===_)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===m)throw i=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=g;var c=p(e,n,r);if("normal"===c.type){if(i=r.done?y:v,c.arg===_)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=y,r.method="throw",r.arg=c.arg)}}}function I(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,I(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),_;var o=p(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,_;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,_):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,_)}function L(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function D(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(L,this),this.reset(!0)}function O(e){if(e||""===e){var n=e[c];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(a.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(r(e)+" is not iterable")}return C.prototype=k,s(T,"constructor",{value:k,configurable:!0}),s(k,"constructor",{value:C,configurable:!0}),C.displayName=h(k,d,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===C||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,k):(e.__proto__=k,h(e,d,"GeneratorFunction")),e.prototype=Object.create(T),e},n.awrap=function(e){return{__await:e}},P(E.prototype),h(E.prototype,l,(function(){return this})),n.AsyncIterator=E,n.async=function(e,t,r,i,o){void 0===o&&(o=Promise);var a=new E(f(e,t,r,i),o);return n.isGeneratorFunction(t)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},P(T),h(T,d,"Generator"),h(T,c,(function(){return this})),h(T,"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=O,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(D),!e)for(var n in this)"t"===n.charAt(0)&&a.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 s.type="throw",s.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],s=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=a.call(o,"catchLoc"),c=a.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&&a.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,_):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),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),D(n),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;D(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:O(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),_}},n}e.exports=i,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:()=>Fe,Channels:()=>en,SDK:()=>xe,default:()=>tn});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),f=n.n(h),p=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 f()(n,e),o()(n)}(p),y=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)}}])}(),_=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=function(){function e(n){t()(this,e),s()(this,"_document",void 0),s()(this,"_location",void 0),s()(this,"_navigator",void 0),s()(this,"_window",void 0),this._document=n.document,this._location=n.location,this._navigator=n.navigator,this._window=n.window}return o()(e,[{key:"FormData",get:function(){return this._window.FormData}},{key:"HTMLVideoElement",get:function(){return this._window.HTMLVideoElement}},{key:"MediaStream",get:function(){return this._window.MediaStream}},{key:"MediaStreamTrack",get:function(){return this._window.MediaStreamTrack}},{key:"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(t){if(this._instance.value)throw new Error("GlobalScope can only be set one time");this._instance.value=new e(t)}},{key:"getInstance",value:function(){return e._readOnlyInstance}},{key:"subscribe",value:function(t){return e._readOnlyInstance.subscribe(t)}}])}();v=b,s()(b,"_instance",new y(null)),s()(b,"_readOnlyInstance",new _(v._instance));var C,k,S,w=b.getInstance(),x=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""}}])}();C=x,s()(x,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),s()(x,"_browserNameAndVersion",C.parseBrowserNameAndVersion()),s()(x,"_browserName",C.parseBrowserName()),s()(x,"_browserMajorVersion",C.parseBrowserMajorVersion()),s()(x,"_isMobile",/Android|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(null===(k=navigator)||void 0===k?void 0:k.userAgent)),s()(x,"_isAndroid",/Android/i.test(null===(S=navigator)||void 0===S?void 0:S.userAgent)),s()(x,"_isChrome69",C._browserNameAndVersion.includes("Chrome/69.")),s()(x,"_isChrome70",C._browserNameAndVersion.includes("Chrome/70.")),s()(x,"_isChrome71",C._browserNameAndVersion.includes("Chrome/71.")),s()(x,"_isChrome72",C._browserNameAndVersion.includes("Chrome/72.")),s()(x,"_isChrome74",C._browserNameAndVersion.includes("Chrome/74.")),s()(x,"_isChrome75",C._browserNameAndVersion.includes("Chrome/75.")),s()(x,"_isChrome76",C._browserNameAndVersion.includes("Chrome/76.")),s()(x,"_isChrome77",C._browserNameAndVersion.includes("Chrome/77."));var T=function(){function e(){t()(this,e)}return o()(e,null,[{key:"clientOfferDisabled",get:function(){return x.isChrome74||x.isChrome75||x.isChrome76||x.isChrome77}},{key:"getTransceiversDisabled",get:function(){return e.addTranceiverDisabled}},{key:"addTranceiverDisabled",get:function(){return x.isChrome69||x.isChrome70||x.isChrome71||x.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===x.browserName&&x.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===x.browserName&&x.browserMajorVersion<=69||"Firefox"===x.browserName&&x.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===x.browserName&&x.browserMajorVersion<=63||"Firefox"===x.browserName&&x.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===x.browserName&&x.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===x.browserName&&x.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===x.browserName||"SamsungBrowser"===x.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==x.browserName}},{key:"isForceChromeGarbageCollectionSupported",get:function(){var e;return"Chrome"===x.browserName&&"function"==typeof(null===(e=w.value)||void 0===e?void 0:e.documentCreateElement)}},{key:"isQueueMicrotaskSupported",get:function(){return"Chrome"===x.browserName&&x.browserMajorVersion>=71||"Firefox"===x.browserName&&x.browserMajorVersion>=69||"Safari"===x.browserName}},{key:"isMobile",get:function(){return x.isMobile()}},{key:"isInsertableStreamsSupported",get:function(){return!("undefined"==typeof MediaStreamTrackProcessor||"undefined"==typeof MediaStreamTrackGenerator)}},{key:"isEncodedInsertableStreamsSupported",get:function(){return"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams}},{key:"isRTCRtpScriptTransformSupported",get:function(){return"undefined"!=typeof RTCRtpScriptTransform}},{key:"isRequestVideoFrameCallbackSupported",get:function(){var e;return void 0!==(null===(e=w.value)||void 0===e?void 0:e.HTMLVideoElement.prototype.requestVideoFrameCallback)}},{key:"isChannelFrameTimingInformationSupported",get:function(){return e.isRequestVideoFrameCallbackSupported&&(e.isEncodedInsertableStreamsSupported||e.isRTCRtpScriptTransformSupported)}},{key:"errorStackAlsoHasErrorMessage",get:function(){return"Firefox"!==x.browserName&&"Safari"!==x.browserName}}])}(),P=function(e){return e[e.All=-1]="All",e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.Off=100]="Off",e}({}),E=function(){return o()((function e(n,r,i){t()(this,e),s()(this,"_category",void 0),s()(this,"_appenders",void 0),s()(this,"_threshold",void 0),this._category=n,this._appenders=r,this._threshold=i}),[{key:"category",get:function(){return this._category}},{key:"appenders",get:function(){return this._appenders}},{key:"threshold",get:function(){return this._threshold}},{key:"trace",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>P.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(P.Fatal,t)}}},{key:"log",value:function(e,t){var n=this,r=new Date,i=this.replacePlaceholders(t);this._appenders.value.forEach((function(t){t.log(e,i,n.category,r)}))}},{key:"replacePlaceholders",value:function(e){for(var t=this,n=e[0],r=0;n.indexOf&&e.length>1&&r>=0;)if((r=n.indexOf("%",r))>0)switch(n.substring(r+1,r+2)){case"%":n=n.substring(0,r)+n.substring(r+1),r++;break;case"s":case"d":e[0]=n=this.replaceArgument(this.toString(e[1]),n,r),e.splice(1,1);break;case"j":e[0]=n=this.replaceArgument(this.stringify(e[1]),n,r),e.splice(1,1);break;default:return e.toString()}return e.length>1&&(e=e.reduce((function(e,n,r,i){return r+1===i.length&&n instanceof Error?T.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}}])}(),F=function(){return o()((function e(){t()(this,e),s()(this,"_appenders",[])}),[{key:"value",get:function(){return this._appenders}},{key:"add",value:function(e){this._appenders.push(e)}},{key:"remove",value:function(e){this._appenders=this._appenders.reduce((function(t,n){return n!==e&&t.push(n),t}),[])}}])}(),I=function(){return o()((function e(){t()(this,e)}),null,[{key:"sendLocalCandidates",get:function(){return this._sendLocalCandidates}},{key:"sendLogs",get:function(){return this._sendLogs}},{key:"sendMetrics",get:function(){return this._sendMetrics}},{key:"logToConsole",get:function(){return this._logToConsole}},{key:"applyFeatures",value:function(){try{var e={sendLocalCandidates:!0,sendLogs:"All",sendMetrics:"All",logToConsole:"All"};this._sendLocalCandidates=!("sendLocalCandidates"in e)||e.sendLocalCandidates,this._sendLogs="sendLogs"in e?e.sendLogs:"All",this._sendMetrics="sendMetrics"in e?e.sendMetrics:"All",this._logToConsole="logToConsole"in e?e.logToConsole:"All"}catch(e){this._sendLocalCandidates=!0,this._sendLogs="All",this._sendMetrics="All",this._logToConsole="All"}}}])}();s()(I,"_sendLocalCandidates",void 0),s()(I,"_sendLogs",void 0),s()(I,"_sendMetrics",void 0),s()(I,"_logToConsole",void 0),I.applyFeatures();var L=function(){return o()((function e(){t()(this,e)}),null,[{key:"defaultLoggingLevel",get:function(){return P[I.sendLogs]}},{key:"defaultConsoleLoggingLevel",get:function(){return P[I.logToConsole]}},{key:"defaultTelemetryLoggingLevel",get:function(){return P.Info}}])}(),D=function(){return o()((function e(){t()(this,e),s()(this,"_threshold",L.defaultLoggingLevel)}),[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}])}(),R=function(){return o()((function e(n){t()(this,e),s()(this,"_threshold",void 0),this._threshold=n}),[{key:"log",value:function(e,t,n,r){if(!(e<this._threshold)){var i="".concat(r.toISOString()," [").concat(n,"] [").concat(P[e],"] ").concat(t);e<P.Warn?console.log(i):console.error(i)}}}])}(),O=n(293),A=n.n(O),M=n(756),N=n.n(M),V=function(){function e(){throw t()(this,e),new Error("Numbers is a static class that may not be instantiated")}return o()(e,null,[{key:"countNumberLength",value:function(t){var n=0,r=t;return r<0&&(r*=-1,n++),e.countDigitsBeforeDecimal(r)+n+(r!==Math.floor(r)?e.countDigitsAfterDecimal(r)+1:0)}},{key:"fixRounding",value:function(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}},{key:"countDigitsBeforeDecimal",value:function(e){for(var t=1,n=e;n>=10;)n/=10,t++;return t}},{key:"countDigitsAfterDecimal",value:function(t){for(var n=t,r=Math.floor(t),i=0;r!==n&&i<15;)i++,r=e.fixRounding(n,i);return i}}])}(),U=function(){return o()((function e(){t()(this,e)}),null,[{key:"sdkVersion",get:function(){try{return"2025-02-06T18:19:43.870Z (2025.0.4-beta.409)"}catch(e){return this._defaultVersion}}}])}();s()(U,"_defaultVersion",(new Date).toISOString());var B=function(){return o()((function e(n){var r=this;t()(this,e),s()(this,"_telemetryConfiguration",void 0),s()(this,"_logs",[]),s()(this,"_isSending",!1),s()(this,"_domain",""),this._telemetryConfiguration=n,this.getLocationHostnameFromGlobalScope().then((function(e){r._domain=e}))}),[{key:"push",value:function(e,t,n,r){var i=(r.valueOf()-this._telemetryConfiguration.pageLoadTime)/1e3,o={timestamp:r.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:P[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:U.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain,runtime:i};e<P.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new Promise((function(e){var t=w.subscribe((function(n){n&&(e(n.locationHostname),t.dispose())}))}))}},{key:"sendLogs",value:(n=A()(N().mark((function e(t){var n;return N().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=A()(N().mark((function e(){var t,n,r,i,o,a=this;return N().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?V.countNumberLength(e):e.length},i=function(e){return Object.values(e).reduce((function(e,t){return e+(t?r(t):0)}),0)};this._logs.length>t&&i(this._logs[t])+n<8192;)n+=i(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,i(this._logs[t])+(8192-i(this._logs[t]))),t=1),o=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.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}(),j=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 B(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",L.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}}])}(),z=function(){return o()((function e(){t()(this,e)}),null,[{key:"defaultTelemetryLevel",get:function(){return G[I.sendMetrics]}}])}(),G=function(e){return e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All",e}({}),W=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}}])}(),q=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},J=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case G.Off:return"Off";case G.Essential:return"Essential";case G.All:return"All";default:q(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return G.Off;case"Essential":return G.Essential;case"All":return G.All;default:q(e)}}}])}(),K=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case P.Off:return"Off";case P.Trace:return"Trace";case P.Debug:return"Debug";case P.Info:return"Trace";case P.Warn:return"Warn";case P.Error:return"Error";case P.Fatal:return"Fatal";case P.All:return"All";default:q(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return P.Off;case"Trace":return P.Trace;case"Debug":return P.Debug;case"Info":return P.Info;case"Warn":return P.Warn;case"Error":return P.Error;case"Fatal":return P.Fatal;case"All":return P.All;default:q(e)}}}])}(),Z=function(){function e(){t()(this,e)}return o()(e,null,[{key:"getStringValue",value:function(t){return e.defaultStringValue[t]}},{key:"getBooleanValue",value:function(t){return e.defaultBooleanValue[t]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":J.convertTelemetryLevelToTelemetryLevelType(z.defaultTelemetryLevel),"phenix-logging-level":K.convertLoggingLevelToLoggingLevelType(L.defaultLoggingLevel),"phenix-console-logging-level":K.convertLoggingLevelToLoggingLevelType(L.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":K.convertLoggingLevelToLoggingLevelType(L.defaultTelemetryLoggingLevel),"phenix-channel-token":"","phenix-uri":"","phenix-base-uri":""}}},{key:"defaultBooleanValue",get:function(){return{"phenix-automatically-retry-on-failure":!0,"phenix-automatically-reconnect-peer-connection":!0,"phenix-force-garbage-collection-on-restart":!0,"phenix-skip-garbage-collection-on-mobile-devices":!0}}}])}(),Q=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 E(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=Z.getStringValue("phenix-logging-level");P[e]&&this._threshold.setThreshold(P[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=Z.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(P[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new R(e||L.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||L.defaultTelemetryLoggingLevel,this._appenders.add(new j(this._telemetryConfiguration))}}])}();s()(Q,"_loggers",{}),s()(Q,"_appenders",new F),s()(Q,"_threshold",new D),s()(Q,"_telemetryConfiguration",new H),Q.applyLoggerConfigFromParameterConfiguration();var $=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)}}])}(),X=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}}])}(),Y=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 X(null);try{var n=atob(t.substr(7)),r=JSON.parse(n);return r.token=JSON.parse(r.token),new X(r)}catch(t){return e._logger.error("Cannot parse token value",t),new X(null)}}},{key:"isEncodedEdgeTokenValid",value:function(e){return!!e&&e.startsWith("DIGEST:")}}])}();s()(Y,"_logger",Q.getLogger("EdgeAuthParser"));var ee=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,"]")}}])}(),te="visibilitychange",ne=function(){return o()((function e(){t()(this,e),s()(this,"_disposables",new ee),s()(this,"_readOnlyIsForeground",void 0),s()(this,"_isForeground",void 0),s()(this,"_timeOfLastTabFocusChange",Date.now()),this._isForeground=new y(!0),this._readOnlyIsForeground=new _(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(te,t,n),this._disposables.add(new p((function(){return w.value.removeDocumentEventListener(te,t,n)})))}}])}(),re=function(){return o()((function e(n){t()(this,e),s()(this,"_logger",Q.getLogger("VanillaPeerConnection")),s()(this,"_peerConnection",void 0),T.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!T.getTransceiversDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.getTransceivers)}},{key:"supportsAddTransceiver",get:function(){var e;return!T.addTranceiverDisabled&&"function"==typeof(null===(e=this._peerConnection)||void 0===e?void 0:e.addTransceiver)}},{key:"createOffer",value:(i=A()(N().mark((function e(t){var n=this;return N().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(!T.promiseBasedPCMethodsDisabled){e.next=4;break}return e.abrupt("return",new Promise((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=A()(N().mark((function e(t){var n=this;return N().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(!T.promiseBasedPCMethodsDisabled){e.next=4;break}return e.abrupt("return",new Promise((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=A()(N().mark((function e(t){return N().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(T.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=A()(N().mark((function e(t){var n;return N().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(T.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 Promise((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}(),ie=function(){return o()((function e(){t()(this,e)}),[{key:"createPeerConnection",value:(e=A()(N().mark((function e(t){return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){w.subscribe((function(n){n&&e(new re(t))}))})));case 1:case"end":return e.stop()}}),e)}))),function(t){return e.apply(this,arguments)})}]);var e}(),oe=function(e){return e[e.Disabled=0]="Disabled",e[e.Enabled=1]="Enabled",e}({}),ae=["audio","video"],se=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(){T.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error("Failed to pre-cache peer connection offer",t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(r=A()(N().mark((function t(){return N().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=A()(N().mark((function t(){var n,r,i,o,a,s=arguments;return N().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=s.length>0&&void 0!==s[0]?s[0]:"recvonly",r=s.length>1&&void 0!==s[1]?s[1]:ae,i=s.length>2&&void 0!==s[2]?s[2]:oe.Disabled,!e._cached||e._cached.direction!==n||i!==oe.Disabled||!this.isTracksKindsEquivalentToDefault(r)){t.next=7;break}return o=e._cached.peerConnection,e._cached=null,t.abrupt("return",o);case 7:return a=T.isEncodedInsertableStreamsSupported?{encodedInsertableStreams:i===oe.Enabled}:void 0,t.abrupt("return",e._peerConnectionFactory.value.createPeerConnection(a).then(function(){var e=A()(N().mark((function e(t){var i,o,a,s;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=t.supportsAddTransceiver,o=[],a=[],!i){e.next=12;break}return r.forEach((function(e){"audio"!==e?"video"!==e||a.push(t.addTransceiver(e,{direction:n})):o.push(t.addTransceiver(e,{direction:n}))})),e.t0=o,e.t1=a,e.t2=t,e.next=10,t.createOffer(void 0);case 10:return e.t3=e.sent,e.abrupt("return",{audioTransceivers:e.t0,videoTransceivers:e.t1,peerConnection:e.t2,localOffer:e.t3});case 12:return s="recvonly"===n?{offerToReceiveAudio:!0,offerToReceiveVideo:!0}:{},e.t4=t,e.next=16,t.createOffer(s);case 16:return e.t5=e.sent,e.abrupt("return",{peerConnection:e.t4,localOffer:e.t5});case 18:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 9:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"isTracksKindsEquivalentToDefault",value:function(e){if(e.length!==ae.length)return!1;var t=function(e){return e.reduce((function(e,t){return e[t]=(e[t]||0)+1,e}),{audio:0,video:0})},n=t(e),r=t(ae);return n.audio===r.audio&&n.video===r.video}}]);var n,r}();s()(se,"_logger",Q.getLogger("PeerConnectionService")),s()(se,"_peerConnectionFactory",new y(new ie)),s()(se,"_cached",void 0),se.initiateInitialPrecaching();var ue=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}}}])}(),ce=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""}}}])}(),le=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:"distribution"}};this._discoveryParameters="discovery"in e?e.discovery:{intentions:""}}catch(e){this._discoveryParameters={intentions:""}}}}])}();s()(le,"_discoveryParameters",void 0),le.applyParameters();var de=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=U.sdkVersion,r=le.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()(de,"_discoveryUri",new y("https://pcast.phenixrts.com/pcast/endPoints"));var he,fe,pe=n(738),me=n.n(pe),ve=n(132),ge=n.n(ve),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)}}])}(),_e=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}(_e||{}),be=_e,Ce=function(){return o()((function e(n){t()(this,e),s()(this,"_metrics",void 0),this._metrics=n}),[{key:"getName",value:function(){return be[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case be.TimeToFirstFrame:case be.ChannelCreationTimeToFirstFrame:return G.Essential;case be.Stalled:case be.Buffering:case be.SetupCompleted:case be.SetupFailed:case be.RoundTripTime:case be.DownlinkThroughputCapacity:case be.NetworkType:case be.ResolutionChanged:case be.ApplicationForeground:case be.ApplicationBackground:return G.All;default:q(this._metrics)}}}])}(),ke=function(){return o()((function e(n){var r=this;t()(this,e),s()(this,"_logger",Q.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 ye,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 Ce(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:U.sdkVersion,runtime:i,resource:o,kind:a};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"getLocationHostnameFromGlobalScope",value:function(){return new Promise((function(e){var t=w.subscribe((function(n){n&&(e(n.locationHostname),t.dispose())}))}))}},{key:"sendMetrics",value:(n=A()(N().mark((function e(t){var n;return N().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=A()(N().mark((function e(){var t,n=this;return N().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(ge()(t),ge()(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}(),Se=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(me()(t),"]"));var n=e._metricsServices[t];if(n)return n;var r=new W;return r.sessionId=xe.clientSessionId,r.tenancy=xe.tenancy.value,r.url=ue.getTelemetryUrl(t),r.environment=ce.getEnvironmentFromUrl(t),r.threshold=J.convertTelemetryLevelTypeToTelemetryLevel(xe.telemetryLevel),e._metricsServices[t]=new ke(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}])}();s()(Se,"_metricsServices",{});var we=(null===(he=b.getInstance().value)||void 0===he?void 0:he.pageLoadTime)||Date.now(),xe=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 K.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return J.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return x}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=Q.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 j}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new j(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 j}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new j(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=Se.getMetricsService(de.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=Z.getStringValue("phenix-metrics-level");t&&Se.setTelemetryLevel(G[t]),e._telemetryLevel.subscribe((function(e){Se.setTelemetryLevel(e)}))}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=Z.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=Z.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=Z.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=Z.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices"),this._logger.info("Skip garbage collection on mobile devices on restart is set to: [%s]",this._skipGarbageCollectionOnMobileDevices)}},{key:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe((function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=ce.getEnvironmentFromUrl(t)}));var t=Z.getStringValue("phenix-channel-token");if(t){var n=Y.parseToken(t);return e._tenancy.value=n.tenancy,de.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=Z.getStringValue("phenix-uri");if(r)return de.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=Z.getStringValue("phenix-base-uri");if(i){var o=new(b.getInstance().value.URL)(i);return o.pathname="/pcast/endPoints",de.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 ne,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&&b.setInstance(n.globalScope),t.discoveryUri&&(de.uri.value=t.discoveryUri),t.peerConnectionFactory&&(se.peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&G[t.telemetryLevel]&&(e._telemetryLevel.value=J.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&P[t.loggingLevel]&&this._logger.threshold.setThreshold(K.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&P[t.consoleLoggingLevel]){var r=this._logger.appenders.value.find((function(e){return e instanceof R}));r&&this._logger.appenders.remove(r),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new R(K.convertLoggingLevelTypeToLoggingLevel(t.consoleLoggingLevel)))}"boolean"==typeof t.automaticallyPlayMediaStream&&(this._automaticallyPlayMediaStream=t.automaticallyPlayMediaStream),"boolean"==typeof t.automaticallyMuteVideoOnPlayFailure&&(this._automaticallyMuteVideoOnPlayFailure=t.automaticallyMuteVideoOnPlayFailure),t.webPlayerLoader&&(this._webPlayerLoader=t.webPlayerLoader),t.shakaPlayerLoader&&(this._shakaPlayerLoader=t.shakaPlayerLoader),t.hlsJsLoader&&(this._hlsJsLoader=t.hlsJsLoader)}}},{key:"dispose",value:function(){var t;e._initialized.value=!1,null===(t=this._applicationActivityMonitor)||void 0===t||t.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return ue.getTelemetryUrl(e)}}])}();fe=xe,s()(xe,"_automaticallyRetryOnFailure",Z.getBooleanValue("phenix-automatically-retry-on-failure")),s()(xe,"_automaticallyReconnectPeerConnection",Z.getBooleanValue("phenix-automatically-reconnect-peer-connection")),s()(xe,"_automaticallyPlayMediaStream",!0),s()(xe,"_automaticallyMuteVideoOnPlayFailure",!0),s()(xe,"_forceGarbageCollectionOnRestart",Z.getBooleanValue("phenix-force-garbage-collection-on-restart")),s()(xe,"_skipGarbageCollectionOnMobileDevices",Z.getBooleanValue("phenix-skip-garbage-collection-on-mobile-devices")),s()(xe,"_webPlayerLoader",void 0),s()(xe,"_shakaPlayerLoader",void 0),s()(xe,"_hlsJsLoader",void 0),s()(xe,"_applicationActivityMonitor",void 0),s()(xe,"_environment",new y("")),s()(xe,"_telemetryUrl",new y("https://telemetry.phenixrts.com/telemetry")),s()(xe,"_maximalNumberOfPeerConnectionReconnectAttempts",8),s()(xe,"_telemetryLevel",new y(z.defaultTelemetryLevel)),s()(xe,"_metricsService",void 0),s()(xe,"_metricsConfiguration",void 0),s()(xe,"_sendLocalCandidates",new y(I.sendLocalCandidates)),s()(xe,"_tenancy",new y("")),s()(xe,"_clientSessionId",$.random(32)),s()(xe,"_loadedTimestamp",new Date),s()(xe,"_logger",Q.getLogger("SDK")),s()(xe,"_initialized",new y(!1)),s()(xe,"_readOnlyInitialized",new _(fe._initialized)),s()(xe,"_readOnlyDiscoveryUri",new _(de.uri)),s()(xe,"_readOnlyPeerConnectionFactory",new _(se.peerConnectionFactory)),b.subscribe(xe.onLoad.bind(xe));var Te=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)}}])}(),Pe=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(){T.isForceChromeGarbageCollectionSupported&&this.forceChromeGarbageCollection()}},{key:"forceChromeGarbageCollection",value:function(){T.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}}}])}(),Ee=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}(Ee||{}),Fe=Ee,Ie=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(){},De=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",Q.getLogger("StreamTelemetry")),s()(this,"_disposables",new ee),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 p((function(){return null}))),s()(this,"_clearRebufferingListener",new p((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 p((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 p((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 Ie(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:be.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 Ie(this._timeToFirstFrame).toIsoString())}},{key:"pushChannelCreationTimeToFirstFrame",value:function(e){this._channelCreationTimeToFirstFrame=e-this._channelStartTime,this._metricsService.push({metricType:be.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 Ie(this._channelCreationTimeToFirstFrame).toIsoString())}},{key:"onStall",value:function(){this._videoStalled||(this._metricsService.push({metricType:be.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:be.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 Ie(i).toIsoString()),this._videoStalled=null}}}},{key:"onVideoResolutionChanges",value:function(e){this._metricsService.push({metricType:be.ResolutionChanged,runtime:(Date.now()-this._pageLoadTime)/1e3,value:{string:e},previousValue:this._videoResolution?{string:this._videoResolution}:void 0,streamId:this._streamId}),this._videoResolution=e}}])}(),Re=function(){return o()((function e(n){t()(this,e),s()(this,"_logger",Q.getLogger("StreamSetupListener")),s()(this,"metricsService",xe.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(be.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(be.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new Ce(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 Ie(n-this._pageLoadTime).toIsoString(),t,i,new Ie(r).toIsoString())}}}])}(),Oe=function(){return o()((function e(){t()(this,e),s()(this,"_disposables",new ee),s()(this,"_isSupported",void 0!==w.value.navigatorConnection),s()(this,"_rtt",new y(void 0)),s()(this,"_effectiveType",new y(void 0)),s()(this,"_downlinkThroughputCapacity",new y(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 p((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()}}])}(),Ae=function(){return o()((function e(n,r){var i=this;if(t()(this,e),s()(this,"_logger",Q.getLogger("SessionTelemetry")),s()(this,"_metricsService",void 0),s()(this,"_applicationActivityMonitor",xe.applicationActivityMonitor),s()(this,"_networkMonitor",new Oe),s()(this,"_pageLoadTime",void 0),s()(this,"_disposables",new ee),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 Re(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?be.ApplicationForeground:be.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 Ie(r).toIsoString()))}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:be.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 Ie(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:be.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 Ie(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:be.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 Ie(t-this._pageLoadTime).toIsoString(),e,n)}}])}(),Me=function(e){return e[e.Keep=0]="Keep",e[e.Reset=1]="Reset",e}({}),Ne=function(e){return e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset",e}({}),Ve=o()((function e(n){t()(this,e),s()(this,"token",void 0),s()(this,"tokenExpiring",void 0),this.token=new y(n),this.tokenExpiring=new y(!1)})),Ue=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 ee,this.channelDisposables=new ee,this.rendererDisposables=new ee,this.channelInitialization=new Date,this.videoElement=new y(null),this.state=new y(Fe.Initializing),this.autoMuted=new y(!1),this.autoPaused=new y(!1),this.authorized=new y(!0),this.online=new y(!0),this.loading=new y(!1),this.playing=new y(!1),this.standby=new y(!1),this.stopped=new y(!1),this.targetLag=new y(null!==(r=null==n?void 0:n.targetLag)&&void 0!==r?r:0),this.lag=new y(void 0),this.bitrateLimit=new y(0),this.resolution=new y(Te.empty),this.failureCount=new y(0),this.endPoint=new y(null),this.stream=new y(null),this.rtcStatistics=new y(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=xe.clientSessionId,this.videoElement.value.dataset.streamId=this.streamId)}},{key:"mapSubscribeStatusToChannelStatus",value:function(e){switch(e){case"ok":return Fe.Starting;case"no-stream":case"not-found":return Fe.StandBy;case"geo-restricted":return Fe.GeoRestricted;case"geo-blocked":return Fe.GeoBlocked;case"unauthorized":return Fe.Unauthorized;case"capacity":case"rate-limited":case"timeout":return Fe.Recovering;case"forbidden-tag":return Fe.ConfigurationError;case"port-in-range-not-found":return Fe.TransientConfigurationError;case"failed":return Fe.Error;default:q(e)}}}])}(),Be=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(me()(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"}}}])}(),je=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(me()(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 y(n.hasInsertableStreams),this.hasEncodedInsertableStreams=new y(n.hasEncodedInsertableStreams),this.videoStreamTransformCallback=n.videoStreamTransformCallback,this.audioStreamTransformCallback=n.audioStreamTransformCallback,this.encodedVideoStreamSink=n.encodedVideoStreamSink,this.encodedAudioStreamSink=n.encodedAudioStreamSink})),ze=o()((function e(){t()(this,e),s()(this,"mediaStream",void 0),s()(this,"peerConnection",void 0),s()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new y(null),this.peerConnection=new y(null),this.peerConnectionReconnectAttempts=0})),Ge=o()((function e(){t()(this,e),s()(this,"isStarting",void 0),s()(this,"isDisposed",void 0),this.isStarting=new y(!1),this.isDisposed=!1})),We=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 y(!1),this.shouldExtractTimestamps=new y(!1),this.isEnabled=new y(!1),this.decodedFrameTimingInformation=new y(null),this.renderedFrameTimingInformation=new y(null)})),qe=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Ne.Normal:return"Normal";case Ne.Force:return"Force";case Ne.Reset:return"Reset";default:q(e)}}}])}(),Je=function(){return o()((function e(){t()(this,e)}),null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case Me.Keep:return"Keep";case Me.Reset:return"Reset";default:q(e)}}}])}(),Ke=function(){return o()((function e(n,r){if(t()(this,e),s()(this,"_logger",Q.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=A()(N().mark((function e(){var t,n,r,i,o=this;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,Promise.race([w.value.fetch(t,{method:"GET",cache:"no-cache"}),new Promise((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:(p=A()(N().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,f,p,m,v=this;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=Y.parseToken(t).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",t),e.abrupt("return",{status:"unauthorized"});case 4:return o=this.buildUrl([i,"stream","subscribe"]).toString(),a=new w.value.FormData,s=U.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,Promise.race([w.value.fetch(o,{method:"POST",body:a}),new Promise((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"===(f=this.mapHttpStatusToSubscribeStatus(d))){e.next=23;break}return e.abrupt("return",{status:f});case 23:return p=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,p-l),e.abrupt("return",m);case 29:case"end":return e.stop()}}),e,this,[[9,16]])}))),function(e,t,n){return p.apply(this,arguments)})},{key:"publish",value:(f=A()(N().mark((function e(t,n,r,i){var o,a,s,u,c,l,d,h,f,p,m,v,g=this;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=Y.parseToken(n).tenancy){e.next=4;break}return this._logger.error("Failed to parse token [%s]",n),e.abrupt("return",{status:"unauthorized"});case 4:return a=this.buildUrl([o,"stream","publish"]).toString(),s=new w.value.FormData,u=U.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,f=null,e.next=13,Promise.race([w.value.fetch(a,{method:"POST",body:s}),new Promise((function(e){return f=w.value.setTimeout((function(){g._logger.error("Failed to publish",new Error("Publish timed out [".concat(a,"]"))),e({status:408})}),g._timeout)}))]).finally((function(){f&&w.value.clearTimeout(f)}));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"===(p=this.mapHttpStatusToPublishStatus(h))){e.next=23;break}return e.abrupt("return",{status:p});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 f.apply(this,arguments)})},{key:"setRemoteDescription",value:(h=A()(N().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return N().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,Promise.race([w.value.fetch(r,{method:"POST",body:i}),new Promise((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=A()(N().mark((function e(t,n,r,i,o){var a,s,u,c,l,d,h,f,p=this;return N().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:Je.convertBitrateStateToBitrateStateType(i),bitrateMode:qe.convertBitrateModeToBitrateModeType(o)},s.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,d=null,e.next=9,Promise.race([w.value.fetch(a,{method:"POST",body:s}),new Promise((function(e){return d=w.value.setTimeout((function(){p._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(a,"]"))),e({status:408})}),p._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),f=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",h,f-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=A()(N().mark((function e(t,n,r){var i,o,a,s,u,c,l,d,h,f,p=this,m=arguments;return N().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,Promise.race([w.value.fetch(o,{method:"POST",body:a}),new Promise((function(e){return l=w.value.setTimeout((function(){p._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(o,"]"))),e({status:408})}),p._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 f=e.sent,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",f,h-u),e.abrupt("return",f);case 26:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e,t,n){return l.apply(this,arguments)})},{key:"destroyStream",value:(c=A()(N().mark((function e(t,n){var r,i,o,a,s,u,c,l,d,h=this;return N().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,Promise.race([w.value.fetch(r,{method:"POST",body:i,cache:"no-cache"}),new Promise((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=A()(N().mark((function e(t,n){var r,i,o,a;return N().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,ge()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new w.value.URL(this._uri),t=U.sdkVersion,n=le.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=A()(N().mark((function e(t,n){var r,i;return N().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=A()(N().mark((function e(t,n){var r,i;return N().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=A()(N().mark((function e(t){var n,r;return N().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=A()(N().mark((function e(t){var n,r;return N().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=A()(N().mark((function e(t){var n,r;return N().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,f,p,m}(),Ze=function(){return o()((function e(n){if(t()(this,e),s()(this,"_logger",Q.getLogger("Discovery")),s()(this,"_metricsService",void 0),s()(this,"_uri",void 0),!n)throw new Error("Discovery requires uri");this._metricsService=Se.getMetricsService(n.toString()),this._uri=n}),[{key:"discoverNearbyEndPoints",value:(n=A()(N().mark((function e(t,n){var r,i,o,a;return N().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,Promise.race([w.value.fetch(r,{method:"GET",cache:"no-cache"}),new Promise((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 Ke(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(e=A()(N().mark((function e(){var t,n,r,i,o,a,s=this,u=arguments;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u.length>0&&void 0!==u[0]?u[0]:2e4,n=de.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 Promise((function(e,t){i>=r.length&&t("Discovery of [".concat(r.length,"] endpoints from [").concat(n,"] failed, preventing it from completing"))}))},e.next=9,Promise.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:be.RoundTripTime,runtime:(n-xe.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}(),Qe=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=A()(N().mark((function t(){return N().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t){w.subscribe((function(n){if(n){var r=new n.URL(xe.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=A()(N().mark((function t(n){var r,i,o;return N().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 Ze(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()(Qe,"_cache",{}),Qe.precacheClosestEndPointDiscovery();var $e=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 Xe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ye(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xe(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var et=function(){return o()((function e(n,r,i,o,a,u){t()(this,e),s()(this,"_logger",Q.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(st.phenixWebPlayer){var t,n,r=Ye(Ye({},this._options),{},{bandwidthToStartAt:3e6});return this._player=new st.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===st.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 st.phenixWebPlayer&&st.phenixWebPlayer.isSupported}},{key:"getStats",value:function(){var e,t;if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:$e.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=$e.NetworkLoading:n.currentTime>0?n.networkState=$e.NetworkIdle:n.video?n.networkState=$e.NetworkEmpty:n.networkState=$e.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 tt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function nt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?tt(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var rt=function(){return o()((function e(n,r,i,o,a,u){t()(this,e),s()(this,"_logger",Q.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 ee,this._monitoredStatistics={estimatedBandwidth:0,playTime:0},this._player=null}),[{key:"start",value:function(){if(st.shaka)return this._player=new st.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:$e.NetworkNoSource,dataBuffered:0};var e=nt(nt({},this._player.getStats()),{},{currentTime:0,lag:0}),t=this._videoElement.currentTime||0,n=(Date.now()-this._options.originStartTime)/1e3,r=Math.max(0,n-t);return this._videoElement&&(e.currentTime=t,e.lag=r,this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0))),e.estimatedBandwidth&&(e.estimatedBandwidth&&e.estimatedBandwidth>0&&this._monitoredStatistics.estimatedBandwidth&&this._monitoredStatistics.estimatedBandwidth<e.estimatedBandwidth?e.networkState=$e.NetworkLoading:e.playTime&&e.playTime>0&&this._monitoredStatistics.playTime&&this._monitoredStatistics.playTime<e.playTime?e.networkState=$e.NetworkIdle:e.video?e.networkState=$e.NetworkEmpty:e.networkState=$e.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 p((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)}))}}])}(),it=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(){st.hlsPlayer&&(st.hlsPlayer.isSupported()?(this._player=new st.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 st.hlsPlayer&&st.hlsPlayer.isSupported()}},{key:"getStats",value:function(){if(!this._player)return{width:0,height:0,currentTime:0,lag:0,networkState:$e.NetworkNoSource,dataBuffered:0};var e={width:this._player.media.offsetWidth,height:this._player.media.offsetHeight,currentTime:this._player.media.currentTime,lag:0,networkState:$e.NetworkIdle,dataBuffered:0};this._videoElement.buffered&&this._videoElement.buffered.length&&(e.dataBuffered=this._videoElement.buffered.end(0)),"IDLE"===this._player.streamController.state?e.networkState=$e.NetworkIdle:"ERROR"===this._player.streamController.state||"ENDED"===this._player.streamController.state?e.networkState=$e.NetworkNoSource:this._player.streamController.state.includes("LOADING")||this._player.streamController.state.includes("WAITING")?e.networkState=$e.NetworkLoading:e.networkState=$e.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)}}])}();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(){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=A()(N().mark((function e(t,n,r,i,o){var a=this;return N().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(xe.webPlayerLoader||xe.shakaPlayerLoader||xe.hlsJsLoader){e.next=5;break}throw new Error("Unsupported-feature, add stream player");case 5:return e.abrupt("return",new Promise((function(e){xe.hlsJsLoader&&(a._pending=!0,xe.hlsJsLoader((function(i){a._hlsPlayer=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))}))),xe.webPlayerLoader&&(a._pending=!0,xe.webPlayerLoader((function(i){a._phenixWebPlayer=i,a._pending&&(a._pending=!1,e(a.loaded(t,n,r,o)))}))),xe.shakaPlayerLoader&&(a._pending=!0,xe.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=A()(N().mark((function e(t,n,r,i,o,a){var s,u,c,l;return N().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&&!T.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&&T.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(it,e,t,n,at(at({},this._options),{},{preferNative:T.shouldUseNativeHls}),r):this._phenixWebPlayer?this.play(et,e,t,n,at(at({},this._options),{},{preferNative:T.shouldUseNativeHls}),r):this.play(rt,e,t,n,at(at({},this._options),{},{preferNative:T.shouldUseNativeHls}),r)}}]);var e,n}();s()(st,"_pending",!1),s()(st,"_hlsPlayer",void 0),s()(st,"_phenixWebPlayer",void 0),s()(st,"_shaka",void 0),s()(st,"_options",void 0),s()(st,"_player",void 0);var ut=function(e){return e[e.Live=1]="Live",e[e.OndDemand=2]="OndDemand",e}(ut||{}),ct=ut,lt=function(){return o()((function e(n,r,i){t()(this,e),s()(this,"_logger",Q.getLogger("ChunkedStream")),s()(this,"_channelContext",void 0),s()(this,"_chunkedStreamPlaybackMode",void 0),s()(this,"_disposables",new ee),s()(this,"_monitorDisposables",new ee),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 Qe.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=Fe.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?st.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=Fe.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=Fe.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=Fe.Stopped))}))}},{key:"retryOnStreamFailure",value:function(){var e=this;this._monitorFailureCount=0,this._channelContext.state.value=Fe.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=st.getStats();if(t._chunkedStreamPlaybackMode!==ct.Live||(null==s?void 0:s.networkState)!==$e.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===Fe.Playing&&(t._channelContext.state.value=Fe.Paused),null!==(a=t._channelContext.videoElement.value)&&void 0!==a&&a.paused||t._channelContext.state.value===Fe.Playing||(t._channelContext.state.value=Fe.Playing),t._streamStatistics=s,t.monitor(e)}else t.retryOnStreamFailure()}),1e3);this._monitorDisposables.add(new p((function(){w.value.clearTimeout(n)})))}},{key:"dispose",value:function(){this._disposables.dispose(),this._monitorDisposables.dispose()}}])}(),dt=n(715),ht=n.n(dt),ft=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]}}])}(),pt=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}}])}(),mt=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 y({})),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(!T.getCurrentOfferDisabled&&null!==(o=this._peerConnection)&&void 0!==o&&null!==(a=o.currentRemoteDescription)&&void 0!==a&&a.sdp){var u=new ft(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=A()(N().mark((function e(){var t,n,r=this;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!T.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,f,p,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===(f=h[s])||void 0===f?void 0:f.timestamp)||0),y=v&&g?Math.floor(8*v/g*1e3):0;if(t[s]={ssrc:a.ssrc,mediaType:s,timestamp:a.timestamp,bitrate:y,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!==(p=r._rtcStatistic.value)&&void 0!==p&&null!==(m=p.video)&&void 0!==m&&m.framesDecoded){t[s].framesDecoded=a.framesDecoded;var _=(a.framesDecoded-r._rtcStatistic.value.video.framesDecoded)/(t[s].timestamp-r._rtcStatistic.value.video.timestamp)*1e3;t[s].fps=_?Math.round(100*_)/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=A()(N().mark((function e(){var t,n=this;return N().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}(),vt=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}(vt||{}),gt=vt,yt=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}}])}(),_t=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}}])}(),bt=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}(bt||{}),Ct=function(){return o()((function e(){t()(this,e)}),[{key:"parse",value:function(e,t){var n=new yt(_t.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 bt.ProgressiveFrame:case bt.TopField:case bt.BottomField:return 1;case bt.TopFieldBottomField:case bt.BottomFieldTopField:case bt.FrameDoubling:return 2;case bt.TopFieldBottomFieldTopFieldRepeated:case bt.BottomFieldTopFieldBottomFieldRepeated:case bt.FrameTripling:return 3;default:return 0}}}])}();function kt(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 St=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 p((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 kt(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)?kt(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()}}])}(),wt=function(){return o()((function e(){t()(this,e),s()(this,"_eventEmitters",new Map),s()(this,"_onEventWithNoSubscriberHandlers",new Set),s()(this,"_disposables",new ee)}),[{key:"onEventWithNoSubscriber",value:function(e){var t=this;return this._onEventWithNoSubscriberHandlers.add(e),new p((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 St;return this._eventEmitters.set(e,t),t}}])}(),xt=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}({}),Tt=function(){return o()((function e(n){t()(this,e),s()(this,"_eventPublisher",void 0),s()(this,"_disposables",new ee),this._eventPublisher=n}),[{key:"subscribeToNalUnit",value:function(e,t){return this._eventPublisher.subscribe(xt.NalUnit,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToSeiPayloadType",value:function(e,t){return this._eventPublisher.subscribe(xt.SeiPayload,(function(n){n.data.type===e&&t(n)}))}},{key:"subscribeToPayload",value:function(e,t,n){return this._eventPublisher.publish(xt.PayloadSubscription,{context:e,data:t}),this._eventPublisher.subscribe(xt.Payload,(function(e){e.data.uuid===t&&n(e)}))}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),Pt=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("")}}])}(),Et=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}(Et||{}),Ft=Et,It=function(){function e(n,r){t()(this,e),s()(this,"_eventPublisher",void 0),s()(this,"_vclExtractionStrategy",void 0),s()(this,"_disposables",new ee),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(xt.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===gt.UserDataUnregistered&&this.handleSeiPayloadUserDataUnregistered(e,t)}},{key:"handleSeiPayloadUserDataUnregistered",value:function(e,t){var n=Pt.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(xt.NalUnit,{context:e,data:t})}},{key:"publishSeiPayload",value:function(e,t){this._eventPublisher.publish(xt.SeiPayload,{context:e,data:t})}},{key:"publishPayload",value:function(e,t){this._eventPublisher.publish(xt.Payload,{context:e,data:t})}},{key:"notifyEndOfChunk",value:function(e){this._eventPublisher.publish(xt.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 Ft.SliceLayerNonIdrData:case Ft.SliceDataPartitionALayer:case Ft.SliceDataPartitionBLayer:case Ft.SliceDataPartitionCLayer:case Ft.SliceLayerIdrData:n=this._vclExtractionStrategy.extractVclNalUnit(e,i);break;case Ft.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=[];!Pt.isDataAtOffsetTargetByteSequence(e._seiPayload4ByteEndCode,t,r)&&!Pt.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+_t.getOffsetWithExpandedEmulationPreventionBytes(e,n,o);return{payloadType:i,payload:e.subarray(n,a),endIndex:a}}}],[{key:"findAnnexBStartIndexFromOffset",value:function(t,n,r){var i=Pt.findTargetByteSequenceIndexFromOffset(e.annexB4ByteStartCode,t,n,r);return i!==r?i:Pt.findTargetByteSequenceIndexFromOffset(e.annexB3ByteStartCode,t,n,r)}}])}();s()(It,"annexB3ByteStartCode",new Uint8Array([0,0,1])),s()(It,"annexB4ByteStartCode",new Uint8Array([0,0,0,1])),s()(It,"_seiPayload3ByteEndCode",new Uint8Array([128,0,0,1])),s()(It,"_seiPayload4ByteEndCode",new Uint8Array([128,0,0,0,1]));var Lt=function(){return o()((function e(){t()(this,e)}),[{key:"extractVclNalUnit",value:function(e,t){var n=It.findAnnexBStartIndexFromOffset(e,t,e.byteLength);return{nalUnitData:e.subarray(t,n)}}}])}(),Dt=function(){function e(){t()(this,e)}return o()(e,[{key:"extractVclNalUnit",value:function(t,n){var r=n+It.annexB4ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;if(Pt.isDataAtOffsetTargetByteSequence(It.annexB4ByteStartCode,t,r))return{nalUnitData:t.subarray(n+It.annexB4ByteStartCode.byteLength,r)};var i=n+It.annexB3ByteStartCode.byteLength+e._truncatedVclNalUnitByteLength;return Pt.isDataAtOffsetTargetByteSequence(It.annexB3ByteStartCode,t,i)?{nalUnitData:t.subarray(n+It.annexB3ByteStartCode.byteLength,i)}:{nalUnitData:t.subarray(n)}}}])}();s()(Dt,"_truncatedVclNalUnitByteLength",32);var Rt=function(){},Ot=function(){function e(n){t()(this,e),s()(this,"_logger",Q.getLogger("PhenixEmbeddedIsoBmff2023")),s()(this,"_eventPublisher",void 0),s()(this,"_expectedPayloadUuid",new Set),s()(this,"_endOfChunkHandlersByTrackId",new Map),s()(this,"_disposables",new ee),s()(this,"_enableWarningLogWhenVclEmbeddedDataNotFound",new p(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(xt.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(xt.PayloadSubscription,(function(t){var n=t.data;return e._expectedPayloadUuid.add(n)}))}},{key:"subscribeToEncodedVideoStreamChunkEvents",value:function(){return this._eventPublisher.subscribe(xt.EncodedVideoStreamChunk,this.armLoggingNoVclEmbeddedDataFound.bind(this))}},{key:"subscribeToNalUnitEvents",value:function(){return this._eventPublisher.subscribe(xt.NalUnit,this.handleNalUnitEvent.bind(this))}},{key:"handleNalUnitEvent",value:function(t){var n=t.context,r=t.data;r.type>Ft.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(xt.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,Rt)}},{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(xt.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(xt.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()(Ot,"_truncatedVclNalUnitDataByteLength",32),s()(Ot,"_phenixVclEmbeddedDataUuid","00000000-0000-0000-0000-000000000000"),s()(Ot,"_phenixInitializationSegmentUuid","511e22bd-34c0-4cee-b6c3-3c4d407622c7");var At=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 ee),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(xt.EncodedVideoStreamChunk,e)}},{key:"dispose",value:function(){this._disposables.dispose()}}])}(),Mt=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 ee,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)}}])}(),Nt=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 wt,t=new Tt(e),n=new It(e,new Lt);return new At(e,t,n)}},{key:"createPhenixH264EmbeddedIsoBmff2023VideoBitstreamDecoder",value:function(){var e=new wt,t=new Tt(e),n=new It(e,new Dt),r=new At(e,t,n),i=new Ot(e);return new Mt(r,i)}}])}();function Vt(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?Vt(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Bt(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 jt,Ht=function(){function e(n,r){var i=this;t()(this,e),s()(this,"_channelContext",void 0),s()(this,"_frameTimingInformationContext",void 0),s()(this,"_bitstreamDecoder",Nt.createH264VideoBitstreamDecoder()),s()(this,"_frameTimingsByRtpTimestamp",new Map),s()(this,"_picturingTimingParsingConfig",{cpbDpbDelaysPresentFlag:!1,picStructPresentFlag:!0}),s()(this,"_pictureTimingParser",new Ct),s()(this,"_videoElementDisposables",new ee),s()(this,"_currentPlaybackState","waiting"),s()(this,"_armedVideoFrameCallbackId",null),s()(this,"_disposables",new ee),s()(this,"_disposed",!1),this._channelContext=n,this._frameTimingInformationContext=r,this._disposables.add(this._bitstreamDecoder),this._disposables.add(new p((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(gt.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 Bt(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)?Bt(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=ht()(r.value,2),s=a[0],u=a[1];if(parseInt(s,10)>n)break;"playing"===this._currentPlaybackState&&(this._frameTimingInformationContext.renderedFrameTimingInformation.value=Ut(Ut({},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 p((function(){return e.removeEventListener("playing",n)})));var r=function(){return t._currentPlaybackState="paused"};e.addEventListener("pause",r),this._videoElementDisposables.add(new p((function(){return e.removeEventListener("pause",r)})));var i=function(){return t._currentPlaybackState="stalled"};e.addEventListener("stalled",i),this._videoElementDisposables.add(new p((function(){return e.removeEventListener("stalled",i)})));var o=function(){return t._currentPlaybackState="waiting"};e.addEventListener("waiting",o),this._videoElementDisposables.add(new p((function(){return e.removeEventListener("waiting",o)})));var a=function(){return t._currentPlaybackState="ended"};e.addEventListener("ended",a),this._videoElementDisposables.add(new p((function(){return e.removeEventListener("ended",a)})));var s=function(){return t._currentPlaybackState="error"};e.addEventListener("error",s),this._videoElementDisposables.add(new p((function(){return e.removeEventListener("error",s)}))),this.armVideoFrameCallback(),this._videoElementDisposables.add(new p((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()(Ht,"MAX_FRAME_TIMING_ENTRIES",1800);var zt=Symbol(),Gt=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)?zt: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?zt: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}}])}();jt=Gt,s()(Gt,"_isSafari","Safari"===x.browserName),s()(Gt,"_isMobileChrome","Chrome"===x.browserName&&x.isMobile()),s()(Gt,"_isAndroidChrome","Chrome"===x.browserName&&x.isAndroid),s()(Gt,"_singleZeroByte",new Uint8Array([0])),s()(Gt,"_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()(Gt,"_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()(Gt,"_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()(Gt,"_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(ge()(new Uint8Array(40).fill(255)),[95],ge()(new Uint8Array(10295).fill(255)),[128,0,0,0,1,101,136,132,5],ge()(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(ge()(new Uint8Array(40).fill(255)),[164],ge()(new Uint8Array(10364).fill(255)),[128,0,0,0,1,65,154,32,21,240,75]))}),s()(Gt,"_dummy82x82H264PFrameFrameNumberIndex",10418),s()(Gt,"_surrogate82x82PFrameFrameNumberReset",1),s()(Gt,"_useUpdateSurrogate82x82PFrameFrameNumber",jt._isMobileChrome||jt._isSafari),s()(Gt,"_surrogate82x82PFrameFrameNumber",jt._surrogate82x82PFrameFrameNumberReset);var Wt=n(131),qt=n.n(Wt);function Jt(){return qt()('(()=>{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 Kt=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 ee,s=new y(null),u=new y(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(T.isRTCRtpScriptTransformSupported){var h=Jt();h.onmessage=function(){var t=A()(N().mark((function t(r){return N().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 p((function(){h.terminate()})));break}var f=function(){var t=A()(N().mark((function t(r,o){var a;return N().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?Gt.getInvalidSurrogateVideoIFrame(i):Gt.getInvalidSurrogateVideoPFrame(i))!==zt){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=Gt.getSurrogateVideoIFramePerCodec(i)||r.data:r.data=Gt.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:f}),v=c.createEncodedStreams(),g=v.readable,y=v.writable;g.pipeThrough(m).pipeTo(y);break;case"audio":var _=!!r;if(T.isRTCRtpScriptTransformSupported){var b=Jt();b.onmessage=function(){var t=A()(N().mark((function t(n){return N().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n.data.chunk},t.t0=_,!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:_});var C=new MediaStream,k=new Audio;k.srcObject=C,document.body.appendChild(k),a.add(new p((function(){b.terminate(),document.body.removeChild(k)})));break}var S=function(){var t=A()(N().mark((function t(n,i){return N().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u.value={track:e,chunk:n},!_){t.next=9;break}return t.next=4,r(e,n);case 4:if(t.sent){t.next=8;break}n.data=Gt.getInvalidSurrogateAudioData(),t.next=9;break;case 8:n.data=Gt.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)}}(),w=new TransformStream({transform:S}),x=c.createEncodedStreams(),P=x.readable,E=x.writable;P.pipeThrough(w).pipeTo(E);break;default:q(l)}})),{disposables:a,encodedVideoFrame:s,encodedAudioFrame:u}}},{key:"configureInsertableStreamTransformation",value:function(e,t,n){var r=new MediaStream,i=new ee;return e.getTracks().forEach((function(e){var o=e.kind;switch(o){case"video":if(t){var a=e,s=new TransformStream({transform:function(n,r){t(e,n,r)}}),u=new MediaStreamTrackProcessor({track:a}),c=new MediaStreamTrackGenerator({kind:a.kind}),l=u.readable,d=c.writable;l.pipeThrough(s).pipeTo(d),r.addTrack(c),i.add(new p((function(){r.removeTrack(c)})))}else r.addTrack(e);break;case"audio":if(n){var h=e,f=new TransformStream({transform:function(t,r){n(e,t,r)}}),m=new MediaStreamTrackProcessor({track:h}),v=new MediaStreamTrackGenerator({kind:h.kind}),g=m.readable,y=v.writable;g.pipeThrough(f).pipeTo(y),r.addTrack(v);var _=new MediaStream,b=new Audio;_.addTrack(e),b.srcObject=_,document.body.appendChild(b),i.add(new p((function(){r.removeTrack(v),document.body.removeChild(b)})))}else r.addTrack(e);break;default:q(o)}})),{transformedStream:r,disposables:i}}}])}();function Zt(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?Zt(Object(n),!0).forEach((function(t){s()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var $t=function(){return o()((function e(n,r,i,o,a){t()(this,e),s()(this,"_logger",Q.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 ee,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?oe.Enabled:oe.Disabled;return Promise.all([Qe.discoverClosestEndPointWithCaching(e),se.createPeerConnectionOffer("recvonly",ae,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=ht()(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),!T.clientOfferDisabled&&s.supportsSetConfiguration&&s.supportsGetConfiguration?r.subscribe(t,a,i._channelContext.failureCount.value):(s.close(),s.dispose(),!xe.forceGarbageCollectionOnRestart||T.isMobile&&xe.skipGarbageCollectionOnMobileDevices||Pe.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||xe.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=Fe.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:q(e.iceConnectionState)}}};var f=new Promise((function(t,n){if(!T.onTrackDisabled){var r=w.value.setTimeout((function(){return n(new Error("Stream setup timed out"))}),3e4);return i._disposables.add(new p((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 p((function(){return w.value.clearTimeout(a)})))}));return new Promise((function(e){e()})).then((function(){if(u)return i._logger.info("[%s] Set local SDP offer [%s]",i._channelContext.streamId,u.sessionDescription.sdp),e.setLocalDescription(u.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,u.sessionDescription,e.message),e}))})).then((function(){if(l)return i._logger.info("[%s] Set remote SDP answer [%s]",i._channelContext.streamId,l.sessionDescription.sdp),e.setRemoteDescription(l.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,l.sessionDescription,e.message),e}))})).then((function(){if(c)return i._logger.info("[%s] Set remote SDP offer [%s]",i._channelContext.streamId,c.sessionDescription.sdp),e.setRemoteDescription(c.sessionDescription).catch((function(e){throw i._logger.info("[%s] Failed to set remote description [%j] with message [%s]",i._channelContext.streamId,c.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!0,offerToReceiveVideo:!0})})).then((function(e){return i._logger.info("[%s] Set local SDP answer [%j]",i._channelContext.streamId,e),i._channelContext.endPoint.value.setRemoteDescription(a,e)})).then((function(t){var n=t.status,r=t.sessionDescription;return i._channelContext.state.value=i.mapSetRemoteDescriptionStatusToChannelStatus(n),"ok"!==n?(i._channelContext.playing.value=!1,i._channelContext.standby.value=!0,void(i._channelContext.stopped.value=!1)):e.setLocalDescription(r).catch((function(e){throw i._logger.info("[%s] Failed to set local description [%j] with message [%s]",i._channelContext.streamId,r,e.message),e}))}))})).then((function(){return n.success(i._channelContext.streamId),f})).then((function(t){var n,a;if(o&&null!=e&&null!==(n=e.currentRemoteDescription)&&void 0!==n&&n.sdp){var s=new ft(e.currentRemoteDescription.sdp),u=e.getReceivers(),c=Kt.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 Ht(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 f=Kt.configureInsertableStreamTransformation(t,i._streamTransformContext.videoStreamTransformCallback,i._streamTransformContext.audioStreamTransformCallback),p=f.transformedStream,m=f.disposables;i._disposables.add(m),t=p}i._peerConnectionContext.mediaStream.value=t;var v=new mt(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 Ie(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 Ie(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=Fe.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!==Fe.Reconnecting&&i._channelContext.state.value!==Fe.Offline)return;i._channelContext.state.value=i._channelContext.playing.value?Fe.Playing:Fe.Paused,i._logger.info("Channel state restored to [%s] after reconnecting",Fe[i._channelContext.state.value])}else i._channelContext.state.value=Fe.Offline}}));return i._disposables.add(g),xe.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=Fe.Paused))}))}))}))}},{key:"applyRtcConfiguration",value:(e=A()(N().mark((function e(t,n){var r;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=pt.truncateIceServers(n),e.abrupt("return",xe.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=Qt(Qt({},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=Fe.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<xe.maximalNumberOfPeerConnectionReconnectAttempts||!xe.automaticallyReconnectPeerConnection){var r;this._peerConnectionContext.peerConnectionReconnectAttempts++;var i="offer"===(null===(r=e.currentLocalDescription)||void 0===r?void 0:r.type);if(T.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 Fe.Starting;case"unauthorized":return Fe.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return Fe.Recovering;case"failed":return Fe.Error;default:q(e)}}}]);var e}(),Xt=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=Y.parseToken(e).capabilities,s=a.includes("streaming"),u=a.includes("on-demand");return s||u?new lt(t,u?ct.OndDemand:ct.Live,o):new $t(t,n,r,i,o)}}])}(),Yt=function(){return o()((function e(n,r,i){var o=this;t()(this,e),s()(this,"_logger",Q.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=Y.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 Ve(r),this._channelContext=new Ue(u),this._peerConnectionContext=new ze,this._streamTransformContext=new He(c),this._stateContext=new Ge,this._exponentialBackoff=new ye,this._channelStartTime=Date.now(),this._readOnlyPeerConnection=new _(this._peerConnectionContext.peerConnection),this._readOnlyState=new _(this._channelContext.state),this._readOnlyAutoMuted=new _(this._channelContext.autoMuted),this._readOnlyAutoPaused=new _(this._channelContext.autoPaused),this._readOnlyTokenExpiring=new _(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new _(this._channelContext.authorized),this._readOnlyOnline=new _(this._channelContext.online),this._readOnlyLoading=new _(this._channelContext.loading),this._readOnlyPlaying=new _(this._channelContext.playing),this._readOnlyStandby=new _(this._channelContext.standby),this._readOnlyStopped=new _(this._channelContext.stopped),this._readOnlyTargetLag=new _(this._channelContext.targetLag),this._readOnlyLag=new _(this._channelContext.lag),this._readOnlyBitrateLimit=new _(this._channelContext.bitrateLimit),this._readOnlyResolution=new _(this._channelContext.resolution),this._readOnlyFailureCount=new _(this._channelContext.failureCount),this._readOnlyEndPoint=new _(this._channelContext.endPoint),this._readOnlyStream=new _(this._channelContext.stream),this._readOnlyRtcStatistics=new _(this._channelContext.rtcStatistics),this._readOnlyMediaStream=new _(this._peerConnectionContext.mediaStream);var l=(a.uri||xe.discoveryUri.value).toString();xe.tenancy.value=a.tenancy||xe.tenancy.value,de.uri.value=l,this._metricsService=Se.getMetricsService(l),this._sessionTelemetry=new Ae(xe.pageLoadTime,this._metricsService),this._channelContext.channelDisposables.add(this._sessionTelemetry),this._videoMetaDataChangedHandler=this.handleVideoMetaDataChanged.bind(this),this.videoElement=n,this._frameTimingInformationContext=new We,this.configureFrameTimingInformation(a),this._readOnlyIsFrameTimingInformationEnabled=new _(this._frameTimingInformationContext.isEnabled),this._readOnlyDecodedFrameTimingInformation=new _(this._frameTimingInformationContext.decodedFrameTimingInformation),this._readOnlyRenderedFrameTimingInformation=new _(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=xe.clientSessionId,o.videoElement.dataset.streamId=o.streamId),o._channelContext.videoTelemetry=new De(o.streamId,xe.pageLoadTime,o._channelStartTime,o._metricsService),o._channelContext.videoTelemetry.setupListenerForTimeToFirstTime(o.videoElement),o._channelContext.videoTelemetry.setupListenerForRebuffering(o.videoElement),o._channelContext.state.value===Fe.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===Fe.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,Me.Keep,Ne.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 p((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!==Fe.Initializing&&(this._channelContext.state.value=Fe.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 Te(e.videoWidth,e.videoHeight)):this._channelContext.resolution.value=Te.empty}},{key:"token",get:function(){return this._tokenContext.token.value},set:function(e){this._channelContext.disposables.dispose(),this._tokenContext.token.value=e,this._tokenContext.tokenExpiring.value=!1;var t=Y.parseToken(this._tokenContext.token.value),n=(t.uri||xe.discoveryUri.value).toString();xe.tenancy.value=t.tenancy||xe.tenancy.value,de.uri.value=n,this._metricsService=Se.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,Me.Keep,Ne.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=A()(N().mark((function e(t){var n=this;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((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=Fe.Stopped}},{key:"resume",value:(l=A()(N().mark((function e(){return N().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=A()(N().mark((function e(){var t=this;return N().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 Y.parseToken(e).uri||(this._logger.info("Fall back to the default discover URI [%s]",xe.discoveryUri.value),new w.value.URL(xe.discoveryUri.value))}},{key:"start",value:(u=A()(N().mark((function e(){return N().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=A()(N().mark((function e(){var t,n,r,i,o,a,s,u,c,l,d,h,f,m,v,g,y,_,b,C=this;return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._channelContext.state.value=Fe.Starting,this.cleanUpResources("client:start"),t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),Y.isEncodedEdgeTokenValid(t)){e.next=10;break}return this._logger.error("Failed to parse token [%s]",t),this._channelContext.state.value=Fe.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=je.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=Fe.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=je.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=Fe.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=Be.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=Fe.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=Be.validateEncodedStreamSink("audio",this._streamTransformContext.encodedAudioStreamSink),f=h.valid,m=h.validationResult,f){e.next=42;break}return this._logger.error(m),this._channelContext.state.value=Fe.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=Fe.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=Fe.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(T.isInsertableStreamsSupported){e.next=63;break}return this._logger.error("Browser does not support Media Stream Track API"),this._channelContext.state.value=Fe.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=Fe.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=Fe.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(T.isEncodedInsertableStreamsSupported||T.isRTCRtpScriptTransformSupported){e.next=84;break}return this._logger.error("Browser does not support encodedInsertableStreams API"),this._channelContext.state.value=Fe.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=Fe.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=Fe.ConfigurationError,this._channelContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 98:if(this._channelContext.loading.value=!0,y=this.getUri(t),this._channelContext.disposables.add(this._channelContext.state.subscribe((function(e){e!==Fe.Error&&e!==Fe.Recovering||Qe.clearCachedClosestEndpoint(y)}))),_=function(){return new Promise((function(e){return C._stateContext.isStarting.value=!1,e(C.handleStreamFailure())}))},b=Xt.create(t,this._channelContext,this._peerConnectionContext,this._streamTransformContext,this._frameTimingInformationContext,_)){e.next=106;break}return this._stateContext.isStarting.value=!1,e.abrupt("return");case 106:return e.abrupt("return",b.start(y,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=Fe.ClientStartError,C._logger.error("Failed to start channel",e)})).finally((function(){if(C._stateContext.isStarting.value=!1,C._channelContext.state.value!==Fe.Playing&&xe.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 p((function(){w.value.clearTimeout(e)})))}})));case 107:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"restartAfterStop",value:(i=A()(N().mark((function e(){return N().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=A()(N().mark((function e(){var t;return N().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 Fe.Initializing:case Fe.StandBy:case Fe.Offline:return 15e3;case Fe.Error:case Fe.Recovering:case Fe.Unauthorized:case Fe.GeoRestricted:case Fe.GeoBlocked:case Fe.Stopped:case Fe.Starting:case Fe.Playing:case Fe.Paused:case Fe.Reconnecting:case Fe.UnsupportedFeature:case Fe.ConfigurationError:case Fe.TransientConfigurationError:case Fe.ConnectionError:case Fe.ClientStartError:return this._exponentialBackoff.getExponentialBackoffIntervalByFailureCount(this._channelContext.failureCount.value);default:q(this._channelContext.state.value)}}},{key:"handleStreamFailure",value:(n=A()(N().mark((function e(){return N().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._channelContext.state.value,e.next=e.t0===Fe.Error||e.t0===Fe.Reconnecting||e.t0===Fe.StandBy||e.t0===Fe.Offline||e.t0===Fe.Recovering||e.t0===Fe.TransientConfigurationError||e.t0===Fe.ConnectionError||e.t0===Fe.ClientStartError?3:e.t0===Fe.Unauthorized?5:e.t0===Fe.GeoRestricted?7:e.t0===Fe.GeoBlocked?9:e.t0===Fe.Stopped?11:e.t0===Fe.Initializing?13:e.t0===Fe.Playing?15:e.t0===Fe.Paused?17:e.t0===Fe.Starting?19:e.t0===Fe.UnsupportedFeature?21:e.t0===Fe.ConfigurationError?23:25;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._channelContext.state.value,Fe[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:q(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(),!xe.forceGarbageCollectionOnRestart||T.isMobile&&xe.skipGarbageCollectionOnMobileDevices||Pe.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?T.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=A()(N().mark((function e(t){var n,r,i=this;return N().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=Fe.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=Fe.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=Fe.Playing})).catch((function(e){var r=!!t.getTracks().filter((function(e){return"audio"===e.kind})).length,o=!xe.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=Fe.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=Fe.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=Fe.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}(),en=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(!xe.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 Yt(e.videoElement,e.token,t)}},{key:"isFrameTimingInformationSupported",get:function(){return T.isChannelFrameTimingInformationSupported}}])}(),tn={SDK:xe,Channels:en,ChannelState:Fe}})(),r})()));
|
|
3
3
|
//# sourceMappingURL=channels.js.map
|