@phenixrts/sdk 2023.0.2 → 2023.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/debug/channels.js +1 -1
  2. package/dist/debug/full.js +1 -1
  3. package/dist/debug/groups.js +1 -1
  4. package/dist/debug/messaging.js +1 -1
  5. package/dist/debug/publish.js +3 -3
  6. package/dist/debug.private/channels.js +1 -1
  7. package/dist/debug.private/full.js +1 -1
  8. package/dist/debug.private/groups.js +1 -1
  9. package/dist/debug.private/messaging.js +1 -1
  10. package/dist/debug.private/publish.js +3 -3
  11. package/dist/es5.debug.private/channels.js +1 -1
  12. package/dist/es5.debug.private/full.js +1 -1
  13. package/dist/es5.debug.private/groups.js +1 -1
  14. package/dist/es5.debug.private/messaging.js +1 -1
  15. package/dist/es5.debug.private/publish.js +3 -3
  16. package/dist/legacy.debug/channels.js +1 -1
  17. package/dist/legacy.debug/full.js +1 -1
  18. package/dist/legacy.debug/groups.js +1 -1
  19. package/dist/legacy.debug/messaging.js +1 -1
  20. package/dist/legacy.debug/publish.js +3 -3
  21. package/dist/legacy.debug.private/channels.js +1 -1
  22. package/dist/legacy.debug.private/full.js +1 -1
  23. package/dist/legacy.debug.private/groups.js +1 -1
  24. package/dist/legacy.debug.private/messaging.js +1 -1
  25. package/dist/legacy.debug.private/publish.js +3 -3
  26. package/dist/legacy.min/channels.js +1 -1
  27. package/dist/legacy.min/full.js +1 -1
  28. package/dist/legacy.min/groups.js +1 -1
  29. package/dist/legacy.min/messaging.js +1 -1
  30. package/dist/legacy.min/publish.js +1 -1
  31. package/dist/legacy.min/publish.js.map +1 -1
  32. package/dist/min/channels.js +1 -1
  33. package/dist/min/full.js +1 -1
  34. package/dist/min/groups.js +1 -1
  35. package/dist/min/messaging.js +1 -1
  36. package/dist/min/publish.js +1 -1
  37. package/dist/min/publish.js.map +1 -1
  38. package/dist/min.private/channels.js +1 -1
  39. package/dist/min.private/full.js +1 -1
  40. package/dist/min.private/groups.js +1 -1
  41. package/dist/min.private/messaging.js +1 -1
  42. package/dist/min.private/publish.js +1 -1
  43. package/dist/min.private/publish.js.map +1 -1
  44. package/examples/src/channel-viewer-native-peer-connection-access.html +13 -0
  45. package/examples/src/channel-viewer-native-peer-connection-access.js +57 -0
  46. package/examples/src/user-media-publisher-change-video-track.html +27 -0
  47. package/examples/src/user-media-publisher-change-video-track.js +122 -0
  48. package/package.json +1 -1
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see publish.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,(function(){return(()=>{var e={228:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},858:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},646:(e,t,n)=>{var r=n(228);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},506: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},926:(e,t,n)=>{var r=n(202).default;function i(e,t,n,i,o,s,a){try{var u=e[s](a),c=u.value}catch(e){return void n(e)}u.done?t(c):r.resolve(c).then(i,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new r((function(r,o){var s=e.apply(t,n);function a(e){i(s,r,o,a,u,"next",e)}function u(e){i(s,r,o,a,u,"throw",e)}a(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},575: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},913:(e,t,n)=>{var r=n(696);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},713:(e,t,n)=>{var r=n(696);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},754: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},205:(e,t,n)=>{var r=n(489);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},860: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},884: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,s,a=[],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)&&(a.push(r.value),a.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}},e.exports.__esModule=!0,e.exports.default=e.exports},521: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},206: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},585:(e,t,n)=>{var r=n(8).default,i=n(506);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},591:(e,t,n)=>{var r=n(202).default,i=n(8).default;function o(){"use strict";e.exports=o=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},n=Object.prototype,s=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",h=u.toStringTag||"@@toStringTag";function p(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(e){p=function(e,t,n){return e[t]=n}}function d(e,t,n,r){var i=t&&t.prototype instanceof g?t:g,o=Object.create(i.prototype),s=new L(r||[]);return a(o,"_invoke",{value:x(e,n,s)}),o}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=d;var v={};function g(){}function y(){}function m(){}var _={};p(_,c,(function(){return this}));var b=Object.getPrototypeOf,w=b&&b(b(D([])));w&&w!==n&&s.call(w,c)&&(_=w);var C=m.prototype=g.prototype=Object.create(_);function k(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(r,o,a,u){var c=f(e[r],e,o);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==i(h)&&s.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,a,u)}),(function(e){n("throw",e,a,u)})):t.resolve(h).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,u)}))}u(c.arg)}var r;a(this,"_invoke",{value:function(e,i){function o(){return new t((function(t,r){n(e,i,t,r)}))}return r=r?r.then(o,o):o()}})}function x(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var s=n.delegate;if(s){var a=T(s,n);if(a){if(a===v)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=f(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function T(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=f(r,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,v;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,v):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,v)}function P(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 R(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function D(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(s.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return r.next=r}}return{next:O}}function O(){return{value:void 0,done:!0}}return y.prototype=m,a(C,"constructor",{value:m,configurable:!0}),a(m,"constructor",{value:y,configurable:!0}),y.displayName=p(m,h,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,p(e,h,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},k(S.prototype),p(S.prototype,l,(function(){return this})),t.AsyncIterator=S,t.async=function(e,n,i,o,s){void 0===s&&(s=r);var a=new S(d(e,n,i,o),s);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},k(C),p(C,h,"Generator"),p(C,c,(function(){return this})),p(C,"toString",(function(){return"[object Generator]"})),t.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}},t.values=D,L.prototype={constructor:L,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(R),!e)for(var t in this)"t"===t.charAt(0)&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},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 t=this;function n(n,r){return o.type="throw",o.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=s.call(i,"catchLoc"),u=s.call(i,"finallyLoc");if(a&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):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),v},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),R(n),v}},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;R(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:D(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),v}},t}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},489: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},38:(e,t,n)=>{var r=n(858),i=n(884),o=n(379),s=n(521);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},319:(e,t,n)=>{var r=n(646),i=n(860),o=n(379),s=n(206);e.exports=function(e){return r(e)||i(e)||o(e)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},868:(e,t,n)=>{var r=n(8).default;e.exports=function(e,t){if("object"!==r(e)||null===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},696:(e,t,n)=>{var r=n(8).default,i=n(868);e.exports=function(e){var t=i(e,"string");return"symbol"===r(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},8: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},379:(e,t,n)=>{var r=n(228);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.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},757:(e,t,n)=>{var r=n(591)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},202:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>d});var r=n(8),i=n.n(r),o=n(575),s=n.n(o),a=n(913),u=n.n(a),c=n(713),l=n.n(c),h=u()((function e(t,n,r){s()(this,e),l()(this,"onFulfilled",void 0),l()(this,"onRejected",void 0),l()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.promise=r})),p=function(){function e(t){if(s()(this,e),l()(this,"_state",void 0),l()(this,"_handled",void 0),l()(this,"_value",void 0),l()(this,"_deferreds",void 0),!(this instanceof e))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],this.doResolve(t)}return u()(e,[{key:"doResolve",value:function(e){var t=this,n=!1;try{e((function(e){n||(n=!0,t.promiseResolve(e))}),(function(e){n||(n=!0,t.promiseReject(e))}))}catch(e){if(n)return;n=!0,this.promiseReject(e)}}},{key:"promiseResolve",value:function(t){var n=this;try{if(t===n)throw new TypeError("A Promise cannot be resolved with it self.");if(t&&("object"===i()(t)||"function"==typeof t)){var r=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof r)return void n.doResolve((function(){r.apply(t,arguments)}))}n._state=1,n._value=t,n.finale()}catch(e){n.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate((function(){t._handled||e._unhandledRejection(t._value)}));for(var n=0,r=this._deferreds.length;n<r;n++)this.handle(this._deferreds[n]);this._deferreds=null}},{key:"handle",value:function(t){for(var n=this;3===n._state;)n=n._value;0!==n._state?(n._handled=!0,e._immediate((function(){var e=1===n._state?t.onFulfilled:t.onRejected;if(null!==e){var r;try{r=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(r)}else 1===n._state?t.promise.promiseResolve(n._value):t.promise.promiseReject(n._value)}))):n._deferreds.push(t)}}],[{key:"all",value:function(t){return new e((function(e,n){if(!Array.isArray(t))return n(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);for(var o=r.length,s=function t(s,a){try{if(a&&("object"===i()(a)||"function"==typeof a)){var u=a.then;if("function"==typeof u)return void u.call(a,(function(e){return t(s,e)}),n)}r[s]=a,0==--o&&e(r)}catch(e){n(e)}},a=0;a<r.length;a++)s(a,r[a])}))}},{key:"resolve",value:function(t){return t&&"object"===i()(t)&&t.constructor===e?t:new e((function(e){return e(t)}))}},{key:"reject",value:function(t){return new e((function(e,n){return n(t)}))}},{key:"race",value:function(t){return new e((function(n,r){if(!Array.isArray(t))return r(new TypeError("Promise.race accepts an array"));for(var i=0,o=t.length;i<o;i++)e.resolve(t[i]).then(n,r)}))}},{key:"_immediate",value:function(e){setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}]),e}();p.prototype.catch=function(e){return this.then(null,e)},p.prototype.then=function(e,t){var n=new this.constructor((function(){return null}));return this.handle(new h(e,t,n)),n},p.prototype.finally=function(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){return t.reject(n)}))}))};var d=p},112:(e,t,n)=>{"use strict";n.r(t),n.d(t,{PublisherState:()=>de,Publishers:()=>Je,SDK:()=>pe,default:()=>Ke});var r,i=n(575),o=n.n(i),s=n(913),a=n.n(s),u=n(713),c=n.n(u);!function(e){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"}(r||(r={}));var l=function(){function e(t,n,r){o()(this,e),c()(this,"_category",void 0),c()(this,"_appenders",void 0),c()(this,"_threshold",void 0),this._category=t,this._appenders=n,this._threshold=r}return a()(e,[{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>r.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.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?e+"\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}}]),e}(),h=function(){function e(){o()(this,e),c()(this,"_appenders",[])}return a()(e,[{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}),[])}}]),e}(),p=function(){function e(){o()(this,e)}return a()(e,null,[{key:"isPrivate",get:function(){return this._isPrivate}},{key:"applyIsPrivate",value:function(){try{this._isPrivate=!0}catch(e){this._isPrivate=!1}}}]),e}();c()(p,"_isPrivate",void 0),p.applyIsPrivate();var d=function(){function e(){o()(this,e)}return a()(e,null,[{key:"defaultLoggingLevel",get:function(){return p.isPrivate?r.Off:r.All}},{key:"defaultConsoleLoggingLevel",get:function(){return p.isPrivate?r.Off:r.All}},{key:"defaultTelemetryLoggingLevel",get:function(){return r.Info}}]),e}(),f=function(){function e(){o()(this,e),c()(this,"_threshold",d.defaultLoggingLevel)}return a()(e,[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}]),e}(),v=function(){function e(t){o()(this,e),c()(this,"_threshold",void 0),this._threshold=t}return a()(e,[{key:"log",value:function(e,t,n,i){if(!(e<this._threshold)){var o="".concat(i.toISOString()," [").concat(n,"] [").concat(r[e],"] ").concat(t);e<r.Warn?console.log(o):console.error(o)}}}]),e}(),g=n(926),y=n.n(g),m=n(757),_=n.n(m),b=function(){function e(){o()(this,e)}return a()(e,null,[{key:"sdkVersion",get:function(){try{return"2022-12-23T18:20:11.081Z (2023.0.2)"}catch(e){return this._defaultVersion}}}]),e}();c()(b,"_defaultVersion",(new Date).toISOString());var w,C=function(){function e(t){o()(this,e),c()(this,"_telemetryConfiguration",void 0),c()(this,"_logs",[]),c()(this,"_isSending",void 0),c()(this,"_domain",location.hostname),this._telemetryConfiguration=t}var t,n;return a()(e,[{key:"push",value:function(e,t,n,i){var o={timestamp:i.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:r[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:b.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain};e<r.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"sendLogs",value:(n=y()(_().mark((function e(t){var n;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,fetch(this._telemetryConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"sendLogsIfAble",value:(t=y()(_().mark((function e(){var t,n,r,i,o=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._logs.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:for(t=0,n=0,this._isSending=!0,r=function(e){return Object.values(e).reduce((function(e,t){return e+(t?t.length:0)}),0)};this._logs.length>t&&r(this._logs[t])+n<8192;)n+=r(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,r(this._logs[t])+(8192-r(this._logs[t]))),t=1),i=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.abrupt("return",this.sendLogs(i).then((function(e){return o._isSending=!1,o.sendLogsIfAble(),e})).catch((function(){o._isSending=!1,o.sendLogsIfAble()})));case 11:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),k=function(){function e(t){o()(this,e),c()(this,"_telemetryService",void 0),c()(this,"_tenancy",void 0),c()(this,"_sessionId",void 0),c()(this,"_threshold",void 0),this._tenancy=t.tenancy,this._sessionId=t.sessionId,this._threshold=t.threshold,this._telemetryService=new C(t)}return a()(e,[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}]),e}(),S=function(){function e(){o()(this,e),c()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),c()(this,"_tenancy",void 0),c()(this,"_sessionId",void 0),c()(this,"_environment",void 0),c()(this,"_threshold",d.defaultTelemetryLoggingLevel)}return a()(e,[{key:"url",get:function(){return this._url},set:function(e){var t=new URL(e);t.pathname=t.pathname+"/logs",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}]),e}(),x=function(){function e(){o()(this,e)}return a()(e,null,[{key:"defaultTelemetryLevel",get:function(){return p.isPrivate?w.Essential:w.All}}]),e}();!function(e){e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All"}(w||(w={}));var T=function(){function e(){o()(this,e),c()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),c()(this,"_tenancy",void 0),c()(this,"_sessionId",void 0),c()(this,"_environment",void 0),c()(this,"_threshold",x.defaultTelemetryLevel)}return a()(e,[{key:"url",get:function(){return this._url},set:function(e){var t=new URL(e);t.pathname=t.pathname+"/metrics",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}]),e}(),P=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},R=function(){function e(){o()(this,e)}return a()(e,null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case w.Off:return"Off";case w.Essential:return"Essential";case w.All:return"All";default:P(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return w.Off;case"Essential":return w.Essential;case"All":return w.All;default:P(e)}}}]),e}(),L=function(){function e(){o()(this,e)}return a()(e,null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case r.Off:return"Off";case r.Trace:return"Trace";case r.Debug:return"Debug";case r.Info:return"Trace";case r.Warn:return"Warn";case r.Error:return"Error";case r.Fatal:return"Fatal";case r.All:return"All";default:P(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return r.Off;case"Trace":return r.Trace;case"Debug":return r.Debug;case"Info":return r.Info;case"Warn":return r.Warn;case"Error":return r.Error;case"Fatal":return r.Fatal;case"All":return r.All;default:P(e)}}}]),e}(),D=function(){function e(){o()(this,e)}return a()(e,[{key:"getStringValue",value:function(e){return this.defaultStringValue[e]}},{key:"getBooleanValue",value:function(e){return this.defaultBooleanValue[e]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":R.convertTelemetryLevelToTelemetryLevelType(x.defaultTelemetryLevel),"phenix-logging-level":L.convertLoggingLevelToLoggingLevelType(d.defaultLoggingLevel),"phenix-console-logging-level":L.convertLoggingLevelToLoggingLevelType(d.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":L.convertLoggingLevelToLoggingLevelType(d.defaultTelemetryLoggingLevel),"phenix-channel-token":"","phenix-uri":"","phenix-base-uri":""}}},{key:"defaultBooleanValue",get:function(){return{"phenix-automatically-retry-on-failure":!0,"phenix-automatically-reconnect-peer-connection":!0}}}]),e}(),O=function(){function e(){throw o()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return a()(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 l(t,this._appenders,this._threshold))}},{key:"applyLoggerConfigFromParameterConfiguration",value:function(){e.applyLoggingLevel(),e.applyAppenderLoggingLevel("console",e.applyConsoleLogger.bind(this)),e.applyAppenderLoggingLevel("telemetry",e.applyTelemetryLogger.bind(this))}},{key:"applyLoggingLevel",value:function(){var e=this._configurationParameterReader.getStringValue("phenix-logging-level");r[e]&&this._threshold.setThreshold(r[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=this._configurationParameterReader.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(r[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new v(e||d.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||d.defaultTelemetryLoggingLevel,this._appenders.add(new k(this._telemetryConfiguration))}}]),e}();c()(O,"_configurationParameterReader",new D),c()(O,"_loggers",{}),c()(O,"_appenders",new h),c()(O,"_threshold",new f),c()(O,"_telemetryConfiguration",new S),O.applyLoggerConfigFromParameterConfiguration();var E=function(){function e(){throw o()(this,e),new Error("Strings is a static class that may not be instantiated")}return a()(e,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)}}]),e}(),A=n(205),I=n.n(A),F=n(585),M=n.n(F),j=n(754),V=n.n(j),N=function(){function e(t){o()(this,e),c()(this,"_disposed",void 0),c()(this,"_disposable",void 0),this._disposed=!1,this._disposable=t}return a()(e,[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}]),e}();var U=function(e){I()(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=V()(t);if(n){var i=V()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return M()(this,e)});function i(e,t){return o()(this,i),r.call(this,(function(){var n=e.indexOf(t);n>=0&&e.splice(n,1)}))}return a()(i)}(N),B=function(){function e(t){o()(this,e),c()(this,"_listeners",void 0),c()(this,"_value",void 0),this._listeners=[],this._value=t}return a()(e,[{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 U(this._listeners,e)}}]),e}(),z=function(){function e(t){o()(this,e),c()(this,"_subject",void 0),this._subject=t}return a()(e,[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}]),e}(),G=function(){function e(){o()(this,e)}return a()(e,null,[{key:"browserNameAndVersion",get:function(){return e._browserNameAndVersion}},{key:"browserName",get:function(){return this._browserName}},{key:"browserMajorVersion",get:function(){return this._browserMajorVersion}},{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:"parseBrowserNameAndVersion",value:function(){if(!navigator||!navigator.userAgent)return"";var t=navigator.userAgent.match(e._browserNameAndVersionRegex);return t&&t[0]?t[0]:e.parseBrowserNameAndVersionForIE()}},{key:"parseBrowserName",value:function(){if(!e._browserNameAndVersion)return"";var t=e._browserNameAndVersion.split("/");return t&&t[0]?t[0]:""}},{key:"parseBrowserMajorVersion",value:function(){if(!e._browserNameAndVersion)return 0;var t=e._browserNameAndVersion.split("/");if(!t||!t[1])return 0;var n=t[1];return n&&Number(n.split(".")[0])||0}},{key:"parseBrowserNameAndVersionForIE",value:function(){if(!navigator||!navigator.userAgent)return"";var e=navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return"IE/".concat(parseInt(e.substring(t+5,e.indexOf(".",t)),10));if(e.indexOf("Trident/")>0){var n=e.indexOf("rv:");return"IE/".concat(parseInt(e.substring(n+3,e.indexOf(".",n)),10))}return""}}]),e}();c()(G,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),c()(G,"_browserNameAndVersion",G.parseBrowserNameAndVersion()),c()(G,"_browserName",G.parseBrowserName()),c()(G,"_browserMajorVersion",G.parseBrowserMajorVersion()),c()(G,"_isChrome69",G._browserNameAndVersion.includes("Chrome/69.")),c()(G,"_isChrome70",G._browserNameAndVersion.includes("Chrome/70.")),c()(G,"_isChrome71",G._browserNameAndVersion.includes("Chrome/71.")),c()(G,"_isChrome72",G._browserNameAndVersion.includes("Chrome/72.")),c()(G,"_isChrome74",G._browserNameAndVersion.includes("Chrome/74.")),c()(G,"_isChrome75",G._browserNameAndVersion.includes("Chrome/75.")),c()(G,"_isChrome76",G._browserNameAndVersion.includes("Chrome/76.")),c()(G,"_isChrome77",G._browserNameAndVersion.includes("Chrome/77."));var H=function(){function e(){o()(this,e)}return a()(e,null,[{key:"clientOfferDisabled",get:function(){return G.isChrome74||G.isChrome75||G.isChrome76||G.isChrome77}},{key:"addTranceiverDisabled",get:function(){return G.isChrome69||G.isChrome70||G.isChrome71||G.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===G.browserName&&G.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===G.browserName&&G.browserMajorVersion<=69||"Firefox"===G.browserName&&G.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===G.browserName&&G.browserMajorVersion<=63||"Firefox"===G.browserName&&G.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===G.browserName&&G.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===G.browserName&&G.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===G.browserName||"SamsungBrowser"===G.browserName}},{key:"isRTMPEnabled",get:function(){return"Firefox"===G.browserName&&G.browserMajorVersion<84||"Chrome"===G.browserName&&G.browserMajorVersion<70||"Edge"===G.browserName||"IE"===G.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==G.browserName}}]),e}(),W=n(202).default,J=function(){function e(t){o()(this,e),c()(this,"_logger",O.getLogger("VanillaPeerConnection")),c()(this,"_peerConnection",void 0),H.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(t):this._peerConnection=new RTCPeerConnection(t)}var t,n,r,i;return a()(e,[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){return this._peerConnection.currentLocalDescription}},{key:"currentRemoteDescription",get:function(){return this._peerConnection.currentRemoteDescription}},{key:"iceConnectionState",get:function(){return this._peerConnection.iceConnectionState}},{key:"supportsGetConfiguration",get:function(){return"function"==typeof this._peerConnection.getConfiguration}},{key:"supportsSetConfiguration",get:function(){return"function"==typeof this._peerConnection.setConfiguration}},{key:"supportsAddTransceiver",get:function(){return!H.addTranceiverDisabled&&"function"==typeof this._peerConnection.addTransceiver}},{key:"createOffer",value:(i=y()(_().mark((function e(t){var n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!H.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new W((function(e,r){return n._peerConnection.createOffer(e,r,t)})));case 2:return e.abrupt("return",this._peerConnection.createOffer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"createAnswer",value:(r=y()(_().mark((function e(t){var n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!H.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new W((function(e,r){return n._peerConnection.createAnswer(e,r,t)})));case 2:return e.abrupt("return",this._peerConnection.createAnswer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setLocalDescription",value:(n=y()(_().mark((function e(t){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._peerConnection.setLocalDescription(H.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(t=y()(_().mark((function e(t){var n;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(null===(n=t.sdp)||void 0===n?void 0:n.match(/a=crypto:/i))&&this._logger.warn("SDP a=crypto is not supported"),e.abrupt("return",this._peerConnection.setRemoteDescription(H.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"getSenders",value:function(){return this._peerConnection.getSenders()}},{key:"getStats",value:function(e){return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;return new W((function(t){e._peerConnection.getStats(t)}))}},{key:"addEventListener",value:function(e,t,n){this._peerConnection.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){this._peerConnection.removeEventListener(e,t,n)}},{key:"addTransceiver",value:function(e,t){return this._peerConnection.addTransceiver(e,t)}},{key:"addStream",value:function(e){var t=this;e.getTracks().forEach((function(e){t._peerConnection.addTrack(e)}))}},{key:"getConfiguration",value:function(){return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){this._peerConnection.setConfiguration(e)}},{key:"ontrack",get:function(){return this._peerConnection.ontrack},set:function(e){this._peerConnection.ontrack=e}},{key:"onicecandidate",get:function(){return this._peerConnection.onicecandidate},set:function(e){this._peerConnection.onicecandidate=e}},{key:"oniceconnectionstatechange",get:function(){return this._peerConnection.oniceconnectionstatechange},set:function(e){this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){this._peerConnection.close()}}]),e}(),K=J,q=function(){function e(){o()(this,e)}var t;return a()(e,[{key:"createPeerConnection",value:(t=y()(_().mark((function e(t){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new K(t));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}(),Q=q,Y="DIGEST:",Z=function(){function e(){o()(this,e)}return a()(e,null,[{key:"parseToken",value:function(t){if(this.isValidToken(t))try{var n=atob(t.substr(Y.length)),r=JSON.parse(n);return r.token=JSON.parse(r.token),r}catch(t){return void e._logger.error("Cannot parse token value",t)}else e._logger.error("Token is not valid [%s]",t)}},{key:"getUri",value:function(e){return e&&e.token&&e.token.uri?new URL(e.token.uri):null}},{key:"getTenancy",value:function(e){return e&&e.applicationId?e.applicationId:""}},{key:"isValidToken",value:function(e){return!!e&&e.startsWith(Y)}}]),e}();c()(Z,"_logger",O.getLogger("EdgeAuth"));var $,X=n(8),ee=n.n(X),te=function(){function e(){o()(this,e),c()(this,"_list",[])}return a()(e,[{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,"]")}}]),e}(),ne=function(){function e(){o()(this,e),c()(this,"_disposables",new te),c()(this,"_readOnlyIsForeground",void 0),c()(this,"_isForeground",void 0),c()(this,"_timeOfLastTabFocusChange",Date.now()),c()(this,"_documentFocusInterval",void 0),this._isForeground=new B(!0),this._readOnlyIsForeground=new z(this._isForeground),this.detectTabFocusChange()}return a()(e,[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"detectTabFocusChange",value:function(){var e,t,n=this;if("object"===("undefined"==typeof document?"undefined":ee()(document))){void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden?(e="webkitHidden",t="webkitvisibilitychange"):void 0!==document.hidden&&(e="hidden",t="visibilitychange");var r=function(){var t=!document[e];n.setFocusState(t)};void 0!==document.addEventListener&&void 0!==document[e]?(document.addEventListener(t,r,!1),this._disposables.add(new N((function(){document.removeEventListener(t,r,!1)})))):this.listenForDocumentFocus.call(this)}}},{key:"listenForDocumentFocus",value:function(){var e=this;this._documentFocusInterval=window.setInterval((function(){var t=document.hasFocus();e.setFocusState(t)}),3e3),this._disposables.add(new N((function(){e._documentFocusInterval&&clearInterval(e._documentFocusInterval),e._documentFocusInterval=null})))}},{key:"setFocusState",value:function(e){this._isForeground!==e&&(this._isForeground.value=e)}}]),e}(),re=function(){function e(){o()(this,e)}return a()(e,null,[{key:"getTelemetryUrl",value:function(e){try{var t=new URL(e),n=t.hostname.split(".");switch(t.protocol){case"ws:":t.protocol="http:";break;case"wss:":t.protocol="https:"}return 2===n.length||3===n.length&&n[n.length-2].length<=2&&n[n.length-1].length<=3?n.unshift("telemetry"):n[0].startsWith("stg-")||n[0].endsWith("-stg")||n[0].includes("-stg-")||"stg"===n[0]?n[0]="telemetry-stg":n[0].startsWith("local")||n[0].endsWith("-local")||(n[0]="telemetry"),t.hostname=n.join("."),"".concat(t.origin,"/telemetry")}catch(t){return e}}}]),e}(),ie=function(){function e(){o()(this,e)}return a()(e,null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new URL(e).origin}catch(e){return""}}}]),e}(),oe=function(){function e(){throw o()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return a()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new URL(e.toString()),n=b.sdkVersion;return t.search="?".concat(new URLSearchParams([["version",n],["_","".concat(Date.now())]]).toString()),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}]),e}();c()(oe,"_discoveryUri",new B("https://pcast.phenixrts.com/pcast/endPoints")),function(e){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"}($||($={}));var se=$,ae=function(){function e(t){o()(this,e),c()(this,"_metrics",void 0),this._metrics=t}return a()(e,[{key:"getName",value:function(){return se[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case se.TimeToFirstFrame:case se.ChannelCreationTimeToFirstFrame:return w.Essential;case se.Stalled:case se.Buffering:case se.SetupCompleted:case se.SetupFailed:case se.RoundTripTime:case se.DownlinkThroughputCapacity:case se.NetworkType:case se.ResolutionChanged:case se.ApplicationForeground:case se.ApplicationBackground:return w.All;default:P(this._metrics)}}}]),e}(),ue=function(){function e(t){o()(this,e),c()(this,"_metricsConfiguration",void 0),c()(this,"_metrics",[]),c()(this,"_isSending",void 0),c()(this,"_domain",location.hostname),this._metricsConfiguration=t}var t,n;return a()(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,s=e.kind,a=new ae(e.metricType);if(!(this._metricsConfiguration.threshold>a.getTelemetryLevel())){var u={timestamp:(new Date).toISOString(),tenancy:this._metricsConfiguration.tenancy,sessionId:this._metricsConfiguration.sessionId,streamId:t,metric:a.getName(),value:n,previousValue:r,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:b.sdkVersion,runtime:i,resource:o,kind:s};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:(n=y()(_().mark((function e(t){var n;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,fetch(this._metricsConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(t=y()(_().mark((function e(){var t,n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._metrics.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.abrupt("return",this.sendMetrics(t).then((function(e){return n._isSending=!1,n.sendMetricsIfAble(),e})).catch((function(){n._isSending=!1,n.sendMetricsIfAble()})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),ce=function(){function e(){throw o()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return a()(e,null,[{key:"getMetricsService",value:function(t){if("string"!=typeof t)throw new Error("ur");var n=e._metricsServices[t];if(n)return n;var r=new T;return r.sessionId=pe.clientSessionId,r.tenancy=pe.tenancy.value,r.url=re.getTelemetryUrl(t),r.environment=ie.getEnvironmentFromUrl(t),r.threshold=R.convertTelemetryLevelTypeToTelemetryLevel(pe.telemetryLevel),e._metricsServices[t]=new ue(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}]),e}();c()(ce,"_metricsServices",{});var le,he=window.__phenixPageLoadTime||window.__pageLoadTime||Date.now(),pe=function(){function e(){throw o()(this,e),new Error("SDK is a static class that may not be instantiated")}return a()(e,null,[{key:"pageLoadTime",get:function(){return he}},{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:"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 L.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return R.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return G}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=O.telemetryConfiguration;n.sessionId=e.clientSessionId,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 k}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new k(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 k}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new k(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=ce.getMetricsService(oe.uri.value),e._metricsConfiguration=e._metricsService.metricsConfiguration,e._metricsConfiguration.sessionId=e.clientSessionId,e._environment.subscribe((function(t){e._metricsConfiguration.environment=t})),e.telemetryUrl.subscribe((function(t){e._metricsConfiguration.url=t})),e._tenancy.subscribe((function(t){e._metricsConfiguration.tenancy=t}));var t=this._configurationParameterReader.getStringValue("phenix-metrics-level");t&&ce.setTelemetryLevel(w[t]),e._telemetryLevel.subscribe((function(e){ce.setTelemetryLevel(e)}))}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=this._configurationParameterReader.getBooleanValue("phenix-automatically-retry-on-failure"),this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure)}},{key:"applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration",value:function(){this._automaticallyReconnectPeerConnection=this._configurationParameterReader.getBooleanValue("phenix-automatically-reconnect-peer-connection"),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection)}},{key:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe((function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=ie.getEnvironmentFromUrl(t)}));var t=this._configurationParameterReader.getStringValue("phenix-channel-token");if(t){var n=Z.parseToken(t);return e._tenancy.value=Z.getTenancy(n),oe.uri.value=(Z.getUri(n)||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var r=this._configurationParameterReader.getStringValue("phenix-uri");if(r)return oe.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=this._configurationParameterReader.getStringValue("phenix-base-uri");return i?(oe.uri.value="".concat(i,"/pcast/endPoints"),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)):void 0}},{key:"init",value:function(t){if(this._initialized.value||(this._applicationActivityMonitor=new ne),t){if(t.discoveryUri&&(oe.uri.value=t.discoveryUri),t.peerConnectionFactory&&(e._peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&w[t.telemetryLevel]&&(e._telemetryLevel.value=R.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&r[t.loggingLevel]&&this._logger.threshold.setThreshold(L.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&r[t.consoleLoggingLevel]){var n=this._logger.appenders.value.find((function(e){return e instanceof v}));n&&this._logger.appenders.remove(n),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new v(L.convertLoggingLevelTypeToLoggingLevel(t.consoleLoggingLevel)))}"boolean"==typeof t.automaticallyPlayMediaStream&&(this._automaticallyPlayMediaStream=t.automaticallyPlayMediaStream),"boolean"==typeof t.automaticallyMuteVideoOnPlayFailure&&(this._automaticallyMuteVideoOnPlayFailure=t.automaticallyMuteVideoOnPlayFailure),t.webPlayerLoader&&(this._webPlayerLoader=t.webPlayerLoader),t.shakaPlayerLoader&&(this._shakaPlayerLoader=t.shakaPlayerLoader),t.hlsJsLoader&&(this._hlsJsLoader=t.hlsJsLoader)}e._initialized.value=!0}},{key:"dispose",value:function(){e._initialized.value=!1,this._applicationActivityMonitor.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return re.getTelemetryUrl(e)}}]),e}();c()(pe,"_automaticallyRetryOnFailure",!0),c()(pe,"_automaticallyReconnectPeerConnection",!0),c()(pe,"_automaticallyPlayMediaStream",!0),c()(pe,"_automaticallyMuteVideoOnPlayFailure",!0),c()(pe,"_webPlayerLoader",null),c()(pe,"_shakaPlayerLoader",null),c()(pe,"_hlsJsLoader",null),c()(pe,"_configurationParameterReader",new D),c()(pe,"_applicationActivityMonitor",void 0),c()(pe,"_environment",new B("")),c()(pe,"_telemetryUrl",new B("https://telemetry.phenixrts.com/telemetry")),c()(pe,"_maximalNumberOfPeerConnectionReconnectAttempts",8),c()(pe,"_telemetryLevel",new B(x.defaultTelemetryLevel)),c()(pe,"_metricsService",void 0),c()(pe,"_metricsConfiguration",void 0),c()(pe,"_sendLocalCandidates",new B(!p.isPrivate)),c()(pe,"_tenancy",new B("")),c()(pe,"_clientSessionId",E.random(32)),c()(pe,"_loadedTimestamp",new Date),c()(pe,"_logger",O.getLogger("SDK")),c()(pe,"_initialized",new B(!1)),c()(pe,"_peerConnectionFactory",new B(new Q)),c()(pe,"_readOnlyInitialized",new z(pe._initialized)),c()(pe,"_readOnlyDiscoveryUri",new z(oe.uri)),c()(pe,"_readOnlyPeerConnectionFactory",new z(pe._peerConnectionFactory)),window.addEventListener("unload",(function(){pe.dispose()})),pe.applyDiscoveryUriDefaultFromParameterConfiguration(),pe.applyMetricsConfiguration(),pe.applyTelemetryConfiguration(),pe.applyAutomaticallyRetryOnFailureFromParameterConfiguration(),pe.applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration(),pe.init(),function(e){e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Publishing=3]="Publishing",e[e.Recovering=4]="Recovering",e[e.Reconnecting=5]="Reconnecting",e[e.StandBy=6]="StandBy",e[e.Stopped=7]="Stopped",e[e.Unauthorized=8]="Unauthorized",e[e.GeoRestricted=9]="GeoRestricted",e[e.GeoBlocked=10]="GeoBlocked",e[e.UnsupportedFeature=11]="UnsupportedFeature",e[e.Error=12]="Error"}(le||(le={}));var de=le,fe=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;o()(this,e),c()(this,"_duration",void 0),this._duration=t}return a()(e,[{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,s=(n=Math.floor(n/60))%24,a=["PT"];return e&&a.unshift("-"),s&&a.push(s+"H"),o&&a.push(o+"M"),(i||r)&&(a.push(String(i)),r&&a.push("."+this.padStart(r.toString(),3,"0")),a.push("S")),a.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)}}]),e}(),ve=function(){function e(t){o()(this,e),c()(this,"_logger",O.getLogger("StreamSetupListener")),c()(this,"metricsService",pe.metricsService),c()(this,"_pageLoadTime",void 0),c()(this,"_startTime",void 0),c()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=t}return a()(e,[{key:"success",value:function(e){this.recordStreamMetric(se.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(se.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new ae(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 fe(n-this._pageLoadTime).toIsoString(),t,i,new fe(r).toIsoString())}}}]),e}(),ge=function(){function e(){o()(this,e),c()(this,"_disposables",new te),c()(this,"_isSupported",navigator&&navigator.connection),c()(this,"_rtt",new B(void 0)),c()(this,"_effectiveType",new B(void 0)),c()(this,"_downlinkThroughputCapacity",new B(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())}return a()(e,[{key:"isSupported",get:function(){return this._isSupported}},{key:"rtt",get:function(){return this._rtt}},{key:"effectiveType",get:function(){return this._effectiveType}},{key:"downlinkThroughputCapacity",get:function(){return this._downlinkThroughputCapacity}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"getDownlinkThroughputCapacity",value:function(){return this.isSupported?navigator.connection.downlink||navigator.connection.downlinkMax:-1}},{key:"getEffectiveType",value:function(){return this.isSupported?navigator.connection.effectiveType||navigator.connection.type:"Unknown"}},{key:"getRoundTripTime",value:function(){return navigator.connection.rtt}},{key:"setupNetworkChangeListeners",value:function(){var e=this,t=function(){e.updateStatistics()};navigator.connection.addEventListener("change",t),this._disposables.add(new N((function(){navigator.connection.removeEventListener("change",t)})))}},{key:"updateStatistics",value:function(){this._rtt.value=this.getRoundTripTime(),this._effectiveType.value=this.getEffectiveType(),this._downlinkThroughputCapacity.value=this.getDownlinkThroughputCapacity()}}]),e}(),ye=function(){function e(t,n){var r=this;o()(this,e),c()(this,"_logger",O.getLogger("SessionTelemetry")),c()(this,"_metricsService",void 0),c()(this,"_applicationActivityMonitor",pe.applicationActivityMonitor),c()(this,"_networkMonitor",new ge),c()(this,"_pageLoadTime",void 0),c()(this,"_disposables",new te),c()(this,"_lastNetworkStatistics",{}),this._pageLoadTime=t,this._disposables.add(this._networkMonitor),this._metricsService=n,this._networkMonitor.isSupported&&(this._disposables.add(this._applicationActivityMonitor.isForeground.subscribe((function(e){r.recordForegroundChange(e)}))),this._disposables.add(this._networkMonitor.rtt.subscribe((function(e){r.recordNetworkRTTUpdate(e)}))),this._disposables.add(this._networkMonitor.effectiveType.subscribe((function(e){r.recordNetworkTypeChangeUpdate(e)}))),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe((function(e){r.recordNetworkDownlinkThroughputCapacityUpdate(e)}))))}return a()(e,[{key:"listenOnStreamSetup",value:function(){return new ve(this._pageLoadTime)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"recordForegroundChange",value:function(e){var t=Date.now(),n=this._applicationActivityMonitor.getTimeSinceLastChange();this._metricsService.push({metricType:e?se.ApplicationForeground:se.ApplicationBackground,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:n}}),this._logger.info("Application has gone into the [%s] after [%s] ms",e?"foreground":"background",new fe(n).toIsoString())}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:se.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 fe(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:se.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 fe(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:se.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 fe(t-this._pageLoadTime).toIsoString(),e,n)}}]),e}(),me=a()((function e(t){o()(this,e),c()(this,"token",void 0),c()(this,"tokenExpiring",void 0),this.token=new B(t),this.tokenExpiring=new B(!1)})),_e=function(){function e(t){o()(this,e),c()(this,"publisherInitialization",void 0),c()(this,"disposables",void 0),c()(this,"publisherDisposables",void 0),c()(this,"state",void 0),c()(this,"authorized",void 0),c()(this,"online",void 0),c()(this,"loading",void 0),c()(this,"publishing",void 0),c()(this,"standby",void 0),c()(this,"stopped",void 0),c()(this,"failureCount",void 0),c()(this,"endPoint",void 0),c()(this,"stream",void 0),c()(this,"rtcStatistics",void 0),c()(this,"clearFailureCountTimeout",void 0),c()(this,"name",void 0),c()(this,"rtcAudioStatistic",void 0),c()(this,"rtcVideoStatistic",void 0),this.disposables=new te,this.publisherDisposables=new te,this.publisherInitialization=new Date,this.state=new B(de.Starting),this.authorized=new B(!0),this.online=new B(!0),this.loading=new B(!1),this.publishing=new B(!1),this.standby=new B(!1),this.stopped=new B(!1),this.failureCount=new B(0),this.endPoint=new B(null),this.stream=new B(null),this.rtcStatistics=new B(null),this.name=t&&t.length?t:this.generateScreenName()}return a()(e,[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":this.authorized.value=!1;case"no-stream":case"not-found":return this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null,void(this.state.value=de.Error)}}},{key:"mapPublishStatusToPublisherStatus",value:function(e){switch(e){case"ok":return de.Starting;case"no-stream":case"not-found":return de.StandBy;case"geo-restricted":return de.GeoRestricted;case"geo-blocked":return de.GeoBlocked;case"unauthorized":return de.Unauthorized;case"capacity":case"rate-limited":case"timeout":return de.Recovering;case"failed":return de.Error;default:P(e)}}},{key:"generateScreenName",value:function(){return E.random(12)}}]),e}(),be=a()((function e(){o()(this,e),c()(this,"mediaStream",void 0),c()(this,"peerConnection",void 0),c()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new B(null),this.peerConnection=new B(null),this.peerConnectionReconnectAttempts=0})),we=a()((function e(){o()(this,e),c()(this,"isStarting",void 0),c()(this,"isDisposed",void 0),this.isStarting=new B(!1),this.isDisposed=!1})),Ce=n(38),ke=n.n(Ce),Se=function(){function e(){throw o()(this,e),new Error("PeerConnectionService is a static class that may not be instantiated")}var t,n;return a()(e,null,[{key:"initiateInitialPrecaching",value:function(){H.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error('Failed to pre-cache peer connection offer"',t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(n=y()(_().mark((function t(){return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e._cached={direction:"recvonly",peerConnection:e.createPeerConnectionOffer().catch((function(t){throw e._cached=null,t}))});case 1:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(t=y()(_().mark((function t(){var n,r,i,o=arguments;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=o.length>0&&void 0!==o[0]?o[0]:"recvonly",!e._cached||e._cached.direction!==n){t.next=5;break}return r=e._cached.peerConnection,e._cached=null,t.abrupt("return",r);case 5:return i=pe.peerConnectionFactory.value,t.abrupt("return",i.createPeerConnection().then(function(){var e=y()(_().mark((function e(t){var r,i,o;return _().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 7:case"end":return t.stop()}}),t)}))),function(){return t.apply(this,arguments)})}]),e}();c()(Se,"_logger",O.getLogger("PeerConnectionService")),c()(Se,"_cached",void 0),Se.initiateInitialPrecaching();var xe,Te,Pe=n(319),Re=n.n(Pe);!function(e){e[e.Keep=0]="Keep",e[e.Reset=1]="Reset"}(xe||(xe={})),function(e){e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset"}(Te||(Te={}));var Le=function(){function e(){o()(this,e)}return a()(e,null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Te.Normal:return"Normal";case Te.Force:return"Force";case Te.Reset:return"Reset";default:P(e)}}}]),e}(),De=function(){function e(){o()(this,e)}return a()(e,null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case xe.Keep:return"Keep";case xe.Reset:return"Reset";default:P(e)}}}]),e}(),Oe=n(202).default,Ee=function(){function e(t,n){if(o()(this,e),c()(this,"_logger",O.getLogger("EndPoint")),c()(this,"_uri",void 0),c()(this,"_timeout",void 0),c()(this,"_roundTripTime",void 0),this._uri=t,this._timeout=n,!n)throw new Error("End point requires a timeout")}var t,n,r,i,s,u,l,h,p,d,f,v;return a()(e,[{key:"roundTripTime",get:function(){return this._roundTripTime}},{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:(v=y()(_().mark((function e(){var t,n,r,i,o=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,Oe.race([fetch(t,{method:"GET",cache:"no-cache"}),new Oe((function(e,n){return setTimeout((function(){return n(new Error("Ping timed out [".concat(t,"]")))}),o._timeout)}))]);case 4:if(r=e.sent,i=Date.now(),r.ok){e.next=8;break}throw new Error("Ping failed [".concat(t,"] [").concat(r.status,"]"));case 8:return this._roundTripTime=i-n,e.abrupt("return",this._roundTripTime);case 10:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"subscribe",value:(f=y()(_().mark((function e(t,n,r){var i,o,s,a,u,c,l,h,p,d,f,v,g,y=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((i=Z.parseToken(t))&&i.applicationId){e.next=4;break}return this._logger.error("Failed to parse token [%s]",t),e.abrupt("return",{status:"unauthorized"});case 4:return o=i.applicationId,s=this.buildUrl([o,"stream","subscribe"]).toString(),a=new FormData,u=b.sdkVersion,0===r&&n?(c={apiVersion:6,clientVersion:u,edgeAuthToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:6,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(n.type),sdp:n.sdp}},createAnswerDescription:{apiVersion:6}},a.append("jsonBody",JSON.stringify(c))):(l={apiVersion:6,clientVersion:u,edgeAuthToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:6}},a.append("jsonBody",JSON.stringify(l))),h=Date.now(),e.prev=10,d=null,e.next=14,Oe.race([fetch(s,{method:"POST",body:a}),new Oe((function(e){return d=window.setTimeout((function(){y._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(s,"]"))),e({status:408})}),y._timeout)}))]).finally((function(){d&&clearTimeout(d)}));case 14:p=e.sent,e.next=21;break;case 17:return e.prev=17,e.t0=e.catch(10),this._logger.error("Failed to subscribe",e.t0),e.abrupt("return",{status:"failed"});case 21:if("ok"===(f=this.mapHttpStatusToSubscribeStatus(p))){e.next=24;break}return e.abrupt("return",{status:f});case 24:return v=Date.now(),e.next=27,this.convertHttpResponseToSubscribeResponse(o,p);case 27:return g=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",g,v-h),e.abrupt("return",g);case 30:case"end":return e.stop()}}),e,this,[[10,17]])}))),function(e,t,n){return f.apply(this,arguments)})},{key:"publish",value:(d=y()(_().mark((function e(t,n,r,i){var o,s,a,u,c,l,h,p,d,f,v,g,y,m=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((o=Z.parseToken(n))&&o.applicationId){e.next=4;break}return this._logger.error("Failed to parse token [%s]",n),e.abrupt("return",{status:"unauthorized"});case 4:return s=o.applicationId,a=this.buildUrl([s,"stream","publish"]).toString(),u=new FormData,c=b.sdkVersion,0===i&&r?(l={apiVersion:6,clientVersion:c,edgeAuthToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:6,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(r.type),sdp:r.sdp}},createAnswerDescription:{streamId:"",options:["upload"],apiVersion:6}},u.append("jsonBody",JSON.stringify(l))):(h={apiVersion:6,clientVersion:c,edgeAuthToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",options:["upload"],apiVersion:6}},u.append("jsonBody",JSON.stringify(h))),p=Date.now(),e.prev=10,f=null,e.next=14,Oe.race([fetch(a,{method:"POST",body:u}),new Oe((function(e){return f=window.setTimeout((function(){m._logger.error("Failed to publish",new Error("Publish timed out [".concat(a,"]"))),e({status:408})}),m._timeout)}))]).finally((function(){f&&clearTimeout(f)}));case 14:d=e.sent,e.next=21;break;case 17:return e.prev=17,e.t0=e.catch(10),this._logger.error("Failed to publish",e.t0),e.abrupt("return",{status:"failed"});case 21:if("ok"===(v=this.mapHttpStatusToPublishStatus(d))){e.next=24;break}return e.abrupt("return",{status:v});case 24:return g=Date.now(),e.next=27,this.convertHttpResponseToPublishResponse(s,d);case 27:return y=e.sent,this._logger.debug("Got publish response [%j] in [%s] ms",y,g-p),e.abrupt("return",y);case 30:case"end":return e.stop()}}),e,this,[[10,17]])}))),function(e,t,n,r){return d.apply(this,arguments)})},{key:"setRemoteDescription",value:(p=y()(_().mark((function e(t,n){var r,i,o,s,a,u,c,l,h,p=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new FormData,o={apiVersion:6,sharedSecret:t.sharedSecret,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(n.type),sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),s=Date.now(),e.prev=5,u=null,e.next=9,Oe.race([fetch(r,{method:"POST",body:i}),new Oe((function(e){return u=window.setTimeout((function(){p._logger.error("Failed to set remote description",new Error("Set remote description timed out [".concat(r,"]"))),e({status:408})}),p._timeout)}))]).finally((function(){u&&clearTimeout(u)}));case 9:a=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(a))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToSetRemoteDescriptionResponse(a);case 22:return h=e.sent,this._logger.debug("Got set remote description response [%j] in [%s] ms",h,l-s),e.abrupt("return",h);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return p.apply(this,arguments)})},{key:"limitBitrate",value:(h=y()(_().mark((function e(t,n,r,i,o){var s,a,u,c,l,h,p,d,f=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),a=new FormData,u={apiVersion:6,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:De.convertBitrateStateToBitrateStateType(i),bitrateMode:Le.convertBitrateModeToBitrateModeType(o)},a.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,h=null,e.next=9,Oe.race([fetch(s,{method:"POST",body:a}),new Oe((function(e){return h=window.setTimeout((function(){f._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(s,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){h&&clearTimeout(h)}));case 9:l=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set limit bitrate timed",e.t0),e.abrupt("return",{status:"failed"});case 16:return p=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),d=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",p,d-c),e.abrupt("return",{status:p});case 20:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t,n,r,i){return h.apply(this,arguments)})},{key:"addIceCandidates",value:(l=y()(_().mark((function e(t,n,r){var i,o,s,a,u,c,l,h,p,d,f=this,v=arguments;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=v.length>3&&void 0!==v[3]?v[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),s=new FormData,a={apiVersion:6,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},s.append("jsonBody",JSON.stringify(a)),u=Date.now(),e.prev=6,l=null,e.next=10,Oe.race([fetch(o,{method:"POST",body:s}),new Oe((function(e){return l=window.setTimeout((function(){f._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(o,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){l&&clearTimeout(l)}));case 10:c=e.sent,e.next=17;break;case 13:return e.prev=13,e.t0=e.catch(6),this._logger.error("Failed to add ice candidates",e.t0),e.abrupt("return",{status:"failed"});case 17:if("ok"===(h=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.next=20;break}return e.abrupt("return",{status:h});case 20:return p=Date.now(),e.next=23,this.convertHttpResponseToAddIceCandidatesResponse(c);case 23:return d=e.sent,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",d,p-u),e.abrupt("return",d);case 26:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e,t,n){return l.apply(this,arguments)})},{key:"destroyStream",value:(u=y()(_().mark((function e(t,n){var r,i,o,s,a,u,c,l,h,p=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new FormData,o={apiVersion:6,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),s=Date.now(),e.prev=5,u=null,e.next=9,Oe.race([fetch(r,{method:"POST",body:i,cache:"no-cache"}),new Oe((function(e){return u=window.setTimeout((function(){p._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})}),p._timeout)}))]).finally((function(){u&&clearTimeout(u)}));case 9:a=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(a))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToDestroyStreamResponse(a);case 22:return h=e.sent,this._logger.info("Got destroy stream response [%j] in [%s] ms",h,l-s),e.abrupt("return",h);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return u.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,Re()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new URL(this._uri),t=b.sdkVersion;return e.search="?".concat(new URLSearchParams([["type","http"],["version",t],["_","".concat(Date.now())]]).toString()),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 408:return"timeout";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 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:(s=y()(_().mark((function e(t,n){var r,i;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},i.lag=r.lag,r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.setRemoteDescriptionResponse.sessionDescription)}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createAnswerDescriptionResponse.sessionDescription)}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createOfferDescriptionResponse.sessionDescription)})),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(i=y()(_().mark((function e(t,n){var r,i;return _().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:this.convertISessionDescriptionToRTCSessionDescription(r.setRemoteDescriptionResponse.sessionDescription)}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createAnswerDescriptionResponse.sessionDescription)}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createOfferDescriptionResponse.sessionDescription)})),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={};if(e.bundlePolicy)switch(e.bundlePolicy){case"BundlePolicyBalanced":t.bundlePolicy="balanced";break;case"BundlePolicyMaxCompat":t.bundlePolicy="max-compat";break;case"BundlePolicyMaxBundle":t.bundlePolicy="max-bundle";break;default:P(e.bundlePolicy)}if("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}if(e.iceTransportPolicy)switch(e.iceTransportPolicy){case"IceTransportPolicyAll":t.iceTransportPolicy="all";break;case"IceTransportPolicyRelay":t.iceTransportPolicy="relay";break;case"IceTransportPolicyPublic":break;default:P(e.iceTransportPolicy)}if(e.peerIdentity&&(t.peerIdentity=e.peerIdentity),e.rtcpMuxPolicy)switch(e.rtcpMuxPolicy){case"RtcpMuxPolicyNegotiate":t.rtcpMuxPolicy="negotiate";break;case"RtcpMuxPolicyRequire":t.rtcpMuxPolicy="require";break;default:P(e.rtcpMuxPolicy)}return t}},{key:"convertISessionDescriptionToRTCSessionDescription",value:function(e){var t={sdp:e.sdp};switch(e.type){case"Offer":t.type="offer";break;case"Answer":t.type="answer";break;default:P(e.type)}return t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(r=y()(_().mark((function e(t){var n,r;return _().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=this.convertISessionDescriptionToRTCSessionDescription(n.sessionDescription)),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(n=y()(_().mark((function e(t){var n,r;return _().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:(t=y()(_().mark((function e(t){var n,r;return _().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(e){return t.apply(this,arguments)})},{key:"convertRTCSdpTypeToSdpType",value:function(e){switch(e){case"answer":return"Answer";case"offer":return"Offer";case"pranswer":case"rollback":throw new Error("SDP type [".concat(e,"] is not supported"));default:P(e)}}}]),e}(),Ae=n(202).default,Ie=function(){function e(t){if(o()(this,e),c()(this,"_logger",O.getLogger("Discovery")),c()(this,"_metricsService",void 0),c()(this,"_uri",void 0),!t)throw new Error("Discovery requires uri");this._metricsService=ce.getMetricsService(t.toString()),this._uri=t}var t,n;return a()(e,[{key:"discoverNearbyEndPoints",value:(n=y()(_().mark((function e(t,n){var r,i,o,s;return _().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,Ae.race([fetch(r,{method:"GET",cache:"no-cache"}),new Ae((function(e,t){return setTimeout((function(){return t(new Error("Discovery timed out [".concat(r,"]")))}),n)}))]);case 5:if((i=e.sent).ok){e.next=8;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 8:if(null!==i.body){e.next=10;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 10:return e.next=12,i.text();case 12:return o=e.sent,s=o.split(","),e.abrupt("return",s.map((function(e){return new Ee(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(t=y()(_().mark((function e(){var t,n,r,i,o,s=this,a=arguments;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.length>0&&void 0!==a[0]?a[0]:2e4,n=oe.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new URL(n),t);case 4:return r=e.sent,i=function(){return new Ae((function(){s._logger.info("Request [%s] failed, preventing it from completing",n)}))},e.next=8,Ae.race(r.map((function(e){return e.ping().catch((function(t){return s._logger.warn("Failed to ping end point [%s]",e,t),i()})).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:se.RoundTripTime,runtime:(n-pe.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e}))})));case 8:return o=e.sent,e.abrupt("return",o);case 10:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),Fe=function(){function e(){throw o()(this,e),new Error("Discovery is a static class that may not be instantiated")}var t,n;return a()(e,null,[{key:"precacheClosestEndPointDiscovery",value:(n=y()(_().mark((function t(){var n;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new URL(pe.discoveryUri.value),t.abrupt("return",e.discoverClosestEndPointWithCaching(n));case 2:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(t=y()(_().mark((function t(n){var r,i,o;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.toString(),!e._cache[r]){t.next=3;break}return t.abrupt("return",e._cache[r]);case 3:return i=new Ie(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then((function(){setTimeout((function(){e._cache[r]===o&&delete e._cache[r]}),6e4)})).catch((function(t){throw delete e._cache[r],t})),t.abrupt("return",o);case 7:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})}]),e}();c()(Fe,"_cache",{}),Fe.precacheClosestEndPointDiscovery();var Me=function(){function e(t){o()(this,e),c()(this,"_sdp",void 0),c()(this,"_audioCodec",void 0),c()(this,"_videoCodec",void 0),c()(this,"_isAudioTrackEnabled",void 0),c()(this,"_isVideoTrackEnabled",void 0),this._sdp=t;var n=this._sdp.split(/(\r\n|\r|\n)/),r=this._sdp.split("m=");this._audioCodec=this.applyCodec("audio",n),this._videoCodec=this.applyCodec("video",n),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",r),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",r)}return a()(e,[{key:"audioCodec",get:function(){return this._audioCodec}},{key:"videoCodec",get:function(){return this._videoCodec}},{key:"isAudioTrackEnabled",get:function(){return this._isAudioTrackEnabled}},{key:"isVideoTrackEnabled",get:function(){return this._isVideoTrackEnabled}},{key:"isTrackByTypeEnabled",value:function(e,t){var n=t.find((function(t){return t.startsWith(e)}));return!!n&&!n.includes("a=inactive")}},{key:"applyCodec",value:function(e,t){return t.find((function(n){return n.includes("a=rtpmap:".concat(t.find((function(t){return t.includes("m=".concat(e))})).split(" ")[3]))})).split(" ")[1].split("/")[0]}}]),e}(),je=function(){function e(t,n,r){if(o()(this,e),c()(this,"_estimatedRoundTripTime",void 0),c()(this,"_estimatedVideoCodec",void 0),c()(this,"_estimatedAudioCodec",void 0),c()(this,"_rtcStatistic",new B({})),c()(this,"_peerConnection",void 0),c()(this,"_isMonitorRunning",!0),c()(this,"_updateTimeOut",void 0),c()(this,"_availableTracks",void 0),this._peerConnection=t,this._estimatedRoundTripTime=r,this._peerConnection){var i=new Me(this._peerConnection.currentLocalDescription.sdp),s=new Me(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=s.audioCodec,this._estimatedVideoCodec=s.videoCodec,this._availableTracks={audio:i.isAudioTrackEnabled&&s.isAudioTrackEnabled,video:i.isVideoTrackEnabled&&s.isVideoTrackEnabled},this.updateStatistic()}}var t;return a()(e,[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeOut&&(clearTimeout(this._updateTimeOut),this._updateTimeOut=null)}},{key:"updateStatistic",value:(t=y()(_().mark((function e(){var t,n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!H.getStatsPromiseBasedDisabled){e.next=3;break}return e.abrupt("return");case 3:return t=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=6,this._peerConnection.getStats(null).then((function(e){var r={};if(e){var i,o=n._estimatedRoundTripTime;e.forEach((function(s){if("candidate-pair"===s.type&&s.currentRoundTripTime&&(o=1e3*s.currentRoundTripTime,r.audio&&(r.audio.roundTripTime=o),r.video&&(r.video.roundTripTime=o)),"candidate-pair"===s.type&&s.lastPacketSentTimestamp&&(i=s.lastPacketSentTimestamp,r.audio&&(r.audio.lastPacketSentTimestamp=i),r.video&&(r.video.lastPacketSentTimestamp=i)),"outbound-rtp"===s.type){var a=s.kind||s.mediaType||t(s),u="";if(e.forEach((function(e){e.id===s.codecId&&(u=e.mimeType)})),a&&n._availableTracks[a]){var c,l,h,p,d,f=(s.bytesSent||0)-(null!==(c=null===(l=n._rtcStatistic.value)||void 0===l||null===(h=l[a])||void 0===h?void 0:h.bytesSent)&&void 0!==c?c:0),v=s.timestamp-(null===(p=n._rtcStatistic.value)||void 0===p||null===(d=p[a])||void 0===d?void 0:d.timestamp),g=f&&v?Math.floor(8*f/v*1e3):0;if(r[a]={ssrc:s.ssrc,mediaType:a,timestamp:s.timestamp,bitrate:g,bytesSent:s.bytesSent,packetsSent:s.packetsSent,retransmittedBytesSent:s.retransmittedBytesSent,codec:u||n.getCodecByType(a),roundTripTime:o},(s.lastPacketSentTimestamp||i)&&(r[a].lastPacketSentTimestamp=s.lastPacketSentTimestamp||i),"video"===a&&n._rtcStatistic.value&&n._rtcStatistic.value.video){r[a].firCount=s.firCount,r[a].frameHeight=s.frameHeight,r[a].frameWidth=s.frameWidth,r[a].framesEncoded=s.framesEncoded,r[a].framesSent=s.framesSent,r[a].headerBytesSent=s.headerBytesSent,r[a].hugeFramesSent=s.hugeFramesSent,r[a].pliCount=s.pliCount,r[a].qpSum=s.qpSum,r[a].totalEncodeTime=s.totalEncodeTime,r[a].totalEncodedBytesTarget=s.totalEncodedBytesTarget;var y=(s.framesEncoded-n._rtcStatistic.value.video.framesEncoded)/(r[a].timestamp-n._rtcStatistic.value.video.timestamp)*1e3;r[a].fps=y?Math.round(100*y)/100:0}}}}))}n._rtcStatistic.value=r})).then((function(){n._isMonitorRunning&&(n._updateTimeOut=window.setTimeout((function(){return n.updateStatistic()}),1500))}));case 6:e.sent;case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec;case"video":return this._estimatedVideoCodec;default:return"unknown"}}}]),e}(),Ve=function(){function e(){throw o()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")}return a()(e,null,[{key:"truncateIceServers",value:function(e){for(var t=[],n=0;n<e.iceServers.length;n++){for(var r=[],i=0;i<2;i++)e.iceServers[n].urls[i]&&r.push(e.iceServers[n].urls[i]);t.push({urls:r,username:e.iceServers[n].username,credential:e.iceServers[n].credential})}return e.iceServers=t,e}}]),e}(),Ne=n(202).default;function Ue(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 Be(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ue(Object(n),!0).forEach((function(t){c()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ue(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ze=function(){function e(t,n,r){o()(this,e),c()(this,"_logger",O.getLogger("RealTimePublisher")),c()(this,"_publisherContext",void 0),c()(this,"_peerConnectionContext",void 0),c()(this,"_handleStreamFailure",void 0),this._publisherContext=t,this._peerConnectionContext=n,this._handleStreamFailure=r}var t;return a()(e,[{key:"start",value:function(e,t,n){var r=this;return Ne.all([Fe.discoverClosestEndPointWithCaching(e),Se.createPeerConnectionOffer("sendonly")]).then((function(e){var n=ke()(e,2),i=n[0],o=n[1],s=o.localOffer,a=o.peerConnection;return r._publisherContext.online.value=!0,r._publisherContext.endPoint.value=i,r._logger.info("Connecting to [%s]",i.toString()),r._logger.info("Local offer:\n"+s.sdp),!H.clientOfferDisabled&&a.supportsSetConfiguration&&a.supportsGetConfiguration||(a.close(),a=null,s=null),r._peerConnectionContext.peerConnection.value=a,i.publish(r._publisherContext.name,t,s,r._publisherContext.failureCount.value)})).then((function(e){var t=e.status,i=e.stream,o=e.rtcConfiguration,s=e.setRemoteDescriptionResponse,a=e.createOfferDescriptionResponse,u=e.createAnswerDescriptionResponse;if(r._publisherContext.stream.value=i,r._logger.debug("[%s] Publish completed [%s] [%j] [%j] [%j] [%j]",r._publisherContext.streamId,t,o,s,a,u),r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyStatus(t),"ok"===t)return r.applyRtcConfiguration(r._peerConnectionContext.peerConnection.value,o).then((function(e){var t,o=!1,c=!1,l=[];return r._peerConnectionContext.peerConnection.value=e,e.addStream(r._peerConnectionContext.mediaStream.value),e.onicecandidate=function(n){r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e&&(o||pe.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?l.push(n.candidate):c=!0,t||(t=setTimeout((function(){r._publisherContext.stream.value!==i||o||r._publisherContext.endPoint.value.addIceCandidates(i,l,c).then((function(e){var t=e.status,n=e.options;"ok"===t?(n.includes("cancel")&&(o=!0),r._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",r._publisherContext.streamId,t,n)):r._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",r._publisherContext.streamId,t)})).catch((function(e){r._logger.error("[%s] Failed to add ICE candidates",r._publisherContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e){var t=function(){r._publisherContext.state.value=de.Error,r._publisherContext.publishing.value=!1,r._publisherContext.loading.value=!0,r._handleStreamFailure().catch((function(t){r._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",r._publisherContext.streamId,e.iceConnectionState,t)}))};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return void(navigator.onLine&&(r._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",r._publisherContext.streamId,e.iceConnectionState),r.reconnectPeerConnection(e,t)));case"closed":return r._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",r._publisherContext.streamId,e.iceConnectionState),void t();default:P(e.iceConnectionState)}}},new Ne((function(e){e()})).then((function(){if(s)return r._logger.info("[%s] Set local SDP offer [%s]",r._publisherContext.streamId,s.sessionDescription.sdp),e.setLocalDescription(s.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,s.sessionDescription,e.message),e}))})).then((function(){if(u)return r._logger.info("[%s] Set remote SDP answer [%s]",r._publisherContext.streamId,u.sessionDescription.sdp),e.setRemoteDescription(u.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,u.sessionDescription,e.message),e}))})).then((function(){if(a)return r._logger.info("[%s] Set remote SDP offer [%s]",r._publisherContext.streamId,a.sessionDescription.sdp),e.setRemoteDescription(a.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,u.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!1,offerToReceiveVideo:!1})})).then((function(e){return r._logger.info("[%s] Set local SDP answer [%s]",r._publisherContext.streamId,e.sdp),r._publisherContext.endPoint.value.setRemoteDescription(i,e)})).then((function(t){var n=t.status,i=t.sessionDescription;return r._publisherContext.state.value=r.mapSetRemoteDescriptionStatusToPublisherStatus(n),"ok"!==n?(r._publisherContext.publishing.value=!1,r._publisherContext.standby.value=!0,void(r._publisherContext.stopped.value=!1)):(r._logger.info("[%s] Set local SDP [%s]",r._publisherContext.streamId,i.sdp),e.setLocalDescription(i).catch((function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,i,e.message),e})))}))})).then((function(){n.success(r._publisherContext.streamId),r._publisherContext.state.value=de.Publishing,r._publisherContext.publishing.value=!0;var t=new je(e,r._peerConnectionContext.mediaStream.value,r._publisherContext.endPoint.value.roundTripTime/4);return t.rtcStatistic.subscribe((function(n){if(r._publisherContext.rtcStatistics.value=n,!r._publisherContext.rtcVideoStatistic&&!r._publisherContext.rtcAudioStatistic)return r._publisherContext.rtcAudioStatistic=n.audio,void(r._publisherContext.rtcVideoStatistic=n.video);var i=!1,o=!1;n.audio&&r._publisherContext.rtcAudioStatistic&&r._publisherContext.rtcAudioStatistic.timestamp!==n.audio.timestamp&&((i=r._publisherContext.rtcAudioStatistic&&r._publisherContext.rtcAudioStatistic.bytesSent===n.audio.bytesSent)&&navigator.onLine&&r._logger.info("[%s] Audio track failed with last bytesSent [%s] is equal to previous bytesSent [%s] within [%s]",r._publisherContext.streamId,n.audio.bytesSent,r._publisherContext.rtcAudioStatistic.bytesSent,new fe(n.audio.timestamp-r._publisherContext.rtcAudioStatistic.timestamp).toIsoString()),r._publisherContext.rtcAudioStatistic=n.audio),n.video&&r._publisherContext.rtcVideoStatistic&&r._publisherContext.rtcVideoStatistic.timestamp!==n.video.timestamp&&((o=r._publisherContext.rtcVideoStatistic&&r._publisherContext.rtcVideoStatistic.bytesSent===n.video.bytesSent)&&navigator.onLine&&r._logger.info("[%s] Video track failed with last bytesSent [%s] is equal to previous bytesSent [%s] within [%s]",r._publisherContext.streamId,n.video.bytesSent,r._publisherContext.rtcVideoStatistic.bytesSent,new fe(n.video.timestamp-r._publisherContext.rtcVideoStatistic.timestamp).toIsoString()),r._publisherContext.rtcVideoStatistic=n.video),(o||i)&&navigator.onLine?r.reconnectPeerConnection(e,(function(){r._publisherContext.state.value=de.Error,r._publisherContext.loading.value=!0,t.dispose(),r._handleStreamFailure().catch((function(t){r._logger.error("[%s] Failed handling stream failure after track stopped with state [%s]",r._publisherContext.streamId,e.iceConnectionState,t)}))})):r._peerConnectionContext.peerConnectionReconnectAttempts=0})),Ne.resolve()}))}))}))}},{key:"applyRtcConfiguration",value:(t=y()(_().mark((function e(t,n){var r;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=Ve.truncateIceServers(n),e.abrupt("return",pe.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=Be(Be({},t.getConfiguration()),n),t.setConfiguration(r),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._publisherContext.state.value=de.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<pe.maximalNumberOfPeerConnectionReconnectAttempts||!pe.automaticallyReconnectPeerConnection){if(this._peerConnectionContext.peerConnectionReconnectAttempts++,H.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||this._publisherContext.failureCount.value)return;this._logger.info("Reconnecting peer connection by restarting ICE");var r=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(t){return e.setLocalDescription(t).then((function(){return e.setLocalDescription(r).then((function(){n._publisherContext.state.value=de.Publishing}))}))})).catch((function(e){n._logger.error("Failed to reconnect peer connection",e),n._peerConnectionContext.peerConnectionReconnectAttempts=0,t()}))}else this._logger.info("Failed to reconnect peer connection after [%s] attempts, performing full recovery",this._peerConnectionContext.peerConnectionReconnectAttempts),this._peerConnectionContext.peerConnectionReconnectAttempts=0,t()}},{key:"mapSetRemoteDescriptionStatusToPublisherStatus",value:function(e){switch(e){case"ok":return de.Starting;case"unauthorized":return de.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return de.Recovering;case"failed":return de.Error;default:P(e)}}}]),e}(),Ge=n(202).default,He="client:termination",We=function(){function e(t,n,r){var i=this;o()(this,e),c()(this,"_logger",O.getLogger("Publisher")),c()(this,"_tokenContext",void 0),c()(this,"_publisherContext",void 0),c()(this,"_peerConnectionContext",void 0),c()(this,"_stateContext",void 0),c()(this,"_publisherStartTime",void 0),c()(this,"_readOnlyToken",void 0),c()(this,"_readOnlyPeerConnection",void 0),c()(this,"_readOnlyState",void 0),c()(this,"_readOnlyTokenExpiring",void 0),c()(this,"_readOnlyAuthorized",void 0),c()(this,"_readOnlyOnline",void 0),c()(this,"_readOnlyLoading",void 0),c()(this,"_readOnlyPublishing",void 0),c()(this,"_readOnlyStandby",void 0),c()(this,"_readOnlyStopped",void 0),c()(this,"_readOnlyFailureCount",void 0),c()(this,"_readOnlyEndPoint",void 0),c()(this,"_readOnlyStream",void 0),c()(this,"_readOnlyRtcStatistics",void 0),c()(this,"_readOnlyMediaStream",void 0),c()(this,"_metricsService",void 0),c()(this,"_sessionTelemetry",void 0),this._tokenContext=new me(n),this._publisherContext=new _e(r),this._peerConnectionContext=new be,this._stateContext=new we,this._publisherStartTime=Date.now(),this._readOnlyToken=new z(this._tokenContext.token),this._readOnlyPeerConnection=new z(this._peerConnectionContext.peerConnection),this._readOnlyState=new z(this._publisherContext.state),this._readOnlyTokenExpiring=new z(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new z(this._publisherContext.authorized),this._readOnlyOnline=new z(this._publisherContext.online),this._readOnlyLoading=new z(this._publisherContext.loading),this._readOnlyPublishing=new z(this._publisherContext.publishing),this._readOnlyStandby=new z(this._publisherContext.standby),this._readOnlyStopped=new z(this._publisherContext.stopped),this._readOnlyFailureCount=new z(this._publisherContext.failureCount),this._readOnlyEndPoint=new z(this._publisherContext.endPoint),this._readOnlyStream=new z(this._publisherContext.stream),this._readOnlyRtcStatistics=new z(this._publisherContext.rtcStatistics),this._readOnlyMediaStream=new z(this._peerConnectionContext.mediaStream),this._peerConnectionContext.mediaStream.value=t;var s=Z.parseToken(this._tokenContext.token.value),a=(Z.getUri(s)||pe.discoveryUri.value).toString();pe.tenancy.value=Z.getTenancy(s)||pe.tenancy.value,oe.uri.value=a,this._metricsService=ce.getMetricsService(a),this._sessionTelemetry=new ye(pe.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe((function(e){i._publisherContext.clearFailureCountTimeout&&clearTimeout(i._publisherContext.clearFailureCountTimeout),i._publisherContext.failureCount.value&&e===de.Publishing&&(i._publisherContext.clearFailureCountTimeout=window.setTimeout((function(){i._publisherContext.failureCount.value=0}),3e3))})));var u=function(){i._publisherContext.stream.value&&i._publisherContext.endPoint.value&&i._publisherContext.endPoint.value.destroyStream(i._publisherContext.stream.value,"client:termination-on-window-unload")};window.addEventListener("beforeunload",u),this._publisherContext.publisherDisposables.add(new N((function(){window.removeEventListener("beforeunload",u)}))),this.start()}var t,n,r,i,s;return a()(e,[{key:"token",get:function(){return this._tokenContext.token.value},set:function(e){this._publisherContext.disposables.dispose(),this._tokenContext.token.value=e,this._tokenContext.tokenExpiring.value=!1;var t=Z.parseToken(this._tokenContext.token.value),n=(Z.getUri(t)||pe.discoveryUri.value).toString();pe.tenancy.value=Z.getTenancy(t)||pe.tenancy.value,oe.uri.value=n,this._metricsService=ce.getMetricsService(n),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"publishing",get:function(){return this._readOnlyPublishing}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._publisherContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"stop",value:(s=y()(_().mark((function e(t){var n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Ge((function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._publisherContext.disposables.add(n._stateContext.isStarting.subscribe((function(r){r||(n.processStop(t),e())})))})));case 1:case"end":return e.stop()}}),e)}))),function(e){return s.apply(this,arguments)})},{key:"processStop",value:function(e){this.cleanUpResources(e),this._peerConnectionContext.peerConnection.value&&(this._peerConnectionContext.peerConnection.value.close(),this._peerConnectionContext.peerConnection.value=null),this._publisherContext.state.value=de.Stopped}},{key:"dispose",value:(i=y()(_().mark((function e(){var t=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stop("client:channel-dispose").then((function(){t._publisherContext.publisherDisposables.dispose(),t._stateContext.isDisposed=!0})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getUri",value:function(e){var t=Z.parseToken(e);return Z.getUri(t)||(this._logger.info("Fall back to the default discover URI [%s]",pe.discoveryUri.value),new URL(pe.discoveryUri.value))}},{key:"start",value:(r=y()(_().mark((function e(){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._stateContext.isStarting.value){e.next=5;break}return this._logger.info("Publisher is already starting, skipping start"),e.abrupt("return");case 5:return this._stateContext.isStarting.value=!0,e.abrupt("return",this.processStart());case 7:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"setMediaStream",value:function(e){var t=this;this._peerConnectionContext.mediaStream.value=e,this._peerConnectionContext.peerConnection.value&&e.getTracks().forEach((function(e){t._peerConnectionContext.peerConnection.value.getSenders().forEach((function(t){var n;e.kind===(null==t||null===(n=t.track)||void 0===n?void 0:n.kind)&&t.replaceTrack(e)}))}))}},{key:"processStart",value:(n=y()(_().mark((function e(){var t,n,r,i,o,s=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),Z.isValidToken(t)){e.next=8;break}return this._logger.error("Failed to parse token [%s]",t),this._publisherContext.state.value=de.Unauthorized,this._publisherContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 8:return this.cleanUpResources("client:start"),this._publisherContext.state.value=de.Starting,this._publisherContext.loading.value=!0,r=this.getUri(t),i=function(){return new Ge((function(e){return s._stateContext.isStarting.value=!1,e(s.handleStreamFailure())}))},o=new ze(this._publisherContext,this._peerConnectionContext,i),e.abrupt("return",o.start(r,t,n).then((function(){s._publisherContext.loading.value=!1})).catch((function(e){n.fail(),s._publisherContext.failureCount.value++,s._publisherContext.online.value=!1,s.cleanUpResources("client:cleanup-after-failed-setup"),s._publisherContext.state.value=de.Error,s._logger.error("Failed to start publishing",e)})).finally((function(){if(s._stateContext.isStarting.value=!1,s._publisherContext.state.value!==de.Publishing&&pe.automaticRetryOnFailure){var e=setTimeout((function(){s.handleStreamFailure().catch((function(e){s._logger.error("Failed handling stream failure",e)}))}),s.getRetryInterval());s._publisherContext.disposables.add(new N((function(){clearTimeout(e)})))}})));case 15:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getRetryInterval",value:function(){switch(this._publisherContext.state.value){case de.StandBy:case de.Offline:return 15e3;case de.Error:case de.Recovering:case de.Unauthorized:case de.GeoRestricted:case de.GeoBlocked:case de.Stopped:case de.Starting:case de.Publishing:case de.Reconnecting:case de.UnsupportedFeature:return Math.min(3e5,Math.pow(2e3,Math.max(0,this._publisherContext.failureCount.value-1)));default:P(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:(t=y()(_().mark((function e(){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._publisherContext.state.value,e.next=e.t0===de.Error||e.t0===de.Reconnecting||e.t0===de.StandBy||e.t0===de.Offline||e.t0===de.Recovering?3:e.t0===de.Unauthorized?5:e.t0===de.GeoRestricted?7:e.t0===de.GeoBlocked?9:e.t0===de.Stopped?11:e.t0===de.Publishing?13:e.t0===de.Starting?15:e.t0===de.UnsupportedFeature?17:19;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,de[this._publisherContext.state.value]),e.abrupt("break",20);case 5:return this._logger.info("Publisher is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 7:return this._logger.info("Publisher is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 9:return this._logger.info("Publisher is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 11:return this._logger.info("Publisher is stopped, skipping retry of start."),e.abrupt("return");case 13:return this._logger.info("Publisher is publishing, skipping retry of start"),e.abrupt("return");case 15:return this._logger.info("Publisher is already starting, skipping retry of start"),e.abrupt("return");case 17:return this._logger.info("Publisher is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 19:P(this._publisherContext.state.value);case 20:return e.abrupt("return",this.start());case 21:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:He;this._publisherContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close()),this._publisherContext.publishing.value=!1,this._publisherContext.stopped.value=!0,this._publisherContext.standby.value=!1,this._publisherContext.stream.value&&this._publisherContext.endPoint.value&&this._publisherContext.endPoint.value.destroyStream(this._publisherContext.stream.value,t).then((function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)})).catch((function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)})),this._publisherContext.stream.value=null,this._publisherContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}}]),e}(),Je=function(){function e(){throw o()(this,e),new Error("Publishers is a static class that may not be instantiated")}return a()(e,null,[{key:"createPublisher",value:function(e){if(!pe.initialized.value)throw new Error("SDK is not loaded.");return new We(e.mediaStream,e.token,e.name)}}]),e}(),Ke={SDK:pe,Publishers:Je,PublisherState:de}}},t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}return 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})},n(112)})()}));
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,(function(){return(()=>{var e={228:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r},e.exports.__esModule=!0,e.exports.default=e.exports},858:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},646:(e,t,n)=>{var r=n(228);e.exports=function(e){if(Array.isArray(e))return r(e)},e.exports.__esModule=!0,e.exports.default=e.exports},506: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},926:(e,t,n)=>{var r=n(202).default;function i(e,t,n,i,o,s,a){try{var u=e[s](a),c=u.value}catch(e){return void n(e)}u.done?t(c):r.resolve(c).then(i,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new r((function(r,o){var s=e.apply(t,n);function a(e){i(s,r,o,a,u,"next",e)}function u(e){i(s,r,o,a,u,"throw",e)}a(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},575: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},913:(e,t,n)=>{var r=n(696);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},713:(e,t,n)=>{var r=n(696);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},754: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},205:(e,t,n)=>{var r=n(489);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},860: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},884: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,s,a=[],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)&&(a.push(r.value),a.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}},e.exports.__esModule=!0,e.exports.default=e.exports},521: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},206: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},585:(e,t,n)=>{var r=n(8).default,i=n(506);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},591:(e,t,n)=>{var r=n(202).default,i=n(8).default;function o(){"use strict";e.exports=o=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},n=Object.prototype,s=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",h=u.toStringTag||"@@toStringTag";function p(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{p({},"")}catch(e){p=function(e,t,n){return e[t]=n}}function d(e,t,n,r){var i=t&&t.prototype instanceof g?t:g,o=Object.create(i.prototype),s=new L(r||[]);return a(o,"_invoke",{value:x(e,n,s)}),o}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=d;var v={};function g(){}function y(){}function m(){}var _={};p(_,c,(function(){return this}));var b=Object.getPrototypeOf,w=b&&b(b(D([])));w&&w!==n&&s.call(w,c)&&(_=w);var C=m.prototype=g.prototype=Object.create(_);function k(e){["next","throw","return"].forEach((function(t){p(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function n(r,o,a,u){var c=f(e[r],e,o);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==i(h)&&s.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,a,u)}),(function(e){n("throw",e,a,u)})):t.resolve(h).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,u)}))}u(c.arg)}var r;a(this,"_invoke",{value:function(e,i){function o(){return new t((function(t,r){n(e,i,t,r)}))}return r=r?r.then(o,o):o()}})}function x(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var s=n.delegate;if(s){var a=T(s,n);if(a){if(a===v)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=f(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function T(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,T(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=f(r,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,v;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,v):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,v)}function P(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 R(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function D(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,r=function t(){for(;++n<e.length;)if(s.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return r.next=r}}return{next:O}}function O(){return{value:void 0,done:!0}}return y.prototype=m,a(C,"constructor",{value:m,configurable:!0}),a(m,"constructor",{value:y,configurable:!0}),y.displayName=p(m,h,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,p(e,h,"GeneratorFunction")),e.prototype=Object.create(C),e},t.awrap=function(e){return{__await:e}},k(S.prototype),p(S.prototype,l,(function(){return this})),t.AsyncIterator=S,t.async=function(e,n,i,o,s){void 0===s&&(s=r);var a=new S(d(e,n,i,o),s);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},k(C),p(C,h,"Generator"),p(C,c,(function(){return this})),p(C,"toString",(function(){return"[object Generator]"})),t.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}},t.values=D,L.prototype={constructor:L,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(R),!e)for(var t in this)"t"===t.charAt(0)&&s.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},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 t=this;function n(n,r){return o.type="throw",o.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=s.call(i,"catchLoc"),u=s.call(i,"finallyLoc");if(a&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):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),v},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),R(n),v}},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;R(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:D(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),v}},t}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},489: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},38:(e,t,n)=>{var r=n(858),i=n(884),o=n(379),s=n(521);e.exports=function(e,t){return r(e)||i(e,t)||o(e,t)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},319:(e,t,n)=>{var r=n(646),i=n(860),o=n(379),s=n(206);e.exports=function(e){return r(e)||i(e)||o(e)||s()},e.exports.__esModule=!0,e.exports.default=e.exports},868:(e,t,n)=>{var r=n(8).default;e.exports=function(e,t){if("object"!==r(e)||null===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},696:(e,t,n)=>{var r=n(8).default,i=n(868);e.exports=function(e){var t=i(e,"string");return"symbol"===r(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},8: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},379:(e,t,n)=>{var r=n(228);e.exports=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.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},757:(e,t,n)=>{var r=n(591)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},202:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>d});var r=n(8),i=n.n(r),o=n(575),s=n.n(o),a=n(913),u=n.n(a),c=n(713),l=n.n(c),h=u()((function e(t,n,r){s()(this,e),l()(this,"onFulfilled",void 0),l()(this,"onRejected",void 0),l()(this,"promise",void 0),this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.promise=r})),p=function(){function e(t){if(s()(this,e),l()(this,"_state",void 0),l()(this,"_handled",void 0),l()(this,"_value",void 0),l()(this,"_deferreds",void 0),!(this instanceof e))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],this.doResolve(t)}return u()(e,[{key:"doResolve",value:function(e){var t=this,n=!1;try{e((function(e){n||(n=!0,t.promiseResolve(e))}),(function(e){n||(n=!0,t.promiseReject(e))}))}catch(e){if(n)return;n=!0,this.promiseReject(e)}}},{key:"promiseResolve",value:function(t){var n=this;try{if(t===n)throw new TypeError("A Promise cannot be resolved with it self.");if(t&&("object"===i()(t)||"function"==typeof t)){var r=t.then;if(t instanceof e)return n._state=3,n._value=t,void n.finale();if("function"==typeof r)return void n.doResolve((function(){r.apply(t,arguments)}))}n._state=1,n._value=t,n.finale()}catch(e){n.promiseReject(e)}}},{key:"promiseReject",value:function(e){this._state=2,this._value=e,this.finale()}},{key:"finale",value:function(){var t=this;2===this._state&&0===this._deferreds.length&&e._immediate((function(){t._handled||e._unhandledRejection(t._value)}));for(var n=0,r=this._deferreds.length;n<r;n++)this.handle(this._deferreds[n]);this._deferreds=null}},{key:"handle",value:function(t){for(var n=this;3===n._state;)n=n._value;0!==n._state?(n._handled=!0,e._immediate((function(){var e=1===n._state?t.onFulfilled:t.onRejected;if(null!==e){var r;try{r=e(n._value)}catch(e){return void t.promise.promiseReject(e)}t.promise.promiseResolve(r)}else 1===n._state?t.promise.promiseResolve(n._value):t.promise.promiseReject(n._value)}))):n._deferreds.push(t)}}],[{key:"all",value:function(t){return new e((function(e,n){if(!Array.isArray(t))return n(new TypeError("Promise.all accepts an array"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);for(var o=r.length,s=function t(s,a){try{if(a&&("object"===i()(a)||"function"==typeof a)){var u=a.then;if("function"==typeof u)return void u.call(a,(function(e){return t(s,e)}),n)}r[s]=a,0==--o&&e(r)}catch(e){n(e)}},a=0;a<r.length;a++)s(a,r[a])}))}},{key:"resolve",value:function(t){return t&&"object"===i()(t)&&t.constructor===e?t:new e((function(e){return e(t)}))}},{key:"reject",value:function(t){return new e((function(e,n){return n(t)}))}},{key:"race",value:function(t){return new e((function(n,r){if(!Array.isArray(t))return r(new TypeError("Promise.race accepts an array"));for(var i=0,o=t.length;i<o;i++)e.resolve(t[i]).then(n,r)}))}},{key:"_immediate",value:function(e){setTimeout(e,0)}},{key:"_unhandledRejection",value:function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)}}]),e}();p.prototype.catch=function(e){return this.then(null,e)},p.prototype.then=function(e,t){var n=new this.constructor((function(){return null}));return this.handle(new h(e,t,n)),n},p.prototype.finally=function(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){return t.reject(n)}))}))};var d=p},112:(e,t,n)=>{"use strict";n.r(t),n.d(t,{PublisherState:()=>de,Publishers:()=>Je,SDK:()=>pe,default:()=>Ke});var r,i=n(575),o=n.n(i),s=n(913),a=n.n(s),u=n(713),c=n.n(u);!function(e){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"}(r||(r={}));var l=function(){function e(t,n,r){o()(this,e),c()(this,"_category",void 0),c()(this,"_appenders",void 0),c()(this,"_threshold",void 0),this._category=t,this._appenders=n,this._threshold=r}return a()(e,[{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>r.Trace)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Trace,t)}}},{key:"debug",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Debug)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Debug,t)}}},{key:"info",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Info)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Info,t)}}},{key:"warn",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Warn)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Warn,t)}}},{key:"error",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Error)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.Error,t)}}},{key:"fatal",value:function(){if(this._threshold.value&&!(this._threshold.value>r.Fatal)){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(r.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?e+"\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}}]),e}(),h=function(){function e(){o()(this,e),c()(this,"_appenders",[])}return a()(e,[{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}),[])}}]),e}(),p=function(){function e(){o()(this,e)}return a()(e,null,[{key:"isPrivate",get:function(){return this._isPrivate}},{key:"applyIsPrivate",value:function(){try{this._isPrivate=!0}catch(e){this._isPrivate=!1}}}]),e}();c()(p,"_isPrivate",void 0),p.applyIsPrivate();var d=function(){function e(){o()(this,e)}return a()(e,null,[{key:"defaultLoggingLevel",get:function(){return p.isPrivate?r.Off:r.All}},{key:"defaultConsoleLoggingLevel",get:function(){return p.isPrivate?r.Off:r.All}},{key:"defaultTelemetryLoggingLevel",get:function(){return r.Info}}]),e}(),f=function(){function e(){o()(this,e),c()(this,"_threshold",d.defaultLoggingLevel)}return a()(e,[{key:"value",get:function(){return this._threshold}},{key:"setThreshold",value:function(e){this._threshold=e}}]),e}(),v=function(){function e(t){o()(this,e),c()(this,"_threshold",void 0),this._threshold=t}return a()(e,[{key:"log",value:function(e,t,n,i){if(!(e<this._threshold)){var o="".concat(i.toISOString()," [").concat(n,"] [").concat(r[e],"] ").concat(t);e<r.Warn?console.log(o):console.error(o)}}}]),e}(),g=n(926),y=n.n(g),m=n(757),_=n.n(m),b=function(){function e(){o()(this,e)}return a()(e,null,[{key:"sdkVersion",get:function(){try{return"2023-01-06T18:19:52.372Z (2023.0.3)"}catch(e){return this._defaultVersion}}}]),e}();c()(b,"_defaultVersion",(new Date).toISOString());var w,C=function(){function e(t){o()(this,e),c()(this,"_telemetryConfiguration",void 0),c()(this,"_logs",[]),c()(this,"_isSending",void 0),c()(this,"_domain",location.hostname),this._telemetryConfiguration=t}var t,n;return a()(e,[{key:"push",value:function(e,t,n,i){var o={timestamp:i.toISOString(),tenancy:this._telemetryConfiguration.tenancy,level:r[e],category:n,message:t,sessionId:this._telemetryConfiguration.sessionId,version:b.sdkVersion,environment:this._telemetryConfiguration.environment,fullQualifiedName:this._domain};e<r.Error?this._logs.push(o):this._logs.unshift(o),this.sendLogsIfAble()}},{key:"sendLogs",value:(n=y()(_().mark((function e(t){var n;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,fetch(this._telemetryConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"sendLogsIfAble",value:(t=y()(_().mark((function e(){var t,n,r,i,o=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._logs.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:for(t=0,n=0,this._isSending=!0,r=function(e){return Object.values(e).reduce((function(e,t){return e+(t?t.length:0)}),0)};this._logs.length>t&&r(this._logs[t])+n<8192;)n+=r(this._logs[t]),t++;return t||(this._logs[t].message=this._logs[t].message.substring(0,r(this._logs[t])+(8192-r(this._logs[t]))),t=1),i=this._logs.slice(0,t),this._logs=this._logs.slice(t),e.abrupt("return",this.sendLogs(i).then((function(e){return o._isSending=!1,o.sendLogsIfAble(),e})).catch((function(){o._isSending=!1,o.sendLogsIfAble()})));case 11:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),k=function(){function e(t){o()(this,e),c()(this,"_telemetryService",void 0),c()(this,"_tenancy",void 0),c()(this,"_sessionId",void 0),c()(this,"_threshold",void 0),this._tenancy=t.tenancy,this._sessionId=t.sessionId,this._threshold=t.threshold,this._telemetryService=new C(t)}return a()(e,[{key:"log",value:function(e,t,n,r){e<this._threshold||this._telemetryService.push(e,t,n,r)}}]),e}(),S=function(){function e(){o()(this,e),c()(this,"_url","https://telemetry.phenixrts.com/telemetry/logs"),c()(this,"_tenancy",void 0),c()(this,"_sessionId",void 0),c()(this,"_environment",void 0),c()(this,"_threshold",d.defaultTelemetryLoggingLevel)}return a()(e,[{key:"url",get:function(){return this._url},set:function(e){var t=new URL(e);t.pathname=t.pathname+"/logs",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}]),e}(),x=function(){function e(){o()(this,e)}return a()(e,null,[{key:"defaultTelemetryLevel",get:function(){return p.isPrivate?w.Essential:w.All}}]),e}();!function(e){e[e.Off=100]="Off",e[e.Essential=10]="Essential",e[e.All=-1]="All"}(w||(w={}));var T=function(){function e(){o()(this,e),c()(this,"_url","https://telemetry.phenixrts.com/telemetry/metrics"),c()(this,"_tenancy",void 0),c()(this,"_sessionId",void 0),c()(this,"_environment",void 0),c()(this,"_threshold",x.defaultTelemetryLevel)}return a()(e,[{key:"url",get:function(){return this._url},set:function(e){var t=new URL(e);t.pathname=t.pathname+"/metrics",this._url=t.toString()}},{key:"environment",get:function(){return this._environment},set:function(e){this._environment=e}},{key:"tenancy",get:function(){return this._tenancy},set:function(e){this._tenancy=e}},{key:"sessionId",get:function(){return this._sessionId},set:function(e){this._sessionId=e}},{key:"threshold",get:function(){return this._threshold},set:function(e){this._threshold=e}}]),e}(),P=function(e){throw new Error("Unexpected value [".concat(e,"]. This should never be reached"))},R=function(){function e(){o()(this,e)}return a()(e,null,[{key:"convertTelemetryLevelToTelemetryLevelType",value:function(e){switch(e){case w.Off:return"Off";case w.Essential:return"Essential";case w.All:return"All";default:P(e)}}},{key:"convertTelemetryLevelTypeToTelemetryLevel",value:function(e){switch(e){case"Off":return w.Off;case"Essential":return w.Essential;case"All":return w.All;default:P(e)}}}]),e}(),L=function(){function e(){o()(this,e)}return a()(e,null,[{key:"convertLoggingLevelToLoggingLevelType",value:function(e){switch(e){case r.Off:return"Off";case r.Trace:return"Trace";case r.Debug:return"Debug";case r.Info:return"Trace";case r.Warn:return"Warn";case r.Error:return"Error";case r.Fatal:return"Fatal";case r.All:return"All";default:P(e)}}},{key:"convertLoggingLevelTypeToLoggingLevel",value:function(e){switch(e){case"Off":return r.Off;case"Trace":return r.Trace;case"Debug":return r.Debug;case"Info":return r.Info;case"Warn":return r.Warn;case"Error":return r.Error;case"Fatal":return r.Fatal;case"All":return r.All;default:P(e)}}}]),e}(),D=function(){function e(){o()(this,e)}return a()(e,[{key:"getStringValue",value:function(e){return this.defaultStringValue[e]}},{key:"getBooleanValue",value:function(e){return this.defaultBooleanValue[e]}},{key:"defaultStringValue",get:function(){return{"phenix-metrics-level":R.convertTelemetryLevelToTelemetryLevelType(x.defaultTelemetryLevel),"phenix-logging-level":L.convertLoggingLevelToLoggingLevelType(d.defaultLoggingLevel),"phenix-console-logging-level":L.convertLoggingLevelToLoggingLevelType(d.defaultConsoleLoggingLevel),"phenix-telemetry-logging-level":L.convertLoggingLevelToLoggingLevelType(d.defaultTelemetryLoggingLevel),"phenix-channel-token":"","phenix-uri":"","phenix-base-uri":""}}},{key:"defaultBooleanValue",get:function(){return{"phenix-automatically-retry-on-failure":!0,"phenix-automatically-reconnect-peer-connection":!0}}}]),e}(),O=function(){function e(){throw o()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return a()(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 l(t,this._appenders,this._threshold))}},{key:"applyLoggerConfigFromParameterConfiguration",value:function(){e.applyLoggingLevel(),e.applyAppenderLoggingLevel("console",e.applyConsoleLogger.bind(this)),e.applyAppenderLoggingLevel("telemetry",e.applyTelemetryLogger.bind(this))}},{key:"applyLoggingLevel",value:function(){var e=this._configurationParameterReader.getStringValue("phenix-logging-level");r[e]&&this._threshold.setThreshold(r[e])}},{key:"applyAppenderLoggingLevel",value:function(e,t){var n=this._configurationParameterReader.getStringValue("phenix-".concat(e,"-logging-level"));"Off"!==n&&t(r[n])}},{key:"applyConsoleLogger",value:function(e){this._appenders.add(new v(e||d.defaultConsoleLoggingLevel))}},{key:"applyTelemetryLogger",value:function(e){this._telemetryConfiguration.threshold=e||d.defaultTelemetryLoggingLevel,this._appenders.add(new k(this._telemetryConfiguration))}}]),e}();c()(O,"_configurationParameterReader",new D),c()(O,"_loggers",{}),c()(O,"_appenders",new h),c()(O,"_threshold",new f),c()(O,"_telemetryConfiguration",new S),O.applyLoggerConfigFromParameterConfiguration();var E=function(){function e(){throw o()(this,e),new Error("Strings is a static class that may not be instantiated")}return a()(e,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)}}]),e}(),A=n(205),I=n.n(A),F=n(585),M=n.n(F),j=n(754),V=n.n(j),N=function(){function e(t){o()(this,e),c()(this,"_disposed",void 0),c()(this,"_disposable",void 0),this._disposed=!1,this._disposable=t}return a()(e,[{key:"dispose",value:function(){if(!this._disposed)return this._disposed=!0,this._disposable.call(this)}}]),e}();var U=function(e){I()(i,e);var t,n,r=(t=i,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=V()(t);if(n){var i=V()(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return M()(this,e)});function i(e,t){return o()(this,i),r.call(this,(function(){var n=e.indexOf(t);n>=0&&e.splice(n,1)}))}return a()(i)}(N),B=function(){function e(t){o()(this,e),c()(this,"_listeners",void 0),c()(this,"_value",void 0),this._listeners=[],this._value=t}return a()(e,[{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 U(this._listeners,e)}}]),e}(),z=function(){function e(t){o()(this,e),c()(this,"_subject",void 0),this._subject=t}return a()(e,[{key:"value",get:function(){return this._subject.value}},{key:"subscribe",value:function(e){return this._subject.subscribe(e)}}]),e}(),G=function(){function e(){o()(this,e)}return a()(e,null,[{key:"browserNameAndVersion",get:function(){return e._browserNameAndVersion}},{key:"browserName",get:function(){return this._browserName}},{key:"browserMajorVersion",get:function(){return this._browserMajorVersion}},{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:"parseBrowserNameAndVersion",value:function(){if(!navigator||!navigator.userAgent)return"";var t=navigator.userAgent.match(e._browserNameAndVersionRegex);return t&&t[0]?t[0]:e.parseBrowserNameAndVersionForIE()}},{key:"parseBrowserName",value:function(){if(!e._browserNameAndVersion)return"";var t=e._browserNameAndVersion.split("/");return t&&t[0]?t[0]:""}},{key:"parseBrowserMajorVersion",value:function(){if(!e._browserNameAndVersion)return 0;var t=e._browserNameAndVersion.split("/");if(!t||!t[1])return 0;var n=t[1];return n&&Number(n.split(".")[0])||0}},{key:"parseBrowserNameAndVersionForIE",value:function(){if(!navigator||!navigator.userAgent)return"";var e=navigator.userAgent,t=e.indexOf("MSIE ");if(t>0)return"IE/".concat(parseInt(e.substring(t+5,e.indexOf(".",t)),10));if(e.indexOf("Trident/")>0){var n=e.indexOf("rv:");return"IE/".concat(parseInt(e.substring(n+3,e.indexOf(".",n)),10))}return""}}]),e}();c()(G,"_browserNameAndVersionRegex",/(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\/)([\d.apre]+)/g),c()(G,"_browserNameAndVersion",G.parseBrowserNameAndVersion()),c()(G,"_browserName",G.parseBrowserName()),c()(G,"_browserMajorVersion",G.parseBrowserMajorVersion()),c()(G,"_isChrome69",G._browserNameAndVersion.includes("Chrome/69.")),c()(G,"_isChrome70",G._browserNameAndVersion.includes("Chrome/70.")),c()(G,"_isChrome71",G._browserNameAndVersion.includes("Chrome/71.")),c()(G,"_isChrome72",G._browserNameAndVersion.includes("Chrome/72.")),c()(G,"_isChrome74",G._browserNameAndVersion.includes("Chrome/74.")),c()(G,"_isChrome75",G._browserNameAndVersion.includes("Chrome/75.")),c()(G,"_isChrome76",G._browserNameAndVersion.includes("Chrome/76.")),c()(G,"_isChrome77",G._browserNameAndVersion.includes("Chrome/77."));var H=function(){function e(){o()(this,e)}return a()(e,null,[{key:"clientOfferDisabled",get:function(){return G.isChrome74||G.isChrome75||G.isChrome76||G.isChrome77}},{key:"addTranceiverDisabled",get:function(){return G.isChrome69||G.isChrome70||G.isChrome71||G.isChrome72}},{key:"getStatsPromiseBasedDisabled",get:function(){return"Chrome"===G.browserName&&G.browserMajorVersion<=66}},{key:"getCurrentOfferDisabled",get:function(){return"Chrome"===G.browserName&&G.browserMajorVersion<=69||"Firefox"===G.browserName&&G.browserMajorVersion<=56}},{key:"onTrackDisabled",get:function(){return"Chrome"===G.browserName&&G.browserMajorVersion<=63||"Firefox"===G.browserName&&G.browserMajorVersion<=52}},{key:"webkitRTCPeerConnectionEnabled",get:function(){return"Chrome"===G.browserName&&G.browserMajorVersion<=55}},{key:"promiseBasedPCMethodsDisabled",get:function(){return"Firefox"===G.browserName&&G.browserMajorVersion<=52}},{key:"shouldUseNativeHls",get:function(){return"Safari"===G.browserName||"SamsungBrowser"===G.browserName}},{key:"isRTMPEnabled",get:function(){return"Firefox"===G.browserName&&G.browserMajorVersion<84||"Chrome"===G.browserName&&G.browserMajorVersion<70||"Edge"===G.browserName||"IE"===G.browserName}},{key:"isPrecachingEnabled",get:function(){return"IE"!==G.browserName}}]),e}(),W=n(202).default,J=function(){function e(t){o()(this,e),c()(this,"_logger",O.getLogger("VanillaPeerConnection")),c()(this,"_peerConnection",void 0),H.webkitRTCPeerConnectionEnabled?this._peerConnection=new webkitRTCPeerConnection(t):this._peerConnection=new RTCPeerConnection(t)}var t,n,r,i;return a()(e,[{key:"native",get:function(){return this._peerConnection}},{key:"currentLocalDescription",get:function(){return this._peerConnection.currentLocalDescription}},{key:"currentRemoteDescription",get:function(){return this._peerConnection.currentRemoteDescription}},{key:"iceConnectionState",get:function(){return this._peerConnection.iceConnectionState}},{key:"supportsGetConfiguration",get:function(){return"function"==typeof this._peerConnection.getConfiguration}},{key:"supportsSetConfiguration",get:function(){return"function"==typeof this._peerConnection.setConfiguration}},{key:"supportsAddTransceiver",get:function(){return!H.addTranceiverDisabled&&"function"==typeof this._peerConnection.addTransceiver}},{key:"createOffer",value:(i=y()(_().mark((function e(t){var n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!H.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new W((function(e,r){return n._peerConnection.createOffer(e,r,t)})));case 2:return e.abrupt("return",this._peerConnection.createOffer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"createAnswer",value:(r=y()(_().mark((function e(t){var n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!H.promiseBasedPCMethodsDisabled){e.next=2;break}return e.abrupt("return",new W((function(e,r){return n._peerConnection.createAnswer(e,r,t)})));case 2:return e.abrupt("return",this._peerConnection.createAnswer(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"setLocalDescription",value:(n=y()(_().mark((function e(t){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._peerConnection.setLocalDescription(H.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(t=y()(_().mark((function e(t){var n;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(null===(n=t.sdp)||void 0===n?void 0:n.match(/a=crypto:/i))&&this._logger.warn("SDP a=crypto is not supported"),e.abrupt("return",this._peerConnection.setRemoteDescription(H.promiseBasedPCMethodsDisabled?new RTCSessionDescription(t):t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"getSenders",value:function(){return this._peerConnection.getSenders()}},{key:"getStats",value:function(e){return this._peerConnection.getStats(e)}},{key:"getStatsLegacy",value:function(){var e=this;return new W((function(t){e._peerConnection.getStats(t)}))}},{key:"addEventListener",value:function(e,t,n){this._peerConnection.addEventListener(e,t,n)}},{key:"removeEventListener",value:function(e,t,n){this._peerConnection.removeEventListener(e,t,n)}},{key:"addTransceiver",value:function(e,t){return this._peerConnection.addTransceiver(e,t)}},{key:"addStream",value:function(e){var t=this;e.getTracks().forEach((function(e){t._peerConnection.addTrack(e)}))}},{key:"getConfiguration",value:function(){return this._peerConnection.getConfiguration()}},{key:"setConfiguration",value:function(e){this._peerConnection.setConfiguration(e)}},{key:"ontrack",get:function(){return this._peerConnection.ontrack},set:function(e){this._peerConnection.ontrack=e}},{key:"onicecandidate",get:function(){return this._peerConnection.onicecandidate},set:function(e){this._peerConnection.onicecandidate=e}},{key:"oniceconnectionstatechange",get:function(){return this._peerConnection.oniceconnectionstatechange},set:function(e){this._peerConnection.oniceconnectionstatechange=e}},{key:"close",value:function(){this._peerConnection.close()}}]),e}(),K=J,q=function(){function e(){o()(this,e)}var t;return a()(e,[{key:"createPeerConnection",value:(t=y()(_().mark((function e(t){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new K(t));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}(),Q=q,Y="DIGEST:",Z=function(){function e(){o()(this,e)}return a()(e,null,[{key:"parseToken",value:function(t){if(this.isValidToken(t))try{var n=atob(t.substr(Y.length)),r=JSON.parse(n);return r.token=JSON.parse(r.token),r}catch(t){return void e._logger.error("Cannot parse token value",t)}else e._logger.error("Token is not valid [%s]",t)}},{key:"getUri",value:function(e){return e&&e.token&&e.token.uri?new URL(e.token.uri):null}},{key:"getTenancy",value:function(e){return e&&e.applicationId?e.applicationId:""}},{key:"isValidToken",value:function(e){return!!e&&e.startsWith(Y)}}]),e}();c()(Z,"_logger",O.getLogger("EdgeAuth"));var $,X=n(8),ee=n.n(X),te=function(){function e(){o()(this,e),c()(this,"_list",[])}return a()(e,[{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,"]")}}]),e}(),ne=function(){function e(){o()(this,e),c()(this,"_disposables",new te),c()(this,"_readOnlyIsForeground",void 0),c()(this,"_isForeground",void 0),c()(this,"_timeOfLastTabFocusChange",Date.now()),c()(this,"_documentFocusInterval",void 0),this._isForeground=new B(!0),this._readOnlyIsForeground=new z(this._isForeground),this.detectTabFocusChange()}return a()(e,[{key:"isForeground",get:function(){return this._readOnlyIsForeground}},{key:"getTimeSinceLastChange",value:function(){return Date.now()-this._timeOfLastTabFocusChange}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"detectTabFocusChange",value:function(){var e,t,n=this;if("object"===("undefined"==typeof document?"undefined":ee()(document))){void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden?(e="webkitHidden",t="webkitvisibilitychange"):void 0!==document.hidden&&(e="hidden",t="visibilitychange");var r=function(){var t=!document[e];n.setFocusState(t)};void 0!==document.addEventListener&&void 0!==document[e]?(document.addEventListener(t,r,!1),this._disposables.add(new N((function(){document.removeEventListener(t,r,!1)})))):this.listenForDocumentFocus.call(this)}}},{key:"listenForDocumentFocus",value:function(){var e=this;this._documentFocusInterval=window.setInterval((function(){var t=document.hasFocus();e.setFocusState(t)}),3e3),this._disposables.add(new N((function(){e._documentFocusInterval&&clearInterval(e._documentFocusInterval),e._documentFocusInterval=null})))}},{key:"setFocusState",value:function(e){this._isForeground!==e&&(this._isForeground.value=e)}}]),e}(),re=function(){function e(){o()(this,e)}return a()(e,null,[{key:"getTelemetryUrl",value:function(e){try{var t=new URL(e),n=t.hostname.split(".");switch(t.protocol){case"ws:":t.protocol="http:";break;case"wss:":t.protocol="https:"}return 2===n.length||3===n.length&&n[n.length-2].length<=2&&n[n.length-1].length<=3?n.unshift("telemetry"):n[0].startsWith("stg-")||n[0].endsWith("-stg")||n[0].includes("-stg-")||"stg"===n[0]?n[0]="telemetry-stg":n[0].startsWith("local")||n[0].endsWith("-local")||(n[0]="telemetry"),t.hostname=n.join("."),"".concat(t.origin,"/telemetry")}catch(t){return e}}}]),e}(),ie=function(){function e(){o()(this,e)}return a()(e,null,[{key:"getEnvironmentFromUrl",value:function(e){try{return new URL(e).origin}catch(e){return""}}}]),e}(),oe=function(){function e(){throw o()(this,e),new Error("DiscoveryUri is a static class that may not be instantiated")}return a()(e,null,[{key:"uri",get:function(){return e._discoveryUri}},{key:"buildDiscoveryUrl",value:function(e){var t=new URL(e.toString()),n=b.sdkVersion;return t.search="?".concat(new URLSearchParams([["version",n],["_","".concat(Date.now())]]).toString()),"/"===t.pathname&&(t.pathname="/pcast/endPoints"),t.toString()}}]),e}();c()(oe,"_discoveryUri",new B("https://pcast.phenixrts.com/pcast/endPoints")),function(e){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"}($||($={}));var se=$,ae=function(){function e(t){o()(this,e),c()(this,"_metrics",void 0),this._metrics=t}return a()(e,[{key:"getName",value:function(){return se[this._metrics]}},{key:"getTelemetryLevel",value:function(){switch(this._metrics){case se.TimeToFirstFrame:case se.ChannelCreationTimeToFirstFrame:return w.Essential;case se.Stalled:case se.Buffering:case se.SetupCompleted:case se.SetupFailed:case se.RoundTripTime:case se.DownlinkThroughputCapacity:case se.NetworkType:case se.ResolutionChanged:case se.ApplicationForeground:case se.ApplicationBackground:return w.All;default:P(this._metrics)}}}]),e}(),ue=function(){function e(t){o()(this,e),c()(this,"_metricsConfiguration",void 0),c()(this,"_metrics",[]),c()(this,"_isSending",void 0),c()(this,"_domain",location.hostname),this._metricsConfiguration=t}var t,n;return a()(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,s=e.kind,a=new ae(e.metricType);if(!(this._metricsConfiguration.threshold>a.getTelemetryLevel())){var u={timestamp:(new Date).toISOString(),tenancy:this._metricsConfiguration.tenancy,sessionId:this._metricsConfiguration.sessionId,streamId:t,metric:a.getName(),value:n,previousValue:r,fullQualifiedName:this._domain,environment:this._metricsConfiguration.environment,version:b.sdkVersion,runtime:i,resource:o,kind:s};this._metrics.push(u),this.sendMetricsIfAble()}}},{key:"sendMetrics",value:(n=y()(_().mark((function e(t){var n;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("jsonBody",JSON.stringify({records:t})),e.next=4,fetch(this._metricsConfiguration.url,{method:"POST",body:n});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"sendMetricsIfAble",value:(t=y()(_().mark((function e(){var t,n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._metrics.length<=0||this._isSending)){e.next=2;break}return e.abrupt("return");case 2:return this._isSending=!0,t=this._metrics.slice(0,1024),this._metrics=this._metrics.slice(1024),e.abrupt("return",this.sendMetrics(t).then((function(e){return n._isSending=!1,n.sendMetricsIfAble(),e})).catch((function(){n._isSending=!1,n.sendMetricsIfAble()})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),ce=function(){function e(){throw o()(this,e),new Error("LoggerFactory is a static class that may not be instantiated")}return a()(e,null,[{key:"getMetricsService",value:function(t){if("string"!=typeof t)throw new Error("ur");var n=e._metricsServices[t];if(n)return n;var r=new T;return r.sessionId=pe.clientSessionId,r.tenancy=pe.tenancy.value,r.url=re.getTelemetryUrl(t),r.environment=ie.getEnvironmentFromUrl(t),r.threshold=R.convertTelemetryLevelTypeToTelemetryLevel(pe.telemetryLevel),e._metricsServices[t]=new ue(r)}},{key:"setTelemetryLevel",value:function(t){var n=Object.values(e._metricsServices);n&&n.length&&n.forEach((function(e){e.metricsConfiguration.threshold=t}))}}]),e}();c()(ce,"_metricsServices",{});var le,he=window.__phenixPageLoadTime||window.__pageLoadTime||Date.now(),pe=function(){function e(){throw o()(this,e),new Error("SDK is a static class that may not be instantiated")}return a()(e,null,[{key:"pageLoadTime",get:function(){return he}},{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:"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 L.convertLoggingLevelToLoggingLevelType(this._logger.threshold.value)}},{key:"telemetryLevel",get:function(){return R.convertTelemetryLevelToTelemetryLevelType(e._telemetryLevel.value)}},{key:"browserDetector",get:function(){return G}},{key:"applyTelemetryConfiguration",value:function(){var t=this,n=O.telemetryConfiguration;n.sessionId=e.clientSessionId,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 k}));r&&(n.url=e,t._logger.appenders.remove(r),t._logger.appenders.add(new k(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 k}));r&&e&&(n.tenancy=e,t._logger.appenders.remove(r),t._logger.appenders.add(new k(n)),t._logger.info("Telemetry tenancy was set to [%s]",n.tenancy))}))}},{key:"applyMetricsConfiguration",value:function(){e._metricsService=ce.getMetricsService(oe.uri.value),e._metricsConfiguration=e._metricsService.metricsConfiguration,e._metricsConfiguration.sessionId=e.clientSessionId,e._environment.subscribe((function(t){e._metricsConfiguration.environment=t})),e.telemetryUrl.subscribe((function(t){e._metricsConfiguration.url=t})),e._tenancy.subscribe((function(t){e._metricsConfiguration.tenancy=t}));var t=this._configurationParameterReader.getStringValue("phenix-metrics-level");t&&ce.setTelemetryLevel(w[t]),e._telemetryLevel.subscribe((function(e){ce.setTelemetryLevel(e)}))}},{key:"applyAutomaticallyRetryOnFailureFromParameterConfiguration",value:function(){this._automaticallyRetryOnFailure=this._configurationParameterReader.getBooleanValue("phenix-automatically-retry-on-failure"),this._logger.info("Automatically retry on failure is set to: [%s]",this._automaticallyRetryOnFailure)}},{key:"applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration",value:function(){this._automaticallyReconnectPeerConnection=this._configurationParameterReader.getBooleanValue("phenix-automatically-reconnect-peer-connection"),this._logger.info("Automatically reconnect peer connection is set to: [%s]",this._automaticallyReconnectPeerConnection)}},{key:"applyDiscoveryUriDefaultFromParameterConfiguration",value:function(){e.discoveryUri.subscribe((function(t){e.telemetryUrl.value=e.getTelemetryUrl(t),e._environment.value=ie.getEnvironmentFromUrl(t)}));var t=this._configurationParameterReader.getStringValue("phenix-channel-token");if(t){var n=Z.parseToken(t);return e._tenancy.value=Z.getTenancy(n),oe.uri.value=(Z.getUri(n)||e.discoveryUri.value).toString(),void this._logger.info("Discovery URI set from configuration parameter to [%s]",e.discoveryUri.value)}var r=this._configurationParameterReader.getStringValue("phenix-uri");if(r)return oe.uri.value=r,void this._logger.info('Discovery URI set from "phenix-uri" configuration parameter tag to [%s]',e.discoveryUri.value);var i=this._configurationParameterReader.getStringValue("phenix-base-uri");return i?(oe.uri.value="".concat(i,"/pcast/endPoints"),void this._logger.info('Discovery URI set from "phenix-base-uri" configuration parameter tag to [%s]',e.discoveryUri.value)):void 0}},{key:"init",value:function(t){if(this._initialized.value||(this._applicationActivityMonitor=new ne),t){if(t.discoveryUri&&(oe.uri.value=t.discoveryUri),t.peerConnectionFactory&&(e._peerConnectionFactory.value=t.peerConnectionFactory),t.telemetryLevel&&w[t.telemetryLevel]&&(e._telemetryLevel.value=R.convertTelemetryLevelTypeToTelemetryLevel(t.telemetryLevel)),t.loggingLevel&&r[t.loggingLevel]&&this._logger.threshold.setThreshold(L.convertLoggingLevelTypeToLoggingLevel(t.loggingLevel)),t.consoleLoggingLevel&&r[t.consoleLoggingLevel]){var n=this._logger.appenders.value.find((function(e){return e instanceof v}));n&&this._logger.appenders.remove(n),"Off"!==t.consoleLoggingLevel&&this._logger.appenders.add(new v(L.convertLoggingLevelTypeToLoggingLevel(t.consoleLoggingLevel)))}"boolean"==typeof t.automaticallyPlayMediaStream&&(this._automaticallyPlayMediaStream=t.automaticallyPlayMediaStream),"boolean"==typeof t.automaticallyMuteVideoOnPlayFailure&&(this._automaticallyMuteVideoOnPlayFailure=t.automaticallyMuteVideoOnPlayFailure),t.webPlayerLoader&&(this._webPlayerLoader=t.webPlayerLoader),t.shakaPlayerLoader&&(this._shakaPlayerLoader=t.shakaPlayerLoader),t.hlsJsLoader&&(this._hlsJsLoader=t.hlsJsLoader)}e._initialized.value=!0}},{key:"dispose",value:function(){e._initialized.value=!1,this._applicationActivityMonitor.dispose(),this._applicationActivityMonitor=null}},{key:"getTelemetryUrl",value:function(e){return re.getTelemetryUrl(e)}}]),e}();c()(pe,"_automaticallyRetryOnFailure",!0),c()(pe,"_automaticallyReconnectPeerConnection",!0),c()(pe,"_automaticallyPlayMediaStream",!0),c()(pe,"_automaticallyMuteVideoOnPlayFailure",!0),c()(pe,"_webPlayerLoader",null),c()(pe,"_shakaPlayerLoader",null),c()(pe,"_hlsJsLoader",null),c()(pe,"_configurationParameterReader",new D),c()(pe,"_applicationActivityMonitor",void 0),c()(pe,"_environment",new B("")),c()(pe,"_telemetryUrl",new B("https://telemetry.phenixrts.com/telemetry")),c()(pe,"_maximalNumberOfPeerConnectionReconnectAttempts",8),c()(pe,"_telemetryLevel",new B(x.defaultTelemetryLevel)),c()(pe,"_metricsService",void 0),c()(pe,"_metricsConfiguration",void 0),c()(pe,"_sendLocalCandidates",new B(!p.isPrivate)),c()(pe,"_tenancy",new B("")),c()(pe,"_clientSessionId",E.random(32)),c()(pe,"_loadedTimestamp",new Date),c()(pe,"_logger",O.getLogger("SDK")),c()(pe,"_initialized",new B(!1)),c()(pe,"_peerConnectionFactory",new B(new Q)),c()(pe,"_readOnlyInitialized",new z(pe._initialized)),c()(pe,"_readOnlyDiscoveryUri",new z(oe.uri)),c()(pe,"_readOnlyPeerConnectionFactory",new z(pe._peerConnectionFactory)),window.addEventListener("unload",(function(){pe.dispose()})),pe.applyDiscoveryUriDefaultFromParameterConfiguration(),pe.applyMetricsConfiguration(),pe.applyTelemetryConfiguration(),pe.applyAutomaticallyRetryOnFailureFromParameterConfiguration(),pe.applyAutomaticallyReconnectPeerConnectionFromParameterConfiguration(),pe.init(),function(e){e[e.Offline=1]="Offline",e[e.Starting=2]="Starting",e[e.Publishing=3]="Publishing",e[e.Recovering=4]="Recovering",e[e.Reconnecting=5]="Reconnecting",e[e.StandBy=6]="StandBy",e[e.Stopped=7]="Stopped",e[e.Unauthorized=8]="Unauthorized",e[e.GeoRestricted=9]="GeoRestricted",e[e.GeoBlocked=10]="GeoBlocked",e[e.UnsupportedFeature=11]="UnsupportedFeature",e[e.Error=12]="Error"}(le||(le={}));var de=le,fe=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;o()(this,e),c()(this,"_duration",void 0),this._duration=t}return a()(e,[{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,s=(n=Math.floor(n/60))%24,a=["PT"];return e&&a.unshift("-"),s&&a.push(s+"H"),o&&a.push(o+"M"),(i||r)&&(a.push(String(i)),r&&a.push("."+this.padStart(r.toString(),3,"0")),a.push("S")),a.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)}}]),e}(),ve=function(){function e(t){o()(this,e),c()(this,"_logger",O.getLogger("StreamSetupListener")),c()(this,"metricsService",pe.metricsService),c()(this,"_pageLoadTime",void 0),c()(this,"_startTime",void 0),c()(this,"_metricSubmitted",!1),this._startTime=Date.now(),this._pageLoadTime=t}return a()(e,[{key:"success",value:function(e){this.recordStreamMetric(se.SetupCompleted,e)}},{key:"fail",value:function(){this.recordStreamMetric(se.SetupFailed)}},{key:"recordStreamMetric",value:function(e,t){if(!this._metricSubmitted){this._metricSubmitted=!0;var n=Date.now(),r=n-this._startTime,i=new ae(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 fe(n-this._pageLoadTime).toIsoString(),t,i,new fe(r).toIsoString())}}}]),e}(),ge=function(){function e(){o()(this,e),c()(this,"_disposables",new te),c()(this,"_isSupported",navigator&&navigator.connection),c()(this,"_rtt",new B(void 0)),c()(this,"_effectiveType",new B(void 0)),c()(this,"_downlinkThroughputCapacity",new B(void 0)),this.isSupported&&(this.setupNetworkChangeListeners(),this.updateStatistics())}return a()(e,[{key:"isSupported",get:function(){return this._isSupported}},{key:"rtt",get:function(){return this._rtt}},{key:"effectiveType",get:function(){return this._effectiveType}},{key:"downlinkThroughputCapacity",get:function(){return this._downlinkThroughputCapacity}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"getDownlinkThroughputCapacity",value:function(){return this.isSupported?navigator.connection.downlink||navigator.connection.downlinkMax:-1}},{key:"getEffectiveType",value:function(){return this.isSupported?navigator.connection.effectiveType||navigator.connection.type:"Unknown"}},{key:"getRoundTripTime",value:function(){return navigator.connection.rtt}},{key:"setupNetworkChangeListeners",value:function(){var e=this,t=function(){e.updateStatistics()};navigator.connection.addEventListener("change",t),this._disposables.add(new N((function(){navigator.connection.removeEventListener("change",t)})))}},{key:"updateStatistics",value:function(){this._rtt.value=this.getRoundTripTime(),this._effectiveType.value=this.getEffectiveType(),this._downlinkThroughputCapacity.value=this.getDownlinkThroughputCapacity()}}]),e}(),ye=function(){function e(t,n){var r=this;o()(this,e),c()(this,"_logger",O.getLogger("SessionTelemetry")),c()(this,"_metricsService",void 0),c()(this,"_applicationActivityMonitor",pe.applicationActivityMonitor),c()(this,"_networkMonitor",new ge),c()(this,"_pageLoadTime",void 0),c()(this,"_disposables",new te),c()(this,"_lastNetworkStatistics",{}),this._pageLoadTime=t,this._disposables.add(this._networkMonitor),this._metricsService=n,this._networkMonitor.isSupported&&(this._disposables.add(this._applicationActivityMonitor.isForeground.subscribe((function(e){r.recordForegroundChange(e)}))),this._disposables.add(this._networkMonitor.rtt.subscribe((function(e){r.recordNetworkRTTUpdate(e)}))),this._disposables.add(this._networkMonitor.effectiveType.subscribe((function(e){r.recordNetworkTypeChangeUpdate(e)}))),this._disposables.add(this._networkMonitor.downlinkThroughputCapacity.subscribe((function(e){r.recordNetworkDownlinkThroughputCapacityUpdate(e)}))))}return a()(e,[{key:"listenOnStreamSetup",value:function(){return new ve(this._pageLoadTime)}},{key:"dispose",value:function(){this._disposables.dispose()}},{key:"recordForegroundChange",value:function(e){var t=Date.now(),n=this._applicationActivityMonitor.getTimeSinceLastChange();this._metricsService.push({metricType:e?se.ApplicationForeground:se.ApplicationBackground,runtime:(t-this._pageLoadTime)/1e3,value:{uint64:n}}),this._logger.info("Application has gone into the [%s] after [%s] ms",e?"foreground":"background",new fe(n).toIsoString())}},{key:"recordNetworkRTTUpdate",value:function(e){var t=Date.now(),n=this._lastNetworkStatistics.rtt;this._lastNetworkStatistics.rtt=e,this._metricsService.push({metricType:se.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 fe(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:se.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 fe(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:se.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 fe(t-this._pageLoadTime).toIsoString(),e,n)}}]),e}(),me=a()((function e(t){o()(this,e),c()(this,"token",void 0),c()(this,"tokenExpiring",void 0),this.token=new B(t),this.tokenExpiring=new B(!1)})),_e=function(){function e(t){o()(this,e),c()(this,"publisherInitialization",void 0),c()(this,"disposables",void 0),c()(this,"publisherDisposables",void 0),c()(this,"state",void 0),c()(this,"authorized",void 0),c()(this,"online",void 0),c()(this,"loading",void 0),c()(this,"publishing",void 0),c()(this,"standby",void 0),c()(this,"stopped",void 0),c()(this,"failureCount",void 0),c()(this,"endPoint",void 0),c()(this,"stream",void 0),c()(this,"rtcStatistics",void 0),c()(this,"clearFailureCountTimeout",void 0),c()(this,"name",void 0),c()(this,"rtcAudioStatistic",void 0),c()(this,"rtcVideoStatistic",void 0),this.disposables=new te,this.publisherDisposables=new te,this.publisherInitialization=new Date,this.state=new B(de.Starting),this.authorized=new B(!0),this.online=new B(!0),this.loading=new B(!1),this.publishing=new B(!1),this.standby=new B(!1),this.stopped=new B(!1),this.failureCount=new B(0),this.endPoint=new B(null),this.stream=new B(null),this.rtcStatistics=new B(null),this.name=t&&t.length?t:this.generateScreenName()}return a()(e,[{key:"streamId",get:function(){var e=this.stream.value;return e?e.streamId:"-"}},{key:"applyStatus",value:function(e){switch(e){case"ok":break;case"unauthorized":case"geo-restricted":case"geo-blocked":this.authorized.value=!1;case"no-stream":case"not-found":return this.failureCount.value=0,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,void(this.stream.value=null);default:return this.failureCount.value++,this.publishing.value=!1,this.standby.value=!0,this.stopped.value=!1,this.stream.value=null,void(this.state.value=de.Error)}}},{key:"mapPublishStatusToPublisherStatus",value:function(e){switch(e){case"ok":return de.Starting;case"no-stream":case"not-found":return de.StandBy;case"geo-restricted":return de.GeoRestricted;case"geo-blocked":return de.GeoBlocked;case"unauthorized":return de.Unauthorized;case"capacity":case"rate-limited":case"timeout":return de.Recovering;case"failed":return de.Error;default:P(e)}}},{key:"generateScreenName",value:function(){return E.random(12)}}]),e}(),be=a()((function e(){o()(this,e),c()(this,"mediaStream",void 0),c()(this,"peerConnection",void 0),c()(this,"peerConnectionReconnectAttempts",void 0),this.mediaStream=new B(null),this.peerConnection=new B(null),this.peerConnectionReconnectAttempts=0})),we=a()((function e(){o()(this,e),c()(this,"isStarting",void 0),c()(this,"isDisposed",void 0),this.isStarting=new B(!1),this.isDisposed=!1})),Ce=n(38),ke=n.n(Ce),Se=function(){function e(){throw o()(this,e),new Error("PeerConnectionService is a static class that may not be instantiated")}var t,n;return a()(e,null,[{key:"initiateInitialPrecaching",value:function(){H.isPrecachingEnabled&&e.precacheCreatePeerConnectionOffer().catch((function(t){return e._logger.error('Failed to pre-cache peer connection offer"',t)}))}},{key:"precacheCreatePeerConnectionOffer",value:(n=y()(_().mark((function t(){return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e._cached={direction:"recvonly",peerConnection:e.createPeerConnectionOffer().catch((function(t){throw e._cached=null,t}))});case 1:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})},{key:"createPeerConnectionOffer",value:(t=y()(_().mark((function t(){var n,r,i,o=arguments;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=o.length>0&&void 0!==o[0]?o[0]:"recvonly",!e._cached||e._cached.direction!==n){t.next=5;break}return r=e._cached.peerConnection,e._cached=null,t.abrupt("return",r);case 5:return i=pe.peerConnectionFactory.value,t.abrupt("return",i.createPeerConnection().then(function(){var e=y()(_().mark((function e(t){var r,i,o;return _().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 7:case"end":return t.stop()}}),t)}))),function(){return t.apply(this,arguments)})}]),e}();c()(Se,"_logger",O.getLogger("PeerConnectionService")),c()(Se,"_cached",void 0),Se.initiateInitialPrecaching();var xe,Te,Pe=n(319),Re=n.n(Pe);!function(e){e[e.Keep=0]="Keep",e[e.Reset=1]="Reset"}(xe||(xe={})),function(e){e[e.Normal=0]="Normal",e[e.Force=1]="Force",e[e.Reset=2]="Reset"}(Te||(Te={}));var Le=function(){function e(){o()(this,e)}return a()(e,null,[{key:"convertBitrateModeToBitrateModeType",value:function(e){switch(e){case Te.Normal:return"Normal";case Te.Force:return"Force";case Te.Reset:return"Reset";default:P(e)}}}]),e}(),De=function(){function e(){o()(this,e)}return a()(e,null,[{key:"convertBitrateStateToBitrateStateType",value:function(e){switch(e){case xe.Keep:return"Keep";case xe.Reset:return"Reset";default:P(e)}}}]),e}(),Oe=n(202).default,Ee=function(){function e(t,n){if(o()(this,e),c()(this,"_logger",O.getLogger("EndPoint")),c()(this,"_uri",void 0),c()(this,"_timeout",void 0),c()(this,"_roundTripTime",void 0),this._uri=t,this._timeout=n,!n)throw new Error("End point requires a timeout")}var t,n,r,i,s,u,l,h,p,d,f,v;return a()(e,[{key:"roundTripTime",get:function(){return this._roundTripTime}},{key:"toString",value:function(){return"EndPoint[uri=".concat(this._uri,"]")}},{key:"ping",value:(v=y()(_().mark((function e(){var t,n,r,i,o=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.buildPingUrl(),n=Date.now(),e.next=4,Oe.race([fetch(t,{method:"GET",cache:"no-cache"}),new Oe((function(e,n){return setTimeout((function(){return n(new Error("Ping timed out [".concat(t,"]")))}),o._timeout)}))]);case 4:if(r=e.sent,i=Date.now(),r.ok){e.next=8;break}throw new Error("Ping failed [".concat(t,"] [").concat(r.status,"]"));case 8:return this._roundTripTime=i-n,e.abrupt("return",this._roundTripTime);case 10:case"end":return e.stop()}}),e,this)}))),function(){return v.apply(this,arguments)})},{key:"subscribe",value:(f=y()(_().mark((function e(t,n,r){var i,o,s,a,u,c,l,h,p,d,f,v,g,y=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((i=Z.parseToken(t))&&i.applicationId){e.next=4;break}return this._logger.error("Failed to parse token [%s]",t),e.abrupt("return",{status:"unauthorized"});case 4:return o=i.applicationId,s=this.buildUrl([o,"stream","subscribe"]).toString(),a=new FormData,u=b.sdkVersion,0===r&&n?(c={apiVersion:6,clientVersion:u,edgeAuthToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,setRemoteDescription:{apiVersion:6,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(n.type),sdp:n.sdp}},createAnswerDescription:{apiVersion:6}},a.append("jsonBody",JSON.stringify(c))):(l={apiVersion:6,clientVersion:u,edgeAuthToken:t,failureCount:r,httpRoundTripTime:this._roundTripTime,createOfferDescription:{apiVersion:6}},a.append("jsonBody",JSON.stringify(l))),h=Date.now(),e.prev=10,d=null,e.next=14,Oe.race([fetch(s,{method:"POST",body:a}),new Oe((function(e){return d=window.setTimeout((function(){y._logger.error("Failed to subscribe",new Error("Subscribe timed out [".concat(s,"]"))),e({status:408})}),y._timeout)}))]).finally((function(){d&&clearTimeout(d)}));case 14:p=e.sent,e.next=21;break;case 17:return e.prev=17,e.t0=e.catch(10),this._logger.error("Failed to subscribe",e.t0),e.abrupt("return",{status:"failed"});case 21:if("ok"===(f=this.mapHttpStatusToSubscribeStatus(p))){e.next=24;break}return e.abrupt("return",{status:f});case 24:return v=Date.now(),e.next=27,this.convertHttpResponseToSubscribeResponse(o,p);case 27:return g=e.sent,this._logger.debug("Got subscribe response [%j] in [%s] ms",g,v-h),e.abrupt("return",g);case 30:case"end":return e.stop()}}),e,this,[[10,17]])}))),function(e,t,n){return f.apply(this,arguments)})},{key:"publish",value:(d=y()(_().mark((function e(t,n,r,i){var o,s,a,u,c,l,h,p,d,f,v,g,y,m=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((o=Z.parseToken(n))&&o.applicationId){e.next=4;break}return this._logger.error("Failed to parse token [%s]",n),e.abrupt("return",{status:"unauthorized"});case 4:return s=o.applicationId,a=this.buildUrl([s,"stream","publish"]).toString(),u=new FormData,c=b.sdkVersion,0===i&&r?(l={apiVersion:6,clientVersion:c,edgeAuthToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,setRemoteDescription:{apiVersion:6,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(r.type),sdp:r.sdp}},createAnswerDescription:{streamId:"",options:["upload"],apiVersion:6}},u.append("jsonBody",JSON.stringify(l))):(h={apiVersion:6,clientVersion:c,edgeAuthToken:n,failureCount:i,httpRoundTripTime:this._roundTripTime,name:t,createOfferDescription:{streamId:"",options:["upload"],apiVersion:6}},u.append("jsonBody",JSON.stringify(h))),p=Date.now(),e.prev=10,f=null,e.next=14,Oe.race([fetch(a,{method:"POST",body:u}),new Oe((function(e){return f=window.setTimeout((function(){m._logger.error("Failed to publish",new Error("Publish timed out [".concat(a,"]"))),e({status:408})}),m._timeout)}))]).finally((function(){f&&clearTimeout(f)}));case 14:d=e.sent,e.next=21;break;case 17:return e.prev=17,e.t0=e.catch(10),this._logger.error("Failed to publish",e.t0),e.abrupt("return",{status:"failed"});case 21:if("ok"===(v=this.mapHttpStatusToPublishStatus(d))){e.next=24;break}return e.abrupt("return",{status:v});case 24:return g=Date.now(),e.next=27,this.convertHttpResponseToPublishResponse(s,d);case 27:return y=e.sent,this._logger.debug("Got publish response [%j] in [%s] ms",y,g-p),e.abrupt("return",y);case 30:case"end":return e.stop()}}),e,this,[[10,17]])}))),function(e,t,n,r){return d.apply(this,arguments)})},{key:"setRemoteDescription",value:(p=y()(_().mark((function e(t,n){var r,i,o,s,a,u,c,l,h,p=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"description","remote"]).toString(),i=new FormData,o={apiVersion:6,sharedSecret:t.sharedSecret,sessionDescription:{type:this.convertRTCSdpTypeToSdpType(n.type),sdp:n.sdp}},i.append("jsonBody",JSON.stringify(o)),s=Date.now(),e.prev=5,u=null,e.next=9,Oe.race([fetch(r,{method:"POST",body:i}),new Oe((function(e){return u=window.setTimeout((function(){p._logger.error("Failed to set remote description",new Error("Set remote description timed out [".concat(r,"]"))),e({status:408})}),p._timeout)}))]).finally((function(){u&&clearTimeout(u)}));case 9:a=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(a))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToSetRemoteDescriptionResponse(a);case 22:return h=e.sent,this._logger.debug("Got set remote description response [%j] in [%s] ms",h,l-s),e.abrupt("return",h);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return p.apply(this,arguments)})},{key:"limitBitrate",value:(h=y()(_().mark((function e(t,n,r,i,o){var s,a,u,c,l,h,p,d,f=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=this.buildUrl([t.tenancy,"stream",t.streamId,"bitrate"]).toString(),a=new FormData,u={apiVersion:6,sharedSecret:t.sharedSecret,elapsedInMilliseconds:n,bitrateInBitsPerSecond:r,bitrateState:De.convertBitrateStateToBitrateStateType(i),bitrateMode:Le.convertBitrateModeToBitrateModeType(o)},a.append("jsonBody",JSON.stringify(u)),c=Date.now(),e.prev=5,h=null,e.next=9,Oe.race([fetch(s,{method:"POST",body:a}),new Oe((function(e){return h=window.setTimeout((function(){f._logger.error("Failed to set limit bitrate timed",new Error("Set limit bitrate timed out [".concat(s,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){h&&clearTimeout(h)}));case 9:l=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(5),this._logger.error("Failed to set limit bitrate timed",e.t0),e.abrupt("return",{status:"failed"});case 16:return p=this.mapHttpStatusToSetTemporaryMaximalBitrateStatus(l),d=Date.now(),this._logger.info("Got set limit bitrate response [%s] in [%s] ms",p,d-c),e.abrupt("return",{status:p});case 20:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t,n,r,i){return h.apply(this,arguments)})},{key:"addIceCandidates",value:(l=y()(_().mark((function e(t,n,r){var i,o,s,a,u,c,l,h,p,d,f=this,v=arguments;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=v.length>3&&void 0!==v[3]?v[3]:[],o=this.buildUrl([t.tenancy,"stream",t.streamId,"ice","candidates"]).toString(),s=new FormData,a={apiVersion:6,sharedSecret:t.sharedSecret,candidates:n,discoveryCompleted:r,options:i},s.append("jsonBody",JSON.stringify(a)),u=Date.now(),e.prev=6,l=null,e.next=10,Oe.race([fetch(o,{method:"POST",body:s}),new Oe((function(e){return l=window.setTimeout((function(){f._logger.error("Failed to add ice candidates",new Error("Add ice candidates timed out [".concat(o,"]"))),e({status:408})}),f._timeout)}))]).finally((function(){l&&clearTimeout(l)}));case 10:c=e.sent,e.next=17;break;case 13:return e.prev=13,e.t0=e.catch(6),this._logger.error("Failed to add ice candidates",e.t0),e.abrupt("return",{status:"failed"});case 17:if("ok"===(h=this.mapHttpStatusToAddIceCandidatesStatus(c))){e.next=20;break}return e.abrupt("return",{status:h});case 20:return p=Date.now(),e.next=23,this.convertHttpResponseToAddIceCandidatesResponse(c);case 23:return d=e.sent,this._logger.info("Got add ICE candidates response [%j] in [%s] ms",d,p-u),e.abrupt("return",d);case 26:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e,t,n){return l.apply(this,arguments)})},{key:"destroyStream",value:(u=y()(_().mark((function e(t,n){var r,i,o,s,a,u,c,l,h,p=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this.buildUrl([t.tenancy,"stream",t.streamId,"destroy"]).toString(),i=new FormData,o={apiVersion:6,sharedSecret:t.sharedSecret,reason:n,options:[]},i.append("jsonBody",JSON.stringify(o)),s=Date.now(),e.prev=5,u=null,e.next=9,Oe.race([fetch(r,{method:"POST",body:i,cache:"no-cache"}),new Oe((function(e){return u=window.setTimeout((function(){p._logger.error("Failed to subscribe",new Error("Delete stream timed out [".concat(r,"]"))),e({status:408})}),p._timeout)}))]).finally((function(){u&&clearTimeout(u)}));case 9:a=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(a))){e.next=19;break}return e.abrupt("return",{status:c});case 19:return l=Date.now(),e.next=22,this.convertHttpResponseToDestroyStreamResponse(a);case 22:return h=e.sent,this._logger.info("Got destroy stream response [%j] in [%s] ms",h,l-s),e.abrupt("return",h);case 25:case"end":return e.stop()}}),e,this,[[5,12]])}))),function(e,t){return u.apply(this,arguments)})},{key:"buildUrl",value:function(e){var t=new URL(this._uri),n=t.pathname.split("/");return n.length=n.length-1,t.pathname=n.concat.apply(n,Re()(e)).join("/"),t}},{key:"buildPingUrl",value:function(){var e=new URL(this._uri),t=b.sdkVersion;return e.search="?".concat(new URLSearchParams([["type","http"],["version",t],["_","".concat(Date.now())]]).toString()),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 408:return"timeout";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 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:(s=y()(_().mark((function e(t,n){var r,i;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.json();case 2:return r=e.sent,(i={status:r.status}).stream={tenancy:t,streamId:r.streamId,sharedSecret:r.sharedSecret},i.lag=r.lag,r&&(r.rtcConfiguration&&(i.rtcConfiguration=this.convertIRtcConfigurationToRTCConfiguration(r.rtcConfiguration)),r.setRemoteDescriptionResponse&&r.setRemoteDescriptionResponse.sessionDescription&&(i.setRemoteDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.setRemoteDescriptionResponse.sessionDescription)}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createAnswerDescriptionResponse.sessionDescription)}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createOfferDescriptionResponse.sessionDescription)})),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"convertHttpResponseToPublishResponse",value:(i=y()(_().mark((function e(t,n){var r,i;return _().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:this.convertISessionDescriptionToRTCSessionDescription(r.setRemoteDescriptionResponse.sessionDescription)}),r.createAnswerDescriptionResponse&&r.createAnswerDescriptionResponse.sessionDescription&&(i.createAnswerDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createAnswerDescriptionResponse.sessionDescription)}),r.createOfferDescriptionResponse&&r.createOfferDescriptionResponse.sessionDescription&&(i.createOfferDescriptionResponse={sessionDescription:this.convertISessionDescriptionToRTCSessionDescription(r.createOfferDescriptionResponse.sessionDescription)})),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"convertIRtcConfigurationToRTCConfiguration",value:function(e){var t={};if(e.bundlePolicy)switch(e.bundlePolicy){case"BundlePolicyBalanced":t.bundlePolicy="balanced";break;case"BundlePolicyMaxCompat":t.bundlePolicy="max-compat";break;case"BundlePolicyMaxBundle":t.bundlePolicy="max-bundle";break;default:P(e.bundlePolicy)}if("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}if(e.iceTransportPolicy)switch(e.iceTransportPolicy){case"IceTransportPolicyAll":t.iceTransportPolicy="all";break;case"IceTransportPolicyRelay":t.iceTransportPolicy="relay";break;case"IceTransportPolicyPublic":break;default:P(e.iceTransportPolicy)}if(e.peerIdentity&&(t.peerIdentity=e.peerIdentity),e.rtcpMuxPolicy)switch(e.rtcpMuxPolicy){case"RtcpMuxPolicyNegotiate":t.rtcpMuxPolicy="negotiate";break;case"RtcpMuxPolicyRequire":t.rtcpMuxPolicy="require";break;default:P(e.rtcpMuxPolicy)}return t}},{key:"convertISessionDescriptionToRTCSessionDescription",value:function(e){var t={sdp:e.sdp};switch(e.type){case"Offer":t.type="offer";break;case"Answer":t.type="answer";break;default:P(e.type)}return t}},{key:"convertHttpResponseToSetRemoteDescriptionResponse",value:(r=y()(_().mark((function e(t){var n,r;return _().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=this.convertISessionDescriptionToRTCSessionDescription(n.sessionDescription)),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"convertHttpResponseToAddIceCandidatesResponse",value:(n=y()(_().mark((function e(t){var n,r;return _().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:(t=y()(_().mark((function e(t){var n,r;return _().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(e){return t.apply(this,arguments)})},{key:"convertRTCSdpTypeToSdpType",value:function(e){switch(e){case"answer":return"Answer";case"offer":return"Offer";case"pranswer":case"rollback":throw new Error("SDP type [".concat(e,"] is not supported"));default:P(e)}}}]),e}(),Ae=n(202).default,Ie=function(){function e(t){if(o()(this,e),c()(this,"_logger",O.getLogger("Discovery")),c()(this,"_metricsService",void 0),c()(this,"_uri",void 0),!t)throw new Error("Discovery requires uri");this._metricsService=ce.getMetricsService(t.toString()),this._uri=t}var t,n;return a()(e,[{key:"discoverNearbyEndPoints",value:(n=y()(_().mark((function e(t,n){var r,i,o,s;return _().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,Ae.race([fetch(r,{method:"GET",cache:"no-cache"}),new Ae((function(e,t){return setTimeout((function(){return t(new Error("Discovery timed out [".concat(r,"]")))}),n)}))]);case 5:if((i=e.sent).ok){e.next=8;break}throw new Error("Discovery failed [".concat(r,"] [").concat(i.status,"]"));case 8:if(null!==i.body){e.next=10;break}throw new Error("Discovery failed with no data [".concat(r,"]"));case 10:return e.next=12,i.text();case 12:return o=e.sent,s=o.split(","),e.abrupt("return",s.map((function(e){return new Ee(e,n)})));case 15:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"discoverClosestEndPoint",value:(t=y()(_().mark((function e(){var t,n,r,i,o,s=this,a=arguments;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.length>0&&void 0!==a[0]?a[0]:2e4,n=oe.buildDiscoveryUrl(this._uri),e.next=4,this.discoverNearbyEndPoints(new URL(n),t);case 4:return r=e.sent,i=function(){return new Ae((function(){s._logger.info("Request [%s] failed, preventing it from completing",n)}))},e.next=8,Ae.race(r.map((function(e){return e.ping().catch((function(t){return s._logger.warn("Failed to ping end point [%s]",e,t),i()})).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:se.RoundTripTime,runtime:(n-pe.pageLoadTime)/1e3,value:{uint64:t||0},resource:e.toString(),kind:"ping"}),e}))})));case 8:return o=e.sent,e.abrupt("return",o);case 10:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),Fe=function(){function e(){throw o()(this,e),new Error("Discovery is a static class that may not be instantiated")}var t,n;return a()(e,null,[{key:"precacheClosestEndPointDiscovery",value:(n=y()(_().mark((function t(){var n;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new URL(pe.discoveryUri.value),t.abrupt("return",e.discoverClosestEndPointWithCaching(n));case 2:case"end":return t.stop()}}),t)}))),function(){return n.apply(this,arguments)})},{key:"discoverClosestEndPointWithCaching",value:(t=y()(_().mark((function t(n){var r,i,o;return _().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=n.toString(),!e._cache[r]){t.next=3;break}return t.abrupt("return",e._cache[r]);case 3:return i=new Ie(n),o=e._cache[r]=i.discoverClosestEndPoint(),e._cache[r].then((function(){setTimeout((function(){e._cache[r]===o&&delete e._cache[r]}),6e4)})).catch((function(t){throw delete e._cache[r],t})),t.abrupt("return",o);case 7:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})}]),e}();c()(Fe,"_cache",{}),Fe.precacheClosestEndPointDiscovery();var Me=function(){function e(t){o()(this,e),c()(this,"_sdp",void 0),c()(this,"_audioCodec",void 0),c()(this,"_videoCodec",void 0),c()(this,"_isAudioTrackEnabled",void 0),c()(this,"_isVideoTrackEnabled",void 0),this._sdp=t;var n=this._sdp.split(/(\r\n|\r|\n)/),r=this._sdp.split("m=");this._audioCodec=this.applyCodec("audio",n),this._videoCodec=this.applyCodec("video",n),this._isAudioTrackEnabled=this.isTrackByTypeEnabled("audio",r),this._isVideoTrackEnabled=this.isTrackByTypeEnabled("video",r)}return a()(e,[{key:"audioCodec",get:function(){return this._audioCodec}},{key:"videoCodec",get:function(){return this._videoCodec}},{key:"isAudioTrackEnabled",get:function(){return this._isAudioTrackEnabled}},{key:"isVideoTrackEnabled",get:function(){return this._isVideoTrackEnabled}},{key:"isTrackByTypeEnabled",value:function(e,t){var n=t.find((function(t){return t.startsWith(e)}));return!!n&&!n.includes("a=inactive")}},{key:"applyCodec",value:function(e,t){return t.find((function(n){return n.includes("a=rtpmap:".concat(t.find((function(t){return t.includes("m=".concat(e))})).split(" ")[3]))})).split(" ")[1].split("/")[0]}}]),e}(),je=function(){function e(t,n,r){if(o()(this,e),c()(this,"_estimatedRoundTripTime",void 0),c()(this,"_estimatedVideoCodec",void 0),c()(this,"_estimatedAudioCodec",void 0),c()(this,"_rtcStatistic",new B({})),c()(this,"_peerConnection",void 0),c()(this,"_isMonitorRunning",!0),c()(this,"_updateTimeOut",void 0),c()(this,"_availableTracks",void 0),this._peerConnection=t,this._estimatedRoundTripTime=r,this._peerConnection){var i=new Me(this._peerConnection.currentLocalDescription.sdp),s=new Me(this._peerConnection.currentRemoteDescription.sdp);this._estimatedAudioCodec=s.audioCodec,this._estimatedVideoCodec=s.videoCodec,this._availableTracks={audio:i.isAudioTrackEnabled&&s.isAudioTrackEnabled,video:i.isVideoTrackEnabled&&s.isVideoTrackEnabled},this.updateStatistic()}}var t;return a()(e,[{key:"rtcStatistic",get:function(){return this._rtcStatistic}},{key:"dispose",value:function(){this._isMonitorRunning=!1,this._peerConnection=null,this._updateTimeOut&&(clearTimeout(this._updateTimeOut),this._updateTimeOut=null)}},{key:"updateStatistic",value:(t=y()(_().mark((function e(){var t,n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!H.getStatsPromiseBasedDisabled){e.next=3;break}return e.abrupt("return");case 3:return t=function(e){return e.id.includes("Audio")?"audio":e.id.includes("Video")?"video":""},e.next=6,this._peerConnection.getStats(null).then((function(e){var r={};if(e){var i,o=n._estimatedRoundTripTime;e.forEach((function(s){if("candidate-pair"===s.type&&s.currentRoundTripTime&&(o=1e3*s.currentRoundTripTime,r.audio&&(r.audio.roundTripTime=o),r.video&&(r.video.roundTripTime=o)),"candidate-pair"===s.type&&s.lastPacketSentTimestamp&&(i=s.lastPacketSentTimestamp,r.audio&&(r.audio.lastPacketSentTimestamp=i),r.video&&(r.video.lastPacketSentTimestamp=i)),"outbound-rtp"===s.type){var a=s.kind||s.mediaType||t(s),u="";if(e.forEach((function(e){e.id===s.codecId&&(u=e.mimeType)})),a&&n._availableTracks[a]){var c,l,h,p,d,f=(s.bytesSent||0)-(null!==(c=null===(l=n._rtcStatistic.value)||void 0===l||null===(h=l[a])||void 0===h?void 0:h.bytesSent)&&void 0!==c?c:0),v=s.timestamp-(null===(p=n._rtcStatistic.value)||void 0===p||null===(d=p[a])||void 0===d?void 0:d.timestamp),g=f&&v?Math.floor(8*f/v*1e3):0;if(r[a]={ssrc:s.ssrc,mediaType:a,timestamp:s.timestamp,bitrate:g,bytesSent:s.bytesSent,packetsSent:s.packetsSent,retransmittedBytesSent:s.retransmittedBytesSent,codec:u||n.getCodecByType(a),roundTripTime:o},(s.lastPacketSentTimestamp||i)&&(r[a].lastPacketSentTimestamp=s.lastPacketSentTimestamp||i),"video"===a&&n._rtcStatistic.value&&n._rtcStatistic.value.video){r[a].firCount=s.firCount,r[a].frameHeight=s.frameHeight,r[a].frameWidth=s.frameWidth,r[a].framesEncoded=s.framesEncoded,r[a].framesSent=s.framesSent,r[a].headerBytesSent=s.headerBytesSent,r[a].hugeFramesSent=s.hugeFramesSent,r[a].pliCount=s.pliCount,r[a].qpSum=s.qpSum,r[a].totalEncodeTime=s.totalEncodeTime,r[a].totalEncodedBytesTarget=s.totalEncodedBytesTarget;var y=(s.framesEncoded-n._rtcStatistic.value.video.framesEncoded)/(r[a].timestamp-n._rtcStatistic.value.video.timestamp)*1e3;r[a].fps=y?Math.round(100*y)/100:0}}}}))}n._rtcStatistic.value=r})).then((function(){n._isMonitorRunning&&(n._updateTimeOut=window.setTimeout((function(){return n.updateStatistic()}),1500))}));case 6:e.sent;case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getCodecByType",value:function(e){switch(e){case"audio":return this._estimatedAudioCodec;case"video":return this._estimatedVideoCodec;default:return"unknown"}}}]),e}(),Ve=function(){function e(){throw o()(this,e),new Error("RtcConfigurationManager is a static class that may not be instantiated")}return a()(e,null,[{key:"truncateIceServers",value:function(e){for(var t=[],n=0;n<e.iceServers.length;n++){for(var r=[],i=0;i<2;i++)e.iceServers[n].urls[i]&&r.push(e.iceServers[n].urls[i]);t.push({urls:r,username:e.iceServers[n].username,credential:e.iceServers[n].credential})}return e.iceServers=t,e}}]),e}(),Ne=n(202).default;function Ue(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 Be(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ue(Object(n),!0).forEach((function(t){c()(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ue(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var ze=function(){function e(t,n,r){o()(this,e),c()(this,"_logger",O.getLogger("RealTimePublisher")),c()(this,"_publisherContext",void 0),c()(this,"_peerConnectionContext",void 0),c()(this,"_handleStreamFailure",void 0),this._publisherContext=t,this._peerConnectionContext=n,this._handleStreamFailure=r}var t;return a()(e,[{key:"start",value:function(e,t,n){var r=this;return Ne.all([Fe.discoverClosestEndPointWithCaching(e),Se.createPeerConnectionOffer("sendonly")]).then((function(e){var n=ke()(e,2),i=n[0],o=n[1],s=o.localOffer,a=o.peerConnection;return r._publisherContext.online.value=!0,r._publisherContext.endPoint.value=i,r._logger.info("Connecting to [%s]",i.toString()),r._logger.info("Local offer:\n"+s.sdp),!H.clientOfferDisabled&&a.supportsSetConfiguration&&a.supportsGetConfiguration||(a.close(),a=null,s=null),r._peerConnectionContext.peerConnection.value=a,i.publish(r._publisherContext.name,t,s,r._publisherContext.failureCount.value)})).then((function(e){var t=e.status,i=e.stream,o=e.rtcConfiguration,s=e.setRemoteDescriptionResponse,a=e.createOfferDescriptionResponse,u=e.createAnswerDescriptionResponse;if(r._publisherContext.stream.value=i,r._logger.debug("[%s] Publish completed [%s] [%j] [%j] [%j] [%j]",r._publisherContext.streamId,t,o,s,a,u),r._publisherContext.state.value=r._publisherContext.mapPublishStatusToPublisherStatus(t),r._publisherContext.applyStatus(t),"ok"===t)return r.applyRtcConfiguration(r._peerConnectionContext.peerConnection.value,o).then((function(e){var t,o=!1,c=!1,l=[];return r._peerConnectionContext.peerConnection.value=e,e.addStream(r._peerConnectionContext.mediaStream.value),e.onicecandidate=function(n){r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e&&(o||pe.sendLocalCandidates.value&&(n.candidate&&n.candidate.candidate?l.push(n.candidate):c=!0,t||(t=setTimeout((function(){r._publisherContext.stream.value!==i||o||r._publisherContext.endPoint.value.addIceCandidates(i,l,c).then((function(e){var t=e.status,n=e.options;"ok"===t?(n.includes("cancel")&&(o=!0),r._logger.info("[%s] Added ICE candidates with reason [%s] and options [%s]",r._publisherContext.streamId,t,n)):r._logger.warn("[%s] Failed to add ICE candidates with reason [%s]",r._publisherContext.streamId,t)})).catch((function(e){r._logger.error("[%s] Failed to add ICE candidates",r._publisherContext.streamId,e)}))}),100))))},e.oniceconnectionstatechange=function(){if(r._publisherContext.stream.value===i&&r._peerConnectionContext.peerConnection.value===e){var t=function(){r._publisherContext.state.value=de.Error,r._publisherContext.publishing.value=!1,r._publisherContext.loading.value=!0,r._handleStreamFailure().catch((function(t){r._logger.error("[%s] Failed handling stream failure after peer connection stopped with state [%s]",r._publisherContext.streamId,e.iceConnectionState,t)}))};switch(e.iceConnectionState){case"checking":case"completed":case"connected":case"new":return;case"disconnected":case"failed":return void(navigator.onLine&&(r._logger.info("[%s] ICE connection state changed to [%s], trying to reconnect",r._publisherContext.streamId,e.iceConnectionState),r.reconnectPeerConnection(e,t)));case"closed":return r._logger.info("[%s] ICE connection state changed to [%s], retrying to connect",r._publisherContext.streamId,e.iceConnectionState),void t();default:P(e.iceConnectionState)}}},new Ne((function(e){e()})).then((function(){if(s)return r._logger.info("[%s] Set local SDP offer [%s]",r._publisherContext.streamId,s.sessionDescription.sdp),e.setLocalDescription(s.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,s.sessionDescription,e.message),e}))})).then((function(){if(u)return r._logger.info("[%s] Set remote SDP answer [%s]",r._publisherContext.streamId,u.sessionDescription.sdp),e.setRemoteDescription(u.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,u.sessionDescription,e.message),e}))})).then((function(){if(a)return r._logger.info("[%s] Set remote SDP offer [%s]",r._publisherContext.streamId,a.sessionDescription.sdp),e.setRemoteDescription(a.sessionDescription).catch((function(e){throw r._logger.info("[%s] Failed to set remote description [%j] with message [%s]",r._publisherContext.streamId,u.sessionDescription,e.message),e})).then((function(){return e.createAnswer({offerToReceiveAudio:!1,offerToReceiveVideo:!1})})).then((function(e){return r._logger.info("[%s] Set local SDP answer [%s]",r._publisherContext.streamId,e.sdp),r._publisherContext.endPoint.value.setRemoteDescription(i,e)})).then((function(t){var n=t.status,i=t.sessionDescription;return r._publisherContext.state.value=r.mapSetRemoteDescriptionStatusToPublisherStatus(n),"ok"!==n?(r._publisherContext.publishing.value=!1,r._publisherContext.standby.value=!0,void(r._publisherContext.stopped.value=!1)):(r._logger.info("[%s] Set local SDP [%s]",r._publisherContext.streamId,i.sdp),e.setLocalDescription(i).catch((function(e){throw r._logger.info("[%s] Failed to set local description [%j] with message [%s]",r._publisherContext.streamId,i,e.message),e})))}))})).then((function(){n.success(r._publisherContext.streamId),r._publisherContext.state.value=de.Publishing,r._publisherContext.publishing.value=!0;var t=new je(e,r._peerConnectionContext.mediaStream.value,r._publisherContext.endPoint.value.roundTripTime/4);return t.rtcStatistic.subscribe((function(n){if(r._publisherContext.rtcStatistics.value=n,!r._publisherContext.rtcVideoStatistic&&!r._publisherContext.rtcAudioStatistic)return r._publisherContext.rtcAudioStatistic=n.audio,void(r._publisherContext.rtcVideoStatistic=n.video);var i=!1,o=!1;n.audio&&r._publisherContext.rtcAudioStatistic&&r._publisherContext.rtcAudioStatistic.timestamp!==n.audio.timestamp&&((i=r._publisherContext.rtcAudioStatistic&&r._publisherContext.rtcAudioStatistic.bytesSent===n.audio.bytesSent)&&navigator.onLine&&r._logger.info("[%s] Audio track failed with last bytesSent [%s] is equal to previous bytesSent [%s] within [%s]",r._publisherContext.streamId,n.audio.bytesSent,r._publisherContext.rtcAudioStatistic.bytesSent,new fe(n.audio.timestamp-r._publisherContext.rtcAudioStatistic.timestamp).toIsoString()),r._publisherContext.rtcAudioStatistic=n.audio),n.video&&r._publisherContext.rtcVideoStatistic&&r._publisherContext.rtcVideoStatistic.timestamp!==n.video.timestamp&&((o=r._publisherContext.rtcVideoStatistic&&r._publisherContext.rtcVideoStatistic.bytesSent===n.video.bytesSent)&&navigator.onLine&&r._logger.info("[%s] Video track failed with last bytesSent [%s] is equal to previous bytesSent [%s] within [%s]",r._publisherContext.streamId,n.video.bytesSent,r._publisherContext.rtcVideoStatistic.bytesSent,new fe(n.video.timestamp-r._publisherContext.rtcVideoStatistic.timestamp).toIsoString()),r._publisherContext.rtcVideoStatistic=n.video),(o||i)&&navigator.onLine?r.reconnectPeerConnection(e,(function(){r._publisherContext.state.value=de.Error,r._publisherContext.loading.value=!0,t.dispose(),r._handleStreamFailure().catch((function(t){r._logger.error("[%s] Failed handling stream failure after track stopped with state [%s]",r._publisherContext.streamId,e.iceConnectionState,t)}))})):r._peerConnectionContext.peerConnectionReconnectAttempts=0})),Ne.resolve()}))}))}))}},{key:"applyRtcConfiguration",value:(t=y()(_().mark((function e(t,n){var r;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=3;break}return n=Ve.truncateIceServers(n),e.abrupt("return",pe.peerConnectionFactory.value.createPeerConnection(n));case 3:return r=Be(Be({},t.getConfiguration()),n),t.setConfiguration(r),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"reconnectPeerConnection",value:function(e,t){var n=this;if("closed"!==e.iceConnectionState)if(this._publisherContext.state.value=de.Reconnecting,this._peerConnectionContext.peerConnectionReconnectAttempts<pe.maximalNumberOfPeerConnectionReconnectAttempts||!pe.automaticallyReconnectPeerConnection){if(this._peerConnectionContext.peerConnectionReconnectAttempts++,H.clientOfferDisabled||!e.supportsSetConfiguration||!e.supportsGetConfiguration||this._publisherContext.failureCount.value)return;this._logger.info("Reconnecting peer connection by restarting ICE");var r=e.currentLocalDescription;e.createOffer({iceRestart:!0}).then((function(t){return e.setLocalDescription(t).then((function(){return e.setLocalDescription(r).then((function(){n._publisherContext.state.value=de.Publishing}))}))})).catch((function(e){n._logger.error("Failed to reconnect peer connection",e),n._peerConnectionContext.peerConnectionReconnectAttempts=0,t()}))}else this._logger.info("Failed to reconnect peer connection after [%s] attempts, performing full recovery",this._peerConnectionContext.peerConnectionReconnectAttempts),this._peerConnectionContext.peerConnectionReconnectAttempts=0,t()}},{key:"mapSetRemoteDescriptionStatusToPublisherStatus",value:function(e){switch(e){case"ok":return de.Starting;case"unauthorized":return de.Unauthorized;case"not-found":case"capacity":case"rate-limited":case"timeout":return de.Recovering;case"failed":return de.Error;default:P(e)}}}]),e}(),Ge=n(202).default,He="client:termination",We=function(){function e(t,n,r){var i=this;o()(this,e),c()(this,"_logger",O.getLogger("Publisher")),c()(this,"_tokenContext",void 0),c()(this,"_publisherContext",void 0),c()(this,"_peerConnectionContext",void 0),c()(this,"_stateContext",void 0),c()(this,"_publisherStartTime",void 0),c()(this,"_readOnlyToken",void 0),c()(this,"_readOnlyPeerConnection",void 0),c()(this,"_readOnlyState",void 0),c()(this,"_readOnlyTokenExpiring",void 0),c()(this,"_readOnlyAuthorized",void 0),c()(this,"_readOnlyOnline",void 0),c()(this,"_readOnlyLoading",void 0),c()(this,"_readOnlyPublishing",void 0),c()(this,"_readOnlyStandby",void 0),c()(this,"_readOnlyStopped",void 0),c()(this,"_readOnlyFailureCount",void 0),c()(this,"_readOnlyEndPoint",void 0),c()(this,"_readOnlyStream",void 0),c()(this,"_readOnlyRtcStatistics",void 0),c()(this,"_readOnlyMediaStream",void 0),c()(this,"_metricsService",void 0),c()(this,"_sessionTelemetry",void 0),this._tokenContext=new me(n),this._publisherContext=new _e(r),this._peerConnectionContext=new be,this._stateContext=new we,this._publisherStartTime=Date.now(),this._readOnlyToken=new z(this._tokenContext.token),this._readOnlyPeerConnection=new z(this._peerConnectionContext.peerConnection),this._readOnlyState=new z(this._publisherContext.state),this._readOnlyTokenExpiring=new z(this._tokenContext.tokenExpiring),this._readOnlyAuthorized=new z(this._publisherContext.authorized),this._readOnlyOnline=new z(this._publisherContext.online),this._readOnlyLoading=new z(this._publisherContext.loading),this._readOnlyPublishing=new z(this._publisherContext.publishing),this._readOnlyStandby=new z(this._publisherContext.standby),this._readOnlyStopped=new z(this._publisherContext.stopped),this._readOnlyFailureCount=new z(this._publisherContext.failureCount),this._readOnlyEndPoint=new z(this._publisherContext.endPoint),this._readOnlyStream=new z(this._publisherContext.stream),this._readOnlyRtcStatistics=new z(this._publisherContext.rtcStatistics),this._readOnlyMediaStream=new z(this._peerConnectionContext.mediaStream),this._peerConnectionContext.mediaStream.value=t;var s=Z.parseToken(this._tokenContext.token.value),a=(Z.getUri(s)||pe.discoveryUri.value).toString();pe.tenancy.value=Z.getTenancy(s)||pe.tenancy.value,oe.uri.value=a,this._metricsService=ce.getMetricsService(a),this._sessionTelemetry=new ye(pe.pageLoadTime,this._metricsService),this._publisherContext.publisherDisposables.add(this._sessionTelemetry),this._publisherContext.publisherDisposables.add(this._publisherContext.state.subscribe((function(e){i._publisherContext.clearFailureCountTimeout&&clearTimeout(i._publisherContext.clearFailureCountTimeout),i._publisherContext.failureCount.value&&e===de.Publishing&&(i._publisherContext.clearFailureCountTimeout=window.setTimeout((function(){i._publisherContext.failureCount.value=0}),3e3))})));var u=function(){i._publisherContext.stream.value&&i._publisherContext.endPoint.value&&i._publisherContext.endPoint.value.destroyStream(i._publisherContext.stream.value,"client:termination-on-window-unload")};window.addEventListener("beforeunload",u),this._publisherContext.publisherDisposables.add(new N((function(){window.removeEventListener("beforeunload",u)}))),this.start()}var t,n,r,i,s;return a()(e,[{key:"token",get:function(){return this._tokenContext.token.value},set:function(e){this._publisherContext.disposables.dispose(),this._tokenContext.token.value=e,this._tokenContext.tokenExpiring.value=!1;var t=Z.parseToken(this._tokenContext.token.value),n=(Z.getUri(t)||pe.discoveryUri.value).toString();pe.tenancy.value=Z.getTenancy(t)||pe.tenancy.value,oe.uri.value=n,this._metricsService=ce.getMetricsService(n),this.start()}},{key:"peerConnection",get:function(){return this._readOnlyPeerConnection}},{key:"state",get:function(){return this._readOnlyState}},{key:"tokenExpiring",get:function(){return this._readOnlyTokenExpiring}},{key:"authorized",get:function(){return this._readOnlyAuthorized}},{key:"online",get:function(){return this._readOnlyOnline}},{key:"loading",get:function(){return this._readOnlyLoading}},{key:"publishing",get:function(){return this._readOnlyPublishing}},{key:"standby",get:function(){return this._readOnlyStandby}},{key:"stopped",get:function(){return this._readOnlyStopped}},{key:"failureCount",get:function(){return this._readOnlyFailureCount}},{key:"endPoint",get:function(){return this._readOnlyEndPoint}},{key:"stream",get:function(){return this._readOnlyStream}},{key:"streamId",get:function(){return this._publisherContext.streamId}},{key:"rtcStatistics",get:function(){return this._readOnlyRtcStatistics}},{key:"mediaStream",get:function(){return this._readOnlyMediaStream}},{key:"stop",value:(s=y()(_().mark((function e(t){var n=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Ge((function(e){if(!n._stateContext.isStarting.value)return n.processStop(t),void e();n._publisherContext.disposables.add(n._stateContext.isStarting.subscribe((function(r){r||(n.processStop(t),e())})))})));case 1:case"end":return e.stop()}}),e)}))),function(e){return s.apply(this,arguments)})},{key:"processStop",value:function(e){this.cleanUpResources(e),this._peerConnectionContext.peerConnection.value&&(this._peerConnectionContext.peerConnection.value.close(),this._peerConnectionContext.peerConnection.value=null),this._publisherContext.state.value=de.Stopped}},{key:"dispose",value:(i=y()(_().mark((function e(){var t=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.stop("client:channel-dispose").then((function(){t._publisherContext.publisherDisposables.dispose(),t._stateContext.isDisposed=!0})));case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getUri",value:function(e){var t=Z.parseToken(e);return Z.getUri(t)||(this._logger.info("Fall back to the default discover URI [%s]",pe.discoveryUri.value),new URL(pe.discoveryUri.value))}},{key:"start",value:(r=y()(_().mark((function e(){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._stateContext.isDisposed){e.next=2;break}throw new Error("Channel was already disposed");case 2:if(!this._stateContext.isStarting.value){e.next=5;break}return this._logger.info("Publisher is already starting, skipping start"),e.abrupt("return");case 5:return this._stateContext.isStarting.value=!0,e.abrupt("return",this.processStart());case 7:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"setMediaStream",value:function(e){var t=this;this._peerConnectionContext.mediaStream.value=e,this._peerConnectionContext.peerConnection.value&&e.getTracks().forEach((function(e){t._peerConnectionContext.peerConnection.value.getSenders().forEach((function(t){var n;e.kind===(null==t||null===(n=t.track)||void 0===n?void 0:n.kind)&&e.id!==t.track.id&&t.replaceTrack(e)}))}))}},{key:"processStart",value:(n=y()(_().mark((function e(){var t,n,r,i,o,s=this;return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._tokenContext.token.value,n=this._sessionTelemetry.listenOnStreamSetup(),Z.isValidToken(t)){e.next=8;break}return this._logger.error("Failed to parse token [%s]",t),this._publisherContext.state.value=de.Unauthorized,this._publisherContext.authorized.value=!1,this._stateContext.isStarting.value=!1,e.abrupt("return");case 8:return this.cleanUpResources("client:start"),this._publisherContext.state.value=de.Starting,this._publisherContext.loading.value=!0,r=this.getUri(t),i=function(){return new Ge((function(e){return s._stateContext.isStarting.value=!1,e(s.handleStreamFailure())}))},o=new ze(this._publisherContext,this._peerConnectionContext,i),e.abrupt("return",o.start(r,t,n).then((function(){s._publisherContext.loading.value=!1})).catch((function(e){n.fail(),s._publisherContext.failureCount.value++,s._publisherContext.online.value=!1,s.cleanUpResources("client:cleanup-after-failed-setup"),s._publisherContext.state.value=de.Error,s._logger.error("Failed to start publishing",e)})).finally((function(){if(s._stateContext.isStarting.value=!1,s._publisherContext.state.value!==de.Publishing&&pe.automaticRetryOnFailure){var e=setTimeout((function(){s.handleStreamFailure().catch((function(e){s._logger.error("Failed handling stream failure",e)}))}),s.getRetryInterval());s._publisherContext.disposables.add(new N((function(){clearTimeout(e)})))}})));case 15:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"getRetryInterval",value:function(){switch(this._publisherContext.state.value){case de.StandBy:case de.Offline:return 15e3;case de.Error:case de.Recovering:case de.Unauthorized:case de.GeoRestricted:case de.GeoBlocked:case de.Stopped:case de.Starting:case de.Publishing:case de.Reconnecting:case de.UnsupportedFeature:return Math.min(3e5,Math.pow(2e3,Math.max(0,this._publisherContext.failureCount.value-1)));default:P(this._publisherContext.state.value)}}},{key:"handleStreamFailure",value:(t=y()(_().mark((function e(){return _().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this._publisherContext.state.value,e.next=e.t0===de.Error||e.t0===de.Reconnecting||e.t0===de.StandBy||e.t0===de.Offline||e.t0===de.Recovering?3:e.t0===de.Unauthorized?5:e.t0===de.GeoRestricted?7:e.t0===de.GeoBlocked?9:e.t0===de.Stopped?11:e.t0===de.Publishing?13:e.t0===de.Starting?15:e.t0===de.UnsupportedFeature?17:19;break;case 3:return this._logger.info("Retry start with initial state [%s] [%s]",this._publisherContext.state.value,de[this._publisherContext.state.value]),e.abrupt("break",20);case 5:return this._logger.info("Publisher is unauthorized, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 7:return this._logger.info("Publisher is geo restricted, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 9:return this._logger.info("Publisher is geo blocked, skipping retry of start. Please provide a new token and invoke start()"),e.abrupt("return");case 11:return this._logger.info("Publisher is stopped, skipping retry of start."),e.abrupt("return");case 13:return this._logger.info("Publisher is publishing, skipping retry of start"),e.abrupt("return");case 15:return this._logger.info("Publisher is already starting, skipping retry of start"),e.abrupt("return");case 17:return this._logger.info("Publisher is stopped due to unsupported feature, skipping retry of start."),e.abrupt("return");case 19:P(this._publisherContext.state.value);case 20:return e.abrupt("return",this.start());case 21:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"cleanUpResources",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:He;this._publisherContext.disposables.dispose();var n=this._peerConnectionContext.peerConnection.value;n&&(this._peerConnectionContext.peerConnection.value=null,n.close()),this._publisherContext.publishing.value=!1,this._publisherContext.stopped.value=!0,this._publisherContext.standby.value=!1,this._publisherContext.stream.value&&this._publisherContext.endPoint.value&&this._publisherContext.endPoint.value.destroyStream(this._publisherContext.stream.value,t).then((function(t){var n=t.status;"ok"===n?e._logger.info("[%s] Destroyed stream with reason [%s]",e.streamId,n):e._logger.warn("[%s] Failed to destroy stream with reason [%s]",e.streamId,n)})).catch((function(t){e._logger.error("[%s] Failed to destroy stream",e.streamId,t)})),this._publisherContext.stream.value=null,this._publisherContext.endPoint.value=null,this._peerConnectionContext.peerConnectionReconnectAttempts=0}}]),e}(),Je=function(){function e(){throw o()(this,e),new Error("Publishers is a static class that may not be instantiated")}return a()(e,null,[{key:"createPublisher",value:function(e){if(!pe.initialized.value)throw new Error("SDK is not loaded.");return new We(e.mediaStream,e.token,e.name)}}]),e}(),Ke={SDK:pe,Publishers:Je,PublisherState:de}}},t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}return 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})},n(112)})()}));
3
3
  //# sourceMappingURL=publish.js.map