UNPKG

opentok-network-test-js

Version:

Precall network test for applications using the OpenTok platform.

2 lines 84 kB
/*! For license information please see index.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("OpenTokNetworkConnectivity",[],t):"object"==typeof exports?exports.OpenTokNetworkConnectivity=t():e.OpenTokNetworkConnectivity=t()}(self,(()=>(()=>{"use strict";var e={236:(e,t,r)=>{var n=r(795),o=[],s=[],i=n.makeRequestCallFromTimer((function(){if(s.length)throw s.shift()}));function a(e){var t;(t=o.length?o.pop():new c).task=e,n(t)}function c(){this.task=null}e.exports=a,c.prototype.call=function(){try{this.task.call()}catch(e){a.onerror?a.onerror(e):(s.push(e),i())}finally{this.task=null,o[o.length]=this}}},795:(e,t,r)=>{function n(e){s.length||(o(),!0),s[s.length]=e}e.exports=n;var o,s=[],i=0;function a(){for(;i<s.length;){var e=i;if(i+=1,s[e].call(),i>1024){for(var t=0,r=s.length-i;t<r;t++)s[t]=s[t+i];s.length-=i,i=0}}s.length=0,i=0}var c,u,l,d=void 0!==r.g?r.g:self,f=d.MutationObserver||d.WebKitMutationObserver;function p(e){return function(){var t=setTimeout(n,0),r=setInterval(n,50);function n(){clearTimeout(t),clearInterval(r),e()}}}"function"==typeof f?(c=1,u=new f(a),l=document.createTextNode(""),u.observe(l,{characterData:!0}),o=function(){c=-c,l.data=c}):o=p(a),n.requestFlush=o,n.makeRequestCallFromTimer=p},674:(e,t,r)=>{var n,o,s;function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function a(e){return e=function(e,t){if("object"!=c(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);if(r=r.call(e,t||"default"),"object"!=c(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}(e,"string"),"symbol"==c(e)?e:String(e)}function c(e){return(c="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)}o=[r(425)],void 0===(s="function"==typeof(n=function(e){function t(t){var o;t=function(e){if(!e.clientVersion)throw console.log("Error. The clientVersion field cannot be null in the log entry"),new Error("The clientVersion field cannot be null in the log entry");if(!e.source)throw console.log("Error. The source field cannot be null in the log entry"),new Error("The source field cannot be null in the log entry");if(!e.componentId)throw console.log("Error. The componentId field cannot be null in the log entry"),new Error("The componentId field cannot be null in the log entry");var t,r;if(e.name)return t=e.logVersion||"2",r=e.clientSystemTime||(new Date).getTime(),Object.assign({},e,{logVersion:t,clientSystemTime:r});throw console.log("Error. The name field cannot be null in the log entry"),new Error("The guid field cannot be null in the log entry")}(t),n?e.post(r,t):((o=new XMLHttpRequest).open("POST",r,!0),o.setRequestHeader("Content-type","application/json"),o.send(JSON.stringify(t)))}var r,n=!1,o=function(e,t,r){var o,s;return n||(o="",r&&((s=new Date).setTime(s.getTime()+24*r*60*60*1e3),o=["; expires=",s.toGMTString()].join("")),r=[e,"=",t,o,"; path=/"].join(""),document.cookie=r),t},s=function(e){if(!n)for(var t,r="".concat(e,"="),o=document.cookie.split(";"),s=0;s<o.length;s++){for(t=o[s];" "===t.charAt(0);)t=t.substring(1,t.length);if(0===t.indexOf(r))return t.substring(r.length,t.length)}return null},a=function(){for(var e=[],t="0123456789abcdef",r=0;r<36;r++)e.push(t.substr(Math.floor(16*Math.random()),1));return e[14]="4",e[19]=t.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-",e.join("")};return function(){function e(t,i){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.analyticsData=t,n=i&&i.server;var c="hlg.tokbox.com/prod/logging/ClientEvent";i&&i.loggingUrl&&(c=i.loggingUrl),r=i&&i.proxyUrl&&"".concat(i.proxyUrl,"/").concat(c)||"https://".concat(c),this.analyticsData.guid=(i=t.name,s(i)||o(i,a(),7))}return function(e,t,r){t&&i(e.prototype,t),r&&i(e,r),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"addSessionInfo",value:function(e){if(!e.sessionId)throw console.log("Error. The sessionId field cannot be null in the log entry"),new Error("The sessionId field cannot be null in the log entry");if(this.analyticsData.sessionId=e.sessionId,!e.connectionId)throw console.log("Error. The connectionId field cannot be null in the log entry"),new Error("The connectionId field cannot be null in the log entry");if(this.analyticsData.connectionId=e.connectionId,0===e.partnerId)throw console.log("Error. The partnerId field cannot be null in the log entry"),new Error("The partnerId field cannot be null in the log entry");this.analyticsData.partnerId=e.partnerId}},{key:"logEvent",value:function(e){this.analyticsData=Object.assign({},this.analyticsData,e,{clientSystemTime:(new Date).getTime()}),t(this.analyticsData)}}]),e}()})?n.apply(t,o):n)||(e.exports=s)},918:(e,t,r)=>{e.exports=r(706)},551:(e,t,r)=>{var n=r(795);function o(){}var s=null,i={};function a(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("Promise constructor's argument is not a function");this._x=0,this._y=0,this._z=null,this._A=null,e!==o&&p(e,this)}function c(e,t){for(;3===e._y;)e=e._z;if(a._B&&a._B(e),0===e._y)return 0===e._x?(e._x=1,void(e._A=t)):1===e._x?(e._x=2,void(e._A=[e._A,t])):void e._A.push(t);!function(e,t){n((function(){var r=1===e._y?t.onFulfilled:t.onRejected;if(null!==r){var n=function(e,t){try{return e(t)}catch(e){return s=e,i}}(r,e._z);n===i?l(t.promise,s):u(t.promise,n)}else 1===e._y?u(t.promise,e._z):l(t.promise,e._z)}))}(e,t)}function u(e,t){if(t===e)return l(e,new TypeError("A promise cannot be resolved with itself."));if(t&&("object"==typeof t||"function"==typeof t)){var r=function(e){try{return e.then}catch(e){return s=e,i}}(t);if(r===i)return l(e,s);if(r===e.then&&t instanceof a)return e._y=3,e._z=t,void d(e);if("function"==typeof r)return void p(r.bind(t),e)}e._y=1,e._z=t,d(e)}function l(e,t){e._y=2,e._z=t,a._C&&a._C(e,t),d(e)}function d(e){if(1===e._x&&(c(e,e._A),e._A=null),2===e._x){for(var t=0;t<e._A.length;t++)c(e,e._A[t]);e._A=null}}function f(e,t,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=r}function p(e,t){var r=!1,n=function(e,t,r){try{e(t,r)}catch(e){return s=e,i}}(e,(function(e){r||(r=!0,u(t,e))}),(function(e){r||(r=!0,l(t,e))}));r||n!==i||(r=!0,l(t,s))}e.exports=a,a._B=null,a._C=null,a._D=o,a.prototype.then=function(e,t){if(this.constructor!==a)return function(e,t,r){return new e.constructor((function(n,s){var i=new a(o);i.then(n,s),c(e,new f(t,r,i))}))}(this,e,t);var r=new a(o);return c(this,new f(e,t,r)),r}},556:(e,t,r)=>{var n=r(551);e.exports=n,n.prototype.done=function(e,t){(arguments.length?this.then.apply(this,arguments):this).then(null,(function(e){setTimeout((function(){throw e}),0)}))}},635:(e,t,r)=>{var n=r(551);e.exports=n;var o=l(!0),s=l(!1),i=l(null),a=l(void 0),c=l(0),u=l("");function l(e){var t=new n(n._D);return t._y=1,t._z=e,t}n.resolve=function(e){if(e instanceof n)return e;if(null===e)return i;if(void 0===e)return a;if(!0===e)return o;if(!1===e)return s;if(0===e)return c;if(""===e)return u;if("object"==typeof e||"function"==typeof e)try{var t=e.then;if("function"==typeof t)return new n(t.bind(e))}catch(e){return new n((function(t,r){r(e)}))}return l(e)};var d=function(e){return"function"==typeof Array.from?(d=Array.from,Array.from(e)):(d=function(e){return Array.prototype.slice.call(e)},Array.prototype.slice.call(e))};function f(e){return{status:"fulfilled",value:e}}function p(e){return{status:"rejected",reason:e}}function h(e){if(e&&("object"==typeof e||"function"==typeof e)){if(e instanceof n&&e.then===n.prototype.then)return e.then(f,p);var t=e.then;if("function"==typeof t)return new n(t.bind(e)).then(f,p)}return f(e)}function E(e){if("function"==typeof AggregateError)return new AggregateError(e,"All promises were rejected");var t=new Error("All promises were rejected");return t.name="AggregateError",t.errors=e,t}n.all=function(e){var t=d(e);return new n((function(e,r){if(0===t.length)return e([]);var o=t.length;function s(i,a){if(a&&("object"==typeof a||"function"==typeof a)){if(a instanceof n&&a.then===n.prototype.then){for(;3===a._y;)a=a._z;return 1===a._y?s(i,a._z):(2===a._y&&r(a._z),void a.then((function(e){s(i,e)}),r))}var c=a.then;if("function"==typeof c)return void new n(c.bind(a)).then((function(e){s(i,e)}),r)}t[i]=a,0==--o&&e(t)}for(var i=0;i<t.length;i++)s(i,t[i])}))},n.allSettled=function(e){return n.all(d(e).map(h))},n.reject=function(e){return new n((function(t,r){r(e)}))},n.race=function(e){return new n((function(t,r){d(e).forEach((function(e){n.resolve(e).then(t,r)}))}))},n.prototype.catch=function(e){return this.then(null,e)},n.any=function(e){return new n((function(t,r){var o=d(e),s=!1,i=[];function a(e){s||(s=!0,t(e))}function c(e){i.push(e),i.length===o.length&&r(E(i))}0===o.length?r(E(i)):o.forEach((function(e){n.resolve(e).then(a,c)}))}))}},293:(e,t,r)=>{var n=r(551);e.exports=n,n.prototype.finally=function(e){return this.then((function(t){return n.resolve(e()).then((function(){return t}))}),(function(t){return n.resolve(e()).then((function(){throw t}))}))}},706:(e,t,r)=>{e.exports=r(551),r(556),r(293),r(635),r(791),r(727)},791:(e,t,r)=>{var n=r(551),o=r(236);e.exports=n,n.denodeify=function(e,t){return"number"==typeof t&&t!==1/0?function(e,t){for(var r=[],o=0;o<t;o++)r.push("a"+o);var i=["return function ("+r.join(",")+") {","var self = this;","return new Promise(function (rs, rj) {","var res = fn.call(",["self"].concat(r).concat([s]).join(","),");","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],i)(n,e)}(e,t):function(e){for(var t=Math.max(e.length-1,3),r=[],o=0;o<t;o++)r.push("a"+o);var i=["return function ("+r.join(",")+") {","var self = this;","var args;","var argLength = arguments.length;","if (arguments.length > "+t+") {","args = new Array(arguments.length + 1);","for (var i = 0; i < arguments.length; i++) {","args[i] = arguments[i];","}","}","return new Promise(function (rs, rj) {","var cb = "+s+";","var res;","switch (argLength) {",r.concat(["extra"]).map((function(e,t){return"case "+t+":res = fn.call("+["self"].concat(r.slice(0,t)).concat("cb").join(",")+");break;"})).join(""),"default:","args[argLength] = cb;","res = fn.apply(self, args);","}","if (res &&",'(typeof res === "object" || typeof res === "function") &&','typeof res.then === "function"',") {rs(res);}","});","};"].join("");return Function(["Promise","fn"],i)(n,e)}(e)};var s="function (err, res) {if (err) { rj(err); } else { rs(res); }}";n.nodeify=function(e){return function(){var t=Array.prototype.slice.call(arguments),r="function"==typeof t[t.length-1]?t.pop():null,s=this;try{return e.apply(this,arguments).nodeify(r,s)}catch(e){if(null==r)return new n((function(t,r){r(e)}));o((function(){r.call(s,e)}))}}},n.prototype.nodeify=function(e,t){if("function"!=typeof e)return this;this.then((function(r){o((function(){e.call(t,null,r)}))}),(function(r){o((function(){e.call(t,r)}))}))}},727:(e,t,r)=>{var n=r(551);e.exports=n,n.enableSynchronous=function(){n.prototype.isPending=function(){return 0==this.getState()},n.prototype.isFulfilled=function(){return 1==this.getState()},n.prototype.isRejected=function(){return 2==this.getState()},n.prototype.getValue=function(){if(3===this._y)return this._z.getValue();if(!this.isFulfilled())throw new Error("Cannot get a value of an unfulfilled promise.");return this._z},n.prototype.getReason=function(){if(3===this._y)return this._z.getReason();if(!this.isRejected())throw new Error("Cannot get a rejection reason of a non-rejected promise.");return this._z},n.prototype.getState=function(){return 3===this._y?this._z.getState():-1===this._y||-2===this._y?0:this._y}},n.disableSynchronous=function(){n.prototype.isPending=void 0,n.prototype.isFulfilled=void 0,n.prototype.isRejected=void 0,n.prototype.getValue=void 0,n.prototype.getReason=void 0,n.prototype.getState=void 0}},430:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnsupportedResolutionError=t.PermissionDeniedError=t.InvalidOnUpdateCallback=t.MissingSessionCredentialsError=t.IncompleteSessionCredentialsError=t.MissingOpenTokInstanceError=t.NetworkTestError=void 0;const n=r(287);class o extends Error{constructor(e,t){super(e),this.name=t||n.ErrorNames.NETWORK_TEST_ERROR,this.stack=new Error(e).stack}}t.NetworkTestError=o;t.MissingOpenTokInstanceError=class extends o{constructor(){super("An instance of OT, the OpenTok.js client SDK, is required."),this.name=n.ErrorNames.MISSING_OPENTOK_INSTANCE}};t.IncompleteSessionCredentialsError=class extends o{constructor(){super("NetworkConnectivity requires an apiKey, sessionId, and token.",n.ErrorNames.INCOMPLETE_SESSON_CREDENTIALS)}};t.MissingSessionCredentialsError=class extends o{constructor(){super("NetworkConnectivity requires OpenTok session credentials.",n.ErrorNames.MISSING_SESSON_CREDENTIALS)}};t.InvalidOnUpdateCallback=class extends o{constructor(){super("The onUpdate callback must be a function that accepts a single parameter.",n.ErrorNames.INVALID_ON_UPDATE_CALLBACK)}};t.PermissionDeniedError=class extends o{constructor(){super("Precall failed to acquire camera due to a permissions error.",n.ErrorNames.PERMISSION_DENIED_ERROR)}};t.UnsupportedResolutionError=class extends o{constructor(){super("The camera does not support the given resolution.",n.ErrorNames.UNSUPPORTED_RESOLUTION_ERROR)}}},287:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.errorHasName=t.OTErrorType=t.ErrorNames=void 0;const n=r(729);var o,s;!function(e){e.NETWORK_TEST_ERROR="NetworkTestError",e.MISSING_OPENTOK_INSTANCE="MissingOpenTokInstanceError",e.INCOMPLETE_SESSON_CREDENTIALS="IncompleteSessionCredentialsError",e.MISSING_SESSON_CREDENTIALS="MissingSessionCredentialsError",e.INVALID_ON_UPDATE_CALLBACK="InvalidOnUpdateCallback",e.CONNECTIVITY_ERROR="ConnectivityError",e.API_CONNECTIVITY_ERROR="APIConnectivityError",e.CONNECT_TO_SESSION_ERROR="ConnectToSessionError",e.CONNECT_TO_SESSION_TOKEN_ERROR="ConnectToSessionTokenError",e.CONNECT_TO_SESSION_ID_ERROR="ConnectToSessionSessionIdError",e.CONNECT_TO_SESSION_NETWORK_ERROR="ConnectToSessionNetworkError",e.MEDIA_DEVICE_ERROR="MediaDeviceError",e.FAILED_TO_OBTAIN_MEDIA_DEVICES="FailedToObtainMediaDevices",e.NO_VIDEO_CAPTURE_DEVICES="NoVideoCaptureDevicesError",e.NO_AUDIO_CAPTURE_DEVICES="NoAudioCaptureDevicesError",e.PUBLISH_TO_SESSION_ERROR="PublishToSessionError",e.INIT_PUBLISHER_ERROR="InitPublisherError",e.FAILED_MESSAGING_SERVER_TEST="FailedMessagingServerTestError",e.FAILED_TO_CREATE_LOCAL_PUBLISHER="FailedToCreateLocalPublisher",e.PUBLISH_TO_SESSION_NOT_CONNECTED="PublishToSessionNotConnectedError",e.PUBLISH_TO_SESSION_PERMISSION_OR_TIMEOUT_ERROR="PublishToSessionPermissionOrTimeoutError",e.PUBLISH_TO_SESSION_NETWORK_ERROR="PublishToSessionNetworkError",e.SUBSCRIBE_TO_SESSION_ERROR="SubscribeToSessionError",e.LOGGING_SERVER_CONNECTION_ERROR="LoggingServerConnectionError",e.QUALITY_TEST_ERROR="QualityTestError",e.UNSUPPORTED_BROWSER="UnsupportedBrowser",e.SUBSCRIBER_GET_STATS_ERROR="SubscriberGetStatsError",e.MISSING_SUBSCRIBER_ERROR="MissingSubscriberError",e.PERMISSION_DENIED_ERROR="PermissionDeniedError",e.UNSUPPORTED_RESOLUTION_ERROR="UnsupportedResolutionError"}(o||(t.ErrorNames=o={})),function(e){e.JS_EXCEPTION="JS_EXCEPTION",e.OT_AUTHENTICATION_ERROR="OT_AUTHENTICATION_ERROR",e.OT_INVALID_HTTP_STATUS="OT_INVALID_HTTP_STATUS",e.OT_CONNECT_FAILED="OT_CONNECT_FAILED",e.OT_INVALID_SESSION_ID="OT_INVALID_SESSION_ID",e.CONNECT_FAILED="CONNECT_FAILED",e.CONNECT_REJECTED="CONNECT_REJECTED",e.CONNECTION_TIMEOUT="CONNECTION_TIMEOUT",e.NOT_CONNECTED="NOT_CONNECTED",e.INVALID_PARAMETER="INVALID_PARAMETER",e.P2P_CONNECTION_FAILED="P2P_CONNECTION_FAILED",e.API_RESPONSE_FAILURE="API_RESPONSE_FAILURE",e.TERMS_OF_SERVICE_FAILURE="TERMS_OF_SERVICE_FAILURE",e.CONNECTION_LIMIT_EXCEEDED="CONNECTION_LIMIT_EXCEEDED",e.UNABLE_TO_PUBLISH="UNABLE_TO_PUBLISH",e.UNABLE_TO_SUBSCRIBE="UNABLE_TO_SUBSCRIBE",e.UNSUPPORTED_VIDEO_CODEC="UNSUPPORTED_VIDEO_CODEC",e.UNABLE_TO_FORCE_DISCONNECT="UNABLE_TO_FORCE_DISCONNECT",e.UNABLE_TO_FORCE_UNPUBLISH="UNABLE_TO_FORCE_UNPUBLISH",e.PUBLISHER_ICE_WORKFLOW_FAILED="PUBLISHER_ICE_WORKFLOW_FAILED",e.SUBSCRIBER_ICE_WORKFLOW_FAILED="SUBSCRIBER_ICE_WORKFLOW_FAILED",e.STREAM_LIMIT_EXCEEDED="STREAM_LIMIT_EXCEEDED",e.UNEXPECTED_SERVER_RESPONSE="UNEXPECTED_SERVER_RESPONSE",e.REPORT_ISSUE_ERROR="REPORT_ISSUE_ERROR",e.ANVIL_BADLY_FORMED_RESPONSE="ANVIL_BADLY_FORMED_RESPONSE",e.ANVIL_INVALID_HTTP_STATUS="ANVIL_INVALID_HTTP_STATUS",e.ANVIL_XDOMAIN_OR_PARSING_ERROR="ANVIL_XDOMAIN_OR_PARSING_ERROR",e.ANVIL_UNKNOWN_HTTP_ERROR="ANVIL_UNKNOWN_HTTP_ERROR",e.ANVIL_UNEXPECTED_ERROR_CODE="ANVIL_UNEXPECTED_ERROR_CODE",e.ANVIL_EMPTY_RESPONSE_BODY="ANVIL_EMPTY_RESPONSE_BODY",e.ANVIL_CONNECT_FAILED="ANVIL_CONNECT_FAILED"}(s||(t.OTErrorType=s={}));t.errorHasName=(e=null,t)=>(0,n.get)("name",e)===t},312:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LoggingServerConnectionError=t.SubscribeToSessionError=t.PublishToSessionNetworkError=t.PublishToSessionPermissionOrTimeoutError=t.PublishToSessionNotConnectedError=t.FailedToCreateLocalPublisher=t.FailedMessagingServerTestError=t.PublishToSessionError=t.NoAudioCaptureDevicesError=t.NoVideoCaptureDevicesError=t.FailedToObtainMediaDevices=t.MediaDeviceError=t.ConnectToSessionNetworkError=t.ConnectToSessionSessionIdError=t.ConnectToSessionTokenError=t.ConnectToSessionError=t.APIConnectivityError=t.ConnectivityError=void 0;const n=r(430),o=r(287);class s extends n.NetworkTestError{constructor(e,t){super(e,t||o.ErrorNames.CONNECTIVITY_ERROR)}}t.ConnectivityError=s;t.APIConnectivityError=class extends s{constructor(){super("Failed to connect to OpenTOK API Server",o.ErrorNames.API_CONNECTIVITY_ERROR)}};class i extends s{constructor(e,t){super(e||"Failed to connect to the session due to a network error.",t||o.ErrorNames.CONNECT_TO_SESSION_ERROR)}}t.ConnectToSessionError=i;t.ConnectToSessionTokenError=class extends i{constructor(){super("Failed to connect to the session due to an invalid token.",o.ErrorNames.CONNECT_TO_SESSION_TOKEN_ERROR)}};t.ConnectToSessionSessionIdError=class extends i{constructor(){super("Failed to connect to the session due to an invalid session ID.",o.ErrorNames.CONNECT_TO_SESSION_ID_ERROR)}};t.ConnectToSessionNetworkError=class extends i{constructor(){super("Failed to connect to the session due to a network error.",o.ErrorNames.CONNECT_TO_SESSION_NETWORK_ERROR)}};class a extends s{constructor(e,t){super(e||"OpenTok failed to find media devices for this browser.",t||o.ErrorNames.MEDIA_DEVICE_ERROR)}}t.MediaDeviceError=a;t.FailedToObtainMediaDevices=class extends a{constructor(){super("Failed to obtain media devices.",o.ErrorNames.FAILED_TO_OBTAIN_MEDIA_DEVICES)}};t.NoVideoCaptureDevicesError=class extends a{constructor(){super("This browser has no video capture devices",o.ErrorNames.NO_VIDEO_CAPTURE_DEVICES)}};t.NoAudioCaptureDevicesError=class extends a{constructor(){super("This browser has no audio capture devices.",o.ErrorNames.NO_AUDIO_CAPTURE_DEVICES)}};class c extends s{constructor(e,t){super(e||"Encountered an unknown error while attempting to publish to a session.",t||o.ErrorNames.PUBLISH_TO_SESSION_ERROR)}}t.PublishToSessionError=c;t.FailedMessagingServerTestError=class extends c{constructor(){super("Failed to connect to media server due to messaging server connection failure",o.ErrorNames.FAILED_MESSAGING_SERVER_TEST)}};t.FailedToCreateLocalPublisher=class extends c{constructor(){super("Failed to create a local publisher object.",o.ErrorNames.FAILED_TO_CREATE_LOCAL_PUBLISHER)}};t.PublishToSessionNotConnectedError=class extends c{constructor(){super("Precall failed to publish to the session because it was not connected.",o.ErrorNames.PUBLISH_TO_SESSION_NOT_CONNECTED)}};t.PublishToSessionPermissionOrTimeoutError=class extends c{constructor(){super("Precall failed to publish to the session due a permissions error or timeout.",o.ErrorNames.PUBLISH_TO_SESSION_PERMISSION_OR_TIMEOUT_ERROR)}};t.PublishToSessionNetworkError=class extends c{constructor(){super("Precall failed to publish to the session due a network error.",o.ErrorNames.PUBLISH_TO_SESSION_NETWORK_ERROR)}};t.SubscribeToSessionError=class extends s{constructor(e){super(e||"Encountered an unknown error while attempting to subscribe to a session.",o.ErrorNames.SUBSCRIBE_TO_SESSION_ERROR)}};t.LoggingServerConnectionError=class extends s{constructor(){super("Failed to connect to the OpenTok logging server.",o.ErrorNames.LOGGING_SERVER_CONNECTION_ERROR)}}},78:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mapErrors=t.FailureType=void 0;const n=r(287);var o;!function(e){e.Api="api",e.Messaging="messaging",e.OpentokJs="OpenTok.js",e.Media="media",e.Logging="logging",e.ConnectivityError="OpenTok.js"}(o||(t.FailureType=o={}));const s=e=>({error:e,type:(()=>{switch(e.name){case n.ErrorNames.API_CONNECTIVITY_ERROR:case n.ErrorNames.CONNECT_TO_SESSION_NETWORK_ERROR:return o.Api;case n.ErrorNames.CONNECT_TO_SESSION_ERROR:case n.ErrorNames.CONNECT_TO_SESSION_TOKEN_ERROR:case n.ErrorNames.CONNECT_TO_SESSION_ID_ERROR:return o.Messaging;case n.ErrorNames.MEDIA_DEVICE_ERROR:case n.ErrorNames.FAILED_TO_OBTAIN_MEDIA_DEVICES:case n.ErrorNames.NO_VIDEO_CAPTURE_DEVICES:case n.ErrorNames.NO_AUDIO_CAPTURE_DEVICES:case n.ErrorNames.FAILED_TO_CREATE_LOCAL_PUBLISHER:case n.ErrorNames.PUBLISH_TO_SESSION_NOT_CONNECTED:case n.ErrorNames.PUBLISH_TO_SESSION_PERMISSION_OR_TIMEOUT_ERROR:case n.ErrorNames.PUBLISH_TO_SESSION_NETWORK_ERROR:return o.OpentokJs;case n.ErrorNames.PUBLISH_TO_SESSION_ERROR:case n.ErrorNames.SUBSCRIBE_TO_SESSION_ERROR:case n.ErrorNames.FAILED_MESSAGING_SERVER_TEST:return o.Media;case n.ErrorNames.LOGGING_SERVER_CONNECTION_ERROR:return o.Logging;default:return o.OpentokJs}})()});t.mapErrors=(...e)=>e.map(s)},914:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.testConnectivity=function(e,t,r,n){return new o((c=>{(function(e,{apiKey:t,sessionId:r,token:n},a){return new o(((o,c)=>{let u={};a&&a.initSessionOptions&&(u=a.initSessionOptions),a&&a.proxyServerUrl&&(e.hasOwnProperty("setProxyUrl")||(u.proxyUrl=a.proxyServerUrl));const l=e.initSession(t,r,u);l.connect(n,(e=>{(0,i.errorHasName)(e,i.OTErrorType.OT_AUTHENTICATION_ERROR)?c(new s.ConnectToSessionTokenError):(0,i.errorHasName)(e,i.OTErrorType.OT_INVALID_SESSION_ID)?c(new s.ConnectToSessionSessionIdError):(0,i.errorHasName)(e,i.OTErrorType.OT_CONNECT_FAILED)?c(new s.ConnectToSessionNetworkError):(0,i.errorHasName)(e,i.OTErrorType.OT_INVALID_HTTP_STATUS)?c(new s.APIConnectivityError):e?c(new s.ConnectToSessionError):o(l)}))}))})(e,t,n).then((t=>function(e,t,r){return new o(((n,a)=>{const c=e=>{u(t).then((()=>{a(e)}))};(function(e,t){return new o(((r,n)=>{(function(e){return new o(((t,r)=>{e.getDevices(((e,n=[])=>{if(e)r(new s.FailedToObtainMediaDevices);else{const e=n.reduce(((e,t)=>{const r="audioInput"===t.kind?"audio":"video";return Object.assign(Object.assign({},e),{[r]:Object.assign(Object.assign({},e[r]),{[t.deviceId]:t})})}),{audio:{},video:{}});Object.keys(e.audio).length||Object.keys(e.video).length?t(e):r(new s.FailedToObtainMediaDevices)}}))}))})(e).then((o=>{const i=document.createElement("div");i.style.position="fixed",i.style.bottom="-1px",i.style.width="1px",i.style.height="1px",i.style.opacity="0.01",document.body.appendChild(i);const a={width:"100%",height:"100%",insertMode:"append",showControls:!1,scalableVideo:!1};t&&t.audioSource&&(a.audioSource=t.audioSource),t&&t.videoSource&&(a.videoSource=t.videoSource),t&&t.audioOnly&&(a.videoSource=null),Object.keys(o.audio).length||(a.audioSource=null),Object.keys(o.video).length||(a.videoSource=null),t&&t.scalableVideo&&(a.scalableVideo=t.scalableVideo);const c=e.initPublisher(i,a,(e=>{e?n(new s.FailedToCreateLocalPublisher):r({publisher:c})}));c.on("streamCreated",(()=>{i.style.visibility="hidden"}))})).catch(n)}))})(e,r).then((({publisher:e})=>{t.publish(e,(r=>{r?(0,i.errorHasName)(r,i.OTErrorType.NOT_CONNECTED)?c(new s.PublishToSessionNotConnectedError):(0,i.errorHasName)(r,i.OTErrorType.UNABLE_TO_PUBLISH)?c(new s.PublishToSessionPermissionOrTimeoutError):r&&c(new s.PublishToSessionError):n(Object.assign({session:t},{publisher:e}))}))})).catch((e=>{c(e)}))}))}(e,t,n))).then(d).then((t=>f(e,n,t))).then((e=>{const t={success:!0,failedTests:[]};return r.logEvent({action:"testConnectivity",variation:"Success"}),(n=e.session,s=e.subscriber,new o((e=>{s.on("destroyed",(()=>{e()})),s||e(),n.unsubscribe(s)}))).then((()=>l(e.publisher))).then((()=>u(e.session))).then((()=>c(t)));var n,s})).catch((t=>{const o=(...e)=>{const t=(0,a.mapErrors)(...e),n=t.find((e=>"messaging"===e.type)),o={failedTests:[...t,...n?(0,a.mapErrors)(new s.FailedMessagingServerTestError):[]],success:!1};r.logEvent({action:"testConnectivity",variation:"Success"}),c(o)};"LoggingServerConnectionError"===t.name?o(t):f(e,n).then((()=>o(t))).catch((e=>o(t,e)))}))}))};const n=r(425),o=r(918),s=r(312),i=r(287),a=r(78),c=r(729);function u(e){return new o((t=>{e.on("sessionDisconnected",(()=>{e.off(),t()})),e.disconnect()}))}function l(e){return new o((t=>{e.on("destroyed",(()=>{t()})),e||t(),e.destroy()}))}function d({session:e,publisher:t}){return new o(((r,n)=>{const o={testNetwork:!0,audioVolume:0},i=r=>{l(t).then((()=>u(e))).then((()=>{n(r)}))};if(t.stream){const n=document.createElement("div"),a=e.subscribe(t.stream,n,o,(n=>{n?i(new s.SubscribeToSessionError):r(Object.assign(Object.assign({session:e},{publisher:t}),{subscriber:a}))}))}else i(new s.SubscribeToSessionError)}))}function f(e,t,r){return new o(((o,i)=>{const a=`${(0,c.getOr)("","properties.loggingURL",e)}/logging/ClientEvent`,u=t&&t.proxyServerUrl&&`${t.proxyServerUrl}/${a.replace("https://","")}`||a,l=()=>i(new s.LoggingServerConnectionError);n.default.post(u).then((e=>200===e.status?o(r):l())).catch(l)}))}},672:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MissingSubscriberError=t.SubscriberGetStatsError=t.SubscribeToSessionError=t.PublishToSessionPermissionOrTimeoutError=t.PublishToSessionNotConnectedError=t.InitPublisherError=t.PublishToSessionError=t.NoAudioCaptureDevicesError=t.NoVideoCaptureDevicesError=t.FailedToObtainMediaDevices=t.MediaDeviceError=t.ConnectToSessionNetworkError=t.ConnectToSessionSessionIdError=t.ConnectToSessionTokenError=t.ConnectToSessionError=t.UnsupportedBrowserError=t.QualityTestError=void 0;const n=r(430),o=r(287);class s extends n.NetworkTestError{constructor(e,t){super(e,t||o.ErrorNames.QUALITY_TEST_ERROR)}}t.QualityTestError=s;t.UnsupportedBrowserError=class extends s{constructor(e){super(`Your current browser (${e}) does not support the audio-video quality test. Please run the test in a supported browser.`,o.ErrorNames.UNSUPPORTED_BROWSER)}};class i extends s{constructor(e,t){super(e||"Failed to connect to the session due to a network error.",t||o.ErrorNames.CONNECT_TO_SESSION_ERROR)}}t.ConnectToSessionError=i;t.ConnectToSessionTokenError=class extends i{constructor(){super("Failed to connect to the session due to an invalid token.",o.ErrorNames.CONNECT_TO_SESSION_TOKEN_ERROR)}};t.ConnectToSessionSessionIdError=class extends i{constructor(){super("Failed to connect to the session due to an invalid session ID.",o.ErrorNames.CONNECT_TO_SESSION_ID_ERROR)}};t.ConnectToSessionNetworkError=class extends i{constructor(){super("Failed to connect to the session due to a network error.",o.ErrorNames.CONNECT_TO_SESSION_NETWORK_ERROR)}};t.MediaDeviceError=class extends s{constructor(e,t){super(e||"OpenTok failed to find media devices for this browser.",t||o.ErrorNames.MEDIA_DEVICE_ERROR)}};t.FailedToObtainMediaDevices=class extends s{constructor(){super("Failed to obtain media devices.",o.ErrorNames.FAILED_TO_OBTAIN_MEDIA_DEVICES)}};t.NoVideoCaptureDevicesError=class extends s{constructor(){super("This browser has no video capture devices",o.ErrorNames.NO_VIDEO_CAPTURE_DEVICES)}};t.NoAudioCaptureDevicesError=class extends s{constructor(){super("This browser has no audio capture devices.",o.ErrorNames.NO_AUDIO_CAPTURE_DEVICES)}};class a extends s{constructor(e,t){super(e||"Encountered an unknown error while attempting to publish to a session.",t||o.ErrorNames.PUBLISH_TO_SESSION_ERROR)}}t.PublishToSessionError=a;t.InitPublisherError=class extends a{constructor(e){super(e||"Failed to initialize publisher.",o.ErrorNames.INIT_PUBLISHER_ERROR)}};t.PublishToSessionNotConnectedError=class extends a{constructor(){super("Precall failed to publish to the session because it was not connected.",o.ErrorNames.PUBLISH_TO_SESSION_NOT_CONNECTED)}};t.PublishToSessionPermissionOrTimeoutError=class extends a{constructor(){super("Precall failed to publish to the session due a permissions error or timeout.",o.ErrorNames.PUBLISH_TO_SESSION_PERMISSION_OR_TIMEOUT_ERROR)}};class c extends s{constructor(e,t){super(e||"Encountered an unknown error while attempting to publish to a session.",t||o.ErrorNames.SUBSCRIBE_TO_SESSION_ERROR)}}t.SubscribeToSessionError=c;t.SubscriberGetStatsError=class extends c{constructor(){super("Failed to get network stats for a subscriber.",o.ErrorNames.SUBSCRIBER_GET_STATS_ERROR)}};t.MissingSubscriberError=class extends c{constructor(){super("Call checkSubscribeToSession before calling checkSubscriberQuality.",o.ErrorNames.MISSING_SUBSCRIBER_ERROR)}}},588:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class r{constructor(e){this.stats={audio:{},video:{}},this.bandwidth={audio:0,video:0},this.hasAudioTrack=()=>this.subscriberStatsLog[0]&&!!this.subscriberStatsLog[0].audio,this.hasVideoTrack=()=>this.subscriberStatsLog[0]&&!!this.subscriberStatsLog[0].video,this.getLastPublisherStats=()=>{var e;return null!==(e=this.publisherStatsLog[this.publisherStatsLog.length-1])&&void 0!==e?e:void 0},this.subscriberStatsLog=[],this.publisherStatsLog=[],this.audioScoresLog=[],this.videoScoresLog=[],this.audioOnlyFallback=!!e}audioScore(){return this.audioScoresLog.reduce(((e,t)=>e+t),0)/this.audioScoresLog.length}videoScore(){return this.videoScoresLog.reduce(((e,t)=>e+t),0)/this.videoScoresLog.length}clearInterval(){this.intervalId&&window.clearInterval(this.intervalId),this.intervalId=void 0}pruneAudioScores(){const e=this.audioScoresLog;for(;e.length>r.maxLogLength;)e.shift();this.audioScoresLog=e}pruneVideoScores(){const e=this.videoScoresLog;for(;e.length>r.maxLogLength;)e.shift();this.videoScoresLog=e}pruneScores(){this.pruneAudioScores(),this.pruneVideoScores()}audioQualityScore(){return this.hasAudioTrack()?this.audioScore():1}videoQualityScore(){return this.hasVideoTrack()?this.videoScore():1}}r.maxLogLength=1e3,r.scoreInterval=1e3,t.default=r},676:(e,t)=>{function r(e,t){const r=[];for(let n=1;n<t.length;n+=1){const o=t[n],s=t[n-1];if(o[e]&&s[e]){const t=8*(o[e].bytesReceived?o[e].bytesReceived-s[e].bytesReceived:0)/((o.timestamp-s.timestamp)/1e3),n=o[e].packetsReceived,i=o[e].packetsLost,a=i+n;let c=0;a>0&&i>0&&(c=i/a);const u="video"===e?{frameRate:o[e].frameRate}:{};r.push(Object.assign({averageBitrate:t,packetLossRatio:c},u))}}return r}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){if(e.length<2)throw new Error("Cannot calculate bitrate with less than two data points.");return{audio:r("audio",e),video:r("video",e)}}},358:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){const t=(0,n.default)(e.publisherStatsLog),r=(0,o.default)(e.subscriberStatsLog);return{audio:e.hasAudioTrack()?c("audio",r.audio,t):{supported:!1,reason:i.default.strings.noMic},video:e.audioOnlyFallback?{supported:!1,reason:i.default.strings.bandwidthLow}:e.hasVideoTrack()?c("video",r.video,t):{supported:!1,reason:i.default.strings.noCam}}};const n=r(549),o=r(676),s=r(122),i=r(908),a=r(729);function c(e,t,r){var n;let o=0,i=0,c=0;r.forEach((t=>{i+=0,o+="video"===e?1e3*t.videoKbsSent:1e3*t.audioStats[0].kbs})),t.forEach((t=>{i+=t.packetLossRatio,"video"===e&&(c+=Number((0,a.getOr)(0,"frameRate",t)))}));const u=r.some((e=>e.simulcastEnabled)),l=(null===(n=r[r.length-1].videoStats.find((e=>null!==e.qualityLimitationReason&&"none"!==e.qualityLimitationReason)))||void 0===n?void 0:n.qualityLimitationReason)||null,d={availableOutgoingBitrate:r[r.length-1].availableOutgoingBitrate,simulcast:u,bitrate:o/r.length,packetLossRatio:i/t.length};if("video"===e){const{supported:r,reason:n,recommendedResolution:o,recommendedFrameRate:i}=(0,s.default)(d),a="video"===e?{recommendedResolution:o,recommendedFrameRate:i,frameRate:c/t.length}:{};return Object.assign(Object.assign(Object.assign({},d),{supported:r,reason:n,qualityLimitationReason:l}),a)}return Object.assign({},d)}},908:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.default={getStatsInterval:1e3,getStatsVideoAndAudioTestDuration:3e4,getStatsAudioOnlyDuration:1e4,subscribeOptions:{testNetwork:!0,audioVolume:0},minimumVideoAndAudioTestSampleSize:5,steadyStateSampleWindow:5e3,steadyStateAllowedDelta:.05,thresholdRatio:.75,qualityThresholds:{video:[{targetBitrate:4e6,targetBitrateSimulcast:555e4,recommendedSetting:"1920x1080 @ 30FPS"},{targetBitrate:25e5,targetBitrateSimulcast:315e4,recommendedSetting:"1280x720 @ 30FPS"},{targetBitrate:12e5,targetBitrateSimulcast:155e4,recommendedSetting:"960x540 @ 30FPS"},{targetBitrate:5e5,targetBitrateSimulcast:65e4,recommendedSetting:"640x360 @ 30FPS"},{targetBitrate:3e5,targetBitrateSimulcast:35e4,recommendedSetting:"480x270 @ 30FPS"},{targetBitrate:15e4,targetBitrateSimulcast:15e4,recommendedSetting:"320x180 @ 30FPS"}],audio:[{minMos:2.4}]},strings:{bandwidthLow:"Bandwidth too low.",noCam:"No camera was found.",noMic:"No microphone was found."}}},549:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){const t=(0,o.getOr)(0,"timestamp",(0,o.last)(e))-n.default.steadyStateSampleWindow;return e.filter((e=>e.timestamp>=t))};const n=r(908),o=r(729)},38:function(e,t){var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getPublisherStats=function(e,t){return r(this,void 0,void 0,(function*(){if("function"!=typeof e.getRtcStatsReport)return null;try{const r=yield e.getRtcStatsReport();return s(r,t)}catch(e){return null}}))};const n=(e,t)=>{const r=null==t?void 0:t.audioStats[0];if(!r)return 0;const{currentTimestamp:n,byteSent:o}=r,s=e.bytesSent-o,i=(e.timestamp-n)/1e3;return Math.round(8*s/(1e3*i))},o=(e,t)=>{const r=null==t?void 0:t.videoStats.find((t=>t.ssrc===e.ssrc));if(!r)return 0;const{currentTimestamp:n,byteSent:o}=r,s=e.bytesSent-o,i=(e.timestamp-n)/1e3;return Math.round(8*s/(1e3*i))},s=(e,t)=>{if(!e)return null;const{rtcStatsReport:r}=e[0],s=Array.from(r.values()),i=s.filter((e=>"outbound-rtp"===e.type)),a=s.find((e=>"candidate-pair"===e.type&&e.nominated)),c=(u="local-candidate",l=a.localCandidateId,s.find((e=>e.type===u&&e.id===l)));var u,l;const{videoStats:d,audioStats:f}=((e,t)=>{const r=[],s=[];for(const i of e)if("video"===i.kind||"video"===i.mediaType){const e=o(i,t),{ssrc:n,bytesSent:s,timestamp:a}=i,c={kbs:e,ssrc:n,byteSent:s,currentTimestamp:a};r.push(Object.assign(Object.assign({},c),{qualityLimitationReason:i.qualityLimitationReason,resolution:`${i.frameWidth||0}x${i.frameHeight||0}`,framerate:i.framesPerSecond||0,active:i.active||!1,pliCount:i.pliCount||0,nackCount:i.nackCount||0}))}else if("audio"===i.kind||"audio"===i.mediaType){const e=n(i,t),{ssrc:r,bytesSent:o,timestamp:a}=i,c={kbs:e,ssrc:r,byteSent:o,currentTimestamp:a};s.push(c)}return{videoStats:r,audioStats:s}})(i,t),p=(null==a?void 0:a.availableOutgoingBitrate)||-1,h=(null==a?void 0:a.currentRoundTripTime)||-1,E=d.reduce(((e,t)=>e+t.kbs),0),S=d.reduce(((e,t)=>e+t.byteSent),0);return{videoStats:d,audioStats:f,availableOutgoingBitrate:p,videoByteSent:S,videoKbsSent:E,simulcastEnabled:d.length>1,transportProtocol:(null==c?void 0:c.protocol)||"N/A",currentRoundTripTime:h,timestamp:(null==c?void 0:c.timestamp)||0}}},887:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.default=(e,t,r)=>{const{audio:n,video:o}=e,s={bytesSent:t.audioStats[0].byteSent,bytesReceived:n.bytesReceived,packetsLost:n.packetsLost,packetsReceived:n.packetsReceived};let i=null;return"audio-video"===r&&(i={bytesSent:t.videoByteSent,bytesReceived:(null==o?void 0:o.bytesReceived)||0,packetsLost:(null==o?void 0:o.packetsLost)||0,packetsReceived:(null==o?void 0:o.packetsReceived)||0,frameRate:(null==o?void 0:o.frameRate)||0}),{phase:r,audio:s,video:i,timestamp:e.timestamp}}},122:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){const t=n.default.qualityThresholds.video,r=n.default.thresholdRatio,s=e.availableOutgoingBitrate;let i,a=!1,c=30,u="";for(let n=0;n<t.length;n+=1){const l=t[n];if(s>=(e.simulcast?l.targetBitrateSimulcast:l.targetBitrate)*r){a=!0,i=(0,o.get)("recommendedSetting",l),c=Number(i.substring(i.indexOf("@")+1).replace("FPS","")),u=i.substring(0,i.indexOf("@")-1);break}}const l={supported:a,recommendedFrameRate:c,recommendedResolution:u};a?(l.recommendedFrameRate=c,l.recommendedResolution=u):l.reason=n.default.strings.bandwidthLow;return l};const n=r(908),o=r(729)},998:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){const t=(0,n.default)(e);let r=!0;if(t.length<o.default.minimumVideoAndAudioTestSampleSize)return!1;for(const[e,n]of t.entries()){if(0===e)continue;const s=t[e-1];if(n.videoKbsSent>0){const e=n.videoKbsSent,t=s.videoKbsSent;e-t>t*o.default.steadyStateAllowedDelta&&(r=!1)}const i=n.audioStats[0].kbs,a=s.audioStats[0].kbs;i-a>a*o.default.steadyStateAllowedDelta&&(r=!1)}return r};const n=r(549),o=r(908)},684:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){const e=function(){const e=window&&window.navigator;if("undefined"==typeof window||!window.navigator)return"not a browser";if((0,n.get)("mozGetUserMedia",e))return"Firefox";if((0,n.get)("webkitGetUserMedia",e))return window.hasOwnProperty("webkitRTCPeerConnection")?e.userAgent.match(/Edg/)?"Edge":e.userAgent.match(/Opera|OPR\//)?"Opera":"Chrome":e.userAgent.match(/Version\/(\d+).(\d+)/)?"Safari":"WebKit browser without WebRTC support";if(e.mediaDevices&&e.userAgent.match(/Edge\/(\d+).(\d+)$/))return"non-Chromium Edge";if(e.userAgent.indexOf("MSIE ")>0||e.userAgent.match(/Trident.*rv:11\./))return"Internet Explorer";if(e.mediaDevices&&e.userAgent.match(/AppleWebKit\/(\d+)\./))return"Safari";return"unsupported browser"}(),t=["Chrome","Safari","Edge","Opera"].indexOf(e)>-1;return{browser:e,supported:t}};const n=r(729)},559:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,s){function i(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,l,h){return e.intervalId=window.setInterval((()=>{t.getStats(((i,E)=>n(this,void 0,void 0,(function*(){if(!E)return null;if(E.audio.bytesReceived<0||Number((0,a.getOr)(1,"video.bytesReceived",E))<0)return e.clearInterval(),h(e);const n=yield(0,c.getPublisherStats)(r,e.getLastPublisherStats());if(E&&e.subscriberStatsLog.push(E),n&&e.publisherStatsLog.push(n),l&&"function"==typeof l&&l(i,E,n),e.publisherStatsLog.length&&e.publisherStatsLog.length>=2){e.stats=(0,s.default)(e);const r=function(e,t){const r=3e4,n=e=>{const t=2.069924867*Math.pow(Math.log10(e),.6250223771);return Math.pow(10,t)},o=(0,a.last)(t),s=(0,a.nth)(-2,t);if(!o||!s||!e.stream)return 1;const i=f("video",o,s),c=e.stream.videoDimensions.width*e.stream.videoDimensions.height,u=n(c);if(i<r)return 1;const l=Math.min(i,u);let d=Math.log(l/r)/Math.log(u/r)*4+1;return d=Math.min(d,4.5),d}(t,e.subscriberStatsLog);e.videoScoresLog.push(r);const n=function(e,t,r){const n=()=>p,o=e=>{const t=30,r=e=>e<0?0:1,o=0,s=19.8,i=29.7,a=n();return(e=>e<0?1:e>100?4.5:1+.035*e+e*(e-60)*(100-e)*7e-6)((()=>{const n=a+t;return 93.2-(.024*n+.11*(n-177.3)*r(n-177.3))-(o+s*Math.log(1+i*e))})())},s=(0,a.last)(r),i=(0,a.nth)(-2,r);if(!s||!i||!e.stream)return 1;const c=d("audio",s,i);if(0===c)return 1;let l=(u(s.audio)-u(i.audio))/c;l<0&&(l=0);return o(l)}(t,0,e.subscriberStatsLog);if(e.audioScoresLog.push(n),e.pruneScores(),(0,o.default)(e.publisherStatsLog))return e.clearInterval(),h(e)}return null}))))}),i.default.scoreInterval),t.on("destroyed",e.clearInterval.bind(e)),r.on("destroyed",e.clearInterval.bind(e)),e};const o=r(998),s=r(358),i=r(588),a=r(729),c=r(38),u=e=>(0,a.getOr)(0,"packetsLost",e),l=e=>u(e)+(e=>(0,a.getOr)(0,"packetsReceived",e))(e),d=(e,t,r)=>l(t[e])-l(r[e]),f=(e,t,r)=>{const n=t.timestamp-r.timestamp;return t[e]&&t[e].bytesReceived?8*(t[e].bytesReceived-r[e].bytesReceived)/(n/1e3):0},p=150},858:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.testQuality=function(e,t,r,o,i){return T=!1,y=!1,new n(((a,c)=>{b=!(!o||!o.audioOnly),m=b?u.default.getStatsAudioOnlyDuration:u.default.getStatsVideoAndAudioTestDuration,o&&o.timeout&&(m=Math.min(m,o.timeout,3e4));const d=e=>{O=void 0,r.logEvent({action:"testQuality",variation:"Success"}),a(e)},f=e=>{O=void 0,r.logEvent({action:"testQuality",variation:"Failure"}),c(e)};new n(((e,t)=>{const{supported:r,browser:n}=(0,l.default)();return r?e():t(new s.UnsupportedBrowserError(n))})).then((()=>{let r={};o&&o.initSessionOptions&&(r=o.initSessionOptions),o&&o.proxyServerUrl&&(e.hasOwnProperty("setProxyUrl")||(r.proxyUrl=o.proxyServerUrl));const n=e.initSession(t.apiKey,t.sessionId,r);v(e,n,t,o,i).then(d).catch(f)})).catch(f)}))},t.stopQualityTest=function(){y=!0,T&&O&&O()};const n=r(918),o=r(729),s=r(672),i=r(287),a=r(559),c=r(588),u=r(908),l=r(684),d=r(887),f=r(430),p=1920,h=1080,E="1920x1080",S="1280x720";let m,O,g,b=!1,T=!1,y=!1;function _(e,t){return new n(((r,o)=>{e.getDevices(((e,i=[])=>{if(e)return void o(new s.FailedToObtainMediaDevices);const a=i.reduce(((e,t)=>{const r="audioInput"===t.kind?"audio":"video";return Object.assign(Object.assign({},e),{[r]:Object.assign(Object.assign({},e[r]),{[t.deviceId]:t})})}),{audio:{},video:{}});var c,u;Object.keys(a.audio).length?(null==t?void 0:t.fullHd)?(c=p,u=h,new n(((e,t)=>{navigator.mediaDevices.getUserMedia({video:{width:{exact:c},height:{exact:u}},audio:!1}).then((t=>{t&&e()})).catch((e=>{switch(e.name){case"OverconstrainedError":t(new f.UnsupportedResolutionError);break;case"NotAllowedError":t(new f.PermissionDeniedError);break;default:t(e)}}))}))).then((()=>r(a))).catch(o):r(a):o(new s.NoAudioCaptureDevicesError)}))}))}function R(e,t,r,o){return new n(((a,c)=>{(function(e,t){return new n(((r,n)=>{e.connection?r(e):e.connect(t,(t=>{t&&((0,i.errorHasName)(t,i.OTErrorType.OT_AUTHENTICATION_ERROR)?n(new s.ConnectToSessionTokenError):(0,i.errorHasName)(t,i.OTErrorType.OT_INVALID_SESSION_ID)?n(new s.ConnectToSessionSessionIdError):(0,i.errorHasName)(t,i.OTErrorType.OT_CONNECT_FAILED)?n(new s.ConnectToSessionNetworkError):n(new s.ConnectToSessionError)),r(e)}))}))})(t,r.token).then(function(e,t){return r=>new n(((n,o)=>{const a=document.createElement("div");a.style.position="fixed",a.style.bottom="-1px",a.style.width="1px",a.style.height="1px",a.style.opacity="0",document.body.appendChild(a),_(e,t).then((c=>{Object.keys(c.video).length||(b=!0);const u={resolution:(null==t?void 0:t.fullHd)?E:S,scalableVideo:null==t?void 0:t.scalableVideo,width:"100%",height:"100%",insertMode:"append",showControls:!1};t&&t.audioSource&&(u.audioSource=t.audioSource),t&&t.videoSource&&(u.videoSource=t.videoSource),b&&(u.videoSource=null);const l=e.initPublisher(a,u,(e=>{e?o(new s.InitPublisherError(e.message)):r.publish(l,(e=>{if(e)return(0,i.errorHasName)(e,i.OTErrorType.NOT_CONNECTED)?o(new s.PublishToSessionNotConnectedError):(0,i.errorHasName)(e,i.OTErrorType.UNABLE_TO_PUBLISH)?o(new s.PublishToSessionPermissionOrTimeoutError):o(new s.PublishToSessionError)}))}));l.on("streamCreated",(e=>{const t=r.subscribe(e.stream,a,{testNetwork:!0,insertMode:"append",subscribeToAudio:!0,subscribeToVideo:!0},(e=>e?o(new s.SubscribeToSessionError(e.message)):n({publisher:l,subscriber:t})))}))})).catch(o)}))}(e,o)).then(a).catch(c)}))}function v(e,t,r,i,l,f){let p;return new n(((h,E)=>{R(e,t,r,i).then((({publisher:S,subscriber:_})=>{if(_)try{const s=Object.assign(Object.assign({state:new c.default(f)},{subscriber:_}),{credentials:r}),E=(e,t,r)=>{if(t&&r&&l){const e=(0,d.default)(t,r,b?"audio-only":"audio-video");l(e)}},R=()=>{const a=function(e){const t=["bitrate","packetLossRatio","supported","reason","mos"];return e.state.stats.audio.mos=e.state.audioQualityScore(),e.state.stats.video.mos=e.state.videoQualityScore(),e.state.stats.audio.mos>=u.default.qualityThresholds.audio[0].minMos?e.state.stats.audio.supported=!0:(e.state.stats.audio.supported=!1,e.state.stats.audio.reason=u.default.strings.bandwidthLow),{audio:(0,o.pick)(t,e.state.stats.audio),video:(0,o.pick)(t.concat(["frameRate","qualityLimitationReason","recommendedResolution","recommendedFrameRate"]),e.state.stats.video)}}(s);if(b||(c=a).audio.mos&&c.audio.mos>=u.default.qualityThresholds.audio[0].minMos||y)t.on("sessionDisconnected",(()=>{h(a),t.off()})),function(e,t){return new n((r=>{t.on("destroyed",(()=>{r()})),t||r(),e.unsubscribe(t)}))}(t,_).then((()=>function(e,t){return new n((r=>{t.on("destroyed",(()=>{r()})),t||r(),e.unpublish(t)}))}(t,S))).then((()=>t.disconnect()));else{b=!0;const n=a.video;v(e,t,r,i,l,!0).then((e=>{e.video=n,h(e)}))}var c};O=()=>{clearTimeout(p),R()};const N=()=>{clearTimeout(p),R()};(0,a.default)(s.state,_,S,E,N),p=window.setTimeout(R,m),window.clearTimeout(g),g=window.setTimeout((()=>{T=!0,y&&O&&O()}),5e3)}catch(e){E(new s.SubscriberGetStatsError)}else E(new s.MissingSubscriberError)})).catch(E)}))}},729:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.head=t.nth=t.last=t.pickAll=t.pick=t.getOr=t.get=t.assocPath=t.assoc=void 0;t.assoc=(e,t,r)=>Object.assign(Object.assign({},r),{[e]:t});t.assocPath=(e,r,n)=>{const o=e.split("."),s=o[0];if(!o.length)return n;if(1===o.length)return(0,t.assoc)(s,r,n);const i=(0,t.get)(s,n),a=i&&"object"==typeof i?i:i?Object.assign(Object.assign({},n),{[s]:{}}):n,c=(0,t.assoc)(s,(0,t.assocPath)(o.slice(1).join("."),r,(0,t.get)(s,a)),n);return Object.assign(Object.assign({},n),c)};t.get=(e,r)=>{if(!r)return r;const[n,...o]=e.split("."),s=r[n];return null==s?s:o.length?(0,t.get)(o.join("."),s):s};t.getOr=(e,r,n)=>(0,t.get)(r,n)||e;t.pick=(e,t,r=!1)=>e.reduce(((e,n)=>void 0!==t[n]||r?Object.assign(Object.assign({},e),{[n]:t[n]}):e),{});t.pickAll=(e,r)=>(0,t.pick)(e,r,!0);t.last=e=>e[e.length-1];t.nth=(e,t)=>e<0?t[t.length+e]:t[e];t.head=e=>(0,t.nth)(0,e)},425:(e,t,r)=>{function n(e,t){return function(){return e.apply(t,arguments)}}const{toString:o}=Object.prototype,{getPrototypeOf:s}=Object,i=(a=Object.create(null),e=>{const t=o.call(e);return a[t]||(a[t]=t.slice(8,-1).toLowerCase())});var a;const c=e=>(e=e.toLowerCase(),t=>i(t)===e),u=e=>t=>typeof t===e,{isArray:l}=Array,d=u("undefined");const f=c("ArrayBuffer");const p=u("string"),h=u("function"),E=u("number"),S=e=>null!==e&&"object"==typeof e,m=e=>{if("object"!==i(e))return!1;const t=s(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},O=c("Date"),g=c("File"),b=c("Blob"),T=c("FileList"),y=c("URLSearchParams"),[_,R,v,N]=["ReadableStream","Request","Response","Headers"].map(c);function w(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,o;if("object"!=typeof e&&(e=[e]),l(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{const o=r?Object.getOwnPropertyNames(e):Object.keys(e),s=o.length;let i;for(n=0;n<s;n++)i=o[n],t.call(null,e[i],i,e)}}function I(e,t){t=t.toLowerCase();const r=Object.keys(e);let n,o=r.length;for(;o-- >0;)if(n=r[o],t===n.toLowerCase())return n;return null}const C="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:r.g,A=e=>!d(e)&&e!==C;const P=(L="undefined"!=typeof Uint8Array&&s(Uint8Array),e=>L&&e instanceof L);var L;const D=c("HTMLFormElement"),U=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),x=c("RegExp"),k=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};w(r,((r,o)=>{let s;!1!==(s=t(r,o,e))&&(n[o]=s||r)})),Object.defineProperties(e,n)};const j=c("AsyncFunction"),F=(B="function"==typeof setImmediate,M=h(C.postMessage),B?setImmediate:M?(V=`axios@${Math.random()}`,H=[],C.addEventListener("message",(({source:e,data:t})=>{e===C&&t===V&&H.length&&H.shift()()}),!1),e=>{H.push(e),C.postMessage(V,"*")}):e=>setTimeout(e));var B,M,V,H;const q="undefined"!=typeof queueMicrotask?queueMicrotask.bind(C):"undefined"!=typeof process&&process.nextTick||F;var K={isArray:l,isArrayBuffer:f,isBuffer:function(e){return null!==e&&!d(e)&&null!==e.constructor&&!d(e.constructor)&&h(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||h(e.append)&&("formdata"===(t=i(e))||"object"===t&&h(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&f(e.buffer),t},isString:p,isNumber:E,isBoolean:e=>!0===e||!1===e,isObject:S,isPlainObject:m,isReadableStream:_,isRequest:R,isResponse:v,isHeaders:N,isUndefined:d,isDate:O,isFile:g,isBlob: